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>
12 #include <QKeySequence>
15 class XGUI_MainWindow;
18 class XGUI_SelectionMgr;
20 class XGUI_OperationMgr;
21 class XGUI_SalomeConnector;
22 class XGUI_ObjectsBrowser;
23 class XGUI_ActionsMgr;
24 class XGUI_ErrorDialog;
25 class XGUI_SalomeViewer;
26 class XGUI_ViewerProxy;
27 class XGUI_PropertyPanel;
28 class XGUI_ContextMenuMgr;
29 class XGUI_ModuleConnector;
31 class ModuleBase_Operation;
32 class ModuleBase_IModule;
34 class Config_FeatureMessage;
35 class Config_PointerMessage;
40 class Model_FeatureUpdatedMessage;
42 /**\class XGUI_Workshop
44 * \brief Class which defines a configuration of the application (Workshop) and launches it.
46 class XGUI_EXPORT XGUI_Workshop: public QObject, public Events_Listener
51 XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
52 virtual ~XGUI_Workshop();
54 //! Starting of the application
55 void startApplication();
57 //! Returns main window (Desktop) of the application
58 XGUI_MainWindow* mainWindow() const
63 //! Returns selection manager object
64 XGUI_SelectionMgr* selector() const { return mySelector; }
67 XGUI_Displayer* displayer() const { return myDisplayer; }
69 //! ! Returns operation manager.
70 XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
72 //! ! Returns an actions manager
73 XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; };
75 //! Returns property panel widget
76 XGUI_PropertyPanel* propertyPanel() const { return myPropertyPanel; }
78 //! Returns context menu manager object
79 XGUI_ContextMenuMgr* contextMenuMgr() const { return myContextMenuMgr; }
81 //! Creates and adds a new workbench (menu group) with the given name and returns it
82 XGUI_Workbench* addWorkbench(const QString& theName);
84 //! Redefinition of Events_Listener method
85 virtual void processEvent(const Events_Message* theMessage);
87 //! Returns an object which provides interface to Salome Module (LightApp_Module)
88 XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
90 //! Provides an object which provides interface to Salome Viewer
91 XGUI_SalomeViewer* salomeViewer() const;
93 //! Returns true if the application works as SALOME module
94 bool isSalomeMode() const { return mySalomeConnector != 0; }
96 //! Returns Object browser
97 XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
99 void salomeViewerSelectionChanged();
101 XGUI_ViewerProxy* viewer() const { return myViewerProxy; }
103 /// Returns the module connectory
104 /// \returns the instance of connector
105 XGUI_ModuleConnector* moduleConnector() const { return myModuleConnector; }
107 //! Returns icon name according to feature Id
108 static QString featureIcon(const std::string& theId);
110 //! Activates or deactivates a part
111 //! If PartPtr is Null pointer then PartSet will be activated
112 void activatePart(FeaturePtr theFeature);
115 void deleteFeatures(QFeatureList theList);
117 //! Show the given features in 3d Viewer
118 void showFeatures(QFeatureList theList, bool isVisible);
121 void salomeViewerSelection();
122 void errorOccurred(const QString&);
125 void updateCommandStatus();
126 void updateModuleCommands();
136 void showPropertyPanel();
137 void hidePropertyPanel();
138 void showObjectBrowser();
139 void hideObjectBrowser();
141 void onFeatureTriggered();
142 void changeCurrentDocument(FeaturePtr thePart);
144 void activateLastPart();
147 //Event-loop processing methods:
148 void addFeature(const Config_FeatureMessage*);
149 void connectWithOperation(ModuleBase_Operation* theOperation);
150 void saveDocument(QString theName);
152 void onFeatureUpdatedMsg(const Model_FeatureUpdatedMessage* theMsg);
153 void onFeatureCreatedMsg(const Model_FeatureUpdatedMessage* theMsg);
154 void onFeatureRedisplayMsg(const Model_FeatureUpdatedMessage* theMsg);
157 /// SLOT, that is called after the operation is started. Update workshop state according to
158 /// the started operation, e.g. visualizes the property panel and connect to it.
159 void onOperationStarted();
160 /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
161 /// hides the property panel and udpate the command status.
162 /// \param theOpertion a stopped operation
163 void onOperationStopped(ModuleBase_Operation* theOperation);
165 void onContextMenuCommand(const QString& theId, bool isChecked);
167 void onWidgetValuesChanged();
172 ModuleBase_IModule* loadModule(const QString& theModule);
173 bool activateModule();
175 QDockWidget* createObjectBrowser(QWidget* theParent);
176 QDockWidget* createPropertyPanel(QWidget* theParent);
178 // Creates Dock widgets: Object browser and Property panel
179 void createDockWidgets();
181 XGUI_MainWindow* myMainWindow;
182 ModuleBase_IModule* myPartSetModule;
183 XGUI_ObjectsBrowser* myObjectBrowser;
184 XGUI_PropertyPanel* myPropertyPanel;
185 XGUI_SelectionMgr* mySelector;
186 XGUI_Displayer* myDisplayer;
187 XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
188 XGUI_ActionsMgr* myActionsMgr;
189 XGUI_SalomeConnector* mySalomeConnector;
190 XGUI_ErrorDialog* myErrorDlg;
191 XGUI_ViewerProxy* myViewerProxy;
192 XGUI_ContextMenuMgr* myContextMenuMgr;
193 XGUI_ModuleConnector* myModuleConnector;
195 QString myCurrentDir;
196 static QMap<QString, QString> myIcons;