1 // File: PartSet_OperationFeatureCreate.h
2 // Created: 20 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #ifndef PartSet_OperationFeatureCreate_H
6 #define PartSet_OperationFeatureCreate_H
10 #include <PartSet_OperationSketchBase.h>
11 #include <PartSet_Constants.h>
15 class PartSet_FeaturePrs;
16 class GeomDataAPI_Point2D;
21 \class PartSet_OperationFeatureCreate
22 * \brief The operation for the sketch feature creation
24 class PARTSET_EXPORT PartSet_OperationFeatureCreate : 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_OperationFeatureCreate(const QString& theId, QObject* theParent,
40 FeaturePtr theSketch);
42 virtual ~PartSet_OperationFeatureCreate();
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 /// Slots which listen the mode widget activation
89 /// \param theWidget the model widget
90 virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
93 /// \brief Virtual method called when operation is started
94 /// Virtual method called when operation started (see start() method for more description)
95 /// After the parent operation body perform, set sketch feature to the created line feature
96 virtual void startOperation();
98 /// Virtual method called when operation aborted (see abort() method for more description)
99 /// Before the feature is aborted, it should be hidden from the viewer
100 virtual void abortOperation();
102 /// Virtual method called when operation stopped - committed or aborted.
103 /// Restore the multi selection state
104 virtual void stopOperation();
106 /// Virtual method called after operation committed (see commit() method for more description)
107 virtual void afterCommitOperation();
109 /// Creates an operation new feature
110 /// In addition to the default realization it appends the created line feature to
111 /// the sketch feature
112 /// \param theFlushMessage the flag whether the create message should be flushed
113 /// \returns the created feature
114 virtual FeaturePtr createFeature(const bool theFlushMessage = true);
117 ///< Set the point selection mode. Emit signal about focus change if necessary.
118 /// \param theMode a new selection mode
119 /// \param isToEmitSignal the neccessity to emit signal
120 //void setPointSelectionMode(const PartSet_SelectionMode& theMode,
121 // const bool isToEmitSignal = true);
123 /// Returns true if the active widget is the point selector widget
124 /// \return the boolean value
125 bool isPointWidget() const;
127 /// Set the point to the active widget
128 /// \param theX the horizontal coordinate
129 /// \param theY the vertical coordinate
130 /// \return true if the point is set
131 bool setWidgetPoint(double theX, double theY);
133 /// Set the feature to the active widget
134 /// \param theFeature a feature
135 /// \return true if the feature is set
136 bool setWidgetFeature(const FeaturePtr& theFeature);
139 //boost::shared_ptr<PartSet_FeaturePrs> myFeaturePrs; ///< the feature presentation
140 FeaturePtr myInitFeature; ///< the initial feature
141 FeaturePtr mySketch; ///< the sketch of the feature
142 //PartSet_SelectionMode myPointSelectionMode; ///< point selection mode
144 ModuleBase_ModelWidget* myActiveWidget; ///< the active widget