0022749: Segfault in HashCode() of Standard_Transient
[occt.git] / src / Xw / Xw_Driver.cxx
CommitLineData
7fd59977 1/***********************************************************************
2
3 FONCTION :
4 ----------
5 Classe Xw_Driver :
6
7 HISTORIQUE DES MODIFICATIONS :
8 --------------------------------
9
10 30-01-98 : GG ; SPEC_MFT
11 L'utilisation des polices MFT devient parametrable a travers
12 la methode Aspect_Driver::UseMFT().
13 Le symbol CSF_USE_MFT n'est donc plus reconnu.
14
15***********************************************************************/
16
17#define PRO5676 //GG_020197
18// Donner la possibillite d'exprimer la taille
19// par rapport a la hauteur totale du caractere ou par
20// rapport a la hauteur "ascent" situee au dessus de la
21// ligne de base.
22// (CapsHeight flag)
23
24#define CTS50024 //GG_090997
25// Attention avec les nouvelles machines SGI,
26// le pitch vertical n'est pas identique au pitch horizontal.
27
28#define MFT //GG_220497 Etude G1343
29// Utilisation du FontManager MFT permettant de traiter
30// les chaines de caracteres orientees et slantees.
31//
32
33#define OPTIM1 //GG_180997
34// Optimisation du SKETCHER :
35// remplacer les appels Xw_get_window_position() par
36// Xw_get_window_size() qui est plus optimum.
37
38
39#define PRO12934 //GG_060598
40// Eviter de "raiser" lorsqu'une erreur est detectee.
41//
42
43#define PRO17334 //GG_050199
44// Raiser dans DrawMarker() lorsque l'index est hors limites
45
46#include <Xw_Driver.ixx>
47#include <Aspect_ColorMapEntry.hxx>
48#include <Aspect_WidthMapEntry.hxx>
49#include <Aspect_TypeMapEntry.hxx>
50#include <Aspect_LineStyle.hxx>
51#include <Aspect_TypeOfLine.hxx>
52#include <Aspect_FontMapEntry.hxx>
53#include <Aspect_FontStyle.hxx>
54#include <Aspect_MarkMapEntry.hxx>
55#include <Aspect_TypeOfMarker.hxx>
56#include <Aspect_MarkerStyle.hxx>
57#include <TCollection_AsciiString.hxx>
58#include <TColQuantity_Array1OfLength.hxx>
59#include <TColStd_Array1OfBoolean.hxx>
60#include <TShort_Array1OfShortReal.hxx>
61
62// Routines C a declarer en extern
63//extern "C" {
64#include <Xw_Cextern.hxx>
65//}
66typedef struct { float r, g, b; } GRAPHIC2D_PIXEL;
67
68//-Static data definitions
69
70static XW_STATUS status ;
71
72static Standard_ShortReal theSinAngle,theCosAngle;
73#define TRANSFORM(X,Y) \
74 { Standard_Real x = X,y = Y; \
75 X = x*theCosAngle - y*theSinAngle; \
76 Y = x*theSinAngle + y*theCosAngle; \
77 }
78
79//============================================================================
80//==== HashCode : Returns a HashCode CString
81//============================================================================
82inline Standard_Integer HashCode (const Standard_CString Value)
83{
84Standard_Integer i,n,aHashCode = 0;
85union {
86 char charPtr[80];
87 int intPtr[20];
88} u;
89
90 n = strlen(Value);
91
92 if( n > 0 ) {
93 if( n < 80 ) {
94 n = (n+3)/4;
95 u.intPtr[n-1] = 0;
96 strcpy(u.charPtr,Value);
97 } else {
98 n = 20;
99 strncpy(u.charPtr,Value,80);
100 }
101
102 for( i=0 ; i<n ; i++ ) {
103 aHashCode = aHashCode ^ u.intPtr[i];
104 }
105 }
106
107//printf(" HashCode of '%s' is %d\n",Value,aHashCode);
108
109 return Abs(aHashCode) + 1;
110}
111
112void Xw_Driver::PrintError() {
113Standard_CString ErrorMessag ;
114Standard_Integer ErrorNumber ;
115Standard_Integer ErrorGravity ;
116
117 status = XW_SUCCESS ;
118 ErrorMessag = Xw_get_error(&ErrorNumber,&ErrorGravity) ;
119#ifdef PRO12934
120 Xw_print_error() ;
121#else
122 if( ErrorGravity > 2 ) Aspect_DriverError::Raise (ErrorMessag) ;
123 else Xw_print_error() ;
124#endif
125
126}
127
128// Category: Constructors
129
130Xw_Driver::Xw_Driver (const Handle(Xw_Window)& aWindow)
131: Aspect_WindowDriver(aWindow) {
132
133 MyColorIndexs.Nullify() ;
134 MyTypeIndexs.Nullify() ;
135 MyWidthIndexs.Nullify() ;
136 MyFontIndexs.Nullify() ;
137 MyMarkerIndexs.Nullify() ;
138
139 MyVisualClass = aWindow->VisualClass() ;
140 MyExtendedDrawable = aWindow->ExtendedWindow() ;
141 MyExtendedColorMap = aWindow->ExtendedColorMap() ;
142 MyExtendedTypeMap = aWindow->ExtendedTypeMap() ;
143 MyExtendedWidthMap = aWindow->ExtendedWidthMap() ;
144 MyExtendedFontMap = aWindow->ExtendedFontMap() ;
145 MyExtendedMarkMap = aWindow->ExtendedMarkMap() ;
146 MyImage = NULL;
147 MyDrawMode = Aspect_TODM_ERASE ;
148 MyPrimitiveType = Aspect_TOP_UNKNOWN ;
149 MyRetainBuffer = 0 ;
150#ifdef MFT
151 MyTextManager = new Xw_TextManager(MyExtendedDrawable,MyExtendedWidthMap);
152#endif
153 SetDrawMode(Aspect_TODM_REPLACE) ;
154}
155
156// Category: Methods to modify the class definition
157
158void Xw_Driver::BeginDraw ( const Standard_Boolean DBmode,
159 const Standard_Integer aRetainBuffer ) {
160
161 status = Xw_set_double_buffer(MyExtendedDrawable,
162 (XW_DOUBLEBUFFERMODE)DBmode) ;
163
164 if( !status ) PrintError() ;
165
166 status = Xw_set_buffer(MyExtendedDrawable,aRetainBuffer) ;
167 if( status ) {
168 MyRetainBuffer = aRetainBuffer ;
169 } else {
170 PrintError() ;
171 }
172}
173
174void Xw_Driver::EndDraw (const Standard_Boolean Synchronize) {
175
176 if( MyRetainBuffer != 0 ) {
177 MyRetainBuffer = 0 ;
178 status = Xw_set_buffer(MyExtendedDrawable,0) ;
179 // Reset attribs after filling buffer
180 Aspect_TypeOfDrawMode mode = MyDrawMode;
181 MyDrawMode = Aspect_TypeOfDrawMode(mode + 1);
182 SetDrawMode(mode);
183 } else {
184 status = Xw_flush (MyExtendedDrawable,Synchronize);
185 }
186 if( !status ) PrintError() ;
187}
188
189Standard_Boolean Xw_Driver::OpenBuffer (const Standard_Integer aRetainBuffer,
190 const Standard_ShortReal aPivotX,
191 const Standard_ShortReal aPivotY,
192 const Standard_Integer WidthIndex,
193 const Standard_Integer ColorIndex,
194 const Standard_Integer FontIndex,
195 const Aspect_TypeOfDrawMode DrawMode) {
196Standard_Integer theWidth = 0 ;
197Standard_Integer theColor = 0 ;
198Standard_Integer theFont = 0 ;
199Standard_ShortReal xpivot = aPivotX ;
200Standard_ShortReal ypivot = aPivotY ;
201XW_DRAWMODE theDrawMode = (XW_DRAWMODE)DrawMode;
202
203 if( !MyWidthIndexs.IsNull() ) {
204 if( WidthIndex > 0 && WidthIndex >= MyWidthIndexs->Lower() &&
205 WidthIndex <= MyWidthIndexs->Upper() ) {
206 theWidth = MyWidthIndexs->Value(WidthIndex) ;
207 }
208 }
209 if( !MyColorIndexs.IsNull() ) {
210 if( ColorIndex > 0 && ColorIndex >= MyColorIndexs->Lower() &&
211 ColorIndex <= MyColorIndexs->Upper() ) {
212 theColor = MyColorIndexs->Value(ColorIndex) ;
213 }
214 }
215 if( !MyFontIndexs.IsNull() ) {
216 if( FontIndex > 0 && FontIndex >= MyFontIndexs->Lower() &&
217 FontIndex <= MyFontIndexs->Upper() ) {
218 theFont = MyFontIndexs->Value(FontIndex) ;
219 }
220 }
221
222 status = Xw_open_buffer(MyExtendedDrawable,aRetainBuffer,
223 xpivot,ypivot,theWidth,theColor,theFont,theDrawMode) ;
224
225 if( !status ) PrintError() ;
226
227 return status;
228}
229
230void Xw_Driver::CloseBuffer (const Standard_Integer aRetainBuffer) const {
231
232 status = Xw_close_buffer(MyExtendedDrawable,aRetainBuffer) ;
233
234 if( !status ) PrintError() ;
235}
236
237void Xw_Driver::ClearBuffer (const Standard_Integer aRetainBuffer) const {
238
239 status = Xw_clear_buffer(MyExtendedDrawable,aRetainBuffer) ;
240
241 if( !status ) PrintError() ;
242}
243
244void Xw_Driver::DrawBuffer (const Standard_Integer aRetainBuffer) const {
245
246 status = Xw_draw_buffer(MyExtendedDrawable,aRetainBuffer) ;
247
248 if( !status ) PrintError() ;
249}
250
251void Xw_Driver::EraseBuffer (const Standard_Integer aRetainBuffer) const {
252
253 status = Xw_erase_buffer(MyExtendedDrawable,aRetainBuffer) ;
254
255 if( !status ) PrintError() ;
256}
257
258void Xw_Driver::MoveBuffer (const Standard_Integer aRetainBuffer,
259 const Standard_ShortReal aPivotX,
260 const Standard_ShortReal aPivotY) const {
261Standard_ShortReal xpivot = aPivotX ;
262Standard_ShortReal ypivot = aPivotY ;
263
264 status = Xw_move_buffer(MyExtendedDrawable,aRetainBuffer,
265 xpivot,ypivot) ;
266
267 if( !status ) PrintError() ;
268}
269
270void Xw_Driver::ScaleBuffer (const Standard_Integer aRetainBuffer,
271 const Quantity_Factor aScaleX,
272 const Quantity_Factor aScaleY) const {
273Standard_ShortReal scalex = aScaleX;
274Standard_ShortReal scaley = aScaleY;
275
276 status = Xw_scale_buffer(MyExtendedDrawable,aRetainBuffer,scalex,scaley) ;
277
278 if( !status ) PrintError() ;
279}
280
281void Xw_Driver::RotateBuffer (const Standard_Integer aRetainBuffer,
282 const Quantity_PlaneAngle anAngle) const {
283Standard_ShortReal angle = anAngle;
284
285 status = Xw_rotate_buffer(MyExtendedDrawable,aRetainBuffer,angle) ;
286
287 if( !status ) PrintError() ;
288}
289
290Standard_Boolean Xw_Driver::BufferIsOpen (const Standard_Integer aRetainBuffer) const {
291Standard_Integer isopen,isdrawn,isempty;
292
293 status = Xw_get_buffer_status(MyExtendedDrawable,aRetainBuffer,
294 &isopen,&isdrawn,&isempty) ;
295
296 return (isopen != 0 ? Standard_True : Standard_False);
297}
298
299Standard_Boolean Xw_Driver::BufferIsEmpty (const Standard_Integer aRetainBuffer) const {
300Standard_Integer isopen,isdrawn,isempty;
301
302 status = Xw_get_buffer_status(MyExtendedDrawable,aRetainBuffer,
303 &isopen,&isdrawn,&isempty) ;
304 if( !status ) PrintError() ;
305
306 return (isempty != 0 ? Standard_True : Standard_False);
307}
308
309Standard_Boolean Xw_Driver::BufferIsDrawn (const Standard_Integer aRetainBuffer) const {
310Standard_Integer isopen,isdrawn,isempty;
311
312 status = Xw_get_buffer_status(MyExtendedDrawable,aRetainBuffer,
313 &isopen,&isdrawn,&isempty) ;
314 if( !status ) PrintError() ;
315
316 return (isdrawn != 0 ? Standard_True : Standard_False);
317}
318
319void Xw_Driver::SetDrawMode (const Aspect_TypeOfDrawMode aMode) {
320
321 if( MyDrawMode != aMode ) {
322 MyDrawMode = aMode;
323 MyLineColor = -1 ;
324 MyLineType = -1 ;
325 MyLineWidth = -1 ;
326 MyPolyColor = -1 ;
327 MyPolyType = Standard_False ;
328 MyPolyTile = 0 ;
329 MyTextColor = -1 ;
330 MyTextType = 0 ;
331 MyTextFont = -1 ;
332 MyTextHScale = 1. ;
333 MyTextWScale = 1. ;
334 MyTextSlant = 0. ;
335 MyTextIsUnderlined = Standard_False;
336 MyMarkerColor = -1 ;
337 MyMarkerType = Standard_False ;
338 MyMarkerWidth = -1 ;
339 }
340}
341
342Aspect_TypeOfResize Xw_Driver::ResizeSpace () {
343XW_RESIZETYPE mode = Xw_resize_window(MyExtendedDrawable) ;
344
345 if ( Window()->HBackground() )
346 status = Xw_update_background_image( MyExtendedDrawable );
347 if( mode == XW_TOR_UNKNOWN ) PrintError() ;
348
349 if( mode != XW_NO_BORDER ) {
350 MyTextColor = -1 ;
351 }
352
353 return (Aspect_TypeOfResize(mode)) ;
354}
355
356// Category: Methods to define the attributes
357
358void Xw_Driver::InitializeColorMap (const Handle(Aspect_ColorMap)& Colormap) {
359Aspect_ColorMapEntry entry ;
360Quantity_Color color ;
361Standard_Integer index,iindex,oindex,minindex=IntegerLast(),maxindex= -minindex;
362Standard_Real red,green,blue ;
363int hindex ;
364
365 if( !Xw_isdefine_colormap(MyExtendedColorMap) ) PrintError() ;
366
367 for( index=1 ; index<=Colormap->Size() ; index++ ) {
368 entry = Colormap->Entry(index) ;
369 maxindex = Max(maxindex,entry.Index()) ;
370 minindex = Min(minindex,entry.Index()) ;
371 }
372
373 MyColorIndexs = new TColStd_HArray1OfInteger(minindex,maxindex,-1) ;
374
375 for( index=1 ; index<=Colormap->Size() ; index++ ) {
376 entry = Colormap->Entry(index) ;
377 iindex = entry.Index() ;
378 color = entry.Color() ;
379 color.Values(red,green,blue,Quantity_TOC_RGB) ;
380 status = Xw_get_color_index(MyExtendedColorMap,(float)red,
381 (float)green,
382 (float)blue,
383 &hindex) ;
384 oindex = hindex ;
385 MyColorIndexs->SetValue(iindex,oindex) ;
386 }
387}
388
389void Xw_Driver::InitializeTypeMap (const Handle(Aspect_TypeMap)& Typemap) {
390Aspect_TypeMapEntry entry ;
391Aspect_LineStyle style ;
392Aspect_TypeOfLine type ;
393Standard_Integer index,iindex,oindex,minindex=IntegerLast(),maxindex= -minindex;
394Standard_Integer i ;
395int hindex,length ;
396float *vstyle ;
397
398 if( !Xw_isdefine_typemap(MyExtendedTypeMap) ) PrintError() ;
399
400 for( index=1 ; index<=Typemap->Size() ; index++ ) {
401 entry = Typemap->Entry(index) ;
402 maxindex = Max(maxindex,entry.Index()) ;
403 minindex = Min(minindex,entry.Index()) ;
404 }
405
406 MyTypeIndexs = new TColStd_HArray1OfInteger(minindex,maxindex,-1) ;
407
408 for( index=1 ; index<=Typemap->Size() ; index++ ) {
409 entry = Typemap->Entry(index) ;
410 iindex = entry.Index() ;
411 style = entry.Type() ;
412 type = style.Style() ;
413 length = (int) style.Length() ;
414 if( type != Aspect_TOL_SOLID ) {
415 const TColQuantity_Array1OfLength& values(style.Values()) ;
416 TShort_Array1OfShortReal
417 svalues(values.Lower(),values.Length()) ;
418 for( i=values.Lower() ; i<=values.Upper() ; i++ )
419 svalues(i) = TOMILLIMETER(Standard_ShortReal(values(i))) ;
420
421 vstyle = (float*) &svalues.Value(values.Lower()) ;
422 status = Xw_get_type_index(MyExtendedTypeMap,vstyle,length,
423 &hindex) ;
424 oindex = hindex ;
425 } else oindex = 0 ;
426 MyTypeIndexs->SetValue(iindex,oindex) ;
427 }
428}
429
430void Xw_Driver::InitializeWidthMap (const Handle(Aspect_WidthMap)& Widthmap) {
431Aspect_WidthMapEntry entry ;
432Standard_Integer index,iindex,oindex,minindex=IntegerLast(),maxindex= -minindex;
433int hindex ;
434float width ;
435
436 if( !Xw_isdefine_widthmap(MyExtendedWidthMap) ) PrintError() ;
437
438 for( index=1 ; index<=Widthmap->Size() ; index++ ) {
439 entry = Widthmap->Entry(index) ;
440 maxindex = Max(maxindex,entry.Index()) ;
441 minindex = Min(minindex,entry.Index()) ;
442 }
443
444 MyWidthIndexs = new TColStd_HArray1OfInteger(minindex,maxindex,-1) ;
445
446 for( index=1 ; index<=Widthmap->Size() ; index++ ) {
447 entry = Widthmap->Entry(index) ;
448 iindex = entry.Index() ;
449 width = (float) TOMILLIMETER(entry.Width()) ;
450 status = Xw_get_width_index(MyExtendedWidthMap,width,&hindex) ;
451 oindex = hindex ;
452 MyWidthIndexs->SetValue(iindex,oindex) ;
453 }
454}
455
456void Xw_Driver::InitializeFontMap (const Handle(Aspect_FontMap)& Fontmap) {
457Aspect_FontMapEntry entry ;
458Aspect_FontStyle style ;
459Standard_Integer index,iindex,oindex,minindex=IntegerLast(),maxindex= -minindex;
460int hindex ;
461float size,slant ;
462//char env[64];
463
464 if( !Xw_isdefine_fontmap(MyExtendedFontMap) ) PrintError() ;
465
466 for( index=1 ; index<=Fontmap->Size() ; index++ ) {
467 entry = Fontmap->Entry(index) ;
468 maxindex = Max(maxindex,entry.Index()) ;
469 minindex = Min(minindex,entry.Index()) ;
470 }
471
472#ifdef MFT
473 if( UseMFT() ) {
474 MyMFTFonts = new Xw_HListOfMFTFonts(minindex,maxindex,NULL) ;
475 MyMFTSizes = new TShort_HArray1OfShortReal(minindex,maxindex,0.) ;
476 }
477#endif
478
479 MyFontIndexs = new TColStd_HArray1OfInteger(minindex,maxindex,-1) ;
480
481 for( index=1 ; index<=Fontmap->Size() ; index++ ) {
482 entry = Fontmap->Entry(index) ;
483 iindex = entry.Index() ;
484 style = entry.Type() ;
485 size = (float) TOMILLIMETER(style.Size()) ;
486 slant = style.Slant() ;
487#ifdef PRO5676
488 if( style.CapsHeight() ) size = -size;
489#endif
490#ifdef MFT
491 if( UseMFT() ) {
492 TCollection_AsciiString aname(style.AliasName());
493 Standard_Boolean found = MFT_FontManager::IsKnown(aname.ToCString());
494 if( !found ) {
495 cout << " Xw_Driver::SetFontMap.cann't found the MFT fontname '"
496 << aname << "',using 'Defaultfont'" << endl;
497 aname = "Defaultfont"; found = Standard_True;
498 }
499 if( found ) {
500 Handle(MFT_FontManager) theFontManager;
501 Aspect_FontStyle fstyle = MFT_FontManager::Font(aname.ToCString());
502 found = Standard_False;
503 for( Standard_Integer i=minindex ; i<=maxindex ; i++ ) {
504 theFontManager = MyMFTFonts->Value(i);
505 if( !theFontManager.IsNull() ) {
506 if( fstyle == theFontManager->Font() ) {
507 found = Standard_True;
508 break;
509 }
510 }
511 }
512 if( !found ) {
513 theFontManager = new MFT_FontManager(aname.ToCString());
514 }
515 Quantity_Length theFontSize = Abs(size);
516 Quantity_PlaneAngle theFontSlant = slant;
517 Standard_Boolean theCapsHeight =
518 (size < 0.) ? Standard_True : Standard_False;
519 theFontManager->SetFontAttribs(theFontSize,theFontSize,
520 theFontSlant,0.,theCapsHeight);
521 MyFontIndexs->SetValue(iindex,-1) ;
522 MyMFTFonts->SetValue(iindex,theFontManager);
523 MyMFTSizes->SetValue(iindex,size);
524 continue;
525 }
526 }
527#endif
528 TCollection_AsciiString aname(style.FullName()) ;
529 status = Xw_get_font_index(MyExtendedFontMap,
530 size,
531 (Standard_PCharacter)aname.ToCString(),
532 &hindex) ;
533 oindex = hindex ;
534 MyFontIndexs->SetValue(iindex,oindex) ;
535 }
536}
537
538void Xw_Driver::InitializeMarkMap (const Handle(Aspect_MarkMap)& Markmap) {
539Aspect_MarkMapEntry entry ;
540Aspect_MarkerStyle style ;
541Aspect_TypeOfMarker type ;
542Standard_Integer index,iindex,oindex,minindex=IntegerLast(),maxindex= -minindex;
543int hindex,length ;
544
545 if( !Xw_isdefine_markmap(MyExtendedMarkMap) ) PrintError() ;
546
547 for( index=1 ; index<=Markmap->Size() ; index++ ) {
548 entry = Markmap->Entry(index) ;
549 maxindex = Max(maxindex,entry.Index()) ;
550 minindex = Min(minindex,entry.Index()) ;
551 }
552
553 MyMarkerIndexs = new TColStd_HArray1OfInteger(minindex,maxindex,-1) ;
554
555 for( index=1 ; index<=Markmap->Size() ; index++ ) {
556 entry = Markmap->Entry(index) ;
557 iindex = entry.Index() ;
558 style = entry.Style() ;
559 type = style.Type() ;
560 length = style.Length() ;
561 const TColStd_Array1OfBoolean& spoint(style.SValues());
562 const TShort_Array1OfShortReal& xpoint(style.XValues());
563 const TShort_Array1OfShortReal& ypoint(style.YValues());
564 int *S = (int*) &spoint.Value(spoint.Lower());
565 float *X = (float*) &xpoint.Value(xpoint.Lower());
566 float *Y = (float*) &ypoint.Value(ypoint.Lower());
567 status = Xw_get_marker_index(MyExtendedMarkMap,length,
568 S,X,Y,&hindex) ;
569 oindex = hindex ;
570 MyMarkerIndexs->SetValue(iindex,oindex) ;
571 }
572}
573
574void Xw_Driver::SetLineAttrib (const Standard_Integer ColorIndex, const Standard_Integer TypeIndex, const Standard_Integer WidthIndex) {
575Standard_Boolean setattrib = Standard_False;
576
577 if( MyLineColor != ColorIndex ) {
578 setattrib = Standard_True;
579 if( !MyColorIndexs.IsNull() ) {
580 if( ColorIndex < MyColorIndexs->Lower() ||
581 ColorIndex > MyColorIndexs->Upper() ) {
582 MyLineColor = MyColorIndexs->Lower();
583 Aspect_DriverError::Raise ("Bad Color Index") ;
584 } else MyLineColor = ColorIndex;
585 } else MyLineColor = -1;
586 }
587 if( MyLineType != TypeIndex ) {
588 setattrib = Standard_True;
589 if( !MyTypeIndexs.IsNull() ) {
590 if( TypeIndex < MyTypeIndexs->Lower() ||
591 TypeIndex > MyTypeIndexs->Upper() ) {
592 MyLineType = MyTypeIndexs->Lower();
593 Aspect_DriverError::Raise ("Bad Type Index") ;
594 } else MyLineType = TypeIndex;
595 } else MyLineType = -1;
596 }
597 if( MyLineWidth != WidthIndex ) {
598 setattrib = Standard_True;
599 if( !MyWidthIndexs.IsNull() ) {
600 if( WidthIndex < MyWidthIndexs->Lower() ||
601 WidthIndex > MyWidthIndexs->Upper() ) {
602 MyLineWidth = MyWidthIndexs->Lower();
603 Aspect_DriverError::Raise ("Bad Width Index") ;
604 } else MyLineWidth = WidthIndex;
605 } else MyLineWidth = -1;
606 }
607
608 if( setattrib ) {
609 Standard_Integer color ;
610 Standard_Integer type = (MyLineType < 0) ? 0 :
611 MyTypeIndexs->Value(MyLineType) ;
612 Standard_Integer width = (MyLineWidth < 0) ? 0 :
613 MyWidthIndexs->Value(MyLineWidth) ;
614
615 if( MyLineColor > 0 ) {
616 color = MyColorIndexs->Value(MyLineColor) ;
617 } else {
618 status = Xw_get_background_index(MyExtendedDrawable,&color) ;
619 }
620 XW_ATTRIB attrib = Xw_set_line_attrib (MyExtendedDrawable,color,type,width,
621 XW_DRAWMODE (MyDrawMode));
622 if( !attrib ) PrintError() ;
623 }
624
625}
626
627void Xw_Driver::SetPolyAttrib (const Standard_Integer ColorIndex, const Standard_Integer TileIndex, const Standard_Boolean DrawEdge) {
628Standard_Boolean setattrib = Standard_False;
629
630 if( MyPolyColor != ColorIndex ) {
631 setattrib = Standard_True;
632 if( !MyColorIndexs.IsNull() ) {
633 if( (TileIndex >= 0) && (ColorIndex < MyColorIndexs->Lower() ||
634 ColorIndex > MyColorIndexs->Upper()) ) {
635 MyPolyColor = MyColorIndexs->Lower();
636 Aspect_DriverError::Raise ("Bad Color Index") ;
637 } else MyPolyColor = ColorIndex;
638 } else MyPolyColor = -1;
639 }
640 if( MyPolyTile != TileIndex ) {
641 setattrib = Standard_True;
642 MyPolyTile = TileIndex;
643 }
644 if( MyPolyType != (int ) DrawEdge ) {
645 setattrib = Standard_True;
646 MyPolyType = DrawEdge;
647 }
648
649 if( setattrib ) {
650 Standard_Integer color ;
651 Standard_Integer type = MyPolyType ;
652 Standard_Integer tile = MyPolyTile ;
653
654 if( MyPolyColor > 0 ) {
655 color = MyColorIndexs->Value(MyPolyColor) ;
656 } else {
657 status = Xw_get_background_index(MyExtendedDrawable,&color) ;
658 }
659 XW_ATTRIB attrib = Xw_set_poly_attrib (MyExtendedDrawable,color,type,tile,
660 XW_DRAWMODE (MyDrawMode));
661 if( !attrib ) PrintError() ;
662 }
663
664}
665
666void Xw_Driver::SetTextAttrib (const Standard_Integer ColorIndex, const Standard_Integer FontIndex) {
667Standard_Boolean setattrib = Standard_False;
668
669 if( MyTextColor != ColorIndex ) {
670 setattrib = Standard_True;
671 if( !MyColorIndexs.IsNull() ) {
672 if( ColorIndex < MyColorIndexs->Lower() ||
673 ColorIndex > MyColorIndexs->Upper() ) {
674 MyTextColor = MyColorIndexs->Lower();
675 Aspect_DriverError::Raise ("Bad Color Index") ;
676 } else MyTextColor = ColorIndex;
677 } else MyTextColor = -1;
678 }
679 if( MyTextFont != FontIndex ) {
680 setattrib = Standard_True;
681 if( !MyFontIndexs.IsNull() ) {
682 if( FontIndex < MyFontIndexs->Lower() ||
683 FontIndex > MyFontIndexs->Upper() ) {
684 MyTextFont = MyFontIndexs->Lower();
685 Aspect_DriverError::Raise ("Bad Font Index") ;
686 } else MyTextFont = FontIndex;
687 } else MyTextFont = -1;
688 }
689 if( MyTextType != 0 ) {
690 setattrib = Standard_True;
691 MyTextType = 0;
692 }
693
694 if( MyTextHScale != 1. || MyTextWScale != 1. ) {
695 setattrib = Standard_True;
696 MyTextHScale = MyTextWScale = 1.;
697 }
698
699 if( setattrib ) {
700 Standard_Integer color ;
701 Standard_Integer type = MyTextType;
702 Standard_Integer font = (MyTextFont < 0) ? 0 :
703 MyFontIndexs->Value(MyTextFont) ;
704
705 if( MyTextColor > 0 ) {
706 color = MyColorIndexs->Value(MyTextColor) ;
707 } else {
708 status = Xw_get_background_index(MyExtendedDrawable,&color) ;
709 }
710#ifdef MFT
711 if( font < 0 ) {
712 Handle(MFT_FontManager) theFontManager =
713 MyMFTFonts->Value(MyTextFont);
714 Quantity_Length theTextSize = MyMFTSizes->Value(MyTextFont);
715 MyTextWSize = MyTextHSize = Abs(theTextSize);
716 Quantity_PlaneAngle theTextSlant = 0.;
717 Quantity_Factor thePrecision = 0.; //Set default
718 Standard_Boolean theCapsHeight =
719 (theTextSize > 0.) ? Standard_False : Standard_True;
720 theFontManager->SetFontAttribs(MyTextWSize,MyTextHSize,
721 theTextSlant,thePrecision,theCapsHeight);
722 return;
723 }
724#endif
725 XW_ATTRIB attrib = Xw_set_text_attrib (MyExtendedDrawable,
726 color,type,font,XW_DRAWMODE (MyDrawMode));
727
728 if( !attrib ) PrintError() ;
729 }
730
731}
732
733void Xw_Driver::SetTextAttrib (const Standard_Integer ColorIndex, const Standard_Integer FontIndex, const Quantity_PlaneAngle aSlant, const Quantity_Factor aHScale, const Quantity_Factor aWScale,const Standard_Boolean isUnderlined) {
734Standard_Boolean setattrib = Standard_False;
735
736 if( MyTextColor != ColorIndex ) {
737 setattrib = Standard_True;
738 if( !MyColorIndexs.IsNull() ) {
739 if( ColorIndex < MyColorIndexs->Lower() ||
740 ColorIndex > MyColorIndexs->Upper() ) {
741 MyTextColor = MyColorIndexs->Lower();
742 Aspect_DriverError::Raise ("Bad Color Index") ;
743 } else MyTextColor = ColorIndex;
744 } else MyTextColor = -1;
745 }
746 if( MyTextFont != FontIndex ) {
747 setattrib = Standard_True;
748 if( !MyFontIndexs.IsNull() ) {
749 if( FontIndex < MyFontIndexs->Lower() ||
750 FontIndex > MyFontIndexs->Upper() ) {
751 MyTextFont = MyFontIndexs->Lower();
752 Aspect_DriverError::Raise ("Bad Font Index") ;
753 } else MyTextFont = FontIndex;
754 } else MyTextFont = -1;
755 }
756 if( MyTextType != 1 || (MyTextSlant != aSlant) ||
757 (MyTextHScale != aHScale) || (MyTextWScale != aWScale) ) {
758 setattrib = Standard_True;
759 MyTextType = 1;
760 MyTextSlant = aSlant;
761 MyTextHScale = aHScale;
762 MyTextWScale = (aWScale > 0.) ? aWScale : aHScale;
763 }
764
765 if( MyTextIsUnderlined != isUnderlined ) {
766 setattrib = Standard_True;
767 MyTextIsUnderlined = isUnderlined;
768 }
769
770 if( setattrib ) {
771 Standard_Integer color ;
772 Standard_Integer font = (MyTextFont < 0) ? 0 :
773 MyFontIndexs->Value(MyTextFont) ;
774 XW_EXTENDEDTEXT attributes ;
775 attributes.type = XW_EXTENDEDTEXT_UNDERLINE;
776 attributes.xscale = MyTextWScale;
777 attributes.yscale = MyTextHScale;
778 attributes.slant = MyTextSlant;
779 attributes.width = attributes.height = 0.;
780 attributes.spacing = 0.;
781 attributes.isUnderlined = MyTextIsUnderlined;
782 if( MyTextSlant != 0. ) attributes.type |= XW_EXTENDEDTEXT_SLANT;
783 if( MyTextWScale > 0. ) {
784 attributes.type |= XW_EXTENDEDTEXT_XSCALE;
785 }
786 if( MyTextHScale > 0. ) {
787 attributes.type |= XW_EXTENDEDTEXT_YSCALE;
788 }
789 if( MyTextColor > 0 ) {
790 color = MyColorIndexs->Value(MyTextColor) ;
791 } else {
792 status = Xw_get_background_index(MyExtendedDrawable,&color) ;
793 }
794#ifdef MFT
795 if( font < 0 ) {
796 Handle(MFT_FontManager) theFontManager =
797 MyMFTFonts->Value(MyTextFont);
798 Quantity_Length theTextSize = MyMFTSizes->Value(MyTextFont);
799 MyTextWSize = MyTextWScale * Abs(theTextSize);
800 MyTextHSize = MyTextHScale * Abs(theTextSize);
801 Quantity_PlaneAngle theTextSlant = MyTextSlant;
802 Quantity_Factor thePrecision = 0.; //Set default
803 Standard_Boolean theCapsHeight =
804 (theTextSize > 0.) ? Standard_False : Standard_True;
805 theFontManager->SetFontAttribs(MyTextWSize,MyTextHSize,
806 theTextSlant,thePrecision,theCapsHeight);
807 return;
808 }
809#endif
810 XW_ATTRIB attrib = Xw_set_extended_text_attrib (MyExtendedDrawable,
811 color,font,XW_DRAWMODE (MyDrawMode),&attributes);
812
813 if( !attrib ) PrintError() ;
814 }
815}
816
817void Xw_Driver::SetMarkerAttrib (const Standard_Integer ColorIndex, const Standard_Integer WidthIndex, const Standard_Boolean FillMarker) {
818Standard_Boolean setattrib = Standard_False;
819
820 if( MyMarkerColor != ColorIndex ) {
821 setattrib = Standard_True;
822 if( !MyColorIndexs.IsNull() ) {
823 if( ColorIndex < MyColorIndexs->Lower() ||
824 ColorIndex > MyColorIndexs->Upper() ) {
825 MyMarkerColor = MyColorIndexs->Lower();
826 Aspect_DriverError::Raise ("Bad Color Index") ;
827 } else MyMarkerColor = ColorIndex;
828 } else MyMarkerColor = -1;
829 }
830 if( MyMarkerWidth != WidthIndex ) {
831 setattrib = Standard_True;
832 if( !MyWidthIndexs.IsNull() ) {
833 if( WidthIndex < MyWidthIndexs->Lower() ||
834 WidthIndex > MyWidthIndexs->Upper() ) {
835 MyMarkerWidth = MyWidthIndexs->Lower();
836 Aspect_DriverError::Raise ("Bad Width Index") ;
837 } else MyMarkerWidth = WidthIndex;
838 } else MyMarkerWidth = -1;
839 }
840 if( MyMarkerType != FillMarker ) {
841 setattrib = Standard_True;
842 MyMarkerType = FillMarker;
843 }
844
845 if( setattrib ) {
846 Standard_Integer color ;
847 Standard_Integer type = MyMarkerType;
848 Standard_Integer width = (MyMarkerWidth < 0) ? 0 :
849 MyWidthIndexs->Value(MyMarkerWidth) ;
850
851 if( MyMarkerColor > 0 ) {
852 color = MyColorIndexs->Value(MyMarkerColor) ;
853 } else {
854 status = Xw_get_background_index(MyExtendedDrawable,&color) ;
855 }
856 XW_ATTRIB attrib = Xw_set_marker_attrib (MyExtendedDrawable,color,type,width,
857 XW_DRAWMODE (MyDrawMode));
858
859 if( !attrib ) PrintError() ;
860 }
861}
862
863// Category: Methods to manage images
864
865Standard_Boolean Xw_Driver::IsKnownImage(const Handle(Standard_Transient)& anImage) {
866
867 MyImage = Xw_get_image_handle( MyExtendedDrawable,
ec6a1aa7 868 (void*)(::HashCode (anImage, IntegerLast())) ) ;
7fd59977 869
870 if( MyImage ) return (Standard_True) ;
871 else return Standard_False;
872}
873
874Standard_Boolean Xw_Driver::SizeOfImageFile(const Standard_CString anImageFile,
875 Standard_Integer &aWidth,
876 Standard_Integer &aHeight) const {
877Standard_Integer hashcode = ::HashCode(anImageFile) ;
878XW_EXT_IMAGEDATA *pimage;
879int width,height,depth;
880float zoom;
881
882 status = XW_ERROR;
883 pimage = Xw_get_image_handle( MyExtendedDrawable,(void*)hashcode ) ;
884 if( !pimage ) {
885 pimage = Xw_load_image(MyExtendedDrawable,
886 (void*)hashcode,
887 (Standard_PCharacter)anImageFile );
888 }
889
890 if( pimage ) {
891 status = Xw_get_image_info(pimage,&zoom,&width,&height,&depth);
892 aWidth = width;
893 aHeight = height;
894 }
895
896 return status;
897}
898
899void Xw_Driver::ClearImage (const Handle(Standard_Transient)& anImage) {
900
901 MyImage = Xw_get_image_handle( MyExtendedDrawable,
ec6a1aa7 902 (void*) (::HashCode (anImage, IntegerLast())) ) ;
7fd59977 903
904 if( MyImage ) {
905 status = Xw_close_image (MyImage);
906 MyImage = NULL;
907 }
908}
909
910void Xw_Driver::ClearImageFile (const Standard_CString anImageFile) {
911Standard_Integer hashcode = ::HashCode(anImageFile) ;
912XW_EXT_IMAGEDATA *pimage;
913
914 pimage = Xw_get_image_handle( MyExtendedDrawable,(void*)hashcode ) ;
915
916 if( pimage ) {
917 status = Xw_close_image (pimage);
918 }
919}
920
921void Xw_Driver::DrawImage (const Handle(Standard_Transient)& anImage, const Standard_ShortReal aX, const Standard_ShortReal aY) {
922
923 MyImage = Xw_get_image_handle( MyExtendedDrawable,
ec6a1aa7 924 (void*) (::HashCode (anImage, IntegerLast())) ) ;
7fd59977 925
926 if( MyImage ) {
927 status = Xw_draw_image (MyExtendedDrawable, MyImage, aX, aY);
928 }
929}
930
931void Xw_Driver::DrawImageFile (const Standard_CString anImageFile,
932 const Standard_ShortReal aX,
933 const Standard_ShortReal aY,
934 const Quantity_Factor aScale)
935{
936 XW_EXT_IMAGEDATA *pimage;
937 Standard_Integer hashcode = ::HashCode(anImageFile);
938
939 pimage = Xw_get_image_handle( MyExtendedDrawable,(void*)hashcode );
940 if (!pimage) {
941 pimage = Xw_load_image(MyExtendedDrawable,
942 (void*)(hashcode),
943 (Standard_PCharacter)anImageFile );
944 }
945
946 if (pimage && aScale > 0.) {
947 float zoom = aScale;
948 status = Xw_zoom_image (pimage,zoom);
949 }
950
951 if (status == XW_SUCCESS && pimage) {
952 status = Xw_draw_image (MyExtendedDrawable, pimage, aX, aY);
953 } else if (pimage) {
954 status = Xw_draw_zoomed_image (MyExtendedDrawable, pimage, aX, aY, aScale);
955 if (status != XW_SUCCESS)
956 PrintError();
957 } else PrintError ();
958}
959
960void Xw_Driver::FillAndDrawImage (const Handle(Standard_Transient)& anImage, const Standard_ShortReal aX, const Standard_ShortReal aY, const Standard_Integer aWidth, const Standard_Integer aHeight, const Standard_Address anArrayOfPixels) {
961float oldr, oldg, oldb;
962int oldi = 0, oldj = 0, oldindex;
963int num;
964
965// Image 614x614 :
966// temps CPU avec Standard_Integer < 20 secondes
967// temps CPU avec register < 19 secondes
968Standard_Integer i, j;
969
970GRAPHIC2D_PIXEL *pixels;
971GRAPHIC2D_PIXEL pixel;
972
973 if ((aWidth > 0) && (aHeight > 0)) {
974 if( !MyImage ) {
975 MyImage = Xw_open_image (MyExtendedDrawable,
ec6a1aa7 976 (void*) (::HashCode (anImage, IntegerLast())),
7fd59977 977 int (aWidth),int (aHeight));
978 }
979 if( !MyImage ) {
980 PrintError() ;
981 } else {
982 switch (MyVisualClass) {
983 case (Xw_TOV_STATICGRAY) :
984 break;
985 case (Xw_TOV_GRAYSCALE) :
986 break;
987 case (Xw_TOV_STATICCOLOR) :
988 break;
989 case (Xw_TOV_PSEUDOCOLOR) :
990 pixels = (GRAPHIC2D_PIXEL *) anArrayOfPixels;
991
992 for (i=0; i<aHeight; i++) {
993 oldr = oldg = oldb = -1.0;
994 oldindex = -1;
995 num = 0;
996
997 for (j=0; j<aWidth; j++) {
998 pixel = *(pixels+aWidth*i+j);
999 if ((pixel.r == oldr) && (pixel.g == oldg)
1000 && (pixel.b == oldb)) num++;
1001 else {
1002 if (num) {
1003 status = Xw_get_color_index (
1004 MyExtendedColorMap,
1005 oldr, oldg, oldb, &oldindex);
1006 if (status) status = Xw_put_pixel (MyImage,
1007 oldi, oldj, oldindex, num);
1008 }
1009 num = 1;
1010 oldr = pixel.r;
1011 oldg = pixel.g;
1012 oldb = pixel.b;
1013 oldi = int (i);
1014 oldj = int (j);
1015 }
1016 }
1017
1018 // Fin de ligne
1019 status = Xw_get_color_index (MyExtendedColorMap,
1020 oldr, oldg, oldb, &oldindex);
1021 if (status)
1022 status = Xw_put_pixel (MyImage,
1023 oldi, oldj, oldindex, num);
1024
1025 }
1026 this->DrawImage (anImage, aX, aY);
1027 break;
1028 case (Xw_TOV_TRUECOLOR) :
1029 pixels = (GRAPHIC2D_PIXEL *) anArrayOfPixels;
1030
1031 for (i=0; i<aHeight; i++) {
1032 oldr = oldg = oldb = -1.0;
1033 num = 0;
1034
1035 for (j=0; j<aWidth; j++) {
1036 pixel = *(pixels+aWidth*i+j);
1037 if ((pixel.r == oldr) && (pixel.g == oldg)
1038 && (pixel.b == oldb)) num++;
1039 else {
1040 if (num) {
1041 status = Xw_put_rgbpixel (MyImage,
1042 oldi, oldj, oldr, oldg, oldb, num);
1043 }
1044 num = 1;
1045 oldr = pixel.r;
1046 oldg = pixel.g;
1047 oldb = pixel.b;
1048 oldi = int (i);
1049 oldj = int (j);
1050 }
1051 }
1052
1053 // Fin de ligne
1054 status = Xw_put_rgbpixel (MyImage,
1055 oldi, oldj, oldr, oldg, oldb, num);
1056 }
1057 this->DrawImage (anImage, aX, aY);
1058 break;
1059 case (Xw_TOV_DIRECTCOLOR) :
1060 case (Xw_TOV_DEFAULT) :
1061 case (Xw_TOV_PREFERRED_TRUECOLOR) :
1062 case (Xw_TOV_PREFERRED_PSEUDOCOLOR) :
1063 case (Xw_TOV_PREFERRED_OVERLAY) :
1064 case (Xw_TOV_OVERLAY) :
1065 // Cas impossible, mais plus de warning C++ :
1066 // switch ( Xw_TypeOfVisual ) with 6 cases
1067 // ( 9 enumerators)
1068 break;
1069 }
1070
1071 }
1072 }
1073}
1074
1075void Xw_Driver::FillAndDrawImage (const Handle(Standard_Transient)& anImage, const Standard_ShortReal aX, const Standard_ShortReal aY, const Standard_Integer anIndexOfLine, const Standard_Integer aWidth, const Standard_Integer aHeight, const Standard_Address anArrayOfPixels) {
1076float oldr, oldg, oldb;
1077int oldi = 0, oldj = 0, oldindex;
1078int num;
1079
1080// Image 614x614 :
1081// temps CPU avec Standard_Integer < 21 secondes
1082// temps CPU avec register < 20 secondes
1083Standard_Integer j;
1084
1085GRAPHIC2D_PIXEL *pixels;
1086GRAPHIC2D_PIXEL pixel;
1087
1088 if ((anIndexOfLine < 0) || (anIndexOfLine >= aHeight))
1089 Aspect_DriverError::Raise ("Bad Index in Xw_Driver::FillImage");
1090
1091 // Debut d'image
1092 if ((aWidth > 0) && (aHeight > 0) && (anIndexOfLine == 0)) {
1093 if( !MyImage ) {
1094 MyImage = Xw_open_image (MyExtendedDrawable,
ec6a1aa7 1095 (void*) (::HashCode (anImage, IntegerLast())),
7fd59977 1096 int (aWidth),int (aHeight));
1097 }
1098 }
1099 if ((aWidth > 0) && (aHeight > 0) && (anIndexOfLine >= 0)) {
1100 if( !MyImage ) {
1101 PrintError() ;
1102 }
1103 else {
1104 switch (MyVisualClass) {
1105 case (Xw_TOV_STATICGRAY) :
1106 break;
1107 case (Xw_TOV_GRAYSCALE) :
1108 break;
1109 case (Xw_TOV_STATICCOLOR) :
1110 break;
1111 case (Xw_TOV_PSEUDOCOLOR) :
1112 pixels = (GRAPHIC2D_PIXEL *) anArrayOfPixels;
1113
1114 oldr = oldg = oldb = -1.0;
1115 oldi = int (anIndexOfLine);
1116 oldindex = -1;
1117 num = 0;
1118
1119 for (j=0; j<aWidth; j++) {
1120 pixel = *(pixels+j);
1121 if ((pixel.r == oldr) && (pixel.g == oldg)
1122 && (pixel.b == oldb)) num++;
1123 else {
1124 if (num) {
1125 status = Xw_get_color_index (MyExtendedColorMap,
1126 oldr, oldg, oldb, &oldindex);
1127 if (status)
1128 status = Xw_put_pixel (MyImage,
1129 oldi, oldj, oldindex, num);
1130 }
1131 num = 1;
1132 oldr = pixel.r;
1133 oldg = pixel.g;
1134 oldb = pixel.b;
1135 oldj = int (j);
1136 }
1137 }
1138
1139 // Fin de ligne
1140 status = Xw_get_color_index (MyExtendedColorMap,
1141 oldr, oldg, oldb, &oldindex);
1142 if (status)
1143 status = Xw_put_pixel (MyImage,
1144 oldi, oldj, oldindex, num);
1145
1146 // Fin d'image
1147 if (anIndexOfLine == aHeight - 1)
1148 this->DrawImage (anImage, aX, aY);
1149 break;
1150 case (Xw_TOV_TRUECOLOR) :
1151 pixels = (GRAPHIC2D_PIXEL *) anArrayOfPixels;
1152
1153 oldr = oldg = oldb = -1.0;
1154 oldi = int (anIndexOfLine);
1155 num = 0;
1156
1157 for (j=0; j<aWidth; j++) {
1158 pixel = *(pixels+j);
1159 if ((pixel.r == oldr) && (pixel.g == oldg)
1160 && (pixel.b == oldb)) num++;
1161 else {
1162 if (num) {
1163 status = Xw_put_rgbpixel (MyImage,
1164 oldi, oldj, oldr, oldg, oldb, num);
1165 }
1166 num = 1;
1167 oldr = pixel.r;
1168 oldg = pixel.g;
1169 oldb = pixel.b;
1170 oldj = int (j);
1171 }
1172 }
1173
1174 // Fin de ligne
1175 status = Xw_put_rgbpixel (MyImage,
1176 oldi, oldj, oldr, oldg, oldb, num);
1177
1178 // Fin d'image
1179 if (anIndexOfLine == aHeight - 1)
1180 this->DrawImage (anImage, aX, aY);
1181 break;
1182 case (Xw_TOV_DIRECTCOLOR) :
1183 case (Xw_TOV_DEFAULT) :
1184 case (Xw_TOV_PREFERRED_PSEUDOCOLOR) :
1185 case (Xw_TOV_PREFERRED_TRUECOLOR) :
1186 case (Xw_TOV_PREFERRED_OVERLAY) :
1187 case (Xw_TOV_OVERLAY) :
1188 // Cas impossible, mais plus de warning C++ :
1189 // switch ( Xw_TypeOfVisual ) with 6 cases
1190 // ( 9 enumerators)
1191 break;
1192 }
1193
1194 }
1195 }
1196}
1197
1198// Category: Methods to draw primitives
1199
1200void Xw_Driver::DrawPolygon (const TShort_Array1OfShortReal& aListX, const TShort_Array1OfShortReal& aListY) {
1201int npoint = (int)aListX.Length () ;
1202float *X = (float*) &aListX.Value(aListX.Lower()) ;
1203float *Y = (float*) &aListY.Value(aListY.Lower()) ;
1204
1205 if( npoint != (int)aListY.Length () )
1206 Aspect_DriverError::Raise ("2 differents lengths!") ;
1207
1208 if( npoint > 0 ) {
1209 status = Xw_draw_poly(MyExtendedDrawable,npoint,X,Y) ;
1210 if( !status ) PrintError() ;
1211 }
1212}
1213
1214void Xw_Driver::DrawPolyline (const TShort_Array1OfShortReal& aListX, const TShort_Array1OfShortReal& aListY) {
1215int npoint = (int)aListX.Length () ;
1216float *X = (float*) &aListX.Value(aListX.Lower()) ;
1217float *Y = (float*) &aListY.Value(aListY.Lower()) ;
1218
1219 if( npoint != (int)aListY.Length () )
1220 Aspect_DriverError::Raise ("2 differents lengths!") ;
1221
1222 if( npoint > 0 ) {
1223 status = Xw_draw_line(MyExtendedDrawable,npoint,X,Y) ;
1224 if( !status ) PrintError() ;
1225 }
1226}
1227
1228void Xw_Driver::DrawSegment (const Standard_ShortReal X1, const Standard_ShortReal Y1, const Standard_ShortReal X2, const Standard_ShortReal Y2) {
1229
1230 status = Xw_draw_segment (MyExtendedDrawable, X1, Y1, X2, Y2);
1231
1232 if( !status ) PrintError() ;
1233
1234}
1235
1236void Xw_Driver::DrawText (const TCollection_ExtendedString& aText, const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Standard_ShortReal Angle , const Aspect_TypeOfText aType) {
1237
1238 if( aText.Length() > 0 ) {
1239#ifdef MFT
1240 Standard_Integer font = (MyTextFont < 0) ? 0 :
1241 MyFontIndexs->Value(MyTextFont) ;
1242 if( font < 0 ) {
1243 Handle(MFT_FontManager) theFontManager =
1244 MyMFTFonts->Value(MyTextFont);
1245 if( !aText.IsAscii() && !theFontManager->IsComposite() ) {
1246 cout << "*ERROR*Xw_Driver::DrawText.UNABLE to draw an extended text with an ANSI font" << endl;
1247 return;
1248 }
1249 Standard_Real underlinePosition =
1250 (MyTextIsUnderlined) ? theFontManager->UnderlinePosition() : 0.;
1251 Standard_Integer theTextColor;
1252 if( MyTextColor > 0 ) {
1253 theTextColor = MyColorIndexs->Value(MyTextColor) ;
1254 } else {
1255 Xw_get_background_index(MyExtendedDrawable,&theTextColor) ;
1256 }
1257 Aspect_TypeOfText theTextType = aType;
1258 MyTextManager->SetTextAttribs(theTextColor,theTextType,underlinePosition);
1259 theFontManager->DrawText(MyTextManager,aText.ToExtString(),
1260 Quantity_Length(Xpos),Quantity_Length(Ypos),
1261 Quantity_PlaneAngle(Angle));
1262 } else
1263#endif
1264 if( aText.IsAscii() ) {
1265 TCollection_AsciiString atext(aText,'?');
1266 status = Xw_draw_text (MyExtendedDrawable,
1267 Xpos,
1268 Ypos,
1269 (Standard_PCharacter)atext.ToCString (),
1270 Angle,
1271 (int)aType);
1272 } else status = XW_ERROR ; /*Must be Implemented more later*/
1273
1274 if( !status ) PrintError() ;
1275 }
1276}
1277
1278void Xw_Driver::DrawText (const Standard_CString aText, const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Standard_ShortReal Angle , const Aspect_TypeOfText aType) {
1279
1280 if( strlen(aText) > 0 ) {
1281 TCollection_ExtendedString etext(aText);
1282 this->DrawText(etext,Xpos,Ypos,Angle,aType);
1283 }
1284}
1285
1286void Xw_Driver::DrawPolyText (const TCollection_ExtendedString& aText, const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Quantity_Factor aMarge, const Standard_ShortReal Angle , const Aspect_TypeOfText aType) {
1287Standard_ShortReal marge = aMarge ;
1288
1289 if( aText.Length() > 0 ) {
1290#ifdef MFT
1291 Standard_Integer font = (MyTextFont < 0) ? 0 :
1292 MyFontIndexs->Value(MyTextFont) ;
1293 if( font < 0 ) {
1294 Handle(MFT_FontManager) theFontManager =
1295 MyMFTFonts->Value(MyTextFont);
1296 if( !aText.IsAscii() && !theFontManager->IsComposite() ) {
1297 cout << "*ERROR*Xw_Driver::DrawPolyText.UNABLE to draw an extended text with an ANSI font" << endl;
1298 return;
1299 }
1300 Standard_Real underlinePosition =
1301 (MyTextIsUnderlined) ? theFontManager->UnderlinePosition() : 0.;
1302 Standard_ShortReal width,height,xoffset,yoffset,marge;
1303 this->TextSize(aText,width,height,xoffset,yoffset,MyTextFont) ;
1304 if( underlinePosition > yoffset ) yoffset = underlinePosition;
1305 marge = height * aMarge;
1306 xoffset -= marge;
1307 yoffset += marge;
1308 width += 2.*marge;
1309 height += 2.*marge;
1310 if( MyPolyTile < 0 ) {
1311 this->DrawRectangle(Xpos,Ypos,Angle,xoffset,yoffset,width,height);
1312 } else {
1313 this->FillRectangle(Xpos,Ypos,Angle,xoffset,yoffset,width,height);
1314 }
1315 Standard_Integer theTextColor;
1316 if( (MyTextColor > 0) && ((MyTextColor != MyPolyColor) ||
1317 (MyPolyTile < 0)) ) {
1318 theTextColor = MyColorIndexs->Value(MyTextColor) ;
1319 } else {
1320 Xw_get_background_index(MyExtendedDrawable,&theTextColor) ;
1321 }
1322 Aspect_TypeOfText theTextType = aType;
1323 MyTextManager->SetTextAttribs(theTextColor,theTextType,underlinePosition);
1324 theFontManager->DrawText(MyTextManager,aText.ToExtString(),
1325 Quantity_Length(Xpos),Quantity_Length(Ypos),
1326 Quantity_PlaneAngle(Angle));
1327 } else
1328#endif
1329 if( aText.IsAscii() ) {
1330 TCollection_AsciiString atext(aText,'?');
1331 status = Xw_draw_polytext (MyExtendedDrawable,
1332 Xpos,
1333 Ypos,
1334 (Standard_PCharacter)atext.ToCString (),
1335 Angle,
1336 marge,
1337 (int)aType);
1338 } else status = XW_ERROR ; /*Must be Implemented more later*/
1339
1340 if( !status ) PrintError() ;
1341 }
1342}
1343
1344void Xw_Driver::DrawPolyText (const Standard_CString aText, const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Quantity_Factor aMarge, const Standard_ShortReal Angle , const Aspect_TypeOfText aType) {
1345//Standard_ShortReal marge = aMarge ;
1346
1347 if( strlen(aText) > 0 ) {
1348 TCollection_ExtendedString etext(aText);
1349 DrawPolyText(etext,Xpos,Ypos,aMarge,Angle,aType);
1350 }
1351}
1352
1353void Xw_Driver::DrawMarker (const Standard_Integer aMarker, const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Standard_ShortReal Width, const Standard_ShortReal Height, const Standard_ShortReal Angle ) {
1354int marker = -1;
1355float width = TOMILLIMETER(Width);
1356float height = TOMILLIMETER(Height);
1357
1358 if( !MyMarkerIndexs.IsNull() ) {
1359 if( aMarker >= MyMarkerIndexs->Lower()
1360 && aMarker <= MyMarkerIndexs->Upper() ) {
1361 marker = MyMarkerIndexs->Value(aMarker);
1362 }
1363 }
1364
1365#ifdef PRO17334
1366 if( aMarker < 0 )
1367 Aspect_DriverError::Raise ("Bad Marker Index") ;
1368 if( aMarker > 0 ) {
1369#else
1370 if( aMarker >= 0 ) {
1371#endif
1372 status = Xw_draw_marker (MyExtendedDrawable, marker, Xpos, Ypos,
1373 width, height, Angle) ;
1374 } else {
1375 status = Xw_draw_point (MyExtendedDrawable, Xpos, Ypos) ;
1376 }
1377
1378 if( !status ) PrintError() ;
1379}
1380
1381Standard_Boolean Xw_Driver::DrawArc (const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Standard_ShortReal aXradius, const Standard_ShortReal aYradius, const Standard_ShortReal aStartAngle, const Standard_ShortReal aOpenAngle) {
1382
1383 status = Xw_draw_arc(MyExtendedDrawable, Xpos, Ypos,
1384 aXradius, aYradius, aStartAngle, aOpenAngle);
1385 if( !status ) PrintError() ;
1386
1387 return status;
1388}
1389
1390Standard_Boolean Xw_Driver::DrawPolyArc (const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Standard_ShortReal aXradius, const Standard_ShortReal aYradius, const Standard_ShortReal aStartAngle, const Standard_ShortReal aOpenAngle) {
1391
1392 status = Xw_draw_polyarc(MyExtendedDrawable, Xpos, Ypos,
1393 aXradius, aYradius, aStartAngle, aOpenAngle);
1394 if( !status ) PrintError() ;
1395
1396 return status;
1397}
1398
1399void Xw_Driver::BeginPolyline (const Standard_Integer aNumber) {
1400
1401 if( MyPrimitiveType != Aspect_TOP_UNKNOWN ) ClosePrimitive();
1402
1403 if( aNumber < 0 ) return;
1404
1405 status = Xw_begin_line (MyExtendedDrawable, aNumber) ;
1406 if( status ) {
1407 MyPrimitiveType = Aspect_TOP_POLYLINE;
1408 } else {
1409 PrintError() ;
1410 }
1411}
1412
1413void Xw_Driver::BeginPolygon (const Standard_Integer aNumber) {
1414
1415 if( MyPrimitiveType != Aspect_TOP_UNKNOWN ) ClosePrimitive();
1416
1417 if( aNumber < 0 ) return;
1418
1419 status = Xw_begin_poly (MyExtendedDrawable, aNumber, 0) ;
1420 if( status ) {
1421 MyPrimitiveType = Aspect_TOP_POLYGON;
1422 } else {
1423 PrintError() ;
1424 }
1425}
1426
1427void Xw_Driver::BeginSegments () {
1428
1429 if( MyPrimitiveType != Aspect_TOP_UNKNOWN ) ClosePrimitive();
1430
1431 status = Xw_begin_segments (MyExtendedDrawable, 0) ;
1432 if( status ) {
1433 MyPrimitiveType = Aspect_TOP_SEGMENTS;
1434 } else {
1435 PrintError() ;
1436 }
1437}
1438
1439void Xw_Driver::BeginArcs () {
1440
1441 if( MyPrimitiveType != Aspect_TOP_UNKNOWN ) ClosePrimitive();
1442
1443 status = Xw_begin_arcs (MyExtendedDrawable, 0) ;
1444 if( status ) {
1445 MyPrimitiveType = Aspect_TOP_ARCS;
1446 } else {
1447 PrintError() ;
1448 }
1449}
1450
1451void Xw_Driver::BeginPolyArcs () {
1452
1453 if( MyPrimitiveType != Aspect_TOP_UNKNOWN ) ClosePrimitive();
1454
1455 status = Xw_begin_polyarcs (MyExtendedDrawable, 0) ;
1456 if( status ) {
1457 MyPrimitiveType = Aspect_TOP_POLYARCS;
1458 } else {
1459 PrintError() ;
1460 }
1461}
1462
1463void Xw_Driver::BeginMarkers () {
1464
1465 if( MyPrimitiveType != Aspect_TOP_UNKNOWN ) ClosePrimitive();
1466
1467 status = Xw_begin_markers (MyExtendedDrawable, 0) ;
1468 if( status ) {
1469 MyPrimitiveType = Aspect_TOP_MARKERS;
1470 } else {
1471 PrintError() ;
1472 }
1473}
1474
1475void Xw_Driver::BeginPoints () {
1476
1477 if( MyPrimitiveType != Aspect_TOP_UNKNOWN ) ClosePrimitive();
1478
1479 status = Xw_begin_points (MyExtendedDrawable, 0) ;
1480 if( status ) {
1481 MyPrimitiveType = Aspect_TOP_POINTS;
1482 } else {
1483 PrintError() ;
1484 }
1485}
1486
1487void Xw_Driver::DrawPoint (const Standard_ShortReal X, const Standard_ShortReal Y) {
1488 switch( MyPrimitiveType ) {
1489 case Aspect_TOP_POLYLINE:
1490 status = Xw_line_point (MyExtendedDrawable, X, Y) ;
1491 break;
1492 case Aspect_TOP_POLYGON:
1493 status = Xw_poly_point (MyExtendedDrawable, X, Y) ;
1494 break;
1495 default:
1496 status = Xw_draw_point (MyExtendedDrawable, X, Y) ;
1497 }
1498
1499 if( !status ) {
1500 PrintError() ;
1501 }
1502}
1503
1504void Xw_Driver::ClosePrimitive () {
1505
1506 switch( MyPrimitiveType ) {
1507 case Aspect_TOP_POLYLINE:
1508 status = Xw_close_line (MyExtendedDrawable) ;
1509 break;
1510 case Aspect_TOP_POLYGON:
1511 status = Xw_close_poly (MyExtendedDrawable) ;
1512 break;
1513 case Aspect_TOP_SEGMENTS:
1514 status = Xw_close_segments (MyExtendedDrawable) ;
1515 break;
1516 case Aspect_TOP_ARCS:
1517 status = Xw_close_arcs (MyExtendedDrawable) ;
1518 break;
1519 case Aspect_TOP_POLYARCS:
1520 status = Xw_close_polyarcs (MyExtendedDrawable) ;
1521 break;
1522 case Aspect_TOP_MARKERS:
1523 status = Xw_close_markers (MyExtendedDrawable) ;
1524 break;
1525 case Aspect_TOP_POINTS:
1526 status = Xw_close_points (MyExtendedDrawable) ;
1527 break;
1528 default:
1529 MyPrimitiveType = Aspect_TOP_UNKNOWN;
1530 }
1531 MyPrimitiveType = Aspect_TOP_UNKNOWN;
1532 if( !status ) PrintError() ;
1533}
1534
1535void Xw_Driver::WorkSpace ( Quantity_Length &Width, Quantity_Length &Height ) const {
1536
1537#ifdef OPTIM1
1538int width,height ;
1539 status = Xw_get_window_size(MyExtendedDrawable,&width,&height) ;
1540
1541 if( !status ) {
1542 Xw_print_error() ;
1543 }
1544#else
1545XW_WINDOWSTATE state ;
1546int xc,yc,width,height ;
1547
1548 state = Xw_get_window_position(MyExtendedDrawable,
1549 &xc,&yc,&width,&height) ;
1550
1551 if( state == XW_WS_UNKNOWN ) {
1552 Xw_print_error() ;
1553 }
1554#endif
1555
1556#ifdef CTS50024
1557 float x,y ;
1558 status = Xw_get_window_pixelcoord(MyExtendedDrawable,
1559 width,0,&x,&y) ;
1560 if( !status ) {
1561 PrintError() ;
1562 }
1563
1564 Width = Quantity_Length(x); Height = Quantity_Length(y);
1565#else
1566 Width = Xw_get_window_pixelvalue(MyExtendedDrawable,width) ;
1567 Height = Xw_get_window_pixelvalue(MyExtendedDrawable,height) ;
1568#endif
1569}
1570
1571Quantity_Length Xw_Driver::Convert (const Standard_Integer Pv) const {
1572Standard_ShortReal Dv ;
1573
1574 Dv = Xw_get_window_pixelvalue(MyExtendedDrawable,(int)Pv) ;
1575
1576 return Quantity_Length(Dv) ;
1577}
1578
1579void Xw_Driver::Convert (const Standard_Integer Px, const Standard_Integer Py, Quantity_Length &Dx, Quantity_Length &Dy ) const {
1580float x,y ;
1581
1582 status = Xw_get_window_pixelcoord(MyExtendedDrawable,
1583 (int)Px,(int)Py,&x,&y) ;
1584
1585 if( !status ) {
1586 PrintError() ;
1587 }
1588
1589 Dx = Quantity_Length(x) ; Dy = Quantity_Length(y) ;
1590}
1591
1592Standard_Integer Xw_Driver::Convert (const Quantity_Length Dv) const {
1593Standard_Integer Pv ;
1594
1595 Pv = Xw_get_pixel_windowvalue(MyExtendedDrawable,(float)Dv) ;
1596
1597 return (Pv) ;
1598}
1599
1600void Xw_Driver::Convert (const Quantity_Length Dx, const Quantity_Length Dy, Standard_Integer &Px, Standard_Integer &Py ) const {
1601int x,y ;
1602
1603 status = Xw_get_pixel_windowcoord(MyExtendedDrawable,
1604 (float)Dx,(float)Dy,&x,&y) ;
1605
1606 if( !status ) {
1607 PrintError() ;
1608 }
1609
1610 Px = x ; Py = y ;
1611}
1612
1613void Xw_Driver::TextSize (const TCollection_ExtendedString& aText, Standard_ShortReal& Width, Standard_ShortReal& Height, const Standard_Integer aFontIndex ) const {
1614Standard_ShortReal xoffset,yoffset;
1615
1616 this->TextSize(aText,Width,Height,xoffset,yoffset,aFontIndex) ;
1617}
1618
1619void Xw_Driver::TextSize (const TCollection_ExtendedString& aText, Standard_ShortReal& Width, Standard_ShortReal& Height, Standard_ShortReal& Xoffset, Standard_ShortReal& Yoffset, const Standard_Integer aFontIndex ) const {
1620
1621Standard_Integer theFont = (aFontIndex >= 0 ) ? aFontIndex : MyTextFont ;
1622
1623 if( !MyFontIndexs.IsNull() ) {
1624 if( theFont < MyFontIndexs->Lower() ||
1625 theFont > MyFontIndexs->Upper() ) {
1626 Aspect_DriverError::Raise ("Bad Font Index") ;
1627 }
1628 }
1629 Standard_Integer font = (theFont < 0) ? 0 :
1630 MyFontIndexs->Value(theFont) ;
1631#ifdef MFT
1632 if( font < 0 ) {
1633 Handle(MFT_FontManager) theFontManager =
1634 MyMFTFonts->Value(theFont);
1635 Quantity_Length theWidth = 0.,theAscent = 0.,theLbearing = 0.,theDescent = 0.;
1636 if( aText.IsAscii() ) {
1637 TCollection_AsciiString atext(aText,'?');
1638 theFontManager->TextSize(atext.ToCString(),
1639 theWidth,theAscent,theLbearing,theDescent);
1640 } else if( theFontManager->IsComposite() ) {
1641 theFontManager->TextSize(aText.ToExtString(),
1642 theWidth,theAscent,theLbearing,theDescent);
1643 } else {
1644// cout << "*ERROR*Xw_Driver::TextSize(...).Try to gets extended text size with an ANSI font" << endl;
1645 }
1646 if( MyTextIsUnderlined ) {
1647 Quantity_Length theUnderlinePosition =
1648 theFontManager->UnderlinePosition();
1649 theDescent = Max(theDescent,theUnderlinePosition);
1650 }
1651 Width = theWidth;
1652 Height = theAscent + theDescent;
1653 Xoffset = theLbearing;
1654 Yoffset = theDescent;
1655 return;
1656 }
1657#endif
1658 if (aText.IsAscii ()) {
1659 TCollection_AsciiString atext(aText,'?');
1660 status = Xw_get_text_size (MyExtendedDrawable,
1661 font,
1662 (Standard_PCharacter)atext.ToCString(),
1663 &Width,
1664 &Height,
1665 &Xoffset,
1666 &Yoffset) ;
1667 if( !status ) PrintError() ;
1668 } else { /*Must be Implemented more later*/
1669 Width = Height = Xoffset = Yoffset = 0.;
1670 }
1671}
1672
1673void Xw_Driver::TextSize (const Standard_CString aText, Standard_ShortReal& Width, Standard_ShortReal& Height, Standard_ShortReal& Xoffset, Standard_ShortReal& Yoffset, const Standard_Integer aFontIndex) const {
1674//Standard_Integer theFont = (aFontIndex >= 0 ) ? aFontIndex : MyTextFont ;
1675
1676 TCollection_ExtendedString etext(aText);
1677 this->TextSize(etext,Width,Height,Xoffset,Yoffset,aFontIndex);
1678}
1679
1680Standard_CString Xw_Driver::FontSize (Quantity_PlaneAngle &aSlant, Standard_ShortReal &aSize, Standard_ShortReal &aBheight, const Standard_Integer aFontIndex) const {
1681Standard_Integer theFont = (aFontIndex >= 0 ) ? aFontIndex : MyTextFont ;
1682Standard_CString fstring;
1683float size,bheight;
1684
1685 if( !MyFontIndexs.IsNull() ) {
1686 if( theFont < MyFontIndexs->Lower() ||
1687 theFont > MyFontIndexs->Upper() ) {
1688 return NULL ;
1689 }
1690 }
1691 Standard_Integer font = (theFont < 0) ? 0 :
1692 MyFontIndexs->Value(theFont) ;
1693#ifdef MFT
1694 if( font < 0 ) {
1695 Handle(MFT_FontManager) theFontManager =
1696 MyMFTFonts->Value(theFont);
1697 Quantity_Length theWidth,theHeight,theDescent;
1698 Quantity_PlaneAngle theSlant;
1699 Quantity_Factor thePrecision;
1700 Standard_Boolean theCapsHeight;
1701 fstring = theFontManager->FontAttribs(
1702 theWidth,theHeight,theDescent,theSlant,thePrecision,theCapsHeight);
1703 aSize = theHeight;
1704 aBheight = theDescent;
1705 aSlant = theSlant;
1706 return fstring;
1707 }
1708#endif
1709 fstring = Xw_get_font (MyExtendedFontMap,font,&size,&bheight);
1710 if( !fstring ) PrintError() ;
1711
1712 aSlant = 0.; // To be implemented
1713 aSize = FROMMILLIMETER(size);
1714 aBheight = FROMMILLIMETER(bheight);
1715 return fstring;
1716
1717}
1718
1719void Xw_Driver::AngleOfBuffer(const Standard_Integer aRetainBuffer,Quantity_PlaneAngle &anAngle) const {
1720Standard_ShortReal xpivot,ypivot,xscale,yscale,angle ;
1721
1722 status = Xw_get_buffer_info(MyExtendedDrawable,aRetainBuffer,
1723 &xpivot,&ypivot,&xscale,&yscale,&angle) ;
1724
1725 anAngle = angle ;
1726}
1727
1728void Xw_Driver::ScaleOfBuffer(const Standard_Integer aRetainBuffer,Quantity_Factor &aScaleX,Quantity_Factor &aScaleY) const {
1729Standard_ShortReal xpivot,ypivot,xscale,yscale,angle ;
1730
1731 status = Xw_get_buffer_info(MyExtendedDrawable,aRetainBuffer,
1732 &xpivot,&ypivot,&xscale,&yscale,&angle) ;
1733
1734 aScaleX = xscale ;
1735 aScaleY = yscale ;
1736}
1737
1738void Xw_Driver::PositionOfBuffer(const Standard_Integer aRetainBuffer,Standard_ShortReal &aPivotX,Standard_ShortReal &aPivotY) const {
1739Standard_ShortReal xpivot,ypivot,xscale,yscale,angle ;
1740
1741 status = Xw_get_buffer_info(MyExtendedDrawable,aRetainBuffer,
1742 &xpivot,&ypivot,&xscale,&yscale,&angle) ;
1743
1744 aPivotX = xpivot ;
1745 aPivotY = ypivot ;
1746}
1747
1748void Xw_Driver::ColorBoundIndexs(Standard_Integer &aMinIndex, Standard_Integer &aMaxIndex) const {
1749
1750 if( MyColorIndexs.IsNull() ) {
1751 aMinIndex = aMaxIndex = 0;
1752 } else {
1753 aMinIndex = MyColorIndexs->Lower() ;
1754 aMaxIndex = MyColorIndexs->Upper() ;
1755 }
1756}
1757
1758Standard_Integer Xw_Driver::LocalColorIndex(const Standard_Integer anIndex) const {
1759
1760 if( (anIndex < MyColorIndexs->Lower()) ||
1761 (anIndex > MyColorIndexs->Upper()) ) return (-1);
1762
1763 return MyColorIndexs->Value(anIndex);
1764}
1765
1766void Xw_Driver::FontBoundIndexs(Standard_Integer &aMinIndex, Standard_Integer &aMaxIndex) const {
1767
1768 if( MyFontIndexs.IsNull() ) {
1769 aMinIndex = aMaxIndex = 0;
1770 } else {
1771 aMinIndex = MyFontIndexs->Lower() ;
1772 aMaxIndex = MyFontIndexs->Upper() ;
1773 }
1774}
1775
1776Standard_Integer Xw_Driver::LocalFontIndex(const Standard_Integer anIndex) const {
1777
1778 if( (anIndex < MyFontIndexs->Lower()) ||
1779 (anIndex > MyFontIndexs->Upper()) ) return (-1);
1780
1781 return MyFontIndexs->Value(anIndex);
1782}
1783
1784void Xw_Driver::TypeBoundIndexs(Standard_Integer &aMinIndex, Standard_Integer &aMaxIndex) const {
1785
1786 if( MyTypeIndexs.IsNull() ) {
1787 aMinIndex = aMaxIndex = 0;
1788 } else {
1789 aMinIndex = MyTypeIndexs->Lower() ;
1790 aMaxIndex = MyTypeIndexs->Upper() ;
1791 }
1792}
1793
1794Standard_Integer Xw_Driver::LocalTypeIndex(const Standard_Integer anIndex) const {
1795
1796 if( (anIndex < MyTypeIndexs->Lower()) ||
1797 (anIndex > MyTypeIndexs->Upper()) ) return (-1);
1798
1799 return MyTypeIndexs->Value(anIndex);
1800}
1801
1802void Xw_Driver::WidthBoundIndexs(Standard_Integer &aMinIndex, Standard_Integer &aMaxIndex) const {
1803
1804 if( MyWidthIndexs.IsNull() ) {
1805 aMinIndex = aMaxIndex = 0;
1806 } else {
1807 aMinIndex = MyWidthIndexs->Lower() ;
1808 aMaxIndex = MyWidthIndexs->Upper() ;
1809 }
1810}
1811
1812Standard_Integer Xw_Driver::LocalWidthIndex(const Standard_Integer anIndex) const {
1813
1814 if( (anIndex < MyWidthIndexs->Lower()) ||
1815 (anIndex > MyWidthIndexs->Upper()) ) return (-1);
1816
1817 return MyWidthIndexs->Value(anIndex);
1818}
1819
1820void Xw_Driver::MarkBoundIndexs(Standard_Integer &aMinIndex, Standard_Integer &aMaxIndex) const {
1821
1822 if( MyMarkerIndexs.IsNull() ) {
1823 aMinIndex = aMaxIndex = 0;
1824 } else {
1825 aMinIndex = MyMarkerIndexs->Lower() ;
1826 aMaxIndex = MyMarkerIndexs->Upper() ;
1827 }
1828}
1829
1830Standard_Integer Xw_Driver::LocalMarkIndex(const Standard_Integer anIndex) const {
1831
1832 if( (anIndex < MyMarkerIndexs->Lower()) ||
1833 (anIndex > MyMarkerIndexs->Upper()) ) return (-1);
1834
1835 return MyMarkerIndexs->Value(anIndex);
1836}
1837
1838void Xw_Driver::DrawRectangle(const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Standard_ShortReal Angle, const Standard_ShortReal Xoffset, const Standard_ShortReal Yoffset, const Standard_ShortReal Width, const Standard_ShortReal Height) const {
1839Standard_ShortReal xpoly,ypoly;
1840
1841 theSinAngle = Sin(Angle);
1842 theCosAngle = Cos(Angle);
1843 Xw_begin_line(MyExtendedDrawable,5);
1844 xpoly = Xoffset;
1845 ypoly = -Yoffset;
1846 TRANSFORM(xpoly,ypoly);
1847 Xw_line_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly);
1848 xpoly = Xoffset + Width;
1849 ypoly = -Yoffset;
1850 TRANSFORM(xpoly,ypoly);
1851 Xw_line_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly);
1852 xpoly = Xoffset + Width;
1853 ypoly = Height - Yoffset;
1854 TRANSFORM(xpoly,ypoly);
1855 Xw_line_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly);
1856 xpoly = Xoffset;
1857 ypoly = Height - Yoffset;
1858 TRANSFORM(xpoly,ypoly);
1859 Xw_line_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly);
1860 xpoly = Xoffset;
1861 ypoly = -Yoffset;
1862 TRANSFORM(xpoly,ypoly);
1863 Xw_line_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly);
1864 Xw_close_line(MyExtendedDrawable);
1865}
1866
1867void Xw_Driver::FillRectangle(const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Standard_ShortReal Angle, const Standard_ShortReal Xoffset, const Standard_ShortReal Yoffset, const Standard_ShortReal Width, const Standard_ShortReal Height) const {
1868Standard_ShortReal xpoly,ypoly;
1869
1870 theSinAngle = Sin(Angle);
1871 theCosAngle = Cos(Angle);
1872 Xw_begin_poly(MyExtendedDrawable,4,0);
1873 xpoly = Xoffset;
1874 ypoly = -Yoffset;
1875 TRANSFORM(xpoly,ypoly);
1876 Xw_poly_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly);
1877 xpoly = Xoffset + Width;
1878 ypoly = -Yoffset;
1879 TRANSFORM(xpoly,ypoly);
1880 Xw_poly_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly);
1881 xpoly = Xoffset + Width;
1882 ypoly = Height - Yoffset;
1883 TRANSFORM(xpoly,ypoly);
1884 Xw_poly_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly);
1885 xpoly = Xoffset;
1886 ypoly = Height - Yoffset;
1887 TRANSFORM(xpoly,ypoly);
1888 Xw_poly_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly);
1889 Xw_close_poly(MyExtendedDrawable);
1890}