]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Workshop.h
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
[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   //! ! Returns an actions manager
63   XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; };
64
65   //! Creates and adds a new workbench (menu group) with the given name and returns it
66   XGUI_Workbench* addWorkbench(const QString& theName);
67
68   //! Redefinition of Events_Listener method
69   virtual void processEvent(const Events_Message* theMessage);
70
71   XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
72
73   //! Returns true if the application works as SALOME module
74   bool isSalomeMode() const { return mySalomeConnector != 0; }
75
76   //! Returns Object browser
77   XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
78
79   void salomeViewerSelectionChanged();
80
81 signals:
82   void salomeViewerSelection();
83
84 public slots:
85   void updateCommandStatus();
86
87   void onNew();
88   void onOpen();
89   void onSave();
90   void onSaveAs();
91   void onExit();
92   void onUndo();
93   void onRedo();
94
95   void showPropertyPanel();
96   void hidePropertyPanel();
97   void showObjectBrowser();
98   void hideObjectBrowser();
99
100   void onFeatureTriggered();
101   void changeCurrentDocument();
102
103 signals:
104   void errorOccurred(const QString&);
105
106 protected:
107   //Event-loop processing methods:
108   void addFeature(const Config_FeatureMessage*);
109   void connectWithOperation(ModuleBase_Operation* theOperation);
110   void saveDocument(QString theName);
111
112 protected slots:
113   /// SLOT, that is called after the operation is started. Update workshop state according to
114   /// the started operation, e.g. visualizes the property panel and connect to it.
115   void onOperationStarted();
116   /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
117   /// hides the property panel and udpate the command status.
118   /// \param theOpertion a stopped operation
119   void onOperationStopped(ModuleBase_Operation* theOperation);
120
121 private:
122   void initMenu();
123
124   XGUI_Module* loadModule(const QString& theModule);
125   bool activateModule();
126
127   QDockWidget* createObjectBrowser(QWidget* theParent);
128   QDockWidget* createPropertyPanel(QWidget* theParent);
129
130   // Creates Dock widgets: Object browser and Property panel
131   void createDockWidgets();
132   void setPropertyPannelTitle(const QString& theTitle);
133
134   QString myCurrentFile;
135   XGUI_MainWindow* myMainWindow;
136   XGUI_Module* myPartSetModule;
137   XGUI_ObjectsBrowser* myObjectBrowser;
138   QDockWidget* myPropertyPanelDock;
139   XGUI_SelectionMgr* mySelector;
140   XGUI_Displayer* myDisplayer;
141   XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
142   XGUI_ActionsMgr* myActionsMgr;
143   XGUI_SalomeConnector* mySalomeConnector;
144   XGUI_ErrorDialog* myErrorDlg;
145 };
146
147 #endif