]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Restart a line creation by mouse move, other create operation are restarted by mouse...
authornds <nds@opencascade.com>
Wed, 28 Oct 2015 05:46:39 +0000 (08:46 +0300)
committernds <nds@opencascade.com>
Wed, 28 Oct 2015 05:46:39 +0000 (08:46 +0300)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetPoint2d.h

index 1348ef9708fc3d8350ba79aa536a9d0d0601f7cc..7e940adefe097a97258d4a0724d1014b6bffd219 100755 (executable)
@@ -256,12 +256,15 @@ void PartSet_Module::onOperationCommitted(ModuleBase_Operation* theOperation)
   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(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<XGUI_ModuleConnector*>(workshop());
+  /*XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(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
index 270877d4bad263c99fd0f089f621ffa5bcdf3961..2e0435d62213b51ae745232b15a37ae6ea37fbd1 100644 (file)
@@ -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<PartSet_WidgetPoint2D*>(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
index bb75fd068fcd9a26621298727daefa66ce4962fd..40b221c452eb195f902de26886874bb1f5a15e0f 100644 (file)
@@ -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();
index 88ae9ac2e21209e66ddfe771a9d56e9634683ba3..216d058f4abe0fbce6a67f0f69608e044d71a29f 100644 (file)
@@ -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();