]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_OperationSketchBase.h
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   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
71
72   /// Processes the key pressed in the view
73   /// \param theKey a key value
74   virtual void keyReleased(const int theKey) {};
75
76 signals:
77   /// Signal about the feature construing is finished
78   /// \param theFeature the result feature
79   /// \param theMode the mode of the feature modification
80   void featureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
81                           int theMode);
82   /// signal about the request to launch operation
83   /// theName the operation name
84   /// theFeature the operation argument
85   void launchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
86   /// signal to enable/disable multi selection in the viewer
87   /// \param theEnabled the boolean state
88   void multiSelectionEnabled(bool theEnabled);
89
90 protected:
91   /// Creates an operation new feature
92   /// In addition to the default realization it appends the created line feature to
93   /// the sketch feature
94   /// \returns the created feature
95   virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
96 };
97
98 #endif