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 #include <QList>
16
17 class Handle_AIS_InteractiveObject;
18
19 /*!
20  \class PartSet_OperationSketch
21  * \brief The operation for the sketch feature creation
22  */
23 class PARTSET_EXPORT PartSet_OperationSketch : public PartSet_OperationSketchBase
24 {
25 Q_OBJECT
26  public:
27   /// Returns the operation type key
28   static std::string Type()
29   {
30     return SketchPlugin_Sketch::ID();
31   }
32
33  public:
34   /// Constructor
35   /// \param theId the feature identifier
36   /// \param theParent the operation parent
37   PartSet_OperationSketch(const QString& theId, QObject* theParent);
38   /// Destructor
39   virtual ~PartSet_OperationSketch();
40
41   /// Returns True if the given operation is a Sketcher operation
42   virtual bool isGranted(ModuleBase_Operation* theOperation) const;
43
44
45   /// Returns the operation sketch feature
46   /// \returns the sketch instance
47   virtual CompositeFeaturePtr sketch() const;
48
49   /// Processes the mouse pressed in the point
50   /// \param theEvent the mouse event
51   /// \param theView a viewer to have the viewer the eye position
52   /// \param theSelected the list of selected presentations
53   /// \param theHighlighted the list of highlighted presentations
54   virtual void mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection);
55
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, ModuleBase_IViewer* theViewer,
62                              ModuleBase_ISelection* theSelection);
63
64   /// Gives the current mouse point in the viewer
65   /// \param thePoint a point clicked in the viewer
66   /// \param theEvent the mouse event
67   virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer);
68
69   /// Returns the list of the nested features
70   /// \return the list of subfeatures
71   virtual std::list<FeaturePtr> subFeatures() const;
72
73   /// Virtual method called when operation stopped - committed or aborted.
74   /// Emits a signal to hide the preview of the operation
75   virtual void stopOperation();
76
77   /// Returns whether the nested operations are enabled.
78   /// The state can depend on the operation current state.
79   /// It returns true after the sketch plane is choosen.
80   /// \return enabled state
81   virtual bool isNestedOperationsEnabled() const;
82
83   /// Returns whether the sketch plane is set
84   /// \return the boolean value whether the sketch is set
85   bool hasSketchPlane() const;
86
87   /// Set the plane to the current sketch
88   /// \param theShape the shape
89   /// \return selected direction
90   std::shared_ptr<GeomAPI_Dir> setSketchPlane(const TopoDS_Shape& theShape);
91   
92   /// Called on selection changed when the operation is active
93   virtual void selectionChanged(ModuleBase_ISelection* theSelection);
94
95   /// If operation needs to redisplay its result during operation
96   /// then this method has to return True
97   virtual bool hasPreview() const { return false; }
98
99 signals:
100   /// signal about the sketch plane is selected
101   /// \param theX the value in the X direction of the plane
102   /// \param theX the value in the Y direction value of the plane
103   /// \param theX the value in the Z direction of the plane
104   void planeSelected(double theX, double theY, double theZ);
105   // signal about the viewer fit all perform
106   void fitAllView();
107
108   /// Signal to define sketch mode
109   void launchSketch();
110
111   /// Signal to update property panel
112   void updatePropPanel();
113
114  protected:
115   /// Virtual method called when operation started (see start() method for more description)
116   /// Default impl calls corresponding slot and commits immediately.
117   virtual void startOperation();
118
119   /// Virtual method called after operation committed (see commit() method for more description)
120   virtual void afterCommitOperation();
121
122  private:
123   QList<ModuleBase_ViewerPrs> myFeatures;  ///< the features to apply the edit operation
124 };
125
126 #endif