0023510: Integration of test grid "vis" into the new testing system
[occt.git] / src / MFT / MFT_TextManager.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 #define PRO15231        //GG 080998
19 //                      De maniere indirect on corrige le retour
20 //                      de SetCharBoundingBox() de maniere a activer 
21 //                      l'optimisation importante pour myFontManager::TextSize()
22
23 #include <MFT_TextManager.ixx>
24 #include <TCollection_AsciiString.hxx>
25 #define TRACE 0
26
27 static Quantity_Length theXmin,theYmin,theXmax,theYmax;
28 static Quantity_Length theWidth,theHeight;
29 static Quantity_PlaneAngle theOrientation,theSlant;
30 static TCollection_AsciiString theEncoding;
31 static Standard_Boolean theSkipFlag = Standard_False;
32
33 MFT_TextManager::MFT_TextManager() {
34 }
35
36 void MFT_TextManager::BeginString( const Quantity_Length X, const Quantity_Length Y, const Quantity_PlaneAngle anOrientation, const Quantity_Length aWidth, const Quantity_Length aHeight, const Quantity_PlaneAngle aSlant, const Standard_Integer aPaintType) {
37 #if TRACE > 0
38   cout << " MFT_TextManager::BeginString(" << 
39                         X << "," << Y << "," << anOrientation << ","
40                         << aWidth << "," << aHeight << "," aSlant << "," 
41                         << aPaintType << ")" << endl;
42 #endif
43   theOrientation = anOrientation;
44   theSlant = aSlant;
45   theWidth = aWidth;
46   theHeight = aHeight;
47   theXmin = theYmin = theXmax = theYmax = 0.;
48 }
49
50 Standard_Boolean MFT_TextManager::BeginChar(const Standard_Integer aCharCode, const Standard_Real X, const Standard_Real Y) {
51 #if TRACE > 0
52   cout << " MFT_TextManager::BeginChar(" << aCharCode << "," << 
53                                         X << "," << Y << ")" << endl;
54 #endif
55   theXmin = Min(theXmin,X); theXmax = Max(theXmax,X);
56   theYmin = Min(theYmin,Y); theYmax = Max(theYmax,Y);
57   theSkipFlag = Standard_False;
58   theEncoding.Clear();
59   return Standard_True;
60 }
61
62 Standard_Boolean MFT_TextManager::SetCharBoundingBox(const Quantity_Length X1, const Quantity_Length Y1, const Quantity_Length X2, const Quantity_Length Y2, const Quantity_Length X3, const Quantity_Length Y3, const Quantity_Length X4, const Quantity_Length Y4) {
63
64 #if TRACE > 0
65   cout << " MFT_TextManager::SetCharBoundingBox(" << X1 << "," << Y1 << "," << 
66         X2 << "," << Y2 << "," << X3 << "," << Y3 << "," << 
67         X4 << "," << Y4 << ")" << endl;
68 #endif
69
70   if( theOrientation != 0. ) {  //NOT IMPLEMENTED,because not used
71 #ifdef PRO15231
72     theSkipFlag = Standard_False;
73 #endif
74   }
75   if( X2 > X1 ) {
76     theXmin = Min(theXmin,X1); theXmin = Min(theXmin,X4); 
77     theYmin = Min(theYmin,Y1); theYmax = Max(theYmax,Y3);
78     theXmax = Max(theXmax,X2); theXmax = Max(theXmax,X3);
79     theSkipFlag = Standard_True;
80   } else {
81     theSkipFlag = Standard_False;
82   }
83 #ifdef PRO15231
84   return !theSkipFlag;  
85 #else
86   return Standard_True;
87 #endif
88 }
89
90 Standard_Boolean MFT_TextManager::SetCharEncoding(const Standard_CString anEncoding) {
91
92 #if TRACE > 0
93   cout << " MFT_TextManager::SetCharEncoding('" << anEncoding << "')" << endl;
94 #endif
95
96    theEncoding = anEncoding;
97
98    return !theSkipFlag;
99 }
100
101 Standard_Boolean MFT_TextManager::Moveto(const Quantity_Length X, const Quantity_Length Y) {
102 #if TRACE > 1
103   cout << " MFT_TextManager::Moveto(" << X << "," << Y << ")" << endl;
104 #endif
105   theXmin = Min(theXmin,X); theXmax = Max(theXmax,X);
106   theYmin = Min(theYmin,Y); theYmax = Max(theYmax,Y);
107   return Standard_True;
108 }
109
110 Standard_Boolean MFT_TextManager::Lineto(const Quantity_Length X, const Quantity_Length Y) {
111 #if TRACE > 1
112   cout << " MFT_TextManager::Lineto(" << X << "," << Y << ")" << endl;
113 #endif
114   theXmin = Min(theXmin,X); theXmax = Max(theXmax,X);
115   theYmin = Min(theYmin,Y); theYmax = Max(theYmax,Y);
116   return Standard_True;
117 }
118
119 Standard_Boolean MFT_TextManager::Curveto(const Quantity_Length X1, const Quantity_Length Y1, const Quantity_Length X2, const Quantity_Length Y2, const Quantity_Length X3, const Quantity_Length Y3, const Quantity_Length X4, const Quantity_Length Y4) {
120
121 #if TRACE > 0
122   cout << " MFT_TextManager::Curveto(" << X1 << "," << Y1 << "," << 
123         X2 << "," << Y2 << "," << X3 << "," << Y3 << "," << 
124         X4 << "," << Y4 << ")" << endl;
125 #endif
126
127   return Standard_False;        
128 }
129
130 void MFT_TextManager::ClosePath() {
131 #if TRACE > 0
132   cout << " MFT_TextManager::ClosePath()" << endl;
133 #endif
134 }
135
136 Standard_Boolean MFT_TextManager::EndChar(const Standard_Real X, const Standard_Real Y) {
137 #if TRACE > 0
138   cout << " MFT_TextManager::EndChar(" << X << "," << Y << ")" << endl;
139 #endif
140   theXmin = Min(theXmin,X); theXmax = Max(theXmax,X);
141   theYmin = Min(theYmin,Y); theYmax = Max(theYmax,Y);
142   return Standard_True;
143 }
144
145 void MFT_TextManager::EndString() {
146 #if TRACE > 0
147   cout << " MFT_TextManager::EndString()" << endl;
148 #endif
149 }
150
151 void MFT_TextManager::MinMax(Quantity_Length& Xmin, Quantity_Length& Ymin, Quantity_Length& Xmax, Quantity_Length& Ymax) {
152
153   Xmin = theXmin;
154   Ymin = theYmin;
155   Xmax = theXmax;
156   Ymax = theYmax;
157 #if TRACE > 0
158   cout << " MFT_TextManager::MinMax(" << theXmin << "," << theYmin << 
159                         "," << theXmax << "," << theYmax << ")" << endl;
160 #endif
161  theXmin = theYmin = theXmax = theYmax = 0.;
162 }
163
164 Standard_CString MFT_TextManager::Encoding() {
165
166   return theEncoding.ToCString();
167 }