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