Salome HOME
Corrections of selection architecture
[modules/shaper.git] / src / PartSet / PartSet_OperationFeatureEditMulti.h
1 // File:        PartSet_OperationFeatureEditMulti.h
2 // Created:     05 May 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef PartSet_OperationFeatureEditMulti_H
6 #define PartSet_OperationFeatureEditMulti_H
7
8 #include "PartSet.h"
9
10 #include <PartSet_OperationSketchBase.h>
11 #include <QObject>
12 #include <QList>
13
14 class QMouseEvent;
15
16 /*!
17  \class PartSet_OperationFeatureEditMulti
18  * \brief The operation for the sketch feature creation
19  */
20 class PARTSET_EXPORT PartSet_OperationFeatureEditMulti : public PartSet_OperationSketchBase
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     }
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 "EditMulti";
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_OperationFeatureEditMulti(const QString& theId, QObject* theParent,
70                                     CompositeFeaturePtr theFeature);
71   /// Destructor
72   virtual ~PartSet_OperationFeatureEditMulti();
73
74   /// Initialisation of operation with preliminary selection
75   /// \param theSelected the list of selected presentations
76   /// \param theHighlighted the list of highlighted presentations
77   virtual void initSelection(const QList<ModuleBase_ViewerPrs>& theSelected,
78                              const QList<ModuleBase_ViewerPrs>& theHighlighted);
79
80   /// Returns the operation sketch feature
81   /// \returns the sketch instance
82   virtual CompositeFeaturePtr sketch() const;
83
84   /// Processes the mouse pressed in the point
85   /// \param theEvent the mouse event
86   /// \param theView a viewer to have the viewer the eye position
87   /// \param theSelected the list of selected presentations
88   /// \param theHighlighted the list of highlighted presentations
89   virtual void mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection);
90
91   /// Gives the current mouse point in the viewer
92   /// \param theEvent the mouse event
93   /// \param theView a viewer to have the viewer the eye position
94   virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer);
95
96   /// Gives the current selected objects to be processed by the operation
97   /// \param thePoint a point clicked in the viewer
98   /// \param theEvent the mouse event
99   /// \param theSelected the list of selected presentations
100   /// \param theHighlighted the list of highlighted presentations
101   virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, 
102                              ModuleBase_ISelection* theSelection);
103
104  protected:
105   /// \brief Virtual method called when operation is started
106   /// Virtual method called when operation started (see start() method for more description)
107   /// Switch off the multi selection state
108   virtual void startOperation();
109
110   /// Virtual method called when operation stopped - committed or aborted.
111   /// Restore the multi selection state
112   virtual void stopOperation();
113
114  protected:
115   /// Emits a signal about the selection blocking. Emits a signal to change the selection.
116   /// If the block is true, the signal clear selection, otherwise if restore selection flag allows,
117   /// the internal operation features are to be selected
118   /// \param isBlocked the state whether the operation is blocked or unblocked
119   /// \param isRestoreSelection the state whether the selected objects should be reselected
120   //void blockSelection(bool isBlocked, const bool isRestoreSelection = true);
121
122   /// Sends the features
123   void sendFeatures();
124
125  private:
126   CompositeFeaturePtr mySketch;  ///< the sketch feature
127   QList<ModuleBase_ViewerPrs> myFeatures;  ///< the features to apply the edit operation
128   Point myCurPoint;  ///< the current 3D point clicked or moved
129   bool myIsBlockedSelection;  ///< the state of the last state of selection blocked signal
130 };
131
132 #endif