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_EditLine;
16 class PartSet_FeaturePrs;
17 class GeomDataAPI_Point2D;
22 \class PartSet_OperationCreateConstraint
23 * \brief The operation for the sketch feature creation
25 class PARTSET_EXPORT PartSet_OperationCreateConstraint : public PartSet_OperationSketchBase
30 /// Returns true if the feature with the given kind can be created by this operation
31 /// \param theId the feature kind
32 /// \return the boolean result
33 static bool canProcessKind(const std::string& theId);
37 /// \param theId the feature identifier
38 /// \param theParent the operation parent
39 /// \param theSketch the parent feature
40 PartSet_OperationCreateConstraint(const QString& theId, QObject* theParent,
41 FeaturePtr theSketch);
43 virtual ~PartSet_OperationCreateConstraint();
45 /// Verifies whether this operator can be commited.
46 /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
47 virtual bool canBeCommitted() const;
49 /// Returns that this operator can be started above already running one.
50 /// The runned operation should be the sketch feature modified operation
51 /// \param theOperation the previous running operation
52 virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
54 /// Returns the operation local selection mode
55 /// \param theFeature the feature object to get the selection mode
56 /// \return the selection mode
57 virtual std::list<int> getSelectionModes(FeaturePtr theFeature) const;
59 /// Initializes some fields accorging to the feature
60 /// \param theSelected the list of selected presentations
61 /// \param theHighlighted the list of highlighted presentations
62 virtual void init(FeaturePtr theFeature,
63 const std::list<XGUI_ViewerPrs>& theSelected,
64 const std::list<XGUI_ViewerPrs>& theHighlighted);
66 /// Returns the operation sketch feature
67 /// \returns the sketch instance
68 virtual FeaturePtr sketch() const;
70 /// Gives the current selected objects to be processed by the operation
71 /// \param theEvent the mouse event
72 /// \param theView a viewer to have the viewer the eye position
73 /// \param theSelected the list of selected presentations
74 /// \param theHighlighted the list of highlighted presentations
75 virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
76 const std::list<XGUI_ViewerPrs>& theSelected,
77 const std::list<XGUI_ViewerPrs>& theHighlighted);
78 /// Gives the current mouse point in the viewer
79 /// \param thePoint a point clicked in the viewer
80 /// \param theEvent the mouse event
81 virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
82 /// Processes the key pressed in the view
83 /// \param theKey a key value
84 virtual void keyReleased(const int theKey);
86 virtual void keyReleased(std::string theName, QKeyEvent* theEvent);
89 /// \brief Virtual method called when operation is started
90 /// Virtual method called when operation started (see start() method for more description)
91 /// After the parent operation body perform, set sketch feature to the created line feature
92 virtual void startOperation();
94 /// Virtual method called when operation aborted (see abort() method for more description)
95 /// Before the feature is aborted, it should be hidden from the viewer
96 virtual void abortOperation();
98 /// Virtual method called when operation stopped - committed or aborted.
99 /// Restore the multi selection state
100 virtual void stopOperation();
102 /// Virtual method called after operation committed (see commit() method for more description)
103 virtual void afterCommitOperation();
105 /// Creates an operation new feature
106 /// In addition to the default realization it appends the created line feature to
107 /// the sketch feature
108 /// \param theFlushMessage the flag whether the create message should be flushed
109 /// \returns the created feature
110 virtual FeaturePtr createFeature(const bool theFlushMessage = true);
113 ///< Set the point selection mode. Emit signal about focus change if necessary.
114 /// \param theMode a new selection mode
115 /// \param isToEmitSignal the neccessity to emit signal
116 void setPointSelectionMode(const PartSet_SelectionMode& theMode,
117 const bool isToEmitSignal = true);
119 /// Show the value editor
120 /// \param theEvent to get the mouse cursor position
121 /// \param theValue an editor value
122 void showEditor(QMouseEvent* theEvent, double theValue);
125 /// SLOT, that listens the value edited signal and set the new value to the feature
126 /// \param theValue the editor value
127 void onEditStopped(double theValue);
130 boost::shared_ptr<PartSet_FeaturePrs> myFeaturePrs; ///< the feature presentation
131 FeaturePtr myInitFeature; ///< the initial feature
132 PartSet_SelectionMode myPointSelectionMode; ///< point selection mode
133 PartSet_EditLine* myEditor; ///< the constraint value editor