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>
16 \class PartSet_OperationEditLine
17 * \brief The operation for the sketch feature creation
19 class PARTSET_EXPORT PartSet_OperationEditLine : public PartSet_OperationSketchBase
22 /// Struct to define gp point, with the state is the point is initialized
28 /// \param thePoint the point
29 Point(gp_Pnt thePoint)
35 /// clear the initialized flag.
36 void clear() { myIsInitialized = false; }
37 /// set the point and switch on the initialized flag
38 /// \param thePoint the point
39 void setPoint(const gp_Pnt& thePoint)
41 myIsInitialized = true;
45 bool myIsInitialized; /// the state whether the point is set
46 gp_Pnt myPoint; /// the point
50 /// Returns the operation type key
51 static std::string Type() { return "EditLine"; }
55 /// \param theId the feature identifier
56 /// \param theParent the operation parent
57 /// \param theFeature the parent feature
58 PartSet_OperationEditLine(const QString& theId, QObject* theParent,
59 boost::shared_ptr<ModelAPI_Feature> theFeature);
61 virtual ~PartSet_OperationEditLine();
63 /// Returns that this operator can be started above already running one.
64 /// The runned operation should be the sketch feature modified operation
65 /// \param theOperation the previous running operation
66 virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
68 /// Returns the operation local selection mode
69 /// \param theFeature the feature object to get the selection mode
70 /// \return the selection mode
71 virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
73 /// Initializes some fields accorging to the feature
74 /// \param theFeature the feature
75 /// \param theSelected the list of selected presentations
76 /// \param theHighlighted the list of highlighted presentations
77 virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature,
78 const std::list<XGUI_ViewerPrs>& theSelected,
79 const std::list<XGUI_ViewerPrs>& theHighlighted);
81 /// Returns the operation sketch feature
82 /// \returns the sketch instance
83 virtual boost::shared_ptr<ModelAPI_Feature> sketch() const;
85 /// Processes the mouse pressed in the point
86 /// \param theEvent the mouse event
87 /// \param theView a viewer to have the viewer the eye position
88 /// \param theSelected the list of selected presentations
89 /// \param theHighlighted the list of highlighted presentations
90 virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
91 const std::list<XGUI_ViewerPrs>& theSelected,
92 const std::list<XGUI_ViewerPrs>& theHighlighted);
93 /// Gives the current mouse point in the viewer
94 /// \param theEvent the mouse event
95 /// \param theView a viewer to have the viewer the eye position
96 virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
97 /// Gives the current selected objects to be processed by the operation
98 /// \param thePoint a point clicked in the viewer
99 /// \param theEvent the mouse event
100 /// \param theSelected the list of selected presentations
101 /// \param theHighlighted the list of highlighted presentations
102 virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
103 const std::list<XGUI_ViewerPrs>& theSelected,
104 const std::list<XGUI_ViewerPrs>& theHighlighted);
106 /// \brief Virtual method called when operation is started
107 /// Virtual method called when operation started (see start() method for more description)
108 /// Switch off the multi selection state
109 virtual void startOperation();
111 /// Virtual method called when operation stopped - committed or aborted.
112 /// Restore the multi selection state
113 virtual void stopOperation();
115 /// Creates an operation new feature
116 /// Returns NULL feature. This is an operation of edition, not creation.
117 /// \param theFlushMessage the flag whether the create message should be flushed
118 /// \returns the created feature
119 virtual boost::shared_ptr<ModelAPI_Feature> createFeature(const bool theFlushMessage = true);
122 /// Emits a signal about the selection blocking. Emits a signal to change the selection.
123 /// If the block is true, the signal clear selection, otherwise if restore selection flag allows,
124 /// the internal operation features are to be selected
125 /// \param isBlocked the state whether the operation is blocked or unblocked
126 /// \param isRestoreSelection the state whether the selected objects should be reselected
127 void blockSelection(bool isBlocked, const bool isRestoreSelection = true);
129 /// \brief Save the point to the line.
130 /// \param theFeature the source feature
131 /// \param theDeltaX the delta for X coordinate is moved
132 /// \param theDeltaY the delta for Y coordinate is moved
133 /// \param theAttribute the start or end attribute of the line
134 void moveLinePoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
135 double theDeltaX, double theDeltaY,
136 const std::string& theAttribute);
137 /// Sends the features
141 boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
142 std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
143 Point myCurPoint; ///< the current 3D point clicked or moved
144 gp_Pnt myCurPressed; ///< the current 3D point clicked or moved