0023863: Wrong distance value between circle and cylinder
[occt.git] / src / WNT / W32_Allocator.hxx
CommitLineData
b311480e 1// Created by: PLOTNIKOV Eugeny & CHABROVSKY Dmitry
2// Copyright (c) 1998-1999 Matra Datavision
3// Copyright (c) 1999-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20
21#ifndef __W32_ALLOCATOR_HXX
22# define __W32_ALLOCATOR_HXX
23
24# ifndef _WINDOWS_
25# ifndef STRICT
26# define STRICT
27# endif /* STRICT */
28# ifndef WIN32_LEAN_AND_MEAN
29# define WIN32_LEAN_AND_MEAN
30# ifdef NOGDI
31# undef NOGDI /* we need GDI definitions here... */
32# endif
33# include <windows.h>
34# endif /* WIN32_LEAN_AND_MEAN */
35# endif /* _WINDOWS */
36
37# define __W32_DATA -1
38
39# define EPS 0.005F
40
41# define W32F_TOUTLINE 0x00000001 // text flags
42# define W32F_TUNICODE 0x00000002
43# define W32F_TINDEX 0x00000004
44# define W32F_TFREE 0x00000008
45# define W32F_TFULINED 0x00000010
46
47# define W32F_EMPTY 0x00000001
48# define W32F_DRAWN 0x00000002
49# define W32F_XFORM 0x00000004
50# define W32F_MONO 0x00000008
51# define W32F_DBUFF 0x00000010
52# define W32F_START 0x00000020
53# define W32F_WIN95 0x00000040
54# define W32F_DVDRV 0x00000080
55# define W32F_TULIN 0x00000100
56# define W32F_MINIT 0x00000200
57# define W32F_NOFIL 0x00000400
58# define W32F_MFILL 0x80000000
59# define W32F_MOUTL 0x40000000
60# define W32F_POUTL 0x20000000
61# define W32F_DFONT 0x10000000
62
63#define OCC5415 /* avoid warning C4291 in MS VC++ 6.0 */
64
65typedef enum {
66
67 zzNone, zzPoint, zzLine, zzPolyRect, zzRect, zzPolyEllipse,
68 zzRoundRect, zzPolyRoundRect, zzArc, zzChord, zzPolyChord, zzSector,
69 zzPolySector, zzPolygon, zzPolyline, zzLinkedPolyline, zzBezier, zzText,
70 zzPolyText, zzMarker
71
72} W32_Primitive;
73
74struct W32_Allocator;
75typedef W32_Allocator* PW32_Allocator;
76
77typedef struct _W32_Block { // memory block
78
79 _W32_Block* next;
80 int size;
81 int free;
82 int data[ 1 ];
83
84} W32_Block, *PW32_Block;
85
86typedef struct _W32_bitmap {
87
88 int nUsed;
89 HBITMAP hBmp;
90
91 } W32_Bitmap, *PW32_Bitmap;
92
93typedef struct _W32_FCallParam {
94
95 void* pAllocator;
96 void* pDriver;
97
98 } W32_FCALLPARAM, *PW32_FCALLPARAM;
99
100typedef void ( WINAPI *GetPointFunc ) ( int, int, int, LPPOINT, int*, void* );
101
102typedef void ( __cdecl *W32_FCall ) ( PW32_FCALLPARAM );
103
104struct W32_Note { // base class to represent graphic object
105
106 W32_Note () {}
107 virtual ~W32_Note () {}
108
109 void* operator new ( size_t, W32_Allocator* );
110
111 virtual void Play ( BOOL = TRUE ) = 0;
112 virtual void Xform ( void ) {}
113 virtual void Release ( void ) {}
114
115 PW32_Allocator myAllocator;
116
117#ifdef OCC5415
118 void operator delete (void*, W32_Allocator*) {}
119private: // to protect against possible accidental usage
35e08fe8 120 void operator delete (void*) {}
7fd59977 121#endif
122};
123///
124///////////////////////// POINTS ////////////////////////////
125///
126struct W32_PointNote : public W32_Note {
127
128 W32_PointNote ( int, int );
129
130 virtual void Play ( BOOL = TRUE );
131
132 int myX, myY;
133
134};
135
136struct WNT_PointNote : public W32_PointNote {
137
138 WNT_PointNote ( int, int );
139
140 virtual void Play ( BOOL = TRUE );
141 virtual void Xform ( void );
142
143 int myTX, myTY;
144
145};
146
147struct W32_MarkerPointNote : public W32_PointNote {
148
149 W32_MarkerPointNote ( int, int );
150
151 virtual void Play ( BOOL = TRUE );
152
153};
154
155struct WNT_MarkerPointNote : public WNT_PointNote {
156
157 WNT_MarkerPointNote ( int, int );
158
159 virtual void Play ( BOOL = TRUE );
160
161};
162///
163///////////////////////// LINES //////////////////////////////
164///
165struct W32_LineNote : public W32_PointNote {
166
167 W32_LineNote ( int, int, int, int );
168
169 virtual void Play ( BOOL = TRUE );
170
171 int myX2, myY2;
172
173};
174
175struct WNT_LineNote : public WNT_PointNote {
176
177 WNT_LineNote ( int, int, int, int );
178
179 virtual void Play ( BOOL = TRUE );
180 virtual void Xform ( void );
181
182 int myX2, myY2, myTX2, myTY2;
183
184};
185///
186////////////////////// POLY ELLIPSES /////////////////////////
187///
188struct W32_PolyEllipseNote : public W32_PointNote {
189
190 W32_PolyEllipseNote ( int, int, int, int );
191
192 virtual void Play ( BOOL = TRUE );
193
194 int myXr, myYr;
195
196};
197
198struct WNT_PolyEllipseNote : public WNT_PointNote {
199
200 WNT_PolyEllipseNote ( int, int, int, int );
201
202 virtual void Play ( BOOL = TRUE );
203 virtual void Xform ( void );
204
205 int myXr, myYr, myTXr, myTYr;
206
207};
208///
209///////////////////////// ELLIPSES ///////////////////////////
210///
211struct W32_EllipseNote : public W32_PolyEllipseNote {
212
213 W32_EllipseNote ( int, int, int, int );
214
215 virtual void Play ( BOOL = TRUE );
216
217};
218
219struct WNT_EllipseNote : public WNT_PolyEllipseNote {
220
221 WNT_EllipseNote ( int, int, int, int );
222
223 virtual void Play ( BOOL = TRUE );
224
225};
226///
227/////////////////////////// ARCS /////////////////////////////
228///
229struct W32_ArcNote : public W32_PolyEllipseNote {
230
231 W32_ArcNote ( int, int, int, int, double, double );
232
233 virtual void Play ( BOOL = TRUE );
234
235 double mySa, myOa;
236
237};
238
239struct WNT_ArcNote : public WNT_PolyEllipseNote {
240
241 WNT_ArcNote ( int, int, int, int, double, double );
242
243 virtual void Play ( BOOL = TRUE );
244 virtual void Xform ( void );
245
246 int mySX, mySY, myTSX, myTSY,
247 myEX, myEY, myTEX, myTEY,
248 myDirect;
249};
250///
251/////////////////////// POLY CHORDS //////////////////////////
252///
253struct W32_PolyChordNote : public W32_ArcNote {
254
255 W32_PolyChordNote ( int, int, int, int, double, double );
256
257 virtual void Play ( BOOL = TRUE );
258
259};
260
261struct WNT_PolyChordNote : public WNT_ArcNote {
262
263 WNT_PolyChordNote ( int, int, int, int, double, double );
264
265 virtual void Play ( BOOL = TRUE );
266
267};
268///
269////////////////////////// CHORDS ////////////////////////////
270///
271struct W32_ChordNote : public W32_PolyChordNote {
272
273 W32_ChordNote ( int, int, int, int, double, double );
274
275 virtual void Play ( BOOL = TRUE );
276
277};
278
279struct WNT_ChordNote : public WNT_PolyChordNote {
280
281 WNT_ChordNote ( int, int, int, int, double, double );
282
283 virtual void Play ( BOOL = TRUE );
284
285};
286///
287////////////////////// POLY SECTORS //////////////////////////
288///
289struct W32_PolySectorNote : public W32_ArcNote {
290
291 W32_PolySectorNote ( int, int, int, int, double, double );
292
293 virtual void Play ( BOOL = TRUE );
294
295};
296
297struct WNT_PolySectorNote : public WNT_ArcNote {
298
299 WNT_PolySectorNote ( int, int, int, int, double, double );
300
301 virtual void Play ( BOOL = TRUE );
302
303};
304///
305/////////////////////// SECTORS //////////////////////////////
306///
307struct W32_SectorNote : public W32_PolySectorNote {
308
309 W32_SectorNote ( int, int, int, int, double, double );
310
311 virtual void Play ( BOOL = TRUE );
312
313};
314
315struct WNT_SectorNote : public WNT_PolySectorNote {
316
317 WNT_SectorNote ( int, int, int, int, double, double );
318
319 virtual void Play ( BOOL = TRUE );
320
321};
322///
323/////////////////////// MARKERS //////////////////////////////
324///
325struct W32_PolyMarkerNote : public W32_Note {
326
327 W32_PolyMarkerNote ( int );
328
329 void Replace ( int, int, int );
330
331 virtual void Play ( BOOL = TRUE ) {}
332
333 int myMaxPoints, mySetPoints;
334 LPPOINT myPoints;
335
336};
337
338struct W32_PolyMarker1Note : public W32_PolyMarkerNote {
339
340 W32_PolyMarker1Note ( int, GetPointFunc, int, void* );
341
342 virtual void Play ( BOOL = TRUE );
343
344};
345
346struct WNT_PolyMarker1Note : public W32_PolyMarker1Note {
347
348 WNT_PolyMarker1Note ( int, GetPointFunc, int, void* );
349
350 virtual void Play ( BOOL = TRUE );
351
352};
353
354struct W32_PolyMarker2Note : public W32_PolyMarker1Note {
355
356 W32_PolyMarker2Note ( int, GetPointFunc, int, void* );
357
358 virtual void Play ( BOOL = TRUE );
359
360};
361
362struct WNT_PolyMarker2Note : public WNT_PolyMarker1Note {
363
364 WNT_PolyMarker2Note ( int, GetPointFunc, int, void* );
365
366 virtual void Play ( BOOL = TRUE );
367
368};
369///
370/////////////////////// POLYGONS /////////////////////////////
371///
372struct W32_PolygonNote : public W32_PolyMarkerNote {
373
374 W32_PolygonNote ( int );
375
376 void Add ( int, int );
377
378 virtual void Play ( BOOL = TRUE );
379
380};
381
382struct WNT_PolygonNote : public W32_PolygonNote {
383
384 WNT_PolygonNote ( int );
385
386 virtual void Play ( BOOL = TRUE );
387 virtual void Xform ( void );
388
389 LPPOINT myTPoints;
390
391};
392///
393/////////////////////// POLYLINES ////////////////////////////
394///
395struct W32_PolylineNote : public W32_PolygonNote {
396
397 W32_PolylineNote ( int );
398
399 virtual void Play ( BOOL = TRUE );
400
401};
402
403struct WNT_PolylineNote : public WNT_PolygonNote {
404
405 WNT_PolylineNote ( int );
406
407 virtual void Play ( BOOL = TRUE );
408
409};
410///
411///////////////////////// IMAGES /////////////////////////////
412///
413struct W32_ImageNote : public W32_PointNote {
414
415 W32_ImageNote ( int, int, PW32_Bitmap, double = 1.0 );
416 virtual ~W32_ImageNote ();
417
418 virtual void Play ( BOOL = TRUE );
419
420 PW32_Bitmap myBitmap;
421 double myScale;
422
423};
424
425struct WNT_ImageNote : public WNT_PointNote {
426
427 WNT_ImageNote ( int, int, PW32_Bitmap, double = 1.0 );
428 virtual ~WNT_ImageNote ();
429
430 virtual void Play ( BOOL = TRUE );
431
432 PW32_Bitmap myBitmap;
433 double myScale;
434
435};
436///
437///////////////////////// TEXTS //////////////////////////////
438///
439struct W32_TextNote : public W32_PointNote {
440
441 W32_TextNote ( int, int, double, void*, BOOL = FALSE, BOOL = FALSE );
442
443 virtual void Play ( BOOL = TRUE );
444
445 void* myText;
446 double myAngle;
447 DWORD myFlags;
448
449};
450
451struct WNT_TextNote : public WNT_PointNote {
452
453 WNT_TextNote ( int, int, double, void*, BOOL = FALSE, BOOL = FALSE );
454
455 virtual void Play ( BOOL = TRUE );
456 virtual void Xform ( void );
457 void SetAttribs ();
458 void RestoreAttribs ();
459 void PaintText ();
460 void OutlineText ();
461 void FillText ();
462
463 void* myText;
464 double mySlant;
465 DWORD myFlags;
466 int myShift;
467 XFORM RMatrix,
468 IMatrix,
469 SMatrix;
470
471};
472///
473/////////////////////// POLYTEXTS ////////////////////////////
474///
475struct W32_PolyTextNote : public W32_TextNote {
476
477 W32_PolyTextNote ( int, int, double, double, void*, BOOL = FALSE, BOOL = FALSE );
478
479 virtual void Play ( BOOL = TRUE );
480
481 double myMargin;
482
483};
484
485struct WNT_PolyTextNote : public WNT_TextNote {
486
487 WNT_PolyTextNote ( int, int, double, double, void*, BOOL = FALSE, BOOL = FALSE );
488
489 virtual void Play ( BOOL = TRUE );
490
491 double myMargin;
492
493};
494///
495////////////////// BEGIN/END MARKERS /////////////////////////
496///
497struct W32_BeginMarkerNote : public W32_PointNote {
498
499 W32_BeginMarkerNote ( int, int, int, int, double );
500
501 virtual void Play ( BOOL = TRUE );
502
503 int myWidth, myHeight;
504 double myAngle;
505
506};
507
508struct WNT_BeginMarkerNote : public WNT_PointNote {
509
510 WNT_BeginMarkerNote ( int, int, int, int, double );
511
512 virtual void Play ( BOOL = TRUE );
513 virtual void Xform ( void );
514
515 int myWidth, myHeight;
516 double myAngle, myPrevAngle;
517 XFORM myMatrix;
518
519};
520
521struct W32_EndMarkerNote : public W32_Note {
522
523 W32_EndMarkerNote ();
524
525 virtual void Play ( BOOL = TRUE );
526
527};
528
529struct WNT_EndMarkerNote : public W32_Note {
530
531 WNT_EndMarkerNote ();
532
533 virtual void Play ( BOOL = TRUE );
534
535};
536///
537//////////////////// A T T R I B U T E S /////////////////////
538///
539struct W32_LineAttribNote : public W32_Note {
540
541 W32_LineAttribNote ( DWORD, PLOGBRUSH, DWORD = 0, PDWORD = NULL );
542
543 virtual void Play ( BOOL = TRUE );
544
545 LOGBRUSH myLogBrush;
546 DWORD myPenWidth;
547 DWORD myStyleCount;
548 PDWORD myStyles;
549
550};
551
552struct WNT_LineAttribNote : public W32_Note {
553
554 WNT_LineAttribNote ( DWORD, PLOGBRUSH, DWORD = 0, PDWORD = NULL );
555 virtual ~WNT_LineAttribNote ();
556
557 virtual void Play ( BOOL = TRUE );
558
559 HPEN myPen;
560 DWORD myWidth;
561 COLORREF myPointColor;
562
563};
564
565struct W32_PolyAttribNote : public W32_Note {
566
567 W32_PolyAttribNote ( PLOGBRUSH, BOOL, int = ALTERNATE );
568
569 virtual void Play ( BOOL = TRUE );
570
571 LOGBRUSH myBrush;
572 BOOL myfEdge;
573 int myFillMode;
574
575};
576
577struct WNT_PolyAttribNote : public W32_Note {
578
579 WNT_PolyAttribNote ( PLOGBRUSH, BOOL, int = ALTERNATE );
580 virtual ~WNT_PolyAttribNote ();
581
582 virtual void Play ( BOOL = TRUE );
583
584 HBRUSH myBrush;
585 BOOL myfEdge;
586 int myFillMode;
587 BOOL myNoFill;
588
589};
590
591struct W32_TextAttribNote : public W32_Note {
592
593 W32_TextAttribNote (
594 HFONT, COLORREF, double = 0.0, double = 1.0, double = 1.0,
595 BOOL = FALSE, BOOL = FALSE, BOOL = FALSE
596 );
597 virtual ~W32_TextAttribNote ();
598
599 virtual void Play ( BOOL = TRUE );
600
601 COLORREF myColor;
602 HFONT myFont;
603 DWORD myFlags;
604 double mySlant,
605 myHScale,
606 myVScale;
607
608};
609
610struct WNT_TextAttribNote : public W32_Note {
611
612 WNT_TextAttribNote (
613 HFONT, COLORREF, double = 0.0, double = 1.0, double = 1.0,
614 BOOL = FALSE, BOOL = FALSE, BOOL = FALSE
615 );
616 virtual ~WNT_TextAttribNote ();
617
618 virtual void Play ( BOOL = TRUE );
619
620 COLORREF myColor;
621 HPEN myPen;
622 HBRUSH myBrush;
623 HFONT myFont;
624 BOOL myfFree;
625 DWORD myFlags;
626 double mySlant,
627 myHScale,
628 myVScale;
629
630};
631
632struct W32_MarkerAttribNote : public W32_Note {
633
634 W32_MarkerAttribNote ( COLORREF, DWORD, BOOL );
635
636 virtual void Play ( BOOL = TRUE );
637
638 LOGBRUSH myLogBrush;
639
640};
641
642struct WNT_MarkerAttribNote : public W32_Note {
643
644 WNT_MarkerAttribNote ( COLORREF, DWORD, BOOL );
645 virtual ~WNT_MarkerAttribNote ();
646
647 virtual void Play ( BOOL = TRUE );
648
649 HPEN myPen;
650 COLORREF myMarkerPointColor;
651 BOOL myFill;
652
653};
654///
655//////////////////// F U N C T I O N C A L L ////////////////
656///
657struct W32_FCallNote : public W32_Note {
658
659 W32_FCallNote ( W32_FCall, int, PW32_FCALLPARAM );
660
661 virtual void Play ( BOOL = TRUE );
662
663 W32_FCall myFunc;
664 PW32_FCALLPARAM myParam;
665
666};
667///
668//////////////////// A L L O C A T O R ///////////////////////
669///
670struct W32_Allocator {
671
672 W32_Allocator ( int, PW32_Allocator = NULL );
673 virtual ~W32_Allocator ();
674
675 PW32_Block MakeBlock ( int );
676 // allocates memory block
677 virtual PW32_Block KillBlock ( PW32_Block );
678 // deallocates memory block
679 void KillBlocks ( PW32_Block );
680 // deallocates memory blocks starting from specified one
681 void ClearBlocks ( void );
682 // resets allocator
683 void ReleaseBlock ( PW32_Block );
684 // releases graphics primitives in the specified block
685 BOOL FreeSpace ( PW32_Block, int );
686 // checks for free space in the specified block
687 PW32_Block ReserveData ( unsigned int );
688 // checks for free space in the current block
689 PW32_Block ReserveFind ( unsigned int );
690 // searches for free space
691 void* ReserveBlock ( PW32_Block, int, BOOL = FALSE );
692 // reserves data in the specified block
693 void* NewClass ( unsigned int );
694 // gets space for a new class ( W32_Note )
695 void* NewData ( unsigned int, BOOL = FALSE );
696 // gets space for a new data
697 virtual void Xform ( void ) = 0;
698 // sets world transformation in the device context
699
700 virtual void Play ( HDC, PSIZE ) = 0;
701 // plays notes
702 virtual void URect ( LPRECT ) = 0;
703 // gets updated rectangle
704
705 virtual void Point ( int, int ) = 0;
706 // stores a point
707 virtual void MarkerPoint ( int, int ) = 0;
708 // stores a marker point
709 virtual void Line ( int, int, int, int ) = 0;
710 // stores a line segment
711 virtual void PolyEllipse ( int, int, int, int ) = 0;
712 // stores a polyellipse
713 virtual void Ellipse ( int, int, int, int ) = 0;
714 // stores an ellipse
715 virtual void Arc ( int, int, int, int, double, double ) = 0;
716 // stores an arc
717 virtual void PolyChord ( int, int, int, int, double, double ) = 0;
718 // stores a polychord
719 virtual void Chord ( int, int, int, int, double, double ) = 0;
720 // stores a chord
721 virtual void PolySector ( int, int, int, int, double, double ) = 0;
722 // stores a polysector
723 virtual void Sector ( int, int, int, int, double, double ) = 0;
724 // stores a sector
725 virtual void PolyMarker ( int ) = 0;
726 // stores a polymarker
727 virtual void PolyMarker1 ( int, GetPointFunc, int, void* ) = 0;
728 // stores a polymarker1
729 virtual void PolyMarker2 ( int, GetPointFunc, int, void* ) = 0;
730 // stores a polymarker2
731 virtual W32_Note* Polygon ( int ) = 0;
732 // stores a polygon
733 virtual W32_Note* Polyline ( int ) = 0;
734 // stores a polyline
735 virtual void Image ( int, int, PW32_Bitmap, double = 1.0 ) = 0;
736 // stores an image
737 virtual void Text ( int, int, double, void*, BOOL = FALSE, BOOL = FALSE ) = 0;
738 // stores a text
739 virtual void Polytext ( int, int, double, double, void*, BOOL = FALSE, BOOL = FALSE ) = 0;
740 // stores a polytext
741 virtual void BeginMarker ( int, int, int, int, double ) = 0;
742 // stores the begin of marker
743 virtual void EndMarker ( void ) = 0;
744 // stores end of the marker
745 virtual void LineAttrib ( DWORD, PLOGBRUSH, DWORD = 0, PDWORD = NULL ) = 0;
746 // stores line attributes
747 virtual void PolyAttrib ( PLOGBRUSH, BOOL, int = ALTERNATE ) = 0;
748 // stores polygon attributes
749 virtual void TextAttrib (
750 HFONT, COLORREF, double = 0.0, double = 1.0, double = 1.0,
751 BOOL = FALSE, BOOL = FALSE, BOOL = FALSE
752 ) = 0;
753 //stores text attributes
754 virtual void MarkerAttrib ( COLORREF, DWORD, BOOL ) = 0;
755 // stores marker attributes
756 virtual void FunCall ( W32_FCall, int, PW32_FCALLPARAM ) = 0;
757 // stores function call
758
759 virtual int TextSize ( HDC, char*, PSIZE ) = 0;
760 virtual int TextSize ( HDC, wchar_t*, PSIZE ) = 0;
761 //obtains dimensions of the text string
762
763 int myID;
764 PW32_Allocator myNext;
765 PW32_Block myStart, myEnd;
766 W32_Primitive myPrimitive;
767 W32_Note* myNote;
768 int myFillMode;
769 DWORD myFlags;
770 POINT myPivot;
771 POINT myMove;
772 double myScaleX, myScaleY;
773 double myAngle;
774 double myTextVScale;
775 double myTextHScale;
776 double myTextSlant;
777 HFONT myTextFont;
778 COLORREF myPointColor,
779 myMarkerPointColor;
780
781};
782
783extern PW32_Allocator ( *W32_GetAllocator ) ( int, PW32_Allocator );
784
785#define P(v) LONG( ( v ) / myPixelToUnit + 0.5 )
786#define U(v) ( ( v ) * myPixelToUnit )
787
788#endif // __W32_ALLOCATOR_HXX