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_DocumentDataModel.h"
9 #include "PartSet_FilterInfinite.h"
11 #include <ModuleBase_IModule.h>
12 #include <ModuleBase_Definitions.h>
13 #include <ModelAPI_Feature.h>
14 #include <ModelAPI_Attribute.h>
15 #include <ModelAPI_CompositeFeature.h>
17 #include <Events_Listener.h>
19 //#include <StdSelect_FaceFilter.hxx>
20 #include <TopoDS_Shape.hxx>
30 class ModuleBase_Operation;
31 class ModuleBase_IViewWindow;
32 class PartSet_MenuMgr;
33 class PartSet_SketcherMgr;
39 * Implementation of Partset module
41 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule, public Events_Listener
45 /// Enumeration to specify the restart operation properties.
47 RM_None, /// the operation should not be restarted
48 RM_Forbided, /// the operation should not be restarted after there is no active widget
49 RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
50 RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
56 /// \param theWshop a pointer to a workshop
57 PartSet_Module(ModuleBase_IWorkshop* theWshop);
58 virtual ~PartSet_Module();
60 /// Creates custom widgets for property panel
61 virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
62 Config_WidgetAPI* theWidgetApi, std::string theParentId);
64 /// Call back forlast tuning of property panel before operation performance
65 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
68 /// Realizes some functionality by an operation start
69 /// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters
70 /// \param theOperation a started operation
71 virtual void onOperationStarted(ModuleBase_Operation* theOperation);
73 /// Realizes some functionality by an operation commit
74 /// Restarts sketcher operation automatically of it is necessary
75 /// \param theOperation a committed operation
76 virtual void onOperationCommitted(ModuleBase_Operation* theOperation);
78 /// Realizes some functionality by an operation abort
79 /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
80 /// \param theOperation an aborted operation
81 virtual void onOperationAborted(ModuleBase_Operation* theOperation);
83 /// Realizes some functionality by an operation stop
84 /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
85 /// \param theOperation a stopped operation
86 virtual void onOperationStopped(ModuleBase_Operation* theOperation);
88 /// Returns current operation
89 virtual ModuleBase_Operation* currentOperation() const;
91 /// Returns True if there are available Undos and the sketch manager allows undo
92 /// \return the boolean result
93 virtual bool canUndo() const;
95 //! Returns True if there are available Redos and the sketch manager allows redo
96 /// \return the boolean result
97 virtual bool canRedo() const;
99 /// Returns whether the object can be displayed at the bounds of the active operation.
100 /// Display only current operation results for usual operation and ask the sketcher manager
101 /// if it is a sketch operation
102 /// \param theObject a model object
103 virtual bool canDisplayObject(const ObjectPtr& theObject) const;
105 /// Returns true if selection for the object can be activate.
106 /// For sketch operation allow the selection activation if the operation is edit, for other
107 /// operation uses the default result
108 /// \param theObject a model object
109 virtual bool canActivateSelection(const ObjectPtr& theObject) const;
111 /// Add menu atems for object browser into the given menu
112 /// \param theMenu a popup menu to be shown in the object browser
113 virtual void addObjectBrowserMenu(QMenu* theMenu) const;
115 /// Add menu atems for viewer into the given menu
116 /// \param theMenu a popup menu to be shown in the viewer
117 /// \param theStdActions a map of standard actions
118 /// \return true if items are added and there is no necessity to provide standard menu
119 virtual bool addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
121 /// Returns a list of modes, where the AIS objects should be activated
122 /// \param theModes a list of modes
123 virtual void activeSelectionModes(QIntList& theModes);
125 /// Returns whether the mouse enter the viewer's window
126 /// \return true if items are added and there is no necessity to provide standard menu
127 bool isMouseOverWindow();
129 PartSet_SketcherMgr* sketchMgr() const { return mySketchMgr; }
131 /// Returns data model object for representation of data tree in Object browser
132 virtual ModuleBase_IDocumentDataModel* dataModel() const { return myDataModel; }
134 /// Event Listener method
135 /// \param theMessage an event message
136 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
138 /// This method is called on object browser creation for customisation of module specific features
139 /// \param theObjectBrowser a pinter on Object Browser widget
140 virtual void customizeObjectBrowser(QWidget* theObjectBrowser);
142 /// Sends the operation for launching
143 /// \param theOperation the operation
144 virtual void sendOperation(ModuleBase_Operation* theOperation);
147 /// SLOT, that is called by no more widget signal emitted by property panel
148 /// Set a specific flag to restart the sketcher operation
149 void onNoMoreWidgets();
151 /// Redefines the parent method in order to customize the next case:
152 /// If the sketch nested operation is active and the presentation is not visualized in the viewer,
153 /// the operation should be always aborted.
154 virtual void onFeatureTriggered();
156 /// Slolt called on object display
157 /// \param theObject a data object
158 /// \param theAIS a presentation object
159 virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS);
161 /// Called on transformation in current viewer
162 /// \param theTrsfType type of tranformation
163 void onViewTransformed(int theTrsfType = 2);
166 /// Called when previous operation is finished
167 virtual void onSelectionChanged();
169 /// SLOT, that is called by key release in the viewer.
170 /// \param theWnd a view window
171 /// \param theEvent the key event
172 void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
174 /// SLOT, that is called by enter key released
175 /// Set a specific type of restarting the current operation
176 void onEnterReleased();
178 /// SLOT, that is called by the current operation filling with the preselection.
179 /// It commits the operation of it is can be committed
180 void onOperationActivatedByPreselection();
183 /// Register validators for this module
184 virtual void registerValidators();
186 /// Register selection filters for this module
187 virtual void registerFilters();
189 /// Register properties of this module
190 virtual void registerProperties();
193 /// Processing of vertex selected
194 void onVertexSelected();
196 void onTreeViewDoubleClick(const QModelIndex&);
199 /// Breaks sequense of automatically resterted operations
200 void breakOperationSequence();
203 virtual bool deleteObjects();
206 QString myLastOperationId;
207 FeaturePtr myLastFeature;
209 // Automatical restarting mode flag
210 RestartingMode myRestartingMode;
212 /// A filter which provides selection within a current document or whole PartSet
213 Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
214 Handle(PartSet_FilterInfinite) myFilterInfinite;
216 PartSet_SketcherMgr* mySketchMgr;
218 PartSet_MenuMgr* myMenuMgr;
222 PartSet_DocumentDataModel* myDataModel;