Salome HOME
Provide selection only in plane of sketcher
[modules/shaper.git] / src / PartSet / PartSet_Module.h
1 #ifndef PartSet_Module_H
2 #define PartSet_Module_H
3
4 #include "PartSet.h"
5
6 #include <ModuleBase_IModule.h>
7 #include <ModuleBase_Definitions.h>
8 #include <ModuleBase_ViewerFilters.h>
9 #include <XGUI_Command.h>
10 #include <ModelAPI_Feature.h>
11 #include <ModelAPI_CompositeFeature.h>
12
13 #include <StdSelect_FaceFilter.hxx>
14 #include <TopoDS_Shape.hxx>
15
16 #include <QMap>
17 #include <QObject>
18
19 #include <string>
20
21 #include <memory>
22
23 class ModuleBase_Operation;
24 class ModuleBase_IViewWindow;
25
26 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
27 {
28 Q_OBJECT
29
30  public:
31   PartSet_Module(ModuleBase_IWorkshop* theWshop);
32   virtual ~PartSet_Module();
33
34   /// Creates custom widgets for property panel
35   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
36                                       Config_WidgetAPI* theWidgetApi, std::string theParentId,
37                                       QList<ModuleBase_ModelWidget*>& theModelWidgets);
38
39   /// Call back forlast tuning of property panel before operation performance
40   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
41
42   QStringList sketchOperationIdList() const;
43
44 protected slots:
45   /// Called when previous operation is finished
46   virtual void onOperationComitted(ModuleBase_Operation* theOperation);
47
48   virtual void onOperationAborted(ModuleBase_Operation* theOperation);
49
50   virtual void onOperationStarted(ModuleBase_Operation* theOperation);
51
52   virtual void onOperationStopped(ModuleBase_Operation* theOperation);
53
54   /// Called when previous operation is finished
55   virtual void onSelectionChanged();
56
57   /// SLOT, that is called by mouse press in the viewer.
58   /// The mouse released point is sent to the current operation to be processed.
59   /// \param theEvent the mouse event
60   void onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
61
62   /// SLOT, that is called by mouse release in the viewer.
63   /// The mouse released point is sent to the current operation to be processed.
64   /// \param theEvent the mouse event
65   virtual void onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
66   
67   /// SLOT, that is called by mouse move in the viewer.
68   /// The mouse moved point is sent to the current operation to be processed.
69   /// \param theEvent the mouse event
70   virtual void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
71
72   /// Launches the operation from current highlighting
73   void launchEditing();
74
75  protected:
76   /// Returns new instance of operation object (used in createOperation for customization)
77   virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
78
79   /// Register validators for this module
80   virtual void registerValidators();
81
82  private slots:
83    void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
84
85    void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
86
87  private:
88    /// Converts mouse position to 2d coordinates. 
89    /// Member myCurrentSketch has to be correctly defined
90   void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, 
91                   double& theX, double& theY);
92
93   /// Breaks sequense of automatically resterted operations
94   void breakOperationSequence();
95
96  private:
97    QString myLastOperationId;
98    FeaturePtr myLastFeature;
99
100    bool myIsDragging;
101    bool myDragDone;
102
103    // Automatical restarting mode flag
104    bool myRestartingMode;
105
106    double myCurX, myCurY;
107    CompositeFeaturePtr myCurrentSketch;
108    QList<FeaturePtr> myEditingFeatures;
109
110    Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
111 };
112
113 #endif