Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:30

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 
0034   //! Creates a default trihedron.
0035   Standard_EXPORT V3d_Trihedron();
0036 
0037   //! Destructor.
0038   Standard_EXPORT virtual ~V3d_Trihedron();
0039 
0040   //! Return TRUE if wireframe presentation is set; FALSE by default.
0041   bool IsWireframe() const { return myIsWireframe; }
0042 
0043   //! Switch wireframe / shaded trihedron.
0044   void SetWireframe (const Standard_Boolean theAsWireframe)
0045   {
0046     if (myIsWireframe != theAsWireframe)
0047     {
0048       invalidate();
0049       myIsWireframe = theAsWireframe;
0050     }
0051   }
0052 
0053   //! Return trihedron position.
0054   const Handle(Graphic3d_TransformPers) TransformPersistence() const { return myTransformPers; }
0055 
0056   //! Setup the corner to draw the trihedron.
0057   Standard_EXPORT void SetPosition (const Aspect_TypeOfTriedronPosition thePosition);
0058 
0059   //! Return scale factor.
0060   Standard_Real Scale() const { return myScale; }
0061 
0062   //! Setup the scale factor.
0063   Standard_EXPORT void SetScale (const Standard_Real theScale);
0064 
0065   //! Return size ratio factor.
0066   Standard_Real SizeRatio() const { return myRatio; }
0067 
0068   //! Setup the size ratio factor.
0069   Standard_EXPORT void SetSizeRatio (const Standard_Real theRatio);
0070 
0071   //! Return arrow diameter.
0072   Standard_Real ArrowDiameter() const { return myDiameter; }
0073 
0074   //! Setup the arrow diameter.
0075   Standard_EXPORT void SetArrowDiameter (const Standard_Real theDiam);
0076 
0077   //! Return number of facets for tessellation.
0078   Standard_Integer NbFacets() const { return myNbFacettes; }
0079 
0080   //! Setup the number of facets for tessellation.
0081   Standard_EXPORT void SetNbFacets (const Standard_Integer theNbFacets);
0082 
0083   //! Return text aspect for specified axis.
0084   //! @param theAxis [in] axis index
0085   //! @return text aspect
0086   const Handle(Prs3d_TextAspect)& LabelAspect (V3d_TypeOfAxe theAxis) const { return myTextAspects[theAxis]; }
0087 
0088   //! Setup per-label color.
0089   Standard_EXPORT void SetLabelsColor (const Quantity_Color& theXColor,
0090                                        const Quantity_Color& theYColor,
0091                                        const Quantity_Color& theZColor);
0092 
0093   //! Setup color of text labels.
0094   Standard_EXPORT void SetLabelsColor (const Quantity_Color& theColor);
0095 
0096   //! Return shading aspect for specified axis.
0097   //! @param theAxis [in] axis index
0098   //! @return shading aspect
0099   const Handle(Prs3d_ShadingAspect)& ArrowAspect (V3d_TypeOfAxe theAxis) const { return myArrowShadingAspects[theAxis]; }
0100 
0101   //! Setup colors of arrows.
0102   Standard_EXPORT void SetArrowsColor (const Quantity_Color& theXColor,
0103                                        const Quantity_Color& theYColor,
0104                                        const Quantity_Color& theZColor);
0105 
0106   //! Return shading aspect of origin sphere.
0107   const Handle(Prs3d_ShadingAspect)& OriginAspect() const { return mySphereShadingAspect; }
0108 
0109   //! Return axis text.
0110   //! @param theAxis [in] axis index
0111   //! @return text of the label
0112   const TCollection_AsciiString& Label (V3d_TypeOfAxe theAxis) const { return myLabels[theAxis]; }
0113 
0114   //! Setup per-axis text.
0115   Standard_EXPORT void SetLabels (const TCollection_AsciiString& theX,
0116                                   const TCollection_AsciiString& theY,
0117                                   const TCollection_AsciiString& theZ);
0118 
0119   //! Display trihedron.
0120   void Display (const Handle(V3d_View)& theView)
0121   {
0122     Display (*theView);
0123   }
0124 
0125   //! Display trihedron.
0126   Standard_EXPORT void Display (const V3d_View& theView);
0127 
0128   //! Erase trihedron.
0129   Standard_EXPORT void Erase();
0130   
0131   //! Dumps the content of me into the stream
0132   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0133 
0134 protected:
0135 
0136   //! Fills Graphic3d_Group.
0137   Standard_EXPORT void compute();
0138 
0139   //! Invalidates objects. It leads recompute.
0140   void invalidate()
0141   {
0142     myToCompute = Standard_True;
0143   }
0144 
0145   //! Sets offset 2d for transform persistence.
0146   Standard_EXPORT void setOffset2d();
0147 
0148 private:
0149 
0150   //! Custom Graphic3d_Structure implementation.
0151   class TrihedronStructure;
0152 
0153 protected:
0154 
0155   Handle(Prs3d_ShadingAspect)        mySphereShadingAspect;
0156   Handle(Prs3d_TextAspect)           myTextAspects[3];
0157   Handle(Prs3d_ShadingAspect)        myArrowShadingAspects[3];
0158   TCollection_AsciiString            myLabels[3];
0159 
0160   Handle(Graphic3d_Structure)        myStructure;
0161   Handle(Graphic3d_TransformPers)    myTransformPers;
0162 
0163   Standard_Real                      myScale;
0164   Standard_Real                      myRatio;
0165   Standard_Real                      myDiameter;
0166   Standard_Integer                   myNbFacettes;
0167   Standard_Boolean                   myIsWireframe;
0168   Standard_Boolean                   myToCompute;
0169 
0170 };
0171 
0172 DEFINE_STANDARD_HANDLE (V3d_Trihedron, Standard_Transient)
0173 
0174 #endif