Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / PartSet / PartSet_OperationFeatureEdit.h
1 // File:        PartSet_OperationFeatureEdit.h
2 // Created:     05 May 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef PartSet_OperationFeatureEdit_H
6 #define PartSet_OperationFeatureEdit_H
7
8 #include "PartSet.h"
9
10 #include <PartSet_OperationFeatureBase.h>
11 #include <QObject>
12
13 class QMouseEvent;
14
15 /*!
16  \class PartSet_OperationFeatureEdit
17  * \brief The operation for the sketch feature creation
18  */
19 class PARTSET_EXPORT PartSet_OperationFeatureEdit : public PartSet_OperationFeatureBase
20 {
21 Q_OBJECT
22   /// Struct to define gp point, with the state is the point is initialized
23   struct Point
24   {
25     /// Constructor
26     Point()
27     {
28       myIsInitialized = false;
29     }
30     /// Constructor
31     /// \param thePoint the point
32     Point(gp_Pnt thePoint)
33     {
34       setPoint(thePoint);
35     }
36     ~Point()
37     {
38     }
39
40     /// clear the initialized flag.
41     void clear()
42     {
43       myIsInitialized = false;
44     }
45     /// set the point and switch on the initialized flag
46     /// \param thePoint the point
47     void setPoint(const gp_Pnt& thePoint)
48     {
49       myIsInitialized = true;
50       myPoint = thePoint;
51     }
52
53     bool myIsInitialized;  /// the state whether the point is set
54     gp_Pnt myPoint;  /// the point
55   };
56
57  public:
58   /// Returns the operation type key
59   static std::string Type()
60   {
61     return "EditLine";
62   }
63
64  public:
65   /// Constructor
66   /// \param theId the feature identifier
67   /// \param theParent the operation parent
68   /// \param theFeature the parent feature
69   PartSet_OperationFeatureEdit(const QString& theId, QObject* theParent, FeaturePtr theFeature);
70   /// Destructor
71   virtual ~PartSet_OperationFeatureEdit();
72
73   /// Processes the mouse pressed in the point
74   /// \param theEvent the mouse event
75   /// \param theView a viewer to have the viewer the eye position
76   /// \param theSelected the list of selected presentations
77   /// \param theHighlighted the list of highlighted presentations
78   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
79                             const std::list<ModuleBase_ViewerPrs>& theSelected,
80                             const std::list<ModuleBase_ViewerPrs>& theHighlighted);
81   /// Gives the current mouse point in the viewer
82   /// \param theEvent the mouse event
83   /// \param theView a viewer to have the viewer the eye position
84   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
85   /// Gives the current selected objects to be processed by the operation
86   /// \param thePoint a point clicked in the viewer
87   /// \param theEvent the mouse event
88   /// \param theSelected the list of selected presentations
89   /// \param theHighlighted the list of highlighted presentations
90   virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
91                              const std::list<ModuleBase_ViewerPrs>& theSelected,
92                              const std::list<ModuleBase_ViewerPrs>& theHighlighted);
93
94   /// Processes the mouse double click in the point
95   /// \param theEvent the mouse event
96   /// \param theView a viewer to have the viewer the eye position
97   /// \param theSelected the list of selected presentations
98   /// \param theHighlighted the list of highlighted presentations
99   virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
100                                 const std::list<ModuleBase_ViewerPrs>& theSelected,
101                                 const std::list<ModuleBase_ViewerPrs>& theHighlighted);
102
103  protected:
104   /// \brief Virtual method called when operation is started
105   /// Virtual method called when operation started (see start() method for more description)
106   /// Switch off the multi selection state
107   virtual void startOperation();
108
109   /// Virtual method called when operation stopped - committed or aborted.
110   /// Restore the multi selection state
111   virtual void stopOperation();
112
113   /// Creates an operation new feature
114   /// Returns NULL feature. This is an operation of edition, not creation.
115   /// \param theFlushMessage the flag whether the create message should be flushed
116   /// \returns the created feature
117   virtual FeaturePtr createFeature(const bool theFlushMessage = true);
118
119  protected:
120   /// Emits a signal about the selection blocking. Emits a signal to change the selection.
121   /// If the block is true, the signal clear selection, otherwise if restore selection flag allows,
122   /// the internal operation features are to be selected
123   /// \param isBlocked the state whether the operation is blocked or unblocked
124   /// \param isRestoreSelection the state whether the selected objects should be reselected
125   void blockSelection(bool isBlocked, const bool isRestoreSelection = true);
126
127   /// Sends the features
128   void sendFeatures();
129
130  private:
131   Point myCurPoint;  ///< the current 3D point clicked or moved
132   bool myIsBlockedSelection;  ///< the state of the last state of selection blocked signal
133 };
134
135 #endif