Salome HOME
Replace boost::shared_ptr<ModelAPI_Feature> on FeaturePtr
[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 #include <QObject>
17
18 #include <map>
19
20 class Handle_V3d_View;
21 class QMouseEvent;
22 class GeomAPI_Shape;
23 class XGUI_ViewerPrs;
24
25 /*!
26   \class PartSet_OperationSketchBase
27   * \brief The base operation for the sketch features.
28   *  Base class for all sketch operations. It provides an access to the feature preview
29 */
30 class PARTSET_EXPORT PartSet_OperationSketchBase : public ModuleBase_Operation
31 {
32   Q_OBJECT
33 public:
34   enum FeatureActionMode { FM_Activation, FM_Deactivation, FM_Hide };
35
36 public:
37   /// Constructor
38   /// \param theId an feature index
39   /// \param theParent the object parent
40   PartSet_OperationSketchBase(const QString& theId, QObject* theParent);
41   /// Destructor
42   virtual ~PartSet_OperationSketchBase();
43
44   /// Returns the feature preview shape
45   /// \param theFeature the feature object to obtain the preview
46   static boost::shared_ptr<GeomAPI_Shape> preview(FeaturePtr theFeature);
47
48   /// Returns the map of the operation previews including the nested feature previews
49   /// \return the map of feature to the feature preview
50   virtual std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> > subPreview() const;
51
52   /// Returns the operation local selection mode
53   /// \param theFeature the feature object to get the selection mode
54   /// \return the selection mode
55   virtual std::list<int> getSelectionModes(FeaturePtr theFeature) const;
56
57   /// Initializes some fields accorging to the feature
58   /// \param theSelected the list of selected presentations
59   /// \param theHighlighted the list of highlighted presentations
60   virtual void init(FeaturePtr theFeature,
61                     const std::list<XGUI_ViewerPrs>& theSelected,
62                     const std::list<XGUI_ViewerPrs>& theHighlighted) {}
63
64   /// Returns the operation sketch feature
65   /// \returns the sketch instance
66   virtual FeaturePtr sketch() const = 0;
67
68   /// Processes the mouse pressed in the point
69   /// \param theEvent the mouse event
70   /// \param theView a viewer to have the viewer the eye position
71   /// \param theSelected the list of selected presentations
72   /// \param theHighlighted the list of highlighted presentations
73   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
74                             const std::list<XGUI_ViewerPrs>& theSelected,
75                             const std::list<XGUI_ViewerPrs>& theHighlighted);
76
77   /// Processes the mouse release in the point
78   /// \param theEvent the mouse event
79   /// \param theView a viewer to have the viewer the eye position
80   /// \param theSelected the list of selected presentations
81   /// \param theHighlighted the list of highlighted presentations
82   virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
83                              const std::list<XGUI_ViewerPrs>& theSelected,
84                              const std::list<XGUI_ViewerPrs>& theHighlighted);
85
86   /// Processes the mouse move in the point
87   /// \param theEvent the mouse event
88   /// \param theView a viewer to have the viewer the eye position
89   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
90
91   /// Processes the key pressed in the view
92   /// \param theKey a key value
93   virtual void keyReleased(const int theKey);
94
95   virtual void keyReleased(std::string theName, QKeyEvent* theEvent);
96
97   /// Emits a signal about the operation start. This signal has an information about the feature.
98   /// If the provided feature is empty, the current operation feature is used.
99   /// \param theType a type of an operation started
100   /// theFeature the operation argument
101   void restartOperation(const std::string& theType,
102          FeaturePtr theFeature = FeaturePtr());
103
104 signals:
105   /// signal about the request to launch operation
106   /// theName the operation name
107   /// theFeature the operation argument
108   void launchOperation(std::string theName, FeaturePtr theFeature);
109   /// signal about the focus activated
110   /// theName the attribute name
111   void focusActivated(const std::string& theAttibuteName);
112
113   /// Signal about the feature construing is finished
114   /// \param theFeature the result feature
115   /// \param theMode the mode of the feature modification
116   void featureConstructed(FeaturePtr theFeature,
117                           int theMode);
118   /// Signal about the features should be selected
119   /// \param theSelected the list of selected presentations
120   void featureSelected(const std::list<XGUI_ViewerPrs>& theSelected);
121   /// signal to enable/disable multi selection in the viewer
122   /// \param theEnabled the boolean state
123   void multiSelectionEnabled(bool theEnabled);
124
125   /// signal to enable/disable selection in the viewer
126   /// \param theFeatures a list of features to be disabled
127   /// \param theToStop the boolean state whether it it stopped or non stopped
128   void stopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool theToStop);
129   /// signal to set selection in the viewer
130   /// \param theFeatures a list of features to be disabled
131   void setSelection(const std::list<XGUI_ViewerPrs>& theFeatures);
132
133   /// signal to close the operation local context if it is opened
134   void closeLocalContext();
135
136 protected:
137   /// Creates an operation new feature
138   /// In addition to the default realization it appends the created line feature to
139   /// the sketch feature
140   /// \param theFlushMessage the flag whether the create message should be flushed
141   /// \returns the created feature
142   virtual FeaturePtr createFeature(const bool theFlushMessage = true);
143 };
144
145 #endif