Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
[modules/shaper.git] / src / PartSet / PartSet_OperationCreateFeature.h
1 // File:        PartSet_OperationCreateFeature.h
2 // Created:     20 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef PartSet_OperationCreateFeature_H
6 #define PartSet_OperationCreateFeature_H
7
8 #include "PartSet.h"
9
10 #include <PartSet_OperationSketchBase.h>
11 #include <PartSet_Constants.h>
12
13 #include <QObject>
14
15 class PartSet_FeaturePrs;
16 class GeomDataAPI_Point2D;
17 class QMouseEvent;
18 class QKeyEvent;
19
20 /*!
21  \class PartSet_OperationCreateFeature
22  * \brief The operation for the sketch feature creation
23 */
24 class PARTSET_EXPORT PartSet_OperationCreateFeature : public PartSet_OperationSketchBase
25 {
26   Q_OBJECT
27
28 public:
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);
33
34 public:
35   /// Constructor
36   /// \param theId the feature identifier
37   /// \param theParent the operation parent
38   /// \param theSketch the parent feature
39   PartSet_OperationCreateFeature(const QString& theId, QObject* theParent,
40                                  FeaturePtr theSketch);
41   /// Destructor
42   virtual ~PartSet_OperationCreateFeature();
43
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;
47
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;
52
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;
57
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);
64
65   /// Returns the operation sketch feature
66   /// \returns the sketch instance
67   virtual FeaturePtr sketch() const;
68
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);
84
85   virtual void keyReleased(std::string theName, QKeyEvent* theEvent);
86
87 protected:
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();
92
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();
96
97   /// Virtual method called when operation stopped - committed or aborted.
98   /// Restore the multi selection state
99   virtual void stopOperation();
100
101   /// Virtual method called after operation committed (see commit() method for more description)
102   virtual void afterCommitOperation();
103
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);
110
111 protected:
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);
117
118 private:
119   boost::shared_ptr<PartSet_FeaturePrs> myFeaturePrs; ///< the feature presentation
120   FeaturePtr myInitFeature; ///< the initial feature
121   PartSet_SelectionMode myPointSelectionMode; ///< point selection mode
122 };
123
124 #endif