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