Salome HOME
Merge branch 'master' of newgeom:newgeom
[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
75   /// Initialisation of operation with preliminary selection
76   /// \param theSelected the list of selected presentations
77   /// \param theHighlighted the list of highlighted presentations
78   /// \param theViewer a viewer to have the viewer the eye position
79   virtual void initSelection(ModuleBase_ISelection* theSelection,
80                              ModuleBase_IViewer* theViewer);
81
82   /// Processes the mouse pressed in the point
83   /// \param theEvent the mouse event
84   /// \param theView a viewer to have the viewer the eye position
85   /// \param theSelected the list of selected presentations
86   /// \param theHighlighted the list of highlighted presentations
87   virtual void mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection);
88
89   /// Gives the current mouse point in the viewer
90   /// \param theEvent the mouse event
91   /// \param theView a viewer to have the viewer the eye position
92   virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer);
93   /// Gives the current selected objects to be processed by the operation
94   /// \param thePoint a point clicked in the viewer
95   /// \param theEvent the mouse event
96   /// \param theSelected the list of selected presentations
97   /// \param theHighlighted the list of highlighted presentations
98   virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
99                              ModuleBase_ISelection* theSelection);
100
101   /// Processes the mouse double click in the point
102   /// \param theEvent the mouse event
103   /// \param theView a viewer to have the viewer the eye position
104   /// \param theSelected the list of selected presentations
105   /// \param theHighlighted the list of highlighted presentations
106   virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
107                                 ModuleBase_ISelection* theSelection);
108
109  protected:
110   /// \brief Virtual method called when operation is started
111   /// Virtual method called when operation started (see start() method for more description)
112   /// Switch off the multi selection state
113   virtual void startOperation();
114
115   /// Virtual method called when operation stopped - committed or aborted.
116   /// Restore the multi selection state
117   virtual void stopOperation();
118
119   /// Creates an operation new feature
120   /// Returns NULL feature. This is an operation of edition, not creation.
121   /// \param theFlushMessage the flag whether the create message should be flushed
122   /// \returns the created feature
123   virtual FeaturePtr createFeature(const bool theFlushMessage = true, 
124     CompositeFeaturePtr theCompositeFeature = CompositeFeaturePtr());
125
126  protected:
127   /// Emits a signal about the selection blocking. Emits a signal to change the selection.
128   /// If the block is true, the signal clear selection, otherwise if restore selection flag allows,
129   /// the internal operation features are to be selected
130   /// \param isBlocked the state whether the operation is blocked or unblocked
131   /// \param isRestoreSelection the state whether the selected objects should be reselected
132   //void blockSelection(bool isBlocked, const bool isRestoreSelection = true);
133
134   /// Sends the features
135   void sendFeatures();
136
137  private:
138   // the next map should be removed when selection is processed in the move function
139   std::map<FeaturePtr, std::list<std::string> > myFeature2Attribute; /// a map of a feature to attributes
140
141   Point myCurPoint;  ///< the current 3D point clicked or moved
142   bool myIsBlockedSelection;  ///< the state of the last state of selection blocked signal
143   bool myIsMultiOperation; // the state whether the operation is used for some features
144 };
145
146 #endif