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