1 #ifndef PartSet_Module_H
2 #define PartSet_Module_H
5 #include <PartSet_Filters.h>
7 #include <ModuleBase_IModule.h>
8 #include <ModuleBase_Definitions.h>
9 #include <XGUI_Command.h>
10 #include <ModelAPI_Feature.h>
11 #include <ModelAPI_Attribute.h>
12 #include <ModelAPI_CompositeFeature.h>
14 #include <StdSelect_FaceFilter.hxx>
15 #include <TopoDS_Shape.hxx>
24 class ModuleBase_Operation;
25 class ModuleBase_IViewWindow;
27 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
31 /// Enumeration to specify the restart operation properties.
33 RM_None, /// the operation should not be restarted
34 RM_Forbided, /// the operation should not be restarted after there is no active widget
35 RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
36 RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
40 PartSet_Module(ModuleBase_IWorkshop* theWshop);
41 virtual ~PartSet_Module();
43 /// Creates custom widgets for property panel
44 virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
45 Config_WidgetAPI* theWidgetApi, std::string theParentId,
46 QList<ModuleBase_ModelWidget*>& theModelWidgets);
48 /// Call back forlast tuning of property panel before operation performance
49 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
51 QStringList sketchOperationIdList() const;
54 /// SLOT, that is called by no more widget signal emitted by property panel
55 /// Set a specific flag to restart the sketcher operation
56 void onNoMoreWidgets();
59 /// Called when previous operation is finished
60 virtual void onOperationComitted(ModuleBase_Operation* theOperation);
62 virtual void onOperationAborted(ModuleBase_Operation* theOperation);
64 virtual void onOperationStarted(ModuleBase_Operation* theOperation);
66 virtual void onOperationStopped(ModuleBase_Operation* theOperation);
68 /// Called when previous operation is finished
69 virtual void onSelectionChanged();
71 /// SLOT, that is called by mouse press in the viewer.
72 /// \param theWnd - the window where the event happens
73 /// \param theEvent the mouse event
74 void onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
76 /// SLOT, that is called by mouse release in the viewer.
77 /// \param theWnd - the window where the event happens
78 /// \param theEvent the mouse event
79 void onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
81 /// SLOT, that is called by mouse move in the viewer.
82 /// \param theWnd - the window where the event happens
83 /// \param theEvent the mouse event
84 void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
86 /// SLOT, that is called by mouse double click in the viewer.
87 /// \param theWnd - the window where the event happens
88 /// \param theEvent the mouse event
89 void onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
91 /// SLOT, that is called by key release in the viewer.
92 /// The mouse moved point is sent to the current operation to be processed.
93 /// \param theEvent the key event
94 void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
96 /// SLOT, that is called by enter key released
97 /// Set a specific type of restarting the current operation
98 void onEnterReleased();
100 /// Launches the operation from current highlighting
101 void launchEditing();
104 /// Returns new instance of operation object (used in createOperation for customization)
105 virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
107 /// Register validators for this module
108 virtual void registerValidators();
110 /// Register selection filters for this module
111 virtual void registerFilters();
114 void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
116 void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
119 /// Converts mouse position to 2d coordinates.
120 /// Member myCurrentSketch has to be correctly defined
121 void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
122 double& theX, double& theY);
124 /// Breaks sequense of automatically resterted operations
125 void breakOperationSequence();
128 QString myLastOperationId;
129 FeaturePtr myLastFeature;
134 // Automatical restarting mode flag
135 RestartingMode myRestartingMode;
137 double myCurX, myCurY;
138 CompositeFeaturePtr myCurrentSketch;
139 QList<FeaturePtr> myEditingFeatures;
140 QList<AttributePtr> myEditingAttr;
142 Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
143 /// A filter which provides selection within a current document or whole PartSet
144 Handle(PartSet_GlobalFilter) myDocumentShapeFilter;