]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Disable selection in the viewer between mouse move and mouse release signals processing.
authornds <natalia.donis@opencascade.com>
Mon, 29 Dec 2014 13:55:21 +0000 (16:55 +0300)
committernds <natalia.donis@opencascade.com>
Mon, 29 Dec 2014 13:55:21 +0000 (16:55 +0300)
Otherwise the viewer clears the current selection.

src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h

index f2094b5712d1b16a4a0043393e41b6e8c102f720..c8575ee0c1fb49bace2a20ed05c52937d9717a18 100644 (file)
@@ -105,6 +105,8 @@ PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule)
   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
   ModuleBase_IViewer* aViewer = aWorkshop->viewer();
 
+  myPreviousSelectionEnabled = aViewer->isSelectionEnabled();
+
   connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)),
           this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*)));
 
@@ -179,6 +181,7 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
 
     if (isSketcher) {
       myIsDragging = true;
+
       get2dPoint(theWnd, theEvent, myCurX, myCurY);
       myDragDone = false;
       aWorkshop->viewer()->enableMultiselection(false);
@@ -212,18 +215,12 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse
   // Only for sketcher operations
   ModuleBase_IViewer* aViewer = aWorkshop->viewer();
   if (myIsDragging) {
+    aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
     myIsDragging = false;
     if (myDragDone) {
       aViewer->enableMultiselection(true);
       //aOp->commit();
       myFeature2AttributeMap.clear();
-
-      // Reselect edited object
-      aViewer->AISContext()->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
-      if (theEvent->modifiers() & Qt::ShiftModifier)
-        aViewer->AISContext()->ShiftSelect();
-      else
-        aViewer->AISContext()->Select();
       return;
     }
   }
@@ -235,6 +232,11 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse
 void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
   if (myIsDragging) {
+    // the selection should be switched off in order to do not deselect moved objects by the 
+    // mouse release
+    ModuleBase_IViewer* aViewer = myModule->workshop()->viewer();
+    aViewer->enableSelection(false);
+
     ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation();
     if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID())
       return; // No edit operation activated
index 2f51af93129a8dc27eab0c6987e6cb71598db7e3..4ae85671c21518196dada35958f240f0128b642f 100644 (file)
@@ -65,8 +65,8 @@ private slots:
   void onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*);
 
 private:
-   /// Converts mouse position to 2d coordinates. 
-   /// Member myCurrentSketch has to be correctly defined
+  /// Converts mouse position to 2d coordinates. 
+  /// Member myCurrentSketch has to be correctly defined
   void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, 
                   double& theX, double& theY);
 
@@ -108,6 +108,7 @@ private:
 private:
   PartSet_Module* myModule;
 
+  bool myPreviousSelectionEnabled; // the previous selection enabled state in the viewer
   bool myIsDragging;
   bool myDragDone;
   double myCurX, myCurY;