0023510: Integration of test grid "vis" into the new testing system
[occt.git] / src / Prs2d / Prs2d_AspectText.cxx
1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
2 //
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
7 //
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10 //
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
17
18 #include <Prs2d_AspectText.ixx>
19 #include <Prs2d_AspectName.hxx>
20 #include <Aspect_GenericColorMap.hxx> 
21 #include <Aspect_FontMap.hxx> 
22
23 Prs2d_AspectText::Prs2d_AspectText( const Quantity_NameOfColor aColor,
24                         const Standard_CString aFont,
25                             const Quantity_Length aSize,
26                             const Aspect_TypeOfText aType,
27                             const Standard_Boolean isUnderlined )
28   : 
29     Prs2d_AspectRoot( Prs2d_AN_TEXT ),
30     myColor( aColor ),
31     myFont( aFont, aSize ),
32     myRelativeSlant(0.),
33     myType( aType ),
34     myIsUnderlined( isUnderlined ),
35     myFontIndex( 0 ),
36         myColorIndex( 0 )
37 { }
38
39 Prs2d_AspectText::Prs2d_AspectText( const Quantity_Color& aColor,
40                         const Aspect_FontStyle&  aFont,
41                             const Aspect_TypeOfText aType,
42                             const Standard_Boolean isUnderlined)
43   : 
44     Prs2d_AspectRoot( Prs2d_AN_TEXT ),
45     myColor( aColor ),
46     myFont( aFont ),
47     myRelativeSlant(0.),
48     myType( aType ),
49     myIsUnderlined( isUnderlined ),
50     myFontIndex( 0 ),
51         myColorIndex( 0 )
52 { }
53
54 void Prs2d_AspectText::SetColor( const Quantity_NameOfColor aColor ) {
55
56     SetColor(Quantity_Color(aColor));
57 }
58
59 void Prs2d_AspectText::SetColor( const Quantity_Color& aColor ) {
60
61     if( myColor != aColor ) {
62       myColor = aColor;
63       myColorIndex = 0;
64     }
65 }
66
67 void Prs2d_AspectText::SetFont( const Aspect_TypeOfFont aFont ) {
68
69     if( myFont.Style() != aFont ) {
70       myFont = Aspect_FontStyle(aFont,myFont.Size(),
71                                 myFont.Slant(),myFont.CapsHeight());
72       myFontIndex = 0;
73     }
74 }
75
76 void Prs2d_AspectText::SetFont( const Aspect_FontStyle& aFont ) {
77
78     if( myFont != aFont ) {
79       myFont = aFont;
80       myFontIndex = 0;
81     }
82 }
83
84 void Prs2d_AspectText::SetRelativeSlant( const Quantity_PlaneAngle aSlant ) {
85
86     myRelativeSlant = aSlant; 
87 }
88
89 void Prs2d_AspectText::SetHeight( const Quantity_Length anHeight,
90                                 const Standard_Boolean isCapsHeight ) {
91
92     if( myFont.Size() != anHeight || myFont.CapsHeight() != isCapsHeight ) {
93       myFont = Aspect_FontStyle(myFont.Style(),anHeight,
94                                 myFont.Slant(),isCapsHeight);
95       myFontIndex = 0;
96     }
97 }
98
99 void Prs2d_AspectText::SetType( const Aspect_TypeOfText aType ) {
100     myType = aType;
101 }
102
103 void Prs2d_AspectText::SetUnderlined( const Standard_Boolean anIsUnderline ) {
104     myIsUnderlined = anIsUnderline;
105 }
106
107 void Prs2d_AspectText::Values( Quantity_Color& aColor,
108                                        Aspect_FontStyle& aFont,
109                                        Quantity_PlaneAngle& aSlant,
110                                        Aspect_TypeOfText& aType,
111                                        Standard_Boolean& isUnderlined) const {
112     aColor = myColor;
113     aFont = myFont;
114     aSlant = myRelativeSlant + myFont.Slant();
115     aType = myType;
116     isUnderlined = myIsUnderlined;
117 }
118
119 Standard_Integer Prs2d_AspectText :: FontIndex (  ) const {
120
121   return myFontIndex;
122 }  // end Standard_Integer Prs2d_AspectText :: FontIndex
123
124 Standard_Integer Prs2d_AspectText :: ColorIndex (  ) const {
125
126  return myColorIndex;
127
128 }  // end Standard_Integer Prs2d_AspectText :: ColorIndex
129
130 void Prs2d_AspectText :: SetFontIndex ( const Standard_Integer anInd )  {
131
132    myFontIndex = anInd;
133
134 }  // end void Prs2d_AspectText :: SetFontIndex
135
136 void Prs2d_AspectText :: SetColorIndex ( const Standard_Integer anInd )  {
137
138   myColorIndex = anInd;
139
140 }  // end void Prs2d_AspectText :: SetColorIndex
141