Salome HOME
Issue #263 Check validity of the feature when filling it with pre-selection
[modules/shaper.git] / src / PartSet / PartSet_OperationFeatureCreate.h
1 // File:        PartSet_OperationFeatureCreate.h
2 // Created:     20 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef PartSet_OperationFeatureCreate_H
6 #define PartSet_OperationFeatureCreate_H
7
8 #include "PartSet.h"
9
10 #include <PartSet_OperationFeatureBase.h>
11 #include <PartSet_Constants.h>
12
13 #include <QObject>
14
15 class GeomDataAPI_Point2D;
16 class QMouseEvent;
17 class QKeyEvent;
18
19 /*!
20  \class PartSet_OperationFeatureCreate
21  * \brief The operation for the sketch feature creation
22  */
23 class PARTSET_EXPORT PartSet_OperationFeatureCreate : public PartSet_OperationFeatureBase
24 {
25 Q_OBJECT
26
27  public:
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);
32
33   /// Constructor
34   /// \param theId the feature identifier
35   /// \param theParent the operation parent
36   /// \param theSketch the parent feature
37   PartSet_OperationFeatureCreate(
38     const QString& theId, QObject* theParent, CompositeFeaturePtr theSketch);
39   /// Destructor
40   virtual ~PartSet_OperationFeatureCreate();
41
42   /// Gives the current mouse point in the viewer
43   /// \param thePoint a point clicked in the viewer
44   /// \param theEvent the mouse event
45   virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer);
46
47   /// Gives the current selected objects to be processed by the operation
48   /// \param theEvent the mouse event
49   /// \param theView a viewer to have the viewer the eye position
50   /// \param theSelected the list of selected presentations
51   /// \param theHighlighted the list of highlighted presentations
52   virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
53                              ModuleBase_ISelection* theSelection);
54   /// Processes the key pressed in the view
55   /// \param theKey a key value
56   virtual void keyReleased(const int theKey);
57
58   /// Initializes the operation with previously created feature. It is used in sequental operations
59   void initFeature(FeaturePtr theFeature) { myInitFeature = theFeature; }
60
61  public slots:
62   /// Slots which listen the mode widget activation
63   /// \param theWidget the model widget
64   virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
65
66  protected:
67   /// \brief Virtual method called when operation is started
68   /// Virtual method called when operation started (see start() method for more description)
69   /// After the parent operation body perform, set sketch feature to the created line feature
70   virtual void startOperation();
71
72   /// Virtual method called when operation aborted (see abort() method for more description)
73   /// Before the feature is aborted, it should be hidden from the viewer
74   virtual void abortOperation();
75
76   /// Virtual method called when operation stopped - committed or aborted.
77   /// Restore the multi selection state
78   virtual void stopOperation();
79
80   /// Virtual method called after operation committed (see commit() method for more description)
81   virtual void afterCommitOperation();
82
83   /// Creates an operation new feature
84   /// In addition to the default realization it appends the created line feature to
85   /// the sketch feature
86   /// \param theFlushMessage the flag whether the create message should be flushed
87   /// \returns the created feature
88   virtual FeaturePtr createFeature(const bool theFlushMessage = true,
89     CompositeFeaturePtr theCompositeFeature = CompositeFeaturePtr());
90
91 protected:
92   /// Feature of previous operation (for sequintal operations)
93   FeaturePtr myInitFeature;
94 };
95
96 #endif