]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_OperationSketchLine.h
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
[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   /// \return the selection mode
36   virtual int getSelectionMode() const;
37
38   /// Gives the current selected objects to be processed by the operation
39   /// \param thePoint a point clicked in the viewer
40   virtual void mouseReleased(const gp_Pnt& thePoint);
41   /// Gives the current mouse point in the viewer
42   /// \param thePoint a point clicked in the viewer
43   virtual void mouseMoved(const gp_Pnt& thePoint);
44
45 protected:
46   /// \brief Virtual method called when operation is started
47   /// Virtual method called when operation started (see start() method for more description)
48   /// After the parent operation body perform, set sketch feature to the created line feature
49   virtual void startOperation();
50
51   /// \brief Virtual method called when operation is started
52   /// Virtual method called when operation stopped - committed or aborted.
53   /// After the parent operation body perform, reset selection point mode of the operation
54   virtual void stopOperation();
55
56 protected:
57   /// \brief Save the point to the line.
58   /// \param thePoint the 3D point in the viewer
59   /// \param theAttribute the start or end attribute of the line
60   void setLinePoint(const gp_Pnt& thePoint, const std::string& theAttribute);
61
62   /// \brief Converts the 3D point to the projected coodinates on the sketch plane.
63   /// \param thePoint the 3D point in the viewer
64   /// \param theX the X coordinate
65   /// \param theY the Y coordinate
66   void convertTo2D(const gp_Pnt& thePoint, double& theX, double& theY);
67
68 protected:
69   ///< Structure to lists the possible types of point selection modes
70   enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint, SM_None};
71
72 private:
73   boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
74   PointSelectionMode myPointSelectionMode; ///< point selection mode
75 };
76
77 #endif