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 GeomDataAPI_Point2D;
20 \class PartSet_OperationFeatureCreate
21 * \brief The operation for the sketch feature creation
23 class PARTSET_EXPORT PartSet_OperationFeatureCreate : public PartSet_OperationSketchBase
28 /// Returns true if the feature with the given kind can be created by this operation
29 /// \param theId the feature kind
30 /// \return the boolean result
31 static bool canProcessKind(const std::string& theId);
35 /// \param theId the feature identifier
36 /// \param theParent the operation parent
37 /// \param theSketch the parent feature
38 PartSet_OperationFeatureCreate(const QString& theId, QObject* theParent,
39 FeaturePtr theSketch);
41 virtual ~PartSet_OperationFeatureCreate();
43 /// Returns that this operator can be started above already running one.
44 /// The runned operation should be the sketch feature modified operation
45 /// \param theOperation the previous running operation
46 virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
48 /// Returns the operation local selection mode
49 /// \param theFeature the feature object to get the selection mode
50 /// \return the selection mode
51 virtual std::list<int> getSelectionModes(ObjectPtr theFeature) const;
53 /// Initializes the operation with previously created feature. It is used in sequental operations
54 virtual void initFeature(FeaturePtr theFeature);
56 /// Initialisation of operation with preliminary selection
57 /// \param theSelected the list of selected presentations
58 /// \param theHighlighted the list of highlighted presentations
59 virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
60 const std::list<ModuleBase_ViewerPrs>& theHighlighted);
62 /// Returns the operation sketch feature
63 /// \returns the sketch instance
64 virtual FeaturePtr sketch() const;
66 /// Gives the current selected objects to be processed by the operation
67 /// \param theEvent the mouse event
68 /// \param theView a viewer to have the viewer the eye position
69 /// \param theSelected the list of selected presentations
70 /// \param theHighlighted the list of highlighted presentations
71 virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
72 const std::list<ModuleBase_ViewerPrs>& theSelected,
73 const std::list<ModuleBase_ViewerPrs>& theHighlighted);
74 /// Gives the current mouse point in the viewer
75 /// \param thePoint a point clicked in the viewer
76 /// \param theEvent the mouse event
77 virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
78 /// Processes the key pressed in the view
79 /// \param theKey a key value
80 virtual void keyReleased(const int theKey);
82 virtual void keyReleased(std::string theName, QKeyEvent* theEvent);
85 /// Slots which listen the mode widget activation
86 /// \param theWidget the model widget
87 virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
90 /// \brief Virtual method called when operation is started
91 /// Virtual method called when operation started (see start() method for more description)
92 /// After the parent operation body perform, set sketch feature to the created line feature
93 virtual void startOperation();
95 /// Virtual method called when operation aborted (see abort() method for more description)
96 /// Before the feature is aborted, it should be hidden from the viewer
97 virtual void abortOperation();
99 /// Virtual method called when operation stopped - committed or aborted.
100 /// Restore the multi selection state
101 virtual void stopOperation();
103 /// Virtual method called after operation committed (see commit() method for more description)
104 virtual void afterCommitOperation();
106 /// Creates an operation new feature
107 /// In addition to the default realization it appends the created line feature to
108 /// the sketch feature
109 /// \param theFlushMessage the flag whether the create message should be flushed
110 /// \returns the created feature
111 virtual FeaturePtr createFeature(const bool theFlushMessage = true);
113 /// Verifies whether this operator can be commited.
114 /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
115 virtual bool canBeCommitted() const;
118 /// Set value to the active widget
119 /// \param theFeature the feature
120 /// \param theX the horizontal coordinate
121 /// \param theY the vertical coordinate
122 /// \return true if the point is set
123 bool setWidgetValue(ObjectPtr theFeature, double theX, double theY);
126 FeaturePtr myInitFeature; ///< the initial feature
127 FeaturePtr mySketch; ///< the sketch of the feature
129 ModuleBase_ModelWidget* myActiveWidget; ///< the active widget
131 std::list<ModuleBase_ViewerPrs> myPreSelection;