XGUI_ErrorDialog.h
XGUI_ErrorMgr.h
XGUI_HistoryMenu.h
+ XGUI_MenuGroup.h
+ XGUI_MenuMgr.h
+ XGUI_MenuWorkbench.h
XGUI_ModuleConnector.h
XGUI_ObjectsBrowser.h
XGUI_OperationMgr.h
XGUI_ErrorDialog.cpp
XGUI_ErrorMgr.cpp
XGUI_HistoryMenu.cpp
+ XGUI_MenuGroup.cpp
+ XGUI_MenuMgr.cpp
+ XGUI_MenuWorkbench.cpp
XGUI_ModuleConnector.cpp
XGUI_ObjectsBrowser.cpp
XGUI_OperationMgr.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: XGUI_MenuGroup.cpp
+// Created: 13 Apr 2016
+// Author: Natalia ERMOLAEVA
+
+#include <XGUI_MenuGroup.h>
+
+XGUI_MenuGroup::XGUI_MenuGroup()
+{
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: XGUI_MenuGroup.hxx
+// Created: 13 Apr 2016
+// Author: Natalia ERMOLAEVA
+
+#ifndef XGUI_MENUGROUP_H_
+#define XGUI_MENUGROUP_H_
+
+#include "XGUI.h"
+
+/**
+* \ingroup GUI
+* A class for management of menu actions (features). The actions should be arranged like they are
+* in XML file. It listens the read feature of XML and fills internal structure of menu workbenches
+* and groups of feature. After, it creates menues and tools in the module.
+*/
+class XGUI_EXPORT XGUI_MenuGroup
+{
+ public:
+ /// Constructor
+ XGUI_MenuGroup();
+ virtual ~XGUI_MenuGroup() {}
+};
+
+#endif /* XGUI_MENUGROUP_H_ */
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: XGUI_MenuMgr.cpp
+// Created: 13 Apr 2016
+// Author: Natalia ERMOLAEVA
+
+#include <XGUI_MenuMgr.h>
+#include <XGUI_Workshop.h>
+#include <XGUI_ActionsMgr.h>
+#include <XGUI_OperationMgr.h>
+
+#include <Events_Loop.h>
+#include <Config_FeatureMessage.h>
+#include <Config_Keywords.h>
+
+#ifndef HAVE_SALOME
+#include <AppElements_Workbench.h>
+#include <AppElements_Command.h>
+#include <AppElements_MainMenu.h>
+#include <AppElements_MainWindow.h>
+#include <AppElements_MenuGroupPanel.h>
+#include <AppElements_Button.h>
+#endif
+
+#include <ModuleBase_IModule.h>
+
+#include <QObject>
+#include <QAction>
+#include <QDebug>
+
+XGUI_MenuMgr::XGUI_MenuMgr(XGUI_Workshop* theWorkshop)
+: myWorkshop(theWorkshop)
+{
+ Events_Loop* aLoop = Events_Loop::loop();
+
+ aLoop->registerListener(this, Events_Loop::eventByName(Config_FeatureMessage::GUI_EVENT()));
+}
+
+void XGUI_MenuMgr::processEvent(const std::shared_ptr<Events_Message>& theMessage)
+{
+ //A message to start feature creation received.
+ if (theMessage->eventID() == Events_Loop::loop()->eventByName(Config_FeatureMessage::GUI_EVENT())) {
+ std::shared_ptr<Config_FeatureMessage> aFeatureMsg =
+ std::dynamic_pointer_cast<Config_FeatureMessage>(theMessage);
+ if (!aFeatureMsg->isInternal()) {
+ addFeature(aFeatureMsg);
+ }
+ }
+}
+
+void XGUI_MenuMgr::addFeature(const std::shared_ptr<Config_FeatureMessage>& theMessage)
+{
+ if (!theMessage) {
+#ifdef _DEBUG
+ qDebug() << "XGUI_WorkshopListener::addFeature: NULL message.";
+#endif
+ return;
+ }
+
+ ActionInfo aFeatureInfo;
+ aFeatureInfo.initFrom(theMessage);
+
+ QString aWchName = QString::fromStdString(theMessage->workbenchId());
+ QStringList aNestedFeatures =
+ QString::fromStdString(theMessage->nestedFeatures()).split(" ", QString::SkipEmptyParts);
+ QList<QAction*> aNestedActList;
+ bool isColumnButton = !aNestedFeatures.isEmpty();
+ if (isColumnButton) {
+ QString aNestedActions = QString::fromStdString(theMessage->actionsWhenNested());
+ XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
+ XGUI_ActionsMgr* anActionsMgr = myWorkshop->actionsMgr();
+ if (aNestedActions.contains(FEATURE_WHEN_NESTED_ACCEPT)) {
+ QAction* anAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL);
+ QObject::connect(anAction, SIGNAL(triggered()), anOperationMgr, SLOT(commitAllOperations()));
+ aNestedActList << anAction;
+ }
+ if (aNestedActions.contains(FEATURE_WHEN_NESTED_ABORT)) {
+ QAction* anAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AbortAll, NULL);
+ QObject::connect(anAction, SIGNAL(triggered()), anOperationMgr, SLOT(abortAllOperations()));
+ aNestedActList << anAction;
+ }
+ }
+
+#ifdef HAVE_SALOME
+ XGUI_SalomeConnector* aSalomeConnector = myWorkshop->salomeConnector();
+ QAction* aAction;
+ if (isColumnButton) {
+ aAction = aSalomeConnector->addFeatureOfNested(aWchName, aFeatureInfo, aNestedActList);
+ } else {
+ //Issue #650: in the SALOME mode the tooltip should be same as text
+ aFeatureInfo.toolTip = aFeatureInfo.text;
+ aAction = aSalomeConnector->addFeature(aWchName, aFeatureInfo);
+ }
+ aSalomeConnector->setFeatureInfo(aFeatureInfo.id, theMessage);
+
+ myWorkshop->actionsMgr()->addCommand(aAction);
+ myWorkshop->module()->actionCreated(aAction);
+#else
+ //Find or create Workbench
+ AppElements_MainMenu* aMenuBar = myWorkshop->mainWindow()->menuObject();
+ AppElements_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
+ if (!aPage) {
+ aPage = myWorkshop->addWorkbench(aWchName);
+ }
+ //Find or create Group
+ QString aGroupName = QString::fromStdString(theMessage->groupId());
+ AppElements_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
+ if (!aGroup) {
+ aGroup = aPage->addGroup(aGroupName);
+ }
+ // Check if hotkey sequence is already defined:
+ XGUI_ActionsMgr* anActionsMgr = myWorkshop->actionsMgr();
+ QKeySequence aHotKey = anActionsMgr->registerShortcut(aFeatureInfo.shortcut);
+ if(aHotKey != aFeatureInfo.shortcut) {
+ aFeatureInfo.shortcut = aHotKey;
+ }
+ AppElements_Command* aCommand = aGroup->addFeature(theMessage);
+ // Enrich created button with accept/abort buttons if necessary
+ AppElements_Button* aButton = aCommand->button();
+ if (aButton->isColumnButton()) {
+ aButton->setAdditionalButtons(aNestedActList);
+ }
+ myWorkshop->actionsMgr()->addCommand(aCommand);
+ myWorkshop->module()->actionCreated(aCommand);
+#endif
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: XGUI_MenuMgr.hxx
+// Created: 13 Apr 2016
+// Author: Natalia ERMOLAEVA
+
+#ifndef XGUI_MENUMGR_H_
+#define XGUI_MENUMGR_H_
+
+#include "XGUI.h"
+
+#include <Events_Listener.h>
+
+class XGUI_Workshop;
+class Config_FeatureMessage;
+
+/**
+* \ingroup GUI
+* A class for management of menu actions (features). The actions should be arranged like they are
+* in XML file. It listens the read feature of XML and fills internal structure of menu workbenches
+* and groups of feature. After, it creates menues and tools in the module.
+*/
+class XGUI_EXPORT XGUI_MenuMgr : public Events_Listener
+{
+ public:
+ /// Constructor
+ /// \param the current workshop
+ XGUI_MenuMgr(XGUI_Workshop* theWorkshop);
+ virtual ~XGUI_MenuMgr() {}
+
+ //! Redefinition of Events_Listener method
+ virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
+
+protected:
+ /// Process event "Add a feature"
+ void addFeature(const std::shared_ptr<Config_FeatureMessage>& theMessage);
+
+private:
+ XGUI_Workshop* myWorkshop; /// the current workshop
+};
+
+#endif /* XGUI_MENUMGR_H_ */
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: XGUI_MenuWorkbench.cpp
+// Created: 13 Apr 2016
+// Author: Natalia ERMOLAEVA
+
+#include <XGUI_MenuWorkbench.h>
+
+XGUI_MenuWorkbench::XGUI_MenuWorkbench()
+{
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: XGUI_MenuWorkbench.hxx
+// Created: 13 Apr 2016
+// Author: Natalia ERMOLAEVA
+
+#ifndef XGUI_MENUWORKBENCH_H_
+#define XGUI_MENUWORKBENCH_H_
+
+#include "XGUI.h"
+
+/**
+* \ingroup GUI
+* A class for management of menu actions (features). The actions should be arranged like they are
+* in XML file. It listens the read feature of XML and fills internal structure of menu workbenches
+* and groups of feature. After, it creates menues and tools in the module.
+*/
+class XGUI_EXPORT XGUI_MenuWorkbench
+{
+ public:
+ /// Constructor
+ XGUI_MenuWorkbench();
+ /// Destructor
+ virtual ~XGUI_MenuWorkbench() {}
+};
+
+#endif /* XGUI_MENUWORKBENCH_H_ */
+
#include "XGUI_Workshop.h"
#include "XGUI_ActionsMgr.h"
+#include "XGUI_MenuMgr.h"
#include "XGUI_ColorDialog.h"
#include "XGUI_ContextMenuMgr.h"
#include "XGUI_Displayer.h"
myOperationMgr = new XGUI_OperationMgr(this, 0);
myActionsMgr = new XGUI_ActionsMgr(this);
+ myMenuMgr = new XGUI_MenuMgr(this);
myErrorDlg = new XGUI_ErrorDialog(QApplication::desktop());
myContextMenuMgr = new XGUI_ContextMenuMgr(this);
connect(myContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this,
class XGUI_Displayer;
class XGUI_ErrorDialog;
class XGUI_ErrorMgr;
+class XGUI_MenuMgr;
class XGUI_ModuleConnector;
class XGUI_ObjectsBrowser;
class XGUI_OperationMgr;
return myActionsMgr;
}
+ //! ! Returns an actions manager
+ XGUI_MenuMgr* menuMgr() const
+ {
+ return myMenuMgr;
+ }
+
//! Returns property panel widget
XGUI_PropertyPanel* propertyPanel() const
{
XGUI_Displayer* myDisplayer;
XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
XGUI_ActionsMgr* myActionsMgr;
+ XGUI_MenuMgr* myMenuMgr; ///< manager to build menu/tool bar using order defined in XML
XGUI_SalomeConnector* mySalomeConnector;
XGUI_ErrorDialog* myErrorDlg;
XGUI_ViewerProxy* myViewerProxy;
#include "XGUI_QtEvents.h"
#ifndef HAVE_SALOME
-#include <AppElements_Workbench.h>
-#include <AppElements_Command.h>
-#include <AppElements_MainMenu.h>
#include <AppElements_MainWindow.h>
-#include <AppElements_MenuGroupPanel.h>
-#include <AppElements_Button.h>
#endif
#include <ModuleBase_IModule.h>
//Initialize event listening
Events_Loop* aLoop = Events_Loop::loop();
aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
- aLoop->registerListener(this, Events_Loop::eventByName(Config_FeatureMessage::GUI_EVENT()));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
return;
}
- //A message to start feature creation received.
- if (theMessage->eventID() == Events_Loop::loop()->eventByName(Config_FeatureMessage::GUI_EVENT())) {
- std::shared_ptr<Config_FeatureMessage> aFeatureMsg =
- std::dynamic_pointer_cast<Config_FeatureMessage>(theMessage);
- if (!aFeatureMsg->isInternal()) {
- addFeature(aFeatureMsg);
- }
- }
// Process creation of Part
- else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
+ if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
onFeatureCreatedMsg(aUpdMsg);
return false;
}
-void XGUI_WorkshopListener::addFeature(const std::shared_ptr<Config_FeatureMessage>& theMessage)
-{
- if (!theMessage) {
-#ifdef _DEBUG
- qDebug() << "XGUI_WorkshopListener::addFeature: NULL message.";
-#endif
- return;
- }
- ActionInfo aFeatureInfo;
- aFeatureInfo.initFrom(theMessage);
-
- XGUI_Workshop* aWorkshop = workshop();
-
- QString aWchName = QString::fromStdString(theMessage->workbenchId());
- QStringList aNestedFeatures =
- QString::fromStdString(theMessage->nestedFeatures()).split(" ", QString::SkipEmptyParts);
- QList<QAction*> aNestedActList;
- bool isColumnButton = !aNestedFeatures.isEmpty();
- if (isColumnButton) {
- QString aNestedActions = QString::fromStdString(theMessage->actionsWhenNested());
- XGUI_OperationMgr* anOperationMgr = aWorkshop->operationMgr();
- XGUI_ActionsMgr* anActionsMgr = aWorkshop->actionsMgr();
- if (aNestedActions.contains(FEATURE_WHEN_NESTED_ACCEPT)) {
- QAction* anAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AcceptAll, NULL);
- connect(anAction, SIGNAL(triggered()), anOperationMgr, SLOT(commitAllOperations()));
- aNestedActList << anAction;
- }
- if (aNestedActions.contains(FEATURE_WHEN_NESTED_ABORT)) {
- QAction* anAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::AbortAll, NULL);
- connect(anAction, SIGNAL(triggered()), anOperationMgr, SLOT(abortAllOperations()));
- aNestedActList << anAction;
- }
- }
-
-#ifdef HAVE_SALOME
- XGUI_SalomeConnector* aSalomeConnector = aWorkshop->salomeConnector();
- QAction* aAction;
- if (isColumnButton) {
- aAction = aSalomeConnector->addFeatureOfNested(aWchName, aFeatureInfo, aNestedActList);
- } else {
- //Issue #650: in the SALOME mode the tooltip should be same as text
- aFeatureInfo.toolTip = aFeatureInfo.text;
- aAction = aSalomeConnector->addFeature(aWchName, aFeatureInfo);
- }
- aSalomeConnector->setFeatureInfo(aFeatureInfo.id, theMessage);
-
- aWorkshop->actionsMgr()->addCommand(aAction);
- aWorkshop->module()->actionCreated(aAction);
-#else
- //Find or create Workbench
- AppElements_MainMenu* aMenuBar = aWorkshop->mainWindow()->menuObject();
- AppElements_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
- if (!aPage) {
- aPage = aWorkshop->addWorkbench(aWchName);
- }
- //Find or create Group
- QString aGroupName = QString::fromStdString(theMessage->groupId());
- AppElements_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
- if (!aGroup) {
- aGroup = aPage->addGroup(aGroupName);
- }
- // Check if hotkey sequence is already defined:
- XGUI_ActionsMgr* anActionsMgr = aWorkshop->actionsMgr();
- QKeySequence aHotKey = anActionsMgr->registerShortcut(aFeatureInfo.shortcut);
- if(aHotKey != aFeatureInfo.shortcut) {
- aFeatureInfo.shortcut = aHotKey;
- }
- AppElements_Command* aCommand = aGroup->addFeature(theMessage);
- // Enrich created button with accept/abort buttons if necessary
- AppElements_Button* aButton = aCommand->button();
- if (aButton->isColumnButton()) {
- aButton->setAdditionalButtons(aNestedActList);
- }
- aWorkshop->actionsMgr()->addCommand(aCommand);
- aWorkshop->module()->actionCreated(aCommand);
-#endif
-}
-
-
//**************************************************************
bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj, bool& theFirstVisualizedBody)
{
/// Procedure to process postponed events
bool event(QEvent * theEvent);
- /// Process event "Add a feature"
- void addFeature(const std::shared_ptr<Config_FeatureMessage>&);
-
/// Process feature update message
void onFeatureUpdatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& );