+// ============================================================================
+// Function: moveFeature
+// Purpose: move given feature in appropriate group
+// ============================================================================
+bool SketchSolver_Manager::moveFeature(
+ const std::shared_ptr<SketchPlugin_Feature>& theMovedFeature,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theFrom,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theTo)
+{
+ SketchGroupPtr aGroup = findGroup(theMovedFeature);
+ if (!aGroup)
+ return false;
+
+ std::shared_ptr<SketchPlugin_Constraint> aConstraint =
+ std::dynamic_pointer_cast<SketchPlugin_Constraint>(theMovedFeature);
+ if (aConstraint)
+ {
+ std::shared_ptr<GeomDataAPI_Point2D> aPntAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>
+ (aConstraint->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ if (aPntAttr)
+ {
+ aPntAttr->setValue(theTo);
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ }
+ return true;
+ }
+
+ aGroup->blockEvents(true);
+ return aGroup->moveFeature(theMovedFeature, theFrom, theTo);
+}
+
+// ============================================================================
+// Function: moveAttribute
+// Purpose: move given attribute in appropriate group
+// ============================================================================
+bool SketchSolver_Manager::moveAttribute(
+ const std::shared_ptr<ModelAPI_Attribute>& theMovedAttribute,
+ const int theMovedPointIndex,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theFrom,
+ const std::shared_ptr<GeomAPI_Pnt2d>& theTo)
+{
+ FeaturePtr anOwner = ModelAPI_Feature::feature(theMovedAttribute->owner());
+ std::shared_ptr<SketchPlugin_Constraint> aConstraint =
+ std::dynamic_pointer_cast<SketchPlugin_Constraint>(anOwner);
+ if (aConstraint)
+ {
+ setPoint(theMovedAttribute, theMovedPointIndex, theTo);
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ return true;
+ }
+
+ std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(anOwner);
+ SketchGroupPtr aGroup;
+ if (aSketchFeature)
+ aGroup = findGroup(aSketchFeature);
+ if (!aGroup) {
+ setPoint(theMovedAttribute, theMovedPointIndex, theTo);
+ return false;
+ }
+
+ aGroup->blockEvents(true);
+ return aGroup->movePoint(theMovedAttribute, theMovedPointIndex, theFrom, theTo);
+}
+