1 // Created on: 2016-10-11
2 // Created by: Ilya SEVRIKOV
3 // Copyright (c) 2016 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _V3d_Trihedron_HeaderFile
17 #define _V3d_Trihedron_HeaderFile
19 #include <Graphic3d_Group.hxx>
20 #include <Graphic3d_Structure.hxx>
21 #include <Graphic3d_StructureManager.hxx>
22 #include <Graphic3d_TransformPers.hxx>
23 #include <Prs3d_LineAspect.hxx>
24 #include <Prs3d_ShadingAspect.hxx>
25 #include <Prs3d_TextAspect.hxx>
26 #include <V3d_TypeOfAxe.hxx>
30 //! Class for presentation of trihedron object.
31 class V3d_Trihedron : public Standard_Transient
33 DEFINE_STANDARD_RTTIEXT(V3d_Trihedron, Standard_Transient)
36 //! Creates a default trihedron.
37 Standard_EXPORT V3d_Trihedron();
40 Standard_EXPORT virtual ~V3d_Trihedron();
42 //! Return TRUE if wireframe presentation is set; FALSE by default.
43 bool IsWireframe() const { return myIsWireframe; }
45 //! Switch wireframe / shaded trihedron.
46 void SetWireframe (const Standard_Boolean theAsWireframe)
48 if (myIsWireframe != theAsWireframe)
51 myIsWireframe = theAsWireframe;
55 //! Return trihedron position.
56 const Handle(Graphic3d_TransformPers) TransformPersistence() const { return myTransformPers; }
58 //! Setup the corner to draw the trihedron.
59 Standard_EXPORT void SetPosition (const Aspect_TypeOfTriedronPosition thePosition);
61 //! Return scale factor.
62 Standard_Real Scale() const { return myScale; }
64 //! Setup the scale factor.
65 Standard_EXPORT void SetScale (const Standard_Real theScale);
67 //! Return size ratio factor.
68 Standard_Real SizeRatio() const { return myRatio; }
70 //! Setup the size ratio factor.
71 Standard_EXPORT void SetSizeRatio (const Standard_Real theRatio);
73 //! Return arrow diameter.
74 Standard_Real ArrowDiameter() const { return myDiameter; }
76 //! Setup the arrow diameter.
77 Standard_EXPORT void SetArrowDiameter (const Standard_Real theDiam);
79 //! Return number of facets for tessellation.
80 Standard_Integer NbFacets() const { return myNbFacettes; }
82 //! Setup the number of facets for tessellation.
83 Standard_EXPORT void SetNbFacets (const Standard_Integer theNbFacets);
85 //! Return text aspect for specified axis.
86 //! @param theAxis [in] axis index
87 //! @return text aspect
88 const Handle(Prs3d_TextAspect)& LabelAspect (V3d_TypeOfAxe theAxis) const { return myTextAspects[theAxis]; }
90 //! Setup per-label color.
91 Standard_EXPORT void SetLabelsColor (const Quantity_Color& theXColor,
92 const Quantity_Color& theYColor,
93 const Quantity_Color& theZColor);
95 //! Setup color of text labels.
96 Standard_EXPORT void SetLabelsColor (const Quantity_Color& theColor);
98 //! Return shading aspect for specified axis.
99 //! @param theAxis [in] axis index
100 //! @return shading aspect
101 const Handle(Prs3d_ShadingAspect)& ArrowAspect (V3d_TypeOfAxe theAxis) const { return myArrowShadingAspects[theAxis]; }
103 //! Setup colors of arrows.
104 Standard_EXPORT void SetArrowsColor (const Quantity_Color& theXColor,
105 const Quantity_Color& theYColor,
106 const Quantity_Color& theZColor);
108 //! Return shading aspect of origin sphere.
109 const Handle(Prs3d_ShadingAspect)& OriginAspect() const { return mySphereShadingAspect; }
111 //! Return axis text.
112 //! @param theAxis [in] axis index
113 //! @return text of the label
114 const TCollection_AsciiString& Label (V3d_TypeOfAxe theAxis) const { return myLabels[theAxis]; }
116 //! Setup per-axis text.
117 Standard_EXPORT void SetLabels (const TCollection_AsciiString& theX,
118 const TCollection_AsciiString& theY,
119 const TCollection_AsciiString& theZ);
121 //! Display trihedron.
122 void Display (const Handle(V3d_View)& theView)
127 //! Display trihedron.
128 Standard_EXPORT void Display (const V3d_View& theView);
131 Standard_EXPORT void Erase();
133 //! Dumps the content of me into the stream
134 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
138 //! Fills Graphic3d_Group.
139 Standard_EXPORT void compute();
141 //! Invalidates objects. It leads recompute.
144 myToCompute = Standard_True;
147 //! Sets offset 2d for transform persistence.
148 Standard_EXPORT void setOffset2d();
152 //! Custom Graphic3d_Structure implementation.
153 class TrihedronStructure;
157 Handle(Prs3d_ShadingAspect) mySphereShadingAspect;
158 Handle(Prs3d_TextAspect) myTextAspects[3];
159 Handle(Prs3d_ShadingAspect) myArrowShadingAspects[3];
160 TCollection_AsciiString myLabels[3];
162 Handle(Graphic3d_Structure) myStructure;
163 Handle(Graphic3d_TransformPers) myTransformPers;
165 Standard_Real myScale;
166 Standard_Real myRatio;
167 Standard_Real myDiameter;
168 Standard_Integer myNbFacettes;
169 Standard_Boolean myIsWireframe;
170 Standard_Boolean myToCompute;
174 DEFINE_STANDARD_HANDLE (V3d_Trihedron, Standard_Transient)