1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #ifndef PartSet_Module_H
4 #define PartSet_Module_H
7 #include "PartSet_DocumentDataModel.h"
9 #include <ModuleBase_IModule.h>
10 #include <ModuleBase_Definitions.h>
11 #include <ModelAPI_Feature.h>
12 #include <ModelAPI_Attribute.h>
13 #include <ModelAPI_CompositeFeature.h>
15 #include <GeomAPI_ICustomPrs.h>
17 #include <Events_Listener.h>
19 //#include <StdSelect_FaceFilter.hxx>
20 #include <TopoDS_Shape.hxx>
21 #include <SelectMgr_ListOfFilter.hxx>
31 class ModuleBase_Operation;
32 class ModuleBase_IViewWindow;
33 class PartSet_MenuMgr;
34 class PartSet_SketcherMgr;
40 * Implementation of Partset module
42 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule, public Events_Listener
46 /// Enumeration to specify the restart operation properties.
48 RM_None, /// the operation should not be restarted
49 RM_Forbided, /// the operation should not be restarted after there is no active widget
50 RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
51 RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
57 /// \param theWshop a pointer to a workshop
58 PartSet_Module(ModuleBase_IWorkshop* theWshop);
59 virtual ~PartSet_Module();
61 // Add default selection filters of the module to the current viewer
62 virtual void activateSelectionFilters();
63 // Remove default selection filters of the module from the current viewer
64 virtual void deactivateSelectionFilters();
66 /// Creates custom widgets for property panel
67 virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
68 Config_WidgetAPI* theWidgetApi, std::string theParentId);
70 /// Call back forlast tuning of property panel before operation performance
71 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
73 /// Realizes some functionality by an operation start
74 /// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters
75 /// \param theOperation a started operation
76 virtual void onOperationStarted(ModuleBase_Operation* theOperation);
78 /// Realizes some functionality by an operation commit
79 /// Restarts sketcher operation automatically of it is necessary
80 /// \param theOperation a committed operation
81 virtual void onOperationCommitted(ModuleBase_Operation* theOperation);
83 /// Realizes some functionality by an operation abort
84 /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
85 /// \param theOperation an aborted operation
86 virtual void onOperationAborted(ModuleBase_Operation* theOperation);
88 /// Realizes some functionality by an operation stop
89 /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
90 /// \param theOperation a stopped operation
91 virtual void onOperationStopped(ModuleBase_Operation* theOperation);
93 /// Returns current operation
94 virtual ModuleBase_Operation* currentOperation() const;
96 /// Returns True if there are available Undos and the sketch manager allows undo
97 /// \return the boolean result
98 virtual bool canUndo() const;
100 //! Returns True if there are available Redos and the sketch manager allows redo
101 /// \return the boolean result
102 virtual bool canRedo() const;
104 /// Returns True if the current operation can be committed. Asks the sketch manager.
105 /// \return a boolean value
106 virtual bool canCommitOperation() const;
108 /// Returns whether the object can be displayed at the bounds of the active operation.
109 /// Display only current operation results for usual operation and ask the sketcher manager
110 /// if it is a sketch operation
111 /// \param theObject a model object
112 virtual bool canDisplayObject(const ObjectPtr& theObject) const;
114 /// Returns true if selection for the object can be activate.
115 /// For sketch operation allow the selection activation if the operation is edit, for other
116 /// operation uses the default result
117 /// \param theObject a model object
118 virtual bool canActivateSelection(const ObjectPtr& theObject) const;
120 /// Add menu atems for object browser into the given menu
121 /// \param theMenu a popup menu to be shown in the object browser
122 virtual void addObjectBrowserMenu(QMenu* theMenu) const;
124 /// Add menu atems for viewer into the given menu
125 /// \param theMenu a popup menu to be shown in the viewer
126 /// \param theStdActions a map of standard actions
127 /// \return true if items are added and there is no necessity to provide standard menu
128 virtual bool addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
130 /// Returns a list of modes, where the AIS objects should be activated
131 /// \param theModes a list of modes
132 virtual void activeSelectionModes(QIntList& theModes);
134 /// Returns whether the mouse enter the viewer's window
135 /// \return true if items are added and there is no necessity to provide standard menu
136 bool isMouseOverWindow();
138 PartSet_SketcherMgr* sketchMgr() const { return mySketchMgr; }
140 /// Returns data model object for representation of data tree in Object browser
141 virtual ModuleBase_IDocumentDataModel* dataModel() const { return myDataModel; }
143 /// Event Listener method
144 /// \param theMessage an event message
145 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
147 /// Set the object with the object results are customized
148 /// \param theObject an object
149 void setCustomized(const ObjectPtr& theObject);
151 /** Update the object presentable properties such as color, lines width and other
152 * If the object is result with the color attribute value set, it is used,
153 * otherwise the customize is applyed to the object's feature if it is a custom prs
154 * \param theObject an object instance
155 * \return the true state if there is changes and the presentation is customized
157 virtual bool customizeObject(ObjectPtr theObject);
159 /// This method is called on object browser creation for customisation of module specific features
160 /// \param theObjectBrowser a pinter on Object Browser widget
161 virtual void customizeObjectBrowser(QWidget* theObjectBrowser);
164 /// SLOT, that is called by no more widget signal emitted by property panel
165 /// Set a specific flag to restart the sketcher operation
166 void onNoMoreWidgets();
168 /// Redefines the parent method in order to customize the next case:
169 /// If the sketch nested operation is active and the presentation is not visualized in the viewer,
170 /// the operation should be always aborted.
171 virtual void onFeatureTriggered();
173 /// Slolt called on object display
174 /// \param theObject a data object
175 /// \param theAIS a presentation object
176 virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS);
178 /// Called on transformation in current viewer
179 /// \param theTrsfType type of tranformation
180 void onViewTransformed(int theTrsfType = 2);
183 /// Called when previous operation is finished
184 virtual void onSelectionChanged();
186 /// SLOT, that is called by key release in the viewer.
187 /// \param theWnd a view window
188 /// \param theEvent the key event
189 void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
191 /// SLOT, that is called by enter key released
192 /// Set a specific type of restarting the current operation
193 void onEnterReleased();
195 /// SLOT, that is called by the current operation filling with the preselection.
196 /// It commits the operation of it is can be committed
197 void onOperationActivatedByPreselection();
200 /// Register validators for this module
201 virtual void registerValidators();
203 /// Register selection filters for this module
204 virtual void registerFilters();
206 /// Register properties of this module
207 virtual void registerProperties();
210 /// Processing of vertex selected
211 void onVertexSelected();
213 void onTreeViewDoubleClick(const QModelIndex&);
216 /// Breaks sequense of automatically resterted operations
217 void breakOperationSequence();
220 virtual bool deleteObjects();
223 QString myLastOperationId;
224 FeaturePtr myLastFeature;
226 // Automatical restarting mode flag
227 RestartingMode myRestartingMode;
229 SelectMgr_ListOfFilter mySelectionFilters;
231 PartSet_SketcherMgr* mySketchMgr;
232 PartSet_MenuMgr* myMenuMgr;
233 /// A default custom presentation, which is used for references objects of started operation
234 GeomCustomPrsPtr myCustomPrs;
238 PartSet_DocumentDataModel* myDataModel;