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