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;
54 /// Realizes some functionality by an operation start
55 /// \param theOperation a started operation
56 virtual void operationStarted(ModuleBase_Operation* theOperation);
59 /// SLOT, that is called by no more widget signal emitted by property panel
60 /// Set a specific flag to restart the sketcher operation
61 void onNoMoreWidgets();
64 /// Called when previous operation is finished
65 virtual void onOperationComitted(ModuleBase_Operation* theOperation);
67 virtual void onOperationAborted(ModuleBase_Operation* theOperation);
69 virtual void onOperationStopped(ModuleBase_Operation* theOperation);
71 /// Called when previous operation is finished
72 virtual void onSelectionChanged();
74 /// SLOT, that is called by mouse press in the viewer.
75 /// \param theWnd - the window where the event happens
76 /// \param theEvent the mouse event
77 void onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
79 /// SLOT, that is called by mouse release in the viewer.
80 /// \param theWnd - the window where the event happens
81 /// \param theEvent the mouse event
82 void onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
84 /// SLOT, that is called by mouse move in the viewer.
85 /// \param theWnd - the window where the event happens
86 /// \param theEvent the mouse event
87 void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
89 /// SLOT, that is called by mouse double click in the viewer.
90 /// \param theWnd - the window where the event happens
91 /// \param theEvent the mouse event
92 void onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
94 /// SLOT, that is called by key release in the viewer.
95 /// The mouse moved point is sent to the current operation to be processed.
96 /// \param theEvent the key event
97 void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
99 /// SLOT, that is called by enter key released
100 /// Set a specific type of restarting the current operation
101 void onEnterReleased();
103 /// SLOT, that is called by the current operation filling with the preselection.
104 /// It commits the operation of it is can be committed
105 void onOperationActivatedByPreselection();
107 /// Launches the operation from current highlighting
108 void launchEditing();
111 /// Returns new instance of operation object (used in createOperation for customization)
112 virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
114 /// Register validators for this module
115 virtual void registerValidators();
117 /// Register selection filters for this module
118 virtual void registerFilters();
121 void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
123 void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
126 /// Converts mouse position to 2d coordinates.
127 /// Member myCurrentSketch has to be correctly defined
128 void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
129 double& theX, double& theY);
131 /// Breaks sequense of automatically resterted operations
132 void breakOperationSequence();
135 QString myLastOperationId;
136 FeaturePtr myLastFeature;
141 // Automatical restarting mode flag
142 RestartingMode myRestartingMode;
144 double myCurX, myCurY;
145 CompositeFeaturePtr myCurrentSketch;
146 QList<FeaturePtr> myEditingFeatures;
147 QList<AttributePtr> myEditingAttr;
149 Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
150 /// A filter which provides selection within a current document or whole PartSet
151 Handle(PartSet_GlobalFilter) myDocumentShapeFilter;