1 #ifndef XGUI_WORKSHOP_H
2 #define XGUI_WORKSHOP_H
5 #include "XGUI_Constants.h"
6 #include <Events_Listener.h>
7 #include <ModuleBase_Definitions.h>
8 #include <ModelAPI_ResultPart.h>
13 #include <QKeySequence>
16 class XGUI_MainWindow;
19 class XGUI_SelectionMgr;
21 class XGUI_OperationMgr;
22 class XGUI_SalomeConnector;
23 class XGUI_ObjectsBrowser;
24 class XGUI_ActionsMgr;
25 class XGUI_ErrorDialog;
26 class XGUI_SalomeViewer;
27 class XGUI_ViewerProxy;
28 class XGUI_PropertyPanel;
29 class XGUI_ContextMenuMgr;
30 class XGUI_ModuleConnector;
32 class ModuleBase_Operation;
33 class ModuleBase_IModule;
35 class Config_FeatureMessage;
36 class Config_PointerMessage;
41 class Model_ObjectUpdatedMessage;
44 /**\class XGUI_Workshop
46 * \brief Class which defines a configuration of the application (Workshop) and launches it.
48 class XGUI_EXPORT XGUI_Workshop: public QObject, public Events_Listener
53 XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
54 virtual ~XGUI_Workshop();
56 //! Starting of the application
57 void startApplication();
59 //! Returns main window (Desktop) of the application
60 XGUI_MainWindow* mainWindow() const
65 //! Returns selection manager object
66 XGUI_SelectionMgr* selector() const { return mySelector; }
69 XGUI_Displayer* displayer() const { return myDisplayer; }
71 //! ! Returns operation manager.
72 XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
74 //! ! Returns an actions manager
75 XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; };
77 //! Returns property panel widget
78 XGUI_PropertyPanel* propertyPanel() const { return myPropertyPanel; }
80 //! Returns context menu manager object
81 XGUI_ContextMenuMgr* contextMenuMgr() const { return myContextMenuMgr; }
83 //! Creates and adds a new workbench (menu group) with the given name and returns it
84 XGUI_Workbench* addWorkbench(const QString& theName);
86 //! Redefinition of Events_Listener method
87 virtual void processEvent(const Events_Message* theMessage);
89 //! Returns an object which provides interface to Salome Module (LightApp_Module)
90 XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
92 //! Provides an object which provides interface to Salome Viewer
93 XGUI_SalomeViewer* salomeViewer() const;
95 //! Returns true if the application works as SALOME module
96 bool isSalomeMode() const { return mySalomeConnector != 0; }
98 //! Returns Object browser
99 XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
101 void salomeViewerSelectionChanged();
103 XGUI_ViewerProxy* viewer() const { return myViewerProxy; }
105 /// Returns the module connectory
106 /// \returns the instance of connector
107 XGUI_ModuleConnector* moduleConnector() const { return myModuleConnector; }
109 //! Returns icon name according to feature Id
110 static QString featureIcon(const std::string& theId);
112 //! Activates or deactivates a part
113 //! If PartPtr is Null pointer then PartSet will be activated
114 void activatePart(ResultPartPtr theFeature);
117 void deleteObjects(const QList<ObjectPtr>& theList);
119 //! Show the given features in 3d Viewer
120 void showObjects(const QList<ObjectPtr>& theList, bool isVisible);
122 ModuleBase_IModule* module() const { return myModule; }
125 void salomeViewerSelection();
126 void errorOccurred(const QString&);
129 void updateCommandStatus();
130 void updateCommandsOnViewSelection();
140 void showPropertyPanel();
141 void hidePropertyPanel();
142 void showObjectBrowser();
143 void hideObjectBrowser();
145 void onFeatureTriggered();
146 void changeCurrentDocument(ObjectPtr theObj);
148 void activateLastPart();
151 //Event-loop processing methods:
152 void addFeature(const Config_FeatureMessage*);
153 void connectWithOperation(ModuleBase_Operation* theOperation);
154 void saveDocument(QString theName);
156 void onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg);
157 void onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg);
158 void onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theMsg);
160 QList<QAction*> getModuleCommands() const;
163 /// SLOT, that is called after the operation is started. Update workshop state according to
164 /// the started operation, e.g. visualizes the property panel and connect to it.
165 void onOperationStarted();
166 /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
167 /// hides the property panel and udpate the command status.
168 /// \param theOpertion a stopped operation
169 void onOperationStopped(ModuleBase_Operation* theOperation);
171 void onContextMenuCommand(const QString& theId, bool isChecked);
173 void onWidgetValuesChanged();
178 ModuleBase_IModule* loadModule(const QString& theModule);
179 bool activateModule();
181 QDockWidget* createObjectBrowser(QWidget* theParent);
182 QDockWidget* createPropertyPanel(QWidget* theParent);
184 // Creates Dock widgets: Object browser and Property panel
185 void createDockWidgets();
187 XGUI_MainWindow* myMainWindow;
188 ModuleBase_IModule* myModule;
189 XGUI_ObjectsBrowser* myObjectBrowser;
190 XGUI_PropertyPanel* myPropertyPanel;
191 XGUI_SelectionMgr* mySelector;
192 XGUI_Displayer* myDisplayer;
193 XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
194 XGUI_ActionsMgr* myActionsMgr;
195 XGUI_SalomeConnector* mySalomeConnector;
196 XGUI_ErrorDialog* myErrorDlg;
197 XGUI_ViewerProxy* myViewerProxy;
198 XGUI_ContextMenuMgr* myContextMenuMgr;
199 XGUI_ModuleConnector* myModuleConnector;
201 QString myCurrentDir;
202 static QMap<QString, QString> myIcons;