Salome HOME
8f3a8fd4e856a4b898641137c8497159a50129de
[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 theFeature the feature
39   /// \param thePresentations the list of additional presentations
40   virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature,
41                     const std::list<XGUI_ViewerPrs>& thePresentations);
42
43   /// Returns the operation sketch feature
44   /// \returns the sketch instance
45   virtual boost::shared_ptr<ModelAPI_Feature> sketch() const;
46
47   /// Processes the mouse pressed in the point
48   /// \param theEvent the mouse event
49   /// \param theView a viewer to have the viewer the eye position
50   /// \param theSelected the list of selected presentations
51   /// \param theHighlighted the list of highlighted presentations
52   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
53                             const std::list<XGUI_ViewerPrs>& theSelected,
54                             const std::list<XGUI_ViewerPrs>& theHighlighted);
55   /// Gives the current mouse point in the viewer
56   /// \param thePoint a point clicked in the viewer
57   /// \param theEvent the mouse event
58   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
59
60   /// Returns the map of the operation previews including the nested feature previews
61   /// \return the map of feature to the feature preview
62   virtual std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
63                                                                            subPreview() const;
64
65   /// Virtual method called when operation stopped - committed or aborted.
66   /// Emits a signal to hide the preview of the operation
67   virtual void stopOperation();
68
69   /// Returns whether the nested operations are enabled.
70   /// The state can depend on the operation current state.
71   /// It returns true after the sketch plane is choosen.
72   /// \return enabled state
73   virtual bool isNestedOperationsEnabled() const;
74
75 signals:
76   /// signal about the sketch plane is selected
77   /// \param theX the value in the X direction of the plane
78   /// \param theX the value in the Y direction value of the plane
79   /// \param theX the value in the Z direction of the plane
80   void planeSelected(double theX, double theY, double theZ);
81
82 protected:
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   void setSketchPlane(const TopoDS_Shape& theShape);
90
91 private:
92   std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
93 };
94
95 #endif