1 #ifndef XGUI_WORKSHOP_H
2 #define XGUI_WORKSHOP_H
5 #include "XGUI_Constants.h"
6 #include <Events_Listener.h>
7 #include <ModuleBase_Definitions.h>
8 #include <ModelAPI_ResultPart.h>
9 #include <ModelAPI_Document.h>
14 #include <QKeySequence>
16 class XGUI_MainWindow;
19 class XGUI_SelectionMgr;
21 class XGUI_OperationMgr;
22 class XGUI_SalomeConnector;
23 class XGUI_ObjectsBrowser;
24 class XGUI_ActionsMgr;
25 class XGUI_ErrorDialog;
26 class XGUI_SalomeViewer;
27 class XGUI_ViewerProxy;
28 class XGUI_PropertyPanel;
29 class XGUI_ContextMenuMgr;
30 class XGUI_ModuleConnector;
32 class ModuleBase_Operation;
33 class ModuleBase_IModule;
35 class Config_FeatureMessage;
36 class Config_PointerMessage;
41 class ModelAPI_ObjectUpdatedMessage;
42 class ModelAPI_ObjectDeletedMessage;
45 /**\class XGUI_Workshop
47 * \brief Class which defines a configuration of the application (Workshop) and launches it.
49 class XGUI_EXPORT XGUI_Workshop : public QObject, public Events_Listener
54 XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
55 virtual ~XGUI_Workshop();
57 //! Starting of the application
58 void startApplication();
60 //! Returns main window (Desktop) of the application
61 XGUI_MainWindow* mainWindow() const
66 //! Returns selection manager object
67 XGUI_SelectionMgr* selector() const
73 XGUI_Displayer* displayer() const
78 //! ! Returns operation manager.
79 XGUI_OperationMgr* operationMgr() const
81 return myOperationMgr;
84 //! ! Returns an actions manager
85 XGUI_ActionsMgr* actionsMgr() const
91 //! Returns property panel widget
92 XGUI_PropertyPanel* propertyPanel() const
94 return myPropertyPanel;
97 //! Returns context menu manager object
98 XGUI_ContextMenuMgr* contextMenuMgr() const
100 return myContextMenuMgr;
103 //! Creates and adds a new workbench (menu group) with the given name and returns it
104 XGUI_Workbench* addWorkbench(const QString& theName);
106 //! Redefinition of Events_Listener method
107 virtual void processEvent(const Events_Message* theMessage);
109 //! Returns an object which provides interface to Salome Module (LightApp_Module)
110 XGUI_SalomeConnector* salomeConnector() const
112 return mySalomeConnector;
115 //! Provides an object which provides interface to Salome Viewer
116 XGUI_SalomeViewer* salomeViewer() const;
118 //! Returns true if the application works as SALOME module
119 bool isSalomeMode() const
121 return mySalomeConnector != 0;
124 //! Returns Object browser
125 XGUI_ObjectsBrowser* objectBrowser() const
127 return myObjectBrowser;
130 void salomeViewerSelectionChanged();
132 XGUI_ViewerProxy* viewer() const
134 return myViewerProxy;
137 /// Returns the module connectory
138 /// \returns the instance of connector
139 XGUI_ModuleConnector* moduleConnector() const
141 return myModuleConnector;
144 //! Returns icon name according to feature Id
145 static QString featureIcon(const std::string& theId);
147 //! Activates or deactivates a part
148 //! If PartPtr is Null pointer then PartSet will be activated
149 void activatePart(ResultPartPtr theFeature);
152 void deleteObjects(const QList<ObjectPtr>& theList);
154 //! Show the given features in 3d Viewer
155 void showObjects(const QList<ObjectPtr>& theList, bool isVisible);
157 //! Show the given features in 3d Viewer
158 void showOnlyObjects(const QList<ObjectPtr>& theList);
160 ModuleBase_IModule* module() const
165 /// Returns current directory whic contains data files
166 QString currentDataDir() const { return myCurrentDir; }
168 /// Returns current directory whic contains data files
169 void setCurrentDataDir(const QString& theDir) { myCurrentDir = theDir; }
172 * Save the current document into a directory
173 * \param theName - path to the directory
174 * \param theFileNames - returned file names created in this directory
176 void saveDocument(const QString& theName, std::list<std::string>& theFileNames);
179 void salomeViewerSelection();
180 void errorOccurred(const QString&);
183 void updateCommandStatus();
184 void updateCommandsOnViewSelection();
193 void onPreferences();
195 void showPropertyPanel();
196 void hidePropertyPanel();
197 void showObjectBrowser();
198 void hideObjectBrowser();
200 void onFeatureTriggered();
201 void changeCurrentDocument(ObjectPtr theObj);
203 void activateLastPart();
205 /// Display all results of the current document
206 void displayAllResults();
209 //Event-loop processing methods:
210 void addFeature(const Config_FeatureMessage*);
211 void connectWithOperation(ModuleBase_Operation* theOperation);
213 void onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
214 void onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
215 void onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
216 void onObjectDeletedMsg(const ModelAPI_ObjectDeletedMessage* theMsg);
218 void validateOperation(const QString& theOperationId);
220 QList<QAction*> getModuleCommands() const;
222 void displayDocumentResults(DocumentPtr theDoc);
223 void displayGroupResults(DocumentPtr theDoc, std::string theGroup);
226 /// SLOT, that is called after the operation is started. Update workshop state according to
227 /// the started operation, e.g. visualizes the property panel and connect to it.
228 void onOperationStarted();
229 /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
230 /// hides the property panel and udpate the command status.
231 /// \param theOpertion a stopped operation
232 void onOperationStopped(ModuleBase_Operation* theOperation);
234 void onContextMenuCommand(const QString& theId, bool isChecked);
236 void onWidgetValuesChanged();
238 void onStartWaiting();
243 void registerValidators() const;
245 ModuleBase_IModule* loadModule(const QString& theModule);
246 bool activateModule();
248 QDockWidget* createObjectBrowser(QWidget* theParent);
249 QDockWidget* createPropertyPanel(QWidget* theParent);
251 // Creates Dock widgets: Object browser and Property panel
252 void createDockWidgets();
254 XGUI_MainWindow* myMainWindow;
255 ModuleBase_IModule* myModule;
256 XGUI_ObjectsBrowser* myObjectBrowser;
257 XGUI_PropertyPanel* myPropertyPanel;
258 XGUI_SelectionMgr* mySelector;
259 XGUI_Displayer* myDisplayer;
260 XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
261 XGUI_ActionsMgr* myActionsMgr;
262 XGUI_SalomeConnector* mySalomeConnector;
263 XGUI_ErrorDialog* myErrorDlg;
264 XGUI_ViewerProxy* myViewerProxy;
265 XGUI_ContextMenuMgr* myContextMenuMgr;
266 XGUI_ModuleConnector* myModuleConnector;
268 QString myCurrentDir;
269 static QMap<QString, QString> myIcons;