1 // File: PartSet_OperationSketchLine.h
2 // Created: 20 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #ifndef PartSet_OperationSketchLine_H
6 #define PartSet_OperationSketchLine_H
10 #include <PartSet_OperationSketchBase.h>
14 \class PartSet_OperationSketchLine
15 * \brief The operation for the sketch feature creation
17 class PARTSET_EXPORT PartSet_OperationSketchLine : public PartSet_OperationSketchBase
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);
28 virtual ~PartSet_OperationSketchLine();
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;
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;
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);
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,
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();
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();
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);
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);
88 ///< Structure to lists the possible types of point selection modes
89 enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint, SM_None};
92 boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
93 PointSelectionMode myPointSelectionMode; ///< point selection mode