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_StructureManager.hxx>
20 #include <Graphic3d_TransformPers.hxx>
21 #include <Prs3d_LineAspect.hxx>
22 #include <Prs3d_ShadingAspect.hxx>
23 #include <Prs3d_TextAspect.hxx>
24 #include <V3d_TypeOfAxe.hxx>
28 //! Class for presentation of trihedron object.
29 class V3d_Trihedron : public Standard_Transient
31 DEFINE_STANDARD_RTTIEXT(V3d_Trihedron, Standard_Transient)
34 //! Creates a default trihedron.
35 Standard_EXPORT V3d_Trihedron();
38 Standard_EXPORT virtual ~V3d_Trihedron();
40 //! Return TRUE if wireframe presentation is set; FALSE by default.
41 bool IsWireframe() const { return myIsWireframe; }
43 //! Switch wireframe / shaded trihedron.
44 void SetWireframe (const Standard_Boolean theAsWireframe)
46 if (myIsWireframe != theAsWireframe)
49 myIsWireframe = theAsWireframe;
53 //! Return trihedron position.
54 const Handle(Graphic3d_TransformPers) TransformPersistence() const { return myTransformPers; }
56 //! Setup the corner to draw the trihedron.
57 Standard_EXPORT void SetPosition (const Aspect_TypeOfTriedronPosition thePosition);
59 //! Return scale factor.
60 Standard_Real Scale() const { return myScale; }
62 //! Setup the scale factor.
63 Standard_EXPORT void SetScale (const Standard_Real theScale);
65 //! Return size ratio factor.
66 Standard_Real SizeRatio() const { return myRatio; }
68 //! Setup the size ratio factor.
69 Standard_EXPORT void SetSizeRatio (const Standard_Real theRatio);
71 //! Return arrow diameter.
72 Standard_Real ArrowDiameter() const { return myDiameter; }
74 //! Setup the arrow diameter.
75 Standard_EXPORT void SetArrowDiameter (const Standard_Real theDiam);
77 //! Return number of facets for tessellation.
78 Standard_Integer NbFacets() const { return myNbFacettes; }
80 //! Setup the number of facets for tessellation.
81 Standard_EXPORT void SetNbFacets (const Standard_Integer theNbFacets);
83 //! Return text aspect for specified axis.
84 //! @param theAxis [in] axis index
85 //! @return text aspect
86 const Handle(Prs3d_TextAspect)& LabelAspect (V3d_TypeOfAxe theAxis) const { return myTextAspects[theAxis]; }
88 //! Setup per-label color.
89 Standard_EXPORT void SetLabelsColor (const Quantity_Color& theXColor,
90 const Quantity_Color& theYColor,
91 const Quantity_Color& theZColor);
93 //! Setup color of text labels.
94 Standard_EXPORT void SetLabelsColor (const Quantity_Color& theColor);
96 //! Return shading aspect for specified axis.
97 //! @param theAxis [in] axis index
98 //! @return shading aspect
99 const Handle(Prs3d_ShadingAspect)& ArrowAspect (V3d_TypeOfAxe theAxis) const { return myArrowShadingAspects[theAxis]; }
101 //! Setup colors of arrows.
102 Standard_EXPORT void SetArrowsColor (const Quantity_Color& theXColor,
103 const Quantity_Color& theYColor,
104 const Quantity_Color& theZColor);
106 //! Return shading aspect of origin sphere.
107 const Handle(Prs3d_ShadingAspect)& OriginAspect() const { return mySphereShadingAspect; }
109 //! Return axis text.
110 //! @param theAxis [in] axis index
111 //! @return text of the label
112 const TCollection_AsciiString& Label (V3d_TypeOfAxe theAxis) const { return myLabels[theAxis]; }
114 //! Setup per-axis text.
115 Standard_EXPORT void SetLabels (const TCollection_AsciiString& theX,
116 const TCollection_AsciiString& theY,
117 const TCollection_AsciiString& theZ);
119 //! Display trihedron.
120 void Display (const Handle(V3d_View)& theView)
125 //! Display trihedron.
126 Standard_EXPORT void Display (const V3d_View& theView);
129 Standard_EXPORT void Erase();
131 //! Dumps the content of me into the stream
132 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
136 //! Fills Graphic3d_Group.
137 Standard_EXPORT void compute();
139 //! Invalidates objects. It leads recompute.
142 myToCompute = Standard_True;
145 //! Sets offset 2d for transform persistence.
146 Standard_EXPORT void setOffset2d();
150 //! Custom Graphic3d_Structure implementation.
151 class TrihedronStructure;
155 Handle(Prs3d_ShadingAspect) mySphereShadingAspect;
156 Handle(Prs3d_TextAspect) myTextAspects[3];
157 Handle(Prs3d_ShadingAspect) myArrowShadingAspects[3];
158 TCollection_AsciiString myLabels[3];
160 Handle(Graphic3d_Structure) myStructure;
161 Handle(Graphic3d_TransformPers) myTransformPers;
163 Standard_Real myScale;
164 Standard_Real myRatio;
165 Standard_Real myDiameter;
166 Standard_Integer myNbFacettes;
167 Standard_Boolean myIsWireframe;
168 Standard_Boolean myToCompute;
172 DEFINE_STANDARD_HANDLE (V3d_Trihedron, Standard_Transient)