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"
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 <StdSelect_FaceFilter.hxx>
16 #include <TopoDS_Shape.hxx>
26 class ModuleBase_Operation;
27 class ModuleBase_IViewWindow;
28 class PartSet_MenuMgr;
29 class PartSet_SketcherMgr;
35 * Implementation of Partset module
37 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
41 /// Enumeration to specify the restart operation properties.
43 RM_None, /// the operation should not be restarted
44 RM_Forbided, /// the operation should not be restarted after there is no active widget
45 RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
46 RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
51 /// \param theWshop a pointer to a workshop
52 PartSet_Module(ModuleBase_IWorkshop* theWshop);
53 virtual ~PartSet_Module();
55 /// Creates custom widgets for property panel
56 virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
57 Config_WidgetAPI* theWidgetApi, std::string theParentId);
59 /// Call back forlast tuning of property panel before operation performance
60 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
63 /// Realizes some functionality by an operation start
64 /// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters
65 /// \param theOperation a started operation
66 virtual void operationStarted(ModuleBase_Operation* theOperation);
68 /// Realizes some functionality by an operation commit
69 /// Restarts sketcher operation automatically of it is necessary
70 /// \param theOperation a committed operation
71 virtual void operationCommitted(ModuleBase_Operation* theOperation);
73 /// Realizes some functionality by an operation abort
74 /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
75 /// \param theOperation an aborted operation
76 virtual void operationAborted(ModuleBase_Operation* theOperation);
78 /// Realizes some functionality by an operation stop
79 /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
80 /// \param theOperation a stopped operation
81 virtual void operationStopped(ModuleBase_Operation* theOperation);
83 /// Realizes some functionality by an operation start
84 /// \param theOperation a started operation
85 virtual ModuleBase_Operation* currentOperation() const;
87 /// Returns True if there are available Undos and the sketch manager allows undo
88 /// \return the boolean result
89 virtual bool canUndo() const;
91 //! Returns True if there are available Redos and the sketch manager allows redo
92 /// \return the boolean result
93 virtual bool canRedo() const;
95 /// Returns whether the object can be displayed at the bounds of the active operation.
96 /// Display only current operation results for usual operation and ask the sketcher manager
97 /// if it is a sketch operation
98 /// \param theObject a model object
99 virtual bool canDisplayObject(const ObjectPtr& theObject) const;
101 /// Add menu atems for viewer into the given menu
102 /// \param theMenu a popup menu to be shown in the viewer
103 /// \param theStdActions a map of standard actions
104 /// \return true if items are added and there is no necessity to provide standard menu
105 virtual bool addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
107 /// Returns whether the mouse enter the viewer's window
108 /// \return true if items are added and there is no necessity to provide standard menu
109 bool isMouseOverWindow();
111 PartSet_SketcherMgr* sketchMgr() const { return mySketchMgr; }
114 /// SLOT, that is called by no more widget signal emitted by property panel
115 /// Set a specific flag to restart the sketcher operation
116 void onNoMoreWidgets();
118 /// Slolt called on object display
119 /// \param theObject a data object
120 /// \param theAIS a presentation object
121 virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS);
124 /// Called when previous operation is finished
125 virtual void onSelectionChanged();
127 /// SLOT, that is called by key release in the viewer.
128 /// \param theWnd a view window
129 /// \param theEvent the key event
130 void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
132 /// SLOT, that is called by enter key released
133 /// Set a specific type of restarting the current operation
134 void onEnterReleased();
136 /// SLOT, that is called by the current operation filling with the preselection.
137 /// It commits the operation of it is can be committed
138 void onOperationActivatedByPreselection();
141 /// Register validators for this module
142 virtual void registerValidators();
144 /// Register selection filters for this module
145 virtual void registerFilters();
147 /// Register properties of this module
148 virtual void registerProperties();
151 /// Processing of vertex selected
152 void onVertexSelected();
154 /// Called on transformation in current viewer
155 /// \param theTrsfType type of tranformation
156 void onViewTransformed(int theTrsfType = 2);
159 /// Breaks sequense of automatically resterted operations
160 void breakOperationSequence();
163 virtual bool deleteObjects();
166 QString myLastOperationId;
167 FeaturePtr myLastFeature;
169 // Automatical restarting mode flag
170 RestartingMode myRestartingMode;
172 /// A filter which provides selection within a current document or whole PartSet
173 Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
175 PartSet_SketcherMgr* mySketchMgr;
177 PartSet_MenuMgr* myMenuMgr;