From: nds Date: Tue, 2 May 2017 10:22:02 +0000 (+0300) Subject: Task 2.4. Ability to modify the radius of circles and arcs of circle with the mouse X-Git-Tag: V_2.7.1.1~3^2~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=da6240e298b73b4bc534fc6bcbfca5cbed0389d0;p=modules%2Fshaper.git Task 2.4. Ability to modify the radius of circles and arcs of circle with the mouse Sending ModelAPI_ObjectMovedMessage signal instead of the previous sending usual update signal. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 86f0a5df5..ccb0ee1f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 10042d488..b086cd628 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -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() { diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 0b409e6fe..b13d90aeb 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -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; diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 4fe035efd..40625ee9e 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -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 anOriginalPosition = std::shared_ptr( + new GeomAPI_Pnt2d(myCurrentPoint.myCurX, myCurrentPoint.myCurY)); + std::shared_ptr aCurrentPosition = std::shared_ptr( + new GeomAPI_Pnt2d(aMousePnt.myCurX, aMousePnt.myCurY)); +#endif ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer(); @@ -559,9 +565,18 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve std::dynamic_pointer_cast(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 aMessage = std::shared_ptr + (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 aSketchFeature = std::dynamic_pointer_cast(aFeature); if (aSketchFeature) { +#ifndef SUPPORT_NEW_MOVE aSketchFeature->move(dX, dY); - isModified = true; ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, aMoveEvent); +#else + std::shared_ptr aMessage = std::shared_ptr + (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 diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 93d132b98..f099f04a3 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -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);