Salome HOME
It is a filters implementation to be set in the XML file.
[modules/shaper.git] / src / PartSet / PartSet_Module.h
1 #ifndef PartSet_Module_H
2 #define PartSet_Module_H
3
4 #include "PartSet.h"
5 #include <PartSet_Filters.h>
6
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>
13
14 #include <StdSelect_FaceFilter.hxx>
15 #include <TopoDS_Shape.hxx>
16
17 #include <QMap>
18 #include <QObject>
19
20 #include <string>
21
22 #include <memory>
23
24 class ModuleBase_Operation;
25 class ModuleBase_IViewWindow;
26
27 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
28 {
29 Q_OBJECT
30
31 /// Enumeration to specify the restart operation properties.
32 enum RestartingMode {
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
37 };
38
39 public:
40   PartSet_Module(ModuleBase_IWorkshop* theWshop);
41   virtual ~PartSet_Module();
42
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);
47
48   /// Call back forlast tuning of property panel before operation performance
49   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
50
51   QStringList sketchOperationIdList() const;
52
53 public slots:
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();
57
58 protected slots:
59   /// Called when previous operation is finished
60   virtual void onOperationComitted(ModuleBase_Operation* theOperation);
61
62   virtual void onOperationAborted(ModuleBase_Operation* theOperation);
63
64   virtual void onOperationStarted(ModuleBase_Operation* theOperation);
65
66   virtual void onOperationStopped(ModuleBase_Operation* theOperation);
67
68   /// Called when previous operation is finished
69   virtual void onSelectionChanged();
70
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);
75
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);
80   
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);
85
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);
90
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);
95
96   /// SLOT, that is called by enter key released
97   /// Set a specific type of restarting the current operation
98   void onEnterReleased();
99
100   /// Launches the operation from current highlighting
101   void launchEditing();
102
103  protected:
104   /// Returns new instance of operation object (used in createOperation for customization)
105   virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
106
107   /// Register validators for this module
108   virtual void registerValidators();
109
110   /// Register selection filters for this module
111   virtual void registerFilters();
112
113  private slots:
114    void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
115
116    void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
117
118  private:
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);
123
124   /// Breaks sequense of automatically resterted operations
125   void breakOperationSequence();
126
127  private:
128    QString myLastOperationId;
129    FeaturePtr myLastFeature;
130
131    bool myIsDragging;
132    bool myDragDone;
133
134    // Automatical restarting mode flag
135    RestartingMode myRestartingMode;
136
137    double myCurX, myCurY;
138    CompositeFeaturePtr myCurrentSketch;
139    QList<FeaturePtr> myEditingFeatures;
140    QList<AttributePtr> myEditingAttr;
141
142    Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
143   /// A filter which provides selection within a current document or whole PartSet
144   Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
145 };
146
147 #endif