SHAPER  9.15.0
ModuleBase_IModule.h
1 // Copyright (C) 2014-2025 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 ModuleBase_IModule_H
21 #define ModuleBase_IModule_H
22 
23 #include "ModuleBase.h"
24 #include "ModuleBase_IWorkshop.h"
25 #include <ModuleBase_SelectionFilterType.h>
26 
27 #include <ModelAPI_Feature.h>
28 #include <ModelAPI_Attribute.h>
29 
30 #include <GeomAPI_Shape.h>
31 #include <GeomAPI_ICustomPrs.h>
32 
33 #include <SelectMgr_ListOfFilter.hxx>
34 
35 #include <QString>
36 #include <QObject>
37 #include <QMap>
38 #include <QList>
39 
40 #include <string>
41 #include <vector>
42 #include <map>
43 
44 #ifdef _MSC_VER
45 #pragma warning(disable: 4100)
46 #endif
47 
48 class QAction;
49 class QMouseEvent;
50 class QKeyEvent;
51 class QMenu;
52 class Config_WidgetAPI;
53 
59 
60 class ModelAPI_Result;
61 class Events_Message;
62 
64 
69 class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
70 {
71  Q_OBJECT
72  public:
75  CustomizeArguments = 0,
77  CustomizeHighlightedObjects
78  };
79 
83 
84  virtual ~ModuleBase_IModule();
85 
87  virtual void storeSelection() {}
88 
90  virtual void restoreSelection() {}
91 
93  virtual void createFeatures();
94 
96  virtual void actionCreated(QAction*);
97 
100  virtual void editFeature(FeaturePtr theFeature);
101 
104  virtual bool canCommitOperation() const { return true; }
105 
110  virtual void launchOperation(const QString& theCmdId,
111  const bool& isStartAfterCommitOnly);
112 
115  virtual void launchModal(const QString& theCmdId);
116 
119  virtual void operationStarted(ModuleBase_Operation* theOperation) {}
120 
124  virtual void operationResumed(ModuleBase_Operation* theOperation);
125 
127  virtual void operationStopped(ModuleBase_Operation* theOperation) {}
128 
130  virtual void operationCommitted(ModuleBase_Operation* theOperation) {}
131 
133  virtual void operationAborted(ModuleBase_Operation* theOperation) {}
134 
137 
143  virtual bool addViewerMenu(const QMap<QString, QAction*>& theStdActions,
144  QWidget* theParent,
145  QMap<int, QAction*>& theMenuActions) const
146  { return false; }
147 
150  virtual void addObjectBrowserMenu(QMenu* theMenu) const {};
151 
154  virtual void addConstraintBrowserMenu(QMenu* theMenu) const {};
155 
161  virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
162  QWidget* theParent,
163  Config_WidgetAPI* theWidgetApi)
164  {
165  return 0;
166  }
167 
169  virtual ModuleBase_ModelWidget* activeWidget() const = 0;
170 
172  ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
173 
176  virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}
177 
184  virtual bool createWidgets(const FeaturePtr& theFeature, const QString& theXmlRepr,
185  QList<ModuleBase_ModelWidget*>& theWidgets) const { return false; }
186 
188  virtual bool canUndo() const;
189 
191  virtual bool canRedo() const;
192 
197  virtual bool canApplyAction(const ObjectPtr& theObject, const QString& theActionId) const = 0;
198 
201  //virtual bool canCommitOperation() const;
202 
205  virtual bool canEraseObject(const ObjectPtr& theObject) const;
206 
209  virtual bool canDisplayObject(const ObjectPtr& theObject) const;
210 
216  virtual bool canUsePreselection(const QString& thePreviousOperationKind,
217  const QString& theStartedOperationKind);
218 
221  //virtual void processHiddenObject(const std::list<ObjectPtr>& theObjects) {};
222 
226  virtual bool canActivateSelection(const ObjectPtr& theObject) const;
227 
230  virtual bool deleteObjects() { return false; };
231 
233  virtual void closeDocument() = 0;
234 
236  virtual void clearViewer() = 0;
237 
240  virtual void activeSelectionModes(QIntList& theModes) {}
241 
245  virtual void moduleSelectionModes(int theModesType, QIntList& theModes) = 0;
246 
250  virtual void moduleSelectionFilters(const QIntList& theFilterTypes,
251  SelectMgr_ListOfFilter& theSelectionFilters) = 0;
252 
255  virtual QIntList selectionFilters();
256 
260  virtual Handle(SelectMgr_Filter) selectionFilter(const int theType);
261 
265  void registerSelectionFilter(const ModuleBase_SelectionFilterType theFilterType,
266  const Handle(SelectMgr_Filter)& theFilter);
267 
271  virtual bool isCustomPrsActivated(const ModuleBase_CustomizeFlag& theFlag) const
272  { return false; };
273 
278  virtual void activateCustomPrs(const FeaturePtr& theFeature,
279  const ModuleBase_CustomizeFlag& theFlag,
280  const bool theUpdateViewer) {}
281 
285  virtual void deactivateCustomPrs(const ModuleBase_CustomizeFlag& theFlag,
286  const bool theUpdateViewer) {}
287 
289  //virtual bool customisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
290  // AISObjectPtr thePrs,
291  // GeomCustomPrsPtr theCustomPrs) { return false; };
292 
294  //virtual bool afterCustomisePresentation(std::shared_ptr<ModelAPI_Result> theResult,
295  // AISObjectPtr thePrs,
296  // GeomCustomPrsPtr theCustomPrs) { return false; };
297 
306  virtual bool customizeFeature(ObjectPtr theObject, const ModuleBase_CustomizeFlag& theFlag,
307  const bool theUpdateViewer) {
308  return false;
309  }
310 
314 
316  virtual void enableCustomModes() {}
317 
320  virtual void customizeObjectBrowser(QWidget* theObjectBrowser) {}
321 
324  virtual ModuleBase_Operation* createOperation(const std::string& theCmdId);
325 
330  virtual AISObjectPtr createPresentation(const ObjectPtr& theResult);
331 
335  virtual void customizePresentation(const ObjectPtr& theObject, const AISObjectPtr& thePrs) const
336  {}
337 
339  virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const = 0;
340 
344  virtual bool canBeShaded(Handle(AIS_InteractiveObject) theAIS) const;
345 
348  virtual void updateObjectBrowserMenu(const QMap<QString, QAction*>& theStdActions) {}
349 
352  virtual void updateViewerMenu(const QMap<QString, QAction*>& theStdActions) {}
353 
357  virtual bool isActionEnableStateFixed(const int theActionId) const { return false; }
358 
362  virtual QString getFeatureError(const FeaturePtr& theFeature);
363 
365  virtual void grantedOperationIds(ModuleBase_Operation* theOperation, QStringList& theIds) const;
366 
370  virtual void connectToPropertyPanel(ModuleBase_ModelWidget* theWidget, const bool isToConnect) {};
371 
374  virtual void widgetStateChanged(int thePreviousState) {};
375 
378  virtual bool processEnter(const std::string& thePreviousAttributeID) { return false; };
379 
382  virtual void beforeOperationStopped(ModuleBase_Operation* theOperation) {};
383 
387  virtual GeomShapePtr findShape(const AttributePtr& theAttribute) = 0;
388 
393  virtual AttributePtr findAttribute(const ObjectPtr& theObject,
394  const GeomShapePtr& theGeomShape) = 0;
395 
397  virtual std::shared_ptr<Events_Message> reentrantMessage() = 0;
398 
401  virtual void setReentrantPreSelection(const std::shared_ptr<Events_Message>& theMessage) = 0;
402 
407  void getXMLRepresentation(const std::string& theFeatureId, std::string& theXmlCfg,
408  std::string& theDescription);
409 
411  virtual ModuleBase_ITreeNode* rootNode() const = 0;
412 
413 signals:
417 
418 public slots:
420  virtual void onFeatureTriggered();
421 
425  virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS) {}
426 
430  virtual void onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS) {}
431 
434  virtual void onViewTransformed(int theTrsfType = 2) {}
435 
436 protected slots:
438  virtual void onSelectionChanged() {}
439 
440 protected:
442  virtual void registerValidators() {}
443 
445  virtual void registerProperties() {}
446 
448  virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
449 
451  void loadProprietaryPlugins();
452 
454  void processProprietaryFeatures();
455 
456 protected:
459 
461  std::map<std::string, std::string> myFeaturesInFiles;
463  std::map<std::string, std::string> myProprietaryFeatures;
465  std::set<std::string> myProprietaryPlugins;
467  std::set<std::string> myFeaturesValidLicense;
468 
469  std::map<ModuleBase_SelectionFilterType, Handle(SelectMgr_Filter)> mySelectionFilters;
470 
471 };
472 
473 
474 
476 extern "C" {
477 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);
478 }
479 
480 #define CREATE_MODULE "createModule"
481 
482 #endif //ModuleBase_IModule
Provides low-level API for WidgetFactory for reading xml definitions of widgets.
Definition: Config_WidgetAPI.h:46
Message for communication between sender and listener of event.
Definition: Events_Message.h:65
The result of a feature.
Definition: ModelAPI_Result.h:37
Interface to a module.
Definition: ModuleBase_IModule.h:70
virtual bool isCustomPrsActivated(const ModuleBase_CustomizeFlag &theFlag) const
Return true if the custom presentation is activated.
Definition: ModuleBase_IModule.h:271
virtual void addObjectBrowserMenu(QMenu *theMenu) const
Add menu items for object browser into the given menu.
Definition: ModuleBase_IModule.h:150
std::set< std::string > myProprietaryPlugins
Proprietary plugins.
Definition: ModuleBase_IModule.h:465
virtual void enableCustomModes()
Enables disabled custom mode.
Definition: ModuleBase_IModule.h:316
void resumed(ModuleBase_Operation *theOp)
Segnal emitted when an operation is resumed.
virtual bool canApplyAction(const ObjectPtr &theObject, const QString &theActionId) const =0
Returns true if the action can be applied to the object.
virtual ObjectPtr findPresentedObject(const AISObjectPtr &theAIS) const =0
Returns data object by AIS.
virtual void beforeOperationStopped(ModuleBase_Operation *theOperation)
Performs some GUI actions before an operation transaction is stopped Default realization is empty.
Definition: ModuleBase_IModule.h:382
virtual bool customizeFeature(ObjectPtr theObject, const ModuleBase_CustomizeFlag &theFlag, const bool theUpdateViewer)
Modifies the given presentation in the custom way.
Definition: ModuleBase_IModule.h:306
virtual AttributePtr findAttribute(const ObjectPtr &theObject, const GeomShapePtr &theGeomShape)=0
Finds an attribute by geom shape if it is possible.
virtual void storeSelection()
Stores the current selection.
Definition: ModuleBase_IModule.h:87
virtual void moduleSelectionFilters(const QIntList &theFilterTypes, SelectMgr_ListOfFilter &theSelectionFilters)=0
Appends into container of filters module filters corresponded to the modes type.
virtual void onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS)
Slot called on before object erase.
Definition: ModuleBase_IModule.h:430
virtual void operationCommitted(ModuleBase_Operation *theOperation)
Realizes some functionality by an operation commit.
Definition: ModuleBase_IModule.h:130
virtual void operationAborted(ModuleBase_Operation *theOperation)
Realizes some functionality by an operation abort.
Definition: ModuleBase_IModule.h:133
virtual std::shared_ptr< Events_Message > reentrantMessage()=0
Returns reentrant message if it was accepted.
virtual void clearViewer()=0
Clears specific presentations in the viewer.
virtual GeomShapePtr findShape(const AttributePtr &theAttribute)=0
Finds a shape by attribute if it is possible.
ModuleBase_CustomizeFlag
enumeration to know which objects should be customized
Definition: ModuleBase_IModule.h:74
@ CustomizeResults
references of other objects referenced to the current feature
Definition: ModuleBase_IModule.h:76
virtual void addConstraintBrowserMenu(QMenu *theMenu) const
Add menu items for constraints browser into the given menu.
Definition: ModuleBase_IModule.h:154
virtual void connectToPropertyPanel(ModuleBase_ModelWidget *theWidget, const bool isToConnect)
Connects or disconnects to the value changed signal of the property panel widgets.
Definition: ModuleBase_IModule.h:370
virtual void updateViewerMenu(const QMap< QString, QAction * > &theStdActions)
Update state of pop-up menu items in viewer.
Definition: ModuleBase_IModule.h:352
virtual void updateObjectBrowserMenu(const QMap< QString, QAction * > &theStdActions)
Update state of pop-up menu items in object browser.
Definition: ModuleBase_IModule.h:348
virtual void customizePresentation(const ObjectPtr &theObject, const AISObjectPtr &thePrs) const
Customize presentation according to objects attributes.
Definition: ModuleBase_IModule.h:335
ModuleBase_IWorkshop * workshop() const
Returns current workshop.
Definition: ModuleBase_IModule.h:172
std::map< std::string, std::string > myFeaturesInFiles
Map of features in XML.
Definition: ModuleBase_IModule.h:461
virtual void moduleSelectionModes(int theModesType, QIntList &theModes)=0
Appends specific selection modes for the module to the list of types.
virtual void deactivateCustomPrs(const ModuleBase_CustomizeFlag &theFlag, const bool theUpdateViewer)
Deactivate custom presentation for the object.
Definition: ModuleBase_IModule.h:285
virtual void onViewTransformed(int theTrsfType=2)
Called on transformation in current viewer.
Definition: ModuleBase_IModule.h:434
virtual void customizeObjectBrowser(QWidget *theObjectBrowser)
This method is called on object browser creation for customization of module specific features.
Definition: ModuleBase_IModule.h:320
virtual ModuleBase_ModelWidget * createWidgetByType(const std::string &theType, QWidget *theParent, Config_WidgetAPI *theWidgetApi)
Creates custom widgets for property panel.
Definition: ModuleBase_IModule.h:161
virtual void operationStopped(ModuleBase_Operation *theOperation)
Realizes some functionality by an operation stop.
Definition: ModuleBase_IModule.h:127
virtual void restoreSelection()
Restores the current selection.
Definition: ModuleBase_IModule.h:90
virtual void operationStarted(ModuleBase_Operation *theOperation)
Realizes some functionality by an operation start.
Definition: ModuleBase_IModule.h:119
virtual void activateCustomPrs(const FeaturePtr &theFeature, const ModuleBase_CustomizeFlag &theFlag, const bool theUpdateViewer)
Activate custom presentation for the object.
Definition: ModuleBase_IModule.h:278
virtual bool addViewerMenu(const QMap< QString, QAction * > &theStdActions, QWidget *theParent, QMap< int, QAction * > &theMenuActions) const
Add menu items for viewer into the actions map.
Definition: ModuleBase_IModule.h:143
ModuleBase_IWorkshop * myWorkshop
Reference to workshop.
Definition: ModuleBase_IModule.h:458
std::set< std::string > myFeaturesValidLicense
Features, which have valid license.
Definition: ModuleBase_IModule.h:467
virtual void widgetStateChanged(int thePreviousState)
Validates the operation to change the "Apply" button state.
Definition: ModuleBase_IModule.h:374
virtual void registerValidators()
Register validators for this module.
Definition: ModuleBase_IModule.h:442
virtual bool deleteObjects()
Reacts to the delete action in module.
Definition: ModuleBase_IModule.h:230
virtual void registerProperties()
Register properties of this module.
Definition: ModuleBase_IModule.h:445
std::map< std::string, std::string > myProprietaryFeatures
Map of features in XML, which require license but not confirmed yet.
Definition: ModuleBase_IModule.h:463
virtual bool createWidgets(const FeaturePtr &theFeature, const QString &theXmlRepr, QList< ModuleBase_ModelWidget * > &theWidgets) const
Have an opportunity to create widgets for the current operation instead of standard creation in works...
Definition: ModuleBase_IModule.h:184
virtual ModuleBase_ModelWidget * activeWidget() const =0
Returns the active widget, by default it is the property panel active widget.
virtual bool isActionEnableStateFixed(const int theActionId) const
Returns true if the action should be always enabled.
Definition: ModuleBase_IModule.h:357
virtual void propertyPanelDefined(ModuleBase_Operation *theOperation)
Call back forlast tuning of property panel before operation performance It is called as on clearing o...
Definition: ModuleBase_IModule.h:176
virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS)
Slot called on object display.
Definition: ModuleBase_IModule.h:425
virtual void setReentrantPreSelection(const std::shared_ptr< Events_Message > &theMessage)=0
Put current selection into reentrant message.
virtual ModuleBase_Operation * currentOperation() const =0
Realizes some functionality by an operation start.
virtual bool processEnter(const std::string &thePreviousAttributeID)
Returns true if the event is processed.
Definition: ModuleBase_IModule.h:378
virtual void disableCustomMode(ModuleBase_CustomizeFlag theMode)
Disable displaying of custom mode.
Definition: ModuleBase_IModule.h:313
virtual void activeSelectionModes(QIntList &theModes)
Returns a list of modes, where the AIS objects should be activated.
Definition: ModuleBase_IModule.h:240
virtual ModuleBase_ITreeNode * rootNode() const =0
Returns root tree node which represents a data model.
virtual void closeDocument()=0
Performs functionality on closing document.
virtual void onSelectionChanged()
Called on selection changed event.
Definition: ModuleBase_IModule.h:438
virtual bool canCommitOperation() const
Returns true if the operation can be committed.
Definition: ModuleBase_IModule.h:104
Definition: ModuleBase_ITreeNode.h:44
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
An abstract custom widget class.
Definition: ModuleBase_ModelWidget.h:60
Base class for all operations.
Definition: ModuleBase_Operation.h:53
Presentation.
Definition: ModuleBase_ViewerPrs.h:37