SHAPER  9.12.0
XGUI_Workshop.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef XGUI_WORKSHOP_H
21 #define XGUI_WORKSHOP_H
22 
23 #include "XGUI.h"
24 
25 #include <ModelAPI_Document.h>
26 #include <ModelAPI_Feature.h>
27 #include <ModelAPI_ResultBody.h>
28 
29 #include <ModuleBase_ActionInfo.h>
30 #include <ModuleBase_ActionType.h>
31 #include <ModuleBase_Definitions.h>
32 
33 #include <SelectMgr_ListOfFilter.hxx>
34 
35 #include <QIcon>
36 #include <QObject>
37 #include <QKeySequence>
38 #include <QMap>
39 #include <QTemporaryDir>
40 
41 #ifndef HAVE_SALOME
42 class AppElements_Command;
43 class AppElements_MainWindow;
44 class AppElements_Workbench;
45 #endif
46 
48 
49 class XGUI_ActionsMgr;
52 class XGUI_Displayer;
53 class XGUI_ErrorDialog;
54 class XGUI_ErrorMgr;
55 class XGUI_FacesPanel;
56 class XGUI_MenuMgr;
59 class XGUI_OperationMgr;
60 class XGUI_PropertyPanel;
62 class XGUI_SalomeViewer;
64 class XGUI_SelectionMgr;
65 class XGUI_ViewerProxy;
68 
69 class ModuleBase_IModule;
70 class ModuleBase_IViewer;
72 
73 class QAction;
74 class QDockWidget;
75 class QMainWindow;
76 class QWidget;
77 
81 class XGUI_EXPORT XGUI_Workshop : public QObject
82 {
83 Q_OBJECT
84  public:
88  XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0);
89  virtual ~XGUI_Workshop();
90 
92  void startApplication();
93 
95  void activateModule();
96 
98  void deactivateModule();
99 
100 #ifndef HAVE_SALOME
102  AppElements_MainWindow* mainWindow() const { return myMainWindow; }
103 
105  AppElements_Workbench* addWorkbench(const QString& theName);
106 #endif
107 
109  XGUI_SelectionMgr* selector() const { return mySelector; }
110 
112  XGUI_SelectionActivate* selectionActivate() const { return mySelectionActivate; }
113 
115  XGUI_Displayer* displayer() const { return myDisplayer; }
116 
118  XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
119 
121  XGUI_ErrorMgr* errorMgr() const { return myErrorMgr; }
122 
124  XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; }
125 
127  XGUI_ActiveControlMgr* activeControlMgr() const { return myActiveControlMgr; }
128 
130  XGUI_MenuMgr* menuMgr() const { return myMenuMgr; }
131 
133  XGUI_PropertyPanel* propertyPanel() const { return myPropertyPanel; }
134 
136  XGUI_InspectionPanel* inspectionPanel() const { return myInspectionPanel; }
137 
139  XGUI_FacesPanel* facesPanel() const { return myFacesPanel; }
140 
142  XGUI_ContextMenuMgr* contextMenuMgr() const { return myContextMenuMgr; }
143 
145  XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
146 
148  ModuleBase_IViewer* salomeViewer() const;
149 
151  bool isSalomeMode() const { return mySalomeConnector != 0; }
152 
154  XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; }
155 
157  void salomeViewerSelectionChanged();
158 
160  XGUI_ViewerProxy* viewer() const { return myViewerProxy; }
161 
164  XGUI_ModuleConnector* moduleConnector() const { return myModuleConnector; }
165 
168  QMainWindow* desktop() const;
169 
174  virtual bool prepareForDisplay(const std::set<ObjectPtr>& theObjects) const;
175 
177  void deleteObjects();
178 
182  void cleanHistory();
183 
186  bool canMoveFeature();
187 
189  void moveObjects(const bool theSplit);
190 
192  void recoverFeature();
193 
197  bool canBeShaded(const ObjectPtr& theObject) const;
198 
202  bool canChangeProperty(const QString& theActionName) const;
203 
207  void changeColor(const QObjectPtrList& theObjects);
208 
212  void changeAutoColor(const QObjectPtrList& theObjects);
213 
217  void changeDeflection(const QObjectPtrList& theObjects);
218 
222  void changeTransparency(const QObjectPtrList& theObjects);
223 
226  void changeIsoLines(const QObjectPtrList& theObjects);
227 
229  void showObjects(const QObjectPtrList& theList, bool isVisible);
230 
232  void showOnlyObjects(const QObjectPtrList& theList);
233 
237  void setDisplayMode(const QObjectPtrList& theList, int theMode);
238 
240  void toggleEdgesDirection(const QObjectPtrList& theList);
241 
243  void toggleBringToFront(const QObjectPtrList& theList);
244 
247  void setViewerSelectionMode(int theMode);
248 
250  void activateObjectsSelection(const QObjectPtrList& theList);
251 
253  ModuleBase_IModule* module() const { return myModule; }
254 
256  QString currentDataFile() const { return myCurrentFile; }
257 
259  void setCurrentDataFile(const QString& theDir) { myCurrentFile = theDir; }
260 
264  void saveDocument(const QString& theName, std::list<std::string>& theFileNames);
265 
270  bool abortAllOperations();
271 
275  void operationStarted(ModuleBase_Operation* theOperation);
276 
280  bool deleteFeatures(const QObjectPtrList& theFeatures);
281 
286  void deactivateActiveObject(const ObjectPtr& theObject, const bool theUpdateViewer);
287 
290  bool isFeatureOfNested(const FeaturePtr& theFeature);
291 
294  void setStatusBarMessage(const QString& theMessage);
295 
296 #ifdef HAVE_SALOME
298  void synchronizeViewer();
299 
304  void synchronizeGroupInViewer(const DocumentPtr& theDoc,
305  bool theUpdateViewer);
306 
307  void synchronizeResultTree(const ResultBodyPtr& theRes, bool theUpdateViewer);
308 
309 #endif
313  void fillPropertyPanel(ModuleBase_Operation* theOperation);
314 
317  void connectToPropertyPanel(const bool isToConnect);
318 
320  QIntList viewerSelectionModes() const { return myViewerSelMode; }
321 
324  void highlightResults(const QObjectPtrList& theObjects);
325 
328  void highlightFeature(const QObjectPtrList& theObjects);
329 
332  const Config_DataModelReader* dataModelXMLReader() const { return myDataModelXMLReader; }
333 
336  static QString MOVE_TO_END_COMMAND;
340 
343  void openFile(const QString& theDirectory);
344 
345  void updateAutoComputeState();
346 
347  void deactivateCurrentSelector();
348 
350  void updateColorScaleVisibility();
351 
353  void updateGroupsText();
354 
355  void showHelpPage(const QString& thePage) const;
356 
357 signals:
360 
363 
366 
368  void updateUndoHistory(const QList<ActionInfo>&);
369 
371  void updateRedoHistory(const QList<ActionInfo>&);
372 
373  public slots:
375  void updateCommandStatus();
376 
378  void updateHistory();
379 
381  bool onSave();
382 
384  bool onSaveAs();
385 
387  void onUndo(int times = 1);
388 
390  void onRedo(int times = 1);
391 
394  void onWidgetStateChanged(int thePreviousState);
395 
398  void onValuesChanged();
399 
401  void onWidgetObjectUpdated();
402 
404  void showPanel(QDockWidget* theDockWidget);
405 
407  void hidePanel(QDockWidget* theDockWidget);
408 
410  void showObjectBrowser();
411 
413  void hideObjectBrowser();
414 
416  void closeDocument();
417 
419  void onOpen();
420 
422  void onNew();
423 
425  void onImportPart();
426 
428  void onImportShape();
429 
431  void onImportImage();
432 
434  void onExportPart();
435 
437  void onExportShape();
438 
439 #ifndef HAVE_SALOME
441  void onExit();
442 
444  void onPreferences();
445 #endif
446 
448  void onAutoApply();
449 
451  void onTrihedronVisibilityChanged(bool theState);
452 
454  void onTransparencyValueChanged();
455 
456  protected:
460  void setGrantedFeatures(ModuleBase_Operation* theOperation);
461 
462 private:
465  void displayDocumentResults(DocumentPtr theDoc);
466 
468  void displayGroupResults(DocumentPtr theDoc, std::string theGroup);
469 
471  void insertFeatureFolder();
472 
474  void insertToFolder(bool isBefore);
475 
477  void moveOutFolder(bool isBefore);
478 
479  private slots:
483  virtual void onOperationResumed(ModuleBase_Operation* theOperation);
484 
488  virtual void onOperationStopped(ModuleBase_Operation* theOperation);
489 
492  virtual void onOperationCommitted(ModuleBase_Operation* theOperation);
493 
496  void onOperationAborted(ModuleBase_Operation* theOperation);
497 
501  void onContextMenuCommand(const QString& theId, bool isChecked);
502 
504  void onStartWaiting();
505 
508  void onAcceptActionClicked();
509 
512  void onAcceptPlusActionClicked();
513 
516  void onPreviewActionClicked();
517 
519  void onHelpActionClicked() const;
520 
522  void onDockSizeChanged();
523 
524  private:
526  void initMenu();
527 
529  void registerValidators() const;
530 
533  ModuleBase_IModule* loadModule(const QString& theModule);
534 
536  bool createModule();
537 
540  QDockWidget* createObjectBrowser(QWidget* theParent);
541 
542  // Creates Dock widgets: Object browser and Property panel
543  void createDockWidgets();
544 
550  void addHistoryMenu(QObject* theObject, const char* theSignal, const char* theSlot);
551 
553  QList<ActionInfo> processHistoryList(const std::list<std::string>&) const;
554 
558  void processUndoRedo(const ModuleBase_ActionType theActionType, int theTimes);
559 
561  void clearTemporaryDir();
562 
565  void setNormalView(bool toInvert = false);
566 
567 private:
568 #ifndef HAVE_SALOME
569  AppElements_MainWindow* myMainWindow;
570 #endif
571 
572  ModuleBase_IModule* myModule;
573  XGUI_ErrorMgr* myErrorMgr;
574  XGUI_ObjectsBrowser* myObjectBrowser;
575  XGUI_PropertyPanel* myPropertyPanel;
576  XGUI_FacesPanel* myFacesPanel;
577  XGUI_SelectionMgr* mySelector;
578  XGUI_SelectionActivate* mySelectionActivate;
579  XGUI_Displayer* myDisplayer;
580  XGUI_OperationMgr* myOperationMgr;
581  XGUI_ActionsMgr* myActionsMgr;
582  XGUI_ActiveControlMgr* myActiveControlMgr;
583  XGUI_MenuMgr* myMenuMgr;
584  XGUI_SalomeConnector* mySalomeConnector;
585  XGUI_ErrorDialog* myErrorDlg;
586  XGUI_ViewerProxy* myViewerProxy;
587  XGUI_ContextMenuMgr* myContextMenuMgr;
588  XGUI_ModuleConnector* myModuleConnector;
589  XGUI_WorkshopListener* myEventsListener;
590  QString myCurrentFile;
591  QIntList myViewerSelMode;
592  Config_DataModelReader* myDataModelXMLReader;
593  XGUI_InspectionPanel* myInspectionPanel;
594  QTemporaryDir myTmpDir;
595 };
596 
597 #endif
Class that reads data model definition XML for further processing in the XGUI_DataModel.
Definition: Config_DataModelReader.h:36
Interface to a module.
Definition: ModuleBase_IModule.h:70
A Base object for definition of connector object to Salome Viewer.
Definition: ModuleBase_IViewer.h:47
Base class for all operations.
Definition: ModuleBase_Operation.h:53
class XGUI_ActionsMgrA class for management of actions (features) activation/deactivation
Definition: XGUI_ActionsMgr.h:45
Interface of providing only one active control for workshop.
Definition: XGUI_ActiveControlMgr.h:38
A class wihich provides managent of context menu.
Definition: XGUI_ContextMenuMgr.h:39
Displayer.
Definition: XGUI_Displayer.h:172
A class of dialog to show error message.
Definition: XGUI_ErrorDialog.h:34
Class of Errors manager object.
Definition: XGUI_ErrorMgr.h:42
A Hide Faces panel for making it possible to hide faces in the 3D view.
Definition: XGUI_FacesPanel.h:73
A class which represents an inspection panel: to show content of currently selected objects.
Definition: XGUI_InspectionPanel.h:55
A class for management of menu actions (features).
Definition: XGUI_MenuMgr.h:44
Implementation of IWorkshop interface which provides access to Workshop services at module level.
Definition: XGUI_ModuleConnector.h:35
Object browser window object.
Definition: XGUI_ObjectsBrowser.h:149
Operation manager.
Definition: XGUI_OperationMgr.h:49
Realization of Property panel object.
Definition: XGUI_PropertyPanel.h:61
An interface which provides a connection of XGUI functionality with functionality of SALOME module in...
Definition: XGUI_SalomeConnector.h:40
A class which implements activation/deactivate selection modes and using selection filters.
Definition: XGUI_SelectionActivate.h:41
Selection manager.
Definition: XGUI_SelectionMgr.h:46
Proxy class which repersents or AppElements_Viewer or Salome Viewer dependently on current launching ...
Definition: XGUI_ViewerProxy.h:49
Class which process the events from the event loop.
Definition: XGUI_WorkshopListener.h:47
Class which defines a configuration of the application (Workshop) and launches it.
Definition: XGUI_Workshop.h:82
const Config_DataModelReader * dataModelXMLReader() const
Returns Data Model XML reader which contains information about Data structure configuration.
Definition: XGUI_Workshop.h:332
void salomeViewerSelection()
Emitted when selection happens in Salome viewer.
AppElements_MainWindow * mainWindow() const
Returns main window (Desktop) of the application.
Definition: XGUI_Workshop.h:102
void updateRedoHistory(const QList< ActionInfo > &)
Signal to update Redo history list.
bool isSalomeMode() const
Returns true if the application works as SALOME module.
Definition: XGUI_Workshop.h:151
XGUI_ContextMenuMgr * contextMenuMgr() const
Returns context menu manager object.
Definition: XGUI_Workshop.h:142
XGUI_ObjectsBrowser * objectBrowser() const
Returns Object browser.
Definition: XGUI_Workshop.h:154
void applicationStarted()
the application is started
QString currentDataFile() const
Returns current file.
Definition: XGUI_Workshop.h:256
static QString MOVE_TO_END_SPLIT_COMMAND
A constant string used for "Move to end and split" command definition It is used for specific process...
Definition: XGUI_Workshop.h:339
void setCurrentDataFile(const QString &theDir)
Returns current file.
Definition: XGUI_Workshop.h:259
XGUI_SelectionMgr * selector() const
Returns selection manager object.
Definition: XGUI_Workshop.h:109
XGUI_InspectionPanel * inspectionPanel() const
Returns property panel widget.
Definition: XGUI_Workshop.h:136
static QString MOVE_TO_END_COMMAND
A constant string used for "Move to end" command definition It is used for specific processing of Und...
Definition: XGUI_Workshop.h:336
XGUI_ViewerProxy * viewer() const
Returns viewer which unifies access as to Salome viewer as to standalone viewer.
Definition: XGUI_Workshop.h:160
XGUI_ActiveControlMgr * activeControlMgr() const
Returns an active control manager.
Definition: XGUI_Workshop.h:127
XGUI_ModuleConnector * moduleConnector() const
Returns the module connector.
Definition: XGUI_Workshop.h:164
XGUI_ErrorMgr * errorMgr() const
Returns error manager.
Definition: XGUI_Workshop.h:121
QIntList viewerSelectionModes() const
Returns defailt selection mode in 3d viewer.
Definition: XGUI_Workshop.h:320
XGUI_OperationMgr * operationMgr() const
Returns operation manager.
Definition: XGUI_Workshop.h:118
XGUI_SelectionActivate * selectionActivate() const
Returns selection activating object.
Definition: XGUI_Workshop.h:112
XGUI_SalomeConnector * salomeConnector() const
Returns an object which provides interface to Salome Module (LightApp_Module)
Definition: XGUI_Workshop.h:145
XGUI_MenuMgr * menuMgr() const
Returns an actions manager.
Definition: XGUI_Workshop.h:130
void updateUndoHistory(const QList< ActionInfo > &)
Signal to update Undo history list.
XGUI_ActionsMgr * actionsMgr() const
Returns an actions manager.
Definition: XGUI_Workshop.h:124
XGUI_PropertyPanel * propertyPanel() const
Returns property panel widget.
Definition: XGUI_Workshop.h:133
XGUI_FacesPanel * facesPanel() const
Returns panel for hide object faces.
Definition: XGUI_Workshop.h:139
XGUI_Displayer * displayer() const
Returns displayer.
Definition: XGUI_Workshop.h:115
ModuleBase_IModule * module() const
Returns current module.
Definition: XGUI_Workshop.h:253
void commandStatusUpdated()
the signal about the workshop actions states are updated.