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