Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-17 09:15:10

0001 // Created on: 2016-10-11
0002 // Created by: Ilya SEVRIKOV
0003 // Copyright (c) 2016 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _V3d_Trihedron_HeaderFile
0017 #define _V3d_Trihedron_HeaderFile
0018 
0019 #include <Graphic3d_StructureManager.hxx>
0020 #include <Graphic3d_TransformPers.hxx>
0021 #include <Prs3d_LineAspect.hxx>
0022 #include <Prs3d_ShadingAspect.hxx>
0023 #include <Prs3d_TextAspect.hxx>
0024 #include <V3d_TypeOfAxe.hxx>
0025 
0026 class V3d_View;
0027 
0028 //! Class for presentation of trihedron object.
0029 class V3d_Trihedron : public Standard_Transient
0030 {
0031   DEFINE_STANDARD_RTTIEXT(V3d_Trihedron, Standard_Transient)
0032 public:
0033   //! Creates a default trihedron.
0034   Standard_EXPORT V3d_Trihedron();
0035 
0036   //! Destructor.
0037   Standard_EXPORT virtual ~V3d_Trihedron();
0038 
0039   //! Return TRUE if wireframe presentation is set; FALSE by default.
0040   bool IsWireframe() const { return myIsWireframe; }
0041 
0042   //! Switch wireframe / shaded trihedron.
0043   void SetWireframe(const Standard_Boolean theAsWireframe)
0044   {
0045     if (myIsWireframe != theAsWireframe)
0046     {
0047       invalidate();
0048       myIsWireframe = theAsWireframe;
0049     }
0050   }
0051 
0052   //! Return trihedron position.
0053   const Handle(Graphic3d_TransformPers) TransformPersistence() const { return myTransformPers; }
0054 
0055   //! Setup the corner to draw the trihedron.
0056   Standard_EXPORT void SetPosition(const Aspect_TypeOfTriedronPosition thePosition);
0057 
0058   //! Return scale factor.
0059   Standard_Real Scale() const { return myScale; }
0060 
0061   //! Setup the scale factor.
0062   Standard_EXPORT void SetScale(const Standard_Real theScale);
0063 
0064   //! Return size ratio factor.
0065   Standard_Real SizeRatio() const { return myRatio; }
0066 
0067   //! Setup the size ratio factor.
0068   Standard_EXPORT void SetSizeRatio(const Standard_Real theRatio);
0069 
0070   //! Return arrow diameter.
0071   Standard_Real ArrowDiameter() const { return myDiameter; }
0072 
0073   //! Setup the arrow diameter.
0074   Standard_EXPORT void SetArrowDiameter(const Standard_Real theDiam);
0075 
0076   //! Return number of facets for tessellation.
0077   Standard_Integer NbFacets() const { return myNbFacettes; }
0078 
0079   //! Setup the number of facets for tessellation.
0080   Standard_EXPORT void SetNbFacets(const Standard_Integer theNbFacets);
0081 
0082   //! Return text aspect for specified axis.
0083   //! @param[in] theAxis  axis index
0084   //! @return text aspect
0085   const Handle(Prs3d_TextAspect)& LabelAspect(V3d_TypeOfAxe theAxis) const
0086   {
0087     return myTextAspects[theAxis];
0088   }
0089 
0090   //! Setup per-label color.
0091   Standard_EXPORT void SetLabelsColor(const Quantity_Color& theXColor,
0092                                       const Quantity_Color& theYColor,
0093                                       const Quantity_Color& theZColor);
0094 
0095   //! Setup color of text labels.
0096   Standard_EXPORT void SetLabelsColor(const Quantity_Color& theColor);
0097 
0098   //! Return shading aspect for specified axis.
0099   //! @param[in] theAxis  axis index
0100   //! @return shading aspect
0101   const Handle(Prs3d_ShadingAspect)& ArrowAspect(V3d_TypeOfAxe theAxis) const
0102   {
0103     return myArrowShadingAspects[theAxis];
0104   }
0105 
0106   //! Setup colors of arrows.
0107   Standard_EXPORT void SetArrowsColor(const Quantity_Color& theXColor,
0108                                       const Quantity_Color& theYColor,
0109                                       const Quantity_Color& theZColor);
0110 
0111   //! Return shading aspect of origin sphere.
0112   const Handle(Prs3d_ShadingAspect)& OriginAspect() const { return mySphereShadingAspect; }
0113 
0114   //! Return axis text.
0115   //! @param[in] theAxis  axis index
0116   //! @return text of the label
0117   const TCollection_AsciiString& Label(V3d_TypeOfAxe theAxis) const { return myLabels[theAxis]; }
0118 
0119   //! Setup per-axis text.
0120   Standard_EXPORT void SetLabels(const TCollection_AsciiString& theX,
0121                                  const TCollection_AsciiString& theY,
0122                                  const TCollection_AsciiString& theZ);
0123 
0124   //! Display trihedron.
0125   void Display(const Handle(V3d_View)& theView) { Display(*theView); }
0126 
0127   //! Display trihedron.
0128   Standard_EXPORT void Display(const V3d_View& theView);
0129 
0130   //! Erase trihedron.
0131   Standard_EXPORT void Erase();
0132 
0133   //! Dumps the content of me into the stream
0134   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0135 
0136 protected:
0137   //! Fills Graphic3d_Group.
0138   Standard_EXPORT void compute();
0139 
0140   //! Invalidates objects. It leads recompute.
0141   void invalidate() { myToCompute = Standard_True; }
0142 
0143   //! Sets offset 2d for transform persistence.
0144   Standard_EXPORT void setOffset2d();
0145 
0146 private:
0147   //! Custom Graphic3d_Structure implementation.
0148   class TrihedronStructure;
0149 
0150 protected:
0151   Handle(Prs3d_ShadingAspect) mySphereShadingAspect;
0152   Handle(Prs3d_TextAspect)    myTextAspects[3];
0153   Handle(Prs3d_ShadingAspect) myArrowShadingAspects[3];
0154   TCollection_AsciiString     myLabels[3];
0155 
0156   Handle(Graphic3d_Structure)     myStructure;
0157   Handle(Graphic3d_TransformPers) myTransformPers;
0158 
0159   Standard_Real    myScale;
0160   Standard_Real    myRatio;
0161   Standard_Real    myDiameter;
0162   Standard_Integer myNbFacettes;
0163   Standard_Boolean myIsWireframe;
0164   Standard_Boolean myToCompute;
0165 };
0166 
0167 DEFINE_STANDARD_HANDLE(V3d_Trihedron, Standard_Transient)
0168 
0169 #endif