SketchPlugin_ConstraintBase::erase();
}
-#include <ModelAPI_AttributeRefAttrList.h>
void SketchPlugin_ConstraintMirror::attributeChanged(const std::string& theID)
{
if (theID == MIRROR_LIST_ID()) {
AttributeRefListPtr aRefListOfMirrored = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
data()->attribute(SketchPlugin_Constraint::ENTITY_C()));
std::list<ObjectPtr> aTargetList = aRefListOfMirrored->list();
- std::list<ObjectPtr>::reverse_iterator aTargetIter = aTargetList.rbegin();
- for (; aTargetIter != aTargetList.rend(); aTargetIter++) {
+ std::list<ObjectPtr>::iterator aTargetIter = aTargetList.begin();
+ for (; aTargetIter != aTargetList.end(); aTargetIter++) {
FeaturePtr aFeature = ModelAPI_Feature::feature(*aTargetIter);
if (aFeature)
aDoc->removeFeature(aFeature);
return;
// Clear list of objects
- AttributeRefListPtr aRefListOfRotated = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
- data()->attribute(SketchPlugin_Constraint::ENTITY_B()));
+ AttributeRefListPtr aRefListOfRotated = reflist(SketchPlugin_Constraint::ENTITY_B());
std::list<ObjectPtr> aTargetList = aRefListOfRotated->list();
std::list<ObjectPtr>::iterator aTargetIter = aTargetList.begin();
std::set<FeaturePtr> aFeaturesToBeRemoved;
for (int i = 0; i < aNbCopies && aTargetIter != aTargetList.end(); i++, aTargetIter++) {
aRefListOfRotated->remove(*aTargetIter);
// remove the corresponding feature from the sketch
- ResultConstructionPtr aRC =
- std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aTargetIter);
- DocumentPtr aDoc = aRC ? aRC->document() : DocumentPtr();
- FeaturePtr aFeature = aDoc ? aDoc->feature(aRC) : FeaturePtr();
+ FeaturePtr aFeature = ModelAPI_Feature::feature(*aTargetIter);
if (aFeature)
aFeaturesToBeRemoved.insert(aFeature);
}
ModelAPI_Tools::removeFeaturesAndReferences(aFeaturesToBeRemoved);
aRefListOfRotated->clear();
- std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
- data()->attribute(SketchPlugin_Constraint::ENTITY_A()))->clear();
- std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
- data()->attribute(SketchPlugin_Constraint::ENTITY_B()))->clear();
+ reflist(SketchPlugin_Constraint::ENTITY_A())->clear();
}
}
}
int aNbCopies = integer(NUMBER_OF_OBJECTS_ID())->value()-1;
if (aNbCopies <= 0)
return;
+
+ DocumentPtr aDoc = document();
// Clear list of objects
- AttributeRefListPtr aRefListOfTranslated = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
- data()->attribute(SketchPlugin_Constraint::ENTITY_B()));
+ AttributeRefListPtr aRefListOfTranslated = reflist(SketchPlugin_Constraint::ENTITY_B());
std::list<ObjectPtr> aTargetList = aRefListOfTranslated->list();
std::list<ObjectPtr>::iterator aTargetIter = aTargetList.begin();
while (aTargetIter != aTargetList.end()) {
aTargetIter++;
for (int i = 0; i < aNbCopies && aTargetIter != aTargetList.end(); i++, aTargetIter++) {
aRefListOfTranslated->remove(*aTargetIter);
- // remove the corresponding feature from the sketch
- ResultConstructionPtr aRC =
- std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aTargetIter);
- DocumentPtr aDoc = aRC ? aRC->document() : DocumentPtr();
- FeaturePtr aFeature = aDoc ? aDoc->feature(aRC) : FeaturePtr();
+ FeaturePtr aFeature = ModelAPI_Feature::feature(*aTargetIter);
if (aFeature)
aDoc->removeFeature(aFeature);
}
}
aRefListOfTranslated->clear();
- std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
- data()->attribute(SketchPlugin_Constraint::ENTITY_A()))->clear();
- std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
- data()->attribute(SketchPlugin_Constraint::ENTITY_B()))->clear();
+ reflist(SketchPlugin_Constraint::ENTITY_A())->clear();
}
}
}
aConstraint.execute()
refattrA.setAttr(aSketchPointCoords)
refattrB.setAttr(aLineAStartPoint)
+aSession.finishOperation()
+# set flyout point then abort operation, after that check the Distance is correct
+aSession.startOperation()
aFlyoutPoint = geomDataAPI_Point2D(aConstraint.attribute("ConstraintFlyoutValuePnt"))
aFlyoutPoint.setValue(50.0, 100.0)
aSession.finishOperation()
+aSession.abortOperation()
assert (refattrA.isInitialized())
assert (refattrB.isInitialized())
assert (aDistance.isInitialized())
assert (aLineResult is not None)
refattrA.setObject(aLineResult)
refattrB.setAttr(aSketchPointCoords)
+aSession.finishOperation()
+# set flyout point then abort operation, after that check the Distance is correct
+aSession.startOperation()
aFlyoutPoint = geomDataAPI_Point2D(aConstraint.attribute("ConstraintFlyoutValuePnt"))
aFlyoutPoint.setValue(50.0, 100.0)
aSession.finishOperation()
+aSession.abortOperation()
assert (refattrA.isInitialized())
assert (refattrB.isInitialized())
assert (aDistance.isInitialized())