0023830: BRepExtrema_DistShapeShape does not find intersection of face with edge
[occt.git] / src / Xw / Xw_draw_buffer.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18#define CTS50025 /*GG_080997
b311480e 19Preinitialiser la police de caracteres du buffer sinon
7fd59977 20 plantage au chargement
21*/
22
23#define PRO11005 /*GG_131197
24// La couleur de fond du paragraphe n'est pas respectee
25// En mode Highlight,on ne voit plus les textes.
26*/
27
28
29#include <Xw_Extension.h>
30
31 /* ifdef then trace on */
32#ifdef TRACE
33#define TRACE_DRAW_BUFFER
34#endif
35
36#define XROTATE(x,y) (x*cosa + y*sina)
37#define YROTATE(x,y) (y*cosa - x*sina)
38#define UNKNOWN_BUFFER 0
39#define MOVE_BUFFER 1
40#define ROTATE_BUFFER 2
41#define SCALE_BUFFER 3
42
43/*
44 STATUS Xw_draw_buffer (awindow,bufferid)
45 XW_EXT_WINDOW *awindow
46 int bufferid
47
48 Draw one retain buffer of primitives at screen
49
50 Returns ERROR if the extended window address is badly defined
51 or Buffer is empty
52 or Buffer is already drawn at screen
53 or Buffer is not opened
54 Returns SUCCESS if successful
55
56*/
57
58#ifdef XW_PROTOTYPE
59XW_STATUS Xw_draw_buffer (void* awindow,int bufferid)
60#else
61XW_STATUS Xw_draw_buffer (awindow,bufferid)
62void *awindow;
63int bufferid;
64#endif /*XW_PROTOTYPE*/
65{
66XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
67XW_EXT_BUFFER *pbuffer ;
68XW_STATUS status ;
69
70 if( !Xw_isdefine_window(pwindow) ) {
71 /*ERROR*Bad EXT_WINDOW Address*/
72 Xw_set_error(24,"Xw_draw_buffer",pwindow) ;
73 return (XW_ERROR) ;
74 }
75
76 if( bufferid > 0 ) {
77 pbuffer = Xw_get_buffer_structure(pwindow,bufferid) ;
78 if( !pbuffer ) {
79 /*ERROR*BUFFER is not opened*/
80 Xw_set_error(119,"Xw_draw_buffer",&bufferid) ;
81 return (XW_ERROR) ;
82 }
83 } else {
84 pbuffer = &_BUFFER(-bufferid) ;
85 if( !pbuffer->bufferid ) {
86 /*ERROR*BUFFER is not opened*/
87 return (XW_SUCCESS) ;
88 }
89 }
90
91 if( pbuffer->isempty ) return XW_ERROR ;
92
93 if( pbuffer->isdrawn && (QGMODE(pbuffer->code) == XW_XORBACK) )
94 return XW_ERROR ;
95
96 pbuffer->isdrawn = True ;
97
98 status = Xw_redraw_buffer(pwindow,pbuffer) ;
99
100 if( !pbuffer->isretain && (QGTYPE(pbuffer->code) == XW_ENABLE) ) {
101 int x,y,w,h ;
102 if( pbuffer->isupdated ) {
103 x = pbuffer->uxmin - 1 ;
104 y = pbuffer->uymin - 1 ;
105 w = pbuffer->uxmax - x + 1 ;
106 h = pbuffer->uymax - y + 1 ;
107 } else {
108 x = pbuffer->rxmin - 1 ;
109 y = pbuffer->rymin - 1 ;
110 w = pbuffer->rxmax - x + 1 ;
111 h = pbuffer->rymax - y + 1 ;
112 }
113
114 if( x < 0 ) x = 0 ;
115 if( y < 0 ) y = 0 ;
116 if( x+w > _WIDTH ) w = _WIDTH - x ;
117 if( y+h > _HEIGHT ) h = _HEIGHT - y ;
118
119 if( _NWBUFFER > 0 ) {
120 XCopyArea(_DISPLAY,_BWBUFFER,_FWBUFFER,
121 pwindow->qgwind.gccopy,x,y,w,h,x,y) ;
122 } else if( _PIXMAP ) {
123 XCopyArea(_DISPLAY,_PIXMAP,_WINDOW,
124 pwindow->qgwind.gccopy,x,y,w,h,x,y) ;
125 }
126 XFlush(_DISPLAY) ;
127 }
128
129#ifdef TRACE_DRAW_BUFFER
130 if( Xw_get_trace() ) {
131 printf (" Xw_draw_buffer(%lx,%d)\n",(long ) pwindow,bufferid) ;
132 }
133#endif
134
135 return status ;
136}
137
138#ifdef XW_PROTOTYPE
139XW_STATUS Xw_redraw_buffer (XW_EXT_WINDOW *pwindow,XW_EXT_BUFFER *pbuffer)
140#else
141XW_STATUS Xw_redraw_buffer (pwindow,pbuffer)
142XW_EXT_WINDOW *pwindow;
143XW_EXT_BUFFER *pbuffer ;
144#endif /*XW_PROTOTYPE*/
145{
146XW_EXT_IMAGE *pimaglist ;
147XW_EXT_POLY *ppolylist ;
148XW_EXT_LINE *plinelist ;
149XW_EXT_SEGMENT *pseglist ;
150XW_EXT_LTEXT *pltextlist ;
151XW_EXT_PTEXT *pptextlist ;
152XW_EXT_ARC *parclist ;
153XW_EXT_PMARKER *ppmarklist ;
154XW_EXT_LMARKER *plmarklist ;
155XW_EXT_POINT *ppntlist ;
156
157 if( QGTYPE(pbuffer->code) == XW_ENABLE ) {
158 _DRAWABLE = (_NWBUFFER > 0) ? _BWBUFFER : _PIXMAP ;
159 } else {
160 _DRAWABLE = (_NWBUFFER > 0) ? _FWBUFFER : _WINDOW ;
161 }
162
163 for( pimaglist = pbuffer->pimaglist ; pimaglist ;
164 pimaglist = (XW_EXT_IMAGE*)pimaglist->link ) {
165 if( pimaglist->nimage > 0 ) {
166 Xw_draw_pixel_images(pwindow,pimaglist,
167 pbuffer->gcf,pbuffer->gcf);
168 } else break ;
169 }
170
171 for( ppolylist = pbuffer->ppolylist ; ppolylist ;
172 ppolylist = (XW_EXT_POLY*)ppolylist->link ) {
173 if( ppolylist->npoly > 0 ) {
174#ifdef PRO11005
175 Xw_draw_pixel_polys(pwindow,ppolylist,NULL,pbuffer->gcf);
176#else
177 Xw_draw_pixel_polys(pwindow,ppolylist,pbuffer->gcf,NULL);
178#endif
179 } else break ;
180 }
181
182 for( parclist = pbuffer->pparclist ; parclist ;
183 parclist = (XW_EXT_ARC*)parclist->link ) {
184 if( parclist->narc > 0 ) {
185 Xw_draw_pixel_polyarcs(pwindow,parclist,pbuffer->gcf,NULL);
186 } else break ;
187 }
188
189 for( pseglist = pbuffer->pseglist ; pseglist ;
190 pseglist = (XW_EXT_SEGMENT*)pseglist->link ) {
191 if( pseglist->nseg > 0 ) {
192 Xw_draw_pixel_segments(pwindow,pseglist,pbuffer->gcf);
193 } else break ;
194 }
195
196 for( plinelist = pbuffer->plinelist ; plinelist ;
197 plinelist = (XW_EXT_LINE*)plinelist->link ) {
198 if( plinelist->nline > 0 ) {
199 Xw_draw_pixel_lines(pwindow,plinelist,pbuffer->gcf);
200 } else break ;
201 }
202
203 for( parclist = pbuffer->plarclist ; parclist ;
204 parclist = (XW_EXT_ARC*)parclist->link ) {
205 if( parclist->narc > 0 ) {
206 Xw_draw_pixel_arcs(pwindow,parclist,pbuffer->gcf);
207 } else break ;
208 }
209
210 for( pltextlist = pbuffer->pltextlist ; pltextlist ;
211 pltextlist = (XW_EXT_LTEXT*)pltextlist->link ) {
212 if( pltextlist->ntext > 0 ) {
213 Xw_draw_pixel_texts(pwindow,pltextlist,
214 pbuffer->gcf,pbuffer->code);
215 } else break ;
216 }
217
218 for( ppmarklist = pbuffer->ppmarklist ; ppmarklist ;
219 ppmarklist = (XW_EXT_PMARKER*)ppmarklist->link ) {
220 if( ppmarklist->nmark > 0 ) {
221 Xw_draw_pixel_pmarkers(pwindow,ppmarklist,pbuffer->gcf);
222 } else break ;
223 }
224
225 for( plmarklist = pbuffer->plmarklist ; plmarklist ;
226 plmarklist = (XW_EXT_LMARKER*)plmarklist->link ) {
227 if( plmarklist->nmark > 0 ) {
228 Xw_draw_pixel_lmarkers(pwindow,plmarklist,pbuffer->gcf);
229 } else break ;
230 }
231
232 for( pptextlist = pbuffer->pptextlist ; pptextlist ;
233 pptextlist = (XW_EXT_PTEXT*)pptextlist->link ) {
234 if( pptextlist->ntext > 0 ) {
235 Xw_draw_pixel_polytexts(pwindow,pptextlist,
236 pbuffer->gcf,NULL,pbuffer->gcf,pbuffer->code);
237 } else break ;
238 }
239
240 for( ppntlist = pbuffer->ppntlist ; ppntlist ;
241 ppntlist = (XW_EXT_POINT*)ppntlist->link ) {
242 if( ppntlist->npoint > 0 ) {
243 Xw_draw_pixel_points(pwindow,ppntlist,pbuffer->gcf);
244 } else break ;
245 }
246
247 XFlush(_DISPLAY) ;
248
249 return (XW_SUCCESS);
250}
251
252/*
253 STATUS Xw_erase_buffer (awindow,bufferid)
254 XW_EXT_WINDOW *awindow
255 int bufferid
256
257 Erase one retain buffer of primitives from screen
258
259 Returns ERROR if the extended window address is badly defined
260 or Buffer is empty
261 or Buffer is already erase from screen
262 or Buffer is not opened
263 Returns SUCCESS if successful
264
265*/
266
267#ifdef XW_PROTOTYPE
268XW_STATUS Xw_erase_buffer (void* awindow,int bufferid)
269#else
270XW_STATUS Xw_erase_buffer (awindow,bufferid)
271void *awindow;
272int bufferid;
273#endif /*XW_PROTOTYPE*/
274{
275XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
276XW_EXT_BUFFER *pbuffer ;
277XW_STATUS status = XW_SUCCESS ;
278int x,y,w,h ;
279
280 if( !Xw_isdefine_window(pwindow) ) {
281 /*ERROR*Bad EXT_WINDOW Address*/
282 Xw_set_error(24,"Xw_erase_buffer",pwindow) ;
283 return (XW_ERROR) ;
284 }
285
286 if( bufferid > 0 ) {
287 pbuffer = Xw_get_buffer_structure(pwindow,bufferid) ;
288 if( !pbuffer ) {
289 /*ERROR*BUFFER is not opened*/
290 Xw_set_error(119,"Xw_erase_buffer",&bufferid) ;
291 return (XW_ERROR) ;
292 }
293 } else {
294 pbuffer = &_BUFFER(-bufferid) ;
295 if( !pbuffer->bufferid ) {
296 /*ERROR*BUFFER is not opened*/
297 return (XW_SUCCESS) ;
298 }
299 }
300
301 if( pbuffer->isempty ) return XW_ERROR ;
302
303 if( !pbuffer->isdrawn && (QGMODE(pbuffer->code) == XW_XORBACK) )
304 return XW_ERROR ;
305
306 pbuffer->isdrawn = False ;
307 if( pbuffer->isupdated ) {
308 x = pbuffer->uxmin - 1 ;
309 y = pbuffer->uymin - 1 ;
310 w = pbuffer->uxmax - x + 1 ;
311 h = pbuffer->uymax - y + 1 ;
312 } else {
313 x = pbuffer->rxmin - 1 ;
314 y = pbuffer->rymin - 1 ;
315 w = pbuffer->rxmax - x + 1 ;
316 h = pbuffer->rymax - y + 1 ;
317 }
318
319 if( x < 0 ) x = 0 ;
320 if( y < 0 ) y = 0 ;
321 if( x+w > _WIDTH ) w = _WIDTH - x ;
322 if( y+h > _HEIGHT ) h = _HEIGHT - y ;
323
324 if( QGMODE(pbuffer->code) == XW_REPLACE ) {
325 /* Restore from MIN-MAX buffer pixmap */
326 if( _NWBUFFER > 0 ) {
327 XCopyArea(_DISPLAY,_BWBUFFER,_FWBUFFER,
328 pwindow->qgwind.gccopy,x,y,w,h,x,y) ;
329 } else if( _PIXMAP ) {
330 XCopyArea(_DISPLAY,_PIXMAP,_WINDOW,
331 pwindow->qgwind.gccopy,x,y,w,h,x,y) ;
332 } else {
333 XClearArea(_DISPLAY,_WINDOW,x,y,w,h,False);
334 }
335 XFlush(_DISPLAY) ;
336 } else if( QGMODE(pbuffer->code) == XW_XORBACK ) {
337 status = Xw_redraw_buffer(pwindow,pbuffer) ;
338 if( !pbuffer->isretain && (QGTYPE(pbuffer->code) == XW_ENABLE) ) {
339 if( _NWBUFFER > 0 ) {
340 XCopyArea(_DISPLAY,_BWBUFFER,_FWBUFFER,
341 pwindow->qgwind.gccopy,x,y,w,h,x,y) ;
342 } else if( _PIXMAP ) {
343 XCopyArea(_DISPLAY,_PIXMAP,_WINDOW,
344 pwindow->qgwind.gccopy,x,y,w,h,x,y) ;
345 }
346 XFlush(_DISPLAY) ;
347 }
348 }
349
350#ifdef TRACE_DRAW_BUFFER
351 if( Xw_get_trace() ) {
352 printf (" Xw_erase_buffer(%lx,%d)\n",(long ) pwindow,bufferid) ;
353 }
354#endif
355 return status ;
356}
357
358/*
359 XW_STATUS Xw_clear_buffer (awindow,bufferid)
360 XW_EXT_WINDOW *awindow
361 int bufferid
362
363 Erase and Clear one retain buffer of primitives from screen
364
365 Returns ERROR if the extended window address is badly defined
366 or Buffer is empty
367 or Buffer is not opened
368 Returns SUCCESS if successful
369
370*/
371
372#ifdef XW_PROTOTYPE
373XW_STATUS Xw_clear_buffer (void* awindow,int bufferid)
374#else
375XW_STATUS Xw_clear_buffer (awindow,bufferid)
376void *awindow;
377int bufferid ;
378#endif /*PROTOTYPE*/
379{
380XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
381XW_EXT_BUFFER *pbuffer ;
382XW_EXT_IMAGE *pimaglist ;
383XW_EXT_POLY *ppolylist ;
384XW_EXT_LINE *plinelist ;
385XW_EXT_SEGMENT *pseglist ;
386XW_EXT_LTEXT *pltextlist ;
387XW_EXT_PTEXT *pptextlist ;
388XW_EXT_ARC *parclist ;
389XW_EXT_PMARKER *ppmarklist ;
390XW_EXT_LMARKER *plmarklist ;
391XW_EXT_POINT *ppntlist ;
392XW_EXT_POINT *plinedesc ;
393XW_EXT_CHAR *ptextdesc ;
394
395 if( !Xw_isdefine_window(pwindow) ) {
396 /*ERROR*Bad EXT_WINDOW Address*/
397 Xw_set_error(24,"Xw_clear_buffer",pwindow) ;
398 return (XW_ERROR) ;
399 }
400
401 if( bufferid > 0 ) {
402 pbuffer = Xw_get_buffer_structure(pwindow,bufferid) ;
403 if( !pbuffer ) {
404 /*ERROR*BUFFER is not opened*/
405 Xw_set_error(119,"Xw_clear_buffer",&bufferid) ;
406 return (XW_ERROR) ;
407 }
408 } else {
409 pbuffer = &_BUFFER(-bufferid) ;
410 if( !pbuffer->bufferid ) {
411 /*ERROR*BUFFER is not opened*/
412 return (XW_SUCCESS) ;
413 }
414 }
415
416 if( pbuffer->isempty ) return XW_ERROR ;
417
418 if( pbuffer->isdrawn ) Xw_erase_buffer(pwindow,bufferid) ;
419
420 pbuffer->isempty = True ;
421 pbuffer->isupdated = UNKNOWN_BUFFER ;
422 pbuffer->rxmin = _WIDTH ;
423 pbuffer->rymin = _HEIGHT ;
424 pbuffer->rxmax = 0 ;
425 pbuffer->rymax = 0 ;
426 pbuffer->xscale = 1. ;
427 pbuffer->dxscale = 1. ;
428 pbuffer->yscale = 1. ;
429 pbuffer->dyscale = 1. ;
430 pbuffer->angle = 0. ;
431 pbuffer->dangle = 0. ;
432 pbuffer->dxpivot = 0 ;
433 pbuffer->dypivot = 0 ;
434
435 for( pimaglist = pbuffer->pimaglist ; pimaglist ;
436 pimaglist = (XW_EXT_IMAGE*)pimaglist->link ) {
437 if( pimaglist->nimage > 0 ) {
438 pimaglist->isupdated = False ;
439 pimaglist->nimage = 0 ;
440 } else break ;
441 }
442
443 for( ppolylist = pbuffer->ppolylist ; ppolylist ;
444 ppolylist = (XW_EXT_POLY*)ppolylist->link ) {
445 if( ppolylist->npoly > 0 ) {
446 ppolylist->isupdated = False ;
447 ppolylist->npoly = 0 ;
448 } else break ;
449 }
450
451 for( parclist = pbuffer->pparclist ; parclist ;
452 parclist = (XW_EXT_ARC*)parclist->link ) {
453 if( parclist->narc > 0 ) {
454 parclist->isupdated = False ;
455 parclist->narc = 0 ;
456 } else break ;
457 }
458
459 for( pseglist = pbuffer->pseglist ; pseglist ;
460 pseglist = (XW_EXT_SEGMENT*)pseglist->link ) {
461 if( pseglist->nseg > 0 ) {
462 pseglist->isupdated = False ;
463 pseglist->nseg = 0 ;
464 } else break ;
465 }
466
467 for( plinelist = pbuffer->plinelist ; plinelist ;
468 plinelist = (XW_EXT_LINE*)plinelist->link ) {
469 if( plinelist->nline > 0 ) {
470 plinelist->isupdated = False ;
471 plinelist->nline = 0 ;
472 } else break ;
473 }
474
475 for( parclist = pbuffer->plarclist ; parclist ;
476 parclist = (XW_EXT_ARC*)parclist->link ) {
477 if( parclist->narc > 0 ) {
478 parclist->isupdated = False ;
479 parclist->narc = 0 ;
480 } else break ;
481 }
482
483 for( pltextlist = pbuffer->pltextlist ; pltextlist ;
484 pltextlist = (XW_EXT_LTEXT*)pltextlist->link ) {
485 if( pltextlist->ntext > 0 ) {
486 pltextlist->isupdated = False ;
487 pltextlist->ntext = 0 ;
488 } else break ;
489 }
490
491 for( pptextlist = pbuffer->pptextlist ; pptextlist ;
492 pptextlist = (XW_EXT_PTEXT*)pptextlist->link ) {
493 if( pptextlist->ntext > 0 ) {
494 pptextlist->isupdated = False ;
495 pptextlist->ntext = 0 ;
496 } else break ;
497 }
498
499 for( ppmarklist = pbuffer->ppmarklist ; ppmarklist ;
500 ppmarklist = (XW_EXT_PMARKER*)ppmarklist->link ) {
501 if( ppmarklist->nmark > 0 ) {
502 ppmarklist->isupdated = False ;
503 ppmarklist->nmark = 0 ;
504 ppmarklist->npoint = 0 ;
505 } else break ;
506 }
507
508 for( plmarklist = pbuffer->plmarklist ; plmarklist ;
509 plmarklist = (XW_EXT_LMARKER*)plmarklist->link ) {
510 if( plmarklist->nmark > 0 ) {
511 plmarklist->isupdated = False ;
512 plmarklist->nmark = 0 ;
513 plmarklist->nseg = 0 ;
514 } else break ;
515 }
516
517 for( ppntlist = pbuffer->ppntlist ; ppntlist ;
518 ppntlist = (XW_EXT_POINT*)ppntlist->link ) {
519 if( ppntlist->npoint > 0 ) {
520 ppntlist->isupdated = False ;
521 ppntlist->npoint = 0 ;
522 } else break ;
523 }
524
525 for( plinedesc = pbuffer->plinedesc ; plinedesc ;
526 plinedesc = (XW_EXT_POINT*)plinedesc->link ) {
527 if( plinedesc->npoint > 0 ) {
528 plinedesc->isupdated = False ;
529 plinedesc->npoint = 0 ;
530 } else break ;
531 }
532
533 for( ptextdesc = pbuffer->ptextdesc ; ptextdesc ;
534 ptextdesc = (XW_EXT_CHAR*)ptextdesc->link ) {
535 if( ptextdesc->nchar > 0 ) {
536 ptextdesc->nchar = 0 ;
537 } else break ;
538 }
539
540#ifdef TRACE_DRAW_BUFFER
541 if( Xw_get_trace() ) {
542 printf (" Xw_clear_buffer(%lx,%d)\n",(long ) pwindow,bufferid) ;
543 }
544#endif
545
546 return (XW_SUCCESS);
547}
548
549/*
550 XW_STATUS Xw_open_buffer
551 (awindow,bufferid,xpivot,ypivot,width,color,font,drawmode)
552 XW_EXT_WINDOW *awindow
553 int bufferid
554 float xpivot,ypivot buffer hit point
555 int widthindex
556 int colorindex
557 int fontindex
558 XW_DRAWMODE drawmode
559
560 Open one retain buffer
561
562 Returns ERROR if the extended window address is badly defined
563 or Buffer identification is <= 0
564 Returns SUCCESS if successful
565
566 Note that if the buffer is already opened,this is reset with the
567 new hit point.
568
569*/
570
571#ifdef XW_PROTOTYPE
572XW_STATUS Xw_open_buffer
573 (void* awindow,int bufferid,float xpivot,float ypivot,
574 int width,int color,int font,XW_DRAWMODE drawmode)
575#else
576XW_STATUS Xw_open_buffer
577 (awindow,bufferid,xpivot,ypivot,width,color,font,drawmode)
578void *awindow;
579int bufferid ;
580float xpivot,ypivot ;
581int width ;
582int color ;
583int font ;
584XW_DRAWMODE drawmode ;
585#endif /*PROTOTYPE*/
586{
587XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
588XW_EXT_BUFFER *pbuffer ;
589XGCValues gc_values ;
590//XFontStruct *pfontinfo ;
591int i,mask = 0 ;
592
593 if( !Xw_isdefine_window(pwindow) ) {
594 /*ERROR*Bad EXT_WINDOW Address*/
595 Xw_set_error(24,"Xw_open_buffer",pwindow) ;
596 return (XW_ERROR) ;
597 }
598
599 if( bufferid <= 0 ) {
600 /*ERROR*Bad BUFFER identification*/
601 Xw_set_error(122,"Xw_open_buffer",&bufferid) ;
602 return (XW_ERROR) ;
603 }
604
605 if( drawmode != XW_REPLACE && drawmode != XW_XORBACK ) {
606 /*ERROR*Bad Buffer drawing mode*/
607 Xw_set_error(125,"Xw_open_buffer",&drawmode) ;
608 drawmode = XW_XORBACK ;
609 }
610
611 if ( !Xw_isdefine_width(_WIDTHMAP,width) ) {
612 /*ERROR*Bad Defined Width*/
613 Xw_set_error(52,"Xw_open_buffer",&width) ;
614 width = 0 ;
615 }
616
617 if ( !Xw_isdefine_color(_COLORMAP,color) ) {
618 /*ERROR*Bad Defined Color*/
619 Xw_set_error(41,"Xw_open_buffer",&color) ;
620 color = 0 ;
621 }
622
623 if ( !Xw_isdefine_font(_FONTMAP,font) ) {
624 /*WARNING*Bad Defined Font*/
625 Xw_set_error(43,"Xw_open_buffer",&font) ;
626 font = 0 ;
627 }
628
629 pbuffer = Xw_get_buffer_structure(pwindow,bufferid) ;
630 if( pbuffer ) {
631 /*ERROR*BUFFER is already opened
632 Xw_set_error(120,"Xw_open_buffer",&bufferid) ;
633*/
634 if( pbuffer->isdrawn ) {
635 Xw_erase_buffer(pwindow,bufferid) ;
636 }
637 } else {
638 for( i=1 ; i<MAXBUFFERS ; i++ ) {
639 if( _BUFFER(i).bufferid <= 0 ) break ;
640 }
641 if( i < MAXBUFFERS ) {
642 pbuffer = &_BUFFER(i) ;
643 } else {
644 /*ERROR*Too much BUFFERS are opened,max is*/
645 Xw_set_error(121,"Xw_open_buffer",&i) ;
646 return (XW_ERROR) ;
647 }
648
649 pbuffer->bufferid = bufferid;
650 pbuffer->gcf = XCreateGC(_DISPLAY,_WINDOW, 0, NULL) ;
651 pbuffer->gcb = XCreateGC(_DISPLAY,_WINDOW, 0, NULL) ;
652 }
653
654//OCC186
655 pbuffer->xpivot = PXPOINT(xpivot, pwindow->xratio) ;
656 pbuffer->ypivot = PYPOINT(ypivot, pwindow->attributes.height, pwindow->yratio) ;
657//OCC186
658
659 mask = GCFont | GCFunction | GCForeground | GCBackground ;
660 mask |= GCLineWidth ;
661 XGetGCValues(_DISPLAY,pwindow->qgwind.gccopy,mask,&gc_values) ;
662 pbuffer->code = 0 ;
663 if( width > 0 ) {
664#ifdef BUG /* Conflicting with SETFONT */
665 pbuffer->code = QGSETWIDTH(pbuffer->code,width) ;
666#endif
667 gc_values.line_width = _WIDTHMAP->widths[width] ;
668 /* gc_values.line_style = LineSolid ; */
669 }
670 if( color > 0 ) {
671 pbuffer->code = QGSETCOLOR(pbuffer->code,color) ;
672 gc_values.foreground = _COLORMAP->pixels[color] ;
673 }
674 if( font >= 0 ) {
675 pbuffer->code = QGSETFONT(pbuffer->code,font) ;
676 gc_values.font = _FONTMAP->fonts[font]->fid ;
677 }
678 if( drawmode == XW_REPLACE ) {
679 pbuffer->code = QGSETMODE(pbuffer->code,XW_REPLACE) ;
680 gc_values.function = GXcopy ;
681 } else if( drawmode == XW_XORBACK ) {
682 pbuffer->code = QGSETMODE(pbuffer->code,XW_XORBACK) ;
683 gc_values.function = GXxor ;
684 gc_values.foreground ^= gc_values.background ;
685 }
686 XChangeGC(_DISPLAY,pbuffer->gcf,mask,&gc_values) ;
687 gc_values.function = GXcopy ;
688 gc_values.foreground = gc_values.background ;
689 XChangeGC(_DISPLAY,pbuffer->gcb,mask,&gc_values) ;
690
691#ifdef CTS50025
692 Xw_set_text_attrib (pwindow,color,0,font,XW_REPLACE);
693#endif
694
695#ifdef TRACE_DRAW_BUFFER
696 if( Xw_get_trace() ) {
697 printf (" Xw_open_buffer(%lx,%d,%f,%f)\n",
698 (long ) pwindow,bufferid,xpivot,ypivot) ;
699 }
700#endif
701 return (XW_SUCCESS);
702}
703
704/*
705 XW_STATUS Xw_close_buffer (awindow,bufferid)
706 XW_EXT_WINDOW *awindow
707 int bufferid
708
709 Close the retain buffer
710
711 Returns ERROR if the extended window address is badly defined
712 or Buffer is not opened
713 Returns SUCCESS if successful
714
715*/
716
717#ifdef XW_PROTOTYPE
718XW_STATUS Xw_close_buffer (void* awindow,int bufferid)
719#else
720XW_STATUS Xw_close_buffer (awindow,bufferid)
721void *awindow;
722int bufferid ;
723#endif /*PROTOTYPE*/
724{
725XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
726XW_EXT_BUFFER *pbuffer ;
727//int i ;
728
729 if( !Xw_isdefine_window(pwindow) ) {
730 /*ERROR*Bad EXT_WINDOW Address*/
731 Xw_set_error(24,"Xw_close_buffer",pwindow) ;
732 return (XW_ERROR) ;
733 }
734
735 if( bufferid > 0 ) {
736 pbuffer = Xw_get_buffer_structure(pwindow,bufferid) ;
737 if( !pbuffer ) {
738 /*ERROR*BUFFER is not opened*/
739 Xw_set_error(119,"Xw_close_buffer",&bufferid) ;
740 return (XW_ERROR) ;
741 }
742 } else if( bufferid < 0 ) {
743 pbuffer = &_BUFFER(-bufferid) ;
744 if( !pbuffer->bufferid ) {
745 /*ERROR*BUFFER is not opened*/
746 return (XW_SUCCESS) ;
747 }
748 } else {
749 pbuffer = &_BUFFER(0) ;
750 }
751
752 if( !pbuffer->isempty ) {
753 Xw_clear_buffer(pwindow,bufferid) ;
754 }
755
756 if( pbuffer->gcf ) {
757 XFreeGC(_DISPLAY,pbuffer->gcf) ;
758 pbuffer->gcf = NULL ;
759 }
760 if( pbuffer->gcb ) {
761 XFreeGC(_DISPLAY,pbuffer->gcb) ;
762 pbuffer->gcb = NULL ;
763 }
764 pbuffer->code = 0 ;
765 pbuffer->bufferid = 0;
766 Xw_del_text_desc_structure(pbuffer) ;
767 Xw_del_line_desc_structure(pbuffer) ;
768 Xw_del_image_structure(pbuffer) ;
769 Xw_del_point_structure(pbuffer) ;
770 Xw_del_segment_structure(pbuffer) ;
771 Xw_del_polyline_structure(pbuffer) ;
772 Xw_del_arc_structure(pbuffer) ;
773 Xw_del_polyarc_structure(pbuffer) ;
774 Xw_del_polygone_structure(pbuffer) ;
775 Xw_del_text_structure(pbuffer) ;
776 Xw_del_polytext_structure(pbuffer) ;
777 Xw_del_lmarker_structure(pbuffer) ;
778 Xw_del_pmarker_structure(pbuffer) ;
779
780#ifdef TRACE_DRAW_BUFFER
781 if( Xw_get_trace() ) {
782 printf (" Xw_close_buffer(%lx,%d)\n",(long ) pwindow,bufferid) ;
783 }
784#endif
785 return (XW_SUCCESS);
786}
787
788/*
789 XW_STATUS Xw_set_buffer (awindow,bufferid)
790 XW_EXT_WINDOW *awindow
791 int bufferid
792
793 Activate the retain buffer for drawing
794
795 Returns ERROR if the extended window address is badly defined
796 or Buffer is not opened
797 Returns SUCCESS if successful
798
799*/
800#ifdef XW_PROTOTYPE
801XW_STATUS Xw_set_buffer (void* awindow,int bufferid)
802#else
803XW_STATUS Xw_set_buffer (awindow,bufferid)
804void *awindow;
805int bufferid ;
806#endif /*PROTOTYPE*/
807{
808XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
809XW_EXT_BUFFER *pbuffer ;
810int i ;
811
812 if( !Xw_isdefine_window(pwindow) ) {
813 /*ERROR*Bad EXT_WINDOW Address*/
814 Xw_set_error(24,"Xw_set_buffer",pwindow) ;
815 return (XW_ERROR) ;
816 }
817
818 if( bufferid > 0 ) {
819 for( i=1 ; i<MAXBUFFERS ; i++ ) {
820 pbuffer = &_BUFFER(i) ;
821 if( bufferid == pbuffer->bufferid ) break ;
822 }
823 if( i < MAXBUFFERS ) {
824 _BINDEX = i ;
825 if( QGMODE(pbuffer->code) == XW_REPLACE ) {
826 pbuffer->code = QGSETTYPE(pbuffer->code,XW_DISABLE) ;
827 } else {
828 if( _PIXMAP || _NWBUFFER > 0 ) {
829 pbuffer->code = QGSETTYPE(pbuffer->code,XW_ENABLE) ;
830 } else {
831 pbuffer->code = QGSETTYPE(pbuffer->code,XW_DISABLE) ;
832 }
833 }
834 } else {
835 /*ERROR*BUFFER is not opened*/
836 Xw_set_error(119,"Xw_set_buffer",&bufferid) ;
837 return (XW_ERROR) ;
838 }
839 } else {
840 _BINDEX = 0 ;
841 }
842
843#ifdef TRACE_DRAW_BUFFER
844 if( Xw_get_trace() ) {
845 printf (" Xw_set_buffer(%lx,%d)\n",(long ) pwindow,bufferid) ;
846 }
847#endif
848 return (XW_SUCCESS);
849}
850
851/*
852 XW_STATUS Xw_get_buffer_status (awindow,bufferid,isopen,isdrawn,isempty)
853 XW_EXT_WINDOW *awindow
854 int bufferid
855 int *isopen
856 int *isdrawn
857 int *isempty
858
859 Get the status info of one retain buffer
860
861 Returns ERROR if the extended window address is badly defined
862 Returns SUCCESS if successful
863
864*/
865
866#ifdef XW_PROTOTYPE
867XW_STATUS Xw_get_buffer_status (void* awindow,int bufferid,int* isopen,int* isdrawn,int* isempty)
868#else
869XW_STATUS Xw_get_buffer_status (awindow,bufferid,isopen,isdrawn,isempty)
870void *awindow;
871int bufferid ;
872int* isopen;
873int* isdrawn;
874int* isempty;
875#endif /*PROTOTYPE*/
876{
877XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
878XW_EXT_BUFFER *pbuffer ;
879
880 if( !Xw_isdefine_window(pwindow) ) {
881 /*ERROR*Bad EXT_WINDOW Address*/
882 Xw_set_error(24,"Xw_get_buffer_status",pwindow) ;
883 return (XW_ERROR) ;
884 }
885
886 pbuffer = Xw_get_buffer_structure(pwindow,bufferid) ;
887
888 *isopen = *isdrawn = *isempty = False ;
889
890 if( pbuffer ) {
891 *isopen = True ;
892 *isdrawn = pbuffer->isdrawn ;
893 *isempty = pbuffer->isempty ;
894 }
895
896#ifdef TRACE_DRAW_BUFFER
897 if( Xw_get_trace() ) {
898 printf (" Xw_get_buffer_status(%lx,%d,%d,%d,%d)\n",
899 (long ) pwindow,bufferid,*isopen,*isdrawn,*isempty) ;
900 }
901#endif
902 return (XW_SUCCESS);
903
904}
905
906/*
907 XW_STATUS Xw_get_buffer_info (awindow,bufferid,xpivot,ypivot,xscale,yscale,angle)
908 XW_EXT_WINDOW *awindow
909 int bufferid
910 float *xpivot returned buffer position
911 float *ypivot returned buffer position
912 float *xscale returned buffer scale
913 float *yscale returned buffer scale
914 float *angle returned buffer orientation
915
916 Get the transform infos of one retain buffer
917
918 Returns ERROR if the extended window address is badly defined
919 Returns SUCCESS if successful
920
921*/
922
923#ifdef XW_PROTOTYPE
924XW_STATUS Xw_get_buffer_info (void* awindow,int bufferid,float *xpivot,float *ypivot,float *xscale,float *yscale,float *angle)
925#else
926XW_STATUS Xw_get_buffer_info (awindow,bufferid,xpivot,ypivot,xscale,yscale,angle)
927void *awindow;
928int bufferid ;
929float *xpivot,*ypivot ;
930float *xscale,*yscale ;
931float *angle ;
932#endif /*PROTOTYPE*/
933{
934XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow ;
935XW_EXT_BUFFER *pbuffer ;
936
937 if( !Xw_isdefine_window(pwindow) ) {
938 /*ERROR*Bad EXT_WINDOW Address*/
939 Xw_set_error(24,"Xw_get_buffer_info",pwindow) ;
940 return (XW_ERROR) ;
941 }
942
943 pbuffer = Xw_get_buffer_structure(pwindow,bufferid) ;
944 if( !pbuffer ) {
945 /*ERROR*BUFFER is not opened*/
946 Xw_set_error(119,"Xw_get_buffer_info",&bufferid) ;
947 return (XW_ERROR) ;
948 }
949
950 *xpivot = UXPOINT(pbuffer->xpivot+pbuffer->dxpivot) ;
951 *ypivot = UYPOINT(pbuffer->ypivot+pbuffer->dypivot) ;
952 *xscale = pbuffer->xscale*pbuffer->dxscale ;
953 *yscale = pbuffer->yscale*pbuffer->dyscale ;
954 *angle = pbuffer->angle+pbuffer->dangle ;
955
956#ifdef TRACE_DRAW_BUFFER
957 if( Xw_get_trace() ) {
958 printf (" Xw_get_buffer_info(%lx,%d,%f,%f,%f,%f,%f)\n",
959 (long ) pwindow,bufferid,*xpivot,*ypivot,*xscale,*yscale,*angle) ;
960 }
961#endif
962 return (XW_SUCCESS);
963
964}
965
966#ifdef XW_PROTOTYPE
967XW_EXT_BUFFER* Xw_get_buffer_structure(XW_EXT_WINDOW *pwindow,int bufferid)
968#else
969XW_EXT_BUFFER* Xw_get_buffer_structure(pwindow,bufferid)
970XW_EXT_WINDOW *pwindow;
971int bufferid;
972#endif /*XW_PROTOTYPE*/
973{
974int i ;
975
976 if( bufferid <= 0 ) return NULL ;
977
978 for( i=1 ; i<MAXBUFFERS ; i++ ) {
979 if( _BUFFER(i).bufferid == bufferid ) break ;
980 }
981
982 if( i < MAXBUFFERS ) return &_BUFFER(i) ;
983 else return NULL ;
984}
985
986#ifdef XW_PROTOTYPE
987XW_STATUS Xw_update_buffer (XW_EXT_WINDOW* pwindow,XW_EXT_BUFFER* pbuffer)
988#else
989XW_STATUS Xw_update_buffer (pwindow,pbuffer)
990XW_EXT_WINDOW *pwindow;
991XW_EXT_BUFFER *pbuffer;
992#endif /*XW_PROTOTYPE*/
993{
994XW_EXT_IMAGE *pimaglist ;
995XW_EXT_POLY *ppolylist ;
996XW_EXT_LINE *plinelist ;
997XW_EXT_SEGMENT *pseglist ;
998XW_EXT_LTEXT *pltextlist ;
999XW_EXT_PTEXT *pptextlist ;
1000XW_EXT_ARC *parclist ;
1001XW_EXT_PMARKER *ppmarklist ;
1002XW_EXT_LMARKER *plmarklist ;
1003XW_EXT_POINT *ppntlist ;
1004XW_EXT_POINT *plinedesc ;
1005int i ;
1006
1007 if( !pbuffer->isupdated ) return XW_ERROR ;
1008
1009 for( pimaglist = pbuffer->pimaglist ; pimaglist ;
1010 pimaglist = (XW_EXT_IMAGE*)pimaglist->link ) {
1011 if( pimaglist->nimage > 0 ) {
1012 pimaglist->isupdated = False ;
1013 for( i=0 ; i<pimaglist->nimage ; i++ ) {
1014 pimaglist->rpoints[i].x = pimaglist->upoints[i].x ;
1015 pimaglist->rpoints[i].y = pimaglist->upoints[i].y ;
1016 }
1017 } else break ;
1018 }
1019
1020 for( parclist = pbuffer->pparclist ; parclist ;
1021 parclist = (XW_EXT_ARC*)parclist->link ) {
1022 if( parclist->narc > 0 ) {
1023 parclist->isupdated = False ;
1024 for( i=0 ; i<parclist->narc ; i++ ) {
1025 parclist->rarcs[i].x = parclist->uarcs[i].x ;
1026 parclist->rarcs[i].y = parclist->uarcs[i].y ;
1027 parclist->rarcs[i].width = parclist->uarcs[i].width ;
1028 parclist->rarcs[i].height = parclist->uarcs[i].height ;
1029 parclist->rarcs[i].angle1 = parclist->uarcs[i].angle1 ;
1030 parclist->rarcs[i].angle2 = parclist->uarcs[i].angle2 ;
1031
1032 }
1033 } else break ;
1034 }
1035
1036 for( pseglist = pbuffer->pseglist ; pseglist ;
1037 pseglist = (XW_EXT_SEGMENT*)pseglist->link ) {
1038 if( pseglist->nseg > 0 ) {
1039 pseglist->isupdated = False ;
1040 for( i=0 ; i<pseglist->nseg ; i++ ) {
1041 pseglist->rsegments[i].x1 = pseglist->usegments[i].x1 ;
1042 pseglist->rsegments[i].y1 = pseglist->usegments[i].y1 ;
1043 pseglist->rsegments[i].x2 = pseglist->usegments[i].x2 ;
1044 pseglist->rsegments[i].y2 = pseglist->usegments[i].y2 ;
1045 }
1046 } else break ;
1047 }
1048
1049 for( parclist = pbuffer->plarclist ; parclist ;
1050 parclist = (XW_EXT_ARC*)parclist->link ) {
1051 if( parclist->narc > 0 ) {
1052 parclist->isupdated = False ;
1053 for( i=0 ; i<parclist->narc ; i++ ) {
1054 parclist->rarcs[i].x = parclist->uarcs[i].x ;
1055 parclist->rarcs[i].y = parclist->uarcs[i].y ;
1056 parclist->rarcs[i].width = parclist->uarcs[i].width ;
1057 parclist->rarcs[i].height = parclist->uarcs[i].height ;
1058 parclist->rarcs[i].angle1 = parclist->uarcs[i].angle1 ;
1059 parclist->rarcs[i].angle2 = parclist->uarcs[i].angle2 ;
1060 }
1061 } else break ;
1062 }
1063
1064 for( pltextlist = pbuffer->pltextlist ; pltextlist ;
1065 pltextlist = (XW_EXT_LTEXT*)pltextlist->link ) {
1066 if( pltextlist->ntext > 0 ) {
1067 pltextlist->isupdated = False ;
1068 for( i=0 ; i<pltextlist->ntext ; i++ ) {
1069 pltextlist->rpoints[i].x = pltextlist->upoints[i].x ;
1070 pltextlist->rpoints[i].y = pltextlist->upoints[i].y ;
1071 pltextlist->rangles[i] = pltextlist->uangles[i] ;
1072 pltextlist->rscalex[i] = pltextlist->uscalex[i] ;
1073 pltextlist->rscaley[i] = pltextlist->uscaley[i] ;
1074 }
1075 } else break ;
1076 }
1077
1078 for( pptextlist = pbuffer->pptextlist ; pptextlist ;
1079 pptextlist = (XW_EXT_PTEXT*)pptextlist->link ) {
1080 if( pptextlist->ntext > 0 ) {
1081 pptextlist->isupdated = False ;
1082 for( i=0 ; i<pptextlist->ntext ; i++ ) {
1083 pptextlist->rpoints[i].x = pptextlist->upoints[i].x ;
1084 pptextlist->rpoints[i].y = pptextlist->upoints[i].y ;
1085 pptextlist->rangles[i] = pptextlist->uangles[i] ;
1086 pptextlist->rscalex[i] = pptextlist->uscalex[i] ;
1087 pptextlist->rscaley[i] = pptextlist->uscaley[i] ;
1088 }
1089 } else break ;
1090 }
1091
1092 for( ppmarklist = pbuffer->ppmarklist ; ppmarklist ;
1093 ppmarklist = (XW_EXT_PMARKER*)ppmarklist->link ) {
1094 if( ppmarklist->nmark > 0 ) {
1095 ppmarklist->isupdated = False ;
1096 for( i=0 ; i<ppmarklist->nmark ; i++ ) {
1097 ppmarklist->rcenters[i].x = ppmarklist->ucenters[i].x ;
1098 ppmarklist->rcenters[i].y = ppmarklist->ucenters[i].y ;
1099 }
1100 for( i=0 ; i<ppmarklist->npoint ; i++ ) {
1101 ppmarklist->rpoints[i].x = ppmarklist->upoints[i].x ;
1102 ppmarklist->rpoints[i].y = ppmarklist->upoints[i].y ;
1103 }
1104 } else break ;
1105 }
1106
1107 for( plmarklist = pbuffer->plmarklist ; plmarklist ;
1108 plmarklist = (XW_EXT_LMARKER*)plmarklist->link ) {
1109 if( plmarklist->nmark > 0 ) {
1110 plmarklist->isupdated = False ;
1111 for( i=0 ; i<plmarklist->nmark ; i++ ) {
1112 plmarklist->rcenters[i].x = plmarklist->ucenters[i].x ;
1113 plmarklist->rcenters[i].y = plmarklist->ucenters[i].y ;
1114 }
1115 for( i=0 ; i<plmarklist->nseg ; i++ ) {
1116 plmarklist->rsegments[i].x1 = plmarklist->usegments[i].x1 ;
1117 plmarklist->rsegments[i].y1 = plmarklist->usegments[i].y1 ;
1118 plmarklist->rsegments[i].x2 = plmarklist->usegments[i].x2 ;
1119 plmarklist->rsegments[i].y2 = plmarklist->usegments[i].y2 ;
1120 }
1121 } else break ;
1122 }
1123
1124 for( ppntlist = pbuffer->ppntlist ; ppntlist ;
1125 ppntlist = (XW_EXT_POINT*)ppntlist->link ) {
1126 if( ppntlist->npoint > 0 ) {
1127 ppntlist->isupdated = False ;
1128 for( i=0 ; i<ppntlist->npoint ; i++ ) {
1129 ppntlist->rpoints[i].x = ppntlist->upoints[i].x ;
1130 ppntlist->rpoints[i].y = ppntlist->upoints[i].y ;
1131 }
1132 } else break ;
1133 }
1134
1135 for( ppolylist = pbuffer->ppolylist ; ppolylist ;
1136 ppolylist = (XW_EXT_POLY*)ppolylist->link ) {
1137 if( ppolylist->npoly > 0 ) {
1138 ppolylist->isupdated = False ;
1139 } else break ;
1140 }
1141
1142 for( plinelist = pbuffer->plinelist ; plinelist ;
1143 plinelist = (XW_EXT_LINE*)plinelist->link ) {
1144 if( plinelist->nline > 0 ) {
1145 plinelist->isupdated = False ;
1146 } else break ;
1147 }
1148
1149 for( plinedesc = pbuffer->plinedesc ; plinedesc ;
1150 plinedesc = (XW_EXT_POINT*)plinedesc->link ) {
1151 if( plinedesc->npoint > 0 ) {
1152 plinedesc->isupdated = False ;
1153 for( i=0 ; i<plinedesc->npoint ; i++ ) {
1154 plinedesc->rpoints[i].x = plinedesc->upoints[i].x ;
1155 plinedesc->rpoints[i].y = plinedesc->upoints[i].y ;
1156 }
1157 } else break ;
1158 }
1159
1160 pbuffer->xpivot += pbuffer->dxpivot ;
1161 pbuffer->ypivot += pbuffer->dypivot ;
1162 pbuffer->dxpivot = pbuffer->dypivot = 0 ;
1163
1164 pbuffer->angle += pbuffer->dangle ;
1165 pbuffer->dangle = 0. ;
1166
1167 pbuffer->xscale *= pbuffer->dxscale ;
1168 pbuffer->yscale *= pbuffer->dyscale ;
1169 pbuffer->dxscale = pbuffer->dyscale = 1. ;
1170
1171 pbuffer->rxmin = pbuffer->uxmin ;
1172 pbuffer->rymin = pbuffer->uymin ;
1173 pbuffer->rxmax = pbuffer->uxmax ;
1174 pbuffer->rymax = pbuffer->uymax ;
1175
1176 pbuffer->isupdated = UNKNOWN_BUFFER ;
1177
1178#ifdef TRACE_DRAW_BUFFER
1179 if( Xw_get_trace() ) {
1180 printf (" Xw_update_buffer(%lx,%d)\n",(long ) pwindow,pbuffer->bufferid) ;
1181 }
1182#endif
1183
1184 return (XW_SUCCESS);
1185}
1186
1187/*
1188 STATUS Xw_move_buffer (awindow,bufferid,xpivot,ypivot)
1189 XW_EXT_WINDOW *awindow
1190 int bufferid
1191 float xpivot,ypivot new DWU pivot point location
1192
1193 Move & display one retain buffer of primitives at screen
1194
1195 Returns ERROR if the extended window address is badly defined
1196 or Buffer is empty
1197 or Buffer is not opened
1198 Returns SUCCESS if successful
1199
1200*/
1201
1202#ifdef XW_PROTOTYPE
1203XW_STATUS Xw_move_buffer (void* awindow,int bufferid,float pivotx,float pivoty)
1204#else
1205XW_STATUS Xw_move_buffer (awindow,bufferid,pivotx,pivoty)
1206void *awindow;
1207int bufferid;
1208float pivotx,pivoty;
1209#endif /*XW_PROTOTYPE*/
1210{
1211XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
1212XW_EXT_BUFFER *pbuffer ;
1213XW_EXT_IMAGE *pimaglist ;
1214XW_EXT_POLY *ppolylist ;
1215XW_EXT_LINE *plinelist ;
1216XW_EXT_SEGMENT *pseglist ;
1217XW_EXT_LTEXT *pltextlist ;
1218XW_EXT_PTEXT *pptextlist ;
1219XW_EXT_ARC *parclist ;
1220XW_EXT_PMARKER *ppmarklist ;
1221XW_EXT_LMARKER *plmarklist ;
1222XW_EXT_POINT *ppntlist ;
1223XW_EXT_POINT *plinedesc ;
1224int i,dx,dy,xpivot,ypivot ;
1225int rxmin,rymin,rxmax,rymax ;
1226int uxmin,uymin,uxmax,uymax ;
1227
1228 if( !Xw_isdefine_window(pwindow) ) {
1229 /*ERROR*Bad EXT_WINDOW Address*/
1230 Xw_set_error(24,"Xw_move_buffer",pwindow) ;
1231 return (XW_ERROR) ;
1232 }
1233
1234 pbuffer = Xw_get_buffer_structure(pwindow,bufferid) ;
1235 if( !pbuffer ) {
1236 /*ERROR*BUFFER is not opened*/
1237 Xw_set_error(119,"Xw_move_buffer",&bufferid) ;
1238 return (XW_ERROR) ;
1239 }
1240
1241 if( pbuffer->isempty ) return XW_ERROR ;
1242
1243 pbuffer->isretain = True ;
1244 if( pbuffer->isdrawn ) {
1245 Xw_erase_buffer(pwindow,bufferid) ;
1246 }
1247
1248 if( pbuffer->isupdated != MOVE_BUFFER ) {
1249 if( pbuffer->isupdated ) Xw_update_buffer(pwindow,pbuffer) ;
1250 }
1251
1252//OCC186
1253 xpivot = PXPOINT(pivotx, pwindow->xratio) ;
1254 ypivot = PYPOINT(pivoty, pwindow->attributes.height, pwindow->yratio) ;
1255//OCC186
1256
1257 dx = xpivot - pbuffer->xpivot ;
1258 dy = ypivot - pbuffer->ypivot ;
1259
1260 rxmin = pbuffer->rxmin ;
1261 rymin = pbuffer->rymin ;
1262 rxmax = pbuffer->rxmax ;
1263 rymax = pbuffer->rymax ;
1264
1265 if( pbuffer->isupdated ) {
1266 uxmin = pbuffer->uxmin ;
1267 uymin = pbuffer->uymin ;
1268 uxmax = pbuffer->uxmax ;
1269 uymax = pbuffer->uymax ;
1270 } else {
1271 uxmin = rxmin ; uymin = rymin ;
1272 uxmax = rxmax ; uymax = rymax ;
1273 }
1274
1275 if( dx || dy ) {
1276
1277 for( pimaglist = pbuffer->pimaglist ; pimaglist ;
1278 pimaglist = (XW_EXT_IMAGE*)pimaglist->link ) {
1279 if( pimaglist->nimage > 0 ) {
1280 pimaglist->isupdated = True ;
1281 for( i=0 ; i<pimaglist->nimage ; i++ ) {
1282 pimaglist->upoints[i].x = pimaglist->rpoints[i].x + dx ;
1283 pimaglist->upoints[i].y = pimaglist->rpoints[i].y + dy ;
1284 }
1285 } else break ;
1286 }
1287
1288 for( parclist = pbuffer->pparclist ; parclist ;
1289 parclist = (XW_EXT_ARC*)parclist->link ) {
1290 if( parclist->narc > 0 ) {
1291 parclist->isupdated = True ;
1292 for( i=0 ; i<parclist->narc ; i++ ) {
1293 parclist->uarcs[i].x = parclist->rarcs[i].x + dx ;
1294 parclist->uarcs[i].y = parclist->rarcs[i].y + dy ;
1295 parclist->uarcs[i].width = parclist->rarcs[i].width ;
1296 parclist->uarcs[i].height = parclist->rarcs[i].height ;
1297 parclist->uarcs[i].angle1 = parclist->rarcs[i].angle1 ;
1298 parclist->uarcs[i].angle2 = parclist->rarcs[i].angle2 ;
1299
1300 }
1301 } else break ;
1302 }
1303
1304 for( pseglist = pbuffer->pseglist ; pseglist ;
1305 pseglist = (XW_EXT_SEGMENT*)pseglist->link ) {
1306 if( pseglist->nseg > 0 ) {
1307 pseglist->isupdated = True ;
1308 for( i=0 ; i<pseglist->nseg ; i++ ) {
1309 pseglist->usegments[i].x1 = pseglist->rsegments[i].x1 + dx ;
1310 pseglist->usegments[i].y1 = pseglist->rsegments[i].y1 + dy ;
1311 pseglist->usegments[i].x2 = pseglist->rsegments[i].x2 + dx ;
1312 pseglist->usegments[i].y2 = pseglist->rsegments[i].y2 + dy ;
1313 }
1314 } else break ;
1315 }
1316
1317 for( parclist = pbuffer->plarclist ; parclist ;
1318 parclist = (XW_EXT_ARC*)parclist->link ) {
1319 if( parclist->narc > 0 ) {
1320 parclist->isupdated = True ;
1321 for( i=0 ; i<parclist->narc ; i++ ) {
1322 parclist->uarcs[i].x = parclist->rarcs[i].x + dx ;
1323 parclist->uarcs[i].y = parclist->rarcs[i].y + dy ;
1324 parclist->uarcs[i].width = parclist->rarcs[i].width ;
1325 parclist->uarcs[i].height = parclist->rarcs[i].height ;
1326 parclist->uarcs[i].angle1 = parclist->rarcs[i].angle1 ;
1327 parclist->uarcs[i].angle2 = parclist->rarcs[i].angle2 ;
1328 }
1329 } else break ;
1330 }
1331
1332 for( pltextlist = pbuffer->pltextlist ; pltextlist ;
1333 pltextlist = (XW_EXT_LTEXT*)pltextlist->link ) {
1334 if( pltextlist->ntext > 0 ) {
1335 pltextlist->isupdated = True ;
1336 for( i=0 ; i<pltextlist->ntext ; i++ ) {
1337 pltextlist->upoints[i].x = pltextlist->rpoints[i].x + dx ;
1338 pltextlist->upoints[i].y = pltextlist->rpoints[i].y + dy ;
1339 pltextlist->uangles[i] = pltextlist->rangles[i] ;
1340 pltextlist->uscalex[i] = pltextlist->rscalex[i] ;
1341 pltextlist->uscaley[i] = pltextlist->rscaley[i] ;
1342 }
1343 } else break ;
1344 }
1345
1346 for( pptextlist = pbuffer->pptextlist ; pptextlist ;
1347 pptextlist = (XW_EXT_PTEXT*)pptextlist->link ) {
1348 if( pptextlist->ntext > 0 ) {
1349 pptextlist->isupdated = True ;
1350 for( i=0 ; i<pptextlist->ntext ; i++ ) {
1351 pptextlist->upoints[i].x = pptextlist->rpoints[i].x + dx ;
1352 pptextlist->upoints[i].y = pptextlist->rpoints[i].y + dy ;
1353 pptextlist->uangles[i] = pptextlist->rangles[i] ;
1354 pptextlist->uscalex[i] = pptextlist->rscalex[i] ;
1355 pptextlist->uscaley[i] = pptextlist->rscaley[i] ;
1356 }
1357 } else break ;
1358 }
1359
1360 for( ppmarklist = pbuffer->ppmarklist ; ppmarklist ;
1361 ppmarklist = (XW_EXT_PMARKER*)ppmarklist->link ) {
1362 if( ppmarklist->nmark > 0 ) {
1363 ppmarklist->isupdated = True ;
1364 for( i=0 ; i<ppmarklist->nmark ; i++ ) {
1365 ppmarklist->ucenters[i].x = ppmarklist->rcenters[i].x + dx ;
1366 ppmarklist->ucenters[i].y = ppmarklist->rcenters[i].y + dy ;
1367 }
1368 for( i=0 ; i<ppmarklist->npoint ; i++ ) {
1369 ppmarklist->upoints[i].x = ppmarklist->rpoints[i].x + dx ;
1370 ppmarklist->upoints[i].y = ppmarklist->rpoints[i].y + dy ;
1371 }
1372 } else break ;
1373 }
1374
1375 for( plmarklist = pbuffer->plmarklist ; plmarklist ;
1376 plmarklist = (XW_EXT_LMARKER*)plmarklist->link ) {
1377 if( plmarklist->nmark > 0 ) {
1378 plmarklist->isupdated = True ;
1379 for( i=0 ; i<plmarklist->nmark ; i++ ) {
1380 plmarklist->ucenters[i].x = plmarklist->rcenters[i].x + dx ;
1381 plmarklist->ucenters[i].y = plmarklist->rcenters[i].y + dy ;
1382 }
1383 for( i=0 ; i<plmarklist->nseg ; i++ ) {
1384 plmarklist->usegments[i].x1 = plmarklist->rsegments[i].x1 + dx ;
1385 plmarklist->usegments[i].y1 = plmarklist->rsegments[i].y1 + dy ;
1386 plmarklist->usegments[i].x2 = plmarklist->rsegments[i].x2 + dx ;
1387 plmarklist->usegments[i].y2 = plmarklist->rsegments[i].y2 + dy ;
1388 }
1389 } else break ;
1390 }
1391
1392 for( ppntlist = pbuffer->ppntlist ; ppntlist ;
1393 ppntlist = (XW_EXT_POINT*)ppntlist->link ) {
1394 if( ppntlist->npoint > 0 ) {
1395 ppntlist->isupdated = True ;
1396 for( i=0 ; i<ppntlist->npoint ; i++ ) {
1397 ppntlist->upoints[i].x = ppntlist->rpoints[i].x + dx ;
1398 ppntlist->upoints[i].y = ppntlist->rpoints[i].y + dy ;
1399 }
1400 } else break ;
1401 }
1402
1403 for( ppolylist = pbuffer->ppolylist ; ppolylist ;
1404 ppolylist = (XW_EXT_POLY*)ppolylist->link ) {
1405 if( ppolylist->npoly > 0 ) {
1406 ppolylist->isupdated = True ;
1407 } else break ;
1408 }
1409
1410 for( plinelist = pbuffer->plinelist ; plinelist ;
1411 plinelist = (XW_EXT_LINE*)plinelist->link ) {
1412 if( plinelist->nline > 0 ) {
1413 plinelist->isupdated = True ;
1414 } else break ;
1415 }
1416
1417 for( plinedesc = pbuffer->plinedesc ; plinedesc ;
1418 plinedesc = (XW_EXT_POINT*)plinedesc->link ) {
1419 if( plinedesc->npoint > 0 ) {
1420 plinedesc->isupdated = True ;
1421 for( i=0 ; i<plinedesc->npoint ; i++ ) {
1422 plinedesc->upoints[i].x = plinedesc->rpoints[i].x + dx ;
1423 plinedesc->upoints[i].y = plinedesc->rpoints[i].y + dy ;
1424 }
1425 } else break ;
1426 }
1427
1428 pbuffer->dxpivot = dx ;
1429 pbuffer->dypivot = dy ;
1430
1431 pbuffer->uxmin = pbuffer->rxmin + dx ;
1432 pbuffer->uymin = pbuffer->rymin + dy ;
1433 pbuffer->uxmax = pbuffer->rxmax + dx ;
1434 pbuffer->uymax = pbuffer->rymax + dy ;
1435
1436 uxmin = min(uxmin,pbuffer->uxmin) ;
1437 uymin = min(uymin,pbuffer->uymin) ;
1438 uxmax = max(uxmax,pbuffer->uxmax) ;
1439 uymax = max(uymax,pbuffer->uymax) ;
1440
1441 pbuffer->isupdated = MOVE_BUFFER ;
1442
1443 }
1444
1445 Xw_draw_buffer(pwindow,bufferid) ;
1446
1447 if( QGTYPE(pbuffer->code) == XW_ENABLE ) {
1448 int x = uxmin - 1 ;
1449 int y = uymin - 1 ;
1450 int w = uxmax - x + 1 ;
1451 int h = uymax - y + 1 ;
1452
1453 if( x < 0 ) x = 0 ;
1454 if( y < 0 ) y = 0 ;
1455 if( x+w > _WIDTH ) w = _WIDTH - x ;
1456 if( y+h > _HEIGHT ) h = _HEIGHT - y ;
1457
1458 if( _NWBUFFER > 0 ) {
1459 XCopyArea(_DISPLAY,_BWBUFFER,_FWBUFFER,
1460 pwindow->qgwind.gccopy,x,y,w,h,x,y) ;
1461 } else if( _PIXMAP ) {
1462 XCopyArea(_DISPLAY,_PIXMAP,_WINDOW,
1463 pwindow->qgwind.gccopy,x,y,w,h,x,y) ;
1464 }
1465 XFlush(_DISPLAY) ;
1466 }
1467 pbuffer->isretain = False ;
1468
1469#ifdef TRACE_DRAW_BUFFER
1470 if( Xw_get_trace() ) {
1471 printf (" Xw_move_buffer(%lx,%d,%d,%d)\n",
1472 (long ) pwindow,bufferid,xpivot,ypivot) ;
1473 }
1474#endif
1475
1476 return (XW_SUCCESS);
1477}
1478
1479/*
1480 STATUS Xw_rotate_buffer (awindow,bufferid,angle)
1481 XW_EXT_WINDOW *awindow
1482 int bufferid
1483 float angle Last orientation since the creation time
1484
1485 Rotate & display one retain buffer of primitives at screen
1486
1487 Returns ERROR if the extended window address is badly defined
1488 or Buffer is empty
1489 or Buffer is not opened
1490 Returns SUCCESS if successful
1491
1492*/
1493
1494#ifdef XW_PROTOTYPE
1495XW_STATUS Xw_rotate_buffer (void* awindow,int bufferid,float angle)
1496#else
1497XW_STATUS Xw_rotate_buffer (awindow,bufferid,angle)
1498void *awindow;
1499int bufferid;
1500float angle;
1501#endif /*XW_PROTOTYPE*/
1502{
1503XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
1504XW_EXT_BUFFER *pbuffer ;
1505XW_EXT_IMAGE *pimaglist ;
1506XW_EXT_POLY *ppolylist ;
1507XW_EXT_LINE *plinelist ;
1508XW_EXT_SEGMENT *pseglist ;
1509XW_EXT_LTEXT *pltextlist ;
1510XW_EXT_PTEXT *pptextlist ;
1511XW_EXT_ARC *parclist ;
1512XW_EXT_PMARKER *ppmarklist ;
1513XW_EXT_LMARKER *plmarklist ;
1514XW_EXT_POINT *ppntlist ;
1515XW_EXT_POINT *plinedesc ;
1516int i,j,n,x,y,dx,dy,xp,yp,angle1 ;
1517int rxmin,rymin,rxmax,rymax ;
1518int uxmin,uymin,uxmax,uymax ;
1519float a,cosa,sina ;
1520
1521 if( !Xw_isdefine_window(pwindow) ) {
1522 /*ERROR*Bad EXT_WINDOW Address*/
1523 Xw_set_error(24,"Xw_rotate_buffer",pwindow) ;
1524 return (XW_ERROR) ;
1525 }
1526
1527 pbuffer = Xw_get_buffer_structure(pwindow,bufferid) ;
1528 if( !pbuffer ) {
1529 /*ERROR*BUFFER is not opened*/
1530 Xw_set_error(119,"Xw_rotate_buffer",&bufferid) ;
1531 return (XW_ERROR) ;
1532 }
1533
1534 if( pbuffer->isempty ) return XW_ERROR ;
1535
1536 pbuffer->isretain = True ;
1537 if( pbuffer->isdrawn ) {
1538 Xw_erase_buffer(pwindow,bufferid) ;
1539 }
1540
1541 if( pbuffer->isupdated != ROTATE_BUFFER ) {
1542 if( pbuffer->isupdated ) Xw_update_buffer(pwindow,pbuffer) ;
1543 }
1544
1545 xp = pbuffer->xpivot ;
1546 yp = pbuffer->ypivot ;
1547
1548 rxmin = pbuffer->rxmin ;
1549 rymin = pbuffer->rymin ;
1550 rxmax = pbuffer->rxmax ;
1551 rymax = pbuffer->rymax ;
1552
1553 if( pbuffer->isupdated ) {
1554 uxmin = pbuffer->uxmin ;
1555 uymin = pbuffer->uymin ;
1556 uxmax = pbuffer->uxmax ;
1557 uymax = pbuffer->uymax ;
1558 } else {
1559 uxmin = rxmin ; uymin = rymin ;
1560 uxmax = rxmax ; uymax = rymax ;
1561 }
1562
1563 if( angle != pbuffer->dangle ) {
1564 int dxmin = rxmin - xp ;
1565 int dymin = rymin - yp ;
1566 int dxmax = rxmax - xp ;
1567 int dymax = rymax - yp ;
1568
1569 cosa = cos((double)angle) ;
1570 sina = sin((double)angle) ;
1571
1572 for( pimaglist = pbuffer->pimaglist ; pimaglist ;
1573 pimaglist = (XW_EXT_IMAGE*)pimaglist->link ) {
1574 if( pimaglist->nimage > 0 ) {
1575 pimaglist->isupdated = True ;
1576 for( i=0 ; i<pimaglist->nimage ; i++ ) {
1577 x = pimaglist->rpoints[i].x - xp ;
1578 y = pimaglist->rpoints[i].y - yp ;
1579 pimaglist->upoints[i].x = (short int )( xp + XROTATE(x,y) );
1580 pimaglist->upoints[i].y = (short int )( yp + YROTATE(x,y) );
1581 }
1582 } else break ;
1583 }
1584
1585 for( parclist = pbuffer->pparclist ; parclist ;
1586 parclist = (XW_EXT_ARC*)parclist->link ) {
1587 if( parclist->narc > 0 ) {
1588 parclist->isupdated = True ;
1589 for( i=0 ; i<parclist->narc ; i++ ) {
1590 x = parclist->rarcs[i].x + parclist->rarcs[i].width/2 - xp ;
1591 y = parclist->rarcs[i].y + parclist->rarcs[i].height/2 - yp ;
1592 parclist->uarcs[i].x = (short int )( xp + XROTATE(x,y) -
1593 (int)parclist->rarcs[i].width/2 );
1594 parclist->uarcs[i].y = (short int )( yp + YROTATE(x,y) -
1595 (int)parclist->rarcs[i].height/2 );
1596 angle1 = (int )( parclist->rarcs[i].angle1 + angle*64./DRAD );
1597 if( angle1 > 0 ) {
1598 while( angle1 > MAXANGLE ) angle1 -= MAXANGLE ;
1599 } else if( angle1 < 0 ) {
1600 while( angle1 < -MAXANGLE ) angle1 += MAXANGLE ;
1601 }
1602 parclist->uarcs[i].angle1 = angle1 ;
1603 parclist->uarcs[i].angle2 = parclist->rarcs[i].angle2 ;
1604 }
1605 } else break ;
1606 }
1607
1608 for( pseglist = pbuffer->pseglist ; pseglist ;
1609 pseglist = (XW_EXT_SEGMENT*)pseglist->link ) {
1610 if( pseglist->nseg > 0 ) {
1611 pseglist->isupdated = True ;
1612 for( i=0 ; i<pseglist->nseg ; i++ ) {
1613 x = pseglist->rsegments[i].x1 - xp ;
1614 y = pseglist->rsegments[i].y1 - yp ;
1615 pseglist->usegments[i].x1 = (short int )( xp + XROTATE(x,y) );
1616 pseglist->usegments[i].y1 = (short int )( yp + YROTATE(x,y) );
1617 x = pseglist->rsegments[i].x2 - xp ;
1618 y = pseglist->rsegments[i].y2 - yp ;
1619 pseglist->usegments[i].x2 = (short int )( xp + XROTATE(x,y) );
1620 pseglist->usegments[i].y2 = (short int )( yp + YROTATE(x,y) );
1621 }
1622 } else break ;
1623 }
1624
1625 for( parclist = pbuffer->plarclist ; parclist ;
1626 parclist = (XW_EXT_ARC*)parclist->link ) {
1627 if( parclist->narc > 0 ) {
1628 parclist->isupdated = True ;
1629 for( i=0 ; i<parclist->narc ; i++ ) {
1630 x = parclist->rarcs[i].x + parclist->rarcs[i].width/2 - xp ;
1631 y = parclist->rarcs[i].y + parclist->rarcs[i].height/2 - yp ;
1632 parclist->uarcs[i].x = (short int )( xp + XROTATE(x,y) -
1633 (int)parclist->rarcs[i].width/2 );
1634 parclist->uarcs[i].y = (short int )( yp + YROTATE(x,y) -
1635 (int)parclist->rarcs[i].height/2 );
1636 angle1 = (int )( parclist->rarcs[i].angle1 + angle*64./DRAD );
1637 if( angle1 > 0 ) {
1638 while( angle1 > MAXANGLE ) angle1 -= MAXANGLE ;
1639 } else if( angle1 < 0 ) {
1640 while( angle1 < -MAXANGLE ) angle1 += MAXANGLE ;
1641 }
1642 parclist->uarcs[i].angle1 = angle1 ;
1643 parclist->uarcs[i].angle2 = parclist->rarcs[i].angle2 ;
1644 }
1645 } else break ;
1646 }
1647
1648 for( pltextlist = pbuffer->pltextlist ; pltextlist ;
1649 pltextlist = (XW_EXT_LTEXT*)pltextlist->link ) {
1650 if( pltextlist->ntext > 0 ) {
1651 pltextlist->isupdated = True ;
1652 for( i=0 ; i<pltextlist->ntext ; i++ ) {
1653 x = pltextlist->rpoints[i].x - xp ;
1654 y = pltextlist->rpoints[i].y - yp ;
1655 pltextlist->upoints[i].x = (short int )( xp + XROTATE(x,y) );
1656 pltextlist->upoints[i].y = (short int )( yp + YROTATE(x,y) );
1657 a = pltextlist->rangles[i] + angle ;
1658 if( a > 0. ) {
c6541a0c 1659 while( a > 2.*M_PI ) a -= 2.*M_PI ;
7fd59977 1660 } else if( a < 0. ) {
c6541a0c 1661 while( a < -2.*M_PI ) a += 2.*M_PI ;
7fd59977 1662 }
1663 pltextlist->uangles[i] = a ;
1664 pltextlist->uscalex[i] = pltextlist->rscalex[i] ;
1665 pltextlist->uscaley[i] = pltextlist->rscaley[i] ;
1666 }
1667 } else break ;
1668 }
1669
1670 for( pptextlist = pbuffer->pptextlist ; pptextlist ;
1671 pptextlist = (XW_EXT_PTEXT*)pptextlist->link ) {
1672 if( pptextlist->ntext > 0 ) {
1673 pptextlist->isupdated = True ;
1674 for( i=0 ; i<pptextlist->ntext ; i++ ) {
1675 x = pptextlist->rpoints[i].x - xp ;
1676 y = pptextlist->rpoints[i].y - yp ;
1677 pptextlist->upoints[i].x = (short int )( xp + XROTATE(x,y) );
1678 pptextlist->upoints[i].y = (short int )( yp + YROTATE(x,y) );
1679 a = pptextlist->rangles[i] + angle ;
1680 if( a > 0. ) {
c6541a0c 1681 while( a > 2.*M_PI ) a -= 2.*M_PI ;
7fd59977 1682 } else if( a < 0. ) {
c6541a0c 1683 while( a < -2.*M_PI ) a += 2.*M_PI ;
7fd59977 1684 }
1685 pptextlist->uangles[i] = a ;
1686 pptextlist->uscalex[i] = pptextlist->rscalex[i] ;
1687 pptextlist->uscaley[i] = pptextlist->rscaley[i] ;
1688 }
1689 } else break ;
1690 }
1691
1692 for( ppmarklist = pbuffer->ppmarklist ; ppmarklist ;
1693 ppmarklist = (XW_EXT_PMARKER*)ppmarklist->link ) {
1694 if( ppmarklist->nmark > 0 ) {
1695 ppmarklist->isupdated = True ;
1696 for( i=n=0 ; i<ppmarklist->nmark ; i++ ) {
1697 x = ppmarklist->rcenters[i].x - xp ;
1698 y = ppmarklist->rcenters[i].y - yp ;
1699 dx = (int )( XROTATE(x,y) - x );
1700 dy = (int )( YROTATE(x,y) - y );
1701 ppmarklist->ucenters[i].x = ppmarklist->rcenters[i].x + dx ;
1702 ppmarklist->ucenters[i].y = ppmarklist->rcenters[i].y + dy ;
1703 for( j=0 ; j<ppmarklist->marks[i] ; j++,n++ ) {
1704 ppmarklist->upoints[n].x = ppmarklist->rpoints[n].x + dx ;
1705 ppmarklist->upoints[n].y = ppmarklist->rpoints[n].y + dy ;
1706 }
1707 }
1708 } else break ;
1709 }
1710
1711 for( plmarklist = pbuffer->plmarklist ; plmarklist ;
1712 plmarklist = (XW_EXT_LMARKER*)plmarklist->link ) {
1713 if( plmarklist->nmark > 0 ) {
1714 plmarklist->isupdated = True ;
1715 for( i=n=0 ; i<plmarklist->nmark ; i++ ) {
1716 x = plmarklist->rcenters[i].x - xp ;
1717 y = plmarklist->rcenters[i].y - yp ;
1718 dx = (int )( XROTATE(x,y) - x );
1719 dy = (int )( YROTATE(x,y) - y );
1720 plmarklist->ucenters[i].x = plmarklist->rcenters[i].x + dx ;
1721 plmarklist->ucenters[i].y = plmarklist->rcenters[i].y + dy ;
1722 for( j=0 ; j<plmarklist->marks[i] ; j++,n++ ) {
1723 plmarklist->usegments[n].x1 = plmarklist->rsegments[n].x1 + dx ;
1724 plmarklist->usegments[n].y1 = plmarklist->rsegments[n].y1 + dy ;
1725 plmarklist->usegments[n].x2 = plmarklist->rsegments[n].x2 + dx ;
1726 plmarklist->usegments[n].y2 = plmarklist->rsegments[n].y2 + dy ;
1727 }
1728 }
1729 } else break ;
1730 }
1731
1732 for( ppntlist = pbuffer->ppntlist ; ppntlist ;
1733 ppntlist = (XW_EXT_POINT*)ppntlist->link ) {
1734 if( ppntlist->npoint > 0 ) {
1735 ppntlist->isupdated = True ;
1736 for( i=0 ; i<ppntlist->npoint ; i++ ) {
1737 x = ppntlist->rpoints[i].x - xp ;
1738 y = ppntlist->rpoints[i].y - yp ;
1739 ppntlist->upoints[i].x = (short int )( xp + XROTATE(x,y) );
1740 ppntlist->upoints[i].y = (short int )( yp + YROTATE(x,y) );
1741 }
1742 } else break ;
1743 }
1744
1745 for( ppolylist = pbuffer->ppolylist ; ppolylist ;
1746 ppolylist = (XW_EXT_POLY*)ppolylist->link ) {
1747 if( ppolylist->npoly > 0 ) {
1748 ppolylist->isupdated = True ;
1749 } else break ;
1750 }
1751
1752 for( plinelist = pbuffer->plinelist ; plinelist ;
1753 plinelist = (XW_EXT_LINE*)plinelist->link ) {
1754 if( plinelist->nline > 0 ) {
1755 plinelist->isupdated = True ;
1756 } else break ;
1757 }
1758
1759 for( plinedesc = pbuffer->plinedesc ; plinedesc ;
1760 plinedesc = (XW_EXT_POINT*)plinedesc->link ) {
1761 if( plinedesc->npoint > 0 ) {
1762 plinedesc->isupdated = True ;
1763 for( i=0 ; i<plinedesc->npoint ; i++ ) {
1764 x = plinedesc->rpoints[i].x - xp ;
1765 y = plinedesc->rpoints[i].y - yp ;
1766 plinedesc->upoints[i].x = (short int )( xp + XROTATE(x,y) );
1767 plinedesc->upoints[i].y = (short int )( yp + YROTATE(x,y) );
1768 }
1769 } else break ;
1770 }
1771
1772 pbuffer->dangle = angle ;
1773 pbuffer->uxmin = _WIDTH ;
1774 pbuffer->uymin = _HEIGHT ;
1775 pbuffer->uxmax = 0 ;
1776 pbuffer->uymax = 0 ;
1777
1778 x = (int )( xp + XROTATE(dxmin,dymin) );
1779 pbuffer->uxmin = min(pbuffer->uxmin,x) ;
1780 pbuffer->uxmax = max(pbuffer->uxmax,x) ;
1781 y = (int )( yp + YROTATE(dxmin,dymin) );
1782 pbuffer->uymin = min(pbuffer->uymin,y) ;
1783 pbuffer->uymax = max(pbuffer->uymax,y) ;
1784
1785 x = (int )( xp + XROTATE(dxmax,dymin) );
1786 pbuffer->uxmin = min(pbuffer->uxmin,x) ;
1787 pbuffer->uxmax = max(pbuffer->uxmax,x) ;
1788 y = (int )( yp + YROTATE(dxmax,dymin) );
1789 pbuffer->uymin = min(pbuffer->uymin,y) ;
1790 pbuffer->uymax = max(pbuffer->uymax,y) ;
1791
1792 x = (int )( xp + XROTATE(dxmin,dymax) );
1793 pbuffer->uxmin = min(pbuffer->uxmin,x) ;
1794 pbuffer->uxmax = max(pbuffer->uxmax,x) ;
1795 y = (int )( yp + YROTATE(dxmin,dymax) );
1796 pbuffer->uymin = min(pbuffer->uymin,y) ;
1797 pbuffer->uymax = max(pbuffer->uymax,y) ;
1798
1799 x = (int )( xp + XROTATE(dxmax,dymax) );
1800 pbuffer->uxmin = min(pbuffer->uxmin,x) ;
1801 pbuffer->uxmax = max(pbuffer->uxmax,x) ;
1802 y = (int )( yp + YROTATE(dxmax,dymax) );
1803 pbuffer->uymin = min(pbuffer->uymin,y) ;
1804 pbuffer->uymax = max(pbuffer->uymax,y) ;
1805
1806 uxmin = min(uxmin,pbuffer->uxmin) ;
1807 uymin = min(uymin,pbuffer->uymin) ;
1808 uxmax = max(uxmax,pbuffer->uxmax) ;
1809 uymax = max(uymax,pbuffer->uymax) ;
1810
1811 pbuffer->isupdated = ROTATE_BUFFER ;
1812
1813 }
1814
1815 Xw_draw_buffer(pwindow,bufferid) ;
1816
1817 if( QGTYPE(pbuffer->code) == XW_ENABLE ) {
1818 int x = uxmin - 1 ;
1819 int y = uymin - 1 ;
1820 int w = uxmax - x + 1 ;
1821 int h = uymax - y + 1 ;
1822
1823 if( x < 0 ) x = 0 ;
1824 if( y < 0 ) y = 0 ;
1825 if( x+w > _WIDTH ) w = _WIDTH - x ;
1826 if( y+h > _HEIGHT ) h = _HEIGHT - y ;
1827
1828 if( _NWBUFFER > 0 ) {
1829 XCopyArea(_DISPLAY,_BWBUFFER,_FWBUFFER,
1830 pwindow->qgwind.gccopy,x,y,w,h,x,y) ;
1831 } else if( _PIXMAP ) {
1832 XCopyArea(_DISPLAY,_PIXMAP,_WINDOW,
1833 pwindow->qgwind.gccopy,x,y,w,h,x,y) ;
1834 }
1835 XFlush(_DISPLAY) ;
1836 }
1837 pbuffer->isretain = False ;
1838
1839#ifdef TRACE_DRAW_BUFFER
1840 if( Xw_get_trace() ) {
1841 printf (" Xw_rotate_buffer(%lx,%d,%f)\n",(long ) pwindow,bufferid,angle) ;
1842 }
1843#endif
1844
1845 return (XW_SUCCESS);
1846}
1847
1848/*
1849 STATUS Xw_scale_buffer (awindow,bufferid,xscale,yscale)
1850 XW_EXT_WINDOW *awindow
1851 int bufferid
1852 float xscale,yscale Last scale factors since the creation time
1853
1854 scale & display one retain buffer of primitives at screen
1855
1856 Returns ERROR if the extended window address is badly defined
1857 or one of scale factor is <= 0.
1858 or Buffer is empty
1859 or Buffer is not opened
1860 Returns SUCCESS if successful
1861
1862*/
1863
1864#ifdef XW_PROTOTYPE
1865XW_STATUS Xw_scale_buffer (void* awindow,int bufferid,float xscale,float yscale)
1866#else
1867XW_STATUS Xw_scale_buffer (awindow,bufferid,xscale,yscale)
1868void *awindow;
1869int bufferid;
1870float xscale,yscale;
1871#endif /*XW_PROTOTYPE*/
1872{
1873XW_EXT_WINDOW *pwindow = (XW_EXT_WINDOW*)awindow;
1874XW_EXT_BUFFER *pbuffer ;
1875XW_EXT_IMAGE *pimaglist ;
1876XW_EXT_POLY *ppolylist ;
1877XW_EXT_LINE *plinelist ;
1878XW_EXT_SEGMENT *pseglist ;
1879XW_EXT_LTEXT *pltextlist ;
1880XW_EXT_PTEXT *pptextlist ;
1881XW_EXT_ARC *parclist ;
1882XW_EXT_PMARKER *ppmarklist ;
1883XW_EXT_LMARKER *plmarklist ;
1884XW_EXT_POINT *ppntlist ;
1885XW_EXT_POINT *plinedesc ;
1886int i,j,n,x,y,dx,dy,xp,yp ;
1887int rxmin,rymin,rxmax,rymax ;
1888int uxmin,uymin,uxmax,uymax ;
1889
1890 if( !Xw_isdefine_window(pwindow) ) {
1891 /*ERROR*Bad EXT_WINDOW Address*/
1892 Xw_set_error(24,"Xw_scale_buffer",pwindow) ;
1893 return (XW_ERROR) ;
1894 }
1895
1896 pbuffer = Xw_get_buffer_structure(pwindow,bufferid) ;
1897 if( !pbuffer ) {
1898 /*ERROR*BUFFER is not opened*/
1899 Xw_set_error(119,"Xw_scale_buffer",&bufferid) ;
1900 return (XW_ERROR) ;
1901 }
1902
1903 if( xscale <= 0. ) { ;
1904 /*ERROR*Bad BUFFER scale factor*/
1905 Xw_set_error(123,"Xw_scale_buffer",&xscale) ;
1906 return (XW_ERROR) ;
1907 }
1908
1909 if( yscale <= 0. ) { ;
1910 /*ERROR*Bad BUFFER scale factor*/
1911 Xw_set_error(123,"Xw_scale_buffer",&yscale) ;
1912 return (XW_ERROR) ;
1913 }
1914
1915 if( pbuffer->isempty ) return XW_ERROR ;
1916
1917 pbuffer->isretain = True ;
1918 if( pbuffer->isdrawn ) {
1919 Xw_erase_buffer(pwindow,bufferid) ;
1920 }
1921
1922 if( pbuffer->isupdated != SCALE_BUFFER ) {
1923 if( pbuffer->isupdated ) Xw_update_buffer(pwindow,pbuffer) ;
1924 }
1925
1926 xp = pbuffer->xpivot ;
1927 yp = pbuffer->ypivot ;
1928
1929 rxmin = pbuffer->rxmin ;
1930 rymin = pbuffer->rymin ;
1931 rxmax = pbuffer->rxmax ;
1932 rymax = pbuffer->rymax ;
1933
1934 if( pbuffer->isupdated ) {
1935 uxmin = pbuffer->uxmin ;
1936 uymin = pbuffer->uymin ;
1937 uxmax = pbuffer->uxmax ;
1938 uymax = pbuffer->uymax ;
1939 } else {
1940 uxmin = rxmin ; uymin = rymin ;
1941 uxmax = rxmax ; uymax = rymax ;
1942 }
1943
1944 if( xscale != pbuffer->xscale || yscale != pbuffer->yscale ) {
1945 int dxmin = rxmin - xp ;
1946 int dymin = rymin - yp ;
1947 int dxmax = rxmax - xp ;
1948 int dymax = rymax - yp ;
1949
1950 for( pimaglist = pbuffer->pimaglist ; pimaglist ;
1951 pimaglist = (XW_EXT_IMAGE*)pimaglist->link ) {
1952 if( pimaglist->nimage > 0 ) {
1953 pimaglist->isupdated = True ;
1954 for( i=0 ; i<pimaglist->nimage ; i++ ) {
1955 x = pimaglist->rpoints[i].x - xp ;
1956 y = pimaglist->rpoints[i].y - yp ;
1957 dx = ROUND(xscale*x) - x ; dy = ROUND(yscale*y) - y ;
1958 pimaglist->upoints[i].x = pimaglist->rpoints[i].x + dx ;
1959 pimaglist->upoints[i].y = pimaglist->rpoints[i].y + dy ;
1960 }
1961 } else break ;
1962 }
1963
1964 for( parclist = pbuffer->pparclist ; parclist ;
1965 parclist = (XW_EXT_ARC*)parclist->link ) {
1966 if( parclist->narc > 0 ) {
1967 parclist->isupdated = True ;
1968 for( i=0 ; i<parclist->narc ; i++ ) {
1969 dx = parclist->rarcs[i].width/2 ;
1970 dy = parclist->rarcs[i].height/2 ;
1971 x = parclist->rarcs[i].x + dx - xp ;
1972 y = parclist->rarcs[i].y + dy - yp ;
1973 x = ROUND(xscale*x) ; y = ROUND(yscale*y) ;
1974 dx = ROUND(xscale*dx) ; dy = ROUND(yscale*dy) ;
1975 parclist->uarcs[i].width = 2*dx ;
1976 parclist->uarcs[i].height = 2*dy ;
1977 parclist->uarcs[i].x = xp + x - dx ;
1978 parclist->uarcs[i].y = yp + y - dy ;
1979 parclist->uarcs[i].angle1 = parclist->rarcs[i].angle1 ;
1980 parclist->uarcs[i].angle2 = parclist->rarcs[i].angle2 ;
1981 }
1982 } else break ;
1983 }
1984
1985 for( pseglist = pbuffer->pseglist ; pseglist ;
1986 pseglist = (XW_EXT_SEGMENT*)pseglist->link ) {
1987 if( pseglist->nseg > 0 ) {
1988 pseglist->isupdated = True ;
1989 for( i=0 ; i<pseglist->nseg ; i++ ) {
1990 x = pseglist->rsegments[i].x1 - xp ;
1991 y = pseglist->rsegments[i].y1 - yp ;
1992 dx = ROUND(xscale*x) - x ; dy = ROUND(yscale*y) - y ;
1993 pseglist->usegments[i].x1 = pseglist->rsegments[i].x1 + dx ;
1994 pseglist->usegments[i].y1 = pseglist->rsegments[i].y1 + dy ;
1995 x = pseglist->rsegments[i].x2 - xp ;
1996 y = pseglist->rsegments[i].y2 - yp ;
1997 dx = ROUND(xscale*x) - x ; dy = ROUND(yscale*y) - y ;
1998 pseglist->usegments[i].x2 = pseglist->rsegments[i].x2 + dx ;
1999 pseglist->usegments[i].y2 = pseglist->rsegments[i].y2 + dy ;
2000 }
2001 } else break ;
2002 }
2003
2004 for( parclist = pbuffer->plarclist ; parclist ;
2005 parclist = (XW_EXT_ARC*)parclist->link ) {
2006 if( parclist->narc > 0 ) {
2007 parclist->isupdated = True ;
2008 for( i=0 ; i<parclist->narc ; i++ ) {
2009 dx = parclist->rarcs[i].width/2 ;
2010 dy = parclist->rarcs[i].height/2 ;
2011 x = parclist->rarcs[i].x + dx - xp ;
2012 y = parclist->rarcs[i].y + dy - yp ;
2013 x = ROUND(xscale*x) ; y = ROUND(yscale*y) ;
2014 dx = ROUND(xscale*dx) ; dy = ROUND(yscale*dy) ;
2015 parclist->uarcs[i].width = 2*dx ;
2016 parclist->uarcs[i].height = 2*dy ;
2017 parclist->uarcs[i].x = xp + x - dx ;
2018 parclist->uarcs[i].y = yp + y - dy ;
2019 parclist->uarcs[i].angle1 = parclist->rarcs[i].angle1 ;
2020 parclist->uarcs[i].angle2 = parclist->rarcs[i].angle2 ;
2021 }
2022 } else break ;
2023 }
2024
2025 for( pltextlist = pbuffer->pltextlist ; pltextlist ;
2026 pltextlist = (XW_EXT_LTEXT*)pltextlist->link ) {
2027 if( pltextlist->ntext > 0 ) {
2028 pltextlist->isupdated = True ;
2029 for( i=0 ; i<pltextlist->ntext ; i++ ) {
2030 x = pltextlist->rpoints[i].x - xp ;
2031 y = pltextlist->rpoints[i].y - yp ;
2032 dx = ROUND(xscale*x) - x ; dy = ROUND(yscale*y) - y ;
2033 pltextlist->upoints[i].x = pltextlist->rpoints[i].x + dx ;
2034 pltextlist->upoints[i].y = pltextlist->rpoints[i].y + dy ;
2035 pltextlist->uangles[i] = pltextlist->rangles[i] ;
2036 pltextlist->uscalex[i] = pltextlist->rscalex[i] * xscale;
2037 pltextlist->uscaley[i] = pltextlist->rscaley[i] * yscale;
2038 }
2039 } else break ;
2040 }
2041
2042 for( pptextlist = pbuffer->pptextlist ; pptextlist ;
2043 pptextlist = (XW_EXT_PTEXT*)pptextlist->link ) {
2044 if( pptextlist->ntext > 0 ) {
2045 pptextlist->isupdated = True ;
2046 for( i=0 ; i<pptextlist->ntext ; i++ ) {
2047 x = pptextlist->rpoints[i].x - xp ;
2048 y = pptextlist->rpoints[i].y - yp ;
2049 dx = ROUND(xscale*x) - x ; dy = ROUND(yscale*y) - y ;
2050 pptextlist->upoints[i].x = pptextlist->rpoints[i].x + dx ;
2051 pptextlist->upoints[i].y = pptextlist->rpoints[i].y + dy ;
2052 pptextlist->uangles[i] = pptextlist->rangles[i] ;
2053 pptextlist->uscalex[i] = pptextlist->rscalex[i] * xscale;
2054 pptextlist->uscaley[i] = pptextlist->rscaley[i] * yscale;
2055 }
2056 } else break ;
2057 }
2058
2059 for( ppmarklist = pbuffer->ppmarklist ; ppmarklist ;
2060 ppmarklist = (XW_EXT_PMARKER*)ppmarklist->link ) {
2061 if( ppmarklist->nmark > 0 ) {
2062 ppmarklist->isupdated = True ;
2063 for( i=n=0 ; i<ppmarklist->nmark ; i++ ) {
2064 x = ppmarklist->rcenters[i].x - xp ;
2065 y = ppmarklist->rcenters[i].y - yp ;
2066 dx = ROUND(xscale*x) - x ; dy = ROUND(yscale*y) - y ;
2067 ppmarklist->ucenters[i].x = ppmarklist->rcenters[i].x + dx ;
2068 ppmarklist->ucenters[i].y = ppmarklist->rcenters[i].y + dy ;
2069 for( j=0 ; j<ppmarklist->marks[i] ; j++,n++ ) {
2070 ppmarklist->upoints[n].x = ppmarklist->rpoints[n].x + dx ;
2071 ppmarklist->upoints[n].y = ppmarklist->rpoints[n].y + dy ;
2072 }
2073 }
2074 } else break ;
2075 }
2076
2077 for( plmarklist = pbuffer->plmarklist ; plmarklist ;
2078 plmarklist = (XW_EXT_LMARKER*)plmarklist->link ) {
2079 if( plmarklist->nmark > 0 ) {
2080 plmarklist->isupdated = True ;
2081 for( i=n=0 ; i<plmarklist->nmark ; i++ ) {
2082 x = plmarklist->rcenters[i].x - xp ;
2083 y = plmarklist->rcenters[i].y - yp ;
2084 dx = ROUND(xscale*x) - x ; dy = ROUND(yscale*y) - y ;
2085 plmarklist->ucenters[i].x = plmarklist->rcenters[i].x + dx ;
2086 plmarklist->ucenters[i].y = plmarklist->rcenters[i].y + dy ;
2087 for( j=0 ; j<plmarklist->marks[i] ; j++,n++ ) {
2088 plmarklist->usegments[n].x1 = plmarklist->rsegments[n].x1 + dx ;
2089 plmarklist->usegments[n].y1 = plmarklist->rsegments[n].y1 + dy ;
2090 plmarklist->usegments[n].x2 = plmarklist->rsegments[n].x2 + dx ;
2091 plmarklist->usegments[n].y2 = plmarklist->rsegments[n].y2 + dy ;
2092 }
2093 }
2094 } else break ;
2095 }
2096
2097 for( ppntlist = pbuffer->ppntlist ; ppntlist ;
2098 ppntlist = (XW_EXT_POINT*)ppntlist->link ) {
2099 if( ppntlist->npoint > 0 ) {
2100 ppntlist->isupdated = True ;
2101 for( i=0 ; i<ppntlist->npoint ; i++ ) {
2102 x = ppntlist->rpoints[i].x - xp ;
2103 y = ppntlist->rpoints[i].y - yp ;
2104 dx = ROUND(xscale*x) - x ; dy = ROUND(yscale*y) - y ;
2105 ppntlist->upoints[i].x = ppntlist->rpoints[i].x + dx ;
2106 ppntlist->upoints[i].y = ppntlist->rpoints[i].y + dy ;
2107 }
2108 } else break ;
2109 }
2110
2111 for( ppolylist = pbuffer->ppolylist ; ppolylist ;
2112 ppolylist = (XW_EXT_POLY*)ppolylist->link ) {
2113 if( ppolylist->npoly > 0 ) {
2114 ppolylist->isupdated = True ;
2115 } else break ;
2116 }
2117
2118 for( plinelist = pbuffer->plinelist ; plinelist ;
2119 plinelist = (XW_EXT_LINE*)plinelist->link ) {
2120 if( plinelist->nline > 0 ) {
2121 plinelist->isupdated = True ;
2122 } else break ;
2123 }
2124
2125 for( plinedesc = pbuffer->plinedesc ; plinedesc ;
2126 plinedesc = (XW_EXT_POINT*)plinedesc->link ) {
2127 if( plinedesc->npoint > 0 ) {
2128 plinedesc->isupdated = True ;
2129 for( i=0 ; i<plinedesc->npoint ; i++ ) {
2130 x = plinedesc->rpoints[i].x - xp ;
2131 y = plinedesc->rpoints[i].y - yp ;
2132 dx = ROUND(xscale*x) - x ; dy = ROUND(yscale*y) - y ;
2133 plinedesc->upoints[i].x = plinedesc->rpoints[i].x + dx ;
2134 plinedesc->upoints[i].y = plinedesc->rpoints[i].y + dy ;
2135 }
2136 } else break ;
2137 }
2138
2139 pbuffer->dxscale = xscale ;
2140 pbuffer->dyscale = yscale ;
2141 x = ROUND(xscale*dxmin) ; y = ROUND(yscale*dymin) ;
2142 pbuffer->uxmin = xp + x ;
2143 pbuffer->uymin = yp + y ;
2144 x = ROUND(xscale*dxmax) ; y = ROUND(yscale*dymax) ;
2145 pbuffer->uxmax = xp + x ;
2146 pbuffer->uymax = yp + y ;
2147
2148 uxmin = min(uxmin,pbuffer->uxmin) ;
2149 uymin = min(uymin,pbuffer->uymin) ;
2150 uxmax = max(uxmax,pbuffer->uxmax) ;
2151 uymax = max(uymax,pbuffer->uymax) ;
2152
2153 pbuffer->isupdated = SCALE_BUFFER ;
2154
2155 }
2156
2157 Xw_draw_buffer(pwindow,bufferid) ;
2158
2159 if( QGTYPE(pbuffer->code) == XW_ENABLE ) {
2160 int x = uxmin - 1 ;
2161 int y = uymin - 1 ;
2162 int w = uxmax - x + 1 ;
2163 int h = uymax - y + 1 ;
2164
2165 if( x < 0 ) x = 0 ;
2166 if( y < 0 ) y = 0 ;
2167 if( x+w > _WIDTH ) w = _WIDTH - x ;
2168 if( y+h > _HEIGHT ) h = _HEIGHT - y ;
2169
2170 if( _NWBUFFER > 0 ) {
2171 XCopyArea(_DISPLAY,_BWBUFFER,_FWBUFFER,
2172 pwindow->qgwind.gccopy,x,y,w,h,x,y) ;
2173 } else if( _PIXMAP ) {
2174 XCopyArea(_DISPLAY,_PIXMAP,_WINDOW,
2175 pwindow->qgwind.gccopy,x,y,w,h,x,y) ;
2176 }
2177 XFlush(_DISPLAY) ;
2178 }
2179 pbuffer->isretain = False ;
2180
2181#ifdef TRACE_DRAW_BUFFER
2182 if( Xw_get_trace() ) {
2183 printf (" Xw_scale_buffer(%lx,%d,%f,%f)\n",
2184 (long ) pwindow,bufferid,xscale,yscale) ;
2185 }
2186#endif
2187
2188 return (XW_SUCCESS);
2189}