X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_Workshop.cpp;h=b5b0b5f6baeeb50b95d9cd621859c12dd4d9cfdf;hb=47c18d4de2719126f6b045b5c37525cd8f170aa1;hp=7be906691ae361f33510a648ed18b9c56a9d6a45;hpb=c5311359309c0ec43f24a94015ff56840ab4317d;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 7be906691..b5b0b5f6b 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -10,6 +10,7 @@ #include "XGUI_Viewer.h" #include "ModuleBase_WidgetFactory.h" #include "XGUI_SelectionMgr.h" +#include "XGUI_Selection.h" #include "XGUI_ObjectsBrowser.h" #include "XGUI_Displayer.h" #include "XGUI_OperationMgr.h" @@ -28,14 +29,18 @@ #include #include #include +#include #include #include #include + #include #include #include +#include + #include #include #include @@ -85,7 +90,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) myDisplayer = new XGUI_Displayer(this); mySelector = new XGUI_SelectionMgr(this); - connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(updateModuleCommands())); + //connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(updateModuleCommands())); myOperationMgr = new XGUI_OperationMgr(this); myActionsMgr = new XGUI_ActionsMgr(this); @@ -95,6 +100,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) this, SLOT(onContextMenuCommand(const QString&, bool))); myViewerProxy = new XGUI_ViewerProxy(this); + connect(myViewerProxy, SIGNAL(selectionChanged()), this, SLOT(updateCommandsOnViewSelection())); myModuleConnector = new XGUI_ModuleConnector(this); @@ -712,7 +718,7 @@ void XGUI_Workshop::updateCommandStatus() } //****************************************************** -void XGUI_Workshop::updateModuleCommands() +QList XGUI_Workshop::getModuleCommands() const { QList aCommands; if (isSalomeMode()) { // update commands in SALOME mode @@ -726,9 +732,7 @@ void XGUI_Workshop::updateModuleCommands() } } } - foreach(QAction* aCmd, aCommands) { - aCmd->setEnabled(myModule->isFeatureEnabled(aCmd->data().toString())); - } + return aCommands; } //****************************************************** @@ -854,7 +858,7 @@ XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const //************************************************************** void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) { - QFeatureList aFeatures = mySelector->selectedFeatures(); + QFeatureList aFeatures = mySelector->selection()->selectedFeatures(); if ((theId == "ACTIVATE_PART_CMD") && (aFeatures.size() > 0)) activatePart(aFeatures.first()); else if (theId == "DEACTIVATE_PART_CMD") @@ -955,3 +959,24 @@ void XGUI_Workshop::showFeatures(QFeatureList theList, bool isVisible) } myDisplayer->updateViewer(); } + +//************************************************************** +void XGUI_Workshop::updateCommandsOnViewSelection() +{ + PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); + XGUI_Selection* aSelection = mySelector->selection(); + + QList aActions = getModuleCommands(); + foreach(QAction* aAction, aActions) { + QString aId = aAction->data().toString(); + const ModelAPI_Validator* aValidator = aFactory->validator(aId.toStdString()); + if (aValidator) { + const ModuleBase_SelectionValidator* aSelValidator = + dynamic_cast(aValidator); + if (aSelValidator) { + aAction->setEnabled(aSelValidator->isValid(aSelection)); + } + } + } +}