0029570: Visualization, Graphic3d_Aspect - merge Graphic3d_Group aspects
[occt.git] / src / Prs3d / Prs3d_TextAspect.hxx
1 // Created on: 1993-09-14
2 // Created by: Jean-Louis FRENKEL
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _Prs3d_TextAspect_HeaderFile
18 #define _Prs3d_TextAspect_HeaderFile
19
20 #include <Graphic3d_AspectText3d.hxx>
21 #include <Graphic3d_TextPath.hxx>
22 #include <Graphic3d_HorizontalTextAlignment.hxx>
23 #include <Graphic3d_VerticalTextAlignment.hxx>
24 #include <Prs3d_BasicAspect.hxx>
25
26 //! Defines the attributes when displaying a text.
27 class Prs3d_TextAspect : public Prs3d_BasicAspect
28 {
29   DEFINE_STANDARD_RTTIEXT(Prs3d_TextAspect, Prs3d_BasicAspect)
30 public:
31
32   //! Constructs an empty framework for defining display attributes of text.
33   Standard_EXPORT Prs3d_TextAspect();
34   
35   Standard_EXPORT Prs3d_TextAspect(const Handle(Graphic3d_AspectText3d)& theAspect);
36
37   //! Sets the color of the type used in text display.
38   void SetColor (const Quantity_Color& theColor) { myTextAspect->SetColor (theColor); }
39
40   //! Sets the font used in text display.
41   void SetFont (const Standard_CString theFont) { myTextAspect->SetFont (theFont); }
42
43   //! Sets the height of the text.
44   void SetHeight (const Standard_Real theHeight) { myHeight = theHeight; }
45   
46   //! Sets the angle
47   void SetAngle (const Standard_Real theAngle) { myTextAspect->SetTextAngle (theAngle); }
48   
49   //! Returns the height of the text box.
50   Standard_Real Height() const { return myHeight; }
51   
52   //! Returns the angle
53   Standard_Real Angle() const { return myTextAspect->GetTextAngle(); }
54   
55   //! Sets horizontal alignment of text.
56   void SetHorizontalJustification (const Graphic3d_HorizontalTextAlignment theJustification) { myHorizontalJustification = theJustification; }
57   
58   //! Sets the vertical alignment of text.
59   void SetVerticalJustification (const Graphic3d_VerticalTextAlignment theJustification) { myVerticalJustification = theJustification; }
60   
61   //! Sets the orientation of text.
62   void SetOrientation (const Graphic3d_TextPath theOrientation) { myOrientation = theOrientation; }
63   
64   //! Returns the horizontal alignment of the text.
65   //! The range of values includes:
66   //! -   left
67   //! -   center
68   //! -   right, and
69   //! -   normal (justified).
70   Graphic3d_HorizontalTextAlignment HorizontalJustification() const { return myHorizontalJustification; }
71   
72   //! Returns the vertical alignment of the text.
73   //! The range of values includes:
74   //! -   normal
75   //! -   top
76   //! -   cap
77   //! -   half
78   //! -   base
79   //! -   bottom
80   Graphic3d_VerticalTextAlignment VerticalJustification() const { return myVerticalJustification; }
81   
82   //! Returns the orientation of the text.
83   //! Text can be displayed in the following directions:
84   //! -   up
85   //! -   down
86   //! -   left, or
87   //! -   right
88   Graphic3d_TextPath Orientation() const { return myOrientation; }
89
90   //! Returns the purely textual attributes used in the display of text.
91   //! These include:
92   //! -   color
93   //! -   font
94   //! -   height/width ratio, that is, the expansion factor, and
95   //! -   space between characters.
96   const Handle(Graphic3d_AspectText3d)& Aspect() const { return myTextAspect; }
97
98   void SetAspect (const Handle(Graphic3d_AspectText3d)& theAspect) { myTextAspect = theAspect; }
99
100 protected:
101
102   Handle(Graphic3d_AspectText3d) myTextAspect;
103   Standard_Real myHeight;
104   Graphic3d_HorizontalTextAlignment myHorizontalJustification;
105   Graphic3d_VerticalTextAlignment myVerticalJustification;
106   Graphic3d_TextPath myOrientation;
107
108 };
109
110 DEFINE_STANDARD_HANDLE(Prs3d_TextAspect, Prs3d_BasicAspect)
111
112 #endif // _Prs3d_TextAspect_HeaderFile