0031511: Point Cloud Rendering, Volume Rendering - reuse Graphic3d_CullingTool
[occt.git] / src / Graphic3d / Graphic3d_Text.hxx
1 // Copyright (c) 2019 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _Graphic3d_Text_HeaderFile
15 #define _Graphic3d_Text_HeaderFile
16
17 #include <gp_Ax2.hxx>
18
19 #include <Graphic3d_Vertex.hxx>
20 #include <Graphic3d_HorizontalTextAlignment.hxx>
21 #include <Graphic3d_VerticalTextAlignment.hxx>
22 #include <NCollection_String.hxx>
23 #include <Standard_Type.hxx>
24 #include <Standard_Transient.hxx>
25 #include <TCollection_AsciiString.hxx>
26
27 //! This class allows the definition of a text object for display.
28 //! The text might be defined in one of ways, using:
29 //! - text value and position,
30 //! - text value, orientation and the state whether the text uses position as point of attach.
31 //! - text formatter. Formatter contains text, height and alignment parameter.
32 //!
33 //! This class also has parameters of the text height and H/V alignments.
34 class Graphic3d_Text : public Standard_Transient
35 {
36   DEFINE_STANDARD_RTTIEXT(Graphic3d_Text, Standard_Transient)
37
38 public:
39
40   //! Creates default text parameters.
41   Standard_EXPORT Graphic3d_Text (const Standard_ShortReal theHeight);
42
43   //! Destructor.
44   virtual ~Graphic3d_Text() {}
45
46   //! Returns text value.
47   const NCollection_String& Text() const { return myText; }
48
49   //! Sets text value.
50   void SetText (const NCollection_String& theText) { myText = theText; }
51
52   //! Sets text value.
53   void SetText (const TCollection_AsciiString& theText) { myText = theText.ToCString(); }
54
55   //! Sets text value.
56   void SetText (Standard_CString theText) { myText = theText; }
57
58   //! The 3D point of attachment is projected.
59   //! If the orientation is defined, the text is written in the plane of projection.
60   const gp_Pnt& Position() const { return myOrientation.Location(); }
61
62   //! Sets text point.
63   void SetPosition (const gp_Pnt& thePoint) { myOrientation.SetLocation (thePoint); }
64
65   //! Returns text orientation in 3D space.
66   const gp_Ax2& Orientation() const { return myOrientation; }
67
68   //! Returns true if the text is filled by a point
69   Standard_Boolean HasPlane() const { return myHasPlane; }
70
71   //! Sets text orientation in 3D space.
72   Standard_EXPORT void SetOrientation (const gp_Ax2& theOrientation);
73
74   //! Reset text orientation in 3D space.
75   Standard_EXPORT void ResetOrientation();
76
77   //! Returns true if the text has an anchor point
78   Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchor; }
79
80   //! Returns true if the text has an anchor point
81   void SetOwnAnchorPoint (const Standard_Boolean theHasOwnAnchor) { myHasOwnAnchor = theHasOwnAnchor; }
82
83   //! Sets height of text. (Relative to the Normalized Projection Coordinates (NPC) Space).
84   Standard_ShortReal Height() const { return myHeight; }
85
86   //! Returns height of text
87   void SetHeight (const Standard_ShortReal theHeight) { myHeight = theHeight; }
88
89   //! Returns horizontal alignment of text.
90   Graphic3d_HorizontalTextAlignment HorizontalAlignment() const { return myHAlign; }
91
92   //! Sets horizontal alignment of text.
93   void SetHorizontalAlignment (const Graphic3d_HorizontalTextAlignment theJustification) { myHAlign = theJustification; }
94
95   //! Returns vertical alignment of text.
96   Graphic3d_VerticalTextAlignment VerticalAlignment() const { return myVAlign; }
97
98   //! Sets vertical alignment of text.
99   void SetVerticalAlignment (const Graphic3d_VerticalTextAlignment theJustification) { myVAlign = theJustification; }
100
101 protected:
102   NCollection_String myText; //!< text value
103   gp_Ax2 myOrientation; //!< Text orientation in 3D space.
104
105   Standard_ShortReal myHeight; //!< height of text
106   Graphic3d_HorizontalTextAlignment myHAlign; //!< horizontal alignment
107   Graphic3d_VerticalTextAlignment myVAlign; //!< vertical alignment
108
109   Standard_Boolean myHasPlane; //!< Check if text have orientation in 3D space.
110   Standard_Boolean myHasOwnAnchor; //!< flag if text uses position as point of attach
111 };
112
113 DEFINE_STANDARD_HANDLE(Graphic3d_Text, Standard_Transient)
114
115 #endif // _Graphic3d_Text_HeaderFile