]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_OperationSketchLine.h
Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / PartSet / PartSet_OperationSketchLine.h
1 // File:        PartSet_OperationSketchLine.h
2 // Created:     20 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef PartSet_OperationSketchLine_H
6 #define PartSet_OperationSketchLine_H
7
8 #include "PartSet.h"
9
10 #include <PartSet_OperationSketchBase.h>
11 #include <QObject>
12
13 /*!
14  \class PartSet_OperationSketchLine
15  * \brief The operation for the sketch feature creation
16 */
17 class PARTSET_EXPORT PartSet_OperationSketchLine : 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_OperationSketchLine(const QString& theId, QObject* theParent,
26                               boost::shared_ptr<ModelAPI_Feature> theSketchFeature);
27   /// Destructor
28   virtual ~PartSet_OperationSketchLine();
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 int getSelectionMode(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
38
39   /// Gives the current selected objects to be processed by the operation
40   /// \param thePoint a point clicked in the viewer
41   virtual void mouseReleased(const gp_Pnt& thePoint);
42   /// Gives the current mouse point in the viewer
43   /// \param thePoint a point clicked in the viewer
44   virtual void mouseMoved(const gp_Pnt& thePoint);
45   /// Processes the key pressed in the view
46   /// \param theKey a key value
47   virtual void keyReleased(const int theKey);
48
49 signals:
50   /// signal about the sketch plane is selected
51   /// \param theX the value in the X direction of the plane
52   /// \param theX the value in the Y direction value of the plane
53   /// \param theX the value in the Z direction of the plane
54   void localContextChanged(boost::shared_ptr<ModelAPI_Feature> theFeature,
55                            int theMode);
56
57 protected:
58   /// \brief Virtual method called when operation is started
59   /// Virtual method called when operation started (see start() method for more description)
60   /// After the parent operation body perform, set sketch feature to the created line feature
61   virtual void startOperation();
62
63   /// \brief Virtual method called when operation is started
64   /// Virtual method called when operation stopped - committed or aborted.
65   /// After the parent operation body perform, reset selection point mode of the operation
66   virtual void stopOperation();
67
68 protected:
69   /// \brief Save the point to the line.
70   /// \param thePoint the 3D point in the viewer
71   /// \param theAttribute the start or end attribute of the line
72   void setLinePoint(const gp_Pnt& thePoint, const std::string& theAttribute);
73
74   /// \brief Set the point to the line by the point of the source line.
75   /// \param theSourceFeature the feature, where the point is obtained
76   /// \param theSourceAttribute the start or end attribute of the source line
77   /// \param theAttribute the start or end attribute of the line
78   void setLinePoint(boost::shared_ptr<ModelAPI_Feature> theSourceFeature,
79                                                const std::string& theSourceAttribute,
80                                                const std::string& theAttribute);
81   /// \brief Converts the 3D point to the projected coodinates on the sketch plane.
82   /// \param thePoint the 3D point in the viewer
83   /// \param theX the X coordinate
84   /// \param theY the Y coordinate
85   void convertTo2D(const gp_Pnt& thePoint, double& theX, double& theY);
86
87 protected:
88   ///< Structure to lists the possible types of point selection modes
89   enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint, SM_None};
90
91 private:
92   boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
93   PointSelectionMode myPointSelectionMode; ///< point selection mode
94 };
95
96 #endif