Salome HOME
Merge branch 'master' of newgeom:newgeom
[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 sketch feature
45   /// \returns the sketch instance
46   virtual CompositeFeaturePtr sketch() const;
47
48   /// Processes the mouse pressed in the point
49   /// \param theEvent the mouse event
50   /// \param theView a viewer to have the viewer the eye position
51   /// \param theSelected the list of selected presentations
52   /// \param theHighlighted the list of highlighted presentations
53   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
54                             const std::list<ModuleBase_ViewerPrs>& theSelected,
55                             const std::list<ModuleBase_ViewerPrs>& theHighlighted);
56   /// Processes the mouse release in the point
57   /// \param theEvent the mouse event
58   /// \param theView a viewer to have the viewer the eye position
59   /// \param theSelected the list of selected presentations
60   /// \param theHighlighted the list of highlighted presentations
61   virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
62                              const std::list<ModuleBase_ViewerPrs>& theSelected,
63                              const std::list<ModuleBase_ViewerPrs>& theHighlighted);
64
65   /// Gives the current mouse point in the viewer
66   /// \param thePoint a point clicked in the viewer
67   /// \param theEvent the mouse event
68   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
69
70   /// Returns the list of the nested features
71   /// \return the list of subfeatures
72   virtual std::list<FeaturePtr> subFeatures() const;
73
74   /// Virtual method called when operation stopped - committed or aborted.
75   /// Emits a signal to hide the preview of the operation
76   virtual void stopOperation();
77
78   /// Returns whether the nested operations are enabled.
79   /// The state can depend on the operation current state.
80   /// It returns true after the sketch plane is choosen.
81   /// \return enabled state
82   virtual bool isNestedOperationsEnabled() const;
83
84   /// Returns whether the sketch plane is set
85   /// \return the boolean value whether the sketch is set
86   bool hasSketchPlane() const;
87
88   /// Set the plane to the current sketch
89   /// \param theShape the shape
90   void setSketchPlane(const TopoDS_Shape& theShape);
91
92   /// If operation needs to redisplay its result during operation
93   /// then this method has to return True
94   virtual bool hasPreview() const { return false; }
95
96 signals:
97   /// signal about the sketch plane is selected
98   /// \param theX the value in the X direction of the plane
99   /// \param theX the value in the Y direction value of the plane
100   /// \param theX the value in the Z direction of the plane
101   void planeSelected(double theX, double theY, double theZ);
102   // signal about the viewer fit all perform
103   void fitAllView();
104
105  protected:
106   /// Virtual method called when operation started (see start() method for more description)
107   /// Default impl calls corresponding slot and commits immediately.
108   virtual void startOperation();
109
110   /// Virtual method called after operation committed (see commit() method for more description)
111   virtual void afterCommitOperation();
112
113  private:
114   std::list<ModuleBase_ViewerPrs> myFeatures;  ///< the features to apply the edit operation
115 };
116
117 #endif