]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_Module.h
Salome HOME
Provide preselection of Line and Point for Distance
[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   /// 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);
75
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);
80   
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);
85
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);
90
91   /// SLOT, that is called by enter key released
92   /// Set a specific type of restarting the current operation
93   void onEnterReleased();
94
95   /// Launches the operation from current highlighting
96   void launchEditing();
97
98  protected:
99   /// Returns new instance of operation object (used in createOperation for customization)
100   virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
101
102   /// Register validators for this module
103   virtual void registerValidators();
104
105  private slots:
106    void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
107
108    void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
109
110  private:
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);
115
116   /// Breaks sequense of automatically resterted operations
117   void breakOperationSequence();
118
119  private:
120    QString myLastOperationId;
121    FeaturePtr myLastFeature;
122
123    bool myIsDragging;
124    bool myDragDone;
125
126    // Automatical restarting mode flag
127    RestartingMode myRestartingMode;
128
129    double myCurX, myCurY;
130    CompositeFeaturePtr myCurrentSketch;
131    QList<FeaturePtr> myEditingFeatures;
132    QList<AttributePtr> myEditingAttr;
133
134    Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
135   /// A filter which provides selection within a current document or whole PartSet
136   Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
137 };
138
139 #endif