Sketcher: Diameter support for Sketch Object

This commit is contained in:
Abdullah Tahiri
2018-06-15 16:16:48 +02:00
committed by wmayer
parent b320f15909
commit 76993592ab

View File

@@ -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<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();
@@ -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();
@@ -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;