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>
16 \class PartSet_OperationSketchLine
17 * \brief The operation for the sketch feature creation
19 class PARTSET_EXPORT PartSet_OperationSketchLine : public PartSet_OperationSketchBase
24 /// Returns the operation type key
25 static std::string Type() { return "SketchLine"; }
29 /// \param theId the feature identifier
30 /// \param theParent the operation parent
31 /// \param theFeature the parent feature
32 PartSet_OperationSketchLine(const QString& theId, QObject* theParent,
33 boost::shared_ptr<ModelAPI_Feature> theSketchFeature);
35 virtual ~PartSet_OperationSketchLine();
37 /// Returns that this operator can be started above already running one.
38 /// The runned operation should be the sketch feature modified operation
39 virtual bool isGranted() const;
41 /// Returns the operation local selection mode
42 /// \param theFeature the feature object to get the selection mode
43 /// \return the selection mode
44 virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
46 /// Gives the current selected objects to be processed by the operation
47 /// \param thePoint a point clicked in the viewer
48 /// \param theEvent the mouse event
49 virtual void mouseReleased(const gp_Pnt& thePoint, QMouseEvent* theEvent);
50 /// Gives the current mouse point in the viewer
51 /// \param thePoint a point clicked in the viewer
52 /// \param theEvent the mouse event
53 virtual void mouseMoved(const gp_Pnt& thePoint, QMouseEvent* theEvent);
54 /// Processes the key pressed in the view
55 /// \param theKey a key value
56 virtual void keyReleased(const int theKey);
59 /// \brief Virtual method called when operation is started
60 /// Virtual method called when operation started (see start() method for more description)
61 /// After the parent operation body perform, set sketch feature to the created line feature
62 virtual void startOperation();
64 /// \brief Virtual method called when operation is started
65 /// Virtual method called when operation stopped - committed or aborted.
66 /// After the parent operation body perform, reset selection point mode of the operation
67 virtual void stopOperation();
69 /// Creates an operation new feature
70 /// In addition to the default realization it appends the created line feature to
71 /// the sketch feature
72 /// \returns the created feature
73 virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
76 /// \brief Save the point to the line.
77 /// \param thePoint the 3D point in the viewer
78 /// \param theAttribute the start or end attribute of the line
79 void setLinePoint(const gp_Pnt& thePoint, const std::string& theAttribute);
81 /// \brief Set the point to the line by the point of the source line.
82 /// \param theSourceFeature the feature, where the point is obtained
83 /// \param theSourceAttribute the start or end attribute of the source line
84 /// \param theAttribute the start or end attribute of the line
85 void setLinePoint(boost::shared_ptr<ModelAPI_Feature> theSourceFeature,
86 const std::string& theSourceAttribute,
87 const std::string& theAttribute);
90 ///< Structure to lists the possible types of point selection modes
91 enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint, SM_None};
94 boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
95 PointSelectionMode myPointSelectionMode; ///< point selection mode