Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / PartSet / PartSet_OperationEditLine.h
1 // File:        PartSet_OperationEditLine.h
2 // Created:     05 May 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef PartSet_OperationEditLine_H
6 #define PartSet_OperationEditLine_H
7
8 #include "PartSet.h"
9
10 #include <PartSet_OperationSketchBase.h>
11 #include <QObject>
12
13 class QMouseEvent;
14
15 /*!
16  \class PartSet_OperationEditLine
17  * \brief The operation for the sketch feature creation
18 */
19 class PARTSET_EXPORT PartSet_OperationEditLine : public PartSet_OperationSketchBase
20 {
21   Q_OBJECT
22 public:
23   /// Returns the operation type key
24   static std::string Type() { return "EditLine"; }
25
26 public:
27   /// Constructor
28   /// \param theId the feature identifier
29   /// \param theParent the operation parent
30   /// \param theFeature the parent feature
31   PartSet_OperationEditLine(const QString& theId, QObject* theParent,
32                             boost::shared_ptr<ModelAPI_Feature> theFeature);
33   /// Destructor
34   virtual ~PartSet_OperationEditLine();
35
36    /// Returns that this operator can be started above already running one.
37    /// The runned operation should be the sketch feature modified operation
38   virtual bool isGranted() const;
39
40   /// Returns the operation local selection mode
41   /// \param theFeature the feature object to get the selection mode
42   /// \return the selection mode
43   virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
44
45   /// Initializes some fields accorging to the feature
46   /// \param theFeature the feature
47   virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature);
48
49   /// Processes the mouse pressed in the point
50   /// \param thePoint a point clicked in the viewer
51   /// \param theEvent the mouse event
52   virtual void mousePressed(const gp_Pnt& thePoint, QMouseEvent* theEvent);
53   /// Gives the current mouse point in the viewer
54   /// \param thePoint a point clicked in the viewer
55   /// \param theEvent the mouse event
56   virtual void mouseMoved(const gp_Pnt& thePoint, QMouseEvent* theEvent);
57
58   /// Gives the current selected objects to be processed by the operation
59   /// \param theFeature the selected feature
60   /// \param theShape the selected shape
61   virtual void setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
62                            const TopoDS_Shape& theShape);
63
64 protected:
65   /// \brief Virtual method called when operation is started
66   /// Virtual method called when operation started (see start() method for more description)
67   /// After the parent operation body perform, set sketch feature to the created line feature
68   virtual void startOperation();
69
70   /// Creates an operation new feature
71   /// Returns NULL feature. This is an operation of edition, not creation.
72   /// \returns the created feature
73   virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
74
75 protected:
76   /// \brief Save the point to the line.
77   /// \param theDeltaX the delta for X coordinate is moved
78   /// \param theDeltaY the delta for Y coordinate is moved
79   /// \param theAttribute the start or end attribute of the line
80   void  moveLinePoint(double theDeltaX, double theDeltaY,
81                       const std::string& theAttribute);
82
83 private:
84   boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
85   gp_Pnt myCurPressed; ///< the current 3D point clicked or moved
86 };
87
88 #endif