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