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 #include <QList>
13
14 #include <list>
15
16 class QMouseEvent;
17
18 /*!
19  \class PartSet_OperationFeatureEditMulti
20  * \brief The operation for the sketch feature creation
21  */
22 class PARTSET_EXPORT PartSet_OperationFeatureEditMulti : public PartSet_OperationSketchBase
23 {
24 Q_OBJECT
25   /// Struct to define gp point, with the state is the point is initialized
26   struct Point
27   {
28     /// Constructor
29     Point()
30     {
31     }
32     /// Constructor
33     /// \param thePoint the point
34     Point(gp_Pnt thePoint)
35     {
36       setPoint(thePoint);
37     }
38     ~Point()
39     {
40     }
41
42     /// clear the initialized flag.
43     void clear()
44     {
45       myIsInitialized = false;
46     }
47     /// set the point and switch on the initialized flag
48     /// \param thePoint the point
49     void setPoint(const gp_Pnt& thePoint)
50     {
51       myIsInitialized = true;
52       myPoint = thePoint;
53     }
54
55     bool myIsInitialized;  /// the state whether the point is set
56     gp_Pnt myPoint;  /// the point
57   };
58
59  public:
60   /// Returns the operation type key
61   static std::string Type()
62   {
63     return "EditMulti";
64   }
65
66  public:
67   /// Constructor
68   /// \param theId the feature identifier
69   /// \param theParent the operation parent
70   /// \param theFeature the parent feature
71   PartSet_OperationFeatureEditMulti(const QString& theId, QObject* theParent,
72                                     CompositeFeaturePtr theFeature);
73   /// Destructor
74   virtual ~PartSet_OperationFeatureEditMulti();
75
76   /// Initialisation of operation with preliminary selection
77   /// \param theSelected the list of selected presentations
78   /// \param theHighlighted the list of highlighted presentations
79   virtual void initSelection(ModuleBase_ISelection* theSelection);
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, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection);
91
92   /// Gives the current mouse point in the viewer
93   /// \param theEvent the mouse event
94   /// \param theView a viewer to have the viewer the eye position
95   virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer);
96
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, ModuleBase_IViewer* theViewer, 
103                              ModuleBase_ISelection* theSelection);
104
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   QList<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