1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #ifndef PartSet_Module_H
4 #define PartSet_Module_H
7 #include "PartSet_Filters.h"
8 #include "PartSet_SketcherMgr.h"
10 #include <ModuleBase_IModule.h>
11 #include <ModuleBase_Definitions.h>
12 #include <ModelAPI_Feature.h>
13 #include <ModelAPI_Attribute.h>
14 #include <ModelAPI_CompositeFeature.h>
16 //#include <StdSelect_FaceFilter.hxx>
17 #include <TopoDS_Shape.hxx>
27 class ModuleBase_Operation;
28 class ModuleBase_IViewWindow;
34 * Implementation of Partset module
36 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
40 /// Enumeration to specify the restart operation properties.
42 RM_None, /// the operation should not be restarted
43 RM_Forbided, /// the operation should not be restarted after there is no active widget
44 RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
45 RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
50 /// \param theWshop a pointer to a workshop
51 PartSet_Module(ModuleBase_IWorkshop* theWshop);
52 virtual ~PartSet_Module();
54 /// Creates custom widgets for property panel
55 virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
56 Config_WidgetAPI* theWidgetApi, std::string theParentId);
58 /// Call back forlast tuning of property panel before operation performance
59 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
62 /// Realizes some functionality by an operation start
63 /// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters
64 /// \param theOperation a started operation
65 virtual void operationStarted(ModuleBase_Operation* theOperation);
67 /// Realizes some functionality by an operation commit
68 /// Restarts sketcher operation automatically of it is necessary
69 /// \param theOperation a committed operation
70 virtual void operationCommitted(ModuleBase_Operation* theOperation);
72 /// Realizes some functionality by an operation abort
73 /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
74 /// \param theOperation an aborted operation
75 virtual void operationAborted(ModuleBase_Operation* theOperation);
77 /// Realizes some functionality by an operation stop
78 /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
79 /// \param theOperation a stopped operation
80 virtual void operationStopped(ModuleBase_Operation* theOperation);
82 /// Realizes some functionality by an operation start
83 /// \param theOperation a started operation
84 virtual ModuleBase_Operation* currentOperation() const;
86 /// Returns action according to the given ID
87 /// \param theId an action identifier, it should be uniqued in the bounds of the module
88 QAction* action(const QString& theId) const;
90 /// Returns True if there are available Undos and the sketch manager allows undo
91 /// \return the boolean result
92 virtual bool canUndo() const;
94 //! Returns True if there are available Redos and the sketch manager allows redo
95 /// \return the boolean result
96 virtual bool canRedo() const;
98 /// Returns whether the object can be displayed at the bounds of the active operation.
99 /// Display only current operation results for usual operation and ask the sketcher manager
100 /// if it is a sketch operation
101 /// \param theObject a model object
102 virtual bool canDisplayObject(const ObjectPtr& theObject) const;
103 /// Add menu atems for viewer into the given menu
104 /// \param theMenu a popup menu to be shown in the viewer
105 virtual void addViewerItems(QMenu* theMenu) const;
108 /// SLOT, that is called by no more widget signal emitted by property panel
109 /// Set a specific flag to restart the sketcher operation
110 void onNoMoreWidgets();
112 /// Processes the context menu action click
113 /// \param isChecked a state of toggle if the action is checkable
114 void onAction(bool isChecked);
116 /// Slolt called on object display
117 /// \param theObject a data object
118 /// \param theAIS a presentation object
119 virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS);
122 /// Called when previous operation is finished
123 virtual void onSelectionChanged();
125 /// SLOT, that is called by key release in the viewer.
126 /// \param theWnd a view window
127 /// \param theEvent the key event
128 void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
130 /// SLOT, that is called by enter key released
131 /// Set a specific type of restarting the current operation
132 void onEnterReleased();
134 /// SLOT, that is called by the current operation filling with the preselection.
135 /// It commits the operation of it is can be committed
136 void onOperationActivatedByPreselection();
139 /// Register validators for this module
140 virtual void registerValidators();
142 /// Register selection filters for this module
143 virtual void registerFilters();
145 /// Register properties of this module
146 virtual void registerProperties();
149 /// Processing of vertex selected
150 void onVertexSelected();
153 /// Breaks sequense of automatically resterted operations
154 void breakOperationSequence();
156 /// Create all actions for context menus. It is called on creation of module
157 /// Put the created actions into an internal map
158 void createActions();
160 /// Add action to the internal map
161 /// \param theId - string ID of the item
162 /// \param theAction - action to add
163 void addAction(const QString& theId, QAction* theAction);
166 virtual bool deleteObjects();
169 QString myLastOperationId;
170 FeaturePtr myLastFeature;
172 // Automatical restarting mode flag
173 RestartingMode myRestartingMode;
175 /// A filter which provides selection within a current document or whole PartSet
176 Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
178 PartSet_SketcherMgr* mySketchMgr;
180 QMap<QString, QAction*> myActions; // the popup menu actions