Salome HOME
Merge branch 'master' of newgeom:newgeom
[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 <Events_Listener.h>
6
7 #include <QObject>
8 #include <QMap>
9 #include <QIcon>
10 #include <QKeySequence>
11
12 class XGUI_MainWindow;
13 class XGUI_Command;
14 class XGUI_Module;
15 class XGUI_Workbench;
16 class XGUI_SelectionMgr;
17 class XGUI_Displayer;
18 class XGUI_OperationMgr;
19 class XGUI_SalomeConnector;
20 class XGUI_ObjectsBrowser;
21 class XGUI_ActionsMgr;
22 class ModuleBase_Operation;
23 class ModuleBase_PropPanelOperation;
24
25 class Config_FeatureMessage;
26 class Config_PointerMessage;
27
28 class QWidget;
29 class QDockWidget;
30
31 /**\class XGUI_Workshop
32  * \ingroup GUI
33  * \brief Class which defines a configuration of the application (Workshop) and launches it.
34  */
35 class XGUI_EXPORT XGUI_Workshop: public QObject, public Events_Listener
36 {
37 Q_OBJECT
38 public:
39
40   XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
41   virtual ~XGUI_Workshop();
42
43   //! Starting of the application
44   void startApplication();
45
46   //! Returns main window (Desktop) of the application
47   XGUI_MainWindow* mainWindow() const
48   {
49     return myMainWindow;
50   }
51
52   //! Returns selection manager object
53   XGUI_SelectionMgr* selector() const { return mySelector; }
54
55   //! Returns displayer
56   XGUI_Displayer* displayer() const;
57
58   //! ! Returns operation manager.
59   XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
60
61   //! Creates and adds a new workbench (menu group) with the given name and returns it
62   XGUI_Workbench* addWorkbench(const QString& theName);
63
64   //! Redefinition of Events_Listener method
65   virtual void processEvent(const Events_Message* theMessage);
66
67   XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
68
69   //! Returns true if the application works as SALOME module
70   bool isSalomeMode() const { return mySalomeConnector != 0; }
71
72   //! Returns Object browser
73   XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
74
75   void salomeViewerSelectionChanged();
76
77 signals:
78   void salomeViewerSelection();
79
80 public slots:
81   void updateCommandStatus();
82
83   void onNew();
84   void onOpen();
85   void onSave();
86   void onSaveAs();
87   void onExit();
88   void onUndo();
89   void onRedo();
90
91   void showPropertyPanel();
92   void hidePropertyPanel();
93   void showObjectBrowser();
94   void hideObjectBrowser();
95
96   void onFeatureTriggered();
97
98   void changeCurrentDocument();
99
100 protected:
101   //Event-loop processing methods:
102   void addFeature(const Config_FeatureMessage*);
103   void connectWithOperation(ModuleBase_Operation* theOperation);
104
105 protected slots:
106   /// SLOT, that is called after the operation is started. Update workshop state according to
107   /// the started operation, e.g. visualizes the property panel and connect to it.
108   void onOperationStarted();
109   /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
110   /// hides the property panel and udpate the command status.
111   /// \param theOpertion a stopped operation
112   void onOperationStopped(ModuleBase_Operation* theOperation);
113
114 private:
115   void initMenu();
116
117   XGUI_Module* loadModule(const QString& theModule);
118   bool activateModule();
119
120   QDockWidget* createObjectBrowser(QWidget* theParent);
121   QDockWidget* createPropertyPanel(QWidget* theParent);
122
123   // Creates Dock widgets: Object browser and Property panel
124   void createDockWidgets();
125   void setPropertyPannelTitle(const QString& theTitle);
126
127
128   XGUI_MainWindow* myMainWindow;
129   XGUI_Module* myPartSetModule;
130
131   XGUI_ObjectsBrowser* myObjectBrowser;
132   QDockWidget* myPropertyPanelDock;
133
134   XGUI_SelectionMgr* mySelector;
135   XGUI_Displayer* myDisplayer;
136
137   XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
138   XGUI_ActionsMgr* myActionsMgr;
139
140
141   XGUI_SalomeConnector* mySalomeConnector;
142 };
143
144 #endif