SHAPER  9.12.0
SHAPERGUI.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 SHAPERGUI_H
21 #define SHAPERGUI_H
22 
23 #include "SHAPER_SHAPERGUI.h"
24 #include "SHAPERGUI_SalomeViewer.h"
25 
26 #include <LightApp_Module.h>
27 #include <XGUI_SalomeConnector.h>
28 
29 #include <ModuleBase_ActionInfo.h>
30 
31 #include <QList>
32 #include <QMap>
33 
34 class XGUI_Workshop;
36 class OCCViewer_Viewer;
37 class CAM_Study;
38 class QtxInfoPanel;
40 
46 class SHAPERGUI_EXPORT SHAPERGUI : public LightApp_Module, public XGUI_SalomeConnector
47 {
48 Q_OBJECT
49  public:
50  SHAPERGUI();
51  virtual ~SHAPERGUI();
52 
53  //----- LightAPP_Module interface ---------------
54 
57  virtual void initialize(CAM_Application* theApp);
58 
60  virtual void windows(QMap<int, int>& theWndMap) const;
61 
63  virtual void viewManagers(QStringList& theList) const;
64 
66  virtual void selectionChanged();
67 
68  //--- XGUI connector interface -----
69 
70  virtual QAction* addFeature(const QString& theWBName, const QString& theTBName,
71  const QString& theId, const QString& theTitle,
72  const QString& theTip, const QIcon& theIcon,
73  const QKeySequence& theKeys/* = QKeySequence()*/,
74  bool isCheckable /*= false*/, const bool isAddSeparator/* = false*/,
75  const QString& theStatusTip);
76 
78  virtual QAction* addFeature(const QString& theWBName,
79  const ActionInfo& theInfo, const bool isAddSeparator);
80 
85  virtual QAction* addFeatureOfNested(const QString& theWBName,
86  const ActionInfo& theInfo,
87  const QList<QAction*>& theNestedActions);
88 
93  virtual bool isFeatureOfNested(const QAction* theAction);
94 
95  virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
96  const QString& theTip, const QIcon& theIcon,
97  const QKeySequence& theKeys, bool isCheckable,
98  const char* theMenuSourceText, const QString& theSubMenu = QString(),
99  const int theMenuPosition = 10,
100  const int theSuibMenuPosition = -1) Standard_OVERRIDE;
101 
102  virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
103  const int theMenuPosition = 10);
104 
108  virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle );
109 
111  virtual void createFeatureActions();
112 
113  virtual QMainWindow* desktop() const;
114 
118  virtual void setFeatureInfo(const QString& theFeatureId,
119  const std::shared_ptr<Config_FeatureMessage>& theMessage);
120 
124  virtual std::shared_ptr<Config_FeatureMessage> featureInfo(const QString& theFeatureId);
125 
127  virtual ModuleBase_IViewer* viewer() const
128  {
129  return myProxyViewer;
130  }
131 
133  virtual QList<QAction*> commandList() const;
134 
139  virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
140 
142  virtual void createPreferences();
143 
145  virtual void preferencesChanged(const QString& theSection, const QString& theParam);
146 
150  // If 0, default value is used, it is 3000
151  virtual void putInfo(const QString& theInfo, const int theMSecs = 0);
152 
154  XGUI_Workshop* workshop() const { return myWorkshop; }
155 
157  void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
158 
159  virtual void updateModuleVisibilityState();
160 
162  QIntList shaperActions() const { return myActionsList; }
163 
165  QMap<QString, QIntList> shaperToolbars() const { return myToolbars; }
166 
168  QIntList getFreeCommands() const;
169 
171  QMap<QString, QIntList> defaultToolbars() const
172  { return (myDefaultToolbars.size() == 0)? myToolbars : myDefaultToolbars; }
173 
174  void resetToolbars();
175 
176  void publishToStudy();
177 
178  virtual void updateInfoPanel();
179 
180  public slots:
184  //virtual void connectToStudy(CAM_Study* theStudy);
185 
188  virtual bool activateModule(SUIT_Study* theStudy);
189 
192  virtual bool deactivateModule(SUIT_Study* theStudy);
193 
194  protected slots:
197  virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
198 
201  virtual void onViewManagerRemoved(SUIT_ViewManager* theMgr);
202 
204  void onDefaultPreferences();
205 
207  void onScriptLoaded();
208 
210  void onSaveDocByShaper();
211 
213  void onSaveAsDocByShaper();
214 
216  void onUpdateCommandStatus();
217 
219  virtual void logShaperGUIEvent();
220 
221  protected:
223  CAM_DataModel* createDataModel();
224 
226  virtual QtxPopupMgr* popupMgr();
227 
229  virtual bool abortAllOperations();
230 
231 private slots:
232  void onWhatIs(bool isToggled);
233 
234  void onEditToolbars();
235 
236  void onOperationCommitted(ModuleBase_Operation*);
237  void onOperationAborted(ModuleBase_Operation*);
238 
239  private:
242  SHAPERGUI_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
243 
244  void registerCommandToolbar(const QString& theToolName, int theCommandId);
245 
246  int getNextCommandId() const;
247 
248  // Update current toolbars
249  void updateToolbars(const QMap<QString, QIntList>& theNewToolbars);
250 
251  void saveToolbarsConfig();
252  void loadToolbarsConfig();
253 
255  void fillPartSetInfoPanel(QtxInfoPanel* theInfoPanel);
256 
258  void fillPartInfoPanel(QtxInfoPanel* theInfoPanel);
259 
261  void fillSketcherInfoPanel(QtxInfoPanel* theInfoPanel);
262 
264  void addActionsToInfoGroup(QtxInfoPanel* theInfoPanel, const QString& theGroup, const QSet<QString>& theActions);
265 
266  void hideInternalWindows();
267 
269  QStringList myNestedActionsList;
270 
272  XGUI_Workshop* myWorkshop;
273 
275  SHAPERGUI_OCCSelector* mySelector;
276 
278  SHAPERGUI_SalomeViewer* myProxyViewer;
279 
281  QMap<QString, std::shared_ptr<Config_FeatureMessage> > myFeaturesInfo;
282 
284  bool myIsOpened;
285 
286  // the next parameter should be restored after this module deactivation
288  bool myIsEditEnabled;
289 
291  QtxPopupMgr* myPopupMgr;
292 
293  QAction* myWhatIsAction;
294 
295  bool myIsInspectionVisible;
296  QDockWidget* myInspectionPanel;
297  bool myIsFacesPanelVisible;
298 
300  QIntList myActionsList;
301  QMap<QString, QIntList> myToolbars;
302  QMap<QString, QIntList> myDefaultToolbars;
303  bool myIsToolbarsModified;
304 
305  std::vector<int> myOldSelectionColor;
306  Handle(Graphic3d_AspectMarker3d) myHighlightPointAspect;
307 
308  double myAxisArrowRate;
309 };
310 
311 #endif
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
Redefinition of standard OCC selector in order to adapt it to SHAPER needs.
Definition: SHAPERGUI_OCCSelector.h:32
A class for providing access of SHAPERGUI functionality to SALOME viewer functionality.
Definition: SHAPERGUI_SalomeViewer.h:82
An implementation of SALOME connector class for implementation of XGUI functionality as a module of S...
Definition: SHAPERGUI.h:47
QIntList shaperActions() const
Returns list of the module commands.
Definition: SHAPERGUI.h:162
virtual ModuleBase_IViewer * viewer() const
Returns interface to Salome viewer.
Definition: SHAPERGUI.h:127
void setIsOpened(bool theOpened)
Set flag about opened document state.
Definition: SHAPERGUI.h:157
QMap< QString, QIntList > shaperToolbars() const
Returns structure of tool bars.
Definition: SHAPERGUI.h:165
QMap< QString, QIntList > defaultToolbars() const
Returns structure of default tool bars.
Definition: SHAPERGUI.h:171
XGUI_Workshop * workshop() const
Definition: SHAPERGUI.h:154
An interface which provides a connection of XGUI functionality with functionality of SALOME module in...
Definition: XGUI_SalomeConnector.h:40
virtual void setFeatureInfo(const QString &theFeatureId, const std::shared_ptr< Config_FeatureMessage > &theMessage)=0
Stores XML information for the feature kind.
virtual QAction * addFeatureOfNested(const QString &theWBName, const ActionInfo &theInfo, const QList< QAction * > &theNestedActions)=0
Creates a feature (command) in SALOME desktop.
virtual void addDesktopMenuSeparator(const char *theMenuSourceText, const int theMenuPosition=10)=0
Insert separator into Edit menu of SALOME desktop.
virtual bool isFeatureOfNested(const QAction *theAction)=0
Returns true if the feature action is a nested action, in other words, it is created by addFeatureOfN...
virtual QAction * addFeature(const QString &theWBName, const QString &theTBName, const QString &theId, const QString &theTitle, const QString &theTip, const QIcon &theIcon, const QKeySequence &theKeys, bool isCheckable, const bool isAddSeparator, const QString &theStatusTip)=0
Creates a feature (command) in SALOME desktop.
virtual void createFeatureActions()=0
Creates menu/tool bar actions for loaded features stored in the menu manager.
virtual std::shared_ptr< Config_FeatureMessage > featureInfo(const QString &theFeatureId)=0
Returns XML information for the feature kind.
virtual void putInfo(const QString &theInfo, const int theMSecs=0)=0
Shows the given text in status bar as a permanent text \theInfo a string value \theMsecs interval of ...
virtual QAction * addDesktopCommand(const QString &theId, const QString &theTitle, const QString &theTip, const QIcon &theIcon, const QKeySequence &theKeys, bool isCheckable, const char *theMenuSourceText, const QString &theSubMenu=QString(), const int theMenuPosition=10, const int theSuibMenuPosition=-1)=0
Creates a command in Edit menu of SALOME desktop.
virtual void createPreferences()=0
Create preferences.
virtual QList< QAction * > commandList() const =0
Returns list of defined actions (just by SHAPER module)
virtual bool addActionInToolbar(QAction *theAction, const QString &theToolBarTitle)=0
Add an action into tool bar.
virtual QMainWindow * desktop() const =0
Returns desktop window of SALOME.
Class which defines a configuration of the application (Workshop) and launches it.
Definition: XGUI_Workshop.h:82
Definition: ModuleBase_ActionInfo.h:37