0024624: Lost word in license statement in source files
[occt.git] / src / Aspect / Aspect_FontMap.cxx
CommitLineData
b311480e 1// Created on: 1993-09-14
2// Created by: GG
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17//-Version
18
19//-Design Declaration des variables specifiques aux Ensembles
20// de Fontures de texts
21
22//-Warning Une FontMap est definie par un ensemble de FontMapEntries
23
24//-References
25
26//-Language C++ 2.0
27
28//-Declarations
29
30// for the class
31#include <Aspect_FontMap.ixx>
32
33//-Aliases
34
35//-Global data definitions
36
37// mydata : SequenceOfFontMapEntry from Aspect is protected
38
39//-Constructors
40
41//-Destructors
42
43//-Methods, in order
44
45Aspect_FontMap::Aspect_FontMap( ) {
46Aspect_FontMapEntry theDefaultEntry;
47
48 AddEntry(theDefaultEntry);
49}
50
51void Aspect_FontMap::AddEntry (const Aspect_FontMapEntry& AnEntry) {
52Standard_Integer i,index = AnEntry.Index();
53Aspect_FontMapEntry theEntry;
54
55 for( i=1 ; i<=mydata.Length() ; i++ ) {
56 theEntry = mydata.Value(i);
57 if( index == theEntry.Index() ) break;
58 }
59
60 if( i > mydata.Length() ) {
61 mydata.Append( AnEntry );
62 } else {
63 mydata.SetValue(i,AnEntry);
64 }
65}
66
67Standard_Integer Aspect_FontMap::AddEntry (const Aspect_FontStyle &aStyle) {
68Aspect_FontMapEntry theEntry ;
69Standard_Integer i,maxindex = 0 ;
70
71 for( i=1 ; i<=mydata.Length() ; i++ ) {
72 theEntry = mydata.Value(i) ;
73 maxindex = Max(maxindex,theEntry.Index()) ;
74 if( theEntry.Type() == aStyle ) return theEntry.Index() ;
75 }
76
77 maxindex++ ;
78 theEntry.SetValue(maxindex,aStyle) ;
79 mydata.Append( theEntry ) ;
80 return maxindex ;
81}
82
83Standard_Integer Aspect_FontMap::Size() const {
84
85 return mydata.Length() ;
86}
87
88Standard_Integer Aspect_FontMap::Index(const Standard_Integer anIndex) const {
89
90 if( anIndex < 1 || anIndex > Size() ) {
91 Aspect_BadAccess::Raise ("Undefined fontmap Index");
92 }
93
94 Aspect_FontMapEntry theEntry = mydata.Value(anIndex) ;
95
96 return theEntry.Index() ;
97}
98
99Aspect_FontMapEntry Aspect_FontMap::Entry (const Standard_Integer AnIndex) const {
100
101 if( AnIndex < 1 || AnIndex > mydata.Length() )
102 Aspect_BadAccess::Raise ("Aspect_FontMap::Entry Bad Index");
103
104 return mydata.Value(AnIndex);
105}
106
107void Aspect_FontMap::Dump () const {
108
109 Standard_Integer i ;
110
111 cout << "Fontmap Dump-->\n" ;
112
113 for ( i = 1 ; i <= Size() ; i++ ) (Entry(i)).Dump() ;
114
115 cout << "<--End Fontmap Dump\n" ;
116}