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