0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / WNT / WNT_WDriver.cxx
... / ...
CommitLineData
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
60typedef struct _m_param {
61
62 Aspect_MarkerStyle* s;
63 int w;
64 int h;
65
66 } MPARAM, *PMPARAM;
67
68typedef struct {
69
70 float r;
71 float g;
72 float b;
73
74 } PIXEL2D, *PPIXEL2D;
75
76extern double W32_TextFactor;
77static PW32_Allocator __fastcall _FindAllocator ( Standard_Address, Standard_Integer );
78static int __fastcall _GetROP2 ( Aspect_TypeOfDrawMode );
79static char* __fastcall _ConvertU2F ( const TCollection_ExtendedString& );
80
81static void WINAPI _SetPoint ( int, int, int, LPPOINT, int*, void* );
82
83WNT_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
112void 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
126Standard_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
138void 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
167void 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
175Aspect_TypeOfResize WNT_WDriver :: ResizeSpace () {
176
177 return myWNTWindow -> DoResize ();
178
179} // end WNT_WDriver :: ResizeSpace
180
181Standard_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
196void WNT_WDriver :: SetDrawMode ( const Aspect_TypeOfDrawMode aMode ) {
197
198 MyDrawMode = aMode;
199
200} // end WNT_WDriver :: SetDrawMode
201
202void 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
248void 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
256void 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
333void 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
349void 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
366void 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
388Standard_Boolean WNT_WDriver :: IsKnownImage (
389 const Handle( Standard_Transient )& anImage
390 )
391{
392 return myWNTWindow -> myImages -> Index ( ::HashCode (anImage, IntegerLast())
393 ) ? Standard_True : Standard_False;
394} // end WNT_WDriver :: IsKnownImage
395
396Standard_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
413void WNT_WDriver :: ClearImage ( const Handle( Standard_Transient )& anImageId ) {
414
415 Standard_Integer i = myWNTWindow -> myImages -> Index (
416 ::HashCode (anImageId, IntegerLast())
417 );
418
419 if ( i ) myWNTWindow -> myImages -> Discard ( i );
420
421} // end WNT_WDriver :: ClearImage
422
423void 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
431void 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 (
438 ::HashCode (anImageId, IntegerLast())
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
448void 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
481void 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 (
507 h = ::HashCode (anImageId, IntegerLast())
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
554void 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 (
581 h = ::HashCode (anImageId, IntegerLast())
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
626void 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
657void 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
688void 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
700void 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
738void 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
766void 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
803void 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
833void 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
850void 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
949Standard_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
977Standard_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
1006void 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
1013void 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
1020void WNT_WDriver :: BeginSegments () {
1021
1022 A -> myPrimitive = zzLine;
1023 A -> myNote = NULL;
1024
1025} // end WNT_WDriver :: BeginSegments
1026
1027void WNT_WDriver :: BeginArcs () {
1028
1029 A -> myPrimitive = zzArc;
1030 A -> myNote = NULL;
1031
1032} // end WNT_WDriver :: BeginArcs
1033
1034void WNT_WDriver :: BeginPolyArcs () {
1035
1036 A -> myPrimitive = zzPolySector;
1037 A -> myNote = NULL;
1038
1039} // end WNT_WDriver :: BeginPolyArcs
1040
1041void WNT_WDriver :: BeginMarkers () {
1042
1043 A -> myPrimitive = zzMarker;
1044 A -> myNote = NULL;
1045
1046} // end WNT_WDriver :: BeginMarkers
1047
1048void WNT_WDriver :: BeginPoints () {
1049
1050 A -> myPrimitive = zzPoint;
1051 A -> myNote = NULL;
1052
1053} // end WNT_WDriver :: BeginPoints
1054
1055void WNT_WDriver :: ClosePrimitive () {
1056
1057 A -> myPrimitive = zzNone;
1058 A -> myNote = NULL;
1059
1060} // end WNT_WDriver :: ClosePrimitive
1061
1062void 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
1081void 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
1098void 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
1115void 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
1231void 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
1248Standard_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
1262 MyDrawMode = aDrawMode;
1263 aNew = _FindAllocator ( myAllocators, aRetainBuffer );
1264
1265 if ( aNew != NULL )
1266
1267 ClearBuffer ( aRetainBuffer );
1268
1269 else aNew = ( *W32_GetAllocator ) (
1270 aRetainBuffer, ( PW32_Allocator )myAllocators
1271 );
1272
1273 aNew -> myPivot.x = P( aPivotX );
1274 aNew -> myPivot.y = P( aPivotY );
1275
1276 if ( aRetainBuffer ) {
1277
1278 Standard_Address aSave = myAllocator;
1279 myAllocator = ( Standard_Address )aNew;
1280
1281 A -> myFlags |= ( W32F_MONO | W32F_MINIT );
1282 SetLineAttrib ( aColorIndex, aTypeIndex, aWidthIndex );
1283 SetTextAttrib ( aColorIndex, aFontIndex );
1284 SetPolyAttrib ( aColorIndex, -1, Standard_True );
1285 SetMarkerAttrib ( aColorIndex, aWidthIndex, Standard_False );
1286 A -> myFlags &= ~W32F_MINIT;
1287
1288 myAllocator = aSave;
1289
1290 } else A -> myFlags &= ~W32F_MONO;
1291
1292 return aNew;
1293
1294} // end WNT_WDriver :: InternalOpenBuffer
1295
1296Standard_Boolean WNT_WDriver :: OpenBuffer (
1297 const Standard_Integer aRetainBuffer,
1298 const Standard_ShortReal aPivotX,
1299 const Standard_ShortReal aPivotY,
1300 const Standard_Integer aWidthIndex,
1301 const Standard_Integer aColorIndex,
1302 const Standard_Integer aFontIndex,
1303 const Aspect_TypeOfDrawMode aDrawMode
1304 ) {
1305 return ( Standard_Boolean )InternalOpenBuffer (
1306 aRetainBuffer, Standard_True,
1307 aPivotX, aPivotY, aColorIndex, aWidthIndex,
1308 0, aFontIndex, aDrawMode
1309 );
1310
1311} // end WNT_WDriver :: OpenBuffer
1312
1313Standard_Boolean WNT_WDriver :: OpenColorBuffer (
1314 const Standard_Integer aRetainBuffer,
1315 const Standard_ShortReal aPivotX,
1316 const Standard_ShortReal aPivotY,
1317 const Standard_Integer aWidthIndex,
1318 const Standard_Integer aColorIndex,
1319 const Standard_Integer aFontIndex,
1320 const Aspect_TypeOfDrawMode aDrawMode
1321 ) {
1322
1323 return ( Standard_Boolean )InternalOpenBuffer (
1324 aRetainBuffer, Standard_False,
1325 aPivotX, aPivotY, aColorIndex, aWidthIndex,
1326 0, aFontIndex, aDrawMode
1327 );
1328
1329} // end WNT_WDriver :: OpenColorBuffer
1330
1331void WNT_WDriver :: CloseBuffer ( const Standard_Integer aRetainBuffer ) const {
1332
1333 if ( aRetainBuffer ) {
1334
1335 PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer );
1336
1337 if ( a != NULL ) {
1338
1339 PW32_Allocator b = ( PW32_Allocator )myAllocators;
1340
1341 while ( b -> myNext != a ) b = b -> myNext;
1342
1343 if ( a -> myFlags & W32F_DRAWN ) EraseBuffer ( aRetainBuffer );
1344
1345 b -> myNext = a -> myNext;
1346
1347 delete a;
1348
1349 } // end if
1350
1351 SelectBuffer ( 0 );
1352
1353 } // end if
1354
1355} // end WNT_WDriver :: CloseBuffer
1356
1357void WNT_WDriver :: ClearBuffer ( const Standard_Integer aRetainBuffer ) const {
1358
1359 PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer );
1360
1361 if ( a != NULL ) {
1362
1363 if ( a -> myFlags & W32F_DRAWN ) EraseBuffer ( aRetainBuffer );
1364
1365 a -> ClearBlocks ();
1366
1367 } // end if
1368
1369} // end WNT_WDriver :: ClearBuffer
1370
1371void WNT_WDriver :: DrawBuffer ( const Standard_Integer aRetainBuffer ) const {
1372
1373 PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer );
1374
1375 if ( a != NULL ) {
1376
1377 RECT r;
1378 SIZE sz;
1379 HPALETTE hpo = NULL;
1380 HDC hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () );
1381
1382 Handle( WNT_GraphicDevice ) gDev = Handle ( WNT_GraphicDevice ) ::
1383 DownCast ( MyWindow -> GraphicDevice () );
1384
1385 if ( gDev -> IsPaletteDevice () )
1386
1387 hpo = SelectPalette ( hdc, ( HPALETTE )gDev -> HPalette (), FALSE );
1388
1389 GetClientRect ( ( HWND )myWNTWindow -> HWindow (), &r );
1390 sz.cx = r.right;
1391 sz.cy = r.bottom;
1392
1393 if ( a -> myFlags & W32F_DBUFF ) {
1394 HDC hdcMem = CreateCompatibleDC ( hdc );
1395 HBITMAP hbo = SelectBitmap( hdcMem, ( HBITMAP )myWNTWindow -> HPixmap () );
1396 HPALETTE hpo;
1397
1398 if ( gDev -> IsPaletteDevice () )
1399
1400 hpo = SelectPalette ( hdcMem, ( HPALETTE )gDev -> HPalette (), FALSE );
1401
1402 SetROP2 ( hdcMem, _GetROP2 ( MyDrawMode ) );
1403
1404 a -> Play ( hdcMem, &sz );
1405
1406 BitBlt (
1407 hdc, r.left, r.top, r.right + 1, r.bottom + 1,
1408 hdcMem, r.left, r.top, SRCCOPY
1409 );
1410
1411 if ( gDev -> IsPaletteDevice () ) SelectPalette ( hdcMem, hpo, FALSE );
1412
1413 SelectBitmap( hdcMem, hbo );
1414 DeleteDC ( hdcMem );
1415 } else {
1416 SetROP2 ( hdc, _GetROP2 ( MyDrawMode ) );
1417 a -> Play ( hdc, &sz );
1418 } // end else
1419
1420 if ( hpo != NULL ) SelectPalette( hdc, hpo, FALSE );
1421
1422 ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc );
1423
1424 a -> myFlags |= W32F_DRAWN;
1425
1426 } // end if
1427
1428} // end WNT_WDriver :: DrawBuffer
1429
1430void WNT_WDriver :: EraseBuffer ( const Standard_Integer aRetainBuffer ) const {
1431
1432 PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer );
1433
1434 if ( a != NULL && ( a -> myFlags & W32F_DRAWN ) ) {
1435
1436 RECT r;
1437
1438 a -> URect ( &r );
1439
1440 if ( !IsRectEmpty ( &r ) ) {
1441
1442 if ( a -> myID != 0 ) {
1443
1444 if ( MyWindow -> BackingStore () )
1445
1446 MyWindow -> RestoreArea (
1447 ( r.left + r.right ) / 2, ( r.top + r.bottom ) / 2,
1448 r.right - r.left + 2, r.bottom - r.top + 2
1449 );
1450
1451 else if ( ( ( PW32_Allocator )myAllocators ) -> myFlags & W32F_DRAWN )
1452
1453 DrawBuffer ( 0 );
1454
1455 else
1456clear:
1457 MyWindow -> ClearArea (
1458 ( r.left + r.right ) / 2, ( r.top + r.bottom ) / 2,
1459 r.right - r.left + 2, r.bottom - r.top + 2
1460 );
1461
1462 } else goto clear;
1463
1464 } // end if
1465
1466 a -> myFlags &= ~W32F_DRAWN;
1467
1468 } // end if
1469
1470} // end WNT_WDriver :: EraseBuffer
1471
1472void WNT_WDriver :: MoveBuffer (
1473 const Standard_Integer aRetainBuffer,
1474 const Standard_ShortReal aPivotX,
1475 const Standard_ShortReal aPivotY
1476 ) const {
1477
1478 PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer );
1479
1480 if ( a != NULL ) {
1481
1482 BOOL fDrawn = a -> myFlags & W32F_DRAWN;
1483
1484 if ( fDrawn ) EraseBuffer ( aRetainBuffer );
1485
1486 a -> myMove.x = P( aPivotX ) - a -> myPivot.x;
1487 a -> myMove.y = P( aPivotY ) - a -> myPivot.y;
1488
1489 if ( fDrawn ) DrawBuffer ( aRetainBuffer );
1490
1491 } // end if
1492
1493} // end WNT_WDriver :: MoveBuffer
1494
1495void WNT_WDriver :: ScaleBuffer (
1496 const Standard_Integer aRetainBuffer,
1497 const Quantity_Factor aScaleX,
1498 const Quantity_Factor aScaleY
1499 ) const {
1500
1501 PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer );
1502
1503 if ( a != NULL ) {
1504
1505 BOOL fDrawn = a -> myFlags & W32F_DRAWN;
1506
1507 if ( fDrawn ) EraseBuffer ( aRetainBuffer );
1508
1509 a -> myScaleX = aScaleX;
1510 a -> myScaleY = aScaleY;
1511
1512 if ( fDrawn ) DrawBuffer ( aRetainBuffer );
1513
1514 } // end if
1515
1516} // end WNT_WDriver :: ScaleBuffer
1517
1518void WNT_WDriver :: RotateBuffer (
1519 const Standard_Integer aRetainBuffer,
1520 const Quantity_PlaneAngle anAngle
1521 ) const {
1522
1523 PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer );
1524
1525 if ( a != NULL ) {
1526
1527 BOOL fDrawn = a -> myFlags & W32F_DRAWN;
1528
1529 if ( fDrawn ) EraseBuffer ( aRetainBuffer );
1530
1531 a -> myAngle = anAngle;
1532
1533 if ( fDrawn ) DrawBuffer ( aRetainBuffer );
1534
1535 } // end if
1536
1537} // end WNT_WDriver :: RotateBuffer
1538
1539void WNT_WDriver :: WorkSpace ( Quantity_Length& Width, Quantity_Length& Heigth ) const {
1540
1541 RECT r;
1542
1543 GetClientRect ( ( HWND )( myWNTWindow -> HWindow () ), &r );
1544
1545 Width = U( r.right );
1546 Heigth = U( r.bottom );
1547
1548} // end WNT_WDriver :: WorkSpace
1549
1550Quantity_Length WNT_WDriver :: Convert ( const Standard_Integer PV ) const {
1551
1552 return U( PV );
1553
1554} // end WNT_WDriver :: Convert
1555
1556Standard_Integer WNT_WDriver :: Convert ( const Quantity_Length DV ) const {
1557
1558 return P( DV );
1559
1560} // end WNT_WDriver :: Convert
1561
1562void WNT_WDriver :: Convert (
1563 const Standard_Integer PX,
1564 const Standard_Integer PY,
1565 Quantity_Length& DX,
1566 Quantity_Length& DY
1567 ) const {
1568
1569 RECT r;
1570 GetClientRect ( ( HWND )myWNTWindow -> HWindow (), &r );
1571
1572 DX = U( PX );
1573 DY = U( r.bottom - PY );
1574
1575} // end WNT_WDriver :: Convert
1576
1577void WNT_WDriver :: Convert (
1578 const Quantity_Length DX,
1579 const Quantity_Length DY,
1580 Standard_Integer& PX,
1581 Standard_Integer& PY
1582 ) const {
1583
1584 RECT r;
1585 GetClientRect ( ( HWND )myWNTWindow -> HWindow (), &r );
1586
1587 PX = P( DX );
1588 PY = r.bottom - P( DY );
1589
1590} // end WNT_WDriver :: Convert
1591
1592Standard_Integer WNT_WDriver :: ProcessColorIndex (
1593 const Standard_Integer ColorIndex
1594 ) const {
1595
1596 if ( !SA ) return A -> myPointColor;
1597
1598 if ( myColors.IsNull () ) return ( Standard_Integer )RGB( 0, 0, 0 );
1599
1600 Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) ::
1601 DownCast ( MyWindow -> GraphicDevice () );
1602
1603 if ( ColorIndex <= 0 ) {
1604
1605 if ((A -> myFlags & W32F_MONO) && (A -> myFlags & W32F_MINIT)) {
1606 return RGB(255, 255, 255);
1607 } else {
1608 LOGBRUSH lb;
1609 GetObject ( myWNTWindow -> HBackground(), sizeof ( LOGBRUSH ), &lb );
1610 return lb.lbColor;
1611 }
1612
1613 } else
1614
1615 switch ( MyDrawMode ) {
1616
1617 default :
1618 case Aspect_TODM_REPLACE :
1619
1620 if (ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper())
1621 return myColors -> Value ( myColors->Lower() );
1622 return myColors -> Value ( ColorIndex );
1623
1624 case Aspect_TODM_ERASE :
1625
1626 return gDev -> SetColor ( MyWindow -> Background ().Color () );
1627
1628 case Aspect_TODM_XORLIGHT :
1629 case Aspect_TODM_XOR :
1630
1631 return gDev -> HighlightColor ();
1632
1633 } // end switch
1634
1635} // end WNT_WDriver :: ProcessColorIndex
1636
1637Quantity_Length WNT_WDriver :: ProcessWidthIndex (
1638 const Standard_Integer WidthIndex
1639 ) const
1640{
1641 Standard_Integer theIndex = WidthIndex;
1642 if (WidthIndex < myWidthIdxs->Lower() || WidthIndex > myWidthIdxs->Upper())
1643 theIndex = myWidthIdxs->Lower();
1644
1645 Aspect_WidthMapEntry Entry = WidthMap () -> Entry ( myWidthIdxs -> Value(theIndex) );
1646 return ( Entry.Type () == Aspect_WOL_THIN ) ?
1647 ( Quantity_Length )0.0 : Entry.Width () / myPixelToUnit;
1648} // end WNT_WDriver :: ProcessWidthIndex
1649
1650Standard_Integer WNT_WDriver :: ProcessTypeIndex (
1651 const Standard_Integer TypeIndex
1652 ) const{
1653
1654 return ( TypeMap () -> Entry ( TypeIndex + 1 ).Type ().Style () == Aspect_TOL_SOLID ) ?
1655 0 : PS_USERSTYLE;
1656
1657} // end WNT_WDriver :: ProcessTypeIndex
1658
1659Standard_Boolean WNT_WDriver :: BufferIsOpen (
1660 const Standard_Integer aRetainBuffer
1661 ) const {
1662
1663 return ( _FindAllocator ( myAllocators, aRetainBuffer) != NULL ?
1664 Standard_True : Standard_False
1665 );
1666
1667} // end WNT_WDriver :: BufferIsOpen
1668
1669Standard_Boolean WNT_WDriver :: BufferIsEmpty (
1670 const Standard_Integer aRetainBuffer
1671 ) const {
1672
1673 PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer );
1674
1675 if ( a != NULL )
1676
1677 return ( a -> myFlags & W32F_EMPTY ) ? Standard_True : Standard_False;
1678
1679 return Standard_True;
1680
1681} // end WNT_WDriver :: BufferIsEmpty
1682
1683Standard_Boolean WNT_WDriver :: BufferIsDrawn (
1684 const Standard_Integer aRetainBuffer
1685 ) const {
1686
1687 PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer );
1688
1689 if ( a != NULL )
1690
1691 return ( a -> myFlags & W32F_DRAWN ) ? Standard_True : Standard_False;
1692
1693 return Standard_False;
1694
1695} // end WNT_WDriver :: BufferIsDrawn
1696
1697void WNT_WDriver :: AngleOfBuffer (
1698 const Standard_Integer aRetainBuffer,
1699 Quantity_PlaneAngle& anAngle
1700 ) const {
1701
1702 PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer );
1703
1704 if ( a != NULL ) anAngle = a -> myAngle;
1705
1706} // end WNT_WDriver :: AngleOfBuffer
1707
1708void WNT_WDriver :: ScaleOfBuffer (
1709 const Standard_Integer aRetainBuffer,
1710 Quantity_Factor& aScaleX,
1711 Quantity_Factor& aScaleY
1712 ) const {
1713
1714 PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer );
1715
1716 if ( a != NULL ) {
1717
1718 aScaleX = a -> myScaleX;
1719 aScaleY = a -> myScaleY;
1720
1721 } // end if
1722
1723} // end WNT_WDriver :: ScaleOfBuffer
1724
1725void WNT_WDriver :: PositionOfBuffer (
1726 const Standard_Integer aRetainBuffer,
1727 Standard_ShortReal& aPivotX,
1728 Standard_ShortReal& aPivotY
1729 ) const {
1730
1731 PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer );
1732
1733 if ( a != NULL ) {
1734
1735 aPivotX = Standard_ShortReal ( U( a -> myPivot.x + a -> myMove.x ) );
1736 aPivotY = Standard_ShortReal ( U( a -> myPivot.y + a -> myMove.y ) );
1737
1738 } // end if
1739
1740} // end WNT_WDriver :: PositionOfBuffer
1741
1742void WNT_WDriver :: TextSize (
1743 const TCollection_ExtendedString& aText,
1744 Standard_ShortReal& aWidth,
1745 Standard_ShortReal& aHeight,
1746 const Standard_Integer aFontIndex
1747 ) const {
1748#ifdef PRO17381
1749if( aText.Length() <= 0 ) {
1750 aWidth = aHeight = 0.;
1751 return;
1752}
1753#endif
1754
1755 Standard_ShortReal xoffset, yoffset;
1756/*====================== MFT ====================*/
1757#ifdef MFT
1758 if ( UseMFT() )
1759 TextSize (aText, aWidth, aHeight, xoffset, yoffset, aFontIndex);
1760 else {
1761#endif
1762/*====================== MFT ====================*/
1763
1764 char* str = _ConvertU2F ( aText );
1765
1766 TextSize ( str, aWidth, aHeight, xoffset, yoffset, aFontIndex );
1767
1768 HeapFree ( GetProcessHeap (), 0, str );
1769
1770/*====================== MFT ====================*/
1771#ifdef MFT
1772 }
1773#endif
1774/*====================== MFT ====================*/
1775} // end WNT_WDriver :: TextSize
1776
1777void WNT_WDriver :: TextSize (
1778 const TCollection_ExtendedString& aText,
1779 Standard_ShortReal& aWidth,
1780 Standard_ShortReal& aHeight,
1781 Standard_ShortReal& anXoffset,
1782 Standard_ShortReal& anYoffset,
1783 const Standard_Integer aFontIndex
1784 ) const {
1785#ifdef PRO17381
1786if( aText.Length() <= 0 ) {
1787 aWidth = aHeight = anXoffset = anYoffset = 0.;
1788 return;
1789}
1790#endif
1791
1792/*====================== MFT ====================*/
1793#ifdef MFT
1794 if ( UseMFT() ) {
1795 Standard_Integer aFont = (aFontIndex < 0 ?
1796 (int)A->myTextFont : aFontIndex);
1797 Handle(MFT_FontManager) theFontManager =
1798 ((WNT_WDriver *const)(this))->MFT_Font(aFont);
1799 Standard_Real theWidth = 0.,theAscent = 0.,
1800 theLbearing = 0.,theDescent = 0.;
1801 if (aText.IsAscii()) {
1802 TCollection_AsciiString ascii (aText,'?');
1803 theFontManager->TextSize(ascii.ToCString(), theWidth,
1804 theAscent, theLbearing, theDescent);
1805 } else if (theFontManager->IsComposite()) {
1806 theFontManager->TextSize(aText.ToExtString(), theWidth,
1807 theAscent, theLbearing, theDescent);
1808 }
1809 theDescent = Max(
1810 theDescent, (A->myFlags & W32F_TULIN ?
1811 theFontManager->UnderlinePosition() : 0.));
1812 aWidth = Standard_ShortReal (theWidth );
1813 aHeight = Standard_ShortReal (theAscent + theDescent);
1814 anXoffset = Standard_ShortReal (theLbearing );
1815 anYoffset = Standard_ShortReal (theDescent );
1816 } else {
1817#endif
1818 char* str = ( char* )_ConvertU2F ( aText );
1819
1820 HDC hdc;
1821 HFONT hfo;
1822 SIZE sz;
1823 int xo;
1824
1825 hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () );
1826 hfo = SelectFont(
1827 hdc,
1828 aFontIndex < 0 ? A -> myTextFont : ( HFONT )myFonts -> Value ( aFontIndex ) -> HFont ()
1829 );
1830
1831 xo = A -> TextSize ( hdc, str, &sz );
1832 aWidth = Standard_ShortReal ( U( sz.cx ) );
1833 aHeight = Standard_ShortReal ( U( sz.cy ) );
1834
1835 anXoffset = Standard_ShortReal ( U( xo ) );
1836 anYoffset = Standard_ShortReal ( 0.0 );
1837
1838 SelectFont( hdc, hfo );
1839 ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc );
1840
1841 HeapFree ( GetProcessHeap (), 0, str );
1842
1843/*====================== MFT ====================*/
1844#ifdef MFT
1845 }
1846#endif
1847/*====================== MFT ====================*/
1848} // end WNT_WDriver :: TextSize
1849
1850void WNT_WDriver :: TextSize (
1851 const Standard_CString aText,
1852 Standard_ShortReal& aWidth,
1853 Standard_ShortReal& aHeight,
1854 Standard_ShortReal& anXoffset,
1855 Standard_ShortReal& anYoffset,
1856 const Standard_Integer aFontIndex
1857 ) const {
1858#ifdef PRO17381
1859if( !aText || (strlen(aText) <= 0) ) {
1860 aWidth = aHeight = anXoffset = anYoffset = 0.;
1861 return;
1862}
1863#endif
1864
1865/*====================== MFT ====================*/
1866#ifdef MFT
1867 if ( UseMFT() ) {
1868 TCollection_ExtendedString extText (aText);
1869 TextSize (extText, aWidth, aHeight, anXoffset, anYoffset, aFontIndex);
1870 } else {
1871#endif
1872/*====================== MFT ====================*/
1873 HDC hdc;
1874 HFONT hfo;
1875 SIZE sz;
1876 int xo;
1877
1878 hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () );
1879 hfo = SelectFont(
1880 hdc,
1881 aFontIndex < 0 ? A -> myTextFont : ( HFONT )myFonts -> Value ( aFontIndex ) -> HFont ()
1882 );
1883
1884 xo = A -> TextSize ( hdc, (Standard_PCharacter)aText, &sz );
1885 aWidth = Standard_ShortReal ( U( sz.cx ) );
1886 aHeight = Standard_ShortReal ( U( sz.cy ) );
1887
1888 anXoffset = Standard_ShortReal ( U( xo ) );
1889 anYoffset = Standard_ShortReal ( 0.0 );
1890
1891 SelectFont( hdc, hfo );
1892 ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc );
1893/*====================== MFT ====================*/
1894#ifdef MFT
1895 }
1896#endif
1897/*====================== MFT ====================*/
1898} // end WNT_WDriver :: TextSize
1899
1900Standard_CString WNT_WDriver :: FontSize (
1901 Quantity_PlaneAngle& aSlant,
1902 Standard_ShortReal& aSize,
1903 Standard_ShortReal& aBheight,
1904 const Standard_Integer aFontIndex
1905 ) const {
1906
1907/*====================== MFT ====================*/
1908#ifdef MFT
1909 if ( UseMFT() ) {
1910 Standard_CString fstring;
1911 Standard_Integer aFont = (aFontIndex < 0 ?
1912 (int)A->myTextFont : aFontIndex);
1913 Handle(MFT_FontManager) theFontManager =
1914 myMFTFonts->Value (aFont);
1915 Quantity_Length theWidth, theHeight, theDescent;
1916 Quantity_PlaneAngle theSlant;
1917 Quantity_Factor thePrecision;
1918 Standard_Boolean theCapsHeight;
1919 fstring = theFontManager->FontAttribs (
1920 theWidth, theHeight, theDescent, theSlant, thePrecision, theCapsHeight
1921 );
1922 aSize = (Standard_ShortReal)theHeight;
1923 aBheight = (Standard_ShortReal)theDescent;
1924 aSlant = theSlant;
1925 return fstring;
1926 } else {
1927#endif
1928/*====================== MFT ====================*/
1929 if (aFontIndex < 0)
1930 aSize = Standard_ShortReal ( U(myFonts->Value(0)->myLogFont.lfHeight) );
1931 else
1932 aSize = Standard_ShortReal ( U(myFonts->Value(aFontIndex)->myLogFont.lfHeight) );
1933 aSize = Standard_ShortReal ( aSize / W32_TextFactor );
1934 aSlant = aFontIndex < 0 ? A -> myTextSlant : 0.0;
1935 aBheight = 0.0F;
1936
1937 return aFontIndex < 0 ? "" : myFonts->Value(aFontIndex)->myLogFont.lfFaceName;
1938/*====================== MFT ====================*/
1939#ifdef MFT
1940 }
1941#endif
1942/*====================== MFT ====================*/
1943} // end WNT_WDriver :: FontSize
1944
1945void WNT_WDriver :: ColorBoundIndexs (
1946 Standard_Integer& aMinIndex,
1947 Standard_Integer& aMaxIndex
1948 ) const {
1949
1950 if ( myColors.IsNull () ) {
1951
1952 aMinIndex =
1953 aMaxIndex = 0;
1954
1955 } else {
1956
1957 aMinIndex = 1;
1958 aMaxIndex = myColors -> Length ();
1959
1960 } // end else
1961
1962} // end WNT_WDriver :: ColorBoundIndexs
1963
1964Standard_Integer WNT_WDriver :: LocalColorIndex (
1965 const Standard_Integer anIndex
1966 ) const {
1967
1968 return ( anIndex < 1 || anIndex > myColors -> Length () ) ? -1 : anIndex;
1969
1970} // end WNT_WDriver :: LocalColorIndex
1971
1972void WNT_WDriver :: FontBoundIndexs (
1973 Standard_Integer& aMinIndex,
1974 Standard_Integer& aMaxIndex
1975 ) const {
1976
1977 if ( myFonts.IsNull () ) {
1978
1979 aMinIndex =
1980 aMaxIndex = 0;
1981
1982 } else {
1983
1984 aMinIndex = 1;
1985 aMaxIndex = myFonts -> Length ();
1986
1987 } // end else
1988
1989} // end WNT_WDriver :: FontBoundIndexs
1990
1991Standard_Integer WNT_WDriver :: LocalFontIndex (
1992 const Standard_Integer anIndex
1993 ) const {
1994
1995 return ( anIndex < 1 || anIndex > myFonts -> Length () ) ? -1 : anIndex;
1996
1997} // end WNT_WDriver :: LocalFontIndex
1998
1999void WNT_WDriver :: TypeBoundIndexs (
2000 Standard_Integer& aMinIndex,
2001 Standard_Integer& aMaxIndex
2002 ) const {
2003
2004 if ( TypeMap ().IsNull () ) {
2005
2006 aMinIndex =
2007 aMaxIndex = 0;
2008
2009 } else {
2010
2011 aMinIndex = 1;
2012 aMaxIndex = TypeMap () -> Size ();
2013
2014 } // end else
2015
2016} // end WNT_WDriver :: TypeBoundIndexs
2017
2018Standard_Integer WNT_WDriver :: LocalTypeIndex (
2019 const Standard_Integer anIndex
2020 ) const {
2021
2022 return ( anIndex < 1 || anIndex > TypeMap () -> Size () ) ? -1 : anIndex;
2023
2024} // end WNT_WDriver :: LocalTypeIndex
2025
2026void WNT_WDriver :: WidthBoundIndexs (
2027 Standard_Integer& aMinIndex,
2028 Standard_Integer& aMaxIndex
2029 ) const {
2030
2031 if ( WidthMap ().IsNull () ) {
2032
2033 aMinIndex =
2034 aMaxIndex = 0;
2035
2036 } else {
2037
2038 aMinIndex = 1;
2039 aMaxIndex = WidthMap () -> Size ();
2040
2041 } // end else
2042
2043} // end WNT_WDriver :: WidthBoundIndexs
2044
2045Standard_Integer WNT_WDriver :: LocalWidthIndex (
2046 const Standard_Integer anIndex
2047 ) const {
2048
2049 return ( anIndex < 1 || anIndex > WidthMap () -> Size () ) ? -1 : anIndex;
2050
2051} // end WNT_WDriver :: LocalWidthIndex
2052
2053void WNT_WDriver :: MarkBoundIndexs (
2054 Standard_Integer& aMinIndex,
2055 Standard_Integer& aMaxIndex
2056 ) const {
2057
2058 if ( MarkMap ().IsNull () ) {
2059
2060 aMinIndex =
2061 aMaxIndex = 0;
2062
2063 } else {
2064
2065 aMinIndex = 1;
2066 aMaxIndex = MarkMap () -> Size ();
2067
2068 } // end else
2069
2070} // end WNT_WDriver :: MarkBoundIndexs
2071
2072Standard_Integer WNT_WDriver :: LocalMarkIndex (
2073 const Standard_Integer anIndex
2074 ) const {
2075
2076 return ( anIndex < 1 || anIndex > MarkMap () -> Size () ) ? -1 : anIndex;
2077
2078} // end WNT_WDriver :: LocalMarkIndex
2079
2080const Handle(WNT_TextManager)& WNT_WDriver :: TextManager ()
2081{
2082 return (myTextManager);
2083} // end WNT_WDriver :: TextManager
2084
2085const Handle(MFT_FontManager)& WNT_WDriver :: MFT_Font
2086 (const Standard_Integer anIndex)
2087{
2088 return myMFTFonts->Value(anIndex);
2089} // end WNT_WDriver :: MFT_FontList
2090
2091Standard_ShortReal WNT_WDriver :: MFT_Size
2092 (const Standard_Integer anIndex)
2093{
2094 return myMFTSizes->Value(anIndex);
2095} // end WNT_WDriver :: MFT_SizeList
2096
2097static PW32_Allocator __fastcall _FindAllocator ( Standard_Address p, Standard_Integer id ) {
2098
2099 while ( p != NULL && ( ( PW32_Allocator )p ) -> myID != id )
2100
2101 p = ( ( PW32_Allocator )p ) -> myNext;
2102
2103 return ( PW32_Allocator )p;
2104
2105} // end _FindAllocator
2106
2107static int __fastcall _GetROP2 ( Aspect_TypeOfDrawMode tdm ) {
2108
2109 int retVal;
2110
2111 switch ( tdm ) {
2112
2113 case Aspect_TODM_ERASE:
2114 case Aspect_TODM_REPLACE:
2115 default:
2116
2117 retVal = R2_COPYPEN;
2118
2119 break;
2120
2121 case Aspect_TODM_XOR:
2122 case Aspect_TODM_XORLIGHT:
2123
2124 retVal = R2_XORPEN;
2125
2126 break;
2127
2128 } // end switch
2129
2130 return retVal;
2131
2132} // end _GetROP2
2133
2134static void WINAPI _SetPoint ( int s, int m, int set, LPPOINT p, int* n, void* param ) {
2135
2136 PMPARAM pmp = ( PMPARAM )param;
2137
2138 *n = 0;
2139
2140 for ( int i = 0; i < m; ++i, ++( *n ), ++s ) {
2141
2142 p[ i ].x = LONG ( pmp -> s -> XValues ().Value ( s ) * pmp -> w / 2.0 + 0.5 );
2143 p[ i ].y = LONG ( pmp -> s -> YValues ().Value ( s ) * pmp -> h / 2.0 + 0.5 );
2144
2145 } // end for
2146
2147} // end _SetPoint
2148
2149static char* __fastcall _ConvertU2F ( const TCollection_ExtendedString& str ) {
2150
2151 char* retVal;
2152 Standard_Integer szBuff = ( str.Length () << 2 );
2153
2154 retVal = ( char* )HeapAlloc (
2155 GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS,
2156 szBuff
2157 );
2158
2159 while ( !Resource_Unicode :: ConvertUnicodeToFormat ( str, retVal, szBuff ) ) {
2160
2161 szBuff <<= 1;
2162 retVal = ( char* )HeapReAlloc (
2163 GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS,
2164 retVal, szBuff
2165 );
2166
2167 } // end while
2168
2169 return retVal;
2170
2171} // end _ConvertU2F