Salome HOME
0045a8e87b1a6c19b2cf227188974d3ea7099387
[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 #include <map>
19
20 class Handle_V3d_View;
21 class QMouseEvent;
22 class GeomAPI_Shape;
23 class XGUI_ViewerPrs;
24
25 /*!
26   \class PartSet_OperationSketchBase
27   * \brief The base operation for the sketch features.
28   *  Base class for all sketch operations. It provides an access to the feature preview
29 */
30 class PARTSET_EXPORT PartSet_OperationSketchBase : public ModuleBase_Operation
31 {
32   Q_OBJECT
33 public:
34   enum FeatureActionMode { FM_Activation, FM_Deactivation, FM_Hide };
35
36 public:
37   /// Constructor
38   /// \param theId an feature index
39   /// \param theParent the object parent
40   PartSet_OperationSketchBase(const QString& theId, QObject* theParent);
41   /// Destructor
42   virtual ~PartSet_OperationSketchBase();
43
44   /// Returns the feature preview shape
45   /// \param theFeature the feature object to obtain the preview
46   boost::shared_ptr<GeomAPI_Shape> preview(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
47
48   /// Returns the map of the operation previews including the nested feature previews
49   /// \return the map of feature to the feature preview
50   virtual std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> > subPreview() const;
51
52   /// Returns the operation local selection mode
53   /// \param theFeature the feature object to get the selection mode
54   /// \return the selection mode
55   virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const = 0;
56
57   /// Initializes some fields accorging to the feature
58   /// \param theFeature the feature
59   /// \param thePresentations the list of additional presentations
60   virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature,
61                     const std::list<XGUI_ViewerPrs>& thePresentations) {}
62
63   /// Returns the operation sketch feature
64   /// \returns the sketch instance
65   virtual boost::shared_ptr<ModelAPI_Feature> sketch() const = 0;
66
67   /// Processes the mouse pressed in the point
68   /// \param thePoint a point clicked in the viewer
69   /// \param theEvent the mouse event
70   /// \param theSelected the list of selected presentations
71   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
72                             const std::list<XGUI_ViewerPrs>& theSelected);
73
74   /// Processes the mouse release in the point
75   /// \param thePoint a point clicked in the viewer
76   /// \param theEvent the mouse event
77   /// \param theSelected the list of selected presentations
78   virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
79                              const std::list<XGUI_ViewerPrs>& theSelected);
80
81   /// Processes the mouse move in the point
82   /// \param thePoint a 3D point clicked in the viewer
83   /// \param theEvent the mouse event
84   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
85
86   /// Processes the key pressed in the view
87   /// \param theKey a key value
88   virtual void keyReleased(const int theKey);
89
90 signals:
91   /// Signal about the feature construing is finished
92   /// \param theFeature the result feature
93   /// \param theMode the mode of the feature modification
94   void featureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
95                           int theMode);
96   /// Signal about the features should be selected
97   /// \param theSelected the list of selected presentations
98   void featureSelected(const std::list<XGUI_ViewerPrs>& theSelected);
99   /// signal about the request to launch operation
100   /// theName the operation name
101   /// theFeature the operation argument
102   void launchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
103   /// signal to enable/disable multi selection in the viewer
104   /// \param theEnabled the boolean state
105   void multiSelectionEnabled(bool theEnabled);
106
107   /// signal to enable/disable selection in the viewer
108   /// \param theFeatures a list of features to be disabled
109   /// \param theToStop the boolean state whether it it stopped or non stopped
110   void stopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool theToStop);
111   /// signal to set selection in the viewer
112   /// \param theFeatures a list of features to be disabled
113   void setSelection(const std::list<XGUI_ViewerPrs>& theFeatures);
114
115   /// signal to close the operation local context if it is opened
116   void closeLocalContext();
117
118 protected:
119   /// Creates an operation new feature
120   /// In addition to the default realization it appends the created line feature to
121   /// the sketch feature
122   /// \returns the created feature
123   virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
124 };
125
126 #endif