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_Document.h>
9 #include <ModelAPI_Feature.h>
13 #include <QKeySequence>
16 class AppElements_MainWindow;
17 class AppElements_Command;
18 class AppElements_Workbench;
20 class XGUI_SelectionMgr;
22 class XGUI_OperationMgr;
23 class XGUI_SalomeConnector;
24 class XGUI_ObjectsBrowser;
25 class XGUI_ActionsMgr;
26 class XGUI_ErrorDialog;
27 class XGUI_SalomeViewer;
28 class XGUI_ViewerProxy;
29 class XGUI_PropertyPanel;
30 class XGUI_ContextMenuMgr;
31 class XGUI_ModuleConnector;
33 class ModuleBase_Operation;
34 class ModuleBase_IModule;
35 class ModuleBase_IViewer;
37 class Config_FeatureMessage;
38 class Config_PointerMessage;
43 class ModelAPI_ObjectUpdatedMessage;
44 class ModelAPI_ObjectDeletedMessage;
45 class ModelAPI_ResultPart;
48 /**\class XGUI_Workshop
50 * \brief Class which defines a configuration of the application (Workshop) and launches it.
52 class XGUI_EXPORT XGUI_Workshop : public QObject, public Events_Listener
57 XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
58 virtual ~XGUI_Workshop();
60 //! Starting of the application
61 void startApplication();
63 //! Returns main window (Desktop) of the application
64 AppElements_MainWindow* mainWindow() const
69 //! Returns selection manager object
70 XGUI_SelectionMgr* selector() const
76 XGUI_Displayer* displayer() const
81 //! ! Returns operation manager.
82 XGUI_OperationMgr* operationMgr() const
84 return myOperationMgr;
87 //! ! Returns an actions manager
88 XGUI_ActionsMgr* actionsMgr() const
94 //! Returns property panel widget
95 XGUI_PropertyPanel* propertyPanel() const
97 return myPropertyPanel;
100 //! Returns context menu manager object
101 XGUI_ContextMenuMgr* contextMenuMgr() const
103 return myContextMenuMgr;
106 //! Creates and adds a new workbench (menu group) with the given name and returns it
107 AppElements_Workbench* addWorkbench(const QString& theName);
109 //! Redefinition of Events_Listener method
110 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
112 //! Returns an object which provides interface to Salome Module (LightApp_Module)
113 XGUI_SalomeConnector* salomeConnector() const
115 return mySalomeConnector;
118 //! Provides an object which provides interface to Salome Viewer
119 ModuleBase_IViewer* salomeViewer() const;
121 //! Returns true if the application works as SALOME module
122 bool isSalomeMode() const
124 return mySalomeConnector != 0;
127 //! Returns Object browser
128 XGUI_ObjectsBrowser* objectBrowser() const
130 return myObjectBrowser;
133 void salomeViewerSelectionChanged();
135 XGUI_ViewerProxy* viewer() const
137 return myViewerProxy;
140 /// Returns the module connectory
141 /// \returns the instance of connector
142 XGUI_ModuleConnector* moduleConnector() const
144 return myModuleConnector;
147 //! Returns icon name according to feature
148 static QIcon featureIcon(const FeaturePtr& theFeature);
150 //! Activates or deactivates a part
151 //! If PartPtr is Null pointer then PartSet will be activated
152 void activatePart(std::shared_ptr<ModelAPI_ResultPart> theFeature);
155 void deleteObjects(const QObjectPtrList& theList);
157 //! Show the given features in 3d Viewer
158 void showObjects(const QObjectPtrList& theList, bool isVisible);
160 //! Show the given features in 3d Viewer
161 void showOnlyObjects(const QObjectPtrList& theList);
163 void setDisplayMode(const QObjectPtrList& theList, int theMode);
165 ModuleBase_IModule* module() const
170 /// Returns current directory whic contains data files
171 QString currentDataDir() const { return myCurrentDir; }
173 /// Returns current directory whic contains data files
174 void setCurrentDataDir(const QString& theDir) { myCurrentDir = theDir; }
177 * Save the current document into a directory
178 * \param theName - path to the directory
179 * \param theFileNames - returned file names created in this directory
181 void saveDocument(const QString& theName, std::list<std::string>& theFileNames);
184 * If there is an active (uncommited) operation shows a prompt to abort it
185 * and performs abortion if user agreed. Returns true if
186 * - operation aborted successfully
187 * - there is no active operation
189 bool isActiveOperationAborted();
192 void salomeViewerSelection();
193 void errorOccurred(const QString&);
196 void updateCommandStatus();
197 void updateCommandsOnViewSelection();
207 void onPreferences();
209 void showPropertyPanel();
210 void hidePropertyPanel();
211 void showObjectBrowser();
212 void hideObjectBrowser();
214 void onFeatureTriggered();
215 void changeCurrentDocument(ObjectPtr theObj);
217 void activateLastPart();
219 void closeDocument();
222 // Find the nested features and set them into the operation
223 // \param theOperation an operation
224 void setNestedFeatures(ModuleBase_Operation* theOperation);
225 // Update the property panel content by the XML description of the operation and set the panel
226 // into the operation
227 // \param theOperation an operation
228 void setPropertyPanel(ModuleBase_Operation* theOperation);
230 bool event(QEvent * theEvent);
231 //Event-loop processing methods:
232 void addFeature(const std::shared_ptr<Config_FeatureMessage>&);
233 void connectWithOperation(ModuleBase_Operation* theOperation);
235 void onFeatureUpdatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
236 void onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
237 void onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
238 void onObjectDeletedMsg(const std::shared_ptr<ModelAPI_ObjectDeletedMessage>& theMsg);
240 void validateOperation(const QString& theOperationId);
242 QList<QAction*> getModuleCommands() const;
244 void displayAllResults();
245 void displayDocumentResults(DocumentPtr theDoc);
246 void displayGroupResults(DocumentPtr theDoc, std::string theGroup);
249 /// SLOT, that is called after the operation is started. Update workshop state according to
250 /// the started operation, e.g. visualizes the property panel and connect to it.
251 /// \param theOpertion a started operation
252 void onOperationStarted(ModuleBase_Operation* theOperation);
254 /// SLOT, that is called after the operation is resumed. Update workshop state according to
255 /// the started operation, e.g. visualizes the property panel and connect to it.
256 /// \param theOpertion a resumed operation
257 virtual void onOperationResumed(ModuleBase_Operation* theOperation);
259 /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
260 /// hides the property panel and udpate the command status.
261 /// \param theOpertion a stopped operation
262 void onOperationStopped(ModuleBase_Operation* theOperation);
264 void onContextMenuCommand(const QString& theId, bool isChecked);
266 void onWidgetValuesChanged();
268 void onStartWaiting();
273 void registerValidators() const;
275 ModuleBase_IModule* loadModule(const QString& theModule);
276 bool activateModule();
278 QDockWidget* createObjectBrowser(QWidget* theParent);
279 QDockWidget* createPropertyPanel(QWidget* theParent);
281 // Creates Dock widgets: Object browser and Property panel
282 void createDockWidgets();
284 AppElements_MainWindow* myMainWindow;
285 ModuleBase_IModule* myModule;
286 XGUI_ObjectsBrowser* myObjectBrowser;
287 XGUI_PropertyPanel* myPropertyPanel;
288 XGUI_SelectionMgr* mySelector;
289 XGUI_Displayer* myDisplayer;
290 XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
291 XGUI_ActionsMgr* myActionsMgr;
292 XGUI_SalomeConnector* mySalomeConnector;
293 XGUI_ErrorDialog* myErrorDlg;
294 XGUI_ViewerProxy* myViewerProxy;
295 XGUI_ContextMenuMgr* myContextMenuMgr;
296 XGUI_ModuleConnector* myModuleConnector;
298 QString myCurrentDir;
299 static QMap<QString, QString> myIcons;
303 // Flag to check that part document is in process of activating
304 bool myPartActivating;