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;
34 class ModuleBase_IViewer;
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
74 XGUI_Displayer* displayer() const
79 //! ! Returns operation manager.
80 XGUI_OperationMgr* operationMgr() const
82 return myOperationMgr;
85 //! ! Returns an actions manager
86 XGUI_ActionsMgr* actionsMgr() const
92 //! Returns property panel widget
93 XGUI_PropertyPanel* propertyPanel() const
95 return myPropertyPanel;
98 //! Returns context menu manager object
99 XGUI_ContextMenuMgr* contextMenuMgr() const
101 return myContextMenuMgr;
104 //! Creates and adds a new workbench (menu group) with the given name and returns it
105 XGUI_Workbench* addWorkbench(const QString& theName);
107 //! Redefinition of Events_Listener method
108 virtual void processEvent(const boost::shared_ptr<Events_Message>& theMessage);
110 //! Returns an object which provides interface to Salome Module (LightApp_Module)
111 XGUI_SalomeConnector* salomeConnector() const
113 return mySalomeConnector;
116 //! Provides an object which provides interface to Salome Viewer
117 ModuleBase_IViewer* salomeViewer() const;
119 //! Returns true if the application works as SALOME module
120 bool isSalomeMode() const
122 return mySalomeConnector != 0;
125 //! Returns Object browser
126 XGUI_ObjectsBrowser* objectBrowser() const
128 return myObjectBrowser;
131 void salomeViewerSelectionChanged();
133 XGUI_ViewerProxy* viewer() const
135 return myViewerProxy;
138 /// Returns the module connectory
139 /// \returns the instance of connector
140 XGUI_ModuleConnector* moduleConnector() const
142 return myModuleConnector;
145 //! Returns icon name according to feature Id
146 static QString featureIcon(const std::string& theId);
148 //! Activates or deactivates a part
149 //! If PartPtr is Null pointer then PartSet will be activated
150 void activatePart(ResultPartPtr theFeature);
153 void deleteObjects(const QList<ObjectPtr>& theList);
155 //! Show the given features in 3d Viewer
156 void showObjects(const QList<ObjectPtr>& theList, bool isVisible);
158 //! Show the given features in 3d Viewer
159 void showOnlyObjects(const QList<ObjectPtr>& theList);
161 void setDisplayMode(const QList<ObjectPtr>& theList, int theMode);
163 ModuleBase_IModule* module() const
168 /// Returns current directory whic contains data files
169 QString currentDataDir() const { return myCurrentDir; }
171 /// Returns current directory whic contains data files
172 void setCurrentDataDir(const QString& theDir) { myCurrentDir = theDir; }
175 * Save the current document into a directory
176 * \param theName - path to the directory
177 * \param theFileNames - returned file names created in this directory
179 void saveDocument(const QString& theName, std::list<std::string>& theFileNames);
182 * If there is an active (uncommited) operation shows a prompt to abort it
183 * and performs abortion if user agreed. Returns true if
184 * - operation aborted successfully
185 * - there is no active operation
187 bool isActiveOperationAborted();
190 void salomeViewerSelection();
191 void errorOccurred(const QString&);
194 void updateCommandStatus();
195 void updateCommandsOnViewSelection();
205 void onPreferences();
207 void showPropertyPanel();
208 void hidePropertyPanel();
209 void showObjectBrowser();
210 void hideObjectBrowser();
212 void onFeatureTriggered();
213 void changeCurrentDocument(ObjectPtr theObj);
215 void activateLastPart();
218 bool event(QEvent * theEvent);
219 //Event-loop processing methods:
220 void addFeature(const boost::shared_ptr<Config_FeatureMessage>&);
221 void connectWithOperation(ModuleBase_Operation* theOperation);
223 void onFeatureUpdatedMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
224 void onFeatureCreatedMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
225 void onFeatureRedisplayMsg(const boost::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg);
226 void onObjectDeletedMsg(const boost::shared_ptr<ModelAPI_ObjectDeletedMessage>& theMsg);
228 void validateOperation(const QString& theOperationId);
230 QList<QAction*> getModuleCommands() const;
232 void displayAllResults();
233 void displayDocumentResults(DocumentPtr theDoc);
234 void displayGroupResults(DocumentPtr theDoc, std::string theGroup);
237 /// SLOT, that is called after the operation is started. Update workshop state according to
238 /// the started operation, e.g. visualizes the property panel and connect to it.
239 void onOperationStarted();
240 /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
241 /// hides the property panel and udpate the command status.
242 /// \param theOpertion a stopped operation
243 void onOperationStopped(ModuleBase_Operation* theOperation);
245 void onContextMenuCommand(const QString& theId, bool isChecked);
247 void onWidgetValuesChanged();
249 void onStartWaiting();
254 void registerValidators() const;
256 ModuleBase_IModule* loadModule(const QString& theModule);
257 bool activateModule();
259 QDockWidget* createObjectBrowser(QWidget* theParent);
260 QDockWidget* createPropertyPanel(QWidget* theParent);
262 // Creates Dock widgets: Object browser and Property panel
263 void createDockWidgets();
265 XGUI_MainWindow* myMainWindow;
266 ModuleBase_IModule* myModule;
267 XGUI_ObjectsBrowser* myObjectBrowser;
268 XGUI_PropertyPanel* myPropertyPanel;
269 XGUI_SelectionMgr* mySelector;
270 XGUI_Displayer* myDisplayer;
271 XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
272 XGUI_ActionsMgr* myActionsMgr;
273 XGUI_SalomeConnector* mySalomeConnector;
274 XGUI_ErrorDialog* myErrorDlg;
275 XGUI_ViewerProxy* myViewerProxy;
276 XGUI_ContextMenuMgr* myContextMenuMgr;
277 XGUI_ModuleConnector* myModuleConnector;
279 QString myCurrentDir;
280 static QMap<QString, QString> myIcons;
284 // Flag to check that part document is in process of activating
285 bool myPartActivating;