1 // File: PartSet_OperationCreateConstraint.h
2 // Created: 20 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #ifndef PartSet_OperationCreateConstraint_H
6 #define PartSet_OperationCreateConstraint_H
10 #include <PartSet_OperationSketchBase.h>
11 #include <PartSet_Constants.h>
15 class PartSet_FeaturePrs;
16 class GeomDataAPI_Point2D;
21 \class PartSet_OperationCreateConstraint
22 * \brief The operation for the sketch feature creation
24 class PARTSET_EXPORT PartSet_OperationCreateConstraint : public PartSet_OperationSketchBase
29 /// Returns true if the feature with the given kind can be created by this operation
30 /// \param theId the feature kind
31 /// \return the boolean result
32 static bool canProcessKind(const std::string& theId);
36 /// \param theId the feature identifier
37 /// \param theParent the operation parent
38 /// \param theSketch the parent feature
39 PartSet_OperationCreateConstraint(const QString& theId, QObject* theParent,
40 FeaturePtr theSketch);
42 virtual ~PartSet_OperationCreateConstraint();
44 /// Verifies whether this operator can be commited.
45 /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
46 virtual bool canBeCommitted() const;
48 /// Returns that this operator can be started above already running one.
49 /// The runned operation should be the sketch feature modified operation
50 /// \param theOperation the previous running operation
51 virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
53 /// Returns the operation local selection mode
54 /// \param theFeature the feature object to get the selection mode
55 /// \return the selection mode
56 virtual std::list<int> getSelectionModes(FeaturePtr theFeature) const;
58 /// Initializes some fields accorging to the feature
59 /// \param theSelected the list of selected presentations
60 /// \param theHighlighted the list of highlighted presentations
61 virtual void init(FeaturePtr theFeature,
62 const std::list<XGUI_ViewerPrs>& theSelected,
63 const std::list<XGUI_ViewerPrs>& theHighlighted);
65 /// Returns the operation sketch feature
66 /// \returns the sketch instance
67 virtual FeaturePtr sketch() const;
69 /// Gives the current selected objects to be processed by the operation
70 /// \param theEvent the mouse event
71 /// \param theView a viewer to have the viewer the eye position
72 /// \param theSelected the list of selected presentations
73 /// \param theHighlighted the list of highlighted presentations
74 virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
75 const std::list<XGUI_ViewerPrs>& theSelected,
76 const std::list<XGUI_ViewerPrs>& theHighlighted);
77 /// Gives the current mouse point in the viewer
78 /// \param thePoint a point clicked in the viewer
79 /// \param theEvent the mouse event
80 virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
81 /// Processes the key pressed in the view
82 /// \param theKey a key value
83 virtual void keyReleased(const int theKey);
85 virtual void keyReleased(std::string theName, QKeyEvent* theEvent);
88 /// \brief Virtual method called when operation is started
89 /// Virtual method called when operation started (see start() method for more description)
90 /// After the parent operation body perform, set sketch feature to the created line feature
91 virtual void startOperation();
93 /// Virtual method called when operation aborted (see abort() method for more description)
94 /// Before the feature is aborted, it should be hidden from the viewer
95 virtual void abortOperation();
97 /// Virtual method called when operation stopped - committed or aborted.
98 /// Restore the multi selection state
99 virtual void stopOperation();
101 /// Virtual method called after operation committed (see commit() method for more description)
102 virtual void afterCommitOperation();
104 /// Creates an operation new feature
105 /// In addition to the default realization it appends the created line feature to
106 /// the sketch feature
107 /// \param theFlushMessage the flag whether the create message should be flushed
108 /// \returns the created feature
109 virtual FeaturePtr createFeature(const bool theFlushMessage = true);
112 ///< Set the point selection mode. Emit signal about focus change if necessary.
113 /// \param theMode a new selection mode
114 /// \param isToEmitSignal the neccessity to emit signal
115 void setPointSelectionMode(const PartSet_SelectionMode& theMode,
116 const bool isToEmitSignal = true);
118 /// Show the value editor
119 /// \param theEvent to get the mouse cursor position
120 /// \param theValue an editor value
121 void showEditor(QMouseEvent* theEvent, double theValue);
124 /// SLOT, that listens the value edited signal and set the new value to the feature
125 /// \param theValue the editor value
126 void onEditStopped(double theValue);
129 boost::shared_ptr<PartSet_FeaturePrs> myFeaturePrs; ///< the feature presentation
130 FeaturePtr myInitFeature; ///< the initial feature
131 PartSet_SelectionMode myPointSelectionMode; ///< point selection mode