Salome HOME
Merge branch 'master' of newgeom:newgeom
[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
13 #include <list>
14
15 class QMouseEvent;
16
17 /*!
18  \class PartSet_OperationFeatureEditMulti
19  * \brief The operation for the sketch feature creation
20  */
21 class PARTSET_EXPORT PartSet_OperationFeatureEditMulti : public PartSet_OperationSketchBase
22 {
23 Q_OBJECT
24   /// Struct to define gp point, with the state is the point is initialized
25   struct Point
26   {
27     /// Constructor
28     Point()
29     {
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 "EditMulti";
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_OperationFeatureEditMulti(const QString& theId, QObject* theParent,
71                                     CompositeFeaturePtr theFeature);
72   /// Destructor
73   virtual ~PartSet_OperationFeatureEditMulti();
74
75   /// Initialisation of operation with preliminary selection
76   /// \param theSelected the list of selected presentations
77   /// \param theHighlighted the list of highlighted presentations
78   virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
79                              const std::list<ModuleBase_ViewerPrs>& theHighlighted);
80
81   /// Returns the operation sketch feature
82   /// \returns the sketch instance
83   virtual CompositeFeaturePtr sketch() const;
84
85   /// Processes the mouse pressed in the point
86   /// \param theEvent the mouse event
87   /// \param theView a viewer to have the viewer the eye position
88   /// \param theSelected the list of selected presentations
89   /// \param theHighlighted the list of highlighted presentations
90   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
91                             const std::list<ModuleBase_ViewerPrs>& theSelected,
92                             const std::list<ModuleBase_ViewerPrs>& theHighlighted);
93   /// Gives the current mouse point in the viewer
94   /// \param theEvent the mouse event
95   /// \param theView a viewer to have the viewer the eye position
96   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
97   /// Gives the current selected objects to be processed by the operation
98   /// \param thePoint a point clicked in the viewer
99   /// \param theEvent the mouse event
100   /// \param theSelected the list of selected presentations
101   /// \param theHighlighted the list of highlighted presentations
102   virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
103                              const std::list<ModuleBase_ViewerPrs>& theSelected,
104                              const std::list<ModuleBase_ViewerPrs>& theHighlighted);
105  protected:
106   /// \brief Virtual method called when operation is started
107   /// Virtual method called when operation started (see start() method for more description)
108   /// Switch off the multi selection state
109   virtual void startOperation();
110
111   /// Virtual method called when operation stopped - committed or aborted.
112   /// Restore the multi selection state
113   virtual void stopOperation();
114
115  protected:
116   /// Emits a signal about the selection blocking. Emits a signal to change the selection.
117   /// If the block is true, the signal clear selection, otherwise if restore selection flag allows,
118   /// the internal operation features are to be selected
119   /// \param isBlocked the state whether the operation is blocked or unblocked
120   /// \param isRestoreSelection the state whether the selected objects should be reselected
121   void blockSelection(bool isBlocked, const bool isRestoreSelection = true);
122
123   /// Sends the features
124   void sendFeatures();
125
126  private:
127   CompositeFeaturePtr mySketch;  ///< the sketch feature
128   std::list<ModuleBase_ViewerPrs> myFeatures;  ///< the features to apply the edit operation
129   Point myCurPoint;  ///< the current 3D point clicked or moved
130   bool myIsBlockedSelection;  ///< the state of the last state of selection blocked signal
131 };
132
133 #endif