1 // File: PartSet_OperationSketchBase.h
2 // Created: 20 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #ifndef PartSet_OperationSketchBase_H
6 #define PartSet_OperationSketchBase_H
10 #include <TopoDS_Shape.hxx>
12 #include <NCollection_List.hxx>
14 #include <ModuleBase_Operation.h>
15 #include <ModuleBase_Operation.h>
17 #include <XGUI_Constants.h>
18 #include <XGUI_Displayer.h>
22 #include <AIS_InteractiveObject.hxx>
26 class Handle_V3d_View;
29 class ModuleBase_ViewerPrs;
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
36 class PARTSET_EXPORT PartSet_OperationSketchBase : public ModuleBase_Operation
40 enum FeatureActionMode
49 /// \param theId an feature index
50 /// \param theParent the object parent
51 PartSet_OperationSketchBase(const QString& theId, QObject* theParent);
53 virtual ~PartSet_OperationSketchBase();
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);
59 /// Returns the list of the nested features
60 /// \return the list of subfeatures
61 virtual std::list<FeaturePtr> subFeatures() const;
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;
68 /// Initializes the operation with previously created feature. It is used in sequental operations
69 virtual void initFeature(FeaturePtr theFeature)
73 /// Initialisation of operation with preliminary selection
74 /// \param theSelected the list of selected presentations
75 /// \param theHighlighted the list of highlighted presentations
76 virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
77 const std::list<ModuleBase_ViewerPrs>& theHighlighted)
81 /// Returns the operation sketch feature
82 /// \returns the sketch instance
83 virtual FeaturePtr sketch() const = 0;
85 /// Processes the mouse pressed in the point
86 /// \param theEvent the mouse event
87 /// \param theView a viewer to have the viewer the eye position
88 /// \param theSelected the list of selected presentations
89 /// \param theHighlighted the list of highlighted presentations
90 virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
91 const std::list<ModuleBase_ViewerPrs>& theSelected,
92 const std::list<ModuleBase_ViewerPrs>& theHighlighted);
94 /// Processes the mouse release in the point
95 /// \param theEvent the mouse event
96 /// \param theView a viewer to have the viewer the eye position
97 /// \param theSelected the list of selected presentations
98 /// \param theHighlighted the list of highlighted presentations
99 virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
100 const std::list<ModuleBase_ViewerPrs>& theSelected,
101 const std::list<ModuleBase_ViewerPrs>& theHighlighted);
103 /// Processes the mouse move in the point
104 /// \param theEvent the mouse event
105 /// \param theView a viewer to have the viewer the eye position
106 virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
108 /// Processes the mouse double click in the point
109 /// \param theEvent the mouse event
110 /// \param theView a viewer to have the viewer the eye position
111 /// \param theSelected the list of selected presentations
112 /// \param theHighlighted the list of highlighted presentations
113 virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
114 const std::list<ModuleBase_ViewerPrs>& theSelected,
115 const std::list<ModuleBase_ViewerPrs>& theHighlighted);
117 /// Processes the key pressed in the view
118 /// \param theKey a key value
119 virtual void keyReleased(const int theKey);
121 virtual void keyReleased(std::string theName, QKeyEvent* theEvent);
123 /// Emits a signal about the operation start. This signal has an information about the feature.
124 /// If the provided feature is empty, the current operation feature is used.
125 /// \param theType a type of an operation started
126 /// theFeature the operation argument
127 void restartOperation(const std::string& theType, ObjectPtr theFeature = ObjectPtr());
130 /// signal about the request to launch operation
131 /// theName the operation name
132 /// theFeature the operation argument
133 void launchOperation(std::string theName, ObjectPtr theFeature);
135 /// Signal about the feature construing is finished
136 /// \param theFeature the result feature
137 /// \param theMode the mode of the feature modification
138 void featureConstructed(ObjectPtr theFeature, int theMode);
140 /// Signal about the features should be selected
141 /// \param theSelected the list of selected presentations
142 void featureSelected(const std::list<ModuleBase_ViewerPrs>& theSelected);
144 /// signal to enable/disable multi selection in the viewer
145 /// \param theEnabled the boolean state
146 void multiSelectionEnabled(bool theEnabled);
148 /// signal to enable/disable selection in the viewer
149 /// \param theFeatures a list of features to be disabled
150 /// \param theToStop the boolean state whether it it stopped or non stopped
151 void stopSelection(const QList<ObjectPtr>& theFeatures, const bool theToStop);
153 /// signal to set selection in the viewer
154 /// \param theFeatures a list of features to be disabled
155 void setSelection(const QList<ObjectPtr>& theFeatures);
157 /// signal to close the operation local context if it is opened
158 void closeLocalContext();
161 /// Creates an operation new feature
162 /// In addition to the default realization it appends the created line feature to
163 /// the sketch feature
164 /// \param theFlushMessage the flag whether the create message should be flushed
165 /// \returns the created feature
166 virtual FeaturePtr createFeature(const bool theFlushMessage = true);