X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Workshop.cpp;h=c8058f38d6fd5ac19d7bf62121dc95cca414dad2;hb=75708cdfd8653e625bfb7aee667a7bb31867f292;hp=ab38ca8a1020e0daa6972f7f9db4395528c7417d;hpb=ace68008dc38022136ba6ed10c7be5e7c8152051;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index ab38ca8a1..c8058f38d 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -63,6 +63,7 @@ #include #include #include +#include #include #include @@ -222,16 +223,29 @@ void XGUI_Workshop::activateModule() myActionsMgr->update(); + // activate visualized objects in the viewer + XGUI_Displayer* aDisplayer = displayer(); + QObjectPtrList aDisplayed = aDisplayer->displayedObjects(); + QIntList aModes; + module()->activeSelectionModes(aModes); + aDisplayer->activateObjects(aModes, aDisplayed); } void XGUI_Workshop::deactivateModule() { myModule->deactivateSelectionFilters(); + // remove internal displayer filter + displayer()->deactivateSelectionFilters(); + disconnect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)), myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr))); disconnect(myDisplayer, SIGNAL(beforeObjectErase(ObjectPtr, AISObjectPtr)), myModule, SLOT(onBeforeObjectErase(ObjectPtr, AISObjectPtr))); + + XGUI_Displayer* aDisplayer = displayer(); + QObjectPtrList aDisplayed = aDisplayer->displayedObjects(); + aDisplayer->deactivateObjects(aDisplayed, true); } //****************************************************** @@ -367,15 +381,18 @@ void XGUI_Workshop::onStartWaiting() void XGUI_Workshop::deactivateActiveObject(const ObjectPtr& theObject, const bool theUpdateViewer) { if (!myModule->canActivateSelection(theObject)) { - if (myDisplayer->isActive(theObject)) - myDisplayer->deactivate(theObject, theUpdateViewer); + if (myDisplayer->isActive(theObject)) { + QObjectPtrList anObjects; + anObjects.append(theObject); + myDisplayer->deactivateObjects(anObjects, theUpdateViewer); + } } } //****************************************************** void XGUI_Workshop::onOperationStarted(ModuleBase_Operation* theOperation) { - setNestedFeatures(theOperation); + setGrantedFeatures(theOperation); ModuleBase_OperationFeature* aFOperation = dynamic_cast (theOperation); @@ -416,7 +433,7 @@ void XGUI_Workshop::onOperationStarted(ModuleBase_Operation* theOperation) //****************************************************** void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation) { - setNestedFeatures(theOperation); + setGrantedFeatures(theOperation); if (theOperation->getDescription()->hasXmlRepresentation()) { //!< No need for property panel setPropertyPanel(theOperation); @@ -430,6 +447,8 @@ void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation) //****************************************************** void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation) { + updateCommandStatus(); + ModuleBase_OperationFeature* aFOperation = dynamic_cast (theOperation); if (!aFOperation) @@ -438,7 +457,6 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation) ModuleBase_ISelection* aSel = mySelector->selection(); QObjectPtrList aObj = aSel->selectedPresentations(); //!< No need for property panel - updateCommandStatus(); hidePropertyPanel(); myPropertyPanel->cleanContent(); @@ -474,16 +492,19 @@ void XGUI_Workshop::onOperationAborted(ModuleBase_Operation* theOperation) myModule->onOperationAborted(theOperation); } -void XGUI_Workshop::setNestedFeatures(ModuleBase_Operation* theOperation) +void XGUI_Workshop::setGrantedFeatures(ModuleBase_Operation* theOperation) { ModuleBase_OperationFeature* aFOperation = dynamic_cast(theOperation); if (!aFOperation) return; + QStringList aGrantedIds; if (isSalomeMode()) - aFOperation->setGrantedOperationIds(mySalomeConnector->nestedActions(theOperation->id())); + aGrantedIds = mySalomeConnector->nestedActions(theOperation->id()); else - aFOperation->setGrantedOperationIds(myActionsMgr->nestedCommands(theOperation->id())); + aGrantedIds = myActionsMgr->nestedCommands(theOperation->id()); + + aFOperation->setGrantedOperationIds(aGrantedIds); } void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation) @@ -530,7 +551,7 @@ void XGUI_Workshop::saveDocument(const QString& theName, std::list& QApplication::restoreOverrideCursor(); } -bool XGUI_Workshop::isActiveOperationAborted() +bool XGUI_Workshop::abortAllOperations() { return myOperationMgr->abortAllOperations(); } @@ -578,7 +599,7 @@ void XGUI_Workshop::onNew() //****************************************************** void XGUI_Workshop::onOpen() { - if(!isActiveOperationAborted()) + if(!abortAllOperations()) return; //save current file before close if modified SessionPtr aSession = ModelAPI_Session::get(); @@ -618,7 +639,7 @@ void XGUI_Workshop::onOpen() //****************************************************** bool XGUI_Workshop::onSave() { - if(!isActiveOperationAborted()) + if(!abortAllOperations()) return false; if (myCurrentDir.isEmpty()) { return onSaveAs(); @@ -634,7 +655,7 @@ bool XGUI_Workshop::onSave() //****************************************************** bool XGUI_Workshop::onSaveAs() { - if(!isActiveOperationAborted()) + if(!abortAllOperations()) return false; QFileDialog dialog(mainWindow()); dialog.setWindowTitle(tr("Select directory to save files...")); @@ -750,6 +771,7 @@ void XGUI_Workshop::onPreferences() myMainWindow->menuObject()->updateFromResources(); } } + displayer()->redisplayObjects(); } } @@ -1013,7 +1035,7 @@ void XGUI_Workshop::deleteObjects() return; } - if (!isActiveOperationAborted()) + if (!abortAllOperations()) return; QObjectPtrList anObjects = mySelector->selection()->selectedObjects(); // It is necessary to clear selection in order to avoid selection changed event during @@ -1041,39 +1063,24 @@ void XGUI_Workshop::deleteObjects() aObjectNames << QString::fromStdString(aObj->data()->name()); } aDescription = aDescription.arg(aObjectNames.join(", ")); + ModuleBase_OperationAction* anOpAction = new ModuleBase_OperationAction(aDescription, module()); - SessionPtr aMgr = ModelAPI_Session::get(); - aMgr->startOperation(aDescription.toStdString()); - // 2. close the documents of the removed parts if the result part is in a list of selected objects - // this is performed in the RemoveFeature of Part object. - /*foreach (ObjectPtr aObj, anObjects) - { - ResultPartPtr aPart = std::dynamic_pointer_cast(aObj); - if (aPart) { - DocumentPtr aDoc = aObj->document(); - if (aDoc == aMgr->activeDocument()) { - aDoc->close(); - } - } - }*/ + operationMgr()->startOperation(anOpAction); // 3. delete objects QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow; std::set anIgnoredFeatures; if (deleteFeatures(anObjects, anIgnoredFeatures, aDesktop, true)) { - myDisplayer->updateViewer(); - aMgr->finishOperation(); - operationMgr()->updateApplyOfOperations(); - updateCommandStatus(); + operationMgr()->commitOperation(); } else { - aMgr->abortOperation(); + operationMgr()->abortOperation(operationMgr()->currentOperation()); } } //************************************************************** void XGUI_Workshop::moveObjects() { - if (!isActiveOperationAborted()) + if (!abortAllOperations()) return; SessionPtr aMgr = ModelAPI_Session::get();