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 sketch feature
64 /// \returns the sketch instance
65 virtual CompositeFeaturePtr sketch() const = 0;
67 /// Processes the mouse pressed in the point
68 /// \param theEvent the mouse event
69 /// \param theView a viewer to have the viewer the eye position
70 /// \param theSelected the list of selected presentations
71 /// \param theHighlighted the list of highlighted presentations
72 virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
73 const std::list<ModuleBase_ViewerPrs>& theSelected,
74 const std::list<ModuleBase_ViewerPrs>& theHighlighted);
76 /// Processes the mouse release in the point
77 /// \param theEvent the mouse event
78 /// \param theView a viewer to have the viewer the eye position
79 /// \param theSelected the list of selected presentations
80 /// \param theHighlighted the list of highlighted presentations
81 virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
82 const std::list<ModuleBase_ViewerPrs>& theSelected,
83 const std::list<ModuleBase_ViewerPrs>& theHighlighted);
85 /// Processes the mouse move in the point
86 /// \param theEvent the mouse event
87 /// \param theView a viewer to have the viewer the eye position
88 virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
90 /// Processes the mouse double click in the point
91 /// \param theEvent the mouse event
92 /// \param theView a viewer to have the viewer the eye position
93 /// \param theSelected the list of selected presentations
94 /// \param theHighlighted the list of highlighted presentations
95 virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
96 const std::list<ModuleBase_ViewerPrs>& theSelected,
97 const std::list<ModuleBase_ViewerPrs>& theHighlighted);
99 /// Emits a signal about the operation start. This signal has an information about the feature.
100 /// If the provided feature is empty, the current operation feature is used.
101 /// \param theType a type of an operation started
102 /// theFeature the operation argument
103 void restartOperation(const std::string& theType, ObjectPtr theFeature = ObjectPtr());
105 /// If operation needs to redisplay its result during operation
106 /// then this method has to return True
107 virtual bool hasPreview() const { return true; }
110 /// signal about the request to launch operation
111 /// theName the operation name
112 /// theFeature the operation argument
113 void restartRequired(std::string theName, ObjectPtr theFeature);
115 /// Signal about the feature construing is finished
116 /// \param theFeature the result feature
117 /// \param theMode the mode of the feature modification
118 void featureConstructed(ObjectPtr theFeature, int theMode);
120 /// Signal about the features should be selected
121 /// \param theSelected the list of selected presentations
122 void featureSelected(const std::list<ModuleBase_ViewerPrs>& theSelected);
124 /// signal to enable/disable multi selection in the viewer
125 /// \param theEnabled the boolean state
126 void multiSelectionEnabled(bool theEnabled);
128 /// signal to enable/disable selection in the viewer
129 /// \param theFeatures a list of features to be disabled
130 /// \param theToStop the boolean state whether it it stopped or non stopped
131 void stopSelection(const QList<ObjectPtr>& theFeatures, const bool theToStop);
133 /// signal to set selection in the viewer
134 /// \param theFeatures a list of features to be disabled
135 void setSelection(const QList<ObjectPtr>& theFeatures);
138 /// Creates an operation new feature
139 /// In addition to the default realization it appends the created line feature to
140 /// the sketch feature
141 /// \param theFlushMessage the flag whether the create message should be flushed
142 /// \returns the created feature
143 virtual FeaturePtr createFeature(const bool theFlushMessage = true);
145 /// Activates widgets by preselection if it is accepted
146 virtual void activateByPreselection();