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 /// The mouse released point is sent to the current operation to be processed.
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 /// The mouse released point is sent to the current operation to be processed.
78 /// \param theEvent the mouse event
79 virtual void onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
81 /// SLOT, that is called by mouse move in the viewer.
82 /// The mouse moved point is sent to the current operation to be processed.
83 /// \param theEvent the mouse event
84 virtual void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
86 /// SLOT, that is called by key release in the viewer.
87 /// The mouse moved point is sent to the current operation to be processed.
88 /// \param theEvent the key event
89 void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
91 /// SLOT, that is called by enter key released
92 /// Set a specific type of restarting the current operation
93 void onEnterReleased();
95 /// Launches the operation from current highlighting
99 /// Returns new instance of operation object (used in createOperation for customization)
100 virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
102 /// Register validators for this module
103 virtual void registerValidators();
106 void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
108 void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
111 /// Converts mouse position to 2d coordinates.
112 /// Member myCurrentSketch has to be correctly defined
113 void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
114 double& theX, double& theY);
116 /// Breaks sequense of automatically resterted operations
117 void breakOperationSequence();
120 QString myLastOperationId;
121 FeaturePtr myLastFeature;
126 // Automatical restarting mode flag
127 RestartingMode myRestartingMode;
129 double myCurX, myCurY;
130 CompositeFeaturePtr myCurrentSketch;
131 QList<FeaturePtr> myEditingFeatures;
132 QList<AttributePtr> myEditingAttr;
134 Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
135 /// A filter which provides selection within a current document or whole PartSet
136 Handle(PartSet_GlobalFilter) myDocumentShapeFilter;