Salome HOME
Merge remote-tracking branch 'origin/BR_WIRE_RESULTS'
[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
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
41   {
42     FM_Activation,
43     FM_Deactivation,
44     FM_Hide
45   };
46
47  public:
48   /// Constructor
49   /// \param theId an feature index
50   /// \param theParent the object parent
51   PartSet_OperationSketchBase(const QString& theId, QObject* theParent);
52   /// Destructor
53   virtual ~PartSet_OperationSketchBase();
54
55   /// Returns the feature preview shape
56   /// \param theFeature the feature object to obtain the preview
57   static boost::shared_ptr<GeomAPI_Shape> preview(FeaturePtr theFeature);
58
59   /// Returns the list of the nested features
60   /// \return the list of subfeatures
61   virtual std::list<FeaturePtr> subFeatures() const;
62
63   /// Returns the operation local selection mode
64   /// \param theFeature the feature object to get the selection mode
65   /// \return the selection mode
66   virtual std::list<int> getSelectionModes(ObjectPtr theFeature) const;
67
68   /// Returns the operation sketch feature
69   /// \returns the sketch instance
70   virtual FeaturePtr sketch() const = 0;
71
72   /// Processes the mouse pressed in the point
73   /// \param theEvent the mouse event
74   /// \param theView a viewer to have the viewer the eye position
75   /// \param theSelected the list of selected presentations
76   /// \param theHighlighted the list of highlighted presentations
77   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
78                             const std::list<ModuleBase_ViewerPrs>& theSelected,
79                             const std::list<ModuleBase_ViewerPrs>& theHighlighted);
80
81   /// Processes the mouse release in the point
82   /// \param theEvent the mouse event
83   /// \param theView a viewer to have the viewer the eye position
84   /// \param theSelected the list of selected presentations
85   /// \param theHighlighted the list of highlighted presentations
86   virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
87                              const std::list<ModuleBase_ViewerPrs>& theSelected,
88                              const std::list<ModuleBase_ViewerPrs>& theHighlighted);
89
90   /// Processes the mouse move in the point
91   /// \param theEvent the mouse event
92   /// \param theView a viewer to have the viewer the eye position
93   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
94
95   /// Processes the mouse double click in the point
96   /// \param theEvent the mouse event
97   /// \param theView a viewer to have the viewer the eye position
98   /// \param theSelected the list of selected presentations
99   /// \param theHighlighted the list of highlighted presentations
100   virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
101                                 const std::list<ModuleBase_ViewerPrs>& theSelected,
102                                 const std::list<ModuleBase_ViewerPrs>& theHighlighted);
103
104   /// Emits a signal about the operation start. This signal has an information about the feature.
105   /// If the provided feature is empty, the current operation feature is used.
106   /// \param theType a type of an operation started
107   /// theFeature the operation argument
108   void restartOperation(const std::string& theType, ObjectPtr theFeature = ObjectPtr());
109
110   /// If operation needs to redisplay its result during operation
111   /// then this method has to return True
112   virtual bool hasPreview() const { return true; }
113
114 signals:
115   /// signal about the request to launch operation
116   /// theName the operation name
117   /// theFeature the operation argument
118   void restartRequired(std::string theName, ObjectPtr theFeature);
119
120   /// Signal about the feature construing is finished
121   /// \param theFeature the result feature
122   /// \param theMode the mode of the feature modification
123   void featureConstructed(ObjectPtr theFeature, int theMode);
124
125   /// Signal about the features should be selected
126   /// \param theSelected the list of selected presentations
127   void featureSelected(const std::list<ModuleBase_ViewerPrs>& theSelected);
128
129   /// signal to enable/disable multi selection in the viewer
130   /// \param theEnabled the boolean state
131   void multiSelectionEnabled(bool theEnabled);
132
133   /// signal to enable/disable selection in the viewer
134   /// \param theFeatures a list of features to be disabled
135   /// \param theToStop the boolean state whether it it stopped or non stopped
136   void stopSelection(const QList<ObjectPtr>& theFeatures, const bool theToStop);
137
138   /// signal to set selection in the viewer
139   /// \param theFeatures a list of features to be disabled
140   void setSelection(const QList<ObjectPtr>& theFeatures);
141
142   /// signal to close the operation local context if it is opened
143   void closeLocalContext();
144
145  protected:
146   /// Creates an operation new feature
147   /// In addition to the default realization it appends the created line feature to
148   /// the sketch feature
149   /// \param theFlushMessage the flag whether the create message should be flushed
150   /// \returns the created feature
151   virtual FeaturePtr createFeature(const bool theFlushMessage = true);
152
153   /// Activates widgets by preselection if it is accepted
154   virtual void activateByPreselection();
155 };
156
157 #endif