From: nds Date: Wed, 28 Oct 2015 05:46:39 +0000 (+0300) Subject: Restart a line creation by mouse move, other create operation are restarted by mouse... X-Git-Tag: V_2.0.0_alfa1~6^2~30 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=19dff6c8fb965bccbe6060ea4fcbaa97a1e9da80;p=modules%2Fshaper.git Restart a line creation by mouse move, other create operation are restarted by mouse release in the viewer. --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 1348ef970..7e940adef 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -256,12 +256,15 @@ void PartSet_Module::onOperationCommitted(ModuleBase_Operation* theOperation) ModuleBase_OperationFeature* aFOperation = dynamic_cast(theOperation); if (!aFOperation) return; + // the clear selection is obsolete because during restart of the creation operation + // we would like to use selected object, e.g. a line in a parallel constraint + // the selection is cleared after commit the create operation // in order to do not use the same selected objects in the restarted operation // for common behaviour, the selection is cleared even if the operation is not restarted - XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); + /*XGUI_ModuleConnector* aConnector = dynamic_cast(workshop()); XGUI_Workshop* aWorkshop = aConnector->workshop(); - aWorkshop->selector()->clearSelection(); + aWorkshop->selector()->clearSelection();*/ /// Restart sketcher operations automatically FeaturePtr aFeature = aFOperation->feature(); @@ -316,6 +319,14 @@ void PartSet_Module::breakOperationSequence() void PartSet_Module::onOperationAborted(ModuleBase_Operation* theOperation) { + if (myIsInternalEditOperation) { + // abort the created feature, which is currently edited + SessionPtr aMgr = ModelAPI_Session::get(); + if (aMgr->hasModuleDocument() && aMgr->canUndo()) { + aMgr->undo(); + } + } + myIsInternalEditOperation = false; breakOperationSequence(); } @@ -597,6 +608,9 @@ void PartSet_Module::onEnterReleased() void PartSet_Module::onOperationActivatedByPreselection() { + if (myRestartingMode != RM_None) + return; + ModuleBase_Operation* anOperation = myWorkshop->currentOperation(); if(anOperation && PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) { // Set final definitions if they are necessary diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 270877d4b..2e0435d62 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -336,6 +336,9 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE if (!(theEvent->buttons() & Qt::LeftButton)) return; + if (myModule->isInternalEditOperation()) // it should be processed by mouse release + return; + // Clear dragging mode myIsDragging = false; @@ -434,6 +437,13 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { + if (myModule->isInternalEditOperation()) { + ModuleBase_Operation* anOperation = getCurrentOperation(); + //if (operationMgr()->isApplyEnabled()) + anOperation->commit(); + return; + } + ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); ModuleBase_IViewer* aViewer = aWorkshop->viewer(); if (!aViewer->canDragByMouse()) @@ -469,6 +479,16 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) { + if (myModule->isInternalEditOperation()) { + PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast(myModule->activeWidget()); + if (aPoint2DWdg && aPoint2DWdg->canBeActivatedByMove()) { + ModuleBase_Operation* anOperation = getCurrentOperation(); + //if (operationMgr()->isApplyEnabled()) + anOperation->commit(); + return; + } + } + if (isNestedCreateOperation(getCurrentOperation()) && !myIsMouseOverViewProcessed) { myIsMouseOverViewProcessed = true; // 1. perform the widget mouse move functionality and display the presentation diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index bb75fd068..40b221c45 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -266,6 +266,16 @@ void PartSet_WidgetPoint2D::activateCustom() myLockApplyMgr->activate(); } +bool PartSet_WidgetPoint2D::canBeActivatedByMove() +{ + bool aCanBeActivated = false; + if (feature()->getKind() == SketchPlugin_Line::ID() && + attributeID() == SketchPlugin_Line::START_ID()) + aCanBeActivated = true; + + return aCanBeActivated; +} + void PartSet_WidgetPoint2D::deactivate() { ModuleBase_IViewer* aViewer = myWorkshop->viewer(); diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index 88ae9ac2e..216d058f4 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -66,6 +66,10 @@ Q_OBJECT //bool initFromPrevious(ObjectPtr theObject); + /// Defines if the widget can be activated by mouse move. + /// By default it returns false + virtual bool canBeActivatedByMove(); + /// The methiod called when widget is deactivated virtual void deactivate();