]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Workshop.h
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / XGUI / XGUI_Workshop.h
1 #ifndef XGUI_WORKSHOP_H
2 #define XGUI_WORKSHOP_H
3
4 #include "XGUI.h"
5 #include "XGUI_Constants.h"
6 #include <Events_Listener.h>
7 #include <ModuleBase_Definitions.h>
8 #include <ModelAPI_ResultPart.h>
9 #include <ModelAPI_Document.h>
10
11 #include <QObject>
12 #include <QMap>
13 #include <QIcon>
14 #include <QKeySequence>
15
16
17 class XGUI_MainWindow;
18 class XGUI_Command;
19 class XGUI_Workbench;
20 class XGUI_SelectionMgr;
21 class XGUI_Displayer;
22 class XGUI_OperationMgr;
23 class XGUI_SalomeConnector;
24 class XGUI_ObjectsBrowser;
25 class XGUI_ActionsMgr;
26 class XGUI_ErrorDialog;
27 class XGUI_SalomeViewer;
28 class XGUI_ViewerProxy;
29 class XGUI_PropertyPanel;
30 class XGUI_ContextMenuMgr;
31 class XGUI_ModuleConnector;
32
33 class ModuleBase_Operation;
34 class ModuleBase_IModule;
35
36 class Config_FeatureMessage;
37 class Config_PointerMessage;
38
39 class QWidget;
40 class QDockWidget;
41
42 class ModelAPI_ObjectUpdatedMessage;
43 class ModelAPI_ObjectDeletedMessage;
44 class QAction;
45
46 class SUIT_ResourceMgr;
47
48 /**\class XGUI_Workshop
49  * \ingroup GUI
50  * \brief Class which defines a configuration of the application (Workshop) and launches it.
51  */
52 class XGUI_EXPORT XGUI_Workshop: public QObject, public Events_Listener
53 {
54 Q_OBJECT
55 public:
56
57   XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
58   virtual ~XGUI_Workshop();
59
60   //! Starting of the application
61   void startApplication();
62
63   //! Returns main window (Desktop) of the application
64   XGUI_MainWindow* mainWindow() const
65   {
66     return myMainWindow;
67   }
68
69   //! Returns selection manager object
70   XGUI_SelectionMgr* selector() const { return mySelector; }
71
72   //! Returns displayer
73   XGUI_Displayer* displayer() const { return myDisplayer; }
74
75   //! ! Returns operation manager.
76   XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
77
78   //! ! Returns an actions manager
79   XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; };
80
81   //! Returns property panel widget
82   XGUI_PropertyPanel* propertyPanel() const { return myPropertyPanel; }
83
84   //! Returns context menu manager object
85   XGUI_ContextMenuMgr* contextMenuMgr() const { return myContextMenuMgr; }
86
87   //! Creates and adds a new workbench (menu group) with the given name and returns it
88   XGUI_Workbench* addWorkbench(const QString& theName);
89
90   //! Redefinition of Events_Listener method
91   virtual void processEvent(const Events_Message* theMessage);
92
93   //! Returns an object which provides interface to Salome Module (LightApp_Module)
94   XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
95
96   //! Provides an object which provides interface to Salome Viewer
97   XGUI_SalomeViewer* salomeViewer() const;
98
99   //! Returns true if the application works as SALOME module
100   bool isSalomeMode() const { return mySalomeConnector != 0; }
101
102   //! Returns Object browser
103   XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
104
105   void salomeViewerSelectionChanged();
106
107   XGUI_ViewerProxy* viewer() const { return myViewerProxy; }
108
109   /// Returns the module connectory
110   /// \returns the instance of connector
111   XGUI_ModuleConnector* moduleConnector() const { return myModuleConnector; }
112
113   //! Returns icon name according to feature Id
114   static QString featureIcon(const std::string& theId);
115
116   static SUIT_ResourceMgr* resourceMgr() { return myResourceMgr; }
117
118   //! Activates or deactivates a part
119   //! If PartPtr is Null pointer then PartSet will be activated
120   void activatePart(ResultPartPtr theFeature);
121
122   //! Delete features
123   void deleteObjects(const QList<ObjectPtr>& theList);
124
125   //! Show the given features in 3d Viewer
126   void showObjects(const QList<ObjectPtr>& theList, bool isVisible);
127
128   ModuleBase_IModule* module() const { return myModule; }
129
130 signals:
131   void salomeViewerSelection();
132   void errorOccurred(const QString&);
133
134 public slots:
135   void updateCommandStatus();
136   void updateCommandsOnViewSelection();
137
138   void onNew();
139   void onOpen();
140   bool onSave();
141   bool onSaveAs();
142   void onExit();
143   void onUndo();
144   void onRedo();
145
146   void showPropertyPanel();
147   void hidePropertyPanel();
148   void showObjectBrowser();
149   void hideObjectBrowser();
150
151   void onFeatureTriggered();
152   void changeCurrentDocument(ObjectPtr theObj);
153
154   void activateLastPart();
155
156 protected:
157   //Event-loop processing methods:
158   void addFeature(const Config_FeatureMessage*);
159   void connectWithOperation(ModuleBase_Operation* theOperation);
160   void saveDocument(QString theName);
161
162   void onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
163   void onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
164   void onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
165   void onObjectDeletedMsg(const ModelAPI_ObjectDeletedMessage* theMsg);
166
167   QList<QAction*> getModuleCommands() const;
168
169   void displayAllResults();
170   void displayDocumentResults(DocumentPtr theDoc);
171   void displayGroupResults(DocumentPtr theDoc, std::string theGroup);
172
173 protected slots:
174   /// SLOT, that is called after the operation is started. Update workshop state according to
175   /// the started operation, e.g. visualizes the property panel and connect to it.
176   void onOperationStarted();
177   /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
178   /// hides the property panel and udpate the command status.
179   /// \param theOpertion a stopped operation
180   void onOperationStopped(ModuleBase_Operation* theOperation);
181
182   void onContextMenuCommand(const QString& theId, bool isChecked);
183
184   void onWidgetValuesChanged();
185
186   void onStartWaiting();
187
188 private:
189   void initMenu();
190
191   void registerValidators() const;
192
193
194   ModuleBase_IModule* loadModule(const QString& theModule);
195   bool activateModule();
196
197   QDockWidget* createObjectBrowser(QWidget* theParent);
198   QDockWidget* createPropertyPanel(QWidget* theParent);
199
200   // Creates Dock widgets: Object browser and Property panel
201   void createDockWidgets();
202
203   XGUI_MainWindow* myMainWindow;
204   ModuleBase_IModule* myModule;
205   XGUI_ObjectsBrowser* myObjectBrowser;
206   XGUI_PropertyPanel* myPropertyPanel;
207   XGUI_SelectionMgr* mySelector;
208   XGUI_Displayer* myDisplayer;
209   XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
210   XGUI_ActionsMgr* myActionsMgr;
211   XGUI_SalomeConnector* mySalomeConnector;
212   XGUI_ErrorDialog* myErrorDlg;
213   XGUI_ViewerProxy* myViewerProxy;
214   XGUI_ContextMenuMgr* myContextMenuMgr;
215   XGUI_ModuleConnector* myModuleConnector;
216
217   QString myCurrentDir;
218   static QMap<QString, QString> myIcons;
219
220   static SUIT_ResourceMgr* myResourceMgr;
221
222 };
223
224 #endif