From: nds Date: Mon, 23 Jun 2014 14:14:11 +0000 (+0400) Subject: refs #80 - Sketch base GUI: create/draw point, circle and arc X-Git-Tag: V_0.4.4~263^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=23b712002a59e78673d8fce54c24aa4a7ab9ee51;p=modules%2Fshaper.git refs #80 - Sketch base GUI: create/draw point, circle and arc The PartSet presentation's functionality should be partially moved to SketchPlugin and a custom widget creation. 1. feature move() method is moved to the sketch plugin feature. --- diff --git a/src/PartSet/PartSet_ConstraintDistancePrs.cpp b/src/PartSet/PartSet_ConstraintDistancePrs.cpp index 809ea8c3c..586a95246 100644 --- a/src/PartSet/PartSet_ConstraintDistancePrs.cpp +++ b/src/PartSet/PartSet_ConstraintDistancePrs.cpp @@ -206,10 +206,6 @@ PartSet_SelectionMode PartSet_ConstraintDistancePrs::getNextMode(const std::stri return SM_FirstPoint; } -void PartSet_ConstraintDistancePrs::move(double theDeltaX, double theDeltaY) -{ -} - double PartSet_ConstraintDistancePrs::distanceToPoint(FeaturePtr theFeature, double theX, double theY) { diff --git a/src/PartSet/PartSet_ConstraintDistancePrs.h b/src/PartSet/PartSet_ConstraintDistancePrs.h index 7bac945e6..717d704a8 100644 --- a/src/PartSet/PartSet_ConstraintDistancePrs.h +++ b/src/PartSet/PartSet_ConstraintDistancePrs.h @@ -64,11 +64,6 @@ public: /// \return next attribute selection mode virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const; - /// \brief Move the full feature. - /// \param theDeltaX the delta for X coordinate is moved - /// \param theDeltaY the delta for Y coordinate is moved - virtual void move(double theDeltaX, double theDeltaY); - /// Return the distance between the feature and the point /// \param theFeature feature object /// \param theX the horizontal coordinate of the point diff --git a/src/PartSet/PartSet_ConstraintLengthPrs.cpp b/src/PartSet/PartSet_ConstraintLengthPrs.cpp index a594bc6d3..16aecb5f8 100644 --- a/src/PartSet/PartSet_ConstraintLengthPrs.cpp +++ b/src/PartSet/PartSet_ConstraintLengthPrs.cpp @@ -204,10 +204,6 @@ PartSet_SelectionMode PartSet_ConstraintLengthPrs::getNextMode(const std::string return SM_FirstPoint; } -void PartSet_ConstraintLengthPrs::move(double theDeltaX, double theDeltaY) -{ -} - double PartSet_ConstraintLengthPrs::distanceToPoint(FeaturePtr theFeature, double theX, double theY) { diff --git a/src/PartSet/PartSet_ConstraintLengthPrs.h b/src/PartSet/PartSet_ConstraintLengthPrs.h index 69fef7848..a29465de3 100644 --- a/src/PartSet/PartSet_ConstraintLengthPrs.h +++ b/src/PartSet/PartSet_ConstraintLengthPrs.h @@ -64,11 +64,6 @@ public: /// \return next attribute selection mode virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const; - /// \brief Move the full feature. - /// \param theDeltaX the delta for X coordinate is moved - /// \param theDeltaY the delta for Y coordinate is moved - virtual void move(double theDeltaX, double theDeltaY); - /// Return the distance between the feature and the point /// \param theFeature feature object /// \param theX the horizontal coordinate of the point diff --git a/src/PartSet/PartSet_ConstraintRadiusPrs.cpp b/src/PartSet/PartSet_ConstraintRadiusPrs.cpp index 394ae38dc..305351ef2 100644 --- a/src/PartSet/PartSet_ConstraintRadiusPrs.cpp +++ b/src/PartSet/PartSet_ConstraintRadiusPrs.cpp @@ -243,10 +243,6 @@ PartSet_SelectionMode PartSet_ConstraintRadiusPrs::getNextMode(const std::string return SM_FirstPoint; } -void PartSet_ConstraintRadiusPrs::move(double theDeltaX, double theDeltaY) -{ -} - double PartSet_ConstraintRadiusPrs::distanceToPoint(FeaturePtr theFeature, double theX, double theY) { diff --git a/src/PartSet/PartSet_ConstraintRadiusPrs.h b/src/PartSet/PartSet_ConstraintRadiusPrs.h index 9767c766f..7f6187954 100644 --- a/src/PartSet/PartSet_ConstraintRadiusPrs.h +++ b/src/PartSet/PartSet_ConstraintRadiusPrs.h @@ -67,11 +67,6 @@ public: /// \return next attribute selection mode virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const; - /// \brief Move the full feature. - /// \param theDeltaX the delta for X coordinate is moved - /// \param theDeltaY the delta for Y coordinate is moved - virtual void move(double theDeltaX, double theDeltaY); - /// Return the distance between the feature and the point /// \param theFeature feature object /// \param theX the horizontal coordinate of the point diff --git a/src/PartSet/PartSet_FeatureArcPrs.cpp b/src/PartSet/PartSet_FeatureArcPrs.cpp index ea9692edc..56b671fe4 100644 --- a/src/PartSet/PartSet_FeatureArcPrs.cpp +++ b/src/PartSet/PartSet_FeatureArcPrs.cpp @@ -94,25 +94,6 @@ PartSet_SelectionMode PartSet_FeatureArcPrs::getNextMode(const std::string& theA return aMode; } -void PartSet_FeatureArcPrs::move(double theDeltaX, double theDeltaY) -{ - boost::shared_ptr aData = feature()->data(); - if (!aData->isValid()) - return; - - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast(aData->attribute(ARC_ATTR_CENTER)); - aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); - - boost::shared_ptr aPoint2 = - boost::dynamic_pointer_cast(aData->attribute(ARC_ATTR_START)); - aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY); - - boost::shared_ptr aPoint3 = - boost::dynamic_pointer_cast(aData->attribute(ARC_ATTR_END)); - aPoint3->setValue(aPoint3->x() + theDeltaX, aPoint3->y() + theDeltaY); -} - double PartSet_FeatureArcPrs::distanceToPoint(FeaturePtr theFeature, double theX, double theY) { diff --git a/src/PartSet/PartSet_FeatureArcPrs.h b/src/PartSet/PartSet_FeatureArcPrs.h index 28d9ab669..2ebc17e7b 100644 --- a/src/PartSet/PartSet_FeatureArcPrs.h +++ b/src/PartSet/PartSet_FeatureArcPrs.h @@ -61,11 +61,6 @@ public: static void projectPointOnFeature(FeaturePtr theFeature, FeaturePtr theSketch, gp_Pnt& thePoint, Handle_V3d_View theView, double& theX, double& theY); - /// \brief Move the full feature. - /// \param theDeltaX the delta for X coordinate is moved - /// \param theDeltaY the delta for Y coordinate is moved - virtual void move(double theDeltaX, double theDeltaY); - /// Return the distance between the feature and the point /// \param theFeature feature object /// \param theX the horizontal coordinate of the point diff --git a/src/PartSet/PartSet_FeatureCirclePrs.cpp b/src/PartSet/PartSet_FeatureCirclePrs.cpp index 70f957134..1de3bb5e3 100644 --- a/src/PartSet/PartSet_FeatureCirclePrs.cpp +++ b/src/PartSet/PartSet_FeatureCirclePrs.cpp @@ -92,17 +92,6 @@ PartSet_SelectionMode PartSet_FeatureCirclePrs::getNextMode(const std::string& t return aMode; } -void PartSet_FeatureCirclePrs::move(double theDeltaX, double theDeltaY) -{ - boost::shared_ptr aData = feature()->data(); - if (!aData->isValid()) - return; - - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast(aData->attribute(CIRCLE_ATTR_CENTER)); - aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); -} - double PartSet_FeatureCirclePrs::distanceToPoint(FeaturePtr theFeature, double theX, double theY) { diff --git a/src/PartSet/PartSet_FeatureCirclePrs.h b/src/PartSet/PartSet_FeatureCirclePrs.h index c3ec1c667..dccead225 100644 --- a/src/PartSet/PartSet_FeatureCirclePrs.h +++ b/src/PartSet/PartSet_FeatureCirclePrs.h @@ -51,11 +51,6 @@ public: /// \return next attribute selection mode virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const; - /// \brief Move the full feature. - /// \param theDeltaX the delta for X coordinate is moved - /// \param theDeltaY the delta for Y coordinate is moved - virtual void move(double theDeltaX, double theDeltaY); - /// Return the distance between the feature and the point /// \param theFeature feature object /// \param theX the horizontal coordinate of the point diff --git a/src/PartSet/PartSet_FeatureLinePrs.cpp b/src/PartSet/PartSet_FeatureLinePrs.cpp index 17c516701..ac173167f 100644 --- a/src/PartSet/PartSet_FeatureLinePrs.cpp +++ b/src/PartSet/PartSet_FeatureLinePrs.cpp @@ -107,21 +107,6 @@ PartSet_SelectionMode PartSet_FeatureLinePrs::getNextMode(const std::string& the return aMode; } -void PartSet_FeatureLinePrs::move(double theDeltaX, double theDeltaY) -{ - boost::shared_ptr aData = feature()->data(); - if (!aData->isValid()) - return; - - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast(aData->attribute(LINE_ATTR_START)); - aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); - - boost::shared_ptr aPoint2 = - boost::dynamic_pointer_cast(aData->attribute(LINE_ATTR_END)); - aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY); -} - void PartSet_FeatureLinePrs::projectPointOnLine(FeaturePtr theFeature, const PartSet_SelectionMode& theMode, const gp_Pnt& thePoint, Handle(V3d_View) theView, diff --git a/src/PartSet/PartSet_FeatureLinePrs.h b/src/PartSet/PartSet_FeatureLinePrs.h index 128c12745..13d973ec6 100644 --- a/src/PartSet/PartSet_FeatureLinePrs.h +++ b/src/PartSet/PartSet_FeatureLinePrs.h @@ -58,11 +58,6 @@ public: /// \return next attribute selection mode virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const; - /// \brief Move the full feature. - /// \param theDeltaX the delta for X coordinate is moved - /// \param theDeltaY the delta for Y coordinate is moved - virtual void move(double theDeltaX, double theDeltaY); - /// Project the point on a feature /// \param theFeature the feature to be projected on /// \param theMode the selection mode diff --git a/src/PartSet/PartSet_FeaturePointPrs.cpp b/src/PartSet/PartSet_FeaturePointPrs.cpp index df9c76bc9..569c771e0 100644 --- a/src/PartSet/PartSet_FeaturePointPrs.cpp +++ b/src/PartSet/PartSet_FeaturePointPrs.cpp @@ -71,17 +71,6 @@ PartSet_SelectionMode PartSet_FeaturePointPrs::getNextMode(const std::string& th return aMode; } -void PartSet_FeaturePointPrs::move(double theDeltaX, double theDeltaY) -{ - boost::shared_ptr aData = feature()->data(); - if (!aData->isValid()) - return; - - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast(aData->attribute(POINT_ATTR_COORD)); - aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); -} - double PartSet_FeaturePointPrs::distanceToPoint(FeaturePtr theFeature, double theX, double theY) { diff --git a/src/PartSet/PartSet_FeaturePointPrs.h b/src/PartSet/PartSet_FeaturePointPrs.h index f0962585e..cc344dc25 100644 --- a/src/PartSet/PartSet_FeaturePointPrs.h +++ b/src/PartSet/PartSet_FeaturePointPrs.h @@ -48,11 +48,6 @@ public: /// \return next attribute selection mode virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const; - /// \brief Move the full feature. - /// \param theDeltaX the delta for X coordinate is moved - /// \param theDeltaY the delta for Y coordinate is moved - virtual void move(double theDeltaX, double theDeltaY); - /// Return the distance between the feature and the point /// \param theFeature feature object /// \param theX the horizontal coordinate of the point diff --git a/src/PartSet/PartSet_FeaturePrs.h b/src/PartSet/PartSet_FeaturePrs.h index 609b16973..75aca1bb9 100644 --- a/src/PartSet/PartSet_FeaturePrs.h +++ b/src/PartSet/PartSet_FeaturePrs.h @@ -59,11 +59,6 @@ public: /// \return next attribute selection mode virtual PartSet_SelectionMode getNextMode(const std::string& theAttribute) const = 0; - /// \brief Move the full feature. - /// \param theDeltaX the delta for X coordinate is moved - /// \param theDeltaY the delta for Y coordinate is moved - virtual void move(double theDeltaX, double theDeltaY) = 0; - /// Return the distance between the feature and the point /// \param theFeature feature object /// \param theX the horizontal coordinate of the point diff --git a/src/PartSet/PartSet_OperationEditConstraint.cpp b/src/PartSet/PartSet_OperationEditConstraint.cpp index ee536279b..0c3fae216 100644 --- a/src/PartSet/PartSet_OperationEditConstraint.cpp +++ b/src/PartSet/PartSet_OperationEditConstraint.cpp @@ -145,10 +145,7 @@ void PartSet_OperationEditConstraint::mouseMoved(QMouseEvent* theEvent, Handle(V double aX, anY; PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); - /*double aDeltaX = aX - aCurX; - double aDeltaY = anY - aCurY; - PartSet_Tools::moveFeature(feature(), aDeltaX, aDeltaY);*/ if (feature()->getKind() == PartSet_ConstraintRadiusPrs::getKind()) { boost::shared_ptr anArcPrs = boost::dynamic_pointer_cast(myFeaturePrs); @@ -157,15 +154,6 @@ void PartSet_OperationEditConstraint::mouseMoved(QMouseEvent* theEvent, Handle(V } } myFeaturePrs->setPoint(aX, anY, SM_LastPoint); - - - /*std::list::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end(); - for (; anIt != aLast; anIt++) { - FeaturePtr aFeature = (*anIt).feature(); - if (!aFeature || aFeature == feature()) - continue; - PartSet_Tools::moveFeature(aFeature, aDeltaX, aDeltaY); - }*/ } sendFeatures(); diff --git a/src/PartSet/PartSet_OperationEditFeature.cpp b/src/PartSet/PartSet_OperationEditFeature.cpp index fb8690720..e0d52827d 100644 --- a/src/PartSet/PartSet_OperationEditFeature.cpp +++ b/src/PartSet/PartSet_OperationEditFeature.cpp @@ -132,14 +132,17 @@ void PartSet_OperationEditFeature::mouseMoved(QMouseEvent* theEvent, Handle(V3d_ double aDeltaX = aX - aCurX; double aDeltaY = anY - aCurY; - PartSet_Tools::moveFeature(feature(), aDeltaX, aDeltaY); + boost::shared_ptr aSketchFeature = + boost::dynamic_pointer_cast(feature()); + aSketchFeature->move(aDeltaX, aDeltaY); std::list::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end(); for (; anIt != aLast; anIt++) { FeaturePtr aFeature = (*anIt).feature(); if (!aFeature || aFeature == feature()) continue; - PartSet_Tools::moveFeature(aFeature, aDeltaX, aDeltaY); + aSketchFeature = boost::dynamic_pointer_cast(aFeature); + aSketchFeature->move(aDeltaX, aDeltaY); } } sendFeatures(); diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 58ed85bb2..8f3090ec5 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -215,17 +215,6 @@ double PartSet_Tools::distanceToPoint(FeaturePtr theFeature, return aDelta; } -void PartSet_Tools::moveFeature(FeaturePtr theFeature, double theDeltaX, double theDeltaY) -{ - if (!theFeature) - return; - - boost::shared_ptr aFeaturePrs = PartSet_Tools::createFeaturePrs( - theFeature->getKind(), FeaturePtr(), theFeature); - if (aFeaturePrs) - aFeaturePrs->move(theDeltaX, theDeltaY); -} - boost::shared_ptr PartSet_Tools::document() { return ModelAPI_PluginManager::get()->rootDocument(); diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h index 7b81b3f10..cf841a81b 100644 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -69,12 +69,6 @@ public: static FeaturePtr nearestFeature(QPoint thePoint, Handle_V3d_View theView, FeaturePtr theSketch, const std::list& theFeatures); - /// \brief Move the feature. - /// \param theFeature the source feature - /// \param theDeltaX the delta for X coordinate is moved - /// \param theDeltaY the delta for Y coordinate is moved - static void moveFeature(FeaturePtr theFeature, double theDeltaX, double theDeltaY); - /// Returns pointer to the root document. static boost::shared_ptr document(); diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index e390c6af2..566ef84d4 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -69,3 +69,22 @@ const boost::shared_ptr& SketchPlugin_Arc::preview() } return getPreview(); } + +void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY) +{ + boost::shared_ptr aData = data(); + if (!aData->isValid()) + return; + + boost::shared_ptr aPoint1 = + boost::dynamic_pointer_cast(aData->attribute(ARC_ATTR_CENTER)); + aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); + + boost::shared_ptr aPoint2 = + boost::dynamic_pointer_cast(aData->attribute(ARC_ATTR_START)); + aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY); + + boost::shared_ptr aPoint3 = + boost::dynamic_pointer_cast(aData->attribute(ARC_ATTR_END)); + aPoint3->setValue(aPoint3->x() + theDeltaX, aPoint3->y() + theDeltaY); +} diff --git a/src/SketchPlugin/SketchPlugin_Arc.h b/src/SketchPlugin/SketchPlugin_Arc.h index 928a76083..4d6e67785 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.h +++ b/src/SketchPlugin/SketchPlugin_Arc.h @@ -48,6 +48,11 @@ public: SKETCHPLUGIN_EXPORT virtual const void addSub( const FeaturePtr& theFeature) {}; + /// Moves the feature + /// \param theDeltaX the delta for X coordinate is moved + /// \param theDeltaY the delta for Y coordinate is moved + SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY); + /// Use plugin manager for features creation SketchPlugin_Arc(); }; diff --git a/src/SketchPlugin/SketchPlugin_Circle.cpp b/src/SketchPlugin/SketchPlugin_Circle.cpp index eaa284d08..ab842378a 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.cpp +++ b/src/SketchPlugin/SketchPlugin_Circle.cpp @@ -64,3 +64,14 @@ const boost::shared_ptr& SketchPlugin_Circle::preview() } return getPreview(); } + +void SketchPlugin_Circle::move(double theDeltaX, double theDeltaY) +{ + boost::shared_ptr aData = data(); + if (!aData->isValid()) + return; + + boost::shared_ptr aPoint1 = + boost::dynamic_pointer_cast(aData->attribute(CIRCLE_ATTR_CENTER)); + aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); +} diff --git a/src/SketchPlugin/SketchPlugin_Circle.h b/src/SketchPlugin/SketchPlugin_Circle.h index 10fee4f7b..e74332eff 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.h +++ b/src/SketchPlugin/SketchPlugin_Circle.h @@ -46,6 +46,11 @@ public: SKETCHPLUGIN_EXPORT virtual const void addSub( const FeaturePtr& theFeature) {}; + /// Moves the feature + /// \param theDeltaX the delta for X coordinate is moved + /// \param theDeltaY the delta for Y coordinate is moved + SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY); + /// Use plugin manager for features creation SketchPlugin_Circle(); }; diff --git a/src/SketchPlugin/SketchPlugin_Constraint.h b/src/SketchPlugin/SketchPlugin_Constraint.h index 08dc621c7..2cc8bad32 100644 --- a/src/SketchPlugin/SketchPlugin_Constraint.h +++ b/src/SketchPlugin/SketchPlugin_Constraint.h @@ -61,6 +61,11 @@ public: SKETCHPLUGIN_EXPORT virtual const void addSub( const FeaturePtr& theFeature) {} + /// Moves the feature + /// \param theDeltaX the delta for X coordinate is moved + /// \param theDeltaY the delta for Y coordinate is moved + SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {}; + protected: /// \brief Use plugin manager for features creation SketchPlugin_Constraint() {} diff --git a/src/SketchPlugin/SketchPlugin_Feature.h b/src/SketchPlugin/SketchPlugin_Feature.h index 8e59b5489..4bf9ae7cb 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.h +++ b/src/SketchPlugin/SketchPlugin_Feature.h @@ -32,6 +32,11 @@ public: /// Returns true if this feature must be displayed in the history (top level of Part tree) SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return false;} + /// Moves the feature + /// \param theDeltaX the delta for X coordinate is moved + /// \param theDeltaY the delta for Y coordinate is moved + SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) = 0; + protected: /// Set the shape to the internal preview field /// \param theShape a preview shape diff --git a/src/SketchPlugin/SketchPlugin_Line.cpp b/src/SketchPlugin/SketchPlugin_Line.cpp index 734666d89..25751f06b 100644 --- a/src/SketchPlugin/SketchPlugin_Line.cpp +++ b/src/SketchPlugin/SketchPlugin_Line.cpp @@ -47,3 +47,18 @@ const boost::shared_ptr& SketchPlugin_Line::preview() } return getPreview(); } + +void SketchPlugin_Line::move(double theDeltaX, double theDeltaY) +{ + boost::shared_ptr aData = data(); + if (!aData->isValid()) + return; + + boost::shared_ptr aPoint1 = + boost::dynamic_pointer_cast(aData->attribute(LINE_ATTR_START)); + aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); + + boost::shared_ptr aPoint2 = + boost::dynamic_pointer_cast(aData->attribute(LINE_ATTR_END)); + aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY); +} diff --git a/src/SketchPlugin/SketchPlugin_Line.h b/src/SketchPlugin/SketchPlugin_Line.h index 6acefd294..554fd5e53 100644 --- a/src/SketchPlugin/SketchPlugin_Line.h +++ b/src/SketchPlugin/SketchPlugin_Line.h @@ -47,6 +47,11 @@ public: SKETCHPLUGIN_EXPORT virtual const void addSub( const FeaturePtr& theFeature) {}; + /// Moves the feature + /// \param theDeltaX the delta for X coordinate is moved + /// \param theDeltaY the delta for Y coordinate is moved + SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY); + /// Use plugin manager for features creation SketchPlugin_Line(); }; diff --git a/src/SketchPlugin/SketchPlugin_Point.cpp b/src/SketchPlugin/SketchPlugin_Point.cpp index 6df2b536b..208063d35 100644 --- a/src/SketchPlugin/SketchPlugin_Point.cpp +++ b/src/SketchPlugin/SketchPlugin_Point.cpp @@ -37,3 +37,14 @@ const boost::shared_ptr& SketchPlugin_Point::preview() } return getPreview(); } + +void SketchPlugin_Point::move(double theDeltaX, double theDeltaY) +{ + boost::shared_ptr aData = data(); + if (!aData->isValid()) + return; + + boost::shared_ptr aPoint1 = + boost::dynamic_pointer_cast(aData->attribute(POINT_ATTR_COORD)); + aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); +} diff --git a/src/SketchPlugin/SketchPlugin_Point.h b/src/SketchPlugin/SketchPlugin_Point.h index 8d37e19e1..9faf8c911 100644 --- a/src/SketchPlugin/SketchPlugin_Point.h +++ b/src/SketchPlugin/SketchPlugin_Point.h @@ -45,6 +45,11 @@ public: SKETCHPLUGIN_EXPORT virtual const void addSub( const FeaturePtr& theFeature) {}; + /// Moves the feature + /// \param theDeltaX the delta for X coordinate is moved + /// \param theDeltaY the delta for Y coordinate is moved + SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY); + /// Use plugin manager for features creation SketchPlugin_Point(); }; diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index 8337c8d24..3172d2f24 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -53,6 +53,11 @@ public: SKETCHPLUGIN_EXPORT virtual const void addSub( const FeaturePtr& theFeature); + /// Moves the feature + /// \param theDeltaX the delta for X coordinate is moved + /// \param theDeltaY the delta for Y coordinate is moved + SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {}; + /// Converts a 2D sketch space point into point in 3D space SKETCHPLUGIN_EXPORT boost::shared_ptr to3D( const double theX, const double theY);