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