Sketcher: Python Interface for Constraint Virtual Space

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

set/get/toggle python interface to enable to set the virtual space status of a constraint via SketchObject.
This commit is contained in:
Abdullah Tahiri
2017-12-17 05:57:35 +01:00
committed by wmayer
parent 804bbbc9cd
commit 5e11e37712
5 changed files with 130 additions and 3 deletions

View File

@@ -417,6 +417,62 @@ int SketchObject::toggleDriving(int ConstrId)
return 0;
}
int SketchObject::setVirtualSpace(int ConstrId, bool isinvirtualspace)
{
const std::vector<Constraint *> &vals = this->Constraints.getValues();
if (ConstrId < 0 || ConstrId >= int(vals.size()))
return -1;
// copy the list
std::vector<Constraint *> newVals(vals);
// clone the changed Constraint
Constraint *constNew = vals[ConstrId]->clone();
constNew->isInVirtualSpace = isinvirtualspace;
newVals[ConstrId] = constNew;
this->Constraints.setValues(newVals);
delete constNew;
return 0;
}
int SketchObject::getVirtualSpace(int ConstrId, bool &isinvirtualspace)
{
const std::vector<Constraint *> &vals = this->Constraints.getValues();
if (ConstrId < 0 || ConstrId >= int(vals.size()))
return -1;
isinvirtualspace=vals[ConstrId]->isInVirtualSpace;
return 0;
}
int SketchObject::toggleVirtualSpace(int ConstrId)
{
const std::vector<Constraint *> &vals = this->Constraints.getValues();
if (ConstrId < 0 || ConstrId >= int(vals.size()))
return -1;
// copy the list
std::vector<Constraint *> newVals(vals);
// clone the changed Constraint
Constraint *constNew = vals[ConstrId]->clone();
constNew->isInVirtualSpace = !constNew->isInVirtualSpace;
newVals[ConstrId] = constNew;
this->Constraints.setValues(newVals);
delete constNew;
return 0;
}
int SketchObject::setUpSketch()
{
return solvedSketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),