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 #include <QObject>
12
13 /*!
14  \class PartSet_OperationSketch
15  * \brief The operation for the sketch feature creation
16 */
17 class PARTSET_EXPORT PartSet_OperationSketch : public PartSet_OperationSketchBase
18 {
19   Q_OBJECT
20 public:
21   /// Returns the operation type key
22   static std::string Type() { return "Sketch"; }
23
24 public:
25   /// Constructor
26   /// \param theId the feature identifier
27   /// \param theParent the operation parent
28   PartSet_OperationSketch(const QString& theId, QObject* theParent);
29   /// Destructor
30   virtual ~PartSet_OperationSketch();
31
32   /// Returns the operation local selection mode
33   /// \param theFeature the feature object to get the selection mode
34   /// \return the selection mode
35   virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
36
37   /// Initializes some fields accorging to the feature
38   /// \param theSelected the list of selected presentations
39   /// \param theHighlighted the list of highlighted presentations
40   virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature,
41                     const std::list<XGUI_ViewerPrs>& theSelected,
42                     const std::list<XGUI_ViewerPrs>& theHighlighted);
43
44   /// Returns the operation sketch feature
45   /// \returns the sketch instance
46   virtual boost::shared_ptr<ModelAPI_Feature> 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<XGUI_ViewerPrs>& theSelected,
55                             const std::list<XGUI_ViewerPrs>& theHighlighted);
56   /// Gives the current mouse point in the viewer
57   /// \param thePoint a point clicked in the viewer
58   /// \param theEvent the mouse event
59   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
60
61   /// Returns the map of the operation previews including the nested feature previews
62   /// \return the map of feature to the feature preview
63   virtual std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
64                                                                            subPreview() const;
65
66   /// Virtual method called when operation stopped - committed or aborted.
67   /// Emits a signal to hide the preview of the operation
68   virtual void stopOperation();
69
70   /// Returns whether the nested operations are enabled.
71   /// The state can depend on the operation current state.
72   /// It returns true after the sketch plane is choosen.
73   /// \return enabled state
74   virtual bool isNestedOperationsEnabled() const;
75
76 signals:
77   /// signal about the sketch plane is selected
78   /// \param theX the value in the X direction of the plane
79   /// \param theX the value in the Y direction value of the plane
80   /// \param theX the value in the Z direction of the plane
81   void planeSelected(double theX, double theY, double theZ);
82   // signal about the viewer fit all perform
83   void fitAllView();
84
85 protected:
86   /// Virtual method called when operation started (see start() method for more description)
87   /// Default impl calls corresponding slot and commits immediately.
88   virtual void startOperation();
89
90   /// Returns whether the sketch plane is set
91   /// \return the boolean value whether the sketch is set
92   bool hasSketchPlane() const;
93
94   /// Set the plane to the current sketch
95   /// \param theShape the shape
96   void setSketchPlane(const TopoDS_Shape& theShape);
97
98 private:
99   std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
100 };
101
102 #endif