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