SHAPER 9.16.0
SHAPERGUI.h
1// Copyright (C) 2014-2026 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#include <future>
34
35class XGUI_Workshop;
37class OCCViewer_Viewer;
38class CAM_Study;
39class QtxInfoPanel;
41
47class SHAPERGUI_EXPORT SHAPERGUI : public LightApp_Module, public XGUI_SalomeConnector
48{
49Q_OBJECT
50 public:
51 SHAPERGUI();
52 virtual ~SHAPERGUI();
53
54 //----- LightAPP_Module interface ---------------
55
58 virtual void initialize(CAM_Application* theApp);
59
61 virtual void windows(QMap<int, int>& theWndMap) const;
62
64 virtual void viewManagers(QStringList& theList) const;
65
67 virtual void selectionChanged();
68
69 //--- XGUI connector interface -----
70
71 virtual QAction* addFeature(
72 const QString& theWorkBenchID,
73 const QString& theWorkBenchName,
74 const QString& theToolBarName,
75 const QString& theActionIdLastToken,
76 const QString& theActionTitle,
77 const QString& theActionToolTip,
78 const QString& theActionStatusTip,
79 const QIcon& theActionIcon,
80 const QKeySequence& theKS,
81 const bool theIsCheckable,
82 const bool theAddSeparator
83 );
84
85 virtual QAction* addFeature(const QString& theWBName, const QString& theTBName,
86 const QString& theIdLastToken, const QString& theTitle,
87 const QString& theTip, const QIcon& theIcon,
88 const QKeySequence& theKeys/* = QKeySequence()*/,
89 const bool theIsCheckable /* = false*/, const bool theAddSeparator/* = false*/,
90 const QString& theStatusTip /* = ""*/);
91
93 virtual QAction* addFeature(const QString& theWBName, const ActionInfo& theInfo, const bool theAddSeparator);
94
99 virtual QAction* addFeatureOfNested(const QString& theWBName,
100 const ActionInfo& theInfo,
101 const QList<QAction*>& theNestedActions);
102
107 virtual bool isFeatureOfNested(const QAction* theAction);
108
109 virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
110 const QString& theTip, const QIcon& theIcon,
111 const QKeySequence& theKeys, bool isCheckable,
112 const char* theMenuSourceText, const QString& theSubMenu = QString(),
113 const int theMenuPosition = 10,
114 const int theSuibMenuPosition = -1) Standard_OVERRIDE;
115
116 virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
117 const int theMenuPosition = 10);
118
122 virtual bool addActionInToolbar( QAction* theAction, const QString& theToolBarTitle );
123
125 virtual void createFeatureActions();
126
127 virtual QMainWindow* desktop() const;
128
132 virtual void setFeatureInfo(const QString& theFeatureId,
133 const std::shared_ptr<Config_FeatureMessage>& theMessage);
134
138 virtual std::shared_ptr<Config_FeatureMessage> featureInfo(const QString& theFeatureId);
139
141 virtual ModuleBase_IViewer* viewer() const
142 {
143 return myProxyViewer;
144 }
145
147 virtual QList<QAction*> commandList() const;
148
153 virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle);
154
156 virtual void createPreferences();
157
159 virtual void preferencesChanged(const QString& theSection, const QString& theParam);
160
164 // If 0, default value is used, it is 3000
165 virtual void putInfo(const QString& theInfo, const int theMSecs = 0);
166
168 XGUI_Workshop* workshop() const { return myWorkshop; }
169
171 void setIsOpened(bool theOpened) { myIsOpened = theOpened; }
172
173 virtual void updateModuleVisibilityState();
174
176 QIntList shaperActions() const { return myActionsList; }
177
179 QMap<QString, QIntList> shaperToolbars() const { return myToolbars; }
180
182 QIntList getFreeCommands() const;
183
185 QMap<QString, QIntList> defaultToolbars() const
186 { return (myDefaultToolbars.size() == 0)? myToolbars : myDefaultToolbars; }
187
188 void resetToolbars();
189
190 void publishToStudy();
191
192 virtual void updateInfoPanel();
193
194signals:
195 void backupDone(QString aName, int aResult);
196
197public slots:
201 //virtual void connectToStudy(CAM_Study* theStudy);
202
205 virtual bool activateModule(SUIT_Study* theStudy);
206
209 virtual bool deactivateModule(SUIT_Study* theStudy);
210
211 protected slots:
214 virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
215
218 virtual void onViewManagerRemoved(SUIT_ViewManager* theMgr);
219
221 void onDefaultPreferences();
222
224 void onScriptLoaded();
225
227 void onSaveDocByShaper();
228
230 void onSaveAsDocByShaper();
231
233 void onBackupDoc();
234
236 void onBackupDone(QString aName, int aResult);
237
239 void onUpdateCommandStatus();
240
242 virtual void logShaperGUIEvent();
243
244 protected:
246 CAM_DataModel* createDataModel();
247
249 virtual QtxPopupMgr* popupMgr();
250
252 virtual bool abortAllOperations();
253
255 int backupDoc();
256
257private slots:
258 void onWhatIs(bool isToggled);
259
260 void onEditToolbars();
261
262 void onOperationCommitted(ModuleBase_Operation*);
263 void onOperationAborted(ModuleBase_Operation*);
264
265 private:
268 SHAPERGUI_OCCSelector* createSelector(SUIT_ViewManager* theMgr);
269
270 void registerCommandToolbar(const QString& theToolName, int theCommandId);
271
272 int getNextCommandId() const;
273
274 // Update current toolbars
275 void updateToolbars(const QMap<QString, QIntList>& theNewToolbars);
276
277 void saveToolbarsConfig();
278 void loadToolbarsConfig();
279
281 void fillPartSetInfoPanel(QtxInfoPanel* theInfoPanel);
282
284 void fillPartInfoPanel(QtxInfoPanel* theInfoPanel);
285
287 void fillSketcherInfoPanel(QtxInfoPanel* theInfoPanel);
288
290 void addActionsToInfoGroup(QtxInfoPanel* theInfoPanel, const QString& theGroup, const QSet<QString>& theActions);
291
292 void hideInternalWindows();
293
294 // Check, whether we are waiting for a backup => if yes, do it now
295 void checkForWaitingBackup();
296
298 QStringList myNestedActionsList;
299
301 XGUI_Workshop* myWorkshop;
302
304 SHAPERGUI_OCCSelector* mySelector;
305
307 SHAPERGUI_SalomeViewer* myProxyViewer;
308
310 QMap<QString, std::shared_ptr<Config_FeatureMessage> > myFeaturesInfo;
311
313 bool myIsOpened;
314
315 // the next parameter should be restored after this module deactivation
317 bool myIsEditEnabled;
318
320 QtxPopupMgr* myPopupMgr;
321
322 QAction* myWhatIsAction;
323
324 bool myIsInspectionVisible;
325 QDockWidget* myInspectionPanel;
326 bool myIsFacesPanelVisible;
327
329 QIntList myActionsList;
330 QMap<QString, QIntList> myToolbars;
331 QMap<QString, QIntList> myDefaultToolbars;
332 bool myIsToolbarsModified;
333
334 std::vector<int> myOldSelectionColor;
335 Handle(Graphic3d_AspectMarker3d) myHighlightPointAspect;
336
337 double myAxisArrowRate;
338
340 QTimer* myBackupTimer; // The timer which triggers the automatic backup
341 std::future<int> myBackupResult; // The result (success/failure) of the backup
342 QString myBackupError; // The backup error message in case of a failure
343 QString myBackupFolder; // The root folder where the backups are saved
344 QString myLastBackupFolder; // The folder of the last backup
345};
346
347#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:48
QIntList shaperActions() const
Returns list of the module commands.
Definition: SHAPERGUI.h:176
XGUI_Workshop * workshop() const
Definition: SHAPERGUI.h:168
QMap< QString, QIntList > defaultToolbars() const
Returns structure of default tool bars.
Definition: SHAPERGUI.h:185
void setIsOpened(bool theOpened)
Set flag about opened document state.
Definition: SHAPERGUI.h:171
QMap< QString, QIntList > shaperToolbars() const
Returns structure of tool bars.
Definition: SHAPERGUI.h:179
virtual ModuleBase_IViewer * viewer() const
Returns interface to Salome viewer.
Definition: SHAPERGUI.h:141
An interface which provides a connection of XGUI functionality with functionality of SALOME module in...
Definition: XGUI_SalomeConnector.h:40
virtual QList< QAction * > commandList() const =0
Returns list of defined actions (just by SHAPER module)
virtual void setFeatureInfo(const QString &theFeatureId, const std::shared_ptr< Config_FeatureMessage > &theMessage)=0
Stores XML information for the feature kind.
virtual std::shared_ptr< Config_FeatureMessage > featureInfo(const QString &theFeatureId)=0
Returns XML information for the feature kind.
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 addDesktopMenuSeparator(const char *theMenuSourceText, const int theMenuPosition=10)=0
Insert separator into Edit menu of SALOME desktop.
virtual QMainWindow * desktop() const =0
Returns desktop window of SALOME.
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 void createFeatureActions()=0
Creates menu/tool bar actions for loaded features stored in the menu manager.
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 void createPreferences()=0
Create preferences.
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 bool addActionInToolbar(QAction *theAction, const QString &theToolBarTitle)=0
Add an action into tool bar.
virtual QAction * addFeatureOfNested(const QString &theWBName, const ActionInfo &theInfo, const QList< QAction * > &theNestedActions)=0
Creates a feature (command) in SALOME desktop.
Class which defines a configuration of the application (Workshop) and launches it.
Definition: XGUI_Workshop.h:83
Definition: ModuleBase_ActionInfo.h:37