Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[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   //! Activates or deactivates a part
102   //! If PartPtr is Null pointer then PartSet will be activated
103   void activatePart(FeaturePtr theFeature);
104
105   void deleteFeatures(QFeatureList theList);
106
107 signals:
108   void salomeViewerSelection();
109   void errorOccurred(const QString&);
110
111 public slots:
112   void updateCommandStatus();
113
114   void onNew();
115   void onOpen();
116   void onSave();
117   void onSaveAs();
118   void onExit();
119   void onUndo();
120   void onRedo();
121
122   void showPropertyPanel();
123   void hidePropertyPanel();
124   void showObjectBrowser();
125   void hideObjectBrowser();
126
127   void onFeatureTriggered();
128   void changeCurrentDocument(FeaturePtr thePart);
129
130   void activateLastPart();
131
132 protected:
133   //Event-loop processing methods:
134   void addFeature(const Config_FeatureMessage*);
135   void connectWithOperation(ModuleBase_Operation* theOperation);
136   void saveDocument(QString theName);
137
138 protected slots:
139   /// SLOT, that is called after the operation is started. Update workshop state according to
140   /// the started operation, e.g. visualizes the property panel and connect to it.
141   void onOperationStarted();
142   /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
143   /// hides the property panel and udpate the command status.
144   /// \param theOpertion a stopped operation
145   void onOperationStopped(ModuleBase_Operation* theOperation);
146
147   void onContextMenuCommand(const QString& theId, bool isChecked);
148
149 private:
150   void initMenu();
151
152   XGUI_Module* loadModule(const QString& theModule);
153   bool activateModule();
154
155   QDockWidget* createObjectBrowser(QWidget* theParent);
156   QDockWidget* createPropertyPanel(QWidget* theParent);
157
158   // Creates Dock widgets: Object browser and Property panel
159   void createDockWidgets();
160
161   XGUI_MainWindow* myMainWindow;
162   XGUI_Module* myPartSetModule;
163   XGUI_ObjectsBrowser* myObjectBrowser;
164   XGUI_PropertyPanel* myPropertyPanel;
165   XGUI_SelectionMgr* mySelector;
166   XGUI_Displayer* myDisplayer;
167   XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
168   XGUI_ActionsMgr* myActionsMgr;
169   XGUI_SalomeConnector* mySalomeConnector;
170   XGUI_ErrorDialog* myErrorDlg;
171   XGUI_ViewerProxy* myViewerProxy;
172   XGUI_ContextMenuMgr* myContextMenuMgr;
173
174   QString myCurrentDir;
175   static QMap<QString, QString> myIcons;
176
177 };
178
179 #endif