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