Salome HOME
Boost has been removed from code
[modules/shaper.git] / src / PartSet / PartSet_OperationSketchBase.h
1 // File:        PartSet_OperationSketchBase.h
2 // Created:     20 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef PartSet_OperationSketchBase_H
6 #define PartSet_OperationSketchBase_H
7
8 #include "PartSet.h"
9
10 #include <TopoDS_Shape.hxx>
11 #include <gp_Pnt.hxx>
12 #include <NCollection_List.hxx>
13
14 #include <ModuleBase_Operation.h>
15 #include <ModuleBase_Operation.h>
16
17 #include <XGUI_Constants.h>
18 #include <XGUI_Displayer.h>
19
20 #include <QObject>
21
22 #include <AIS_InteractiveObject.hxx>
23
24 #include <map>
25
26 class Handle_V3d_View;
27 class QMouseEvent;
28 class GeomAPI_Shape;
29 class ModuleBase_ViewerPrs;
30 class ModuleBase_ISelection;
31 class ModuleBase_IViewer;
32
33 /*!
34  \class PartSet_OperationSketchBase
35  * \brief The base operation for the sketch features.
36  *  Base class for all sketch operations. It provides an access to the feature preview
37  */
38 class PARTSET_EXPORT PartSet_OperationSketchBase : public ModuleBase_Operation
39 {
40 Q_OBJECT
41  public:
42   enum FeatureActionMode
43   {
44     FM_Activation,
45     FM_Deactivation,
46     FM_Hide
47   };
48
49  public:
50   /// Constructor
51   /// \param theId an feature index
52   /// \param theParent the object parent
53   PartSet_OperationSketchBase(const QString& theId, QObject* theParent);
54   /// Destructor
55   virtual ~PartSet_OperationSketchBase();
56
57   /// Returns the feature preview shape
58   /// \param theFeature the feature object to obtain the preview
59   static std::shared_ptr<GeomAPI_Shape> preview(FeaturePtr theFeature);
60
61   /// Returns the list of the nested features
62   /// \return the list of subfeatures
63   virtual std::list<FeaturePtr> subFeatures() const;
64
65   /// Returns the operation sketch feature
66   /// \returns the sketch instance
67   virtual CompositeFeaturePtr sketch() const = 0;
68
69   /// Processes the mouse pressed in the point
70   /// \param theEvent the mouse event
71   /// \param theView a viewer to have the viewer the eye position
72   /// \param theSelected the list of selected presentations
73   /// \param theHighlighted the list of highlighted presentations
74   virtual void mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection);
75
76   /// Processes the mouse release in the point
77   /// \param theEvent the mouse event
78   /// \param theView a viewer to have the viewer the eye position
79   /// \param theSelected the list of selected presentations
80   /// \param theHighlighted the list of highlighted presentations
81   virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
82                              ModuleBase_ISelection* theSelection);
83
84   /// Processes the mouse move in the point
85   /// \param theEvent the mouse event
86   /// \param theView a viewer to have the viewer the eye position
87   virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer);
88
89   /// Processes the mouse double click in the point
90   /// \param theEvent the mouse event
91   /// \param theView a viewer to have the viewer the eye position
92   /// \param theSelected the list of selected presentations
93   /// \param theHighlighted the list of highlighted presentations
94   virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
95                                 ModuleBase_ISelection* theSelection);
96
97   
98   /// Called on selection changed when the operation is active
99   virtual void selectionChanged(ModuleBase_ISelection* theSelection);
100
101   /// Emits a signal about the operation start. This signal has an information about the feature.
102   /// If the provided feature is empty, the current operation feature is used.
103   /// \param theType a type of an operation started
104   /// theFeature the operation argument
105   void restartOperation(const std::string& theType, ObjectPtr theFeature = ObjectPtr());
106
107   /// If operation needs to redisplay its result during operation
108   /// then this method has to return True
109   virtual bool hasPreview() const { return true; }
110
111 signals:
112   /// signal about the request to launch operation
113   /// theName the operation name
114   /// theFeature the operation argument
115   void restartRequired(std::string theName, ObjectPtr theFeature);
116
117   /// Signal about the feature construing is finished
118   /// \param theFeature the result feature
119   /// \param theMode the mode of the feature modification
120   void featureConstructed(ObjectPtr theFeature, int theMode);
121
122   /// Signal about the features should be selected
123   /// \param theSelected the list of selected presentations
124   void featureSelected(const std::list<ModuleBase_ViewerPrs>& theSelected);
125
126   /// signal to enable/disable multi selection in the viewer
127   /// \param theEnabled the boolean state
128   //void multiSelectionEnabled(bool theEnabled);
129
130   /// signal to enable/disable selection in the viewer
131   /// \param theFeatures a list of features to be disabled
132   /// \param theToStop the boolean state whether it it stopped or non stopped
133   void stopSelection(const QList<ObjectPtr>& theFeatures, const bool theToStop);
134
135   /// signal to set selection in the viewer
136   /// \param theFeatures a list of features to be disabled
137   void setSelection(const QList<ObjectPtr>& theFeatures);
138
139  protected:
140   /// Creates an operation new feature
141   /// In addition to the default realization it appends the created line feature to
142   /// the sketch feature
143   /// \param theFlushMessage the flag whether the create message should be flushed
144   /// \returns the created feature
145   virtual FeaturePtr createFeature(const bool theFlushMessage = true);
146 };
147
148 #endif