]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
authornds <natalia.donis@opencascade.com>
Tue, 24 Jun 2014 17:18:55 +0000 (21:18 +0400)
committernds <natalia.donis@opencascade.com>
Tue, 24 Jun 2014 17:18:55 +0000 (21:18 +0400)
Edit move for distance.

src/PartSet/PartSet_OperationEditConstraint.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.h

index 82732d95430e55a074ffbad4cdeb3ab0b2abfb18..07416339a40630a01aec9487800c7aa1a5a0577d 100644 (file)
@@ -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<SketchPlugin_Feature> aSketchFeature = 
+                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
+    aSketchFeature->move(aDeltaX, aDeltaY);
   }
   sendFeatures();
 
index e5480db6c3e22185cf63c80125dc1601528f2203..ed7bc297418012c1e7476bbf8dcbc9da0be5b22b 100644 (file)
@@ -137,6 +137,16 @@ Handle(AIS_InteractiveObject) SketchPlugin_ConstraintDistance::getAISShape(
   return anAIS;
 }
 
+void SketchPlugin_ConstraintDistance::move(double theDeltaX, double theDeltaY)
+{
+  boost::shared_ptr<ModelAPI_Data> aData = data();
+  if (!aData->isValid())
+    return;
+
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+  aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+}
 
 boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
                                                        const std::string& theAttribute)
index 0f04d74e6cf3d5edb59a3aca97b2cae253a3669b..4ffbaf9c7c928b61395562e64a182a06ab30e8d9 100644 (file)
@@ -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();
 };
index 645ecbf6949b5219187616f4f4ba8246a7673287..fea246b5c3f5a7e6e8e73977bb58dcb9b9522373 100644 (file)
@@ -163,3 +163,13 @@ Handle(AIS_InteractiveObject) SketchPlugin_ConstraintRadius::getAISShape(
   return anAIS;
 }
 
+void SketchPlugin_ConstraintRadius::move(double theDeltaX, double theDeltaY)
+{
+  boost::shared_ptr<ModelAPI_Data> aData = data();
+  if (!aData->isValid())
+    return;
+
+  //boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
+  //      boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
+  //aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
+}
index 4ff63b2e8858d6898fcbb287492b4b5f01a45fc0..a8ef9bb6bd48d1fde32294b4b85808a4452c723e 100644 (file)
@@ -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();
 };