]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_OperationEditLine.h
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 /*!
14  \class PartSet_OperationEditLine
15  * \brief The operation for the sketch feature creation
16 */
17 class PARTSET_EXPORT PartSet_OperationEditLine : public PartSet_OperationSketchBase
18 {
19   Q_OBJECT
20 public:
21   /// Constructor
22   /// \param theId the feature identifier
23   /// \param theParent the operation parent
24   /// \param theFeature the parent feature
25   PartSet_OperationEditLine(const QString& theId, QObject* theParent,
26                             boost::shared_ptr<ModelAPI_Feature> theFeature);
27   /// Destructor
28   virtual ~PartSet_OperationEditLine();
29
30    /// Returns that this operator can be started above already running one.
31    /// The runned operation should be the sketch feature modified operation
32   virtual bool isGranted() const;
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 theFeature the feature
41   virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature);
42
43   /// Gives the current selected objects to be processed by the operation
44   /// \param thePoint a point clicked in the viewer
45   virtual void mouseReleased(const gp_Pnt& thePoint);
46   /// Gives the current mouse point in the viewer
47   /// \param thePoint a point clicked in the viewer
48   virtual void mouseMoved(const gp_Pnt& thePoint);
49   /// Processes the key pressed in the view
50   /// \param theKey a key value
51   virtual void keyReleased(const int theKey);
52
53   /// Gives the current selected objects to be processed by the operation
54   /// \param theFeature the selected feature
55   /// \param theShape the selected shape
56   virtual void setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
57                            const TopoDS_Shape& theShape);
58
59 signals:
60   /// signal about the sketch plane is selected
61   /// \param theX the value in the X direction of the plane
62   /// \param theX the value in the Y direction value of the plane
63   /// \param theX the value in the Z direction of the plane
64   void localContextChanged(boost::shared_ptr<ModelAPI_Feature> theFeature,
65                            int theMode);
66
67 protected:
68   /// \brief Virtual method called when operation is started
69   /// Virtual method called when operation started (see start() method for more description)
70   /// After the parent operation body perform, set sketch feature to the created line feature
71   virtual void startOperation();
72
73   /// \brief Virtual method called when operation is started
74   /// Virtual method called when operation stopped - committed or aborted.
75   /// After the parent operation body perform, reset selection point mode of the operation
76   virtual void stopOperation();
77
78   /// Creates an operation new feature
79   /// Returns NULL feature. This is an operation of edition, not creation.
80   /// \returns the created feature
81   virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
82
83 protected:
84   /// \brief Save the point to the line.
85   /// \param thePoint the 3D point in the viewer
86   /// \param theAttribute the start or end attribute of the line
87   void setLinePoint(const gp_Pnt& thePoint, const std::string& theAttribute);
88
89   /// \brief Set the point to the line by the point of the source line.
90   /// \param theSourceFeature the feature, where the point is obtained
91   /// \param theSourceAttribute the start or end attribute of the source line
92   /// \param theAttribute the start or end attribute of the line
93   void setLinePoint(boost::shared_ptr<ModelAPI_Feature> theSourceFeature,
94                                                const std::string& theSourceAttribute,
95                                                const std::string& theAttribute);
96   /// \brief Converts the 3D point to the projected coodinates on the sketch plane.
97   /// \param thePoint the 3D point in the viewer
98   /// \param theX the X coordinate
99   /// \param theY the Y coordinate
100   void convertTo2D(const gp_Pnt& thePoint, double& theX, double& theY);
101
102 protected:
103   ///< Structure to lists the possible types of point selection modes
104   enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint, SM_None};
105
106 private:
107   boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
108   //PointSelectionMode myPointSelectionMode; ///< point selection mode
109 };
110
111 #endif