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"
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 <Events_Listener.h>
18 //#include <StdSelect_FaceFilter.hxx>
19 #include <TopoDS_Shape.hxx>
29 class ModuleBase_Operation;
30 class ModuleBase_IViewWindow;
31 class PartSet_MenuMgr;
32 class PartSet_SketcherMgr;
38 * Implementation of Partset module
40 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule, public Events_Listener
44 /// Enumeration to specify the restart operation properties.
46 RM_None, /// the operation should not be restarted
47 RM_Forbided, /// the operation should not be restarted after there is no active widget
48 RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
49 RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
55 /// \param theWshop a pointer to a workshop
56 PartSet_Module(ModuleBase_IWorkshop* theWshop);
57 virtual ~PartSet_Module();
59 /// Creates custom widgets for property panel
60 virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
61 Config_WidgetAPI* theWidgetApi, std::string theParentId);
63 /// Call back forlast tuning of property panel before operation performance
64 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
67 /// Realizes some functionality by an operation start
68 /// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters
69 /// \param theOperation a started operation
70 virtual void operationStarted(ModuleBase_Operation* theOperation);
72 /// Realizes some functionality by an operation commit
73 /// Restarts sketcher operation automatically of it is necessary
74 /// \param theOperation a committed operation
75 virtual void operationCommitted(ModuleBase_Operation* theOperation);
77 /// Realizes some functionality by an operation abort
78 /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
79 /// \param theOperation an aborted operation
80 virtual void operationAborted(ModuleBase_Operation* theOperation);
82 /// Realizes some functionality by an operation stop
83 /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
84 /// \param theOperation a stopped operation
85 virtual void operationStopped(ModuleBase_Operation* theOperation);
87 /// Returns current operation
88 virtual ModuleBase_Operation* currentOperation() 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;
104 /// Add menu atems for object browser into the given menu
105 /// \param theMenu a popup menu to be shown in the object browser
106 virtual void addObjectBrowserMenu(QMenu* theMenu) const;
108 /// Add menu atems for viewer into the given menu
109 /// \param theMenu a popup menu to be shown in the viewer
110 /// \param theStdActions a map of standard actions
111 /// \return true if items are added and there is no necessity to provide standard menu
112 virtual bool addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
114 /// Returns a list of modes, where the AIS objects should be activated
115 /// \param theModes a list of modes
116 virtual void activeSelectionModes(QIntList& theModes);
118 /// Returns whether the mouse enter the viewer's window
119 /// \return true if items are added and there is no necessity to provide standard menu
120 bool isMouseOverWindow();
122 PartSet_SketcherMgr* sketchMgr() const { return mySketchMgr; }
124 /// Returns data model object for representation of data tree in Object browser
125 virtual ModuleBase_IDocumentDataModel* dataModel() const { return myDataModel; }
127 /// Event Listener method
128 /// \param theMessage an event message
129 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
131 /// This method is called on object browser creation for customisation of module specific features
132 /// \param theObjectBrowser a pinter on Object Browser widget
133 virtual void customizeObjectBrowser(QWidget* theObjectBrowser);
136 /// SLOT, that is called by no more widget signal emitted by property panel
137 /// Set a specific flag to restart the sketcher operation
138 void onNoMoreWidgets();
140 /// Redefines the parent method in order to customize the next case:
141 /// If the sketch nested operation is active and the presentation is not visualized in the viewer,
142 /// the operation should be always aborted.
143 virtual void onFeatureTriggered();
145 /// Slolt called on object display
146 /// \param theObject a data object
147 /// \param theAIS a presentation object
148 virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS);
151 /// Called when previous operation is finished
152 virtual void onSelectionChanged();
154 /// SLOT, that is called by key release in the viewer.
155 /// \param theWnd a view window
156 /// \param theEvent the key event
157 void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
159 /// SLOT, that is called by enter key released
160 /// Set a specific type of restarting the current operation
161 void onEnterReleased();
163 /// SLOT, that is called by the current operation filling with the preselection.
164 /// It commits the operation of it is can be committed
165 void onOperationActivatedByPreselection();
168 /// Register validators for this module
169 virtual void registerValidators();
171 /// Register selection filters for this module
172 virtual void registerFilters();
174 /// Register properties of this module
175 virtual void registerProperties();
177 /// Sends the operation for launching
178 /// \param theOperation the operation
179 virtual void sendOperation(ModuleBase_Operation* theOperation);
182 /// Processing of vertex selected
183 void onVertexSelected();
185 /// Called on transformation in current viewer
186 /// \param theTrsfType type of tranformation
187 void onViewTransformed(int theTrsfType = 2);
189 void onTreeViewDoubleClick(const QModelIndex&);
192 /// Breaks sequense of automatically resterted operations
193 void breakOperationSequence();
196 virtual bool deleteObjects();
199 QString myLastOperationId;
200 FeaturePtr myLastFeature;
202 // Automatical restarting mode flag
203 RestartingMode myRestartingMode;
205 /// A filter which provides selection within a current document or whole PartSet
206 Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
208 PartSet_SketcherMgr* mySketchMgr;
210 PartSet_MenuMgr* myMenuMgr;
214 PartSet_DocumentDataModel* myDataModel;