[DEV] update the change on 'enum' to 'enum class'

This commit is contained in:
Edouard DUPIN 2016-04-29 23:16:07 +02:00
parent 864f2939b3
commit 2b3f855485
5 changed files with 51 additions and 51 deletions

View File

@ -114,7 +114,7 @@ void interpolateCubicBezier(std::vector<esvg::render::Point>& _listPoint,
vec2 pos234 = (pos23+pos34)*0.5f; vec2 pos234 = (pos23+pos34)*0.5f;
vec2 pos1234 = (pos123+pos234)*0.5f; vec2 pos1234 = (pos123+pos234)*0.5f;
interpolateCubicBezier(_listPoint, _recurtionMax, _threshold, _pos1, pos12, pos123, pos1234, _level+1, esvg::render::Point::type_interpolation); interpolateCubicBezier(_listPoint, _recurtionMax, _threshold, _pos1, pos12, pos123, pos1234, _level+1, esvg::render::Point::type::interpolation);
interpolateCubicBezier(_listPoint, _recurtionMax, _threshold, pos1234, pos234, pos34, _pos4, _level+1, _type); interpolateCubicBezier(_listPoint, _recurtionMax, _threshold, pos1234, pos234, pos34, _pos4, _level+1, _type);
} }
@ -158,7 +158,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
ESVG_WARNING(spacingDist(_level+1) << " Request path close of not starting path ..."); ESVG_WARNING(spacingDist(_level+1) << " Request path close of not starting path ...");
} else { } else {
// find the previous tart of the path ... // find the previous tart of the path ...
tmpListPoint.front().m_type = esvg::render::Point::type_join; tmpListPoint.front().m_type = esvg::render::Point::type::join;
// Remove the last point if it is the same position... // Remove the last point if it is the same position...
vec2 delta = (tmpListPoint.front().m_pos - tmpListPoint.back().m_pos).absolute(); vec2 delta = (tmpListPoint.front().m_pos - tmpListPoint.back().m_pos).absolute();
if ( delta.x() <= 0.00001 if ( delta.x() <= 0.00001
@ -185,49 +185,49 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
lastPosition = vec2(0.0f, 0.0f); lastPosition = vec2(0.0f, 0.0f);
} }
lastPosition += it->getPos(); lastPosition += it->getPos();
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type_start)); tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
lastAngle = lastPosition; lastAngle = lastPosition;
break; break;
case esvg::render::path_lineTo: case esvg::render::path_lineTo:
// If no previous point, we need to create the last point has start ... // If no previous point, we need to create the last point has start ...
if (tmpListPoint.size() == 0) { if (tmpListPoint.size() == 0) {
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type_start)); tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
} }
if (it->getRelative() == false) { if (it->getRelative() == false) {
lastPosition = vec2(0.0f, 0.0f); lastPosition = vec2(0.0f, 0.0f);
} }
lastPosition += it->getPos(); lastPosition += it->getPos();
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type_join)); tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
lastAngle = lastPosition; lastAngle = lastPosition;
break; break;
case esvg::render::path_lineToH: case esvg::render::path_lineToH:
// If no previous point, we need to create the last point has start ... // If no previous point, we need to create the last point has start ...
if (tmpListPoint.size() == 0) { if (tmpListPoint.size() == 0) {
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type_start)); tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
} }
if (it->getRelative() == false) { if (it->getRelative() == false) {
lastPosition = vec2(0.0f, 0.0f); lastPosition = vec2(0.0f, 0.0f);
} }
lastPosition += it->getPos(); lastPosition += it->getPos();
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type_join)); tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
lastAngle = lastPosition; lastAngle = lastPosition;
break; break;
case esvg::render::path_lineToV: case esvg::render::path_lineToV:
// If no previous point, we need to create the last point has start ... // If no previous point, we need to create the last point has start ...
if (tmpListPoint.size() == 0) { if (tmpListPoint.size() == 0) {
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type_start)); tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::start));
} }
if (it->getRelative() == false) { if (it->getRelative() == false) {
lastPosition = vec2(0.0f, 0.0f); lastPosition = vec2(0.0f, 0.0f);
} }
lastPosition += it->getPos(); lastPosition += it->getPos();
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type_join)); tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
lastAngle = lastPosition; lastAngle = lastPosition;
break; break;
case esvg::render::path_curveTo: case esvg::render::path_curveTo:
// If no previous point, we need to create the last point has start ... // If no previous point, we need to create the last point has start ...
if (tmpListPoint.size() == 0) { if (tmpListPoint.size() == 0) {
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type_join)); tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
} }
{ {
vec2 lastPosStore(lastPosition); vec2 lastPosStore(lastPosition);
@ -245,7 +245,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
pos2, pos2,
pos, pos,
0, 0,
esvg::render::Point::type_join); esvg::render::Point::type::join);
lastPosition = pos; lastPosition = pos;
lastAngle = pos2; lastAngle = pos2;
} }
@ -253,7 +253,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
case esvg::render::path_smoothCurveTo: case esvg::render::path_smoothCurveTo:
// If no previous point, we need to create the last point has start ... // If no previous point, we need to create the last point has start ...
if (tmpListPoint.size() == 0) { if (tmpListPoint.size() == 0) {
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type_join)); tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
} }
{ {
vec2 lastPosStore(lastPosition); vec2 lastPosStore(lastPosition);
@ -272,7 +272,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
pos2, pos2,
pos, pos,
0, 0,
esvg::render::Point::type_join); esvg::render::Point::type::join);
lastPosition = pos; lastPosition = pos;
lastAngle = pos2; lastAngle = pos2;
} }
@ -280,7 +280,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
case esvg::render::path_bezierCurveTo: case esvg::render::path_bezierCurveTo:
// If no previous point, we need to create the last point has start ... // If no previous point, we need to create the last point has start ...
if (tmpListPoint.size() == 0) { if (tmpListPoint.size() == 0) {
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type_join)); tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
} }
{ {
vec2 lastPosStore(lastPosition); vec2 lastPosStore(lastPosition);
@ -300,7 +300,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
pos2, pos2,
pos, pos,
0, 0,
esvg::render::Point::type_join); esvg::render::Point::type::join);
lastPosition = pos; lastPosition = pos;
lastAngle = tmp1; lastAngle = tmp1;
} }
@ -308,7 +308,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
case esvg::render::path_bezierSmoothCurveTo: case esvg::render::path_bezierSmoothCurveTo:
// If no previous point, we need to create the last point has start ... // If no previous point, we need to create the last point has start ...
if (tmpListPoint.size() == 0) { if (tmpListPoint.size() == 0) {
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type_join)); tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
} }
{ {
vec2 lastPosStore(lastPosition); vec2 lastPosStore(lastPosition);
@ -328,7 +328,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
pos2, pos2,
pos, pos,
0, 0,
esvg::render::Point::type_join); esvg::render::Point::type::join);
lastPosition = pos; lastPosition = pos;
lastAngle = tmp1; lastAngle = tmp1;
} }
@ -336,7 +336,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
case esvg::render::path_elliptic: case esvg::render::path_elliptic:
// If no previous point, we need to create the last point has start ... // If no previous point, we need to create the last point has start ...
if (tmpListPoint.size() == 0) { if (tmpListPoint.size() == 0) {
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type_join)); tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
} }
{ {
std::shared_ptr<esvg::render::ElementElliptic> tmpIt(std::dynamic_pointer_cast<esvg::render::ElementElliptic>(it)); std::shared_ptr<esvg::render::ElementElliptic> tmpIt(std::dynamic_pointer_cast<esvg::render::ElementElliptic>(it));
@ -365,9 +365,9 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|| radius.y() < 1e-6f) { || radius.y() < 1e-6f) {
ESVG_WARNING("Degenerate arc in Line"); ESVG_WARNING("Degenerate arc in Line");
if (tmpListPoint.size() == 0) { if (tmpListPoint.size() == 0) {
tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type_join)); tmpListPoint.push_back(esvg::render::Point(lastPosition, esvg::render::Point::type::join));
} }
tmpListPoint.push_back(esvg::render::Point(pos, esvg::render::Point::type_join)); tmpListPoint.push_back(esvg::render::Point(pos, esvg::render::Point::type::join));
} else { } else {
// Convert to center point parameterization. // Convert to center point parameterization.
// http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
@ -486,7 +486,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
zpos2, zpos2,
zpos, zpos,
0, 0,
esvg::render::Point::type_join); esvg::render::Point::type::join);
lastPosition = zpos; lastPosition = zpos;
lastAngle = zpos2; lastAngle = zpos2;
} }

View File

@ -10,20 +10,20 @@
#include <esvg/debug.h> #include <esvg/debug.h>
void esvg::render::Point::setEndPath() { void esvg::render::Point::setEndPath() {
if (m_type == esvg::render::Point::type_interpolation) { if (m_type == esvg::render::Point::type::interpolation) {
ESVG_WARNING("Request stop path of an interpolate Point"); ESVG_WARNING("Request stop path of an interpolate Point");
m_type = esvg::render::Point::type_stop; m_type = esvg::render::Point::type::stop;
return; return;
} }
if (m_type == esvg::render::Point::type_stop) { if (m_type == esvg::render::Point::type::stop) {
ESVG_WARNING("Request stop path of an STOP Point"); ESVG_WARNING("Request stop path of an STOP Point");
return; return;
} }
if (m_type == esvg::render::Point::type_start) { if (m_type == esvg::render::Point::type::start) {
m_type = esvg::render::Point::type_single; m_type = esvg::render::Point::type::single;
return; return;
} }
m_type = esvg::render::Point::type_stop; m_type = esvg::render::Point::type::stop;
} }
void esvg::render::Point::normalize(const vec2& _nextPoint) { void esvg::render::Point::normalize(const vec2& _nextPoint) {

View File

@ -15,12 +15,12 @@ namespace esvg {
namespace render { namespace render {
class Point { class Point {
public: public:
enum type { enum class type {
type_single, //!< Point type is single, this mean that it start and stop of a path single, //!< Point type is single, this mean that it start and stop of a path
type_start, //!< Point type is starting of a path start, //!< Point type is starting of a path
type_stop, //!< Point type is stoping of a path stop, //!< Point type is stoping of a path
type_join, //!< Point type in an user point provided inside a path join, //!< Point type in an user point provided inside a path
type_interpolation, //!< This point is dynamicly calculated to create an interpolation interpolation, //!< This point is dynamicly calculated to create an interpolation
}; };
public: public:
// TODO : Clean all element here ... // TODO : Clean all element here ...
@ -33,7 +33,7 @@ namespace esvg {
vec2 m_posNext; vec2 m_posNext;
vec2 m_delta; vec2 m_delta;
float m_len; float m_len;
Point(const vec2& _pos, enum esvg::render::Point::type _type = esvg::render::Point::type_join) : Point(const vec2& _pos, enum esvg::render::Point::type _type = esvg::render::Point::type::join) :
m_pos(_pos), m_pos(_pos),
m_type(_type) { m_type(_type) {
// nothing to do ... // nothing to do ...

View File

@ -45,19 +45,19 @@ void esvg::render::PointList::display() {
iii < it.size(); iii < it.size();
++iii) { ++iii) {
switch (it[iii].m_type) { switch (it[iii].m_type) {
case esvg::render::Point::type_single: case esvg::render::Point::type::single:
ESVG_VERBOSE(" [" << iii << "] Find Single " << it[iii].m_pos); ESVG_VERBOSE(" [" << iii << "] Find Single " << it[iii].m_pos);
break; break;
case esvg::render::Point::type_start: case esvg::render::Point::type::start:
ESVG_VERBOSE(" [" << iii << "] Find Start " << it[iii].m_pos); ESVG_VERBOSE(" [" << iii << "] Find Start " << it[iii].m_pos);
break; break;
case esvg::render::Point::type_stop: case esvg::render::Point::type::stop:
ESVG_VERBOSE(" [" << iii << "] Find Stop " << it[iii].m_pos); ESVG_VERBOSE(" [" << iii << "] Find Stop " << it[iii].m_pos);
break; break;
case esvg::render::Point::type_interpolation: case esvg::render::Point::type::interpolation:
ESVG_VERBOSE(" [" << iii << "] Find interpolation " << it[iii].m_pos); ESVG_VERBOSE(" [" << iii << "] Find interpolation " << it[iii].m_pos);
break; break;
case esvg::render::Point::type_join: case esvg::render::Point::type::join:
ESVG_VERBOSE(" [" << iii << "] Find Join " << it[iii].m_pos); ESVG_VERBOSE(" [" << iii << "] Find Join " << it[iii].m_pos);
break; break;
} }

View File

@ -145,8 +145,8 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
if (idNext == itListPoint.size()) { if (idNext == itListPoint.size()) {
idNext = 0; idNext = 0;
} }
if ( itListPoint[idCurrent].m_type == esvg::render::Point::type_join if ( itListPoint[idCurrent].m_type == esvg::render::Point::type::join
|| itListPoint[idCurrent].m_type == esvg::render::Point::type_interpolation) { || itListPoint[idCurrent].m_type == esvg::render::Point::type::interpolation) {
if (idPevious < 0 ) { if (idPevious < 0 ) {
ESVG_ERROR("an error occure a previous ID is < 0.... "); ESVG_ERROR("an error occure a previous ID is < 0.... ");
continue; continue;
@ -181,14 +181,14 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
vecB.safeNormalize(); vecB.safeNormalize();
itListPoint[idCurrent].m_orthoAxePrevious = vec2(vecB.y(), -vecB.x()); itListPoint[idCurrent].m_orthoAxePrevious = vec2(vecB.y(), -vecB.x());
//ESVG_DEBUG("JOIN : miterAxe " << itListPoint[idCurrent].m_miterAxe); //ESVG_DEBUG("JOIN : miterAxe " << itListPoint[idCurrent].m_miterAxe);
} else if (itListPoint[idCurrent].m_type == esvg::render::Point::type_start) { } else if (itListPoint[idCurrent].m_type == esvg::render::Point::type::start) {
itListPoint[idCurrent].m_posNext = itListPoint[idNext].m_pos; itListPoint[idCurrent].m_posNext = itListPoint[idNext].m_pos;
vec2 vecB = itListPoint[idNext].m_pos - itListPoint[idCurrent].m_pos; vec2 vecB = itListPoint[idNext].m_pos - itListPoint[idCurrent].m_pos;
vecB.safeNormalize(); vecB.safeNormalize();
itListPoint[idCurrent].m_miterAxe = vec2(vecB.y(), -vecB.x()); itListPoint[idCurrent].m_miterAxe = vec2(vecB.y(), -vecB.x());
itListPoint[idCurrent].m_orthoAxePrevious = itListPoint[idCurrent].m_miterAxe; itListPoint[idCurrent].m_orthoAxePrevious = itListPoint[idCurrent].m_miterAxe;
itListPoint[idCurrent].m_orthoAxeNext = itListPoint[idCurrent].m_miterAxe; itListPoint[idCurrent].m_orthoAxeNext = itListPoint[idCurrent].m_miterAxe;
} else if (itListPoint[idCurrent].m_type == esvg::render::Point::type_stop) { } else if (itListPoint[idCurrent].m_type == esvg::render::Point::type::stop) {
if (idPevious < 0 ) { if (idPevious < 0 ) {
ESVG_ERROR("an error occure a previous ID is < 0.... "); ESVG_ERROR("an error occure a previous ID is < 0.... ");
continue; continue;
@ -208,7 +208,7 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
vec2 leftPoint(0,0); vec2 leftPoint(0,0);
vec2 rightPoint(0,0); vec2 rightPoint(0,0);
if (itListPoint.size() > 0) { if (itListPoint.size() > 0) {
if (itListPoint.front().m_type == esvg::render::Point::type_join) { if (itListPoint.front().m_type == esvg::render::Point::type::join) {
const esvg::render::Point& it = itListPoint.back(); const esvg::render::Point& it = itListPoint.back();
// Calculate the perpendiculary axis ... // Calculate the perpendiculary axis ...
leftPoint = itListPoint.back().m_pos leftPoint = itListPoint.back().m_pos
@ -216,10 +216,10 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
rightPoint = itListPoint.back().m_pos rightPoint = itListPoint.back().m_pos
- itListPoint.back().m_orthoAxePrevious*_width*0.5f; - itListPoint.back().m_orthoAxePrevious*_width*0.5f;
// cyclic path... // cyclic path...
if (it.m_type == esvg::render::Point::type_interpolation) { if (it.m_type == esvg::render::Point::type::interpolation) {
leftPoint = getIntersect(leftPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe); leftPoint = getIntersect(leftPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
rightPoint = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe); rightPoint = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
} else if (it.m_type == esvg::render::Point::type_join) { } else if (it.m_type == esvg::render::Point::type::join) {
// Calculate the perpendiculary axis ... // Calculate the perpendiculary axis ...
leftPoint = it.m_pos leftPoint = it.m_pos
+ it.m_orthoAxePrevious*_width*0.5f; + it.m_orthoAxePrevious*_width*0.5f;
@ -269,11 +269,11 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
} }
for (auto &it : itListPoint) { for (auto &it : itListPoint) {
switch (it.m_type) { switch (it.m_type) {
case esvg::render::Point::type_single: case esvg::render::Point::type::single:
// just do nothing .... // just do nothing ....
ESVG_VERBOSE("Find Single " << it.m_pos); ESVG_VERBOSE("Find Single " << it.m_pos);
break; break;
case esvg::render::Point::type_start: case esvg::render::Point::type::start:
ESVG_VERBOSE("Find Start " << it.m_pos); ESVG_VERBOSE("Find Start " << it.m_pos);
if (haveStartLine == true) { if (haveStartLine == true) {
// close previous : // close previous :
@ -283,7 +283,7 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
haveStartLine = true; haveStartLine = true;
startStopPoint(leftPoint, rightPoint, it, _cap, _width, true); startStopPoint(leftPoint, rightPoint, it, _cap, _width, true);
break; break;
case esvg::render::Point::type_stop: case esvg::render::Point::type::stop:
ESVG_VERBOSE("Find Stop " << it.m_pos); ESVG_VERBOSE("Find Stop " << it.m_pos);
if (haveStartLine == false) { if (haveStartLine == false) {
ESVG_WARNING("find close path without start part ..."); ESVG_WARNING("find close path without start part ...");
@ -292,7 +292,7 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
haveStartLine = false; haveStartLine = false;
startStopPoint(leftPoint, rightPoint, it, _cap, _width, false); startStopPoint(leftPoint, rightPoint, it, _cap, _width, false);
break; break;
case esvg::render::Point::type_interpolation: case esvg::render::Point::type::interpolation:
{ {
ESVG_VERBOSE("Find interpolation " << it.m_pos); ESVG_VERBOSE("Find interpolation " << it.m_pos);
vec2 left = getIntersect(leftPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe); vec2 left = getIntersect(leftPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
@ -306,7 +306,7 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
rightPoint = right; rightPoint = right;
} }
break; break;
case esvg::render::Point::type_join: case esvg::render::Point::type::join:
ESVG_VERBOSE("Find join " << it.m_pos); ESVG_VERBOSE("Find join " << it.m_pos);
switch (_join) { switch (_join) {
case esvg::join_miter: case esvg::join_miter: