Skip to content

Commit

Permalink
Sketcher: Diameter support for Sketch Object
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahtahiriyo authored and wwmayer committed Jul 29, 2018
1 parent 1e2df10 commit 1032608
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/Mod/Sketcher/App/SketchObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -386,6 +389,7 @@ int SketchObject::toggleDriving(int ConstrId)
type != DistanceX &&
type != DistanceY &&
type != Radius &&
type != Diameter &&
type != Angle &&
type != SnellsLaw)
return -2;
Expand Down Expand Up @@ -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)) {

Expand Down Expand Up @@ -2811,6 +2816,7 @@ int SketchObject::addSymmetric(const std::vector<int> &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();
Expand Down Expand Up @@ -3070,6 +3076,7 @@ int SketchObject::addCopy(const std::vector<int> &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();
Expand Down Expand Up @@ -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 ;
}
}
}

Expand Down Expand Up @@ -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)++;

}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1032608

Please sign in to comment.