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