]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Workshop.h
Salome HOME
1b85fbc0c417f318e6563492203f5742d7441808
[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
10 #include <QObject>
11 #include <QMap>
12 #include <QIcon>
13 #include <QKeySequence>
14
15
16 class XGUI_MainWindow;
17 class XGUI_Command;
18 class XGUI_Workbench;
19 class XGUI_SelectionMgr;
20 class XGUI_Displayer;
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;
31
32 class ModuleBase_Operation;
33 class ModuleBase_IModule;
34
35 class Config_FeatureMessage;
36 class Config_PointerMessage;
37
38 class QWidget;
39 class QDockWidget;
40
41 class Model_ObjectUpdatedMessage;
42 class QAction;
43
44 /**\class XGUI_Workshop
45  * \ingroup GUI
46  * \brief Class which defines a configuration of the application (Workshop) and launches it.
47  */
48 class XGUI_EXPORT XGUI_Workshop: public QObject, public Events_Listener
49 {
50 Q_OBJECT
51 public:
52
53   XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
54   virtual ~XGUI_Workshop();
55
56   //! Starting of the application
57   void startApplication();
58
59   //! Returns main window (Desktop) of the application
60   XGUI_MainWindow* mainWindow() const
61   {
62     return myMainWindow;
63   }
64
65   //! Returns selection manager object
66   XGUI_SelectionMgr* selector() const { return mySelector; }
67
68   //! Returns displayer
69   XGUI_Displayer* displayer() const { return myDisplayer; }
70
71   //! ! Returns operation manager.
72   XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
73
74   //! ! Returns an actions manager
75   XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; };
76
77   //! Returns property panel widget
78   XGUI_PropertyPanel* propertyPanel() const { return myPropertyPanel; }
79
80   //! Returns context menu manager object
81   XGUI_ContextMenuMgr* contextMenuMgr() const { return myContextMenuMgr; }
82
83   //! Creates and adds a new workbench (menu group) with the given name and returns it
84   XGUI_Workbench* addWorkbench(const QString& theName);
85
86   //! Redefinition of Events_Listener method
87   virtual void processEvent(const Events_Message* theMessage);
88
89   //! Returns an object which provides interface to Salome Module (LightApp_Module)
90   XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
91
92   //! Provides an object which provides interface to Salome Viewer
93   XGUI_SalomeViewer* salomeViewer() const;
94
95   //! Returns true if the application works as SALOME module
96   bool isSalomeMode() const { return mySalomeConnector != 0; }
97
98   //! Returns Object browser
99   XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
100
101   void salomeViewerSelectionChanged();
102
103   XGUI_ViewerProxy* viewer() const { return myViewerProxy; }
104
105   /// Returns the module connectory
106   /// \returns the instance of connector
107   XGUI_ModuleConnector* moduleConnector() const { return myModuleConnector; }
108
109   //! Returns icon name according to feature Id
110   static QString featureIcon(const std::string& theId);
111
112   //! Activates or deactivates a part
113   //! If PartPtr is Null pointer then PartSet will be activated
114   void activatePart(ResultPartPtr theFeature);
115
116   //! Delete features
117   void deleteObjects(const QList<ObjectPtr>& theList);
118
119   //! Show the given features in 3d Viewer
120   void showObjects(const QList<ObjectPtr>& theList, bool isVisible);
121
122   ModuleBase_IModule* module() const { return myModule; }
123
124 signals:
125   void salomeViewerSelection();
126   void errorOccurred(const QString&);
127
128 public slots:
129   void updateCommandStatus();
130   void updateCommandsOnViewSelection();
131
132   void onNew();
133   void onOpen();
134   bool onSave();
135   bool onSaveAs();
136   void onExit();
137   void onUndo();
138   void onRedo();
139
140   void showPropertyPanel();
141   void hidePropertyPanel();
142   void showObjectBrowser();
143   void hideObjectBrowser();
144
145   void onFeatureTriggered();
146   void changeCurrentDocument(ObjectPtr theObj);
147
148   void activateLastPart();
149
150 protected:
151   //Event-loop processing methods:
152   void addFeature(const Config_FeatureMessage*);
153   void connectWithOperation(ModuleBase_Operation* theOperation);
154   void saveDocument(QString theName);
155
156   void onFeatureUpdatedMsg(const Model_ObjectUpdatedMessage* theMsg);
157   void onFeatureCreatedMsg(const Model_ObjectUpdatedMessage* theMsg);
158   void onFeatureRedisplayMsg(const Model_ObjectUpdatedMessage* theMsg);
159
160   QList<QAction*> getModuleCommands() const;
161
162 protected slots:
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);
170
171   void onContextMenuCommand(const QString& theId, bool isChecked);
172
173   void onWidgetValuesChanged();
174
175 private:
176   void initMenu();
177
178   ModuleBase_IModule* loadModule(const QString& theModule);
179   bool activateModule();
180
181   QDockWidget* createObjectBrowser(QWidget* theParent);
182   QDockWidget* createPropertyPanel(QWidget* theParent);
183
184   // Creates Dock widgets: Object browser and Property panel
185   void createDockWidgets();
186
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;
200
201   QString myCurrentDir;
202   static QMap<QString, QString> myIcons;
203
204 };
205
206 #endif