]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #374:Prevent switching viewer interaction mode. Clear operations on module...
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 22 Jan 2015 16:05:31 +0000 (19:05 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 22 Jan 2015 16:05:31 +0000 (19:05 +0300)
src/NewGeom/NewGeom_Module.cpp
src/NewGeom/NewGeom_SalomeViewer.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Workshop.cpp

index 42c1a3d3b42ed61df1073f39b3b79847c4d4f9b5..ca51046f90cf9adbc2608f1a475025f0101d052c 100644 (file)
@@ -196,9 +196,10 @@ bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
   // because the displayed objects should be removed from the viewer, but
   // the AIS context is obtained from the selector.
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
-  if (anOperation)
+  while (anOperation) {
     anOperation->abort();
-
+    anOperation = myWorkshop->operationMgr()->currentOperation();
+  }
   // Delete selector because it has to be redefined on next activation
   if (mySelector) {
     myProxyViewer->setSelector(0);
index 288b0c02aa85ff29852469f9155cea9b894e6f5f..0613d66243959e0efcc1ed29da32efc6039d2639 100644 (file)
@@ -207,12 +207,12 @@ void NewGeom_SalomeViewer::onActivated(SUIT_ViewWindow*)
 //**********************************************
 void NewGeom_SalomeViewer::enableSelection(bool isEnabled)
 {
-  //mySelector->viewer()->enableSelection(isEnabled);
+  if (mySelector)
+    mySelector->viewer()->enableSelection(isEnabled);
   // The enableSelection() in SALOME 7.5 cause of forced Viewer update(we have blinking)
   // After this is corrected, the first row should be recommented, the last - removed
-  if (mySelector)
-    mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
-                                                        : SUIT_ViewModel::KEY_FREE);
+    //mySelector->viewer()->setInteractionStyle(isEnabled ? SUIT_ViewModel::STANDARD
+    //                                                    : SUIT_ViewModel::KEY_FREE);
 }
 
 //**********************************************
index 7937a60c337249dc43e58308367d78e723b3951f..0da5482f9a72bfeb51b4f133c175f3ef6e9b85a6 100644 (file)
@@ -132,6 +132,9 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
   if (!(theEvent->buttons() & Qt::LeftButton))
     return;
 
+  // Clear dragging mode
+  myIsDragging = false;
+
   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
   ModuleBase_Operation* aOperation = aWorkshop->currentOperation();
   // Use only for sketch operations
@@ -181,7 +184,6 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
 
     if (isSketcher) {
       myIsDragging = true;
-
       get2dPoint(theWnd, theEvent, myCurX, myCurY);
       myDragDone = false;
       launchEditing();
@@ -205,30 +207,28 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse
 {
   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
   ModuleBase_Operation* aOp = aWorkshop->currentOperation();
-  if (!aOp)
-    return;
-  if (!sketchOperationIdList().contains(aOp->id()))
-    return;
-
-  // Only for sketcher operations
-  ModuleBase_IViewer* aViewer = aWorkshop->viewer();
-  if (myIsDragging) {
-    aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
-    myIsDragging = false;
-    if (myDragDone) {
-      //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;
+  if (aOp) {
+    if (sketchOperationIdList().contains(aOp->id())) {
+      // Only for sketcher operations
+      ModuleBase_IViewer* aViewer = aWorkshop->viewer();
+      if (myIsDragging) {
+        if (myDragDone) {
+          //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();
+            */
+        }
+      }
     }
   }
+  aWorkshop->viewer()->enableSelection(myPreviousSelectionEnabled);
+  myIsDragging = false;
 }
 
 void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
@@ -246,6 +246,8 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
     aViewer->enableSelection(false);
 
     ModuleBase_Operation* aOperation = myModule->workshop()->currentOperation();
+    if (!aOperation)
+      return;
     if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID())
       return; // No edit operation activated
 
index 9fff4686996f5bad134648b16a32382df9218baf..bf48108641a3d72338b4904b8d7e1931c75a2314 100644 (file)
@@ -274,8 +274,6 @@ std::shared_ptr<GeomAPI_Dir> PartSet_WidgetSketchLabel::setSketchPlane(const Top
 
 void PartSet_WidgetSketchLabel::setSketchingMode()
 {
-  qDebug("### Set sketching mode");
-
   XGUI_Displayer* aDisp = myWorkshop->displayer();
   // Clear standard selection modes if they are defined
   //aDisp->activateObjects(aModes);
index f544c5b438f710b6707b64d3856619005e75f5f2..cab65bc08482e14ab69d345d0552761245f01289 100644 (file)
@@ -145,7 +145,6 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
       closeLocalContexts(false);
     }
     aContext->Display(anAISIO, false);
-    qDebug("### Display %i", (long)anAISIO.Access());
 
     aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, false);
     // Customization of presentation
@@ -243,7 +242,6 @@ void XGUI_Displayer::deactivate(ObjectPtr theObject)
     AISObjectPtr anObj = myResult2AISObjectMap[theObject];
     Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
     aContext->Deactivate(anAIS);
-    qDebug("### Deactivate obj %i", (long)anAIS.Access());
   }
 }
 
@@ -268,12 +266,10 @@ void XGUI_Displayer::activate(ObjectPtr theObject, const QIntList& theModes)
       foreach(int aMode, theModes) {
         //aContext->Load(anAIS, aMode, true);
         aContext->Activate(anAIS, aMode);
-        qDebug("### 1. Activate obj %i, %i", (long)anAIS.Access(), aMode);
       }
     } else {
       //aContext->Load(anAIS, 0, true);
       aContext->Activate(anAIS);
-      qDebug("### 2. Activate obj %i", (long)anAIS.Access());
     }
   }
 }
@@ -337,12 +333,10 @@ void XGUI_Displayer::activateObjects(const QIntList& theModes)
       if (myActiveSelectionModes.size() == 0) {
         //aContext->Load(anAISIO, 0, true);
         aContext->Activate(anAISIO);
-        qDebug("### 2. Activate all %i", (long)anAISIO.Access());
       } else {
         foreach(int aMode, myActiveSelectionModes) {
           //aContext->Load(anAISIO, aMode, true);
           aContext->Activate(anAISIO, aMode);
-          qDebug("### 1. Activate all %i, %i", (long)anAISIO.Access(), aMode);
         }
       }
     }
@@ -368,11 +362,6 @@ void XGUI_Displayer::deactivateObjects()
   for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
     anAISIO = aLIt.Value();
     aContext->Deactivate(anAISIO);
-    //aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
-    //if (aTrihedron.IsNull()) {
-    //  qDebug("### Deactivate all %i", (long)anAISIO.Access());
-    //  //aContext->Activate(anAISIO);
-    //}
   }
 }
 
@@ -472,7 +461,6 @@ void XGUI_Displayer::openLocalContext()
 
     //aContext->ClearCurrents();
     aContext->OpenLocalContext();
-    qDebug("### Open context");
     //aContext->NotUseDisplayedObjects();
 
     //myUseExternalObjects = false;
@@ -505,7 +493,6 @@ void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
 
     //aContext->ClearSelected();
     aContext->CloseAllContexts(false);
-    qDebug("### Close context");
 
     // Redisplay all object if they were displayed in localContext
     Handle(AIS_InteractiveObject) aAISIO;
@@ -584,7 +571,6 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   if ((!aContext.IsNull()) && (!aContext->HasOpenedContext())) {
     aContext->OpenLocalContext();
-    qDebug("### Open context");
   }
   return aContext;
 }
index a0ee892600a6e08320351deda27c4a0bf7d845ee..3900f6606298deaebac62257973a08d909367c77 100644 (file)
@@ -1356,6 +1356,11 @@ void XGUI_Workshop::setDisplayMode(const QObjectPtrList& theList, int theMode)
 //**************************************************************
 void XGUI_Workshop::closeDocument()
 {
+  ModuleBase_Operation* anOperation = operationMgr()->currentOperation();
+  while (anOperation) {
+    anOperation->abort();
+    anOperation = operationMgr()->currentOperation();
+  }
   myDisplayer->closeLocalContexts();
   myDisplayer->eraseAll();
   objectBrowser()->clearContent();