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