-void SketchPlugin_MultiTranslation::shiftFeature(
- ObjectPtr theInitial, ObjectPtr theTarget, double theDeltaX, double theDeltaY)
-{
- FeaturePtr anInitialFeature = ModelAPI_Feature::feature(theInitial);
- FeaturePtr aTargetFeature = ModelAPI_Feature::feature(theTarget);
-
- // block feature update
- aTargetFeature->data()->blockSendAttributeUpdated(true);
-
- std::list<AttributePtr> anInitAttrList =
- anInitialFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
- std::list<AttributePtr> aTargetAttrList =
- aTargetFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
- std::list<AttributePtr>::iterator anInitIt = anInitAttrList.begin();
- std::list<AttributePtr>::iterator aTargetIt = aTargetAttrList.begin();
- for (; anInitIt != anInitAttrList.end(); anInitIt++, aTargetIt++) {
- std::shared_ptr<GeomDataAPI_Point2D> aPointFrom =
- std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anInitIt);
- std::shared_ptr<GeomDataAPI_Point2D> aPointTo =
- std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*aTargetIt);
- aPointTo->setValue(aPointFrom->x() + theDeltaX, aPointFrom->y() + theDeltaY);
- }
-
- // unblock feature update
- aTargetFeature->data()->blockSendAttributeUpdated(false);
-}