Integration of OCCT 6.5.0 from SVN
[occt.git] / src / Aspect / Aspect_FontMap.cxx
1
2 // File         Aspect_FontMap.cxx
3 // Created      Septembre 1993
4 // Author       GG
5
6 //-Copyright    MatraDatavision 1991,1992
7
8 //-Version
9
10 //-Design       Declaration des variables specifiques aux Ensembles
11 //              de Fontures de texts
12
13 //-Warning      Une FontMap est definie par un ensemble de FontMapEntries
14
15 //-References
16
17 //-Language     C++ 2.0
18
19 //-Declarations
20
21 // for the class
22 #include <Aspect_FontMap.ixx>
23
24 //-Aliases
25
26 //-Global data definitions
27
28 //      mydata     : SequenceOfFontMapEntry from Aspect is protected
29
30 //-Constructors
31
32 //-Destructors
33
34 //-Methods, in order
35
36 Aspect_FontMap::Aspect_FontMap( ) {
37 Aspect_FontMapEntry theDefaultEntry;
38
39         AddEntry(theDefaultEntry);
40 }
41
42 void Aspect_FontMap::AddEntry (const Aspect_FontMapEntry& AnEntry) {
43 Standard_Integer i,index = AnEntry.Index();
44 Aspect_FontMapEntry theEntry;
45  
46         for( i=1 ; i<=mydata.Length() ; i++ ) {
47             theEntry = mydata.Value(i);
48             if( index == theEntry.Index() ) break;
49         }
50  
51         if( i > mydata.Length() ) {
52             mydata.Append( AnEntry );
53         } else {
54             mydata.SetValue(i,AnEntry);
55         }
56 }
57
58 Standard_Integer Aspect_FontMap::AddEntry (const Aspect_FontStyle &aStyle) {
59 Aspect_FontMapEntry theEntry ;
60 Standard_Integer i,maxindex = 0 ;
61  
62     for( i=1 ; i<=mydata.Length() ; i++ ) {
63         theEntry = mydata.Value(i) ;
64         maxindex = Max(maxindex,theEntry.Index()) ;
65         if( theEntry.Type() == aStyle ) return theEntry.Index() ;
66     }
67  
68     maxindex++ ; 
69     theEntry.SetValue(maxindex,aStyle) ;
70     mydata.Append( theEntry ) ;
71     return maxindex ;
72 }
73
74 Standard_Integer     Aspect_FontMap::Size() const {
75
76         return mydata.Length() ;
77 }
78
79 Standard_Integer     Aspect_FontMap::Index(const Standard_Integer anIndex) const {
80
81         if( anIndex < 1 || anIndex > Size() ) {
82             Aspect_BadAccess::Raise ("Undefined fontmap Index");
83         }
84
85         Aspect_FontMapEntry theEntry = mydata.Value(anIndex) ;
86
87         return theEntry.Index() ;
88 }
89
90 Aspect_FontMapEntry Aspect_FontMap::Entry (const Standard_Integer AnIndex) const {
91
92         if( AnIndex < 1 || AnIndex > mydata.Length() )
93                 Aspect_BadAccess::Raise ("Aspect_FontMap::Entry Bad Index");
94         
95         return mydata.Value(AnIndex);
96 }
97
98 void Aspect_FontMap::Dump () const {
99
100   Standard_Integer i ;
101
102   cout << "Fontmap Dump-->\n" ;
103
104   for ( i = 1 ; i <= Size() ; i++ ) (Entry(i)).Dump() ;
105
106   cout << "<--End Fontmap Dump\n" ;
107 }