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