Salome HOME
0fce89ea66d44db25da948913967aec24e61b25e
[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 class Handle_V3d_View;
19 class QMouseEvent;
20 class GeomAPI_Shape;
21
22 /*!
23   \class PartSet_OperationSketchBase
24   * \brief The base operation for the sketch features.
25   *  Base class for all sketch operations. It provides an access to the feature preview
26 */
27 class PARTSET_EXPORT PartSet_OperationSketchBase : public ModuleBase_Operation
28 {
29   Q_OBJECT
30 public:
31   enum FeatureActionMode { FM_Activation, FM_Deactivation, FM_Abort };
32
33 public:
34   /// Constructor
35   /// \param theId an feature index
36   /// \param theParent the object parent
37   PartSet_OperationSketchBase(const QString& theId, QObject* theParent);
38   /// Destructor
39   virtual ~PartSet_OperationSketchBase();
40
41   /// Returns the feature preview shape
42   /// \param theFeature the feature object to obtain the preview
43   boost::shared_ptr<GeomAPI_Shape> preview(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
44
45   /// Returns the operation local selection mode
46   /// \param theFeature the feature object to get the selection mode
47   /// \return the selection mode
48   virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const = 0;
49
50   /// Initializes some fields accorging to the feature
51   /// \param theFeature the feature
52   virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature) {}
53
54   /// Gives the current selected objects to be processed by the operation
55   /// \param theFeature the selected feature
56   /// \param theShape the selected shape
57   virtual void setSelected(boost::shared_ptr<ModelAPI_Feature> theFeature,
58                            const TopoDS_Shape& theShape) {};
59
60   /// Processes the mouse pressed in the point
61   /// \param thePoint a point clicked in the viewer
62   /// \param theEvent the mouse event
63   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView);
64
65   /// Processes the mouse release in the point
66   /// \param thePoint a point clicked in the viewer
67   /// \param theEvent the mouse event
68   virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView);
69
70   /// Processes the mouse move in the point
71   /// \param thePoint a 3D point clicked in the viewer
72   /// \param theEvent the mouse event
73   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
74
75   /// Processes the key pressed in the view
76   /// \param theKey a key value
77   virtual void keyReleased(const int theKey) {};
78
79 signals:
80   /// Signal about the feature construing is finished
81   /// \param theFeature the result feature
82   /// \param theMode the mode of the feature modification
83   void featureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
84                           int theMode);
85   /// signal about the request to launch operation
86   /// theName the operation name
87   /// theFeature the operation argument
88   void launchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
89   /// signal to enable/disable multi selection in the viewer
90   /// \param theEnabled the boolean state
91   void multiSelectionEnabled(bool theEnabled);
92
93 protected:
94   /// Creates an operation new feature
95   /// In addition to the default realization it appends the created line feature to
96   /// the sketch feature
97   /// \returns the created feature
98   virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
99 };
100
101 #endif