return 0;
}
+//******************************************************
+void NewGeom_Module::setNestedActions(const QString& theId, const QStringList& theActions)
+{
+ myNestedActions[theId] = theActions;
+}
+
+//******************************************************
+QStringList NewGeom_Module::nestedActions(const QString& theId) const
+{
+ if (myNestedActions.contains(theId))
+ return myNestedActions[theId];
+ return QStringList();
+}
+
//******************************************************
Handle(AIS_InteractiveContext) NewGeom_Module::AISContext() const
{
#include <XGUI_SalomeConnector.h>
#include <QStringList>
+#include <QMap>
class XGUI_Workshop;
class NewGeom_OCCSelector;
virtual QAction* command(const QString& theId) const;
+ //! Set nested actions dependent on command Id
+ //! \param theId - the command ID
+ //! \param theActions - the list of nested actions
+ virtual void setNestedActions(const QString& theId, const QStringList& theActions);
+
+ //! Returns list of nested actions according to the given command ID
+ virtual QStringList nestedActions(const QString& theId) const;
+
//! Returns AIS_InteractiveContext from current OCCViewer
virtual Handle(AIS_InteractiveContext) AISContext() const;
XGUI_Workshop* myWorkshop;
NewGeom_OCCSelector* mySelector;
+
+ QMap<QString, QStringList> myNestedActions;
};
#endif
* XGUI_ActionsMgr.cpp
*/
-#include <XGUI_ActionsMgr.h>
-#include <XGUI_Command.h>
+#include "XGUI_ActionsMgr.h"
+#include "XGUI_Command.h"
+#include "XGUI_Workshop.h"
+#include "XGUI_SalomeConnector.h"
+
#include <QAction>
-XGUI_ActionsMgr::XGUI_ActionsMgr(QObject* theParent)
- : QObject(theParent)
+XGUI_ActionsMgr::XGUI_ActionsMgr(XGUI_Workshop* theParent)
+ : QObject(theParent), myWorkshop(theParent)
{
-
+
}
XGUI_ActionsMgr::~XGUI_ActionsMgr()
}
+void XGUI_ActionsMgr::addCommand(QString theId, QAction* theCmd)
+{
+ myActions.insert(theId,theCmd);
+ myActionsState.insert(theId, theCmd->isEnabled());
+ connect(theCmd, SIGNAL(triggered(bool)), this, SLOT(setActionsDisabled(bool)));
+}
+
void XGUI_ActionsMgr::addCommand(XGUI_Command* theCmd)
{
myActions.insert(theCmd->id(),theCmd);
}
//Disable all actions, but caller and unblockable (defined in a xml)
saveCommandsState();
- XGUI_Command* aToggledFeature = dynamic_cast<XGUI_Command*>(sender());
- QString aSkippedId = aToggledFeature->id();
+
+ QString aSkippedId;
+ if (myWorkshop->isSalomeMode()) {
+ QAction* aToggledFeature = dynamic_cast<QAction*>(sender());
+ aSkippedId = myWorkshop->salomeConnector()->commandId(aToggledFeature);
+ } else {
+ XGUI_Command* aToggledFeature = dynamic_cast<XGUI_Command*>(sender());
+ aSkippedId = aToggledFeature->id();
+ }
QStringList anActionIdsList = myActions.keys();
foreach(QString eachKey, anActionIdsList) {
if (eachKey == aSkippedId) {
}
myActions[eachKey]->setEnabled(false);
}
- myNestedActions = aToggledFeature->unblockableCommands();
+ if (myWorkshop->isSalomeMode()) {
+ myNestedActions = myWorkshop->salomeConnector()->nestedActions(aSkippedId);
+ } else {
+ XGUI_Command* aToggledFeature = dynamic_cast<XGUI_Command*>(sender());
+ myNestedActions = aToggledFeature->unblockableCommands();
+ }
}
void XGUI_ActionsMgr::saveCommandsState()
#include <QStringList>
class XGUI_Command;
+class XGUI_Workshop;
class QAction;
class XGUI_ActionsMgr: public QObject
Q_OBJECT
public:
- XGUI_ActionsMgr(QObject* theParent);
+ XGUI_ActionsMgr(XGUI_Workshop* theParent);
virtual ~XGUI_ActionsMgr();
void addCommand(XGUI_Command* theCmd);
+
+ /// Register a command in SALOME mode
+ /// \param theId - string ID of the command
+ /// \param theCmd - command object
+ void addCommand(QString theId, QAction* theCmd);
+
void saveCommandsState();
void restoreCommandState();
QStringList myNestedActions;
QMap<QString, QAction*> myActions;
QMap<QString, bool> myActionsState;
+
+ XGUI_Workshop* myWorkshop;
};
#endif /* XGUI_ACTIONSMGR_H_ */
#include <AIS_InteractiveContext.hxx>
#include <QString>
+#include <QStringList>
class QMainWindow;
//! Returns QAction instance by command string Id
virtual QAction* command(const QString& theId) const = 0;
+ //! Set nested actions dependent on command Id
+ //! \param theId - the command ID
+ //! \param theActions - the list of nested actions
+ virtual void setNestedActions(const QString& theId, const QStringList& theActions) = 0;
+
+ //! Returns list of nested actions according to the given command ID
+ virtual QStringList nestedActions(const QString& theId) const = 0;
+
//! Returns AIS_InteractiveContext from current OCCViewer
virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
};
} else {
hidePropertyPanel();
updateCommandStatus();
-
- if (myMainWindow) {
- myActionsMgr->restoreCommandState();
- }
+ myActionsMgr->restoreCommandState();
}
}
}
//Find or create Workbench
QString aWchName = QString::fromStdString(theMessage->workbenchId());
+ QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
+ bool isUsePropPanel = theMessage->isUseInput();
if (isSalomeMode()) {
+ QString aId = QString::fromStdString(theMessage->id());
salomeConnector()->addFeature(aWchName,
QString::fromStdString(theMessage->id()),
- QString::fromStdString(theMessage->text()),
+ aId,
QString::fromStdString(theMessage->tooltip()),
QIcon(theMessage->icon().c_str()),
- false, this,
+ isUsePropPanel, this,
SLOT(onFeatureTriggered()), QKeySequence());
+ myActionsMgr->addCommand(aId, salomeConnector()->command(aId));
+ salomeConnector()->setNestedActions(aId, aNestedFeatures.split(" "));
+
} else {
+
XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
if (!aPage) {
if (!aGroup) {
aGroup = aPage->addGroup(aGroupName);
}
- bool isUsePropPanel = theMessage->isUseInput();
//Create feature...
XGUI_Command* aCommand = aGroup->addFeature(QString::fromStdString(theMessage->id()),
QString::fromStdString(theMessage->text()),
QString::fromStdString(theMessage->tooltip()),
QIcon(theMessage->icon().c_str()),
QKeySequence(), isUsePropPanel);
- QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
aCommand->setUnblockableCommands(aNestedFeatures.split(" "));
myActionsMgr->addCommand(aCommand);
myPartSetModule->featureCreated(aCommand);