Salome HOME
Composite Feature implementation. Sketch now is Composite.
[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 class QMouseEvent;
14
15 /*!
16  \class PartSet_OperationFeatureEditMulti
17  * \brief The operation for the sketch feature creation
18  */
19 class PARTSET_EXPORT PartSet_OperationFeatureEditMulti : public PartSet_OperationSketchBase
20 {
21 Q_OBJECT
22   /// Struct to define gp point, with the state is the point is initialized
23   struct Point
24   {
25     /// Constructor
26     Point()
27     {
28     }
29     /// Constructor
30     /// \param thePoint the point
31     Point(gp_Pnt thePoint)
32     {
33       setPoint(thePoint);
34     }
35     ~Point()
36     {
37     }
38
39     /// clear the initialized flag.
40     void clear()
41     {
42       myIsInitialized = false;
43     }
44     /// set the point and switch on the initialized flag
45     /// \param thePoint the point
46     void setPoint(const gp_Pnt& thePoint)
47     {
48       myIsInitialized = true;
49       myPoint = thePoint;
50     }
51
52     bool myIsInitialized;  /// the state whether the point is set
53     gp_Pnt myPoint;  /// the point
54   };
55
56  public:
57   /// Returns the operation type key
58   static std::string Type()
59   {
60     return "EditMulti";
61   }
62
63  public:
64   /// Constructor
65   /// \param theId the feature identifier
66   /// \param theParent the operation parent
67   /// \param theFeature the parent feature
68   PartSet_OperationFeatureEditMulti(const QString& theId, QObject* theParent,
69                                     CompositeFeaturePtr theFeature);
70   /// Destructor
71   virtual ~PartSet_OperationFeatureEditMulti();
72
73   /// Initialisation of operation with preliminary selection
74   /// \param theSelected the list of selected presentations
75   /// \param theHighlighted the list of highlighted presentations
76   virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
77                              const std::list<ModuleBase_ViewerPrs>& theHighlighted);
78
79   /// Returns the operation sketch feature
80   /// \returns the sketch instance
81   virtual CompositeFeaturePtr sketch() const;
82
83   /// Processes the mouse pressed in the point
84   /// \param theEvent the mouse event
85   /// \param theView a viewer to have the viewer the eye position
86   /// \param theSelected the list of selected presentations
87   /// \param theHighlighted the list of highlighted presentations
88   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
89                             const std::list<ModuleBase_ViewerPrs>& theSelected,
90                             const std::list<ModuleBase_ViewerPrs>& theHighlighted);
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, Handle_V3d_View theView);
95   /// Gives the current selected objects to be processed by the operation
96   /// \param thePoint a point clicked in the viewer
97   /// \param theEvent the mouse event
98   /// \param theSelected the list of selected presentations
99   /// \param theHighlighted the list of highlighted presentations
100   virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
101                              const std::list<ModuleBase_ViewerPrs>& theSelected,
102                              const std::list<ModuleBase_ViewerPrs>& theHighlighted);
103  protected:
104   /// \brief Virtual method called when operation is started
105   /// Virtual method called when operation started (see start() method for more description)
106   /// Switch off the multi selection state
107   virtual void startOperation();
108
109   /// Virtual method called when operation stopped - committed or aborted.
110   /// Restore the multi selection state
111   virtual void stopOperation();
112
113  protected:
114   /// Emits a signal about the selection blocking. Emits a signal to change the selection.
115   /// If the block is true, the signal clear selection, otherwise if restore selection flag allows,
116   /// the internal operation features are to be selected
117   /// \param isBlocked the state whether the operation is blocked or unblocked
118   /// \param isRestoreSelection the state whether the selected objects should be reselected
119   void blockSelection(bool isBlocked, const bool isRestoreSelection = true);
120
121   /// Sends the features
122   void sendFeatures();
123
124  private:
125   CompositeFeaturePtr mySketch;  ///< the sketch feature
126   std::list<ModuleBase_ViewerPrs> myFeatures;  ///< the features to apply the edit operation
127   Point myCurPoint;  ///< the current 3D point clicked or moved
128   bool myIsBlockedSelection;  ///< the state of the last state of selection blocked signal
129 };
130
131 #endif