Salome HOME
refs #156: Behavior of the Sketch during edition
[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 #include <map>
16
17 class QMouseEvent;
18
19 /*!
20  \class PartSet_OperationFeatureEditMulti
21  * \brief The operation for the sketch feature creation
22  */
23 class PARTSET_EXPORT PartSet_OperationFeatureEditMulti : public PartSet_OperationSketchBase
24 {
25 Q_OBJECT
26   /// Struct to define gp point, with the state is the point is initialized
27   struct Point
28   {
29     /// Constructor
30     Point()
31     {
32     }
33     /// Constructor
34     /// \param thePoint the point
35     Point(gp_Pnt thePoint)
36     {
37       setPoint(thePoint);
38     }
39     ~Point()
40     {
41     }
42
43     /// clear the initialized flag.
44     void clear()
45     {
46       myIsInitialized = false;
47     }
48     /// set the point and switch on the initialized flag
49     /// \param thePoint the point
50     void setPoint(const gp_Pnt& thePoint)
51     {
52       myIsInitialized = true;
53       myPoint = thePoint;
54     }
55
56     bool myIsInitialized;  /// the state whether the point is set
57     gp_Pnt myPoint;  /// the point
58   };
59
60  public:
61   /// Returns the operation type key
62   static std::string Type()
63   {
64     return "EditMulti";
65   }
66
67  public:
68   /// Constructor
69   /// \param theId the feature identifier
70   /// \param theParent the operation parent
71   /// \param theFeature the parent feature
72   PartSet_OperationFeatureEditMulti(const QString& theId, QObject* theParent,
73                                     CompositeFeaturePtr theFeature);
74   /// Destructor
75   virtual ~PartSet_OperationFeatureEditMulti();
76
77   /// Initialisation of operation with preliminary selection
78   /// \param theSelected the list of selected presentations
79   /// \param theHighlighted the list of highlighted presentations
80   /// \param theViewer a viewer to have the viewer the eye position
81   virtual void initSelection(ModuleBase_ISelection* theSelection,
82                              ModuleBase_IViewer* theViewer);
83
84   /// Returns the operation sketch feature
85   /// \returns the sketch instance
86   virtual CompositeFeaturePtr sketch() const;
87
88   /// Processes the mouse pressed in the point
89   /// \param theEvent the mouse event
90   /// \param theView a viewer to have the viewer the eye position
91   /// \param theSelected the list of selected presentations
92   /// \param theHighlighted the list of highlighted presentations
93   //virtual void mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection);
94
95   /// Gives the current mouse point in the viewer
96   /// \param theEvent the mouse event
97   /// \param theView a viewer to have the viewer the eye position
98   virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer);
99
100   /// Gives the current selected objects to be processed by the operation
101   /// \param thePoint a point clicked in the viewer
102   /// \param theEvent the mouse event
103   /// \param theSelected the list of selected presentations
104   /// \param theHighlighted the list of highlighted presentations
105   virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, 
106                              ModuleBase_ISelection* theSelection);
107
108  protected:
109   /// \brief Virtual method called when operation is started
110   /// Virtual method called when operation started (see start() method for more description)
111   /// Switch off the multi selection state
112   virtual void startOperation();
113
114   /// Virtual method called when operation stopped - committed or aborted.
115   /// Restore the multi selection state
116   virtual void stopOperation();
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   // the next map should be removed when selection is processed in the move function
131   std::map<FeaturePtr, std::list<std::string> > myFeature2Attribute; /// a map of a feature to attributes
132
133   CompositeFeaturePtr mySketch;  ///< the sketch feature
134   Point myCurPoint;  ///< the current 3D point clicked or moved
135   bool myIsBlockedSelection;  ///< the state of the last state of selection blocked signal
136 };
137
138 #endif