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