]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task 2.4. Ability to modify the radius of circles and arcs of circle with the mouse
authornds <nds@opencascade.com>
Tue, 2 May 2017 10:22:02 +0000 (13:22 +0300)
committernds <nds@opencascade.com>
Tue, 2 May 2017 10:22:02 +0000 (13:22 +0300)
Sending ModelAPI_ObjectMovedMessage signal instead of the previous sending usual update signal.

CMakeLists.txt
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp

index 86f0a5df5ff3a994efbae4bc58e897e1d145a94c..ccb0ee1f9fb1c3f07f264f2183861a533d040c7d 100644 (file)
@@ -1,5 +1,7 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
 
+ADD_DEFINITIONS(-DSUPPORT_NEW_MOVE)
+
 PROJECT (SHAPER)
 # Ensure a proper linker behavior:
 CMAKE_POLICY(SET CMP0003 NEW)
index 10042d488110d7d6187be6958fd8d3ee765b9c95..b086cd6281f4568a5293e8e9d67e280e3b839da7 100644 (file)
@@ -399,6 +399,7 @@ void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject)
   }
 }
 
+#ifndef SUPPORT_NEW_MOVE
 void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj)
 {
   //blockUpdateViewer(true);
@@ -412,6 +413,7 @@ void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj)
 
   //blockUpdateViewer(false);
 }
+#endif
 
 bool ModuleBase_ModelWidget::processEnter()
 {
index 0b409e6feedb9ce02cd32e60c6224b8e84a938e1..b13d90aeba8afe260164eb732614ed777d7bb68b 100644 (file)
@@ -235,10 +235,12 @@ Q_OBJECT
   /// \param theObj is updating object
   void updateObject(ObjectPtr theObj);
 
+#ifndef SUPPORT_NEW_MOVE
   /// Sends Move event for the given object
   /// \param theObj is object for moving
   static void moveObject(ObjectPtr theObj);
 
+#endif
   /// Translate passed string with widget context()
   virtual QString translate(const std::string& theStr) const;
 
index 4fe035efd7184a84e5294f5a2a854537296df591..40625ee9e4ce5476d11c4b3ee50d99c38595d5ba 100755 (executable)
@@ -523,9 +523,15 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
     gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
     Point aMousePnt;
     get2dPoint(theWnd, theEvent, aMousePnt);
+#ifndef SUPPORT_NEW_MOVE
     double dX =  aMousePnt.myCurX - myCurrentPoint.myCurX;
     double dY =  aMousePnt.myCurY - myCurrentPoint.myCurY;
-
+#else
+    std::shared_ptr<GeomAPI_Pnt2d> anOriginalPosition = std::shared_ptr<GeomAPI_Pnt2d>(
+                            new GeomAPI_Pnt2d(myCurrentPoint.myCurX, myCurrentPoint.myCurY));
+    std::shared_ptr<GeomAPI_Pnt2d> aCurrentPosition = std::shared_ptr<GeomAPI_Pnt2d>(
+                            new GeomAPI_Pnt2d(aMousePnt.myCurX, aMousePnt.myCurY));
+#endif
     ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
     XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
     XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
@@ -559,9 +565,18 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
               std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(aAttrId));
             if (aPoint.get() != NULL) {
               bool isImmutable = aPoint->setImmutable(true);
+#ifndef SUPPORT_NEW_MOVE
               aPoint->move(dX, dY);
-              isModified = true;
               ModelAPI_EventCreator::get()->sendUpdated(aFeature, aMoveEvent);
+#else
+              std::shared_ptr<ModelAPI_ObjectMovedMessage> aMessage = std::shared_ptr
+                       <ModelAPI_ObjectMovedMessage>(new ModelAPI_ObjectMovedMessage(this));
+              aMessage->setMovedAttribute(aPoint);
+              aMessage->setOriginalPosition(anOriginalPosition);
+              aMessage->setCurrentPosition(aCurrentPosition);
+              Events_Loop::loop()->send(aMessage);
+#endif
+              isModified = true;
               aPoint->setImmutable(isImmutable);
             }
           }
@@ -571,9 +586,18 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
         std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
           std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
         if (aSketchFeature) {
+#ifndef SUPPORT_NEW_MOVE
           aSketchFeature->move(dX, dY);
-          isModified = true;
           ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent);
+#else
+          std::shared_ptr<ModelAPI_ObjectMovedMessage> aMessage = std::shared_ptr
+                    <ModelAPI_ObjectMovedMessage>(new ModelAPI_ObjectMovedMessage(this));
+          aMessage->setMovedObject(aFeature);
+          aMessage->setOriginalPosition(anOriginalPosition);
+          aMessage->setCurrentPosition(aCurrentPosition);
+          Events_Loop::loop()->send(aMessage);
+#endif
+          isModified = true;
         }
       }
     }
@@ -581,8 +605,8 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
     // were changed here
     if (isModified) {
       aCurrentOperation->onValuesChanged();
+      Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver
     }
-    Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver
     //Events_Loop::loop()->flush(aUpdateEvent); // up update events - to redisplay presentations
 
     // 5. it is necessary to save current selection in order to restore it after the features moving
index 93d132b98a0c8c026f26bbccdd67423ec971be23..f099f04a309c099dc65dc3a6afd1c3d0c439e0e7 100644 (file)
@@ -347,7 +347,11 @@ bool PartSet_WidgetPoint2D::storeValueCustom()
   aPoint->setValue(myXSpin->value(), myYSpin->value());
 
   // after movement the solver will call the update event: optimization
+#ifndef SUPPORT_NEW_MOVE
   moveObject(myFeature);
+#else
+  updateObject(myFeature);
+#endif
   aPoint->setImmutable(isImmutable);
   that->blockSignals(isBlocked);