#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>
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);
bool isDisplayed = false;
for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
FeaturePtr aFeature = (*aIt);
- if (aFeature->getKind() != PARTSET_PART_KIND) {
+ if (aFeature->getKind() != PartSetPlugin_Part::ID()) {
isDisplayed = myDisplayer->redisplay(aFeature, false);
}
}
bool isDisplayed = false;
for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
FeaturePtr aFeature = (*aIt);
- if (aFeature->getKind() == PARTSET_PART_KIND) {
+ if (aFeature->getKind() == PartSetPlugin_Part::ID()) {
aHasPart = true;
//break;
} else {
}
//******************************************************
-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(myModule->isFeatureEnabled(aCmd->data().toString()));
- }
+ return aCommands;
}
//******************************************************
//**************************************************************
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")
{
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
DocumentPtr aDoc = aMgr->rootDocument();
- FeaturePtr aLastPart = aDoc->feature(PARTS_GROUP, aDoc->size(PARTS_GROUP) - 1, true);
+ FeaturePtr aLastPart = aDoc->feature(ModelAPI_Document::PARTS_GROUP(),
+ aDoc->size(ModelAPI_Document::PARTS_GROUP()) - 1, true);
activatePart(aLastPart);
}
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
aMgr->rootDocument()->startOperation();
foreach (FeaturePtr aFeature, theList) {
- if (aFeature->getKind() == PARTSET_PART_KIND) {
+ if (aFeature->getKind() == PartSetPlugin_Part::ID()) {
DocumentPtr aDoc;
if (!XGUI_Tools::isModelObject(aFeature)) {
aDoc = aFeature->data()->docRef("PartDocument")->value();
}
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));
+ }
+ }
+ }
+}