#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"
#include <ModelAPI_Data.h>
#include <ModelAPI_AttributeDocRef.h>
#include <ModelAPI_Object.h>
+#include <ModelAPI_Validator.h>
#include <PartSetPlugin_Part.h>
#include <Events_Loop.h>
#include <Events_Error.h>
+
#include <ModuleBase_Operation.h>
#include <ModuleBase_Operation.h>
#include <ModuleBase_OperationDescription.h>
+#include <ModuleBase_SelectionValidator.h>
+
#include <Config_Common.h>
#include <Config_FeatureMessage.h>
#include <Config_PointerMessage.h>
XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
: QObject(),
myCurrentDir(QString()),
- myPartSetModule(NULL),
+ myModule(NULL),
mySalomeConnector(theConnector),
myPropertyPanel(0),
myObjectBrowser(0),
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);
this, SLOT(onContextMenuCommand(const QString&, bool)));
myViewerProxy = new XGUI_ViewerProxy(this);
+ connect(myViewerProxy, SIGNAL(selectionChanged()), this, SLOT(updateCommandsOnViewSelection()));
myModuleConnector = new XGUI_ModuleConnector(this);
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_LOADED));
// TODO Is it good to use non standard event within workshop?
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED));
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_TO_REDISPLAY));
activateModule();
}
// Process creation of Part
- if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_CREATED)) {
+ if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
onFeatureCreatedMsg(aUpdMsg);
}
//Update property panel on corresponding message. If there is no current operation (no
//property panel), or received message has different feature to the current - do nothing.
- if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED)) {
+ if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
const Model_FeatureUpdatedMessage* anUpdateMsg =
dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
onFeatureUpdatedMsg(anUpdateMsg);
QKeySequence(), isUsePropPanel);
salomeConnector()->setNestedActions(aId, aNestedFeatures.split(" "));
myActionsMgr->addCommand(aAction);
- myPartSetModule->featureCreated(aAction);
+ myModule->featureCreated(aAction);
} else {
XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
QKeySequence(), isUsePropPanel);
aCommand->setNestedCommands(aNestedFeatures.split(" ", QString::SkipEmptyParts));
myActionsMgr->addCommand(aCommand);
- myPartSetModule->featureCreated(aCommand);
+ myModule->featureCreated(aCommand);
}
}
{
Config_ModuleReader aModuleReader;
QString moduleName = QString::fromStdString(aModuleReader.getModuleName());
- myPartSetModule = loadModule(moduleName);
- if (!myPartSetModule)
+ myModule = loadModule(moduleName);
+ if (!myModule)
return false;
- myPartSetModule->createFeatures();
+ myModule->createFeatures();
myActionsMgr->update();
return true;
}
}
//******************************************************
-void XGUI_Workshop::updateModuleCommands()
+QList<QAction*> XGUI_Workshop::getModuleCommands() const
{
QList<QAction*> aCommands;
if (isSalomeMode()) { // update commands in SALOME mode
}
}
}
- foreach(QAction* aCmd, aCommands) {
- aCmd->setEnabled(myPartSetModule->isFeatureEnabled(aCmd->data().toString()));
- }
+ return aCommands;
}
//******************************************************
if (aCmd) {
QString aId = salomeConnector()->commandId(aCmd);
if (!aId.isNull())
- myPartSetModule->launchOperation(aId);
+ myModule->launchOperation(aId);
}
}
//**************************************************************
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")
}
myDisplayer->updateViewer();
}
+
+//**************************************************************
+void XGUI_Workshop::updateCommandsOnViewSelection()
+{
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+ XGUI_Selection* aSelection = mySelector->selection();
+
+ QList<QAction*> 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<const ModuleBase_SelectionValidator*>(aValidator);
+ if (aSelValidator) {
+ aAction->setEnabled(aSelValidator->isValid(aSelection));
+ }
+ }
+ }
+}