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>
25 class ModuleBase_Operation;
26 class ModuleBase_IViewWindow;
28 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
32 /// Enumeration to specify the restart operation properties.
34 RM_None, /// the operation should not be restarted
35 RM_Forbided, /// the operation should not be restarted after there is no active widget
36 RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
37 RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
41 PartSet_Module(ModuleBase_IWorkshop* theWshop);
42 virtual ~PartSet_Module();
44 /// Creates custom widgets for property panel
45 virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
46 Config_WidgetAPI* theWidgetApi, std::string theParentId,
47 QList<ModuleBase_ModelWidget*>& theModelWidgets);
49 /// Call back forlast tuning of property panel before operation performance
50 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
52 QStringList sketchOperationIdList() const;
55 /// SLOT, that is called by no more widget signal emitted by property panel
56 /// Set a specific flag to restart the sketcher operation
57 void onNoMoreWidgets();
60 /// Called when previous operation is finished
61 virtual void onOperationComitted(ModuleBase_Operation* theOperation);
63 virtual void onOperationAborted(ModuleBase_Operation* theOperation);
65 virtual void onOperationStarted(ModuleBase_Operation* theOperation);
67 virtual void onOperationStopped(ModuleBase_Operation* theOperation);
69 /// Called when previous operation is finished
70 virtual void onSelectionChanged();
72 /// SLOT, that is called by mouse press in the viewer.
73 /// \param theWnd - the window where the event happens
74 /// \param theEvent the mouse event
75 void onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
77 /// SLOT, that is called by mouse release in the viewer.
78 /// \param theWnd - the window where the event happens
79 /// \param theEvent the mouse event
80 void onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
82 /// SLOT, that is called by mouse move in the viewer.
83 /// \param theWnd - the window where the event happens
84 /// \param theEvent the mouse event
85 void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
87 /// SLOT, that is called by mouse double click in the viewer.
88 /// \param theWnd - the window where the event happens
89 /// \param theEvent the mouse event
90 void onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
92 /// SLOT, that is called by key release in the viewer.
93 /// The mouse moved point is sent to the current operation to be processed.
94 /// \param theEvent the key event
95 void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
97 /// SLOT, that is called by enter key released
98 /// Set a specific type of restarting the current operation
99 void onEnterReleased();
101 /// SLOT, that is called by the current operation filling with the preselection.
102 /// It commits the operation of it is can be committed
103 void onOperationActivatedByPreselection();
105 /// Launches the operation from current highlighting
106 void launchEditing();
109 /// Returns new instance of operation object (used in createOperation for customization)
110 virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
112 /// Register validators for this module
113 virtual void registerValidators();
115 /// Register selection filters for this module
116 virtual void registerFilters();
119 void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
121 void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
124 /// Converts mouse position to 2d coordinates.
125 /// Member myCurrentSketch has to be correctly defined
126 void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
127 double& theX, double& theY);
129 /// Breaks sequense of automatically resterted operations
130 void breakOperationSequence();
133 QString myLastOperationId;
134 FeaturePtr myLastFeature;
139 // Automatical restarting mode flag
140 RestartingMode myRestartingMode;
142 double myCurX, myCurY;
143 CompositeFeaturePtr myCurrentSketch;
144 QList<FeaturePtr> myEditingFeatures;
145 QList<AttributePtr> myEditingAttr;
147 Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
148 /// A filter which provides selection within a current document or whole PartSet
149 Handle(PartSet_GlobalFilter) myDocumentShapeFilter;