From: vsv Date: Thu, 22 Jan 2015 16:05:31 +0000 (+0300) Subject: Issue #374:Prevent switching viewer interaction mode. Clear operations on module... X-Git-Tag: V_1.0.0~26^2^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c2fd105bf159c3e81c4a386690a7fa23691e5071;p=modules%2Fshaper.git Issue #374:Prevent switching viewer interaction mode. Clear operations on module deactivation and application exit --- diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index 42c1a3d3b..ca51046f9 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -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); diff --git a/src/NewGeom/NewGeom_SalomeViewer.cpp b/src/NewGeom/NewGeom_SalomeViewer.cpp index 288b0c02a..0613d6624 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.cpp +++ b/src/NewGeom/NewGeom_SalomeViewer.cpp @@ -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); } //********************************************** diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 7937a60c3..0da5482f9 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -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 diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 9fff46869..bf4810864 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -274,8 +274,6 @@ std::shared_ptr 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); diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index f544c5b43..cab65bc08 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -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(); 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; } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index a0ee89260..3900f6606 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -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();