From 7bde8327d8b41eb689fc4eef8edf34b9c0b58b1b Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 24 Jun 2014 21:18:55 +0400 Subject: [PATCH] refs #80 - Sketch base GUI: create/draw point, circle and arc Edit move for distance. --- src/PartSet/PartSet_OperationEditConstraint.cpp | 16 ++++++++++++++-- .../SketchPlugin_ConstraintDistance.cpp | 10 ++++++++++ .../SketchPlugin_ConstraintDistance.h | 5 +++++ .../SketchPlugin_ConstraintRadius.cpp | 10 ++++++++++ src/SketchPlugin/SketchPlugin_ConstraintRadius.h | 5 +++++ 5 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/PartSet/PartSet_OperationEditConstraint.cpp b/src/PartSet/PartSet_OperationEditConstraint.cpp index 82732d954..07416339a 100644 --- a/src/PartSet/PartSet_OperationEditConstraint.cpp +++ b/src/PartSet/PartSet_OperationEditConstraint.cpp @@ -139,7 +139,7 @@ void PartSet_OperationEditConstraint::mouseMoved(QMouseEvent* theEvent, Handle(V blockSelection(true); if (myCurPoint.myIsInitialized) { - double aCurX, aCurY; + /*double aCurX, aCurY; PartSet_Tools::convertTo2D(myCurPoint.myPoint, sketch(), theView, aCurX, aCurY); double aX, anY; @@ -153,7 +153,19 @@ void PartSet_OperationEditConstraint::mouseMoved(QMouseEvent* theEvent, Handle(V anArcPrs->projectPointOnFeature(feature(), sketch(), aPoint, theView, aX, anY); } } - myFeaturePrs->setPoint(aX, anY, SM_LastPoint); + myFeaturePrs->setPoint(aX, anY, SM_LastPoint);*/ + double aCurX, aCurY; + PartSet_Tools::convertTo2D(myCurPoint.myPoint, sketch(), theView, aCurX, aCurY); + + double aX, anY; + PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); + + double aDeltaX = aX - aCurX; + double aDeltaY = anY - aCurY; + + boost::shared_ptr aSketchFeature = + boost::dynamic_pointer_cast(feature()); + aSketchFeature->move(aDeltaX, aDeltaY); } sendFeatures(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index e5480db6c..ed7bc2974 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -137,6 +137,16 @@ Handle(AIS_InteractiveObject) SketchPlugin_ConstraintDistance::getAISShape( return anAIS; } +void SketchPlugin_ConstraintDistance::move(double theDeltaX, double theDeltaY) +{ + boost::shared_ptr aData = data(); + if (!aData->isValid()) + return; + + boost::shared_ptr aPoint1 = + boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT)); + aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); +} boost::shared_ptr getFeaturePoint(DataPtr theData, const std::string& theAttribute) diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h index 0f04d74e6..4ffbaf9c7 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h @@ -41,6 +41,11 @@ public: /// Returns the AIS preview SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious); + /// 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); + /// \brief Use plugin manager for features creation SketchPlugin_ConstraintDistance(); }; diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp index 645ecbf69..fea246b5c 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp @@ -163,3 +163,13 @@ Handle(AIS_InteractiveObject) SketchPlugin_ConstraintRadius::getAISShape( return anAIS; } +void SketchPlugin_ConstraintRadius::move(double theDeltaX, double theDeltaY) +{ + boost::shared_ptr aData = data(); + if (!aData->isValid()) + return; + + //boost::shared_ptr aPoint1 = + // boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT)); + //aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); +} diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.h b/src/SketchPlugin/SketchPlugin_ConstraintRadius.h index 4ff63b2e8..a8ef9bb6b 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.h @@ -40,6 +40,11 @@ public: /// Returns the AIS preview SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious); + /// 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); + /// \brief Use plugin manager for features creation SketchPlugin_ConstraintRadius(); }; -- 2.39.2