Sketcher new Feature: Non-driving constraints (aka Driven constraints or dimensions)
==================================================================================== It allows to enable and disable a constraint in the constraint list. When disabled, the constraints current value is shown, but its value is not enforced (it is driven by the other constraints and user interaction). A disabled constraint can be enabled (as far as it is enforceable, see non-driving constraints to external geometry below). The sketcher functionality has been extended to support non-driving constraints to external geometry elements. This were previously excluded from the possibility of creating a constraint on them (as their values depend on other sketches and would be redundant with the unchanged value or conflicting when value is changed). Now these constraints are created as non-driving, but as they are not enforceable, the UI does not allow you to make them driving. The constraint filter has been extended to include a Non-Driving constraints category. Thanks again to Werner for his continuous support, and specially in this case to DeepSOIC, as he pointed towards a much better implementation solution than my original idea.
This commit is contained in:
@@ -219,6 +219,60 @@ int SketchObject::setDatum(int ConstrId, double Datum)
|
||||
return err;
|
||||
}
|
||||
|
||||
int SketchObject::setDriving(int ConstrId, bool isdriving)
|
||||
{
|
||||
const std::vector<Constraint *> &vals = this->Constraints.getValues();
|
||||
|
||||
if (ConstrId < 0 || ConstrId >= int(vals.size()))
|
||||
return -1;
|
||||
|
||||
ConstraintType type = vals[ConstrId]->Type;
|
||||
|
||||
if (type != Distance &&
|
||||
type != DistanceX &&
|
||||
type != DistanceY &&
|
||||
type != Radius &&
|
||||
type != Angle &&
|
||||
type != SnellsLaw)
|
||||
return -1;
|
||||
|
||||
// copy the list
|
||||
std::vector<Constraint *> newVals(vals);
|
||||
// clone the changed Constraint
|
||||
Constraint *constNew = vals[ConstrId]->clone();
|
||||
constNew->isDriving = isdriving;
|
||||
newVals[ConstrId] = constNew;
|
||||
this->Constraints.setValues(newVals);
|
||||
delete constNew;
|
||||
|
||||
int err = solve();
|
||||
if (err)
|
||||
this->Constraints.setValues(vals);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int SketchObject::getDriving(int ConstrId, bool &isdriving)
|
||||
{
|
||||
const std::vector<Constraint *> &vals = this->Constraints.getValues();
|
||||
|
||||
if (ConstrId < 0 || ConstrId >= int(vals.size()))
|
||||
return -1;
|
||||
|
||||
ConstraintType type = vals[ConstrId]->Type;
|
||||
|
||||
if (type != Distance &&
|
||||
type != DistanceX &&
|
||||
type != DistanceY &&
|
||||
type != Radius &&
|
||||
type != Angle &&
|
||||
type != SnellsLaw)
|
||||
return -1;
|
||||
|
||||
isdriving=vals[ConstrId]->isDriving;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SketchObject::movePoint(int GeoId, PointPos PosId, const Base::Vector3d& toPoint, bool relative)
|
||||
{
|
||||
Sketch sketch;
|
||||
|
||||
Reference in New Issue
Block a user