0024428: Implementation of LGPL license
[occt.git] / src / Aspect / Aspect_FontMapEntry.cxx
1 // Created on: 1993-09-14
2 // Created by: GG
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
9 // under the terms of the GNU Lesser General Public 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 //-Version
18
19 //-Design       Declaration des variables specifiques aux Entries de
20 //              Fontures de texts
21
22 //-Warning      Une entry est definie par un index associee a une Font style
23
24 //-References
25
26 //-Language     C++ 2.0
27
28 //-Declarations
29
30 // for the class
31 #include <Aspect_FontMapEntry.ixx>
32 #include <Aspect_Units.hxx>
33
34 //-Aliases
35
36 //-Global data definitions
37
38 //      MyType                  : FontStyle from Aspect
39 //      MyIndex                 : Integer from Standard
40 //      MyTypeIsDef             : Boolean from Standard
41 //      MyIndexIsDef            : Boolean from Standard
42
43 //-Constructors
44
45 //-Destructors
46
47 //-Methods, in order
48
49 Aspect_FontMapEntry::Aspect_FontMapEntry() {
50
51         MyTypeIsDef     = Standard_True;
52         MyIndexIsDef    = Standard_True;
53         MyIndex         = 0;
54         MyType.SetValues (Aspect_TOF_DEFAULT,3.0 MILLIMETER);
55
56 }
57
58 Aspect_FontMapEntry::Aspect_FontMapEntry (const Standard_Integer index, const Aspect_FontStyle &style) {
59
60         MyTypeIsDef     = Standard_True;
61         MyIndexIsDef    = Standard_True;
62         MyIndex         = index;
63         MyType          = style;
64
65 }
66
67 Aspect_FontMapEntry::Aspect_FontMapEntry (const Aspect_FontMapEntry& entry) {
68
69         if ( !entry.MyTypeIsDef || !entry.MyIndexIsDef ) {
70                 Aspect_BadAccess::Raise("Unallocated FontMapEntry") ;
71         }
72         else {
73                 MyTypeIsDef     = Standard_True;
74                 MyIndexIsDef    = Standard_True;
75                 MyIndex         = entry.MyIndex;
76                 MyType          = entry.MyType;
77         }
78 }
79
80 void Aspect_FontMapEntry::SetValue (const Standard_Integer index, const Aspect_FontStyle &style) {
81
82         MyTypeIsDef     = Standard_True;
83         MyIndexIsDef    = Standard_True;
84         MyIndex         = index;
85         MyType          = style;
86
87 }
88
89 void Aspect_FontMapEntry::SetValue (const Aspect_FontMapEntry& entry) {
90
91         if ( !entry.MyTypeIsDef || !entry.MyIndexIsDef ) {
92                 Aspect_BadAccess::Raise("Unallocated FontMapEntry") ;
93         }
94         else {
95                 MyTypeIsDef     = Standard_True;
96                 MyIndexIsDef    = Standard_True;
97                 MyIndex         = entry.MyIndex;
98                 MyType          = entry.MyType;
99         }
100
101 }
102
103 void Aspect_FontMapEntry::SetType (const Aspect_FontStyle &style) {
104
105         MyTypeIsDef     = Standard_True;
106         MyType          = style;
107
108 }
109
110 const Aspect_FontStyle& Aspect_FontMapEntry::Type () const {
111
112         if ( !MyTypeIsDef || !MyIndexIsDef ) 
113                 Aspect_BadAccess::Raise("Unallocated FontMapEntry") ;
114
115         return MyType;
116
117 }
118
119 void Aspect_FontMapEntry::SetIndex (const Standard_Integer index) {
120
121         MyTypeIsDef     = Standard_True;
122         MyIndex         = index;
123
124 }
125
126 Standard_Integer Aspect_FontMapEntry::Index () const {
127
128         if ( !MyTypeIsDef || !MyIndexIsDef ) 
129                 Aspect_BadAccess::Raise("Unallocated FontMapEntry");
130
131         return MyIndex;
132
133 }
134
135 Standard_Boolean Aspect_FontMapEntry::IsAllocated () const {
136
137         return ( MyTypeIsDef && MyIndexIsDef ) ; 
138
139 }
140
141 void Aspect_FontMapEntry::Free () {
142
143         MyTypeIsDef     = Standard_False;
144         MyIndexIsDef    = Standard_False;
145
146 }
147
148 void Aspect_FontMapEntry::Dump () const
149 {
150   Aspect_TypeOfFont style = MyType.Style();
151   Standard_CString string = MyType.Value();
152   Standard_Real size = MyType.Size();
153   Standard_Real slant = MyType.Slant();
154   Standard_Integer length = MyType.Length();
155   Standard_Boolean capsheight = MyType.CapsHeight();
156
157   cout << " Aspect_FontMapEntry::Dump ()\n";
158   cout << "      MyTypeIsDef : " << (MyTypeIsDef ? "True\n" : "False\n");
159   cout << "      MyIndexIsDef : " << (MyIndexIsDef ? "True\n" : "False\n");
160   cout << "      FontStyle : " << (Standard_Integer) style << " Size : " << size
161        << " Slant : " << slant << endl;
162   cout << "      CapsHeight : " << (capsheight ? "True\n" : "False\n");
163   cout << "      FontStyle length : " << length << "\n";
164   if( length ) cout << "      FontString : " << string << "\n";
165   MyType.Dump ();
166   cout << " ------------------------------" << endl << flush;
167 }