Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:49

0001 // Copyright (c) 2019 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Graphic3d_Text_HeaderFile
0015 #define _Graphic3d_Text_HeaderFile
0016 
0017 #include <gp_Ax2.hxx>
0018 
0019 #include <Font_TextFormatter.hxx>
0020 #include <Graphic3d_HorizontalTextAlignment.hxx>
0021 #include <Graphic3d_VerticalTextAlignment.hxx>
0022 #include <NCollection_String.hxx>
0023 #include <Standard_Type.hxx>
0024 #include <Standard_Transient.hxx>
0025 #include <TCollection_AsciiString.hxx>
0026 
0027 //! This class allows the definition of a text object for display.
0028 //! The text might be defined in one of ways, using:
0029 //! - text value and position,
0030 //! - text value, orientation and the state whether the text uses position as point of attach.
0031 //! - text formatter. Formatter contains text, height and alignment parameter.
0032 //!
0033 //! This class also has parameters of the text height and H/V alignments.
0034 //! Custom formatting is available using Font_TextFormatter.
0035 class Graphic3d_Text : public Standard_Transient
0036 {
0037   DEFINE_STANDARD_RTTIEXT(Graphic3d_Text, Standard_Transient)
0038 
0039 public:
0040 
0041   //! Creates default text parameters.
0042   Standard_EXPORT Graphic3d_Text (const Standard_ShortReal theHeight);
0043 
0044   //! Destructor.
0045   virtual ~Graphic3d_Text() {}
0046 
0047   //! Returns text value.
0048   const NCollection_String& Text() const { return myText; }
0049 
0050   //! Sets text value.
0051   void SetText (const NCollection_String& theText) { myText = theText; }
0052 
0053   //! Sets text value.
0054   void SetText (const TCollection_AsciiString& theText) { myText = theText.ToCString(); }
0055 
0056   //! Sets text value.
0057   void SetText (Standard_CString theText) { myText = theText; }
0058 
0059   //! @return text formatter; NULL by default, which means standard text formatter will be used.
0060   const Handle(Font_TextFormatter)& TextFormatter() const { return myFormatter; }
0061 
0062   //! Setup text default formatter for text within this context.
0063   void SetTextFormatter (const Handle(Font_TextFormatter)& theFormatter) { myFormatter = theFormatter; }
0064 
0065   //! The 3D point of attachment is projected.
0066   //! If the orientation is defined, the text is written in the plane of projection.
0067   const gp_Pnt& Position() const { return myOrientation.Location(); }
0068 
0069   //! Sets text point.
0070   void SetPosition (const gp_Pnt& thePoint) { myOrientation.SetLocation (thePoint); }
0071 
0072   //! Returns text orientation in 3D space.
0073   const gp_Ax2& Orientation() const { return myOrientation; }
0074 
0075   //! Returns true if the text is filled by a point
0076   Standard_Boolean HasPlane() const { return myHasPlane; }
0077 
0078   //! Sets text orientation in 3D space.
0079   Standard_EXPORT void SetOrientation (const gp_Ax2& theOrientation);
0080 
0081   //! Reset text orientation in 3D space.
0082   Standard_EXPORT void ResetOrientation();
0083 
0084   //! Returns true if the text has an anchor point
0085   Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchor; }
0086 
0087   //! Returns true if the text has an anchor point
0088   void SetOwnAnchorPoint (const Standard_Boolean theHasOwnAnchor) { myHasOwnAnchor = theHasOwnAnchor; }
0089 
0090   //! Sets height of text. (Relative to the Normalized Projection Coordinates (NPC) Space).
0091   Standard_ShortReal Height() const { return myHeight; }
0092 
0093   //! Returns height of text
0094   void SetHeight (const Standard_ShortReal theHeight) { myHeight = theHeight; }
0095 
0096   //! Returns horizontal alignment of text.
0097   Graphic3d_HorizontalTextAlignment HorizontalAlignment() const { return myHAlign; }
0098 
0099   //! Sets horizontal alignment of text.
0100   void SetHorizontalAlignment (const Graphic3d_HorizontalTextAlignment theJustification) { myHAlign = theJustification; }
0101 
0102   //! Returns vertical alignment of text.
0103   Graphic3d_VerticalTextAlignment VerticalAlignment() const { return myVAlign; }
0104 
0105   //! Sets vertical alignment of text.
0106   void SetVerticalAlignment (const Graphic3d_VerticalTextAlignment theJustification) { myVAlign = theJustification; }
0107 
0108 protected:
0109   Handle(Font_TextFormatter) myFormatter; //!< text formatter
0110 
0111   NCollection_String myText; //!< text value
0112   gp_Ax2 myOrientation; //!< Text orientation in 3D space.
0113 
0114   Standard_ShortReal myHeight; //!< height of text
0115   Graphic3d_HorizontalTextAlignment myHAlign; //!< horizontal alignment
0116   Graphic3d_VerticalTextAlignment myVAlign; //!< vertical alignment
0117 
0118   Standard_Boolean myHasPlane; //!< Check if text have orientation in 3D space.
0119   Standard_Boolean myHasOwnAnchor; //!< flag if text uses position as point of attach
0120 };
0121 
0122 DEFINE_STANDARD_HANDLE(Graphic3d_Text, Standard_Transient)
0123 
0124 #endif // _Graphic3d_Text_HeaderFile