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>
17 class XGUI_MainWindow;
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;
36 class Config_FeatureMessage;
37 class Config_PointerMessage;
42 class ModelAPI_ObjectUpdatedMessage;
43 class ModelAPI_ObjectDeletedMessage;
46 /**\class XGUI_Workshop
48 * \brief Class which defines a configuration of the application (Workshop) and launches it.
50 class XGUI_EXPORT XGUI_Workshop: public QObject, public Events_Listener
55 XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
56 virtual ~XGUI_Workshop();
58 //! Starting of the application
59 void startApplication();
61 //! Returns main window (Desktop) of the application
62 XGUI_MainWindow* mainWindow() const
67 //! Returns selection manager object
68 XGUI_SelectionMgr* selector() const { return mySelector; }
71 XGUI_Displayer* displayer() const { return myDisplayer; }
73 //! ! Returns operation manager.
74 XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
76 //! ! Returns an actions manager
77 XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; };
79 //! Returns property panel widget
80 XGUI_PropertyPanel* propertyPanel() const { return myPropertyPanel; }
82 //! Returns context menu manager object
83 XGUI_ContextMenuMgr* contextMenuMgr() const { return myContextMenuMgr; }
85 //! Creates and adds a new workbench (menu group) with the given name and returns it
86 XGUI_Workbench* addWorkbench(const QString& theName);
88 //! Redefinition of Events_Listener method
89 virtual void processEvent(const Events_Message* theMessage);
91 //! Returns an object which provides interface to Salome Module (LightApp_Module)
92 XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
94 //! Provides an object which provides interface to Salome Viewer
95 XGUI_SalomeViewer* salomeViewer() const;
97 //! Returns true if the application works as SALOME module
98 bool isSalomeMode() const { return mySalomeConnector != 0; }
100 //! Returns Object browser
101 XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
103 void salomeViewerSelectionChanged();
105 XGUI_ViewerProxy* viewer() const { return myViewerProxy; }
107 /// Returns the module connectory
108 /// \returns the instance of connector
109 XGUI_ModuleConnector* moduleConnector() const { return myModuleConnector; }
111 //! Returns icon name according to feature Id
112 static QString featureIcon(const std::string& theId);
114 //! Activates or deactivates a part
115 //! If PartPtr is Null pointer then PartSet will be activated
116 void activatePart(ResultPartPtr theFeature);
119 void deleteObjects(const QList<ObjectPtr>& theList);
121 //! Show the given features in 3d Viewer
122 void showObjects(const QList<ObjectPtr>& theList, bool isVisible);
124 ModuleBase_IModule* module() const { return myModule; }
127 void salomeViewerSelection();
128 void errorOccurred(const QString&);
131 void updateCommandStatus();
132 void updateCommandsOnViewSelection();
142 void showPropertyPanel();
143 void hidePropertyPanel();
144 void showObjectBrowser();
145 void hideObjectBrowser();
147 void onFeatureTriggered();
148 void changeCurrentDocument(ObjectPtr theObj);
150 void activateLastPart();
153 //Event-loop processing methods:
154 void addFeature(const Config_FeatureMessage*);
155 void connectWithOperation(ModuleBase_Operation* theOperation);
156 void saveDocument(QString theName);
158 void onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
159 void onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
160 void onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* theMsg);
161 void onObjectDeletedMsg(const ModelAPI_ObjectDeletedMessage* theMsg);
163 QList<QAction*> getModuleCommands() const;
165 void displayAllResults();
166 void displayDocumentResults(DocumentPtr theDoc);
167 void displayGroupResults(DocumentPtr theDoc, std::string theGroup);
170 /// SLOT, that is called after the operation is started. Update workshop state according to
171 /// the started operation, e.g. visualizes the property panel and connect to it.
172 void onOperationStarted();
173 /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
174 /// hides the property panel and udpate the command status.
175 /// \param theOpertion a stopped operation
176 void onOperationStopped(ModuleBase_Operation* theOperation);
178 void onContextMenuCommand(const QString& theId, bool isChecked);
180 void onWidgetValuesChanged();
182 void onStartWaiting();
187 void registerValidators() const;
190 ModuleBase_IModule* loadModule(const QString& theModule);
191 bool activateModule();
193 QDockWidget* createObjectBrowser(QWidget* theParent);
194 QDockWidget* createPropertyPanel(QWidget* theParent);
196 // Creates Dock widgets: Object browser and Property panel
197 void createDockWidgets();
199 XGUI_MainWindow* myMainWindow;
200 ModuleBase_IModule* myModule;
201 XGUI_ObjectsBrowser* myObjectBrowser;
202 XGUI_PropertyPanel* myPropertyPanel;
203 XGUI_SelectionMgr* mySelector;
204 XGUI_Displayer* myDisplayer;
205 XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
206 XGUI_ActionsMgr* myActionsMgr;
207 XGUI_SalomeConnector* mySalomeConnector;
208 XGUI_ErrorDialog* myErrorDlg;
209 XGUI_ViewerProxy* myViewerProxy;
210 XGUI_ContextMenuMgr* myContextMenuMgr;
211 XGUI_ModuleConnector* myModuleConnector;
213 QString myCurrentDir;
214 static QMap<QString, QString> myIcons;