Salome HOME
94ddf02d91e173e034c2eedb3edc0354be737454
[modules/shaper.git] / src / PartSet / PartSet_OperationSketch.h
1 // File:        PartSet_OperationSketch.h
2 // Created:     20 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef PartSet_OperationSketch_H
6 #define PartSet_OperationSketch_H
7
8 #include "PartSet.h"
9
10 #include <PartSet_OperationSketchBase.h>
11
12 #include <SketchPlugin_Sketch.h>
13
14 #include <QObject>
15
16 class Handle_AIS_InteractiveObject;
17
18 /*!
19  \class PartSet_OperationSketch
20  * \brief The operation for the sketch feature creation
21  */
22 class PARTSET_EXPORT PartSet_OperationSketch : public PartSet_OperationSketchBase
23 {
24 Q_OBJECT
25  public:
26   /// Returns the operation type key
27   static std::string Type()
28   {
29     return SketchPlugin_Sketch::ID();
30   }
31
32  public:
33   /// Constructor
34   /// \param theId the feature identifier
35   /// \param theParent the operation parent
36   PartSet_OperationSketch(const QString& theId, QObject* theParent);
37   /// Destructor
38   virtual ~PartSet_OperationSketch();
39
40   /// Returns True if the given operation is a Sketcher operation
41   virtual bool isGranted(ModuleBase_Operation* theOperation) const;
42
43
44   /// Returns the operation local selection mode
45   /// \param theFeature the feature object to get the selection mode
46   /// \return the selection mode
47   virtual std::list<int> getSelectionModes(ObjectPtr theFeature) const;
48
49   /// Returns the operation sketch feature
50   /// \returns the sketch instance
51   virtual FeaturePtr sketch() const;
52
53   /// Processes the mouse pressed in the point
54   /// \param theEvent the mouse event
55   /// \param theView a viewer to have the viewer the eye position
56   /// \param theSelected the list of selected presentations
57   /// \param theHighlighted the list of highlighted presentations
58   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
59                             const std::list<ModuleBase_ViewerPrs>& theSelected,
60                             const std::list<ModuleBase_ViewerPrs>& theHighlighted);
61   /// Processes the mouse release in the point
62   /// \param theEvent the mouse event
63   /// \param theView a viewer to have the viewer the eye position
64   /// \param theSelected the list of selected presentations
65   /// \param theHighlighted the list of highlighted presentations
66   virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
67                              const std::list<ModuleBase_ViewerPrs>& theSelected,
68                              const std::list<ModuleBase_ViewerPrs>& theHighlighted);
69
70   /// Gives the current mouse point in the viewer
71   /// \param thePoint a point clicked in the viewer
72   /// \param theEvent the mouse event
73   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
74
75   /// Returns the list of the nested features
76   /// \return the list of subfeatures
77   virtual std::list<FeaturePtr> subFeatures() const;
78
79   /// Virtual method called when operation stopped - committed or aborted.
80   /// Emits a signal to hide the preview of the operation
81   virtual void stopOperation();
82
83   /// Returns whether the nested operations are enabled.
84   /// The state can depend on the operation current state.
85   /// It returns true after the sketch plane is choosen.
86   /// \return enabled state
87   virtual bool isNestedOperationsEnabled() const;
88
89   /// Returns whether the sketch plane is set
90   /// \return the boolean value whether the sketch is set
91   bool hasSketchPlane() const;
92
93   /// Set the plane to the current sketch
94   /// \param theShape the shape
95   void setSketchPlane(const TopoDS_Shape& theShape);
96
97   /// If operation needs to redisplay its result during operation
98   /// then this method has to return True
99   virtual bool hasPreview() const { return false; }
100
101 signals:
102   /// signal about the sketch plane is selected
103   /// \param theX the value in the X direction of the plane
104   /// \param theX the value in the Y direction value of the plane
105   /// \param theX the value in the Z direction of the plane
106   void planeSelected(double theX, double theY, double theZ);
107   // signal about the viewer fit all perform
108   void fitAllView();
109
110  protected:
111   /// Virtual method called when operation started (see start() method for more description)
112   /// Default impl calls corresponding slot and commits immediately.
113   virtual void startOperation();
114
115  private:
116   std::list<ModuleBase_ViewerPrs> myFeatures;  ///< the features to apply the edit operation
117 };
118
119 #endif