Sketcher: GeoId, GeoElementId and GeoUndef refactor

===================================================

This commit is an independent refactor of the identifications used at Sketcher level.

It introduces a new type "GeoElementId" as a combination of GeoId and PointPos.

It moves the Undefined GeoId, previous Constraint::GeoUndef to GeoEnum, together with all
other fixed values of GeoIds.
This commit is contained in:
Abdullah Tahiri
2021-12-11 16:17:21 +01:00
parent 56d86df5bb
commit bb76be1371
20 changed files with 277 additions and 192 deletions
+3 -5
View File
@@ -43,18 +43,16 @@ using namespace Base;
TYPESYSTEM_SOURCE(Sketcher::Constraint, Base::Persistence)
const int Constraint::GeoUndef = -2000;
Constraint::Constraint()
: Value(0.0),
Type(None),
AlignmentType(Undef),
Name(""),
First(GeoUndef),
First(GeoEnum::GeoUndef),
FirstPos(none),
Second(GeoUndef),
Second(GeoEnum::GeoUndef),
SecondPos(none),
Third(GeoUndef),
Third(GeoEnum::GeoUndef),
ThirdPos(none),
LabelDistance(10.f),
LabelPosition(0.f),
+2 -16
View File
@@ -30,6 +30,8 @@
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include "GeoEnum.h"
namespace Sketcher
{
/*!
@@ -75,20 +77,6 @@ enum InternalAlignmentType {
BSplineKnotPoint = 10,
};
/*! PointPos lets us refer to different aspects of a piece of geometry. sketcher::none refers
* to an edge itself (eg., for a Perpendicular constraint on two lines). sketcher::start and
* sketcher::end denote the endpoints of lines or bounded curves. sketcher::mid denotes
* geometries with geometrical centers (eg., circle, ellipse). Bare points use 'start'. More
* complex geometries like parabola focus or b-spline knots use InternalAlignment constraints
* in addition to PointPos.
*/
enum PointPos : int {
none = 0,
start = 1,
end = 2,
mid = 3
};
class SketcherExport Constraint : public Base::Persistence
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
@@ -110,8 +98,6 @@ public:
Constraint *clone(void) const; // does copy the tag, it will be treated as a rename by the expression engine.
Constraint *copy(void) const; // does not copy the tag, but generates a new one
static const int GeoUndef;
// from base class
virtual unsigned int getMemSize(void) const override;
virtual void Save(Base::Writer &/*writer*/) const override;
+6 -6
View File
@@ -49,11 +49,11 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyErr_Clear();
char *ConstraintType;
int FirstIndex = Constraint::GeoUndef;
int FirstIndex = GeoEnum::GeoUndef;
int FirstPos = none;
int SecondIndex= Constraint::GeoUndef;
int SecondIndex= GeoEnum::GeoUndef;
int SecondPos = none;
int ThirdIndex = Constraint::GeoUndef;
int ThirdIndex = GeoEnum::GeoUndef;
int ThirdPos = none;
double Value = 0;
int intArg1, intArg2, intArg3, intArg4, intArg5;
@@ -487,20 +487,20 @@ std::string ConstraintPy::representation(void) const
case Weight : result << "'Weight'>";break;
case Parallel : result << "'Parallel'>";break;
case Tangent :
if (this->getConstraintPtr()->Third == Constraint::GeoUndef)
if (this->getConstraintPtr()->Third == GeoEnum::GeoUndef)
result << "'Tangent'>";
else
result << "'TangentViaPoint'>";
break;
case Perpendicular :
if (this->getConstraintPtr()->Third == Constraint::GeoUndef)
if (this->getConstraintPtr()->Third == GeoEnum::GeoUndef)
result << "'Perpendicular'>";
else
result << "'PerpendicularViaPoint'>";
break;
case Distance : result << "'Distance'>";break;
case Angle :
if (this->getConstraintPtr()->Third == Constraint::GeoUndef)
if (this->getConstraintPtr()->Third == GeoEnum::GeoUndef)
result << "'Angle'>";
else
result << "'AngleViaPoint'>";
+9
View File
@@ -30,4 +30,13 @@ const int GeoEnum::RtPnt = -1;
const int GeoEnum::HAxis = -1;
const int GeoEnum::VAxis = -2;
const int GeoEnum::RefExt = -3;
const int GeoEnum::GeoUndef = -2000;
constexpr const GeoElementId GeoElementId::RtPnt = GeoElementId(GeoEnum::RtPnt, PointPos::start);
constexpr const GeoElementId GeoElementId::HAxis = GeoElementId(GeoEnum::HAxis, PointPos::none);
constexpr const GeoElementId GeoElementId::VAxis = GeoElementId(GeoEnum::VAxis, PointPos::end);
bool GeoElementId::operator==(const GeoElementId& obj) const
{
return this->GeoId == obj.GeoId && this->Pos == obj.Pos;
}
+94 -4
View File
@@ -23,19 +23,109 @@
#ifndef SKETCHER_GeoEnum_H
#define SKETCHER_GeoEnum_H
#include <functional>
namespace Sketcher
{
/** Sketcher Geometry is identified with an index called GeoId.
*
* GeoId >= 0 are normal geometry elements
* GeoId = -1 and -2 are the Horizontal and Vertical axes and the root point
* GeoId <= -2 are external geometry elements
* GeoId = -2000 is an undefined or unused geometry id
*
* GeoEnum struct provides convenience labels for these GeoIds.
*
* However, GeoEnum is not enough to define an element of a Geometry. The most
* straighforward example is the RootPoint and the Horizontal Axis. Both have
* the same GeoId (= -1).
*
* The same happens for elements of a given geometry. For example, a line has
* a starting point, an endpoint and an edge. All these share the same GeoId, as the
* GeoId identifies a geometry and not an element of a geometry.
*
* The elements of a given geometry are identified by the PointPos enum. In the case
* of the root point, it is considered to be the start point of the Horizontal Axis, this
* is a convention.
*
* Therefore, a geometry element (GeoElementId) is univocally defined by the combination of a
* GeoId and a PointPos.
*
* Geometry shapes having more or different elements than those supported by the PointPos
* struct, such as conics, in particular an arc of ellipse, are called complex geometries. The extra
* elements of complex geometries are actual separate geometries (focus of an ellipse, line defining the
* major axis of an ellipse, circle representing the weight of a BSpline), and they are call InternalAlignment
* geometries.
*
* For Geometry lists, refer to GeoListModel template.
*/
struct SketcherExport GeoEnum
{
static const int RtPnt;
static const int HAxis;
static const int VAxis;
static const int RefExt;
static const int RtPnt; // GeoId of the Root Point
static const int HAxis; // GeoId of the Horizontal Axis
static const int VAxis; // GeoId of the Vertical Axis
static const int RefExt; // Starting GeoID of external geometry ( negative geoIds starting at this index)
static const int GeoUndef; // GeoId of an undefined Geometry (uninitialised or unused GeoId)
};
/*! PointPos lets us refer to different aspects of a piece of geometry. sketcher::none refers
* to an edge itself (eg., for a Perpendicular constraint on two lines). sketcher::start and
* sketcher::end denote the endpoints of lines or bounded curves. sketcher::mid denotes
* geometries with geometrical centers (eg., circle, ellipse). Bare points use 'start'. More
* complex geometries like parabola focus or b-spline knots use InternalAlignment constraints
* in addition to PointPos.
*/
enum PointPos : int {
none = 0, // Edge of a geometry
start = 1, // Starting point of a geometry
end = 2, // End point of a geometry
mid = 3 // Mid point of a geometry
};
/** @brief Struct for storing a {GeoId, PointPos} pair.
*
* @details
*
* {GeoId, PointPos} is pervasive in the sketcher as means to identify geometry (edges) and geometry elements (vertices).
*
* GeoElementId intends to substitute this pair whenever appropriate. For example in containers and ordered containers.
*
* It has overloader equality operator and specialised std::less so that it can safely be used in containers, including
* ordered containers.
*
*/
class SketcherExport GeoElementId
{
public:
explicit constexpr GeoElementId(int geoId = GeoEnum::GeoUndef, PointPos pos = PointPos::none);
bool operator==(const GeoElementId& obj) const;
int GeoId;
PointPos Pos;
static const GeoElementId RtPnt; // GeoElementId of the Root Point
static const GeoElementId HAxis; // GeoElementId of the Horizontal Axis
static const GeoElementId VAxis; // GeoElementId of the Vertical Axis
};
constexpr GeoElementId::GeoElementId(int geoId, PointPos pos): GeoId(geoId), Pos(pos)
{
}
} // namespace Sketcher
namespace std
{
template<> struct less<Sketcher::GeoElementId>
{
bool operator() (const Sketcher::GeoElementId& lhs, const Sketcher::GeoElementId& rhs) const
{
return (lhs.GeoId != rhs.GeoId)?(lhs.GeoId < rhs.GeoId):(static_cast<int>(lhs.Pos) < static_cast<int>(rhs.Pos));
}
};
} // namespace std
#endif // SKETCHER_GeoEnum_H
@@ -404,10 +404,10 @@ bool PropertyConstraintList::checkGeometry(const std::vector<Part::Geometry *> &
bool PropertyConstraintList::checkConstraintIndices(int geomax, int geomin)
{
int mininternalgeoid = std::numeric_limits<int>::max();
int maxinternalgeoid = Constraint::GeoUndef;
int maxinternalgeoid = GeoEnum::GeoUndef;
auto cmin = [] (int previousmin, int cindex) {
if( cindex == Constraint::GeoUndef )
if( cindex == GeoEnum::GeoUndef )
return previousmin;
return ( cindex < previousmin )? cindex : previousmin;
+15 -15
View File
@@ -1263,7 +1263,7 @@ int Sketch::addBSpline(const Part::GeomBSplineCurve &bspline, bool fixed)
bs.knotpointGeoids.resize(knots.size());
for(std::vector<int>::iterator it = bs.knotpointGeoids.begin(); it != bs.knotpointGeoids.end(); ++it) {
(*it) = Constraint::GeoUndef;
(*it) = GeoEnum::GeoUndef;
}
BSplines.push_back(bs);
@@ -1546,7 +1546,7 @@ int Sketch::addConstraint(const Constraint *constraint)
rtn = addDistanceXConstraint(constraint->First,c.value,c.driving);
}
else if (constraint->Second == Constraint::GeoUndef) {// point on fixed x-coordinate
else if (constraint->Second == GeoEnum::GeoUndef) {// point on fixed x-coordinate
c.value = new double(constraint->getValue());
if(c.driving)
FixParameters.push_back(c.value);
@@ -1582,7 +1582,7 @@ int Sketch::addConstraint(const Constraint *constraint)
rtn = addDistanceYConstraint(constraint->First,c.value,c.driving);
}
else if (constraint->Second == Constraint::GeoUndef){ // point on fixed y-coordinate
else if (constraint->Second == GeoEnum::GeoUndef){ // point on fixed y-coordinate
c.value = new double(constraint->getValue());
if(c.driving)
FixParameters.push_back(c.value);
@@ -1607,14 +1607,14 @@ int Sketch::addConstraint(const Constraint *constraint)
}
break;
case Horizontal:
if (constraint->Second == Constraint::GeoUndef) // horizontal line
if (constraint->Second == GeoEnum::GeoUndef) // horizontal line
rtn = addHorizontalConstraint(constraint->First);
else // two points on the same horizontal line
rtn = addHorizontalConstraint(constraint->First,constraint->FirstPos,
constraint->Second,constraint->SecondPos);
break;
case Vertical:
if (constraint->Second == Constraint::GeoUndef) // vertical line
if (constraint->Second == GeoEnum::GeoUndef) // vertical line
rtn = addVerticalConstraint(constraint->First);
else // two points on the same vertical line
rtn = addVerticalConstraint(constraint->First,constraint->FirstPos,
@@ -1632,7 +1632,7 @@ int Sketch::addConstraint(const Constraint *constraint)
case Perpendicular:
if (constraint->FirstPos == none &&
constraint->SecondPos == none &&
constraint->Third == Constraint::GeoUndef){
constraint->Third == GeoEnum::GeoUndef){
//simple perpendicularity
rtn = addPerpendicularConstraint(constraint->First,constraint->Second);
} else {
@@ -1655,7 +1655,7 @@ int Sketch::addConstraint(const Constraint *constraint)
case Tangent:
if (constraint->FirstPos == none &&
constraint->SecondPos == none &&
constraint->Third == Constraint::GeoUndef){
constraint->Third == GeoEnum::GeoUndef){
//simple tangency
rtn = addTangentConstraint(constraint->First,constraint->Second);
} else {
@@ -1688,7 +1688,7 @@ int Sketch::addConstraint(const Constraint *constraint)
constraint->Second,constraint->SecondPos,
c.value,c.driving);
}
else if (constraint->Second != Constraint::GeoUndef) {
else if (constraint->Second != GeoEnum::GeoUndef) {
if (constraint->FirstPos != none) { // point to line distance
c.value = new double(constraint->getValue());
if(c.driving)
@@ -1714,7 +1714,7 @@ int Sketch::addConstraint(const Constraint *constraint)
}
break;
case Angle:
if (constraint->Third != Constraint::GeoUndef){
if (constraint->Third != GeoEnum::GeoUndef){
c.value = new double(constraint->getValue());
if(c.driving)
FixParameters.push_back(c.value);
@@ -1740,7 +1740,7 @@ int Sketch::addConstraint(const Constraint *constraint)
rtn = addAngleConstraint(constraint->First,constraint->FirstPos,
constraint->Second,constraint->SecondPos,c.value,c.driving);
}
else if (constraint->Second != Constraint::GeoUndef){ // angle between two lines
else if (constraint->Second != GeoEnum::GeoUndef){ // angle between two lines
c.value = new double(constraint->getValue());
if(c.driving)
FixParameters.push_back(c.value);
@@ -1751,7 +1751,7 @@ int Sketch::addConstraint(const Constraint *constraint)
rtn = addAngleConstraint(constraint->First,constraint->Second,c.value,c.driving);
}
else if (constraint->First != Constraint::GeoUndef) {// orientation angle of a line
else if (constraint->First != GeoEnum::GeoUndef) {// orientation angle of a line
c.value = new double(constraint->getValue());
if(c.driving)
FixParameters.push_back(c.value);
@@ -1983,14 +1983,14 @@ void Sketch::getBlockedGeometry(std::vector<bool> & blockedGeometry,
// solver behaviour
// further, any constraint taking only one element, which is blocked is also unenforceable
if((*it)->Second==Constraint::GeoUndef && (*it)->Third==Constraint::GeoUndef && (*it)->First>=0 ) {
if((*it)->Second==GeoEnum::GeoUndef && (*it)->Third==GeoEnum::GeoUndef && (*it)->First>=0 ) {
if (blockedGeometry[(*it)->First] && i < geo2blockingconstraintindex[(*it)->First]) {
unenforceableConstraints[i]= true;
}
}
// further any constraint on only two elements where both elements are blocked or one is blocked and the other is an axis or external
// provided that the constraints precede the last block constraint.
else if((*it)->Third==Constraint::GeoUndef) {
else if((*it)->Third==GeoEnum::GeoUndef) {
if ( ((*it)->First>=0 && (*it)->Second>=0 && blockedGeometry[(*it)->First] && blockedGeometry[(*it)->Second] &&
(i < geo2blockingconstraintindex[(*it)->First] || i < geo2blockingconstraintindex[(*it)->Second])) ||
((*it)->First<0 && (*it)->Second>=0 && blockedGeometry[(*it)->Second] && i < geo2blockingconstraintindex[(*it)->Second]) ||
@@ -2375,7 +2375,7 @@ int Sketch::addAngleAtPointConstraint(
return -1;
}
bool avp = geoId3!=Constraint::GeoUndef; //is angle-via-point?
bool avp = geoId3!=GeoEnum::GeoUndef; //is angle-via-point?
bool e2c = pos2 == none && pos1 != none;//is endpoint-to-curve?
bool e2e = pos2 != none && pos1 != none;//is endpoint-to-endpoint?
@@ -3450,7 +3450,7 @@ bool Sketch::updateGeometry()
#if OCC_VERSION_HEX >= 0x060900
int index = 0;
for(std::vector<int>::const_iterator it5 = mybsp.knotpointGeoids.begin(); it5 != mybsp.knotpointGeoids.end(); ++it5, index++) {
if( *it5 != Constraint::GeoUndef) {
if( *it5 != GeoEnum::GeoUndef) {
if (Geoms[*it5].type == Point) {
GeomPoint *point = static_cast<GeomPoint*>(Geoms[*it5].geo);
+1 -1
View File
@@ -407,7 +407,7 @@ int SketchAnalysis::detectMissingVerticalHorizontalConstraints(double anglepreci
id.v = dir;
id.First = (int)i;
id.FirstPos = Sketcher::none;
id.Second = Constraint::GeoUndef;
id.Second = GeoEnum::GeoUndef;
id.SecondPos = Sketcher::none;
if( checkVertical(dir, angleprecision) ) {
+53 -53
View File
@@ -424,13 +424,13 @@ int SketchObject::toggleDriving(int ConstrId)
const auto geof2 = getGeometryFacade(vals[ConstrId]->Second);
const auto geof3 = getGeometryFacade(vals[ConstrId]->Third);
bool extorconstructionpoint1 = (vals[ConstrId]->First == Constraint::GeoUndef) ||
bool extorconstructionpoint1 = (vals[ConstrId]->First == GeoEnum::GeoUndef) ||
(vals[ConstrId]->First < 0) ||
(geof1 && geof1->isGeoType(Part::GeomPoint::getClassTypeId()) && geof1->getConstruction() == true);
bool extorconstructionpoint2 = (vals[ConstrId]->Second == Constraint::GeoUndef)||
bool extorconstructionpoint2 = (vals[ConstrId]->Second == GeoEnum::GeoUndef)||
(vals[ConstrId]->Second < 0) ||
(geof2 && geof2->isGeoType(Part::GeomPoint::getClassTypeId()) && geof2->getConstruction() == true);
bool extorconstructionpoint3 = (vals[ConstrId]->Third == Constraint::GeoUndef) ||
bool extorconstructionpoint3 = (vals[ConstrId]->Third == GeoEnum::GeoUndef) ||
(vals[ConstrId]->Third < 0) ||
(geof3 && geof3->isGeoType(Part::GeomPoint::getClassTypeId()) && geof3->getConstruction() == true);
@@ -1397,7 +1397,7 @@ int SketchObject::delConstraintOnPoint(int GeoId, PointPos PosId, bool onlyCoinc
const std::vector<Constraint *> &vals = this->Constraints.getValues();
// check if constraints can be redirected to some other point
int replaceGeoId=Constraint::GeoUndef;
int replaceGeoId=GeoEnum::GeoUndef;
PointPos replacePosId=Sketcher::none;
if (!onlyCoincident) {
for (std::vector<Constraint *>::const_iterator it = vals.begin(); it != vals.end(); ++it) {
@@ -1421,7 +1421,7 @@ int SketchObject::delConstraintOnPoint(int GeoId, PointPos PosId, bool onlyCoinc
for (std::vector<Constraint *>::const_iterator it = vals.begin(); it != vals.end(); ++it) {
if ((*it)->Type == Sketcher::Coincident) {
if ((*it)->First == GeoId && (*it)->FirstPos == PosId) {
if (replaceGeoId != Constraint::GeoUndef &&
if (replaceGeoId != GeoEnum::GeoUndef &&
(replaceGeoId != (*it)->Second || replacePosId != (*it)->SecondPos)) { // redirect this constraint
(*it)->First = replaceGeoId;
(*it)->FirstPos = replacePosId;
@@ -1430,7 +1430,7 @@ int SketchObject::delConstraintOnPoint(int GeoId, PointPos PosId, bool onlyCoinc
continue; // skip this constraint
}
else if ((*it)->Second == GeoId && (*it)->SecondPos == PosId) {
if (replaceGeoId != Constraint::GeoUndef &&
if (replaceGeoId != GeoEnum::GeoUndef &&
(replaceGeoId != (*it)->First || replacePosId != (*it)->FirstPos)) { // redirect this constraint
(*it)->Second = replaceGeoId;
(*it)->SecondPos = replacePosId;
@@ -1449,7 +1449,7 @@ int SketchObject::delConstraintOnPoint(int GeoId, PointPos PosId, bool onlyCoinc
continue; // skip this constraint
}
else if ((*it)->First == GeoId && (*it)->FirstPos == PosId) {
if (replaceGeoId != Constraint::GeoUndef) { // redirect this constraint
if (replaceGeoId != GeoEnum::GeoUndef) { // redirect this constraint
(*it)->First = replaceGeoId;
(*it)->FirstPos = replacePosId;
}
@@ -1457,7 +1457,7 @@ int SketchObject::delConstraintOnPoint(int GeoId, PointPos PosId, bool onlyCoinc
continue; // skip this constraint
}
else if ((*it)->Second == GeoId && (*it)->SecondPos == PosId) {
if (replaceGeoId != Constraint::GeoUndef) { // redirect this constraint
if (replaceGeoId != GeoEnum::GeoUndef) { // redirect this constraint
(*it)->Second = replaceGeoId;
(*it)->SecondPos = replacePosId;
}
@@ -1467,7 +1467,7 @@ int SketchObject::delConstraintOnPoint(int GeoId, PointPos PosId, bool onlyCoinc
}
else if ((*it)->Type == Sketcher::PointOnObject) {
if ((*it)->First == GeoId && (*it)->FirstPos == PosId) {
if (replaceGeoId != Constraint::GeoUndef) { // redirect this constraint
if (replaceGeoId != GeoEnum::GeoUndef) { // redirect this constraint
(*it)->First = replaceGeoId;
(*it)->FirstPos = replacePosId;
}
@@ -2594,7 +2594,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
};
//******************* Step A => Detection of intersection - Common to all Geometries ****************************************//
int GeoId1=Constraint::GeoUndef, GeoId2=Constraint::GeoUndef;
int GeoId1=GeoEnum::GeoUndef, GeoId2=GeoEnum::GeoUndef;
Base::Vector3d point1, point2;
// Using SketchObject wrapper, as Part2DObject version returns GeoId = -1 when intersection not found, which is wrong for a GeoId (axis).
// seekTrimPoints returns:
@@ -2627,7 +2627,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
// it is a non-periodic bspline and one intersection is enough.
auto bspline = static_cast<const Part::GeomBSplineCurve *>(geo);
if(bspline->isPeriodic() && (GeoId1 == Constraint::GeoUndef || GeoId2 == Constraint::GeoUndef))
if(bspline->isPeriodic() && (GeoId1 == GeoEnum::GeoUndef || GeoId2 == GeoEnum::GeoUndef))
return -1;
ifBSplineRemoveInternalAlignmentGeometry(GeoId); // GeoId gets updated here
@@ -2647,8 +2647,8 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
geo = getGeometry(GeoId);
}
if( GeoId1 != Constraint::GeoUndef &&
GeoId2 != Constraint::GeoUndef &&
if( GeoId1 != GeoEnum::GeoUndef &&
GeoId2 != GeoEnum::GeoUndef &&
arePointsWithinPrecision(point1, point2) ) { // If both points are detected and are coincident, deletion is the only option.
delGeometry(GeoId);
@@ -2701,16 +2701,16 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
//****** Step B.1 (2) => Determine trimmable sections and trim operation ******//
// Determine if there is something trimmable
double startDistance = GeoId1 != Constraint::GeoUndef?paramDistance(firstParam, point1Param):paramDistance(firstParam, point2Param);
double endDistance = GeoId2 != Constraint::GeoUndef?paramDistance(lastParam, point2Param):paramDistance(lastParam, point1Param);
double middleDistance = (GeoId1 != Constraint::GeoUndef && GeoId2 != Constraint::GeoUndef)?paramDistance(point1Param, point2Param):0.0;
double startDistance = GeoId1 != GeoEnum::GeoUndef?paramDistance(firstParam, point1Param):paramDistance(firstParam, point2Param);
double endDistance = GeoId2 != GeoEnum::GeoUndef?paramDistance(lastParam, point2Param):paramDistance(lastParam, point1Param);
double middleDistance = (GeoId1 != GeoEnum::GeoUndef && GeoId2 != GeoEnum::GeoUndef)?paramDistance(point1Param, point2Param):0.0;
bool trimmableStart = startDistance > 0.;
bool trimmableMiddle = middleDistance > 0.;
bool trimmableEnd = endDistance > 0.;
struct Operation {
Operation():Type(trim_none), actingParam(0.), intersectingGeoId(Constraint::GeoUndef){}
Operation():Type(trim_none), actingParam(0.), intersectingGeoId(GeoEnum::GeoUndef){}
enum {
trim_none,
trim_start,
@@ -2726,8 +2726,8 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
Operation op;
if ( GeoId1!=Constraint::GeoUndef &&
GeoId2!=Constraint::GeoUndef &&
if ( GeoId1!=GeoEnum::GeoUndef &&
GeoId2!=GeoEnum::GeoUndef &&
pointParam > point1Param && pointParam < point2Param ) { // Trim Point between intersection points
if( (!trimmableStart && !trimmableEnd) || !trimmableMiddle) { // if after trimming nothing would be left or if there is nothing to trim
@@ -2749,7 +2749,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
op.intersectingGeoId = GeoId2;
}
}
else if (GeoId2!=Constraint::GeoUndef && pointParam < point2Param) {
else if (GeoId2!=GeoEnum::GeoUndef && pointParam < point2Param) {
if(trimmableEnd) {
op.Type = Operation::trim_start;
op.actingParam = point2Param; // trim from firstParam until point2Param
@@ -2760,7 +2760,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
op.Type = Operation::trim_delete;
}
}
else if (GeoId1!=Constraint::GeoUndef && pointParam > point1Param) {
else if (GeoId1!=GeoEnum::GeoUndef && pointParam > point1Param) {
if(trimmableStart) {
op.Type = Operation::trim_end;
op.actingParam = point1Param; // trim from point1Param until lastParam
@@ -2904,7 +2904,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
//******************* Step B.2 => Trimming for unbounded periodic geometries ****************************************//
else if ( isCircle || isEllipse || isPeriodicBSpline) {
//****** STEP A(2) => Common tests *****//
if( GeoId1==Constraint::GeoUndef || GeoId2==Constraint::GeoUndef)
if( GeoId1==GeoEnum::GeoUndef || GeoId2==GeoEnum::GeoUndef)
return -1;
//****** Step B.2 (1) => Determine intersection parameters ******//
@@ -3511,7 +3511,7 @@ int SketchObject::addSymmetric(const std::vector<int> &geoIdList, int refGeoId,
if(gf->isInternalAligned()) {
// only add this geometry if the corresponding geometry it defines is also in the list.
int definedGeo = Constraint::GeoUndef;
int definedGeo = GeoEnum::GeoUndef;
for( auto c : Constraints.getValues()) {
if(c->Type == Sketcher::InternalAlignment && c->First == *it) {
@@ -3796,7 +3796,7 @@ int SketchObject::addSymmetric(const std::vector<int> &geoIdList, int refGeoId,
if(gf->isInternalAligned()) {
// only add this geometry if the corresponding geometry it defines is also in the list.
int definedGeo = Constraint::GeoUndef;
int definedGeo = GeoEnum::GeoUndef;
for( auto c : Constraints.getValues()) {
if(c->Type == Sketcher::InternalAlignment && c->First == *it) {
@@ -3963,7 +3963,7 @@ int SketchObject::addSymmetric(const std::vector<int> &geoIdList, int refGeoId,
if(fit != geoIdMap.end()) { // if First of constraint is in geoIdList
if( (*it)->Second == Constraint::GeoUndef /*&& (*it)->Third == Constraint::GeoUndef*/) {
if( (*it)->Second == GeoEnum::GeoUndef /*&& (*it)->Third == GeoEnum::GeoUndef*/) {
if (refIsAxisAligned) {
// in this case we want to keep the Vertical, Horizontal constraints
// DistanceX ,and DistanceY constraints should also be possible to keep in this case,
@@ -3992,7 +3992,7 @@ int SketchObject::addSymmetric(const std::vector<int> &geoIdList, int refGeoId,
if(sit != geoIdMap.end()) { // Second is also in the list
if( (*it)->Third == Constraint::GeoUndef ) {
if( (*it)->Third == GeoEnum::GeoUndef ) {
if((*it)->Type == Sketcher::Coincident ||
(*it)->Type == Sketcher::Perpendicular ||
(*it)->Type == Sketcher::Parallel ||
@@ -4128,7 +4128,7 @@ int SketchObject::addCopy(const std::vector<int> &geoIdList, const Base::Vector3
if(gf->isInternalAligned() && !moveonly) {
// only add this geometry if the corresponding geometry it defines is also in the list.
int definedGeo = Constraint::GeoUndef;
int definedGeo = GeoEnum::GeoUndef;
for( auto c : Constraints.getValues()) {
if(c->Type == Sketcher::InternalAlignment && c->First == *(newgeoIdList.begin())) {
@@ -4177,7 +4177,7 @@ int SketchObject::addCopy(const std::vector<int> &geoIdList, const Base::Vector3
if(gf->isInternalAligned() && !moveonly) {
// only add this geometry if the corresponding geometry it defines is also in the list.
int definedGeo = Constraint::GeoUndef;
int definedGeo = GeoEnum::GeoUndef;
for( auto c : Constraints.getValues()) {
if(c->Type == Sketcher::InternalAlignment && c->First == *it) {
@@ -4313,7 +4313,7 @@ int SketchObject::addCopy(const std::vector<int> &geoIdList, const Base::Vector3
if(fit != geoIdMap.end()) { // if First of constraint is in geoIdList
if( (*it)->Second == Constraint::GeoUndef /*&& (*it)->Third == Constraint::GeoUndef*/) {
if( (*it)->Second == GeoEnum::GeoUndef /*&& (*it)->Third == GeoEnum::GeoUndef*/) {
if( ((*it)->Type != Sketcher::DistanceX && (*it)->Type != Sketcher::DistanceY ) ||
(*it)->FirstPos == Sketcher::none ) { // if it is not a point locking DistanceX/Y
if (((*it)->Type == Sketcher::DistanceX ||
@@ -4349,7 +4349,7 @@ int SketchObject::addCopy(const std::vector<int> &geoIdList, const Base::Vector3
auto sit = geoIdMap.find((*it)->Second);
if(sit != geoIdMap.end()) { // Second is also in the list
if( (*it)->Third == Constraint::GeoUndef ) {
if( (*it)->Third == GeoEnum::GeoUndef ) {
if (((*it)->Type == Sketcher::DistanceX ||
(*it)->Type == Sketcher::DistanceY ||
(*it)->Type == Sketcher::Distance) && ((*it)->First == (*it)->Second) && clone ) {
@@ -4615,15 +4615,15 @@ int SketchObject::removeAxesAlignment(const std::vector<int> &geoIdList)
std::vector< Constraint * > newconstrVals;
newconstrVals.reserve(constrvals.size());
int referenceHorizontal = Constraint::GeoUndef;
int referenceVertical = Constraint::GeoUndef;
int referenceHorizontal = GeoEnum::GeoUndef;
int referenceVertical = GeoEnum::GeoUndef;
int cindex = 0;
for (size_t i = 0; i < constrvals.size(); i++) {
if ( i == changeConstraintIndices[cindex].first ) {
if(changeConstraintIndices[cindex].second == Sketcher::Horizontal && nhoriz > 0) {
changed = true;
if(referenceHorizontal == Constraint::GeoUndef) {
if(referenceHorizontal == GeoEnum::GeoUndef) {
referenceHorizontal = constrvals[i]->First;
}
else {
@@ -4639,7 +4639,7 @@ int SketchObject::removeAxesAlignment(const std::vector<int> &geoIdList)
}
else if(changeConstraintIndices[cindex].second == Sketcher::Vertical && nvert > 0) {
changed = true;
if(referenceVertical == Constraint::GeoUndef) {
if(referenceVertical == GeoEnum::GeoUndef) {
referenceVertical = constrvals[i]->First;;
}
else {
@@ -6022,11 +6022,11 @@ int SketchObject::carbonCopy(App::DocumentObject * pObj, bool construction)
if( (*it)->Third>=0 )
newConstr->Third += nextgeoid;
if( (*it)->First<-2 && (*it)->First != Constraint::GeoUndef )
if( (*it)->First<-2 && (*it)->First != GeoEnum::GeoUndef )
newConstr->First -= (nextextgeoid-2);
if( (*it)->Second<-2 && (*it)->Second != Constraint::GeoUndef)
if( (*it)->Second<-2 && (*it)->Second != GeoEnum::GeoUndef)
newConstr->Second -= (nextextgeoid-2);
if( (*it)->Third<-2 && (*it)->Third != Constraint::GeoUndef)
if( (*it)->Third<-2 && (*it)->Third != GeoEnum::GeoUndef)
newConstr->Third -= (nextextgeoid-2);
newcVals.push_back(newConstr);
@@ -6147,19 +6147,19 @@ int SketchObject::delExternal(int ExtGeoId)
if (cstr->First != GeoId && cstr->Second != GeoId && cstr->Third != GeoId) {
auto copiedConstr = cstr;
if (copiedConstr->First < GeoId &&
copiedConstr->First != Constraint::GeoUndef) {
copiedConstr->First != GeoEnum::GeoUndef) {
if (cstr == copiedConstr)
copiedConstr = cstr->clone();
copiedConstr->First += 1;
}
if (copiedConstr->Second < GeoId &&
copiedConstr->Second != Constraint::GeoUndef) {
copiedConstr->Second != GeoEnum::GeoUndef) {
if (cstr == copiedConstr)
copiedConstr = cstr->clone();
copiedConstr->Second += 1;
}
if (copiedConstr->Third < GeoId &&
copiedConstr->Third != Constraint::GeoUndef) {
copiedConstr->Third != GeoEnum::GeoUndef) {
if (cstr == copiedConstr)
copiedConstr = cstr->clone();
copiedConstr->Third += 1;
@@ -6210,8 +6210,8 @@ int SketchObject::delAllExternal()
for (std::vector<Constraint *>::const_iterator it = constraints.begin(); it != constraints.end(); ++it) {
if ((*it)->First > GeoEnum::RefExt &&
((*it)->Second > GeoEnum::RefExt || (*it)->Second == Constraint::GeoUndef ) &&
((*it)->Third > GeoEnum::RefExt || (*it)->Third == Constraint::GeoUndef) ) {
((*it)->Second > GeoEnum::RefExt || (*it)->Second == GeoEnum::GeoUndef ) &&
((*it)->Third > GeoEnum::RefExt || (*it)->Third == GeoEnum::GeoUndef) ) {
Constraint *copiedConstr = (*it)->clone();
newConstraints.push_back(copiedConstr);
@@ -6243,7 +6243,7 @@ int SketchObject::delConstraintsToExternal()
const std::vector< Constraint * > &constraints = Constraints.getValuesForce();
std::vector< Constraint * > newConstraints(0);
int GeoId = GeoEnum::RefExt, NullId = Constraint::GeoUndef;
int GeoId = GeoEnum::RefExt, NullId = GeoEnum::GeoUndef;
for (std::vector<Constraint *>::const_iterator it = constraints.begin();
it != constraints.end(); ++it) {
if ( (*it)->First > GeoId
@@ -6273,7 +6273,7 @@ int SketchObject::getCompleteGeometryIndex(int GeoId) const
else if (-GeoId <= int(ExternalGeo.size()))
return -GeoId-1;
return Constraint::GeoUndef;
return GeoEnum::GeoUndef;
}
int SketchObject::getGeoIdFromCompleteGeometryIndex(int completeGeometryIndex) const
@@ -6282,7 +6282,7 @@ int SketchObject::getGeoIdFromCompleteGeometryIndex(int completeGeometryIndex) c
if(completeGeometryIndex < 0 ||
completeGeometryIndex >= completeGeometryCount)
return Constraint::GeoUndef;
return GeoEnum::GeoUndef;
if(completeGeometryIndex < Geometry.getSize())
return completeGeometryIndex;
@@ -6430,13 +6430,13 @@ void SketchObject::validateExternalLinks(void)
if ((*it)->First != GeoId && (*it)->Second != GeoId && (*it)->Third != GeoId) {
Constraint *copiedConstr = (*it)->clone();
if (copiedConstr->First < GeoId &&
copiedConstr->First != Constraint::GeoUndef)
copiedConstr->First != GeoEnum::GeoUndef)
copiedConstr->First += 1;
if (copiedConstr->Second < GeoId &&
copiedConstr->Second != Constraint::GeoUndef)
copiedConstr->Second != GeoEnum::GeoUndef)
copiedConstr->Second += 1;
if (copiedConstr->Third < GeoId &&
copiedConstr->Third != Constraint::GeoUndef)
copiedConstr->Third != GeoEnum::GeoUndef)
copiedConstr->Third += 1;
newConstraints.push_back(copiedConstr);
@@ -7455,12 +7455,12 @@ bool SketchObject::evaluateConstraint(const Constraint *constraint) const
ret = ret && (geoId >= -extGeoCount && geoId < intGeoCount);
geoId = constraint->Second;
ret = ret && ((geoId == Constraint::GeoUndef && !requireSecond)
ret = ret && ((geoId == GeoEnum::GeoUndef && !requireSecond)
||
(geoId >= -extGeoCount && geoId < intGeoCount) );
geoId = constraint->Third;
ret = ret && ((geoId == Constraint::GeoUndef && !requireThird)
ret = ret && ((geoId == GeoEnum::GeoUndef && !requireThird)
||
(geoId >= -extGeoCount && geoId < intGeoCount) );
@@ -7653,7 +7653,7 @@ double SketchObject::calculateConstraintError(int ConstrId)
//add only necessary geometry to the sketch
for(std::size_t i=0; i<GeoIdList.size(); i++){
g = GeoIdList[i];
if (g != Constraint::GeoUndef){
if (g != GeoEnum::GeoUndef){
GeoIdList[i] = sk.addGeometry(this->getGeometry(g));
}
}
@@ -7982,7 +7982,7 @@ void SketchObject::migrateSketch(void)
void SketchObject::getGeoVertexIndex(int VertexId, int &GeoId, PointPos &PosId) const
{
if (VertexId < 0 || VertexId >= int(VertexId2GeoId.size())) {
GeoId = Constraint::GeoUndef;
GeoId = GeoEnum::GeoUndef;
PosId = none;
return;
}
@@ -8160,7 +8160,7 @@ bool SketchObject::AutoLockTangencyAndPerpty(Constraint *cstr, bool bForce, bool
geoId2 = cstr->Second;
geoIdPt = cstr->Third;
posPt = cstr->ThirdPos;
if (geoIdPt == Constraint::GeoUndef){//not tangent-via-point, try endpoint-to-endpoint...
if (geoIdPt == GeoEnum::GeoUndef){//not tangent-via-point, try endpoint-to-endpoint...
geoIdPt = cstr->First;
posPt = cstr->FirstPos;
}
+5 -5
View File
@@ -487,7 +487,7 @@ public:
/** retrieves intersection points of this curve with the closest two curves around a point of this curve.
* - it includes internal and external intersecting geometry.
* - it returns Constraint::GeoUndef if no intersection is found.
* - it returns GeoEnum::GeoUndef if no intersection is found.
*/
bool seekTrimPoints(int GeoId, const Base::Vector3d &point,
int &GeoId1, Base::Vector3d &intersect1,
@@ -594,18 +594,18 @@ protected:
void addConstraint( Sketcher::ConstraintType constrType,
int firstGeoId,
Sketcher::PointPos firstPos,
int secondGeoId = Constraint::GeoUndef,
int secondGeoId = GeoEnum::GeoUndef,
Sketcher::PointPos secondPos = Sketcher::none,
int thirdGeoId = Constraint::GeoUndef,
int thirdGeoId = GeoEnum::GeoUndef,
Sketcher::PointPos thirdPos = Sketcher::none);
// creates a new constraint
std::unique_ptr<Constraint> createConstraint( Sketcher::ConstraintType constrType,
int firstGeoId,
Sketcher::PointPos firstPos,
int secondGeoId = Constraint::GeoUndef,
int secondGeoId = GeoEnum::GeoUndef,
Sketcher::PointPos secondPos = Sketcher::none,
int thirdGeoId = Constraint::GeoUndef,
int thirdGeoId = GeoEnum::GeoUndef,
Sketcher::PointPos thirdPos = Sketcher::none);
private:
+1 -1
View File
@@ -1372,7 +1372,7 @@ PyObject* SketchObjectPy::calculateAngleViaPoint(PyObject *args)
PyObject* SketchObjectPy::isPointOnCurve(PyObject *args)
{
int GeoId=Constraint::GeoUndef;
int GeoId=GeoEnum::GeoUndef;
double px=0, py=0;
if (!PyArg_ParseTuple(args, "idd", &GeoId, &px, &py))
return 0;
+6 -6
View File
@@ -825,17 +825,17 @@ void CmdSketcherMirrorSketch::activated(int iMsg)
for (std::vector<Sketcher::Constraint *>::const_iterator itc=mirrorconstr.begin(); itc != mirrorconstr.end(); ++itc) {
if ((*itc)->First != Sketcher::Constraint::GeoUndef
if ((*itc)->First != Sketcher::GeoEnum::GeoUndef
|| (*itc)->First == Sketcher::GeoEnum::HAxis
|| (*itc)->First == Sketcher::GeoEnum::VAxis)
// not x, y axes or origin
(*itc)->First -= (addedGeometries + 1);
if ((*itc)->Second != Sketcher::Constraint::GeoUndef
if ((*itc)->Second != Sketcher::GeoEnum::GeoUndef
|| (*itc)->Second == Sketcher::GeoEnum::HAxis
|| (*itc)->Second == Sketcher::GeoEnum::VAxis)
// not x, y axes or origin
(*itc)->Second -= (addedGeometries + 1);
if ((*itc)->Third != Sketcher::Constraint::GeoUndef
if ((*itc)->Third != Sketcher::GeoEnum::GeoUndef
|| (*itc)->Third == Sketcher::GeoEnum::HAxis
|| (*itc)->Third == Sketcher::GeoEnum::VAxis)
// not x, y axes or origin
@@ -903,17 +903,17 @@ void CmdSketcherMergeSketches::activated(int iMsg)
for (int i=0; i<=(addedConstraints-baseConstraints); i++){
Sketcher::Constraint * constraint= mergesketch->Constraints.getValues()[i+baseConstraints];
if (constraint->First != Sketcher::Constraint::GeoUndef &&
if (constraint->First != Sketcher::GeoEnum::GeoUndef &&
constraint->First != Sketcher::GeoEnum::HAxis &&
constraint->First != Sketcher::GeoEnum::VAxis)
// not x, y axes or origin
constraint->First += baseGeometry;
if (constraint->Second != Sketcher::Constraint::GeoUndef &&
if (constraint->Second != Sketcher::GeoEnum::GeoUndef &&
constraint->Second != Sketcher::GeoEnum::HAxis &&
constraint->Second != Sketcher::GeoEnum::VAxis)
// not x, y axes or origin
constraint->Second += baseGeometry;
if (constraint->Third != Sketcher::Constraint::GeoUndef &&
if (constraint->Third != Sketcher::GeoEnum::GeoUndef &&
constraint->Third != Sketcher::GeoEnum::HAxis &&
constraint->Third != Sketcher::GeoEnum::VAxis)
// not x, y axes or origin
+26 -26
View File
@@ -734,7 +734,7 @@ public:
virtual bool releaseButton(Base::Vector2d onSketchPos)
{
SelIdPair selIdPair;
selIdPair.GeoId = Constraint::GeoUndef;
selIdPair.GeoId = GeoEnum::GeoUndef;
selIdPair.PosId = Sketcher::none;
std::stringstream ss;
SelType newSelType = SelUnknown;
@@ -778,7 +778,7 @@ public:
ss << "ExternalEdge" << Sketcher::GeoEnum::RefExt + 1 - CrvId;
}
if (selIdPair.GeoId == Constraint::GeoUndef) {
if (selIdPair.GeoId == GeoEnum::GeoUndef) {
// If mouse is released on "blank" space, start over
selSeq.clear();
resetOngoingSequences();
@@ -1780,7 +1780,7 @@ class DrawSketchHandlerCoincident: public DrawSketchHandler
public:
DrawSketchHandlerCoincident()
{
GeoId1 = GeoId2 = Constraint::GeoUndef;
GeoId1 = GeoId2 = GeoEnum::GeoUndef;
PosId1 = PosId2 = Sketcher::none;
}
virtual ~DrawSketchHandlerCoincident()
@@ -1825,7 +1825,7 @@ public:
ss << "RootPoint";
}
else {
GeoId1 = GeoId2 = Constraint::GeoUndef;
GeoId1 = GeoId2 = GeoEnum::GeoUndef;
PosId1 = PosId2 = Sketcher::none;
Gui::Selection().clearSelection();
@@ -1833,7 +1833,7 @@ public:
}
if (GeoId1 == Constraint::GeoUndef) {
if (GeoId1 == GeoEnum::GeoUndef) {
GeoId1 = GeoId_temp;
PosId1 = PosId_temp;
Gui::Selection().addSelection(sketchgui->getSketchObject()->getDocument()->getName(),
@@ -1917,7 +1917,7 @@ bool CmdSketcherConstrainCoincident::substituteConstraintCombinations(SketchObje
for (std::vector<Constraint *>::const_iterator it = cvals.begin(); it != cvals.end(); ++it,++j) {
if( (*it)->Type == Sketcher::Tangent &&
(*it)->FirstPos == Sketcher::none && (*it)->SecondPos == Sketcher::none &&
(*it)->Third == Constraint::GeoUndef &&
(*it)->Third == GeoEnum::GeoUndef &&
(((*it)->First == GeoId1 && (*it)->Second == GeoId2) ||
((*it)->Second == GeoId1 && (*it)->First == GeoId2)) ) {
@@ -2147,7 +2147,7 @@ void CmdSketcherConstrainDistance::activated(int iMsg)
return;
}
int GeoId1, GeoId2=Constraint::GeoUndef;
int GeoId1, GeoId2=GeoEnum::GeoUndef;
Sketcher::PointPos PosId1, PosId2=Sketcher::none;
getIdsFromName(SubNames[0], Obj, GeoId1, PosId1);
if (SubNames.size() == 2)
@@ -2283,7 +2283,7 @@ void CmdSketcherConstrainDistance::applyConstraint(std::vector<SelIdPair> &selSe
SketcherGui::ViewProviderSketch* sketchgui = static_cast<SketcherGui::ViewProviderSketch*>(getActiveGuiDocument()->getInEdit());
Sketcher::SketchObject* Obj = sketchgui->getSketchObject();
int GeoId1 = Constraint::GeoUndef, GeoId2 = Constraint::GeoUndef;
int GeoId1 = GeoEnum::GeoUndef, GeoId2 = GeoEnum::GeoUndef;
Sketcher::PointPos PosId1 = Sketcher::none, PosId2 = Sketcher::none;
bool arebothpointsorsegmentsfixed=areBothPointsOrSegmentsFixed(Obj,GeoId1, GeoId2);
@@ -2472,7 +2472,7 @@ bool CmdSketcherConstrainPointOnObject::substituteConstraintCombinations( Sket
for (std::vector<Constraint *>::const_iterator it = cvals.begin(); it != cvals.end(); ++it, ++cid) {
if( (*it)->Type == Sketcher::Tangent &&
(*it)->FirstPos == Sketcher::none && (*it)->SecondPos == Sketcher::none &&
(*it)->Third == Constraint::GeoUndef &&
(*it)->Third == GeoEnum::GeoUndef &&
(((*it)->First == GeoId1 && (*it)->Second == GeoId2) ||
((*it)->Second == GeoId1 && (*it)->First == GeoId2)) ) {
@@ -2744,7 +2744,7 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg)
return;
}
int GeoId1, GeoId2=Constraint::GeoUndef;
int GeoId1, GeoId2=GeoEnum::GeoUndef;
Sketcher::PointPos PosId1, PosId2=Sketcher::none;
getIdsFromName(SubNames[0], Obj, GeoId1, PosId1);
if (SubNames.size() == 2)
@@ -2759,13 +2759,13 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg)
if (GeoId1 == Sketcher::GeoEnum::HAxis && PosId1 == Sketcher::none)
// reject horizontal axis from selection
GeoId1 = Constraint::GeoUndef;
GeoId1 = GeoEnum::GeoUndef;
else if (GeoId1 == Sketcher::GeoEnum::VAxis && PosId1 == Sketcher::none) {
GeoId1 = Sketcher::GeoEnum::HAxis;
PosId1 = Sketcher::start;
}
if (isEdge(GeoId1,PosId1) && GeoId2 == Constraint::GeoUndef) {
if (isEdge(GeoId1,PosId1) && GeoId2 == GeoEnum::GeoUndef) {
// horizontal length of a line
if (GeoId1 < 0 && GeoId1 >= Sketcher::GeoEnum::VAxis) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
@@ -2814,7 +2814,7 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg)
return;
}
else if (isVertex(GeoId1,PosId1) && GeoId2 == Constraint::GeoUndef) {
else if (isVertex(GeoId1,PosId1) && GeoId2 == GeoEnum::GeoUndef) {
// point on fixed x-coordinate
if (GeoId1 < 0 && GeoId1 >= Sketcher::GeoEnum::VAxis) {
@@ -2857,7 +2857,7 @@ void CmdSketcherConstrainDistanceX::applyConstraint(std::vector<SelIdPair> &selS
SketcherGui::ViewProviderSketch* sketchgui = static_cast<SketcherGui::ViewProviderSketch*>(getActiveGuiDocument()->getInEdit());
Sketcher::SketchObject* Obj = sketchgui->getSketchObject();
int GeoId1 = Constraint::GeoUndef, GeoId2 = Constraint::GeoUndef;
int GeoId1 = GeoEnum::GeoUndef, GeoId2 = GeoEnum::GeoUndef;
Sketcher::PointPos PosId1 = Sketcher::none, PosId2 = Sketcher::none;
switch (seqIndex) {
@@ -2996,7 +2996,7 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg)
return;
}
int GeoId1, GeoId2=Constraint::GeoUndef;
int GeoId1, GeoId2=GeoEnum::GeoUndef;
Sketcher::PointPos PosId1, PosId2=Sketcher::none;
getIdsFromName(SubNames[0], Obj, GeoId1, PosId1);
if (SubNames.size() == 2)
@@ -3010,11 +3010,11 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg)
}
if (GeoId1 == Sketcher::GeoEnum::VAxis && PosId1 == Sketcher::none) // reject vertical axis from selection
GeoId1 = Constraint::GeoUndef;
GeoId1 = GeoEnum::GeoUndef;
else if (GeoId1 == Sketcher::GeoEnum::HAxis && PosId1 == Sketcher::none)
PosId1 = Sketcher::start;
if (isEdge(GeoId1,PosId1) && GeoId2 == Constraint::GeoUndef) { // vertical length of a line
if (isEdge(GeoId1,PosId1) && GeoId2 == GeoEnum::GeoUndef) { // vertical length of a line
if (GeoId1 < 0 && GeoId1 >= Sketcher::GeoEnum::VAxis) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Cannot add a vertical length constraint on an axis!"));
@@ -3063,7 +3063,7 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg)
return;
}
else if (isVertex(GeoId1,PosId1) && GeoId2 == Constraint::GeoUndef) {
else if (isVertex(GeoId1,PosId1) && GeoId2 == GeoEnum::GeoUndef) {
// point on fixed y-coordinate
if (GeoId1 < 0 && GeoId1 >= Sketcher::GeoEnum::VAxis) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
@@ -3106,7 +3106,7 @@ void CmdSketcherConstrainDistanceY::applyConstraint(std::vector<SelIdPair> &selS
SketcherGui::ViewProviderSketch* sketchgui = static_cast<SketcherGui::ViewProviderSketch*>(getActiveGuiDocument()->getInEdit());
Sketcher::SketchObject* Obj = sketchgui->getSketchObject();
int GeoId1 = Constraint::GeoUndef, GeoId2 = Constraint::GeoUndef;
int GeoId1 = GeoEnum::GeoUndef, GeoId2 = GeoEnum::GeoUndef;
Sketcher::PointPos PosId1 = Sketcher::none, PosId2 = Sketcher::none;
switch (seqIndex) {
@@ -3722,7 +3722,7 @@ void CmdSketcherConstrainPerpendicular::applyConstraint(std::vector<SelIdPair> &
SketcherGui::ViewProviderSketch* sketchgui = static_cast<SketcherGui::ViewProviderSketch*>(getActiveGuiDocument()->getInEdit());
Sketcher::SketchObject* Obj = sketchgui->getSketchObject();
int GeoId1 = Constraint::GeoUndef, GeoId2 = Constraint::GeoUndef, GeoId3 = Constraint::GeoUndef;
int GeoId1 = GeoEnum::GeoUndef, GeoId2 = GeoEnum::GeoUndef, GeoId3 = GeoEnum::GeoUndef;
Sketcher::PointPos PosId1 = Sketcher::none, PosId2 = Sketcher::none, PosId3 = Sketcher::none;
// check if the edge already has a Block constraint
@@ -4414,7 +4414,7 @@ void CmdSketcherConstrainTangent::applyConstraint(std::vector<SelIdPair> &selSeq
Sketcher::SketchObject* Obj = sketchgui->getSketchObject();
QString strError;
int GeoId1 = Constraint::GeoUndef, GeoId2 = Constraint::GeoUndef, GeoId3 = Constraint::GeoUndef;
int GeoId1 = GeoEnum::GeoUndef, GeoId2 = GeoEnum::GeoUndef, GeoId3 = GeoEnum::GeoUndef;
Sketcher::PointPos PosId1 = Sketcher::none, PosId2 = Sketcher::none, PosId3 = Sketcher::none;
// check if the edge already has a Block constraint
@@ -5777,7 +5777,7 @@ void CmdSketcherConstrainAngle::activated(int iMsg)
}
int GeoId1, GeoId2=Constraint::GeoUndef, GeoId3 = Constraint::GeoUndef;
int GeoId1, GeoId2=GeoEnum::GeoUndef, GeoId3 = GeoEnum::GeoUndef;
Sketcher::PointPos PosId1, PosId2=Sketcher::none, PosId3 = Sketcher::none;
getIdsFromName(SubNames[0], Obj, GeoId1, PosId1);
if (SubNames.size() > 1)
@@ -5863,7 +5863,7 @@ void CmdSketcherConstrainAngle::activated(int iMsg)
std::swap(PosId1,PosId2);
}
if(isBsplinePole(Obj, GeoId1) || (GeoId2 != Constraint::GeoUndef && isBsplinePole(Obj, GeoId2))) {
if(isBsplinePole(Obj, GeoId1) || (GeoId2 != GeoEnum::GeoUndef && isBsplinePole(Obj, GeoId2))) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select an edge that is not a B-spline weight"));
return;
@@ -6026,7 +6026,7 @@ void CmdSketcherConstrainAngle::applyConstraint(std::vector<SelIdPair> &selSeq,
SketcherGui::ViewProviderSketch* sketchgui = static_cast<SketcherGui::ViewProviderSketch*>(getActiveGuiDocument()->getInEdit());
Sketcher::SketchObject* Obj = sketchgui->getSketchObject();
int GeoId1 = Constraint::GeoUndef, GeoId2 = Constraint::GeoUndef, GeoId3 = Constraint::GeoUndef;
int GeoId1 = GeoEnum::GeoUndef, GeoId2 = GeoEnum::GeoUndef, GeoId3 = GeoEnum::GeoUndef;
Sketcher::PointPos PosId1 = Sketcher::none, PosId2 = Sketcher::none, PosId3 = Sketcher::none;
switch (seqIndex) {
@@ -6396,7 +6396,7 @@ void CmdSketcherConstrainEqual::applyConstraint(std::vector<SelIdPair> &selSeq,
Sketcher::SketchObject* Obj = sketchgui->getSketchObject();
QString strError;
int GeoId1 = Constraint::GeoUndef, GeoId2 = Constraint::GeoUndef;
int GeoId1 = GeoEnum::GeoUndef, GeoId2 = GeoEnum::GeoUndef;
switch (seqIndex) {
case 0: // {SelEdge, SelEdge}
@@ -6644,7 +6644,7 @@ void CmdSketcherConstrainSymmetric::applyConstraint(std::vector<SelIdPair> &selS
Sketcher::SketchObject* Obj = sketchgui->getSketchObject();
QString strError;
int GeoId1 = Constraint::GeoUndef, GeoId2 = Constraint::GeoUndef, GeoId3 = Constraint::GeoUndef;
int GeoId1 = GeoEnum::GeoUndef, GeoId2 = GeoEnum::GeoUndef, GeoId3 = GeoEnum::GeoUndef;
Sketcher::PointPos PosId1 = Sketcher::none, PosId2 = Sketcher::none, PosId3 = Sketcher::none;
switch (seqIndex) {
+4 -3
View File
@@ -6091,14 +6091,14 @@ public:
EditMarkers.resize(0);
if(GeoId1 != Sketcher::Constraint::GeoUndef)
if(GeoId1 != Sketcher::GeoEnum::GeoUndef)
EditMarkers.emplace_back(intersect1.x, intersect1.y);
else {
auto start = sk->getPoint(GeoId, Sketcher::start);
EditMarkers.emplace_back(start.x, start.y);
}
if(GeoId2 != Sketcher::Constraint::GeoUndef)
if(GeoId2 != Sketcher::GeoEnum::GeoUndef)
EditMarkers.emplace_back(intersect2.x, intersect2.y);
else {
auto end = sk->getPoint(GeoId, Sketcher::end);
@@ -7145,7 +7145,8 @@ public:
try {
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Add slot"));
AutoConstraint lastCons = {Sketcher::None, Sketcher::Constraint::GeoUndef, Sketcher::none};
AutoConstraint lastCons = {Sketcher::None, Sketcher::GeoEnum::GeoUndef, Sketcher::none};
if (!sugConstr2.empty()) lastCons = sugConstr2.back();
ostringstream snapCon = ostringstream("");
@@ -770,7 +770,7 @@ void CmdSketcherSelectElementsAssociatedWithConstraints::activated(int iMsg)
int ConstrId = Sketcher::PropertyConstraintList::getIndexFromConstraintName(*it);
if(ConstrId < static_cast<int>(vals.size())){
if(vals[ConstrId]->First!=Constraint::GeoUndef){
if(vals[ConstrId]->First!=GeoEnum::GeoUndef){
ss.str(std::string());
switch(vals[ConstrId]->FirstPos)
@@ -789,7 +789,7 @@ void CmdSketcherSelectElementsAssociatedWithConstraints::activated(int iMsg)
elementSubNames.push_back(ss.str());
}
if(vals[ConstrId]->Second!=Constraint::GeoUndef){
if(vals[ConstrId]->Second!=GeoEnum::GeoUndef){
ss.str(std::string());
switch(vals[ConstrId]->SecondPos)
@@ -809,7 +809,7 @@ void CmdSketcherSelectElementsAssociatedWithConstraints::activated(int iMsg)
elementSubNames.push_back(ss.str());
}
if(vals[ConstrId]->Third!=Constraint::GeoUndef){
if(vals[ConstrId]->Third!=GeoEnum::GeoUndef){
ss.str(std::string());
switch(vals[ConstrId]->ThirdPos)
+8 -7
View File
@@ -317,7 +317,8 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
int preSelPnt = sketchgui->getPreselectPoint();
int preSelCrv = sketchgui->getPreselectCurve();
int preSelCrs = sketchgui->getPreselectCross();
int GeoId = Constraint::GeoUndef;
int GeoId = GeoEnum::GeoUndef;
Sketcher::PointPos PosId = Sketcher::none;
if (preSelPnt != -1)
sketchgui->getSketchObject()->getGeoVertexIndex(preSelPnt, GeoId, PosId);
@@ -345,7 +346,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
hitShapeDir = Base::Vector3d(0,1,0);
}
if (GeoId != Constraint::GeoUndef) {
if (GeoId != GeoEnum::GeoUndef) {
const Part::Geometry * hitobject = sketchgui->getSketchObject()->getGeometry(GeoId);
@@ -392,7 +393,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
AutoConstraint constr;
constr.Type = Sketcher::None;
constr.GeoId = Constraint::GeoUndef;
constr.GeoId = GeoEnum::GeoUndef;
constr.PosId = Sketcher::none;
double angle = std::abs(atan2(Dir.y, Dir.x));
if (angle < angleDevRad || (M_PI - angle) < angleDevRad )
@@ -410,7 +411,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
// Find if there are tangent constraints (currently arcs and circles)
int tangId = Constraint::GeoUndef;
int tangId = GeoEnum::GeoUndef;
// Do not consider if distance is more than that.
// Decrease this value when a candidate is found.
@@ -552,7 +553,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
}
}
if (tangId != Constraint::GeoUndef) {
if (tangId != GeoEnum::GeoUndef) {
if (tangId > getHighestCurveIndex()) // external Geometry
tangId = getHighestCurveIndex() - tangId;
// Suggest vertical constraint
@@ -608,11 +609,11 @@ void DrawSketchHandler::createAutoConstraints(const std::vector<AutoConstraint>
// In this case the caller as to set geoId2, then it will be used as target instead of geoId2
case Sketcher::Horizontal: {
Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Horizontal',%i)) ",
geoId2 != Constraint::GeoUndef ? geoId2 : geoId1);
geoId2 != GeoEnum::GeoUndef ? geoId2 : geoId1);
} break;
case Sketcher::Vertical: {
Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Vertical',%i)) ",
geoId2 != Constraint::GeoUndef ? geoId2 : geoId1);
geoId2 != GeoEnum::GeoUndef ? geoId2 : geoId1);
} break;
case Sketcher::Tangent: {
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(sketchgui->getObject());
@@ -171,10 +171,10 @@ public:
bool extended = hGrp->GetBool("ExtendedConstraintInformation",false);
if(extended) {
if(constraint->Second == Sketcher::Constraint::GeoUndef) {
if(constraint->Second == Sketcher::GeoEnum::GeoUndef) {
name = QString::fromLatin1("%1 [(%2,%3)]").arg(name).arg(constraint->First).arg(constraint->FirstPos);
}
else if(constraint->Third == Sketcher::Constraint::GeoUndef) {
else if(constraint->Third == Sketcher::GeoEnum::GeoUndef) {
name = QString::fromLatin1("%1 [(%2,%3),(%4,%5)]").arg(name).arg(constraint->First).arg(constraint->FirstPos).arg(constraint->Second).arg(constraint->SecondPos);
}
else {
@@ -997,11 +997,11 @@ void TaskSketcherConstraints::onSelectionChanged(const Gui::SelectionChanges& ms
}
}
else if(isFilter(ConstraintFilter::SpecialFilterValue::AssociatedConstraints)) { // is NOT a constraint
int geoid = Sketcher::Constraint::GeoUndef;
int geoid = Sketcher::GeoEnum::GeoUndef;
Sketcher::PointPos pointpos = Sketcher::none;
getSelectionGeoId(expr, geoid, pointpos);
if(geoid != Sketcher::Constraint::GeoUndef && pointpos == Sketcher::none){
if(geoid != Sketcher::GeoEnum::GeoUndef && pointpos == Sketcher::none){
// It is not possible to update on single addition/removal of a geometric element,
// as one removal may imply removing a constraint that should be added by a different element
// that is still selected. The necessary checks outweigh a full rebuild of the filter.
@@ -1020,7 +1020,7 @@ void TaskSketcherConstraints::getSelectionGeoId(QString expr, int & geoid, Sketc
{
QRegExp rxEdge(QString::fromLatin1("^Edge(\\d+)$"));
int pos = expr.indexOf(rxEdge);
geoid = Sketcher::Constraint::GeoUndef;
geoid = Sketcher::GeoEnum::GeoUndef;
pointpos = Sketcher::none;
if (pos > -1) {
+6 -6
View File
@@ -130,7 +130,7 @@ bool SketcherGui::ReleaseHandler(Gui::Document* doc) {
void SketcherGui::getIdsFromName(const std::string &name, const Sketcher::SketchObject* Obj,
int &GeoId, PointPos &PosId)
{
GeoId = Constraint::GeoUndef;
GeoId = GeoEnum::GeoUndef;
PosId = Sketcher::none;
if (name.size() > 4 && name.substr(0,4) == "Edge") {
@@ -154,7 +154,7 @@ void SketcherGui::getIdsFromName(const std::string &name, const Sketcher::Sketch
bool SketcherGui::checkBothExternal(int GeoId1, int GeoId2)
{
if (GeoId1 == Constraint::GeoUndef || GeoId2 == Constraint::GeoUndef)
if (GeoId1 == GeoEnum::GeoUndef || GeoId2 == GeoEnum::GeoUndef)
return false;
else
return (GeoId1 < 0 && GeoId2 < 0);
@@ -162,7 +162,7 @@ bool SketcherGui::checkBothExternal(int GeoId1, int GeoId2)
bool SketcherGui::checkBothExternalOrBSplinePoints(const Sketcher::SketchObject* Obj,int GeoId1, int GeoId2)
{
if (GeoId1 == Constraint::GeoUndef || GeoId2 == Constraint::GeoUndef)
if (GeoId1 == GeoEnum::GeoUndef || GeoId2 == GeoEnum::GeoUndef)
return false;
else
return (GeoId1 < 0 && GeoId2 < 0) || (isBsplineKnot(Obj,GeoId1) && isBsplineKnot(Obj,GeoId2)) ||
@@ -173,7 +173,7 @@ bool SketcherGui::isPointOrSegmentFixed(const Sketcher::SketchObject* Obj, int G
{
const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues();
if (GeoId == Constraint::GeoUndef)
if (GeoId == GeoEnum::GeoUndef)
return false;
else
return checkConstraint(vals, Sketcher::Block, GeoId, Sketcher::none) || GeoId <= Sketcher::GeoEnum::RtPnt || isBsplineKnot(Obj,GeoId);
@@ -183,7 +183,7 @@ bool SketcherGui::areBothPointsOrSegmentsFixed(const Sketcher::SketchObject* Obj
{
const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues();
if (GeoId1 == Constraint::GeoUndef || GeoId2 == Constraint::GeoUndef)
if (GeoId1 == GeoEnum::GeoUndef || GeoId2 == GeoEnum::GeoUndef)
return false;
else
return ((checkConstraint(vals, Sketcher::Block, GeoId1, Sketcher::none) || GeoId1 <= Sketcher::GeoEnum::RtPnt || isBsplineKnot(Obj,GeoId1)) &&
@@ -194,7 +194,7 @@ bool SketcherGui::areAllPointsOrSegmentsFixed(const Sketcher::SketchObject* Obj,
{
const std::vector< Sketcher::Constraint * > &vals = Obj->Constraints.getValues();
if (GeoId1 == Constraint::GeoUndef || GeoId2 == Constraint::GeoUndef || GeoId3 == Constraint::GeoUndef)
if (GeoId1 == GeoEnum::GeoUndef || GeoId2 == GeoEnum::GeoUndef || GeoId3 == GeoEnum::GeoUndef)
return false;
else
return ((checkConstraint(vals, Sketcher::Block, GeoId1, Sketcher::none) || GeoId1 <= Sketcher::GeoEnum::RtPnt || isBsplineKnot(Obj,GeoId1)) &&
+2 -2
View File
@@ -79,12 +79,12 @@ bool checkConstraint(const std::vector< Sketcher::Constraint * > &vals, Sketcher
inline bool isVertex(int GeoId, Sketcher::PointPos PosId)
{
return (GeoId != Sketcher::Constraint::GeoUndef && PosId != Sketcher::none);
return (GeoId != Sketcher::GeoEnum::GeoUndef && PosId != Sketcher::none);
}
inline bool isEdge(int GeoId, Sketcher::PointPos PosId)
{
return (GeoId != Sketcher::Constraint::GeoUndef && PosId == Sketcher::none);
return (GeoId != Sketcher::GeoEnum::GeoUndef && PosId == Sketcher::none);
}
}
+26 -26
View File
@@ -403,7 +403,7 @@ ViewProviderSketch::ViewProviderSketch()
rubberband = new Gui::Rubberband();
// Status message states:
subscribeToParameters();
}
@@ -852,7 +852,7 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
int GeoId;
Sketcher::PointPos PosId;
getSketchObject()->getGeoVertexIndex(edit->DragPoint, GeoId, PosId);
if (GeoId != Sketcher::Constraint::GeoUndef && PosId != Sketcher::none) {
if (GeoId != Sketcher::GeoEnum::GeoUndef && PosId != Sketcher::none) {
getDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Drag Point"));
try {
Gui::cmdAppObjectArgs(getObject(), "movePoint(%i,%i,App.Vector(%f,%f,0),%i)"
@@ -1181,7 +1181,7 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
int GeoId;
Sketcher::PointPos PosId;
getSketchObject()->getGeoVertexIndex(edit->DragPoint, GeoId, PosId);
if (GeoId != Sketcher::Constraint::GeoUndef && PosId != Sketcher::none) {
if (GeoId != Sketcher::GeoEnum::GeoUndef && PosId != Sketcher::none) {
getSketchObject()->initTemporaryMove(GeoId, PosId, false);
relative = false;
xInit = 0;
@@ -1308,7 +1308,7 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
Sketcher::PointPos PosId;
getSketchObject()->getGeoVertexIndex(edit->DragPoint, GeoId, PosId);
Base::Vector3d vec(x,y,0);
if (GeoId != Sketcher::Constraint::GeoUndef && PosId != Sketcher::none) {
if (GeoId != Sketcher::GeoEnum::GeoUndef && PosId != Sketcher::none) {
if (getSketchObject()->moveTemporaryPoint(GeoId, PosId, vec, false) == 0) {
setPositionText(Base::Vector2d(x,y));
draw(true,false);
@@ -1419,7 +1419,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2d &toPo
if (Constr->SecondPos != Sketcher::none) { // point to point distance
p1 = getSolvedSketch().getPoint(Constr->First, Constr->FirstPos);
p2 = getSolvedSketch().getPoint(Constr->Second, Constr->SecondPos);
} else if (Constr->Second != Constraint::GeoUndef) { // point to line distance
} else if (Constr->Second != GeoEnum::GeoUndef) { // point to line distance
p1 = getSolvedSketch().getPoint(Constr->First, Constr->FirstPos);
const Part::Geometry *geo = GeoById(geomlist, Constr->Second);
if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
@@ -1433,7 +1433,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2d &toPo
return;
} else if (Constr->FirstPos != Sketcher::none) {
p2 = getSolvedSketch().getPoint(Constr->First, Constr->FirstPos);
} else if (Constr->First != Constraint::GeoUndef) {
} else if (Constr->First != GeoEnum::GeoUndef) {
const Part::Geometry *geo = GeoById(geomlist, Constr->First);
if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
const Part::GeomLineSegment *lineSeg = static_cast<const Part::GeomLineSegment *>(geo);
@@ -1524,9 +1524,9 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2d &toPo
Base::Vector3d p0(0.,0.,0.);
double factor = 0.5;
if (Constr->Second != Constraint::GeoUndef) { // line to line angle
if (Constr->Second != GeoEnum::GeoUndef) { // line to line angle
Base::Vector3d dir1, dir2;
if(Constr->Third == Constraint::GeoUndef) { //angle between two lines
if(Constr->Third == GeoEnum::GeoUndef) { //angle between two lines
const Part::Geometry *geo1 = GeoById(geomlist, Constr->First);
const Part::Geometry *geo2 = GeoById(geomlist, Constr->Second);
if (geo1->getTypeId() != Part::GeomLineSegment::getClassTypeId() ||
@@ -1569,7 +1569,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2d &toPo
factor = factor * Base::sgn<double>((dir1+dir2) * vec);
}
} else if (Constr->First != Constraint::GeoUndef) { // line/arc angle
} else if (Constr->First != GeoEnum::GeoUndef) { // line/arc angle
const Part::Geometry *geo = GeoById(geomlist, Constr->First);
if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
const Part::GeomLineSegment *lineSeg = static_cast<const Part::GeomLineSegment *>(geo);
@@ -3401,7 +3401,7 @@ void ViewProviderSketch::drawConstraintIcons()
case Horizontal:
case Vertical:
{ // second icon is available only for point alignment
if ((*it)->Second != Constraint::GeoUndef &&
if ((*it)->Second != GeoEnum::GeoUndef &&
(*it)->FirstPos != Sketcher::none &&
(*it)->SecondPos != Sketcher::none) {
multipleIcons = true;
@@ -3413,7 +3413,7 @@ void ViewProviderSketch::drawConstraintIcons()
break;
case Perpendicular:
// second icon is available only when there is no common point
if ((*it)->FirstPos == Sketcher::none && (*it)->Third == Constraint::GeoUndef)
if ((*it)->FirstPos == Sketcher::none && (*it)->Third == GeoEnum::GeoUndef)
multipleIcons = true;
break;
case Equal:
@@ -4947,9 +4947,9 @@ Restart:
const Constraint *Constr = *it;
if(Constr->First < -extGeoCount || Constr->First >= intGeoCount
|| (Constr->Second!=Constraint::GeoUndef
|| (Constr->Second!=GeoEnum::GeoUndef
&& (Constr->Second < -extGeoCount || Constr->Second >= intGeoCount))
|| (Constr->Third!=Constraint::GeoUndef
|| (Constr->Third!=GeoEnum::GeoUndef
&& (Constr->Third < -extGeoCount || Constr->Third >= intGeoCount)))
{
// Constraint can refer to non-existent geometry during undo/redo
@@ -4963,7 +4963,7 @@ Restart:
case Vertical: // write the new position of the Vertical constraint
{
assert(Constr->First >= -extGeoCount && Constr->First < intGeoCount);
bool alignment = Constr->Type!=Block && Constr->Second != Constraint::GeoUndef;
bool alignment = Constr->Type!=Block && Constr->Second != GeoEnum::GeoUndef;
// get the geometry
const Part::Geometry *geo = GeoById(*geomlist, Constr->First);
@@ -5134,7 +5134,7 @@ Restart:
bool twoIcons = false;//a very local flag. It's set to true to indicate that the second dir+norm are valid and should be used
if (Constr->Third != Constraint::GeoUndef || //perpty via point
if (Constr->Third != GeoEnum::GeoUndef || //perpty via point
Constr->FirstPos != Sketcher::none) { //endpoint-to-curve or endpoint-to-endpoint perpty
int ptGeoId;
@@ -5426,7 +5426,7 @@ Restart:
pnt1 = getSketchObject()->getPoint(Constr->First, Constr->FirstPos);
pnt2 = getSketchObject()->getPoint(Constr->Second, Constr->SecondPos);
}
} else if (Constr->Second != Constraint::GeoUndef) { // point to line distance
} else if (Constr->Second != GeoEnum::GeoUndef) { // point to line distance
if (temp) {
pnt1 = getSolvedSketch().getPoint(Constr->First, Constr->FirstPos);
} else {
@@ -5448,7 +5448,7 @@ Restart:
} else {
pnt2 = getSketchObject()->getPoint(Constr->First, Constr->FirstPos);
}
} else if (Constr->First != Constraint::GeoUndef) {
} else if (Constr->First != GeoEnum::GeoUndef) {
const Part::Geometry *geo = GeoById(*geomlist, Constr->First);
if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
const Part::GeomLineSegment *lineSeg = static_cast<const Part::GeomLineSegment *>(geo);
@@ -5495,7 +5495,7 @@ Restart:
Base::Vector3d pos, relPos;
if ( Constr->Type == PointOnObject ||
Constr->Type == SnellsLaw ||
(Constr->Type == Tangent && Constr->Third != Constraint::GeoUndef) || //Tangency via point
(Constr->Type == Tangent && Constr->Third != GeoEnum::GeoUndef) || //Tangency via point
(Constr->Type == Tangent && Constr->FirstPos != Sketcher::none) //endpoint-to-curve or endpoint-to-endpoint tangency
) {
@@ -5670,13 +5670,13 @@ Restart:
{
assert(Constr->First >= -extGeoCount && Constr->First < intGeoCount);
assert((Constr->Second >= -extGeoCount && Constr->Second < intGeoCount) ||
Constr->Second == Constraint::GeoUndef);
Constr->Second == GeoEnum::GeoUndef);
SbVec3f p0;
double startangle,range,endangle;
if (Constr->Second != Constraint::GeoUndef) {
if (Constr->Second != GeoEnum::GeoUndef) {
Base::Vector3d dir1, dir2;
if(Constr->Third == Constraint::GeoUndef) { //angle between two lines
if(Constr->Third == GeoEnum::GeoUndef) { //angle between two lines
const Part::Geometry *geo1 = GeoById(*geomlist, Constr->First);
const Part::Geometry *geo2 = GeoById(*geomlist, Constr->Second);
if (geo1->getTypeId() != Part::GeomLineSegment::getClassTypeId() ||
@@ -5741,7 +5741,7 @@ Restart:
endangle = startangle + range;
} else if (Constr->First != Constraint::GeoUndef) {
} else if (Constr->First != GeoEnum::GeoUndef) {
const Part::Geometry *geo = GeoById(*geomlist, Constr->First);
if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) {
const Part::GeomLineSegment *lineSeg = static_cast<const Part::GeomLineSegment *>(geo);
@@ -5786,7 +5786,7 @@ Restart:
assert(Constr->First >= -extGeoCount && Constr->First < intGeoCount);
Base::Vector3d pnt1(0.,0.,0.), pnt2(0.,0.,0.);
if (Constr->First != Constraint::GeoUndef) {
if (Constr->First != GeoEnum::GeoUndef) {
const Part::Geometry *geo = GeoById(*geomlist, Constr->First);
if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) {
@@ -5846,7 +5846,7 @@ Restart:
Base::Vector3d pnt1(0.,0.,0.), pnt2(0.,0.,0.);
if (Constr->First != Constraint::GeoUndef) {
if (Constr->First != GeoEnum::GeoUndef) {
const Part::Geometry *geo = GeoById(*geomlist, Constr->First);
if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) {
@@ -6578,7 +6578,7 @@ QString ViewProviderSketch::appendConstraintMsg(const QString & singularmsg,
return msg;
}
inline QString intListHelper(const std::vector<int> &ints)
inline QString intListHelper(const std::vector<int> &ints)
{
QString results;
if (ints.size() < 8) { // The 8 is a bit heuristic... more than that and we shift formats
@@ -7244,7 +7244,7 @@ bool ViewProviderSketch::onDelete(const std::vector<std::string> &subList)
getSketchObject()->getGeoVertexIndex(*rit, GeoId, PosId);
}
if (GeoId != Constraint::GeoUndef) {
if (GeoId != GeoEnum::GeoUndef) {
for (std::vector< Sketcher::Constraint * >::const_iterator it= vals.begin(); it != vals.end(); ++it) {
if (((*it)->Type == Sketcher::Coincident) && (((*it)->First == GeoId && (*it)->FirstPos == PosId) ||
((*it)->Second == GeoId && (*it)->SecondPos == PosId)) ) {