1 // File: PartSet_OperationEditLine.h
2 // Created: 05 May 2014
3 // Author: Natalia ERMOLAEVA
5 #ifndef PartSet_OperationEditLine_H
6 #define PartSet_OperationEditLine_H
10 #include <PartSet_OperationSketchBase.h>
14 \class PartSet_OperationEditLine
15 * \brief The operation for the sketch feature creation
17 class PARTSET_EXPORT PartSet_OperationEditLine : public PartSet_OperationSketchBase
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);
28 virtual ~PartSet_OperationEditLine();
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 std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
39 /// Initializes some fields accorging to the feature
40 /// \param theFeature the feature
41 virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature);
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);
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);
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,
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();
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();
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();
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);
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);
103 ///< Structure to lists the possible types of point selection modes
104 enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint, SM_None};
107 boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
108 //PointSelectionMode myPointSelectionMode; ///< point selection mode