1 // Created on: 1995-10-09
2 // Created by: Arnaud BOUZY/Odile Olivier
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _AIS_Trihedron_HeaderFile
18 #define _AIS_Trihedron_HeaderFile
20 #include <AIS_InteractiveObject.hxx>
21 #include <AIS_KindOfInteractive.hxx>
22 #include <AIS_TrihedronSelectionMode.hxx>
23 #include <Graphic3d_ArrayOfTriangles.hxx>
24 #include <PrsMgr_PresentationManager3d.hxx>
25 #include <Prs3d_DatumAspect.hxx>
26 #include <Prs3d_DatumMode.hxx>
27 #include <Prs3d_DatumParts.hxx>
28 #include <Prs3d_ShadingAspect.hxx>
29 #include <Prs3d_LineAspect.hxx>
30 #include <Prs3d_PointAspect.hxx>
31 #include <SelectMgr_Selection.hxx>
32 #include <TColgp_Array1OfPnt.hxx>
33 #include <Quantity_Color.hxx>
35 class Geom_Axis2Placement;
39 class Geom_Transformation;
42 //! Create a selectable trihedron
43 //! The trihedron includes 1 origin, 3 axes and 3 labels.
44 //! Default text of labels are "X", "Y", "Z".
45 //! Color of origin and any axis, color of arrows and labels may be changed.
46 //! Visual presentation might be shown in two, shaded and wireframe modes, wireframe by default).
47 //! There are 4 modes of selection:
48 //! - AIS_TrihedronSelectionMode_EntireObject to select trihedron, priority = 1
49 //! - AIS_TrihedronSelectionMode_Origin to select its origin, priority = 5
50 //! - AIS_TrihedronSelectionMode_Axes to select its axis, priority = 3
51 //! - AIS_TrihedronSelectionMode_MainPlanes to select its planes, priority = 2
54 //! For the presentation of trihedron, the default unit of length is the millimetre,
55 //! and the default value for the representation of the axes is 100.
56 //! If you modify these dimensions, you must temporarily recover the Drawer.
57 //! From inside it, you take the aspect in which the values for length are stocked.
58 //! For trihedron, this is Prs3d_Drawer_LineAspect.
59 //! You change the values inside this Aspect and recalculate the presentation.
60 class AIS_Trihedron : public AIS_InteractiveObject
62 DEFINE_STANDARD_RTTIEXT(AIS_Trihedron, AIS_InteractiveObject)
65 //! Initializes a trihedron entity.
66 Standard_EXPORT AIS_Trihedron (const Handle(Geom_Axis2Placement)& theComponent);
68 //! Sets Shading or Wireframe display mode, triangle or segment graphic group is used relatively.
69 void SetDatumDisplayMode (Prs3d_DatumMode theMode) { myTrihDispMode = theMode; }
71 //! Returns datum display mode.
72 Prs3d_DatumMode DatumDisplayMode() const { return myTrihDispMode; }
74 //! Returns the right-handed coordinate system set in SetComponent.
75 const Handle(Geom_Axis2Placement)& Component() const { return myComponent; }
77 //! Constructs the right-handed coordinate system aComponent.
78 Standard_EXPORT void SetComponent (const Handle(Geom_Axis2Placement)& theComponent);
80 //! Returns true if the trihedron object has a size other
81 //! than the default size of 100 mm. along each axis.
82 Standard_Boolean HasOwnSize() const { return myHasOwnSize; }
84 //! Sets the size aValue for the trihedron object.
85 //! The default value is 100 mm.
86 Standard_EXPORT void SetSize (const Standard_Real theValue);
88 //! Removes any non-default settings for size of this trihedron object.
89 //! If the object has 1 color, the default size of the
90 //! drawer is reproduced, otherwise DatumAspect becomes null.
91 Standard_EXPORT void UnsetSize();
93 Standard_EXPORT Standard_Real Size() const;
95 //! Returns true if the display mode selected, aMode, is valid for trihedron datums.
96 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE
101 //! Returns index 3, selection of the planes XOY, YOZ, XOZ.
102 virtual Standard_Integer Signature() const Standard_OVERRIDE { return 3; }
104 //! Indicates that the type of Interactive Object is datum.
105 virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KOI_Datum; }
107 //! Sets the color theColor for this trihedron object, it changes color of axes.
108 Standard_EXPORT void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
110 //! Sets color of label of trihedron axes.
111 Standard_EXPORT void SetTextColor (const Quantity_Color& theColor);
113 //! Returns true if trihedron has own text color
114 Standard_Boolean HasTextColor() const { return myHasOwnTextColor; }
116 //! Returns trihedron text color
117 Standard_EXPORT Quantity_Color TextColor() const;
119 //! Sets color of arrow of trihedron axes. Used only in wireframe mode
120 Standard_EXPORT void SetArrowColor (const Quantity_Color& theColor);
122 //! Returns true if trihedron has own arrow color
123 Standard_Boolean HasArrowColor() const { return myHasOwnArrowColor; }
125 //! Returns trihedron arrow color
126 Standard_EXPORT Quantity_Color ArrowColor() const;
128 //! Removes the settings for color.
129 Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
131 //! Sets color of datum part: origin or some of trihedron axes.
132 //! If presentation is shading mode, this color is set for both sides of facing model
133 Standard_EXPORT void SetDatumPartColor (const Prs3d_DatumParts thePart,
134 const Quantity_Color& theColor);
136 //! Returns color of datum part: origin or some of trihedron axes.
137 Standard_EXPORT Quantity_Color DatumPartColor (Prs3d_DatumParts thePart);
139 //! Sets color of origin.
140 //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
141 Standard_EXPORT void SetOriginColor (const Quantity_Color& theColor);
143 //! Sets color of x-axis.
144 //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
145 Standard_EXPORT void SetXAxisColor (const Quantity_Color& theColor);
147 //! Sets color of y-axis.
148 //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
149 Standard_EXPORT void SetYAxisColor (const Quantity_Color& theColor);
151 //! Sets color of z-axis.
152 //! Standard_DEPRECATED("This method is deprecated - SetColor() should be called instead")
153 Standard_EXPORT void SetAxisColor (const Quantity_Color& theColor);
155 //! Returns true if arrows are to be drawn
156 Standard_EXPORT Standard_Boolean ToDrawArrows() const;
158 //! Sets whether to draw the arrows in visualization
159 Standard_EXPORT void SetDrawArrows (const Standard_Boolean theToDraw);
161 //! Sets priority of selection for owner of the given type
162 void SetSelectionPriority (Prs3d_DatumParts thePart,
163 Standard_Integer thePriority)
165 mySelectionPriority.Bind (thePart, thePriority);
168 //! Sets priority of selection for owner of the given type
169 Standard_Integer SelectionPriority (Prs3d_DatumParts thePart)
171 return mySelectionPriority.Find (thePart);
174 //! Sets text label for trihedron axis. Parameter thePart should be XAxis, YAxis or ZAxis
175 void SetLabel (const Prs3d_DatumParts thePart,
176 const TCollection_ExtendedString& thePriority)
178 myLabel.Bind (thePart, thePriority);
181 //! Returns text of axis. Parameter thePart should be XAxis, YAxis or ZAxis
182 const TCollection_ExtendedString& Label (Prs3d_DatumParts thePart)
184 return myLabel.Find (thePart);
189 //! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden methods.
190 virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return false; }
192 //! Method which clear all selected owners belonging
193 //! to this selectable object ( for fast presentation draw ).
194 Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
196 //! Method which draws selected owners ( for fast presentation draw ).
197 Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePM,
198 const SelectMgr_SequenceOfOwner& theOwners) Standard_OVERRIDE;
200 //! Method which hilight an owner belonging to
201 //! this selectable object ( for fast presentation draw ).
202 Standard_EXPORT virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
203 const Handle(Prs3d_Drawer)& theStyle,
204 const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
208 //! Compute trihedron presentation.
209 Standard_EXPORT void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
210 const Handle(Prs3d_Presentation)& thePrs,
211 const Standard_Integer theMode) Standard_OVERRIDE;
213 //! This compute is unavailable for trihedron presentation.
214 void Compute (const Handle(Prs3d_Projector)& , const Handle(Prs3d_Presentation)& ) Standard_OVERRIDE {}
216 //! This compute is unavailable for trihedron presentation.
217 Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& theProjector,
218 const Handle(Geom_Transformation)& theTrsf,
219 const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE;
221 //! Compute selection.
222 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
223 const Standard_Integer theMode) Standard_OVERRIDE;
227 Standard_EXPORT void LoadRecomputable (const Standard_Integer theMode);
229 //! Creates a sensitive entity for the datum part that will be used in selection owner creation.
230 Standard_EXPORT Handle(SelectBasics_SensitiveEntity) createSensitiveEntity (const Prs3d_DatumParts thePart,
231 const Handle(SelectBasics_EntityOwner)& theOwner) const;
233 //! Computes presentation for display mode equal 1.
234 Standard_EXPORT void computePresentation (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
235 const Handle(Prs3d_Presentation)& thePrs);
237 //! Returns own datum aspect of trihedron, create this aspect if it was not created yet.
238 Standard_EXPORT void setOwnDatumAspect();
240 //! Returns primitives.
241 Standard_EXPORT Handle(Graphic3d_ArrayOfPrimitives) arrayOfPrimitives(
242 Prs3d_DatumParts thePart) const;
244 //! Updates graphic groups for the current datum mode
245 //! Parameters of datum position and orientation
246 Standard_EXPORT void updatePrimitives (const Handle(Prs3d_DatumAspect)& theAspect,
247 Prs3d_DatumMode theMode,
248 const gp_Pnt& theOrigin,
249 const gp_Dir& theXDir,
250 const gp_Dir& theYDir,
251 const gp_Dir& theZDir);
253 //! Returns highlight line aspect , create if it is the first call
254 Handle(Prs3d_ShadingAspect) getHighlightAspect();
255 //! Returns highlight line aspect , create if it is the first call
256 Handle(Prs3d_LineAspect) getHighlightLineAspect();
257 //! Returns highlight line aspect , create if it is the first call
258 Handle(Prs3d_PointAspect) getHighlightPointAspect();
261 Standard_Boolean myHasOwnSize;
262 Standard_Boolean myHasOwnTextColor;
263 Standard_Boolean myHasOwnArrowColor;
264 Standard_Boolean myHasOwnDatumAspect;
266 Prs3d_DatumMode myTrihDispMode;
267 Handle(Geom_Axis2Placement) myComponent;
269 NCollection_DataMap<Prs3d_DatumParts, Standard_Integer> mySelectionPriority;
270 NCollection_DataMap<Prs3d_DatumParts, TCollection_ExtendedString> myLabel;
272 NCollection_DataMap<Prs3d_DatumParts, Handle(Graphic3d_Group)> myPartToGroup;
273 NCollection_List<Prs3d_DatumParts> mySelectedParts;
275 Handle(Prs3d_ShadingAspect) myHighlightAspect;
276 Handle(Prs3d_LineAspect) myHighlightLineAspect;
277 Handle(Prs3d_PointAspect) myHighlightPointAspect;
279 NCollection_DataMap<Prs3d_DatumParts, Handle(Graphic3d_ArrayOfPrimitives)> myPrimitives;
282 DEFINE_STANDARD_HANDLE(AIS_Trihedron, AIS_InteractiveObject)
284 #endif // _AIS_Trihedron_HeaderFile