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 the operation with previously created feature. It is used in sequental operations
59 virtual void initFeature(FeaturePtr theFeature);
61 /// Initialisation of operation with preliminary selection
62 /// \param theSelected the list of selected presentations
63 /// \param theHighlighted the list of highlighted presentations
64 virtual void initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
65 const std::list<XGUI_ViewerPrs>& theHighlighted);
67 /// Returns the operation sketch feature
68 /// \returns the sketch instance
69 virtual FeaturePtr sketch() const;
71 /// Gives the current selected objects to be processed by the operation
72 /// \param theEvent the mouse event
73 /// \param theView a viewer to have the viewer the eye position
74 /// \param theSelected the list of selected presentations
75 /// \param theHighlighted the list of highlighted presentations
76 virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
77 const std::list<XGUI_ViewerPrs>& theSelected,
78 const std::list<XGUI_ViewerPrs>& theHighlighted);
79 /// Gives the current mouse point in the viewer
80 /// \param thePoint a point clicked in the viewer
81 /// \param theEvent the mouse event
82 virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
83 /// Processes the key pressed in the view
84 /// \param theKey a key value
85 virtual void keyReleased(const int theKey);
87 virtual void keyReleased(std::string theName, QKeyEvent* theEvent);
90 /// Slots which listen the mode widget activation
91 /// \param theWidget the model widget
92 virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
95 /// \brief Virtual method called when operation is started
96 /// Virtual method called when operation started (see start() method for more description)
97 /// After the parent operation body perform, set sketch feature to the created line feature
98 virtual void startOperation();
100 /// Virtual method called when operation aborted (see abort() method for more description)
101 /// Before the feature is aborted, it should be hidden from the viewer
102 virtual void abortOperation();
104 /// Virtual method called when operation stopped - committed or aborted.
105 /// Restore the multi selection state
106 virtual void stopOperation();
108 /// Virtual method called after operation committed (see commit() method for more description)
109 virtual void afterCommitOperation();
111 /// Creates an operation new feature
112 /// In addition to the default realization it appends the created line feature to
113 /// the sketch feature
114 /// \param theFlushMessage the flag whether the create message should be flushed
115 /// \returns the created feature
116 virtual FeaturePtr createFeature(const bool theFlushMessage = true);
119 ///< Set the point selection mode. Emit signal about focus change if necessary.
120 /// \param theMode a new selection mode
121 /// \param isToEmitSignal the neccessity to emit signal
122 //void setPointSelectionMode(const PartSet_SelectionMode& theMode,
123 // const bool isToEmitSignal = true);
125 /// Returns true if the active widget is the point selector widget
126 /// \return the boolean value
127 bool isPointWidget() const;
129 /// Set the point to the active widget
130 /// \param theX the horizontal coordinate
131 /// \param theY the vertical coordinate
132 /// \return true if the point is set
133 bool setWidgetPoint(double theX, double theY);
135 /// Set the feature to the active widget
136 /// \param theFeature a feature
137 /// \return true if the feature is set
138 bool setWidgetFeature(const FeaturePtr& theFeature);
141 //boost::shared_ptr<PartSet_FeaturePrs> myFeaturePrs; ///< the feature presentation
142 FeaturePtr myInitFeature; ///< the initial feature
143 FeaturePtr mySketch; ///< the sketch of the feature
144 //PartSet_SelectionMode myPointSelectionMode; ///< point selection mode
146 ModuleBase_ModelWidget* myActiveWidget; ///< the active widget