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() { return SKETCH_KIND; }
28
29 public:
30   /// Constructor
31   /// \param theId the feature identifier
32   /// \param theParent the operation parent
33   PartSet_OperationSketch(const QString& theId, QObject* theParent);
34   /// Destructor
35   virtual ~PartSet_OperationSketch();
36
37   /// Returns the operation local selection mode
38   /// \param theFeature the feature object to get the selection mode
39   /// \return the selection mode
40   virtual std::list<int> getSelectionModes(FeaturePtr theFeature) const;
41
42   /// Initializes some fields accorging to the feature
43   /// \param theSelected the list of selected presentations
44   /// \param theHighlighted the list of highlighted presentations
45   virtual void init(FeaturePtr theFeature,
46                     const std::list<XGUI_ViewerPrs>& theSelected,
47                     const std::list<XGUI_ViewerPrs>& theHighlighted);
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<XGUI_ViewerPrs>& theSelected,
60                             const std::list<XGUI_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<XGUI_ViewerPrs>& theSelected,
68                              const std::list<XGUI_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 map of the operation previews including the nested feature previews
76   /// \return the map of feature to the feature preview
77   virtual std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >
78                                                                            subPreview() const;
79
80   /// Virtual method called when operation stopped - committed or aborted.
81   /// Emits a signal to hide the preview of the operation
82   virtual void stopOperation();
83
84   /// Returns whether the nested operations are enabled.
85   /// The state can depend on the operation current state.
86   /// It returns true after the sketch plane is choosen.
87   /// \return enabled state
88   virtual bool isNestedOperationsEnabled() const;
89
90 signals:
91   /// signal about the sketch plane is selected
92   /// \param theX the value in the X direction of the plane
93   /// \param theX the value in the Y direction value of the plane
94   /// \param theX the value in the Z direction of the plane
95   void planeSelected(double theX, double theY, double theZ);
96   // signal about the viewer fit all perform
97   void fitAllView();
98
99 protected:
100   /// Virtual method called when operation started (see start() method for more description)
101   /// Default impl calls corresponding slot and commits immediately.
102   virtual void startOperation();
103
104   /// Returns whether the sketch plane is set
105   /// \return the boolean value whether the sketch is set
106   bool hasSketchPlane() const;
107
108   /// Set the plane to the current sketch
109   /// \param theShape the shape
110   void setSketchPlane(const TopoDS_Shape& theShape);
111
112   /// Returns the operation type, which is feature or constraint edit opeation
113   /// \param theFeature a feature instance
114   std::string getOperationType(FeaturePtr theFeature);
115
116 private:
117   std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
118 };
119
120 #endif