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 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;
34 class ModuleBase_IViewer;
36 class Config_FeatureMessage;
37 class Config_PointerMessage;
42 class ModelAPI_ObjectUpdatedMessage;
43 class ModelAPI_ObjectDeletedMessage;
44 class ModelAPI_ResultPart;
47 /**\class XGUI_Workshop
49 * \brief Class which defines a configuration of the application (Workshop) and launches it.
51 class XGUI_EXPORT XGUI_Workshop : public QObject, public Events_Listener
56 XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
57 virtual ~XGUI_Workshop();
59 //! Starting of the application
60 void startApplication();
62 //! Returns main window (Desktop) of the application
63 XGUI_MainWindow* mainWindow() const
68 //! Returns selection manager object
69 XGUI_SelectionMgr* selector() const
75 XGUI_Displayer* displayer() const
80 //! ! Returns operation manager.
81 XGUI_OperationMgr* operationMgr() const
83 return myOperationMgr;
86 //! ! Returns an actions manager
87 XGUI_ActionsMgr* actionsMgr() const
93 //! Returns property panel widget
94 XGUI_PropertyPanel* propertyPanel() const
96 return myPropertyPanel;
99 //! Returns context menu manager object
100 XGUI_ContextMenuMgr* contextMenuMgr() const
102 return myContextMenuMgr;
105 //! Creates and adds a new workbench (menu group) with the given name and returns it
106 XGUI_Workbench* addWorkbench(const QString& theName);
108 //! Redefinition of Events_Listener method
109 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
111 //! Returns an object which provides interface to Salome Module (LightApp_Module)
112 XGUI_SalomeConnector* salomeConnector() const
114 return mySalomeConnector;
117 //! Provides an object which provides interface to Salome Viewer
118 ModuleBase_IViewer* salomeViewer() const;
120 //! Returns true if the application works as SALOME module
121 bool isSalomeMode() const
123 return mySalomeConnector != 0;
126 //! Returns Object browser
127 XGUI_ObjectsBrowser* objectBrowser() const
129 return myObjectBrowser;
132 void salomeViewerSelectionChanged();
134 XGUI_ViewerProxy* viewer() const
136 return myViewerProxy;
139 /// Returns the module connectory
140 /// \returns the instance of connector
141 XGUI_ModuleConnector* moduleConnector() const
143 return myModuleConnector;
146 //! Returns icon name according to feature
147 static QIcon featureIcon(const FeaturePtr& theFeature);
149 //! Returns icon name according to feature
150 static std::string featureIconStr(const FeaturePtr& theFeature);
152 //! Activates or deactivates a part
153 //! If PartPtr is Null pointer then PartSet will be activated
154 void activatePart(std::shared_ptr<ModelAPI_ResultPart> theFeature);
157 void deleteObjects(const QObjectPtrList& theList);
159 //! Show the given features in 3d Viewer
160 void showObjects(const QObjectPtrList& theList, bool isVisible);
162 //! Show the given features in 3d Viewer
163 void showOnlyObjects(const QObjectPtrList& theList);
165 void setDisplayMode(const QObjectPtrList& theList, int theMode);
167 ModuleBase_IModule* module() const
172 /// Returns current directory whic contains data files
173 QString currentDataDir() const { return myCurrentDir; }
175 /// Returns current directory whic contains data files
176 void setCurrentDataDir(const QString& theDir) { myCurrentDir = theDir; }
179 * Save the current document into a directory
180 * \param theName - path to the directory
181 * \param theFileNames - returned file names created in this directory
183 void saveDocument(const QString& theName, std::list<std::string>& theFileNames);
186 * If there is an active (uncommited) operation shows a prompt to abort it
187 * and performs abortion if user agreed. Returns true if
188 * - operation aborted successfully
189 * - there is no active operation
191 bool isActiveOperationAborted();
194 void salomeViewerSelection();
195 void errorOccurred(const QString&);
198 void updateCommandStatus();
199 void updateCommandsOnViewSelection();
209 void onPreferences();
211 void showPropertyPanel();
212 void hidePropertyPanel();
213 void showObjectBrowser();
214 void hideObjectBrowser();
216 void onFeatureTriggered();
217 void changeCurrentDocument(ObjectPtr theObj);
219 void activateLastPart();
221 void closeDocument();
224 bool event(QEvent * theEvent);
225 //Event-loop processing methods:
226 void addFeature(const std::shared_ptr<Config_FeatureMessage>&);
227 void connectWithOperation(ModuleBase_Operation* theOperation);
229 void onFeatureUpdatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
230 void onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
231 void onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
232 void onObjectDeletedMsg(const std::shared_ptr<ModelAPI_ObjectDeletedMessage>& theMsg);
234 void validateOperation(const QString& theOperationId);
236 QList<QAction*> getModuleCommands() const;
238 void displayAllResults();
239 void displayDocumentResults(DocumentPtr theDoc);
240 void displayGroupResults(DocumentPtr theDoc, std::string theGroup);
243 /// SLOT, that is called after the operation is started. Update workshop state according to
244 /// the started operation, e.g. visualizes the property panel and connect to it.
245 void onOperationStarted();
247 /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
248 /// hides the property panel and udpate the command status.
249 /// \param theOpertion a stopped operation
250 void onOperationStopped(ModuleBase_Operation* theOperation);
252 void onContextMenuCommand(const QString& theId, bool isChecked);
254 void onWidgetValuesChanged();
256 void onStartWaiting();
261 void registerValidators() const;
263 ModuleBase_IModule* loadModule(const QString& theModule);
264 bool activateModule();
266 QDockWidget* createObjectBrowser(QWidget* theParent);
267 QDockWidget* createPropertyPanel(QWidget* theParent);
269 // Creates Dock widgets: Object browser and Property panel
270 void createDockWidgets();
272 XGUI_MainWindow* myMainWindow;
273 ModuleBase_IModule* myModule;
274 XGUI_ObjectsBrowser* myObjectBrowser;
275 XGUI_PropertyPanel* myPropertyPanel;
276 XGUI_SelectionMgr* mySelector;
277 XGUI_Displayer* myDisplayer;
278 XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
279 XGUI_ActionsMgr* myActionsMgr;
280 XGUI_SalomeConnector* mySalomeConnector;
281 XGUI_ErrorDialog* myErrorDlg;
282 XGUI_ViewerProxy* myViewerProxy;
283 XGUI_ContextMenuMgr* myContextMenuMgr;
284 XGUI_ModuleConnector* myModuleConnector;
286 QString myCurrentDir;
287 static QMap<QString, QString> myIcons;
291 // Flag to check that part document is in process of activating
292 bool myPartActivating;