]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_OperationFeatureEditMulti.h
Salome HOME
f21a78ad6842ec20031e0299be51a7b9051a2f9b
[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     /// Constructor
28     /// \param thePoint the point
29     Point(gp_Pnt thePoint)
30     {
31       setPoint(thePoint);
32     }
33     ~Point() {}
34
35     /// clear the initialized flag.
36     void clear() { myIsInitialized = false; }
37     /// set the point and switch on the initialized flag
38     /// \param thePoint the point
39     void setPoint(const gp_Pnt& thePoint)
40     {
41       myIsInitialized = true;
42       myPoint = thePoint;
43     }
44
45     bool myIsInitialized; /// the state whether the point is set
46     gp_Pnt myPoint; /// the point
47   };
48
49 public:
50   /// Returns the operation type key
51   static std::string Type() { return "EditMulti"; }
52
53 public:
54   /// Constructor
55   /// \param theId the feature identifier
56   /// \param theParent the operation parent
57   /// \param theFeature the parent feature
58   PartSet_OperationFeatureEditMulti(const QString& theId, QObject* theParent,
59                             FeaturePtr theFeature);
60   /// Destructor
61   virtual ~PartSet_OperationFeatureEditMulti();
62
63   /// Returns that this operator can be started above already running one.
64   /// The runned operation should be the sketch feature modified operation
65   /// \param theOperation the previous running operation
66   virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
67
68   /// Initializes some fields accorging to the feature
69   /// \param theFeature the feature
70   /// \param theSelected the list of selected presentations
71   /// \param theHighlighted the list of highlighted presentations
72   virtual void init(FeaturePtr theFeature,
73                     const std::list<XGUI_ViewerPrs>& theSelected,
74                     const std::list<XGUI_ViewerPrs>& theHighlighted);
75
76   /// Returns the operation sketch feature
77   /// \returns the sketch instance
78   virtual FeaturePtr sketch() const;
79
80   /// Processes the mouse pressed in the point
81   /// \param theEvent the mouse event
82   /// \param theView a viewer to have the viewer the eye position
83   /// \param theSelected the list of selected presentations
84   /// \param theHighlighted the list of highlighted presentations
85   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
86                             const std::list<XGUI_ViewerPrs>& theSelected,
87                             const std::list<XGUI_ViewerPrs>& theHighlighted);
88   /// Gives the current mouse point in the viewer
89   /// \param theEvent the mouse event
90   /// \param theView a viewer to have the viewer the eye position
91   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
92   /// Gives the current selected objects to be processed by the operation
93   /// \param thePoint a point clicked in the viewer
94   /// \param theEvent the mouse event
95   /// \param theSelected the list of selected presentations
96   /// \param theHighlighted the list of highlighted presentations
97  virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
98                             const std::list<XGUI_ViewerPrs>& theSelected,
99                             const std::list<XGUI_ViewerPrs>& theHighlighted);
100 protected:
101   /// \brief Virtual method called when operation is started
102   /// Virtual method called when operation started (see start() method for more description)
103   /// Switch off the multi selection state
104   virtual void startOperation();
105
106   /// Virtual method called when operation stopped - committed or aborted.
107   /// Restore the multi selection state
108   virtual void stopOperation();
109
110 protected:
111   /// Emits a signal about the selection blocking. Emits a signal to change the selection.
112   /// If the block is true, the signal clear selection, otherwise if restore selection flag allows,
113   /// the internal operation features are to be selected
114   /// \param isBlocked the state whether the operation is blocked or unblocked
115   /// \param isRestoreSelection the state whether the selected objects should be reselected
116   void blockSelection(bool isBlocked, const bool isRestoreSelection = true);
117
118   /// Sends the features
119   void sendFeatures();
120
121 private:
122   FeaturePtr mySketch; ///< the sketch feature
123   std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
124   Point myCurPoint; ///< the current 3D point clicked or moved
125   bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal
126 };
127
128 #endif