From 76993592abaf7be4243bccf45851ca309846ffe4 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Fri, 15 Jun 2018 16:16:48 +0200 Subject: [PATCH] Sketcher: Diameter support for Sketch Object --- src/Mod/Sketcher/App/SketchObject.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 4e67532e66..8c564d240c 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -290,13 +290,14 @@ int SketchObject::setDatum(int ConstrId, double Datum) type != DistanceX && type != DistanceY && type != Radius && + type != Diameter && type != Angle && type != Tangent && //for tangent, value==0 is autodecide, value==Pi/2 is external and value==-Pi/2 is internal type != Perpendicular && type != SnellsLaw) return -1; - if ((type == Distance || type == Radius) && Datum <= 0) + if ((type == Distance || type == Radius || type == Diameter) && Datum <= 0) return (Datum == 0) ? -5 : -4; // copy the list @@ -328,6 +329,7 @@ int SketchObject::setDriving(int ConstrId, bool isdriving) type != DistanceX && type != DistanceY && type != Radius && + type != Diameter && type != Angle && type != SnellsLaw) return -2; @@ -365,6 +367,7 @@ int SketchObject::getDriving(int ConstrId, bool &isdriving) type != DistanceX && type != DistanceY && type != Radius && + type != Diameter && type != Angle && type != SnellsLaw) return -1; @@ -386,6 +389,7 @@ int SketchObject::toggleDriving(int ConstrId) type != DistanceX && type != DistanceY && type != Radius && + type != Diameter && type != Angle && type != SnellsLaw) return -2; @@ -921,7 +925,8 @@ int SketchObject::addCopyOfConstraints(const SketchObject &orig) newVals[i]->Type == Sketcher::Distance || newVals[i]->Type == Sketcher::DistanceX || newVals[i]->Type == Sketcher::DistanceY || - newVals[i]->Type == Sketcher::Radius || + newVals[i]->Type == Sketcher::Radius || + newVals[i]->Type == Sketcher::Diameter || newVals[i]->Type == Sketcher::Angle || newVals[i]->Type == Sketcher::SnellsLaw)) { @@ -2811,6 +2816,7 @@ int SketchObject::addSymmetric(const std::vector &geoIdList, int refGeoId, (*it)->Type == Sketcher::Distance || (*it)->Type == Sketcher::Equal || (*it)->Type == Sketcher::Radius || + (*it)->Type == Sketcher::Diameter || (*it)->Type == Sketcher::Angle || (*it)->Type == Sketcher::PointOnObject ){ Constraint *constNew = (*it)->copy(); @@ -3070,6 +3076,7 @@ int SketchObject::addCopy(const std::vector &geoIdList, const Base::Vector3 if (((*it)->Type == Sketcher::DistanceX || (*it)->Type == Sketcher::DistanceY || (*it)->Type == Sketcher::Distance || + (*it)->Type == Sketcher::Diameter || (*it)->Type == Sketcher::Radius ) && clone ) { // Distances on a single Element are mapped to equality constraints in clone mode Constraint *constNew = (*it)->copy(); @@ -3760,6 +3767,9 @@ int SketchObject::exposeInternalGeometry(int GeoId) if((*it)->Type == Sketcher::Radius && (*it)->First == controlpointgeoids[0]) { isfirstweightconstrained = true ; } + else if((*it)->Type == Sketcher::Diameter && (*it)->First == controlpointgeoids[0]) { + isfirstweightconstrained = true ; + } } } @@ -4141,8 +4151,8 @@ int SketchObject::deleteUnusedInternalGeometry(int GeoId, bool delgeoid) } } - // ignore radiuses - else if ((*itc)->Type!=Sketcher::Radius && ( (*itc)->Second == (*it) || (*itc)->First == (*it) || (*itc)->Third == (*it)) ) + // ignore radiuses and diameters + else if (((*itc)->Type!=Sketcher::Radius && (*itc)->Type!=Sketcher::Diameter) && ( (*itc)->Second == (*it) || (*itc)->First == (*it) || (*itc)->Third == (*it)) ) (*ita)++; } @@ -4586,7 +4596,8 @@ int SketchObject::carbonCopy(App::DocumentObject * pObj, bool construction) for (std::vector< Sketcher::Constraint * >::const_iterator it= scvals.begin(); it != scvals.end(); ++it,nextcid++,sourceid++) { if ((*it)->Type == Sketcher::Distance || - (*it)->Type == Sketcher::Radius || + (*it)->Type == Sketcher::Radius || + (*it)->Type == Sketcher::Diameter || (*it)->Type == Sketcher::Angle || (*it)->Type == Sketcher::SnellsLaw) { // then we link its value to the parent @@ -5676,6 +5687,9 @@ bool SketchObject::evaluateConstraint(const Constraint *constraint) const case Radius: requireFirst = true; break; + case Diameter: + requireFirst = true; + break; case Horizontal: case Vertical: requireFirst = true;