Commit | Line | Data |
---|---|---|
7fd59977 | 1 | // File: WNT_WDriver.cxx |
2 | // Created: Mon Mar 17 17:28:42 1997 | |
3 | // Author: EugenyPLOTNIKOV | |
4 | // Modified: MAR-98 (DCB) MFT | |
5 | // DCB: SEP-98 Avoid memory crash when color indices do not follow | |
6 | // each other or do not begin with '1' | |
7 | // Copyright: Matra Datavision 1993 | |
8 | ||
9 | // include windows.h first to have all definitions available | |
10 | #include <windows.h> | |
11 | ||
12 | #define MFT // Study S3553 | |
13 | ||
14 | #define PRO17334 //GG_060199 | |
15 | // SetXxxAttrib() must raise when index is wrong | |
16 | // Idem for DrawMarker() | |
17 | ||
18 | #define PRO17381 //GG_080199 | |
19 | // Protection : Do nothing when NULL string is found in TextSize | |
20 | ||
21 | #define PRO19042 //GG_261199 | |
22 | // Don't clear buffer at begin draw .If not this clear | |
23 | // the current buffer attribs and the resulting buffer is black | |
24 | ||
25 | #include <WNT_WDriver.ixx> | |
26 | ||
27 | #include <WNT_GraphicDevice.hxx> | |
28 | #include <WNT_ImageManager.hxx> | |
29 | #include <WNT_Image.hxx> | |
30 | ||
31 | #include <Aspect_FontStyle.hxx> | |
32 | #include <Aspect_FontMapEntry.hxx> | |
33 | #include <Aspect_LineStyle.hxx> | |
34 | #include <Aspect_TypeMapEntry.hxx> | |
35 | #include <Aspect_TypeOfLine.hxx> | |
36 | #include <Aspect_WidthMapEntry.hxx> | |
37 | #include <Aspect_ColorMapEntry.hxx> | |
38 | #include <Aspect_MarkMapEntry.hxx> | |
39 | ||
40 | #include <TColStd_Array1OfBoolean.hxx> | |
41 | #include <TColQuantity_Array1OfLength.hxx> | |
42 | #include <Resource_Unicode.hxx> | |
43 | ||
44 | #include <windowsx.h> | |
45 | ||
46 | #include "W32_Allocator.hxx" | |
47 | ||
48 | #define A ( ( PW32_Allocator )myAllocator ) | |
49 | #define SA ( !( A -> myFlags & W32F_MONO ) || \ | |
50 | ( ( A -> myFlags & W32F_MONO ) && ( A -> myFlags & W32F_MINIT ) ) \ | |
51 | ) | |
52 | ||
53 | /*====================== MFT ====================*/ | |
54 | #ifdef MFT | |
55 | #include <Aspect_Units.hxx> | |
56 | #include "WNT_MFTDraw.hxx" | |
57 | #endif | |
58 | /*====================== MFT ====================*/ | |
59 | ||
60 | typedef struct _m_param { | |
61 | ||
62 | Aspect_MarkerStyle* s; | |
63 | int w; | |
64 | int h; | |
65 | ||
66 | } MPARAM, *PMPARAM; | |
67 | ||
68 | typedef struct { | |
69 | ||
70 | float r; | |
71 | float g; | |
72 | float b; | |
73 | ||
74 | } PIXEL2D, *PPIXEL2D; | |
75 | ||
76 | extern double W32_TextFactor; | |
77 | static PW32_Allocator __fastcall _FindAllocator ( Standard_Address, Standard_Integer ); | |
78 | static int __fastcall _GetROP2 ( Aspect_TypeOfDrawMode ); | |
79 | static char* __fastcall _ConvertU2F ( const TCollection_ExtendedString& ); | |
80 | ||
81 | static void WINAPI _SetPoint ( int, int, int, LPPOINT, int*, void* ); | |
82 | ||
83 | WNT_WDriver :: WNT_WDriver ( const Handle( WNT_Window )& aWindow ) : | |
84 | Aspect_WindowDriver ( aWindow ) { | |
85 | ||
86 | WINDOW_DATA* wd; | |
87 | Standard_Integer pXSize, pYSize; | |
88 | Quantity_Length dXSize, dYSize; | |
89 | ||
90 | Handle( WNT_GraphicDevice ) gDev = Handle ( WNT_GraphicDevice ) :: | |
91 | DownCast ( MyWindow -> GraphicDevice () ); | |
92 | ||
93 | gDev -> DisplaySize ( pXSize, pYSize ); | |
94 | gDev -> DisplaySize ( dXSize, dYSize ); | |
95 | ||
96 | myWNTWindow = Handle( WNT_Window ) :: DownCast ( MyWindow ); | |
97 | myPixelToUnit = ( dXSize / pXSize + dYSize / pYSize ) / 2.0; | |
98 | myAllocators = myAllocator = ( *W32_GetAllocator ) ( 0, NULL ); | |
99 | MyDrawMode = Aspect_TODM_REPLACE; | |
100 | ||
101 | /*====================== MFT ====================*/ | |
102 | #ifdef MFT | |
103 | myTextManager = new WNT_TextManager (myPixelToUnit); | |
104 | #endif | |
105 | /*====================== MFT ====================*/ | |
106 | ||
107 | wd = (WINDOW_DATA* )GetWindowLongPtr ((HWND )aWindow->HWindow(), GWLP_USERDATA); | |
108 | wd->WNT_WDriver_Ptr = (void* )this; | |
109 | ||
110 | } // end constructor | |
111 | ||
112 | void WNT_WDriver :: Destroy () { | |
113 | ||
114 | do { | |
115 | ||
116 | myAllocator = ( ( PW32_Allocator )myAllocators ) -> myNext; | |
117 | ||
118 | delete ( PW32_Allocator )myAllocators; | |
119 | ||
120 | myAllocators = ( PW32_Allocator )myAllocator; | |
121 | ||
122 | } while ( myAllocators != NULL ); | |
123 | ||
124 | } // end WNT_WDriver :: Destroy | |
125 | ||
126 | Standard_Address WNT_WDriver :: SelectBuffer ( | |
127 | const Standard_Integer aRetainBuffer | |
128 | ) const { | |
129 | ||
130 | PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); | |
131 | ||
132 | if ( a != NULL ) *( ( Standard_Address* )&myAllocator ) = ( Standard_Address )a; | |
133 | ||
134 | return myAllocator; | |
135 | ||
136 | } // end WNT_WDriver :: SelectBuffer | |
137 | ||
138 | void WNT_WDriver :: BeginDraw ( | |
139 | const Standard_Boolean aDoubleBuffer, | |
140 | const Standard_Integer aRetainBuffer | |
141 | ) { | |
142 | ||
143 | PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); | |
144 | ||
145 | if ( a != NULL ) { | |
146 | ||
147 | if ( aDoubleBuffer ) { | |
148 | ||
149 | MyWindow -> SetDoubleBuffer ( aDoubleBuffer ); | |
150 | a -> myFlags |= W32F_DBUFF; | |
151 | ||
152 | } else a -> myFlags &= ~W32F_DBUFF; | |
153 | ||
154 | #ifdef PRO19042 | |
155 | if( !aRetainBuffer ) | |
156 | #endif | |
157 | a -> ClearBlocks (); | |
158 | a -> myFlags |= W32F_START; | |
159 | a -> myFlags &= ~W32F_DVDRV; | |
160 | ||
161 | SelectBuffer ( aRetainBuffer ); | |
162 | ||
163 | } // end if | |
164 | ||
165 | } // end WNT_WDriver :: BeginDraw | |
166 | ||
167 | void WNT_WDriver :: EndDraw ( const Standard_Boolean aSynchronize ) { | |
168 | ||
169 | ( ( PW32_Allocator )myAllocator ) -> myFlags &= ~W32F_START; | |
170 | ||
171 | DrawBuffer ( ( ( PW32_Allocator )myAllocator ) -> myID ); | |
172 | ||
173 | } // end WNT_WDriver :: EndDraw | |
174 | ||
175 | Aspect_TypeOfResize WNT_WDriver :: ResizeSpace () { | |
176 | ||
177 | return myWNTWindow -> DoResize (); | |
178 | ||
179 | } // end WNT_WDriver :: ResizeSpace | |
180 | ||
181 | Standard_Boolean WNT_WDriver :: SetHighlightColor ( | |
182 | const Standard_Integer aColorIdx | |
183 | ) const { | |
184 | ||
185 | Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) :: | |
186 | DownCast ( MyWindow -> GraphicDevice () ); | |
187 | ||
188 | gDev -> SetColor ( | |
189 | ColorMap () -> Entry ( aColorIdx + 1 ).Color (), Standard_True | |
190 | ); | |
191 | ||
192 | return Standard_True; | |
193 | ||
194 | } // end WNT_WDriver :: SetHighlightColor | |
195 | ||
196 | void WNT_WDriver :: SetDrawMode ( const Aspect_TypeOfDrawMode aMode ) { | |
197 | ||
198 | MyDrawMode = aMode; | |
199 | ||
200 | } // end WNT_WDriver :: SetDrawMode | |
201 | ||
202 | void WNT_WDriver :: SetLineAttrib ( | |
203 | const Standard_Integer ColorIndex, | |
204 | const Standard_Integer TypeIndex, | |
205 | const Standard_Integer WidthIndex | |
206 | ) | |
207 | { | |
208 | #ifdef PRO17334 | |
209 | if( myColors.IsNull() || | |
210 | ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper() ) | |
211 | Aspect_DriverError::Raise ("Bad Color Index") ; | |
212 | if( myTypeIdxs.IsNull() || | |
213 | TypeIndex < myTypeIdxs->Lower() || TypeIndex > myTypeIdxs->Upper() ) | |
214 | Aspect_DriverError::Raise ("Bad Type Index") ; | |
215 | if( myWidthIdxs.IsNull() || | |
216 | WidthIndex < myWidthIdxs->Lower() || WidthIndex > myWidthIdxs->Upper() ) | |
217 | Aspect_DriverError::Raise ("Bad Width Index") ; | |
218 | ||
219 | Aspect_LineStyle Entry = TypeMap () -> Entry ( myTypeIdxs -> Value(TypeIndex) ).Type (); | |
220 | #else | |
221 | Standard_Integer theIndex = TypeIndex; | |
222 | if (TypeIndex < myTypeIdxs->Lower() || TypeIndex > myTypeIdxs->Upper()) | |
223 | theIndex = myTypeIdxs->Lower(); | |
224 | ||
225 | Aspect_LineStyle Entry = TypeMap () -> Entry ( myTypeIdxs -> Value(theIndex) ).Type (); | |
226 | #endif | |
227 | Standard_Integer type = ((Entry.Style() == Aspect_TOL_SOLID) ? 0 : PS_USERSTYLE); | |
228 | double width = ( double )ProcessWidthIndex ( WidthIndex ); | |
229 | Standard_Boolean fUser = ( type & PS_USERSTYLE ); | |
230 | LOGBRUSH lb = { BS_SOLID, ProcessColorIndex ( ColorIndex ), 0 }; | |
231 | if ( fUser ) { | |
232 | Standard_Integer Lower = Entry.Values ().Lower (); | |
233 | Standard_Integer Count = Entry.Values ().Length (); | |
234 | PDWORD dwStyle = ( PDWORD )HeapAlloc ( | |
235 | GetProcessHeap (), | |
236 | HEAP_GENERATE_EXCEPTIONS, | |
237 | Count * sizeof ( DWORD ) | |
238 | ); | |
239 | for ( Standard_Integer i = 0; i < Count; ++i ) { | |
240 | dwStyle[ i ] = DWORD ( Entry.Values ().Value ( i + Lower ) / myPixelToUnit + 0.5 ); | |
241 | if ( dwStyle[ i ] == 0.0 ) dwStyle[ i ] = 1; | |
242 | } // end for | |
243 | A -> LineAttrib ( DWORD( width + 0.5 ), &lb, Count, dwStyle ); | |
244 | HeapFree ( GetProcessHeap (), 0, ( LPVOID )dwStyle ); | |
245 | } else A -> LineAttrib ( DWORD( width + 0.5 ), &lb ); | |
246 | } // end WNT_WDriver :: SetLineAttrib | |
247 | ||
248 | void WNT_WDriver :: SetTextAttrib ( | |
249 | const Standard_Integer ColorIndex, | |
250 | const Standard_Integer FontIndex | |
251 | ) | |
252 | { | |
253 | SetTextAttrib ( ColorIndex, FontIndex, 0.0, 1.0, 0.0,Standard_False ); | |
254 | } // end WNT_WDriver :: SetTextAttrib | |
255 | ||
256 | void WNT_WDriver :: SetTextAttrib ( | |
257 | const Standard_Integer ColorIndex, | |
258 | const Standard_Integer FontIndex, | |
259 | const Quantity_PlaneAngle aSlant, | |
260 | const Quantity_Factor aHScale, | |
261 | const Quantity_Factor aWScale, | |
262 | const Standard_Boolean isUnderlined | |
263 | ) | |
264 | { | |
265 | #ifdef PRO17334 | |
266 | if( myColors.IsNull() || | |
267 | ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper() ) | |
268 | Aspect_DriverError::Raise ("Bad Color Index") ; | |
269 | if( myFonts.IsNull() || | |
270 | FontIndex < myFonts->Lower() || FontIndex > myFonts->Upper() ) | |
271 | Aspect_DriverError::Raise ("Bad Font Index") ; | |
272 | #endif | |
273 | HFONT hFont; | |
274 | LOGFONT lf; | |
275 | BOOL fFree = FALSE; | |
276 | Handle( WNT_FontMapEntry ) fmEntry = myFonts -> Value ( FontIndex ); | |
277 | /*====================== MFT ====================*/ | |
278 | #ifdef MFT | |
279 | if ( UseMFT() ) { | |
280 | //============== Set some font attributes ============= | |
281 | Handle(MFT_FontManager) theFontManager = MFT_Font(FontIndex); | |
282 | Standard_ShortReal theTextSize = MFT_Size(FontIndex); | |
283 | theFontManager->SetFontAttribs ( | |
284 | Abs(theTextSize)*(aWScale > 0.0 ? aWScale : aHScale)*A->myScaleX, | |
285 | Abs(theTextSize)*aHScale *A->myScaleY, | |
286 | aSlant, 0., ((theTextSize > 0.) ? Standard_False : Standard_True) | |
287 | ); | |
288 | A -> TextAttrib ( | |
289 | (HFONT)FontIndex, ProcessColorIndex ( ColorIndex ), aSlant, | |
290 | aHScale, ( aWScale > 0.0 ? aWScale : aHScale ), | |
291 | isUnderlined, Standard_False, Standard_True | |
292 | ); | |
293 | } else { | |
294 | #endif | |
295 | /*====================== MFT ====================*/ | |
296 | GetObject ( | |
297 | hFont = ( HFONT )fmEntry-> HFont (), | |
298 | sizeof ( LOGFONT ), &lf | |
299 | ); | |
300 | ||
301 | if ( isUnderlined && !lf.lfUnderline ) { | |
302 | FONT_DATA fd = { TRUE }; | |
303 | hFont = ( HFONT )fmEntry -> SetAttrib ( faUnderlined, &fd ); | |
304 | fFree = TRUE; | |
305 | } // end if | |
306 | ||
307 | A -> TextAttrib ( | |
308 | hFont, ProcessColorIndex ( ColorIndex ), aSlant, | |
309 | aHScale / W32_TextFactor, | |
310 | ( aWScale > 0.0 ? aWScale : aHScale ) / W32_TextFactor, | |
311 | isUnderlined, fFree | |
312 | ); | |
313 | #if 0 | |
314 | char* str = (isUnderlined ? "UNDERLINED" : "GOD DAMN "); | |
315 | HDC hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () ); | |
316 | HFONT hf = SelectFont ( hdc, hFont ); | |
317 | SetTextColor ( hdc, RGB (133, 211, 66) ); | |
318 | SetBkColor ( hdc, RGB (0, 0, 0) ); | |
319 | Rectangle ( hdc, 0, 0, 1220, 220 ); | |
320 | SetBkMode ( hdc, OPAQUE ); | |
321 | TextOut ( hdc, 0, 0, str, lstrlen(str) ); | |
322 | SelectFont ( hdc, hf ); | |
323 | ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc ); | |
324 | MessageBox ( ( HWND )myWNTWindow -> HWindow (), str, "Son of a BITCH", MB_OK ); | |
325 | #endif | |
326 | /*====================== MFT ====================*/ | |
327 | #ifdef MFT | |
328 | } | |
329 | #endif | |
330 | /*====================== MFT ====================*/ | |
331 | } // end WNT_WDriver :: SetTextAttrib | |
332 | ||
333 | void WNT_WDriver :: SetPolyAttrib ( | |
334 | const Standard_Integer ColorIndex, | |
335 | const Standard_Integer TileIndex, | |
336 | const Standard_Boolean DrawEdgeFlag | |
337 | ) | |
338 | { | |
339 | #ifdef PRO17334 | |
340 | if( myColors.IsNull() || | |
341 | ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper() ) | |
342 | Aspect_DriverError::Raise ("Bad Color Index") ; | |
343 | #endif | |
344 | if ( !SA ) return; | |
345 | LOGBRUSH lb = { TileIndex < 0 ? BS_NULL : BS_SOLID, ProcessColorIndex ( ColorIndex ), 0 }; | |
346 | A -> PolyAttrib ( &lb, DrawEdgeFlag ); | |
347 | } // end WNT_WDriver :: SetPolyAttrib | |
348 | ||
349 | void WNT_WDriver :: SetPolyAttrib ( | |
350 | const Standard_Integer ColorIndex, | |
351 | const Standard_Integer TileIndex, | |
352 | const Standard_Integer PolygonMode, | |
353 | const Standard_Boolean DrawEdgeFlag | |
354 | ) | |
355 | { | |
356 | #ifdef PRO17334 | |
357 | if( myColors.IsNull() || | |
358 | ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper() ) | |
359 | Aspect_DriverError::Raise ("Bad Color Index") ; | |
360 | #endif | |
361 | if ( !SA ) return; | |
362 | LOGBRUSH lb = { BS_SOLID, ProcessColorIndex ( ColorIndex ), 0 }; | |
363 | A -> PolyAttrib ( &lb, DrawEdgeFlag, PolygonMode ); | |
364 | } // end WNT_WDriver :: SetPolyAttrib | |
365 | ||
366 | void WNT_WDriver :: SetMarkerAttrib ( | |
367 | const Standard_Integer ColorIndex, | |
368 | const Standard_Integer EdgeWidthIndex, | |
369 | const Standard_Boolean FillMarker | |
370 | ) | |
371 | { | |
372 | #ifdef PRO17334 | |
373 | if( myColors.IsNull() || | |
374 | ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper() ) | |
375 | Aspect_DriverError::Raise ("Bad Color Index") ; | |
376 | if( myWidthIdxs.IsNull() || | |
377 | EdgeWidthIndex < myWidthIdxs->Lower() || EdgeWidthIndex > myWidthIdxs->Upper() ) | |
378 | Aspect_DriverError::Raise ("Bad EdgeWidth Index") ; | |
379 | #endif | |
380 | if ( SA ) | |
381 | A -> MarkerAttrib ( | |
382 | ProcessColorIndex ( ColorIndex ), | |
383 | DWORD( ProcessWidthIndex ( EdgeWidthIndex ) + 0.5 ), | |
384 | FillMarker | |
385 | ); | |
386 | } // end WNT_WDriver :: SetMarkerAttrib | |
387 | ||
388 | Standard_Boolean WNT_WDriver :: IsKnownImage ( | |
389 | const Handle( Standard_Transient )& anImage | |
ec6a1aa7 D |
390 | ) |
391 | { | |
392 | return myWNTWindow -> myImages -> Index ( ::HashCode (anImage, IntegerLast()) | |
7fd59977 | 393 | ) ? Standard_True : Standard_False; |
7fd59977 | 394 | } // end WNT_WDriver :: IsKnownImage |
395 | ||
396 | Standard_Boolean WNT_WDriver :: SizeOfImageFile ( | |
397 | const Standard_CString anImageFile, | |
398 | Standard_Integer& aWidth, | |
399 | Standard_Integer& aHeight | |
400 | ) const { | |
401 | #ifndef BUG //Sets the size to 0 when the image file is not found. | |
402 | aWidth = 0; aHeight = 0; | |
403 | #endif | |
404 | ||
405 | Standard_Integer i = myWNTWindow -> myImages -> Load ( anImageFile ); | |
406 | ||
407 | if ( i ) myWNTWindow -> myImages -> Dim ( i, aWidth, aHeight ); | |
408 | ||
409 | return i ? Standard_True : Standard_False; | |
410 | ||
411 | } // end WNT_WDriver :: SizeOfImageFile | |
412 | ||
413 | void WNT_WDriver :: ClearImage ( const Handle( Standard_Transient )& anImageId ) { | |
414 | ||
415 | Standard_Integer i = myWNTWindow -> myImages -> Index ( | |
ec6a1aa7 | 416 | ::HashCode (anImageId, IntegerLast()) |
7fd59977 | 417 | ); |
418 | ||
419 | if ( i ) myWNTWindow -> myImages -> Discard ( i ); | |
420 | ||
421 | } // end WNT_WDriver :: ClearImage | |
422 | ||
423 | void WNT_WDriver :: ClearImageFile ( const Standard_CString anImageFile ) { | |
424 | ||
425 | Standard_Integer i = myWNTWindow -> myImages -> Load ( anImageFile ); | |
426 | ||
427 | if ( i ) myWNTWindow -> myImages -> Discard ( i ); | |
428 | ||
429 | } // end WNT_WDriver :: ClearImageFile | |
430 | ||
431 | void WNT_WDriver :: DrawImage ( | |
432 | const Handle( Standard_Transient )& anImageId, | |
433 | const Standard_ShortReal aX, | |
434 | const Standard_ShortReal aY | |
435 | ) { | |
436 | ||
437 | Standard_Integer i = myWNTWindow -> myImages -> Index ( | |
ec6a1aa7 | 438 | ::HashCode (anImageId, IntegerLast()) |
7fd59977 | 439 | ); |
440 | ||
441 | if ( i ) A -> Image ( | |
442 | P( aX ), P( aY ), | |
443 | ( PW32_Bitmap )myWNTWindow -> myImages -> Image ( i ) -> Image () | |
444 | ); | |
445 | ||
446 | } // end WNT_WDriver :: DrawImage | |
447 | ||
448 | void WNT_WDriver :: DrawImageFile ( | |
449 | const Standard_CString anImageFile, | |
450 | const Standard_ShortReal aX, | |
451 | const Standard_ShortReal aY, | |
452 | const Quantity_Factor aScale | |
453 | ) { | |
454 | ||
455 | int i = myWNTWindow -> myImages -> Load ( anImageFile ); | |
456 | ||
457 | if ( i ) { | |
458 | ||
459 | PW32_Bitmap pBmp; | |
460 | ||
461 | if (aScale != 1.0) { | |
462 | ||
463 | pBmp = ( PW32_Bitmap )HeapAlloc ( | |
464 | GetProcessHeap (), | |
465 | HEAP_GENERATE_EXCEPTIONS, | |
466 | sizeof ( W32_Bitmap ) | |
467 | ); | |
468 | pBmp -> hBmp = ( HBITMAP )myWNTWindow -> myImages -> Scale ( i, aScale, aScale ); | |
469 | pBmp -> nUsed = 0; | |
470 | ||
471 | } else | |
472 | ||
473 | pBmp = ( PW32_Bitmap )myWNTWindow -> myImages -> Image ( i ) -> Image (); | |
474 | ||
475 | A -> Image ( P( aX ), P( aY ), pBmp ); | |
476 | ||
477 | } // end if | |
478 | ||
479 | } // end WNT_WDriver :: DrawImageFile | |
480 | ||
481 | void WNT_WDriver :: FillAndDrawImage ( | |
482 | const Handle(Standard_Transient)& anImageId, | |
483 | const Standard_ShortReal aX, | |
484 | const Standard_ShortReal aY, | |
485 | const Standard_Integer Width, | |
486 | const Standard_Integer Height, | |
487 | const Standard_Address anArrayOfPixels | |
488 | ) { | |
489 | ||
490 | HDC hdc, hdcMem; | |
491 | HBITMAP hbo; | |
492 | HPALETTE hpo = NULL; | |
493 | Standard_Integer i, h; | |
494 | Quantity_Color color; | |
495 | PPIXEL2D p = ( PPIXEL2D )anArrayOfPixels; | |
496 | Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) :: | |
497 | DownCast ( MyWindow -> GraphicDevice () ); | |
498 | ||
499 | hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () ); | |
500 | hdcMem = CreateCompatibleDC ( hdc ); | |
501 | ||
502 | if ( gDev -> IsPaletteDevice () ) | |
503 | ||
504 | hpo = SelectPalette ( hdcMem, ( HPALETTE )gDev -> HPalette (), FALSE ); | |
505 | ||
506 | i = myWNTWindow -> myImages -> Index ( | |
ec6a1aa7 | 507 | h = ::HashCode (anImageId, IntegerLast()) |
7fd59977 | 508 | ); |
509 | ||
510 | if ( i == 0 ) i = myWNTWindow -> myImages -> Open ( hdc, Width, Height, h ); | |
511 | ||
512 | if ( Width > 0 && Height > 0 ) { | |
513 | ||
514 | Standard_Integer iX, iY; | |
515 | Standard_Real sX, sY; | |
516 | ||
517 | myWNTWindow -> myImages -> Dim ( i, iX, iY ); | |
518 | ||
519 | if ( iX != Width || iY != Height ) { | |
520 | ||
521 | sX = Width / ( Standard_Real )iX; | |
522 | sY = Height / ( Standard_Real )iY; | |
523 | ||
524 | myWNTWindow -> myImages -> Scale ( i, sX, sY, Standard_True ); | |
525 | ||
526 | } // end if | |
527 | ||
528 | hbo = SelectBitmap( | |
529 | hdcMem, ( HBITMAP )myWNTWindow -> myImages -> ImageHandle ( i ) | |
530 | ); | |
531 | ||
532 | for ( int i = 0; i < Height; ++i ) | |
533 | ||
534 | for ( int j = 0; j < Width; ++j, ++p ) { | |
535 | ||
536 | color.SetValues ( p -> r, p -> g, p -> b, Quantity_TOC_RGB ); | |
537 | SetPixel ( hdcMem, j, i, gDev -> SetColor ( color ) ); | |
538 | ||
539 | } // end for | |
540 | ||
541 | SelectBitmap( hdcMem, hbo ); | |
542 | ||
543 | } // end if | |
544 | ||
545 | if ( hpo != NULL ) SelectPalette ( hdcMem, hpo, FALSE ); | |
546 | ||
547 | DeleteDC ( hdcMem ); | |
548 | ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc ); | |
549 | ||
550 | DrawImage ( anImageId, aX, aY ); | |
551 | ||
552 | } // end WNT_WDriver :: FillAndDrawImage | |
553 | ||
554 | void WNT_WDriver :: FillAndDrawImage ( | |
555 | const Handle( Standard_Transient )& anImageId, | |
556 | const Standard_ShortReal aX, | |
557 | const Standard_ShortReal aY, | |
558 | const Standard_Integer anIndexOfLine, | |
559 | const Standard_Integer Width, | |
560 | const Standard_Integer Height, | |
561 | const Standard_Address anArrayOfPixels | |
562 | ) { | |
563 | ||
564 | HDC hdc, hdcMem; | |
565 | HBITMAP hbo; | |
566 | HPALETTE hpo = NULL; | |
567 | Standard_Integer i, h; | |
568 | Quantity_Color color; | |
569 | PPIXEL2D p = ( PPIXEL2D )anArrayOfPixels; | |
570 | Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) :: | |
571 | DownCast ( MyWindow -> GraphicDevice () ); | |
572 | ||
573 | hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () ); | |
574 | hdcMem = CreateCompatibleDC ( hdc ); | |
575 | ||
576 | if ( gDev -> IsPaletteDevice () ) | |
577 | ||
578 | hpo = SelectPalette ( hdcMem, ( HPALETTE )gDev -> HPalette (), FALSE ); | |
579 | ||
580 | i = myWNTWindow -> myImages -> Index ( | |
ec6a1aa7 | 581 | h = ::HashCode (anImageId, IntegerLast()) |
7fd59977 | 582 | ); |
583 | ||
584 | if ( i == 0 ) i = myWNTWindow -> myImages -> Open ( hdc, Width, Height, h ); | |
585 | ||
586 | if ( Width > 0 && Height > 0 ) { | |
587 | ||
588 | Standard_Integer iX, iY; | |
589 | Standard_Real sX, sY; | |
590 | ||
591 | myWNTWindow -> myImages -> Dim ( i, iX, iY ); | |
592 | ||
593 | if ( iX != Width || iY != Height ) { | |
594 | ||
595 | sX = Width / ( Standard_Real )iX; | |
596 | sY = Height / ( Standard_Real )iY; | |
597 | ||
598 | myWNTWindow -> myImages -> Scale ( i, sX, sY, Standard_True ); | |
599 | ||
600 | } // end if | |
601 | ||
602 | hbo = SelectBitmap( | |
603 | hdcMem, ( HBITMAP )myWNTWindow -> myImages -> ImageHandle ( i ) | |
604 | ); | |
605 | ||
606 | for ( int j = 0; j < Width; ++j, ++p ) { | |
607 | ||
608 | color.SetValues ( p -> r, p -> g, p -> b, Quantity_TOC_RGB ); | |
609 | SetPixel ( hdcMem, j, anIndexOfLine, gDev -> SetColor ( color ) ); | |
610 | ||
611 | } // end for | |
612 | ||
613 | SelectBitmap( hdcMem, hbo ); | |
614 | ||
615 | } // end if | |
616 | ||
617 | if ( hpo != NULL ) SelectPalette ( hdcMem, hpo, FALSE ); | |
618 | ||
619 | DeleteDC ( hdcMem ); | |
620 | ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc ); | |
621 | ||
622 | if ( anIndexOfLine == Height - 1 ) DrawImage ( anImageId, aX, aY ); | |
623 | ||
624 | } // end WNT_WDriver :: FillAndDrawImage | |
625 | ||
626 | void WNT_WDriver :: DrawPolyline ( | |
627 | const TShort_Array1OfShortReal& ListX, | |
628 | const TShort_Array1OfShortReal& ListY | |
629 | ) { | |
630 | ||
631 | Standard_Integer nPts = ListX.Length (); | |
632 | ||
633 | if ( nPts != ListY.Length () ) | |
634 | ||
635 | Aspect_DriverError :: Raise ( "DrawPolyline: incorrect argument" ); | |
636 | ||
637 | if ( nPts > 0 ) { | |
638 | ||
639 | Standard_Integer lX = ListX.Lower (); | |
640 | Standard_Integer lY = ListY.Lower (); | |
641 | ||
642 | if ( A -> myPrimitive != zzNone ) ClosePrimitive (); | |
643 | ||
644 | W32_PolygonNote* p = ( W32_PolygonNote* )( A -> Polyline ( nPts ) ); | |
645 | ||
646 | for ( Standard_Integer i = 0; i < nPts; ++i ) | |
647 | ||
648 | p -> Add ( | |
649 | P( ListX.Value ( lX + i ) ), | |
650 | P( ListY.Value ( lY + i ) ) | |
651 | ); | |
652 | ||
653 | } // end if | |
654 | ||
655 | } // end WNT_WDriver :: DrawPolyline | |
656 | ||
657 | void WNT_WDriver :: DrawPolygon ( | |
658 | const TShort_Array1OfShortReal& ListX, | |
659 | const TShort_Array1OfShortReal& ListY | |
660 | ) { | |
661 | ||
662 | Standard_Integer nPts = ListX.Length (); | |
663 | ||
664 | if ( nPts != ListY.Length () ) | |
665 | ||
666 | Aspect_DriverError :: Raise ( "DrawPolygon: incorrect argument" ); | |
667 | ||
668 | if ( nPts > 0 ) { | |
669 | ||
670 | Standard_Integer lX = ListX.Lower (); | |
671 | Standard_Integer lY = ListY.Lower (); | |
672 | ||
673 | if ( A -> myPrimitive != zzNone ) ClosePrimitive (); | |
674 | ||
675 | W32_PolygonNote* p = ( W32_PolygonNote* )( A -> Polygon ( nPts ) ); | |
676 | ||
677 | for ( Standard_Integer i = 0; i < nPts; ++i ) | |
678 | ||
679 | p -> Add ( | |
680 | P( ListX.Value ( lX + i ) ), | |
681 | P( ListY.Value ( lY + i ) ) | |
682 | ); | |
683 | ||
684 | } // end if | |
685 | ||
686 | } // end WNT_WDriver :: DrawPolygon | |
687 | ||
688 | void WNT_WDriver :: DrawSegment ( | |
689 | const Standard_ShortReal X1, | |
690 | const Standard_ShortReal Y1, | |
691 | const Standard_ShortReal X2, | |
692 | const Standard_ShortReal Y2 | |
693 | ) { | |
694 | ||
695 | A -> Line ( P( X1 ), P( Y1 ), P( X2 ), P( Y2 ) ); | |
696 | ||
697 | } // end WNT_WDriver :: DrawSegment | |
698 | ||
699 | ||
700 | void WNT_WDriver :: DrawText ( | |
701 | const TCollection_ExtendedString& Text, | |
702 | const Standard_ShortReal Xpos, | |
703 | const Standard_ShortReal Ypos, | |
704 | const Standard_ShortReal anAngle, | |
705 | const Aspect_TypeOfText aType | |
706 | ) | |
707 | { | |
708 | /*====================== MFT ====================*/ | |
709 | #ifdef MFT | |
710 | if ( UseMFT() ) { | |
711 | MFT_DRAWTEXT dt = { | |
712 | myAllocator, this, myPixelToUnit, | |
713 | Xpos, Ypos, anAngle, 0., (int)aType, | |
714 | FALSE, TRUE, Text.Length(), NULL | |
715 | }; | |
716 | CopyMemory (dt.theText, Text.ToExtString(), | |
717 | Text.Length()*sizeof(short)); | |
718 | A -> FunCall ( _Do_MFTDrawText_, sizeof(MFT_DRAWTEXT), | |
719 | PW32_FCALLPARAM(&dt) ); | |
720 | } else { | |
721 | #endif | |
722 | /*====================== MFT ====================*/ | |
723 | char* str = _ConvertU2F ( Text ); | |
724 | A -> Text ( | |
725 | P( Xpos ), P( Ypos ), | |
726 | anAngle, str, FALSE, | |
727 | ( aType == Aspect_TOT_SOLID ) ? FALSE : TRUE | |
728 | ); | |
729 | HeapFree ( GetProcessHeap (), 0, str ); | |
730 | /*====================== MFT ====================*/ | |
731 | #ifdef MFT | |
732 | } | |
733 | #endif | |
734 | /*====================== MFT ====================*/ | |
735 | } // end WNT_WDriver :: DrawText | |
736 | ||
737 | ||
738 | void WNT_WDriver :: DrawText ( | |
739 | const Standard_CString Text, | |
740 | const Standard_ShortReal Xpos, | |
741 | const Standard_ShortReal Ypos, | |
742 | const Standard_ShortReal anAngle, | |
743 | const Aspect_TypeOfText aType | |
744 | ) | |
745 | { | |
746 | /*====================== MFT ====================*/ | |
747 | #ifdef MFT | |
748 | if ( UseMFT() ) { | |
749 | MFT_DRAWTEXT dt = { | |
750 | myAllocator, this, myPixelToUnit, | |
751 | Xpos, Ypos, anAngle, 0., (int)aType, | |
752 | FALSE, FALSE, lstrlen(Text), NULL | |
753 | }; | |
754 | CopyMemory (dt.theText, Text, lstrlen(Text)); | |
755 | A -> FunCall ( _Do_MFTDrawText_, sizeof(MFT_DRAWTEXT), | |
756 | PW32_FCALLPARAM(&dt) ); | |
757 | } else | |
758 | #endif | |
759 | /*====================== MFT ====================*/ | |
760 | A -> Text ( | |
761 | P( Xpos ), P( Ypos ), anAngle, (Standard_Address)Text, FALSE, | |
762 | ( aType == Aspect_TOT_SOLID ) ? FALSE : TRUE | |
763 | ); | |
764 | } // end WNT_WDriver :: DrawText | |
765 | ||
766 | void WNT_WDriver :: DrawPolyText ( | |
767 | const TCollection_ExtendedString& aText, | |
768 | const Standard_ShortReal Xpos, | |
769 | const Standard_ShortReal Ypos, | |
770 | const Quantity_Ratio aMarge, | |
771 | const Standard_ShortReal anAngle, | |
772 | const Aspect_TypeOfText aType | |
773 | ) | |
774 | { | |
775 | /*====================== MFT ====================*/ | |
776 | #ifdef MFT | |
777 | if ( UseMFT() ) { | |
778 | MFT_DRAWTEXT dt = { | |
779 | myAllocator, this, myPixelToUnit, | |
780 | Xpos, Ypos, anAngle, aMarge, (int)aType, | |
781 | TRUE, TRUE, aText.Length(), NULL | |
782 | }; | |
783 | CopyMemory (dt.theText, aText.ToExtString(), | |
784 | aText.Length()*sizeof(short)); | |
785 | A -> FunCall ( _Do_MFTDrawText_, sizeof(MFT_DRAWTEXT), | |
786 | PW32_FCALLPARAM(&dt) ); | |
787 | } else { | |
788 | #endif | |
789 | /*====================== MFT ====================*/ | |
790 | char* str = _ConvertU2F ( aText ); | |
791 | A -> Polytext ( | |
792 | P( Xpos ), P( Ypos ), anAngle, aMarge, str, FALSE, | |
793 | ( aType == Aspect_TOT_SOLID ) ? FALSE : TRUE | |
794 | ); | |
795 | HeapFree ( GetProcessHeap (), 0, str ); | |
796 | /*====================== MFT ====================*/ | |
797 | #ifdef MFT | |
798 | } | |
799 | #endif | |
800 | /*====================== MFT ====================*/ | |
801 | } // end WNT_WDriver :: DrawPolyText | |
802 | ||
803 | void WNT_WDriver :: DrawPolyText ( | |
804 | const Standard_CString aText, | |
805 | const Standard_ShortReal Xpos, | |
806 | const Standard_ShortReal Ypos, | |
807 | const Quantity_Ratio aMarge, | |
808 | const Standard_ShortReal anAngle, | |
809 | const Aspect_TypeOfText aType | |
810 | ) | |
811 | { | |
812 | /*====================== MFT ====================*/ | |
813 | #ifdef MFT | |
814 | if ( UseMFT() ) { | |
815 | MFT_DRAWTEXT dt = { | |
816 | myAllocator, this, myPixelToUnit, | |
817 | Xpos, Ypos, anAngle, aMarge, (int)aType, | |
818 | TRUE, FALSE, lstrlen(aText), NULL | |
819 | }; | |
820 | CopyMemory (dt.theText, aText, lstrlen(aText)); | |
821 | A -> FunCall ( _Do_MFTDrawText_, sizeof(MFT_DRAWTEXT), | |
822 | PW32_FCALLPARAM(&dt) ); | |
823 | } else | |
824 | #endif | |
825 | /*====================== MFT ====================*/ | |
826 | A -> Polytext ( | |
827 | P( Xpos ), P( Ypos ), anAngle, aMarge, (Standard_Address)aText, FALSE, | |
828 | ( aType == Aspect_TOT_SOLID ) ? FALSE : TRUE | |
829 | ); | |
830 | ||
831 | } // end WNT_WDriver :: DrawPolyText | |
832 | ||
833 | void WNT_WDriver :: DrawPoint ( | |
834 | const Standard_ShortReal X, | |
835 | const Standard_ShortReal Y | |
836 | ) | |
837 | { | |
838 | switch ( A -> myPrimitive ) { | |
839 | case zzPolygon: | |
840 | ( ( W32_PolygonNote* )( A -> myNote ) ) -> Add ( P( X ), P( Y ) ); | |
841 | break; | |
842 | case zzPolyline: | |
843 | ( ( W32_PolylineNote* )( A -> myNote ) ) -> Add ( P( X ), P( Y ) ); | |
844 | break; | |
845 | default: | |
846 | A -> Point ( P( X ), P( Y ) ); | |
847 | } // end switch | |
848 | } // end WNT_WDriver :: DrawPoint | |
849 | ||
850 | void WNT_WDriver :: DrawMarker ( | |
851 | const Standard_Integer aMarker, | |
852 | const Standard_ShortReal Xpos, | |
853 | const Standard_ShortReal Ypos, | |
854 | const Standard_ShortReal Width, | |
855 | const Standard_ShortReal Height, | |
856 | const Standard_ShortReal Angle | |
857 | ) { | |
858 | ||
859 | if ( A -> myPrimitive != zzNone && A -> myPrimitive != zzMarker ) ClosePrimitive (); | |
860 | ||
861 | int aWidth = P( Width ); | |
862 | int aHeight = P( Height ); | |
863 | ||
864 | Standard_Integer theIndex = -1; | |
865 | #ifdef PRO17334 | |
866 | if( !myMarkerIdxs.IsNull() && | |
867 | (aMarker >= myMarkerIdxs->Lower() && aMarker <= myMarkerIdxs->Upper()) ) | |
868 | theIndex = myMarkerIdxs->Value(aMarker); | |
869 | if( theIndex < 0 ) Aspect_DriverError::Raise ("Bad Marker Index") ; | |
870 | ||
871 | if ( aWidth && aHeight && (aMarker > 0) ) { | |
872 | #else | |
873 | if (aMarker >= myMarkerIdxs->Lower() || aMarker <= myMarkerIdxs->Upper()) | |
874 | theIndex = myMarkerIdxs->Value(aMarker); | |
875 | ||
876 | if ( aWidth && aHeight && (theIndex >= 0) ) { | |
877 | #endif | |
878 | ||
879 | ||
880 | A -> BeginMarker ( P( Xpos ), P( Ypos ), aWidth, aHeight, Angle ); | |
881 | ||
882 | Aspect_MarkerStyle Style = MarkMap () -> Entry ( theIndex ).Style (); | |
883 | ||
884 | int MarkerSize = Style.Length (); | |
885 | int DrawCount = 0; | |
886 | int PrevPoint = 0; | |
887 | int i; | |
888 | MPARAM mp = { &Style, aWidth, aHeight }; | |
889 | ||
890 | for ( i = 2; i <= MarkerSize; ++i ) { | |
891 | ||
892 | if ( Style.SValues ().Value ( i ) ) { | |
893 | ||
894 | if ( Style.SValues ().Value ( i - 1 ) ) | |
895 | ||
896 | ++DrawCount; | |
897 | ||
898 | else { | |
899 | ||
900 | PrevPoint = i - 1; | |
901 | DrawCount = 2; | |
902 | ||
903 | } // end else | |
904 | ||
905 | } else { | |
906 | ||
907 | if ( Style.SValues().Value ( i - 1 ) ) { | |
908 | ||
909 | if ( ( Style.XValues ().Value ( i ) == Style.XValues ().Value ( PrevPoint ) ) && | |
910 | ( Style.YValues ().Value ( i ) == Style.YValues ().Value ( PrevPoint ) ) | |
911 | ) | |
912 | ||
913 | A -> PolyMarker2 ( DrawCount, &_SetPoint, PrevPoint, &mp ); | |
914 | ||
915 | else | |
916 | ||
917 | A -> PolyMarker1 ( DrawCount, &_SetPoint, PrevPoint, &mp ); | |
918 | ||
919 | } // end if | |
920 | ||
921 | DrawCount = 0; | |
922 | ||
923 | } // end else | |
924 | ||
925 | } // end for | |
926 | ||
927 | --i; | |
928 | ||
929 | if ( DrawCount ) { | |
930 | ||
931 | if ( ( Style.XValues ().Value ( i ) == Style.XValues ().Value ( PrevPoint ) ) && | |
932 | ( Style.YValues ().Value ( i ) == Style.YValues ().Value ( PrevPoint ) ) | |
933 | ) | |
934 | ||
935 | A -> PolyMarker2 ( DrawCount, &_SetPoint, PrevPoint, &mp ); | |
936 | ||
937 | else | |
938 | ||
939 | A -> PolyMarker1 ( DrawCount, &_SetPoint, PrevPoint, &mp ); | |
940 | ||
941 | } // end if | |
942 | ||
943 | A -> EndMarker (); | |
944 | ||
945 | } else A -> MarkerPoint ( P( Xpos ), P( Ypos ) ); | |
946 | ||
947 | } // end WNT_WDriver :: DrawMarker | |
948 | ||
949 | Standard_Boolean WNT_WDriver :: DrawArc ( | |
950 | const Standard_ShortReal X, | |
951 | const Standard_ShortReal Y, | |
952 | const Standard_ShortReal aXradius, | |
953 | const Standard_ShortReal aYradius, | |
954 | const Standard_ShortReal aStartAngle, | |
955 | const Standard_ShortReal anOpenAngle | |
956 | ) { | |
957 | ||
958 | if ( A -> myPrimitive != zzNone && A -> myPrimitive != zzArc ) | |
959 | ||
960 | ClosePrimitive (); | |
961 | ||
962 | if ( anOpenAngle >= 6.28318 ) | |
963 | ||
964 | A -> Ellipse ( P( X ), P( Y ), P( aXradius ), P( aYradius ) ); | |
965 | ||
966 | else | |
967 | ||
968 | A -> Arc ( | |
969 | P( X ), P( Y ), P( aXradius ), P( aYradius ), | |
970 | aStartAngle, anOpenAngle | |
971 | ); | |
972 | ||
973 | return Standard_True; | |
974 | ||
975 | } // end WNT_WDriver :: DrawArc | |
976 | ||
977 | Standard_Boolean WNT_WDriver :: DrawPolyArc ( | |
978 | const Standard_ShortReal X, | |
979 | const Standard_ShortReal Y, | |
980 | const Standard_ShortReal anXradius, | |
981 | const Standard_ShortReal anYradius, | |
982 | const Standard_ShortReal aStartAngle, | |
983 | const Standard_ShortReal anOpenAngle | |
984 | ||
985 | ) { | |
986 | ||
987 | if ( A -> myPrimitive != zzNone && A -> myPrimitive != zzPolySector ) | |
988 | ||
989 | ClosePrimitive (); | |
990 | ||
991 | if ( anOpenAngle >= 6.28318 ) | |
992 | ||
993 | A -> PolyEllipse ( P( X ), P( Y ), P( anXradius ), P( anYradius ) ); | |
994 | ||
995 | else | |
996 | ||
997 | A -> PolySector ( | |
998 | P( X ), P( Y ), P( anXradius ), P( anYradius ), | |
999 | aStartAngle, anOpenAngle | |
1000 | ); | |
1001 | ||
1002 | return Standard_True; | |
1003 | ||
1004 | } // end WNT_WDriver :: DrawPolyArc | |
1005 | ||
1006 | void WNT_WDriver :: BeginPolyline ( const Standard_Integer aNumber ) { | |
1007 | ||
1008 | A -> myPrimitive = zzPolyline; | |
1009 | A -> myNote = A -> Polyline ( aNumber ); | |
1010 | ||
1011 | } // end WNT_WDriver :: BeginPolyline | |
1012 | ||
1013 | void WNT_WDriver :: BeginPolygon ( const Standard_Integer aNumber ) { | |
1014 | ||
1015 | A -> myPrimitive = zzPolygon; | |
1016 | A -> myNote = A -> Polygon ( aNumber ); | |
1017 | ||
1018 | } // end WNT_WDriver :: BeginPolygon | |
1019 | ||
1020 | void WNT_WDriver :: BeginSegments () { | |
1021 | ||
1022 | A -> myPrimitive = zzLine; | |
1023 | A -> myNote = NULL; | |
1024 | ||
1025 | } // end WNT_WDriver :: BeginSegments | |
1026 | ||
1027 | void WNT_WDriver :: BeginArcs () { | |
1028 | ||
1029 | A -> myPrimitive = zzArc; | |
1030 | A -> myNote = NULL; | |
1031 | ||
1032 | } // end WNT_WDriver :: BeginArcs | |
1033 | ||
1034 | void WNT_WDriver :: BeginPolyArcs () { | |
1035 | ||
1036 | A -> myPrimitive = zzPolySector; | |
1037 | A -> myNote = NULL; | |
1038 | ||
1039 | } // end WNT_WDriver :: BeginPolyArcs | |
1040 | ||
1041 | void WNT_WDriver :: BeginMarkers () { | |
1042 | ||
1043 | A -> myPrimitive = zzMarker; | |
1044 | A -> myNote = NULL; | |
1045 | ||
1046 | } // end WNT_WDriver :: BeginMarkers | |
1047 | ||
1048 | void WNT_WDriver :: BeginPoints () { | |
1049 | ||
1050 | A -> myPrimitive = zzPoint; | |
1051 | A -> myNote = NULL; | |
1052 | ||
1053 | } // end WNT_WDriver :: BeginPoints | |
1054 | ||
1055 | void WNT_WDriver :: ClosePrimitive () { | |
1056 | ||
1057 | A -> myPrimitive = zzNone; | |
1058 | A -> myNote = NULL; | |
1059 | ||
1060 | } // end WNT_WDriver :: ClosePrimitive | |
1061 | ||
1062 | void WNT_WDriver :: InitializeColorMap ( const Handle( Aspect_ColorMap) & Colormap ) | |
1063 | { | |
1064 | Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) :: | |
1065 | DownCast ( MyWindow -> GraphicDevice () ); | |
1066 | ||
1067 | Aspect_ColorMapEntry entry; | |
1068 | Standard_Integer i, minindex = IntegerLast(), maxindex = -minindex; | |
1069 | for (i = 1; i <= Colormap->Size (); i++) { | |
1070 | entry = Colormap->Entry (i); | |
1071 | maxindex = Max(maxindex, entry.Index ()); | |
1072 | minindex = Min(minindex, entry.Index ()); | |
1073 | } | |
1074 | ||
1075 | if ( myColors.IsNull () || myColors -> Length () != Colormap -> Size () ) | |
1076 | myColors = new WNT_HColorTable ( minindex, maxindex, (WNT_ColorRef)0x00000000 ); | |
1077 | ||
1078 | gDev -> MapColors ( Colormap, myColors ); | |
1079 | } // end WNT_WDriver :: InitializeColorMap | |
1080 | ||
1081 | void WNT_WDriver :: InitializeTypeMap ( const Handle( Aspect_TypeMap )& Typemap ) | |
1082 | { | |
1083 | Aspect_TypeMapEntry entry; | |
1084 | Standard_Integer i, minindex = IntegerLast(), maxindex = -minindex; | |
1085 | for (i = 1; i <= Typemap->Size (); i++) { | |
1086 | entry = Typemap->Entry (i); | |
1087 | maxindex = Max(maxindex, entry.Index ()); | |
1088 | minindex = Min(minindex, entry.Index ()); | |
1089 | } | |
1090 | ||
1091 | myTypeIdxs = new TColStd_HArray1OfInteger (minindex, maxindex, 1); | |
1092 | for (i = 1; i <= Typemap->Size (); i++) { | |
1093 | entry = Typemap->Entry (i); | |
1094 | myTypeIdxs -> SetValue (entry.Index(), i); | |
1095 | } | |
1096 | } // end WNT_WDriver :: InitializeTypeMap | |
1097 | ||
1098 | void WNT_WDriver :: InitializeWidthMap ( const Handle( Aspect_WidthMap )& Widthmap ) | |
1099 | { | |
1100 | Aspect_WidthMapEntry entry; | |
1101 | Standard_Integer i, minindex = IntegerLast(), maxindex = -minindex; | |
1102 | for (i = 1; i <= Widthmap->Size (); i++) { | |
1103 | entry = Widthmap->Entry (i); | |
1104 | maxindex = Max(maxindex, entry.Index ()); | |
1105 | minindex = Min(minindex, entry.Index ()); | |
1106 | } | |
1107 | ||
1108 | myWidthIdxs = new TColStd_HArray1OfInteger (minindex, maxindex, 1); | |
1109 | for (i = 1; i <= Widthmap->Size (); i++) { | |
1110 | entry = Widthmap->Entry (i); | |
1111 | myWidthIdxs -> SetValue (entry.Index(), i); | |
1112 | } | |
1113 | } // end WNT_WDriver :: InitializeWidthMap | |
1114 | ||
1115 | void WNT_WDriver :: InitializeFontMap ( const Handle( Aspect_FontMap )& Fontmap ) | |
1116 | { | |
1117 | Aspect_FontStyle fontStyle; | |
1118 | Handle( WNT_FontMapEntry ) fmEntry; | |
1119 | Standard_Character left[ 260 ], right[ 250 ]; | |
1120 | Standard_PCharacter pSize; | |
1121 | Standard_Integer height, mapSize = Fontmap -> Size (); | |
1122 | HDC hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () ); | |
1123 | HFONT hfo = SelectFont( hdc, GetStockObject ( DEFAULT_GUI_FONT ) ); | |
1124 | Standard_Integer i; | |
1125 | /*====================== MFT ====================*/ | |
1126 | #ifdef MFT | |
1127 | Aspect_FontMapEntry entry; | |
1128 | Aspect_FontStyle style; | |
1129 | Quantity_Length size; | |
1130 | Quantity_PlaneAngle slant; | |
1131 | TCollection_AsciiString aname; | |
1132 | if ( UseMFT() ) { | |
1133 | Handle(MFT_FontManager) theFontManager; | |
1134 | myMFTFonts = new WNT_HListOfMFTFonts (0, mapSize, theFontManager); | |
1135 | myMFTSizes = new TShort_HArray1OfShortReal (0, mapSize, 0.F); | |
1136 | } | |
1137 | #endif | |
1138 | /*====================== MFT ====================*/ | |
1139 | myFonts = new WNT_HFontTable ( 0, mapSize - 1 ); | |
1140 | for ( i = 0; i < mapSize; ++i ) { | |
1141 | /*====================== MFT ====================*/ | |
1142 | #ifdef MFT | |
1143 | if ( UseMFT() ) { | |
1144 | entry = Fontmap->Entry(i+1); | |
1145 | style = entry.Type (); | |
1146 | size = (Quantity_Length) TOMILLIMETER (style.Size()); | |
1147 | slant = style.Slant (); | |
1148 | if (style.CapsHeight()) size = -size; | |
1149 | aname = style.AliasName (); | |
1150 | Standard_Boolean found = MFT_FontManager::IsKnown (aname.ToCString()); | |
1151 | if (!found) { | |
1152 | cout << " WNT_WDriver::SetFontMap can't find the MFT font name '" | |
1153 | << aname << "', using 'Defaultfont'" << endl << flush; | |
1154 | aname = TCollection_AsciiString("Defaultfont"); | |
1155 | found = Standard_True; | |
1156 | } | |
1157 | if (found) { | |
1158 | Handle(MFT_FontManager) theFontManager; | |
1159 | Aspect_FontStyle theStyle = MFT_FontManager::Font (aname.ToCString()); | |
1160 | found = Standard_False; | |
1161 | for (int k = 0; k < mapSize; k++) { | |
1162 | theFontManager = myMFTFonts -> Value (k); | |
1163 | if (!theFontManager.IsNull()) { | |
1164 | if (theStyle == theFontManager->Font()) { | |
1165 | found = Standard_True; | |
1166 | break; | |
1167 | } | |
1168 | } | |
1169 | } | |
1170 | if (!found) | |
1171 | theFontManager = new MFT_FontManager (aname.ToCString()); | |
1172 | theFontManager->SetFontAttribs ( | |
1173 | Abs(size), Abs(size), slant, 0., Standard_Boolean(size < 0.) | |
1174 | ); | |
1175 | myMFTFonts->SetValue (i, theFontManager); | |
1176 | myMFTSizes->SetValue (i, (Standard_ShortReal)size); | |
1177 | } | |
1178 | } | |
1179 | if ( UseMFT() && !myMFTFonts->Value(i).IsNull()) | |
1180 | continue; | |
1181 | #endif | |
1182 | /*====================== MFT ====================*/ | |
1183 | fontStyle = Fontmap -> Entry ( i + 1 ).Type (); | |
1184 | height = Standard_Integer ( fontStyle.Size () / myPixelToUnit ); | |
1185 | lstrcpyA ( right,"-*-*-*-*-*-*-*-*-*-*-*-*-" ); | |
1186 | switch ( fontStyle.Style () ) { | |
1187 | case Aspect_TOF_HELVETICA: | |
1188 | lstrcatA ( right,"Arial" ); | |
1189 | break; | |
1190 | case Aspect_TOF_DEFAULT: | |
1191 | case Aspect_TOF_COURIER: | |
1192 | lstrcatA ( right, "Courier New" ); | |
1193 | break; | |
1194 | case Aspect_TOF_TIMES: | |
1195 | lstrcatA ( right,"Times New Roman" ); | |
1196 | break; | |
1197 | case Aspect_TOF_USERDEFINED: | |
1198 | lstrcpyA ( left, fontStyle.Value () ); | |
1199 | if ( strchr ( fontStyle.Value (), '-' ) ) { | |
1200 | height = atol ( pSize = strtok ( left, "-" ) ); | |
1201 | if ( height == 0 ) | |
1202 | height = Standard_Integer ( atof ( pSize ) / myPixelToUnit ); | |
1203 | if ( height == 0 ) | |
1204 | height = Standard_Integer ( fontStyle.Size () / myPixelToUnit ); | |
1205 | pSize = left + lstrlenA ( left ); | |
1206 | *pSize = '-'; | |
1207 | lstrcpyA ( right, pSize ); | |
1208 | } else lstrcatA ( right,left ); | |
1209 | } // end switch | |
1210 | height = Standard_Integer ( height * W32_TextFactor ); | |
1211 | ltoa ( height, left, 10 ); | |
1212 | lstrcatA ( left, right ); | |
1213 | fmEntry = new WNT_FontMapEntry ( left ); | |
1214 | if ( fontStyle.CapsHeight () ) { | |
1215 | double r; | |
1216 | TEXTMETRIC tm; | |
1217 | SelectFont( hdc, fmEntry -> HFont () ); | |
1218 | GetTextMetrics ( hdc, &tm ); | |
1219 | r = tm.tmAscent * tm.tmHeight / ( tm.tmAscent - tm.tmInternalLeading ); | |
1220 | lstrcpy ( right, strchr ( left, '-' ) ); | |
1221 | ltoa ( LONG( r + 0.5 ), left, 10 ); | |
1222 | lstrcatA ( left, right ); | |
1223 | fmEntry = new WNT_FontMapEntry ( left ); | |
1224 | } // end if | |
1225 | myFonts -> SetValue ( i, fmEntry ); | |
1226 | } // end for | |
1227 | SelectFont( hdc, hfo ); | |
1228 | ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc ); | |
1229 | } // end WNT_WDriver :: InitializeFontMap | |
1230 | ||
1231 | void WNT_WDriver :: InitializeMarkMap ( const Handle( Aspect_MarkMap )& Markmap ) | |
1232 | { | |
1233 | Aspect_MarkMapEntry entry; | |
1234 | Standard_Integer i, minindex = IntegerLast(), maxindex = -minindex; | |
1235 | for (i = 1; i <= Markmap->Size (); i++) { | |
1236 | entry = Markmap->Entry (i); | |
1237 | maxindex = Max(maxindex, entry.Index ()); | |
1238 | minindex = Min(minindex, entry.Index ()); | |
1239 | } | |
1240 | ||
1241 | myMarkerIdxs = new TColStd_HArray1OfInteger (minindex, maxindex, -1); | |
1242 | for (i = 1; i <= Markmap->Size (); i++) { | |
1243 | entry = Markmap->Entry (i); | |
1244 | myMarkerIdxs -> SetValue (entry.Index(), i); | |
1245 | } | |
1246 | } // end WNT_WDriver :: InitializeMarkMap | |
1247 | ||
1248 | Standard_Address WNT_WDriver :: InternalOpenBuffer ( | |
1249 | const Standard_Integer aRetainBuffer, | |
1250 | const Standard_Boolean aMono, | |
1251 | const Standard_ShortReal aPivotX, | |
1252 | const Standard_ShortReal aPivotY, | |
1253 | const Standard_Integer aColorIndex, | |
1254 | const Standard_Integer aWidthIndex, | |
1255 | const Standard_Integer aTypeIndex, | |
1256 | const Standard_Integer aFontIndex, | |
1257 | const Aspect_TypeOfDrawMode aDrawMode | |
1258 | ) { | |
1259 | ||
1260 | PW32_Allocator aNew = NULL; | |
1261 | Aspect_TypeOfDrawMode DrawMode = Aspect_TODM_REPLACE; | |
1262 | ||
1263 | MyDrawMode = aDrawMode; | |
1264 | aNew = _FindAllocator ( myAllocators, aRetainBuffer ); | |
1265 | ||
1266 | if ( aNew != NULL ) | |
1267 | ||
1268 | ClearBuffer ( aRetainBuffer ); | |
1269 | ||
1270 | else aNew = ( *W32_GetAllocator ) ( | |
1271 | aRetainBuffer, ( PW32_Allocator )myAllocators | |
1272 | ); | |
1273 | ||
1274 | aNew -> myPivot.x = P( aPivotX ); | |
1275 | aNew -> myPivot.y = P( aPivotY ); | |
1276 | ||
1277 | if ( aRetainBuffer ) { | |
1278 | ||
1279 | Standard_Address aSave = myAllocator; | |
1280 | myAllocator = ( Standard_Address )aNew; | |
1281 | ||
1282 | A -> myFlags |= ( W32F_MONO | W32F_MINIT ); | |
1283 | SetLineAttrib ( aColorIndex, aTypeIndex, aWidthIndex ); | |
1284 | SetTextAttrib ( aColorIndex, aFontIndex ); | |
1285 | SetPolyAttrib ( aColorIndex, -1, Standard_True ); | |
1286 | SetMarkerAttrib ( aColorIndex, aWidthIndex, Standard_False ); | |
1287 | A -> myFlags &= ~W32F_MINIT; | |
1288 | ||
1289 | myAllocator = aSave; | |
1290 | ||
1291 | } else A -> myFlags &= ~W32F_MONO; | |
1292 | ||
1293 | return aNew; | |
1294 | ||
1295 | } // end WNT_WDriver :: InternalOpenBuffer | |
1296 | ||
1297 | Standard_Boolean WNT_WDriver :: OpenBuffer ( | |
1298 | const Standard_Integer aRetainBuffer, | |
1299 | const Standard_ShortReal aPivotX, | |
1300 | const Standard_ShortReal aPivotY, | |
1301 | const Standard_Integer aWidthIndex, | |
1302 | const Standard_Integer aColorIndex, | |
1303 | const Standard_Integer aFontIndex, | |
1304 | const Aspect_TypeOfDrawMode aDrawMode | |
1305 | ) { | |
1306 | return ( Standard_Boolean )InternalOpenBuffer ( | |
1307 | aRetainBuffer, Standard_True, | |
1308 | aPivotX, aPivotY, aColorIndex, aWidthIndex, | |
1309 | 0, aFontIndex, aDrawMode | |
1310 | ); | |
1311 | ||
1312 | } // end WNT_WDriver :: OpenBuffer | |
1313 | ||
1314 | Standard_Boolean WNT_WDriver :: OpenColorBuffer ( | |
1315 | const Standard_Integer aRetainBuffer, | |
1316 | const Standard_ShortReal aPivotX, | |
1317 | const Standard_ShortReal aPivotY, | |
1318 | const Standard_Integer aWidthIndex, | |
1319 | const Standard_Integer aColorIndex, | |
1320 | const Standard_Integer aFontIndex, | |
1321 | const Aspect_TypeOfDrawMode aDrawMode | |
1322 | ) { | |
1323 | ||
1324 | return ( Standard_Boolean )InternalOpenBuffer ( | |
1325 | aRetainBuffer, Standard_False, | |
1326 | aPivotX, aPivotY, aColorIndex, aWidthIndex, | |
1327 | 0, aFontIndex, aDrawMode | |
1328 | ); | |
1329 | ||
1330 | } // end WNT_WDriver :: OpenColorBuffer | |
1331 | ||
1332 | void WNT_WDriver :: CloseBuffer ( const Standard_Integer aRetainBuffer ) const { | |
1333 | ||
1334 | if ( aRetainBuffer ) { | |
1335 | ||
1336 | PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); | |
1337 | ||
1338 | if ( a != NULL ) { | |
1339 | ||
1340 | PW32_Allocator b = ( PW32_Allocator )myAllocators; | |
1341 | ||
1342 | while ( b -> myNext != a ) b = b -> myNext; | |
1343 | ||
1344 | if ( a -> myFlags & W32F_DRAWN ) EraseBuffer ( aRetainBuffer ); | |
1345 | ||
1346 | b -> myNext = a -> myNext; | |
1347 | ||
1348 | delete a; | |
1349 | ||
1350 | } // end if | |
1351 | ||
1352 | SelectBuffer ( 0 ); | |
1353 | ||
1354 | } // end if | |
1355 | ||
1356 | } // end WNT_WDriver :: CloseBuffer | |
1357 | ||
1358 | void WNT_WDriver :: ClearBuffer ( const Standard_Integer aRetainBuffer ) const { | |
1359 | ||
1360 | PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); | |
1361 | ||
1362 | if ( a != NULL ) { | |
1363 | ||
1364 | if ( a -> myFlags & W32F_DRAWN ) EraseBuffer ( aRetainBuffer ); | |
1365 | ||
1366 | a -> ClearBlocks (); | |
1367 | ||
1368 | } // end if | |
1369 | ||
1370 | } // end WNT_WDriver :: ClearBuffer | |
1371 | ||
1372 | void WNT_WDriver :: DrawBuffer ( const Standard_Integer aRetainBuffer ) const { | |
1373 | ||
1374 | PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); | |
1375 | ||
1376 | if ( a != NULL ) { | |
1377 | ||
1378 | RECT r; | |
1379 | SIZE sz; | |
1380 | HPALETTE hpo = NULL; | |
1381 | HDC hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () ); | |
1382 | ||
1383 | Handle( WNT_GraphicDevice ) gDev = Handle ( WNT_GraphicDevice ) :: | |
1384 | DownCast ( MyWindow -> GraphicDevice () ); | |
1385 | ||
1386 | if ( gDev -> IsPaletteDevice () ) | |
1387 | ||
1388 | hpo = SelectPalette ( hdc, ( HPALETTE )gDev -> HPalette (), FALSE ); | |
1389 | ||
1390 | GetClientRect ( ( HWND )myWNTWindow -> HWindow (), &r ); | |
1391 | sz.cx = r.right; | |
1392 | sz.cy = r.bottom; | |
1393 | ||
1394 | if ( a -> myFlags & W32F_DBUFF ) { | |
1395 | HDC hdcMem = CreateCompatibleDC ( hdc ); | |
1396 | HBITMAP hbo = SelectBitmap( hdcMem, ( HBITMAP )myWNTWindow -> HPixmap () ); | |
1397 | HPALETTE hpo; | |
1398 | ||
1399 | if ( gDev -> IsPaletteDevice () ) | |
1400 | ||
1401 | hpo = SelectPalette ( hdcMem, ( HPALETTE )gDev -> HPalette (), FALSE ); | |
1402 | ||
1403 | SetROP2 ( hdcMem, _GetROP2 ( MyDrawMode ) ); | |
1404 | ||
1405 | a -> Play ( hdcMem, &sz ); | |
1406 | ||
1407 | BitBlt ( | |
1408 | hdc, r.left, r.top, r.right + 1, r.bottom + 1, | |
1409 | hdcMem, r.left, r.top, SRCCOPY | |
1410 | ); | |
1411 | ||
1412 | if ( gDev -> IsPaletteDevice () ) SelectPalette ( hdcMem, hpo, FALSE ); | |
1413 | ||
1414 | SelectBitmap( hdcMem, hbo ); | |
1415 | DeleteDC ( hdcMem ); | |
1416 | } else { | |
1417 | SetROP2 ( hdc, _GetROP2 ( MyDrawMode ) ); | |
1418 | a -> Play ( hdc, &sz ); | |
1419 | } // end else | |
1420 | ||
1421 | if ( hpo != NULL ) SelectPalette( hdc, hpo, FALSE ); | |
1422 | ||
1423 | ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc ); | |
1424 | ||
1425 | a -> myFlags |= W32F_DRAWN; | |
1426 | ||
1427 | } // end if | |
1428 | ||
1429 | } // end WNT_WDriver :: DrawBuffer | |
1430 | ||
1431 | void WNT_WDriver :: EraseBuffer ( const Standard_Integer aRetainBuffer ) const { | |
1432 | ||
1433 | PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); | |
1434 | ||
1435 | if ( a != NULL && ( a -> myFlags & W32F_DRAWN ) ) { | |
1436 | ||
1437 | RECT r; | |
1438 | ||
1439 | a -> URect ( &r ); | |
1440 | ||
1441 | if ( !IsRectEmpty ( &r ) ) { | |
1442 | ||
1443 | if ( a -> myID != 0 ) { | |
1444 | ||
1445 | if ( MyWindow -> BackingStore () ) | |
1446 | ||
1447 | MyWindow -> RestoreArea ( | |
1448 | ( r.left + r.right ) / 2, ( r.top + r.bottom ) / 2, | |
1449 | r.right - r.left + 2, r.bottom - r.top + 2 | |
1450 | ); | |
1451 | ||
1452 | else if ( ( ( PW32_Allocator )myAllocators ) -> myFlags & W32F_DRAWN ) | |
1453 | ||
1454 | DrawBuffer ( 0 ); | |
1455 | ||
1456 | else | |
1457 | clear: | |
1458 | MyWindow -> ClearArea ( | |
1459 | ( r.left + r.right ) / 2, ( r.top + r.bottom ) / 2, | |
1460 | r.right - r.left + 2, r.bottom - r.top + 2 | |
1461 | ); | |
1462 | ||
1463 | } else goto clear; | |
1464 | ||
1465 | } // end if | |
1466 | ||
1467 | a -> myFlags &= ~W32F_DRAWN; | |
1468 | ||
1469 | } // end if | |
1470 | ||
1471 | } // end WNT_WDriver :: EraseBuffer | |
1472 | ||
1473 | void WNT_WDriver :: MoveBuffer ( | |
1474 | const Standard_Integer aRetainBuffer, | |
1475 | const Standard_ShortReal aPivotX, | |
1476 | const Standard_ShortReal aPivotY | |
1477 | ) const { | |
1478 | ||
1479 | PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); | |
1480 | ||
1481 | if ( a != NULL ) { | |
1482 | ||
1483 | BOOL fDrawn = a -> myFlags & W32F_DRAWN; | |
1484 | ||
1485 | if ( fDrawn ) EraseBuffer ( aRetainBuffer ); | |
1486 | ||
1487 | a -> myMove.x = P( aPivotX ) - a -> myPivot.x; | |
1488 | a -> myMove.y = P( aPivotY ) - a -> myPivot.y; | |
1489 | ||
1490 | if ( fDrawn ) DrawBuffer ( aRetainBuffer ); | |
1491 | ||
1492 | } // end if | |
1493 | ||
1494 | } // end WNT_WDriver :: MoveBuffer | |
1495 | ||
1496 | void WNT_WDriver :: ScaleBuffer ( | |
1497 | const Standard_Integer aRetainBuffer, | |
1498 | const Quantity_Factor aScaleX, | |
1499 | const Quantity_Factor aScaleY | |
1500 | ) const { | |
1501 | ||
1502 | PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); | |
1503 | ||
1504 | if ( a != NULL ) { | |
1505 | ||
1506 | BOOL fDrawn = a -> myFlags & W32F_DRAWN; | |
1507 | ||
1508 | if ( fDrawn ) EraseBuffer ( aRetainBuffer ); | |
1509 | ||
1510 | a -> myScaleX = aScaleX; | |
1511 | a -> myScaleY = aScaleY; | |
1512 | ||
1513 | if ( fDrawn ) DrawBuffer ( aRetainBuffer ); | |
1514 | ||
1515 | } // end if | |
1516 | ||
1517 | } // end WNT_WDriver :: ScaleBuffer | |
1518 | ||
1519 | void WNT_WDriver :: RotateBuffer ( | |
1520 | const Standard_Integer aRetainBuffer, | |
1521 | const Quantity_PlaneAngle anAngle | |
1522 | ) const { | |
1523 | ||
1524 | PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); | |
1525 | ||
1526 | if ( a != NULL ) { | |
1527 | ||
1528 | BOOL fDrawn = a -> myFlags & W32F_DRAWN; | |
1529 | ||
1530 | if ( fDrawn ) EraseBuffer ( aRetainBuffer ); | |
1531 | ||
1532 | a -> myAngle = anAngle; | |
1533 | ||
1534 | if ( fDrawn ) DrawBuffer ( aRetainBuffer ); | |
1535 | ||
1536 | } // end if | |
1537 | ||
1538 | } // end WNT_WDriver :: RotateBuffer | |
1539 | ||
1540 | void WNT_WDriver :: WorkSpace ( Quantity_Length& Width, Quantity_Length& Heigth ) const { | |
1541 | ||
1542 | RECT r; | |
1543 | ||
1544 | GetClientRect ( ( HWND )( myWNTWindow -> HWindow () ), &r ); | |
1545 | ||
1546 | Width = U( r.right ); | |
1547 | Heigth = U( r.bottom ); | |
1548 | ||
1549 | } // end WNT_WDriver :: WorkSpace | |
1550 | ||
1551 | Quantity_Length WNT_WDriver :: Convert ( const Standard_Integer PV ) const { | |
1552 | ||
1553 | return U( PV ); | |
1554 | ||
1555 | } // end WNT_WDriver :: Convert | |
1556 | ||
1557 | Standard_Integer WNT_WDriver :: Convert ( const Quantity_Length DV ) const { | |
1558 | ||
1559 | return P( DV ); | |
1560 | ||
1561 | } // end WNT_WDriver :: Convert | |
1562 | ||
1563 | void WNT_WDriver :: Convert ( | |
1564 | const Standard_Integer PX, | |
1565 | const Standard_Integer PY, | |
1566 | Quantity_Length& DX, | |
1567 | Quantity_Length& DY | |
1568 | ) const { | |
1569 | ||
1570 | RECT r; | |
1571 | GetClientRect ( ( HWND )myWNTWindow -> HWindow (), &r ); | |
1572 | ||
1573 | DX = U( PX ); | |
1574 | DY = U( r.bottom - PY ); | |
1575 | ||
1576 | } // end WNT_WDriver :: Convert | |
1577 | ||
1578 | void WNT_WDriver :: Convert ( | |
1579 | const Quantity_Length DX, | |
1580 | const Quantity_Length DY, | |
1581 | Standard_Integer& PX, | |
1582 | Standard_Integer& PY | |
1583 | ) const { | |
1584 | ||
1585 | RECT r; | |
1586 | GetClientRect ( ( HWND )myWNTWindow -> HWindow (), &r ); | |
1587 | ||
1588 | PX = P( DX ); | |
1589 | PY = r.bottom - P( DY ); | |
1590 | ||
1591 | } // end WNT_WDriver :: Convert | |
1592 | ||
1593 | Standard_Integer WNT_WDriver :: ProcessColorIndex ( | |
1594 | const Standard_Integer ColorIndex | |
1595 | ) const { | |
1596 | ||
1597 | if ( !SA ) return A -> myPointColor; | |
1598 | ||
1599 | if ( myColors.IsNull () ) return ( Standard_Integer )RGB( 0, 0, 0 ); | |
1600 | ||
1601 | Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) :: | |
1602 | DownCast ( MyWindow -> GraphicDevice () ); | |
1603 | ||
1604 | if ( ColorIndex <= 0 ) { | |
1605 | ||
1606 | if ((A -> myFlags & W32F_MONO) && (A -> myFlags & W32F_MINIT)) { | |
1607 | return RGB(255, 255, 255); | |
1608 | } else { | |
1609 | LOGBRUSH lb; | |
1610 | GetObject ( myWNTWindow -> HBackground(), sizeof ( LOGBRUSH ), &lb ); | |
1611 | return lb.lbColor; | |
1612 | } | |
1613 | ||
1614 | } else | |
1615 | ||
1616 | switch ( MyDrawMode ) { | |
1617 | ||
1618 | default : | |
1619 | case Aspect_TODM_REPLACE : | |
1620 | ||
1621 | if (ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper()) | |
1622 | return myColors -> Value ( myColors->Lower() ); | |
1623 | return myColors -> Value ( ColorIndex ); | |
1624 | ||
1625 | case Aspect_TODM_ERASE : | |
1626 | ||
1627 | return gDev -> SetColor ( MyWindow -> Background ().Color () ); | |
1628 | ||
1629 | case Aspect_TODM_XORLIGHT : | |
1630 | case Aspect_TODM_XOR : | |
1631 | ||
1632 | return gDev -> HighlightColor (); | |
1633 | ||
1634 | } // end switch | |
1635 | ||
1636 | } // end WNT_WDriver :: ProcessColorIndex | |
1637 | ||
1638 | Quantity_Length WNT_WDriver :: ProcessWidthIndex ( | |
1639 | const Standard_Integer WidthIndex | |
1640 | ) const | |
1641 | { | |
1642 | Standard_Integer theIndex = WidthIndex; | |
1643 | if (WidthIndex < myWidthIdxs->Lower() || WidthIndex > myWidthIdxs->Upper()) | |
1644 | theIndex = myWidthIdxs->Lower(); | |
1645 | ||
1646 | Aspect_WidthMapEntry Entry = WidthMap () -> Entry ( myWidthIdxs -> Value(theIndex) ); | |
1647 | return ( Entry.Type () == Aspect_WOL_THIN ) ? | |
1648 | ( Quantity_Length )0.0 : Entry.Width () / myPixelToUnit; | |
1649 | } // end WNT_WDriver :: ProcessWidthIndex | |
1650 | ||
1651 | Standard_Integer WNT_WDriver :: ProcessTypeIndex ( | |
1652 | const Standard_Integer TypeIndex | |
1653 | ) const{ | |
1654 | ||
1655 | return ( TypeMap () -> Entry ( TypeIndex + 1 ).Type ().Style () == Aspect_TOL_SOLID ) ? | |
1656 | 0 : PS_USERSTYLE; | |
1657 | ||
1658 | } // end WNT_WDriver :: ProcessTypeIndex | |
1659 | ||
1660 | Standard_Boolean WNT_WDriver :: BufferIsOpen ( | |
1661 | const Standard_Integer aRetainBuffer | |
1662 | ) const { | |
1663 | ||
1664 | return ( _FindAllocator ( myAllocators, aRetainBuffer) != NULL ? | |
1665 | Standard_True : Standard_False | |
1666 | ); | |
1667 | ||
1668 | } // end WNT_WDriver :: BufferIsOpen | |
1669 | ||
1670 | Standard_Boolean WNT_WDriver :: BufferIsEmpty ( | |
1671 | const Standard_Integer aRetainBuffer | |
1672 | ) const { | |
1673 | ||
1674 | PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); | |
1675 | ||
1676 | if ( a != NULL ) | |
1677 | ||
1678 | return ( a -> myFlags & W32F_EMPTY ) ? Standard_True : Standard_False; | |
1679 | ||
1680 | return Standard_True; | |
1681 | ||
1682 | } // end WNT_WDriver :: BufferIsEmpty | |
1683 | ||
1684 | Standard_Boolean WNT_WDriver :: BufferIsDrawn ( | |
1685 | const Standard_Integer aRetainBuffer | |
1686 | ) const { | |
1687 | ||
1688 | PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); | |
1689 | ||
1690 | if ( a != NULL ) | |
1691 | ||
1692 | return ( a -> myFlags & W32F_DRAWN ) ? Standard_True : Standard_False; | |
1693 | ||
1694 | return Standard_False; | |
1695 | ||
1696 | } // end WNT_WDriver :: BufferIsDrawn | |
1697 | ||
1698 | void WNT_WDriver :: AngleOfBuffer ( | |
1699 | const Standard_Integer aRetainBuffer, | |
1700 | Quantity_PlaneAngle& anAngle | |
1701 | ) const { | |
1702 | ||
1703 | PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); | |
1704 | ||
1705 | if ( a != NULL ) anAngle = a -> myAngle; | |
1706 | ||
1707 | } // end WNT_WDriver :: AngleOfBuffer | |
1708 | ||
1709 | void WNT_WDriver :: ScaleOfBuffer ( | |
1710 | const Standard_Integer aRetainBuffer, | |
1711 | Quantity_Factor& aScaleX, | |
1712 | Quantity_Factor& aScaleY | |
1713 | ) const { | |
1714 | ||
1715 | PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); | |
1716 | ||
1717 | if ( a != NULL ) { | |
1718 | ||
1719 | aScaleX = a -> myScaleX; | |
1720 | aScaleY = a -> myScaleY; | |
1721 | ||
1722 | } // end if | |
1723 | ||
1724 | } // end WNT_WDriver :: ScaleOfBuffer | |
1725 | ||
1726 | void WNT_WDriver :: PositionOfBuffer ( | |
1727 | const Standard_Integer aRetainBuffer, | |
1728 | Standard_ShortReal& aPivotX, | |
1729 | Standard_ShortReal& aPivotY | |
1730 | ) const { | |
1731 | ||
1732 | PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); | |
1733 | ||
1734 | if ( a != NULL ) { | |
1735 | ||
1736 | aPivotX = Standard_ShortReal ( U( a -> myPivot.x + a -> myMove.x ) ); | |
1737 | aPivotY = Standard_ShortReal ( U( a -> myPivot.y + a -> myMove.y ) ); | |
1738 | ||
1739 | } // end if | |
1740 | ||
1741 | } // end WNT_WDriver :: PositionOfBuffer | |
1742 | ||
1743 | void WNT_WDriver :: TextSize ( | |
1744 | const TCollection_ExtendedString& aText, | |
1745 | Standard_ShortReal& aWidth, | |
1746 | Standard_ShortReal& aHeight, | |
1747 | const Standard_Integer aFontIndex | |
1748 | ) const { | |
1749 | #ifdef PRO17381 | |
1750 | if( aText.Length() <= 0 ) { | |
1751 | aWidth = aHeight = 0.; | |
1752 | return; | |
1753 | } | |
1754 | #endif | |
1755 | ||
1756 | Standard_ShortReal xoffset, yoffset; | |
1757 | /*====================== MFT ====================*/ | |
1758 | #ifdef MFT | |
1759 | if ( UseMFT() ) | |
1760 | TextSize (aText, aWidth, aHeight, xoffset, yoffset, aFontIndex); | |
1761 | else { | |
1762 | #endif | |
1763 | /*====================== MFT ====================*/ | |
1764 | ||
1765 | char* str = _ConvertU2F ( aText ); | |
1766 | ||
1767 | TextSize ( str, aWidth, aHeight, xoffset, yoffset, aFontIndex ); | |
1768 | ||
1769 | HeapFree ( GetProcessHeap (), 0, str ); | |
1770 | ||
1771 | /*====================== MFT ====================*/ | |
1772 | #ifdef MFT | |
1773 | } | |
1774 | #endif | |
1775 | /*====================== MFT ====================*/ | |
1776 | } // end WNT_WDriver :: TextSize | |
1777 | ||
1778 | void WNT_WDriver :: TextSize ( | |
1779 | const TCollection_ExtendedString& aText, | |
1780 | Standard_ShortReal& aWidth, | |
1781 | Standard_ShortReal& aHeight, | |
1782 | Standard_ShortReal& anXoffset, | |
1783 | Standard_ShortReal& anYoffset, | |
1784 | const Standard_Integer aFontIndex | |
1785 | ) const { | |
1786 | #ifdef PRO17381 | |
1787 | if( aText.Length() <= 0 ) { | |
1788 | aWidth = aHeight = anXoffset = anYoffset = 0.; | |
1789 | return; | |
1790 | } | |
1791 | #endif | |
1792 | ||
1793 | /*====================== MFT ====================*/ | |
1794 | #ifdef MFT | |
1795 | if ( UseMFT() ) { | |
1796 | Standard_Integer aFont = (aFontIndex < 0 ? | |
1797 | (int)A->myTextFont : aFontIndex); | |
1798 | Handle(MFT_FontManager) theFontManager = | |
1799 | ((WNT_WDriver *const)(this))->MFT_Font(aFont); | |
1800 | Standard_Real theWidth = 0.,theAscent = 0., | |
1801 | theLbearing = 0.,theDescent = 0.; | |
1802 | if (aText.IsAscii()) { | |
1803 | TCollection_AsciiString ascii (aText,'?'); | |
1804 | theFontManager->TextSize(ascii.ToCString(), theWidth, | |
1805 | theAscent, theLbearing, theDescent); | |
1806 | } else if (theFontManager->IsComposite()) { | |
1807 | theFontManager->TextSize(aText.ToExtString(), theWidth, | |
1808 | theAscent, theLbearing, theDescent); | |
1809 | } | |
1810 | theDescent = Max( | |
1811 | theDescent, (A->myFlags & W32F_TULIN ? | |
1812 | theFontManager->UnderlinePosition() : 0.)); | |
1813 | aWidth = Standard_ShortReal (theWidth ); | |
1814 | aHeight = Standard_ShortReal (theAscent + theDescent); | |
1815 | anXoffset = Standard_ShortReal (theLbearing ); | |
1816 | anYoffset = Standard_ShortReal (theDescent ); | |
1817 | } else { | |
1818 | #endif | |
1819 | char* str = ( char* )_ConvertU2F ( aText ); | |
1820 | ||
1821 | HDC hdc; | |
1822 | HFONT hfo; | |
1823 | SIZE sz; | |
1824 | int xo; | |
1825 | ||
1826 | hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () ); | |
1827 | hfo = SelectFont( | |
1828 | hdc, | |
1829 | aFontIndex < 0 ? A -> myTextFont : ( HFONT )myFonts -> Value ( aFontIndex ) -> HFont () | |
1830 | ); | |
1831 | ||
1832 | xo = A -> TextSize ( hdc, str, &sz ); | |
1833 | aWidth = Standard_ShortReal ( U( sz.cx ) ); | |
1834 | aHeight = Standard_ShortReal ( U( sz.cy ) ); | |
1835 | ||
1836 | anXoffset = Standard_ShortReal ( U( xo ) ); | |
1837 | anYoffset = Standard_ShortReal ( 0.0 ); | |
1838 | ||
1839 | SelectFont( hdc, hfo ); | |
1840 | ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc ); | |
1841 | ||
1842 | HeapFree ( GetProcessHeap (), 0, str ); | |
1843 | ||
1844 | /*====================== MFT ====================*/ | |
1845 | #ifdef MFT | |
1846 | } | |
1847 | #endif | |
1848 | /*====================== MFT ====================*/ | |
1849 | } // end WNT_WDriver :: TextSize | |
1850 | ||
1851 | void WNT_WDriver :: TextSize ( | |
1852 | const Standard_CString aText, | |
1853 | Standard_ShortReal& aWidth, | |
1854 | Standard_ShortReal& aHeight, | |
1855 | Standard_ShortReal& anXoffset, | |
1856 | Standard_ShortReal& anYoffset, | |
1857 | const Standard_Integer aFontIndex | |
1858 | ) const { | |
1859 | #ifdef PRO17381 | |
1860 | if( !aText || (strlen(aText) <= 0) ) { | |
1861 | aWidth = aHeight = anXoffset = anYoffset = 0.; | |
1862 | return; | |
1863 | } | |
1864 | #endif | |
1865 | ||
1866 | /*====================== MFT ====================*/ | |
1867 | #ifdef MFT | |
1868 | if ( UseMFT() ) { | |
1869 | TCollection_ExtendedString extText (aText); | |
1870 | TextSize (extText, aWidth, aHeight, anXoffset, anYoffset, aFontIndex); | |
1871 | } else { | |
1872 | #endif | |
1873 | /*====================== MFT ====================*/ | |
1874 | HDC hdc; | |
1875 | HFONT hfo; | |
1876 | SIZE sz; | |
1877 | int xo; | |
1878 | ||
1879 | hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () ); | |
1880 | hfo = SelectFont( | |
1881 | hdc, | |
1882 | aFontIndex < 0 ? A -> myTextFont : ( HFONT )myFonts -> Value ( aFontIndex ) -> HFont () | |
1883 | ); | |
1884 | ||
1885 | xo = A -> TextSize ( hdc, (Standard_PCharacter)aText, &sz ); | |
1886 | aWidth = Standard_ShortReal ( U( sz.cx ) ); | |
1887 | aHeight = Standard_ShortReal ( U( sz.cy ) ); | |
1888 | ||
1889 | anXoffset = Standard_ShortReal ( U( xo ) ); | |
1890 | anYoffset = Standard_ShortReal ( 0.0 ); | |
1891 | ||
1892 | SelectFont( hdc, hfo ); | |
1893 | ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc ); | |
1894 | /*====================== MFT ====================*/ | |
1895 | #ifdef MFT | |
1896 | } | |
1897 | #endif | |
1898 | /*====================== MFT ====================*/ | |
1899 | } // end WNT_WDriver :: TextSize | |
1900 | ||
1901 | Standard_CString WNT_WDriver :: FontSize ( | |
1902 | Quantity_PlaneAngle& aSlant, | |
1903 | Standard_ShortReal& aSize, | |
1904 | Standard_ShortReal& aBheight, | |
1905 | const Standard_Integer aFontIndex | |
1906 | ) const { | |
1907 | ||
1908 | /*====================== MFT ====================*/ | |
1909 | #ifdef MFT | |
1910 | if ( UseMFT() ) { | |
1911 | Standard_CString fstring; | |
1912 | Standard_Integer aFont = (aFontIndex < 0 ? | |
1913 | (int)A->myTextFont : aFontIndex); | |
1914 | Handle(MFT_FontManager) theFontManager = | |
1915 | myMFTFonts->Value (aFont); | |
1916 | Quantity_Length theWidth, theHeight, theDescent; | |
1917 | Quantity_PlaneAngle theSlant; | |
1918 | Quantity_Factor thePrecision; | |
1919 | Standard_Boolean theCapsHeight; | |
1920 | fstring = theFontManager->FontAttribs ( | |
1921 | theWidth, theHeight, theDescent, theSlant, thePrecision, theCapsHeight | |
1922 | ); | |
1923 | aSize = (Standard_ShortReal)theHeight; | |
1924 | aBheight = (Standard_ShortReal)theDescent; | |
1925 | aSlant = theSlant; | |
1926 | return fstring; | |
1927 | } else { | |
1928 | #endif | |
1929 | /*====================== MFT ====================*/ | |
1930 | if (aFontIndex < 0) | |
1931 | aSize = Standard_ShortReal ( U(myFonts->Value(0)->myLogFont.lfHeight) ); | |
1932 | else | |
1933 | aSize = Standard_ShortReal ( U(myFonts->Value(aFontIndex)->myLogFont.lfHeight) ); | |
1934 | aSize = Standard_ShortReal ( aSize / W32_TextFactor ); | |
1935 | aSlant = aFontIndex < 0 ? A -> myTextSlant : 0.0; | |
1936 | aBheight = 0.0F; | |
1937 | ||
1938 | return aFontIndex < 0 ? "" : myFonts->Value(aFontIndex)->myLogFont.lfFaceName; | |
1939 | /*====================== MFT ====================*/ | |
1940 | #ifdef MFT | |
1941 | } | |
1942 | #endif | |
1943 | /*====================== MFT ====================*/ | |
1944 | } // end WNT_WDriver :: FontSize | |
1945 | ||
1946 | void WNT_WDriver :: ColorBoundIndexs ( | |
1947 | Standard_Integer& aMinIndex, | |
1948 | Standard_Integer& aMaxIndex | |
1949 | ) const { | |
1950 | ||
1951 | if ( myColors.IsNull () ) { | |
1952 | ||
1953 | aMinIndex = | |
1954 | aMaxIndex = 0; | |
1955 | ||
1956 | } else { | |
1957 | ||
1958 | aMinIndex = 1; | |
1959 | aMaxIndex = myColors -> Length (); | |
1960 | ||
1961 | } // end else | |
1962 | ||
1963 | } // end WNT_WDriver :: ColorBoundIndexs | |
1964 | ||
1965 | Standard_Integer WNT_WDriver :: LocalColorIndex ( | |
1966 | const Standard_Integer anIndex | |
1967 | ) const { | |
1968 | ||
1969 | return ( anIndex < 1 || anIndex > myColors -> Length () ) ? -1 : anIndex; | |
1970 | ||
1971 | } // end WNT_WDriver :: LocalColorIndex | |
1972 | ||
1973 | void WNT_WDriver :: FontBoundIndexs ( | |
1974 | Standard_Integer& aMinIndex, | |
1975 | Standard_Integer& aMaxIndex | |
1976 | ) const { | |
1977 | ||
1978 | if ( myFonts.IsNull () ) { | |
1979 | ||
1980 | aMinIndex = | |
1981 | aMaxIndex = 0; | |
1982 | ||
1983 | } else { | |
1984 | ||
1985 | aMinIndex = 1; | |
1986 | aMaxIndex = myFonts -> Length (); | |
1987 | ||
1988 | } // end else | |
1989 | ||
1990 | } // end WNT_WDriver :: FontBoundIndexs | |
1991 | ||
1992 | Standard_Integer WNT_WDriver :: LocalFontIndex ( | |
1993 | const Standard_Integer anIndex | |
1994 | ) const { | |
1995 | ||
1996 | return ( anIndex < 1 || anIndex > myFonts -> Length () ) ? -1 : anIndex; | |
1997 | ||
1998 | } // end WNT_WDriver :: LocalFontIndex | |
1999 | ||
2000 | void WNT_WDriver :: TypeBoundIndexs ( | |
2001 | Standard_Integer& aMinIndex, | |
2002 | Standard_Integer& aMaxIndex | |
2003 | ) const { | |
2004 | ||
2005 | if ( TypeMap ().IsNull () ) { | |
2006 | ||
2007 | aMinIndex = | |
2008 | aMaxIndex = 0; | |
2009 | ||
2010 | } else { | |
2011 | ||
2012 | aMinIndex = 1; | |
2013 | aMaxIndex = TypeMap () -> Size (); | |
2014 | ||
2015 | } // end else | |
2016 | ||
2017 | } // end WNT_WDriver :: TypeBoundIndexs | |
2018 | ||
2019 | Standard_Integer WNT_WDriver :: LocalTypeIndex ( | |
2020 | const Standard_Integer anIndex | |
2021 | ) const { | |
2022 | ||
2023 | return ( anIndex < 1 || anIndex > TypeMap () -> Size () ) ? -1 : anIndex; | |
2024 | ||
2025 | } // end WNT_WDriver :: LocalTypeIndex | |
2026 | ||
2027 | void WNT_WDriver :: WidthBoundIndexs ( | |
2028 | Standard_Integer& aMinIndex, | |
2029 | Standard_Integer& aMaxIndex | |
2030 | ) const { | |
2031 | ||
2032 | if ( WidthMap ().IsNull () ) { | |
2033 | ||
2034 | aMinIndex = | |
2035 | aMaxIndex = 0; | |
2036 | ||
2037 | } else { | |
2038 | ||
2039 | aMinIndex = 1; | |
2040 | aMaxIndex = WidthMap () -> Size (); | |
2041 | ||
2042 | } // end else | |
2043 | ||
2044 | } // end WNT_WDriver :: WidthBoundIndexs | |
2045 | ||
2046 | Standard_Integer WNT_WDriver :: LocalWidthIndex ( | |
2047 | const Standard_Integer anIndex | |
2048 | ) const { | |
2049 | ||
2050 | return ( anIndex < 1 || anIndex > WidthMap () -> Size () ) ? -1 : anIndex; | |
2051 | ||
2052 | } // end WNT_WDriver :: LocalWidthIndex | |
2053 | ||
2054 | void WNT_WDriver :: MarkBoundIndexs ( | |
2055 | Standard_Integer& aMinIndex, | |
2056 | Standard_Integer& aMaxIndex | |
2057 | ) const { | |
2058 | ||
2059 | if ( MarkMap ().IsNull () ) { | |
2060 | ||
2061 | aMinIndex = | |
2062 | aMaxIndex = 0; | |
2063 | ||
2064 | } else { | |
2065 | ||
2066 | aMinIndex = 1; | |
2067 | aMaxIndex = MarkMap () -> Size (); | |
2068 | ||
2069 | } // end else | |
2070 | ||
2071 | } // end WNT_WDriver :: MarkBoundIndexs | |
2072 | ||
2073 | Standard_Integer WNT_WDriver :: LocalMarkIndex ( | |
2074 | const Standard_Integer anIndex | |
2075 | ) const { | |
2076 | ||
2077 | return ( anIndex < 1 || anIndex > MarkMap () -> Size () ) ? -1 : anIndex; | |
2078 | ||
2079 | } // end WNT_WDriver :: LocalMarkIndex | |
2080 | ||
2081 | const Handle(WNT_TextManager)& WNT_WDriver :: TextManager () | |
2082 | { | |
2083 | return (myTextManager); | |
2084 | } // end WNT_WDriver :: TextManager | |
2085 | ||
2086 | const Handle(MFT_FontManager)& WNT_WDriver :: MFT_Font | |
2087 | (const Standard_Integer anIndex) | |
2088 | { | |
2089 | return myMFTFonts->Value(anIndex); | |
2090 | } // end WNT_WDriver :: MFT_FontList | |
2091 | ||
2092 | Standard_ShortReal WNT_WDriver :: MFT_Size | |
2093 | (const Standard_Integer anIndex) | |
2094 | { | |
2095 | return myMFTSizes->Value(anIndex); | |
2096 | } // end WNT_WDriver :: MFT_SizeList | |
2097 | ||
2098 | static PW32_Allocator __fastcall _FindAllocator ( Standard_Address p, Standard_Integer id ) { | |
2099 | ||
2100 | while ( p != NULL && ( ( PW32_Allocator )p ) -> myID != id ) | |
2101 | ||
2102 | p = ( ( PW32_Allocator )p ) -> myNext; | |
2103 | ||
2104 | return ( PW32_Allocator )p; | |
2105 | ||
2106 | } // end _FindAllocator | |
2107 | ||
2108 | static int __fastcall _GetROP2 ( Aspect_TypeOfDrawMode tdm ) { | |
2109 | ||
2110 | int retVal; | |
2111 | ||
2112 | switch ( tdm ) { | |
2113 | ||
2114 | case Aspect_TODM_ERASE: | |
2115 | case Aspect_TODM_REPLACE: | |
2116 | default: | |
2117 | ||
2118 | retVal = R2_COPYPEN; | |
2119 | ||
2120 | break; | |
2121 | ||
2122 | case Aspect_TODM_XOR: | |
2123 | case Aspect_TODM_XORLIGHT: | |
2124 | ||
2125 | retVal = R2_XORPEN; | |
2126 | ||
2127 | break; | |
2128 | ||
2129 | } // end switch | |
2130 | ||
2131 | return retVal; | |
2132 | ||
2133 | } // end _GetROP2 | |
2134 | ||
2135 | static void WINAPI _SetPoint ( int s, int m, int set, LPPOINT p, int* n, void* param ) { | |
2136 | ||
2137 | PMPARAM pmp = ( PMPARAM )param; | |
2138 | ||
2139 | *n = 0; | |
2140 | ||
2141 | for ( int i = 0; i < m; ++i, ++( *n ), ++s ) { | |
2142 | ||
2143 | p[ i ].x = LONG ( pmp -> s -> XValues ().Value ( s ) * pmp -> w / 2.0 + 0.5 ); | |
2144 | p[ i ].y = LONG ( pmp -> s -> YValues ().Value ( s ) * pmp -> h / 2.0 + 0.5 ); | |
2145 | ||
2146 | } // end for | |
2147 | ||
2148 | } // end _SetPoint | |
2149 | ||
2150 | static char* __fastcall _ConvertU2F ( const TCollection_ExtendedString& str ) { | |
2151 | ||
2152 | char* retVal; | |
2153 | Standard_Integer szBuff = ( str.Length () << 2 ); | |
2154 | ||
2155 | retVal = ( char* )HeapAlloc ( | |
2156 | GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, | |
2157 | szBuff | |
2158 | ); | |
2159 | ||
2160 | while ( !Resource_Unicode :: ConvertUnicodeToFormat ( str, retVal, szBuff ) ) { | |
2161 | ||
2162 | szBuff <<= 1; | |
2163 | retVal = ( char* )HeapReAlloc ( | |
2164 | GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, | |
2165 | retVal, szBuff | |
2166 | ); | |
2167 | ||
2168 | } // end while | |
2169 | ||
2170 | return retVal; | |
2171 | ||
2172 | } // end _ConvertU2F |