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