[comp.windows.x] Xfig2 patch to correct object redraw order

tkacik@rphroy.UUCP (Tom Tkacik) (04/12/90)

Xfig2 patchlevel 5 has added the feature that filled objects are now
drawn opaquely.  This is the feature I have been waiting for.
Unfortunately, with opaque objects, order becomes important,
(in what order are the objects drawn).

It is not possible to bring an object to the front, but you can push
it to the back.  By deleting an object and then hitting UNDO,
the object moves to the front of some internal object list,
will be the first of that type of object to be drawn, and will be in the
background.  The object will appear on top until you hit the REDRAW button.

Worse is that the order objects are drawn on the screen is different than
the order f2ps has them print on a page.  The worst kind of WYSIWYG.
What You See Is What You DON'T Get.

This patch hopefully corrects that.  I modified the redisplay.c routines
so that objects display as you will get them on paper.  I have not attempted
to improve that order.  I leave that as an exercise for the hacker :-).

Note that I have changed the screen redisplay routine, and not f2ps, so
some of your figures may now look different.  They will print the same.

Anyway, here are my patches.

--
Tom Tkacik			GM Research Labs,   Warren MI  48090
Work phone: (313)986-1442	uunet!edsews!rphroy!megatron!tkacik
"I'm president of the United States, and I'm not going to eat anymore broccoli."
						--- Bush
------------------------------------------------------------
*** redisplay.c~	Wed Apr 11 13:27:50 1990
--- redisplay.c	Wed Apr 11 17:25:28 1990
***************
*** 24,32 ****
  		return;
  	for (fill=1; fill >= 0; fill--)
  		{
- 		redisplay_lineobject(objects->lines,fill);
- 		redisplay_ellipseobject(objects->ellipses,fill);
  		redisplay_arcobject(objects->arcs,fill);
  		redisplay_splineobject(objects->splines,fill);
  		}
  	if (pointmarker_shown)	/* show the point markers if they are on */
--- 24,33 ----
  		return;
  	for (fill=1; fill >= 0; fill--)
  		{
  		redisplay_arcobject(objects->arcs,fill);
+ 		redisplay_compoundobject(objects->compounds,fill);
+ 		redisplay_ellipseobject(objects->ellipses,fill);
+ 		redisplay_lineobject(objects->lines,fill);
  		redisplay_splineobject(objects->splines,fill);
  		}
  	if (pointmarker_shown)	/* show the point markers if they are on */
***************
*** 36,43 ****
  	    for (c = objects->compounds; c != NULL; c = c->next)
  		draw_compoundbox(c, INV_PAINT);	/* show the compound boxes */
  	    }
- 	/* fill compound objects later */
- 	redisplay_compoundobject(objects->compounds);
  	/* text doesn't have fill mode */
  	redisplay_textobject(objects->texts);
  	}
--- 37,42 ----
***************
*** 98,106 ****
  		}
  	}
  
! redisplay_textobject(texts,fill)
  F_text	*texts;
- int fill;
  {
  	F_text	*t;
  
--- 97,104 ----
  		}
  	}
  
! redisplay_textobject(texts)
  F_text	*texts;
  {
  	F_text	*t;
  
***************
*** 108,120 ****
  	    draw_text(t, PAINT);
  	}
  
! redisplay_compoundobject(compounds)
  F_compound	*compounds;
  {
  	F_compound	*c;
  
  	for (c = compounds; c != NULL; c = c->next)
! 		draw_compound(c);
  	}
  
  redisplay_canvas()
--- 106,131 ----
  	    draw_text(t, PAINT);
  	}
  
! redisplay_compoundobject(compounds,fill)
  F_compound	*compounds;
+ int fill;
  {
  	F_compound	*c;
  
+ 	if(compounds == NULL)
+ 		return;
+ 
+ 	redisplay_arcobject(compounds->arcs,fill);
  	for (c = compounds; c != NULL; c = c->next)
! 		redisplay_compoundobject(c->compounds,fill);
! 	redisplay_ellipseobject(compounds->ellipses,fill);
! 	redisplay_lineobject(compounds->lines,fill);
! 	redisplay_splineobject(compounds->splines,fill);
! 
! 	/* no filled text mode, just do text on non-filled pass */
! 	if(fill==0) {
! 		redisplay_textobject(compounds->texts);
! 		}
  	}
  
  redisplay_canvas()
-- 
Tom Tkacik			GM Research Labs,   Warren MI  48090
Work phone: (313)986-1442	uunet!edsews!rphroy!megatron!tkacik
"I'm president of the United States, and I'm not going to eat anymore broccoli."
						--- Bush

envbvs@epb2.lbl.gov (Brian V. Smith) (04/12/90)

Thanks for posting this patch.
Someday (soon?) there will be a restacking button to re-order
the objects on the screen (and printer).
Your patch will be included in patchlevel 6.
_____________________________________
Brian V. Smith    (bvsmith@lbl.gov)
Lawrence Berkeley Laboratory
I don't speak for LBL, these non-opinions are all mine.