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 { FM_Activation, FM_Deactivation, FM_Hide };
44 /// \param theId an feature index
45 /// \param theParent the object parent
46 PartSet_OperationSketchBase(const QString& theId, QObject* theParent);
48 virtual ~PartSet_OperationSketchBase();
50 /// Returns the feature preview shape
51 /// \param theFeature the feature object to obtain the preview
52 static boost::shared_ptr<GeomAPI_Shape> preview(FeaturePtr theFeature);
54 /// Returns the list of the nested features
55 /// \return the list of subfeatures
56 virtual std::list<FeaturePtr> subFeatures() const;
58 /// Returns the operation local selection mode
59 /// \param theFeature the feature object to get the selection mode
60 /// \return the selection mode
61 virtual std::list<int> getSelectionModes(FeaturePtr theFeature) const;
63 /// Initializes the operation with previously created feature. It is used in sequental operations
64 virtual void initFeature(FeaturePtr theFeature) {}
66 /// Initialisation of operation with preliminary selection
67 /// \param theSelected the list of selected presentations
68 /// \param theHighlighted the list of highlighted presentations
69 virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
70 const std::list<ModuleBase_ViewerPrs>& theHighlighted) {}
72 /// Returns the operation sketch feature
73 /// \returns the sketch instance
74 virtual FeaturePtr sketch() const = 0;
76 /// Processes the mouse pressed 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 mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
82 const std::list<ModuleBase_ViewerPrs>& theSelected,
83 const std::list<ModuleBase_ViewerPrs>& theHighlighted);
85 /// Processes the mouse release 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 mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
91 const std::list<ModuleBase_ViewerPrs>& theSelected,
92 const std::list<ModuleBase_ViewerPrs>& theHighlighted);
94 /// Processes the mouse move in the point
95 /// \param theEvent the mouse event
96 /// \param theView a viewer to have the viewer the eye position
97 virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
99 /// Processes the mouse double click in the point
100 /// \param theEvent the mouse event
101 /// \param theView a viewer to have the viewer the eye position
102 /// \param theSelected the list of selected presentations
103 /// \param theHighlighted the list of highlighted presentations
104 virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
105 const std::list<ModuleBase_ViewerPrs>& theSelected,
106 const std::list<ModuleBase_ViewerPrs>& theHighlighted);
108 /// Processes the key pressed in the view
109 /// \param theKey a key value
110 virtual void keyReleased(const int theKey);
112 virtual void keyReleased(std::string theName, QKeyEvent* theEvent);
114 /// Emits a signal about the operation start. This signal has an information about the feature.
115 /// If the provided feature is empty, the current operation feature is used.
116 /// \param theType a type of an operation started
117 /// theFeature the operation argument
118 void restartOperation(const std::string& theType,
119 FeaturePtr theFeature = FeaturePtr());
122 /// signal about the request to launch operation
123 /// theName the operation name
124 /// theFeature the operation argument
125 void launchOperation(std::string theName, FeaturePtr theFeature);
126 /// Signal about the feature construing is finished
127 /// \param theFeature the result feature
128 /// \param theMode the mode of the feature modification
129 void featureConstructed(FeaturePtr theFeature,
131 /// Signal about the features should be selected
132 /// \param theSelected the list of selected presentations
133 void featureSelected(const std::list<ModuleBase_ViewerPrs>& theSelected);
134 /// signal to enable/disable multi selection in the viewer
135 /// \param theEnabled the boolean state
136 void multiSelectionEnabled(bool theEnabled);
138 /// signal to enable/disable selection in the viewer
139 /// \param theFeatures a list of features to be disabled
140 /// \param theToStop the boolean state whether it it stopped or non stopped
141 void stopSelection(const QFeatureList& theFeatures, const bool theToStop);
142 /// signal to set selection in the viewer
143 /// \param theFeatures a list of features to be disabled
144 void setSelection(const QFeatureList& theFeatures);
146 /// signal to close the operation local context if it is opened
147 void closeLocalContext();
150 /// Creates an operation new feature
151 /// In addition to the default realization it appends the created line feature to
152 /// the sketch feature
153 /// \param theFlushMessage the flag whether the create message should be flushed
154 /// \returns the created feature
155 virtual FeaturePtr createFeature(const bool theFlushMessage = true);