Received: by ATHENA-PO-3.MIT.EDU (5.45/4.7) id AA12852; Mon, 8 Apr 91 09:21:31 EST
Received: from munnari.OZ.AU by ATHENA.MIT.EDU with SMTP
	id AA27848; Mon, 8 Apr 91 10:21:00 EDT
Received: from melba.bby.oz (via ditmela) by munnari.oz.au with SunIII (5.64+1.3.1+0.50)
	id AA21221; Tue, 9 Apr 1991 00:20:46 +1000 (from gnb%bby.oz.au@melba.bby.oz.au)
Received: from baby.bby.oz.au by melba.bby.oz.au (4.0/SMI-4.0/BBY)
	id AA07199; Mon, 8 Apr 91 17:17:02 EST
       (from gnb@bby.oz.au for bug-at%athena.mit.edu@munnari.oz)
Received: by baby.bby.oz.au (4.1/SMI-4.1)
	id AA19646; Mon, 8 Apr 91 17:16:51 EST
Message-Id: <9104080716.AA19646@baby.bby.oz.au>
To: bug-at@ATHENA.MIT.EDU
Cc: vanandel@stout.atd.ucar.edu (Joe Van Andel)
Subject: AtPlotter bug-of-the-day club: displayed constraint variable
Date: Mon, 08 Apr 91 17:16:48 +1000
From: Gregory Bond <gnb@bby.oz.au>

Guys,

I pointed out last week that the displayed constraint variable was
ignored.  I have fixed this, I think, but there are a few caveats with
these fixes:

1) It seems to work on my static cases.  I don't know what the
   quick-update code is supposed to do, so I haven't tested this.
2) It changes the size of the AtPlotter instance record, so existing
   code will need to be recompiled.  (Only deletes stuff, so you could
   replace it with dummys I suppose).
3) I have removed all distinctions between barchart and other children
   in the ranking code.  All plots are now drawn in birthorder or
   rankorder irrespective of graph type.  It is up to applications
   writer/resource user to specify rankorders correctly if the overlap
   of line and barcharts is a problem. (This not only is more
   flexible, it is more symetric and makes the code a lot simpler).

Included are two other 1-line nit fixes:

1) The Plotter`SetValues routine was copying the title string instead of
   the fontFamily string.

2) The Plotter`ConstraintSetValues routine was not forceing a geometry
   recalc when a plot was changed from yaxis to y2axis.

-----------

Bugs I have identified and will fix soon:

1) Make xaxis and yaxis optional in the same way y2axis is.  I hope to
   fix a bug in the legend positioning then also, where if you use a
   y2 axis, there is space left between the RHS of the graph and the
   LHS of the legend for the axis numbering, but it is not used as the
   numbering is inside the graph area.  This pushes the legend a long
   way to the right.

2) The ticMultiplier is never used.

------------

Some ideas I have:

1) A legend below the graph (or above, or left) instead of stuck at
   the right.

2) A callback to call after the axis geometry has been calculated, but
   before it is used.  This allows a programmer to impose restraints
   on axis values (e.g. y2 scale factor same as y; y axis starts at
   zero, etc), and force two graphs to have identical X scales, etc.
   Is this already possible???

Greg, Plotter-hacker.
-- 
Gregory Bond, Burdett Buckeridge & Young Ltd, Melbourne, Australia
Internet: gnb@melba.bby.oz.au    non-MX: gnb%melba.bby.oz@uunet.uu.net
Uucp: {uunet,pyramid,ubc-cs,ukc,mcvax,prlb2,nttlab...}!munnari!melba.bby.oz!gnb

Diffs follow.

*** ../tmp/PlotterP.h	Tue Mar 19 03:46:03 1991
--- PlotterP.h	Mon Apr  8 12:43:56 1991
***************
*** 82,91 ****
  
      /* private state */
  
!     Rank *ordered_children;    /* rank ordered list of barchart children */
!     Widget *nonbar_children;   /* birth ordered list of non-bar children */
!     int num_nonbar_children;
!     int nonbar_children_size;
      Region clip_region;
      AtFontFamily *ff;
      GC titleGC, legendGC, dragGC;
--- 82,88 ----
  
      /* private state */
  
!     Rank *ordered_children;    /* rank ordered list of all children */
      Region clip_region;
      AtFontFamily *ff;
      GC titleGC, legendGC, dragGC;
*** ../tmp/Plotter.c	Tue Mar 19 03:46:00 1991
--- Plotter.c	Mon Apr  8 16:44:32 1991
***************
*** 49,54 ****
--- 49,56 ----
  #define NUMCHILDREN(w) (w->composite.num_children)
  #define CHILD(w,i) (w->composite.children[i])
  #define CONSTRAINT(w,i) ((AtPlotterConstraints)(CHILD(w,i)->core.constraints))
+ #define ISDISPLAYED(cw) (((AtPlotterConstraints)((AtPlotWidgetClass)(cw)->core.constraints))->plotter.displayed)
+ #define NTHCHILDISDISPLAYED(pw,i) (CONSTRAINT(pw, i)->plotter.displayed)
  #define REDRAWPLOT(pw, p, r) (*((AtPlotWidgetClass)p->core.widget_class)->plot_class.draw)(XtDisplay(pw), XtWindow(pw), (AtPlotWidget)p, XSCALE(pw), YSCALEPLOT(pw, p), r)
  #define REDRAWCHILD(w,i,r) (*((AtPlotWidgetClass)CHILD(w,i)->core.widget_class)->plot_class.draw)(XtDisplay(w), XtWindow(w), (AtPlotWidget)CHILD(w,i), XSCALE(w), YSCALE(w,i), r)
  #define RESIZECHILD(w,i) (*((AtPlotWidgetClass)CHILD(w,i)->core.widget_class)->plot_class.resize)((AtPlotWidget)CHILD(w,i), XSCALE(w), YSCALE(w,i))
***************
*** 425,434 ****
    new->plotter.boundingBox.y2max = new->plotter.y2axis->axis.max;
    new->plotter.newBoundingBox = False;
    new->plotter.ordered_children = NULL;
-   new->plotter.nonbar_children = NULL;
-   new->plotter.num_nonbar_children = 0; /* number of children on the
- 					   nonbar_children list */
-   new->plotter.nonbar_children_size = 0;
  }
  
  /* Called by the redisplay procedure and some other places */
--- 427,432 ----
***************
*** 504,519 ****
    if (pw->plotter.rankChildren) { /* draw children according to rank */
      Rank *tmp = pw->plotter.ordered_children;
      while (tmp) {
!       REDRAWPLOT(pw, tmp->child, region);
        tmp = tmp->next;
      }
-     /* now, draw the non-barchart children */
-     for (i = 0; i < pw->plotter.num_nonbar_children; i++)
-       REDRAWPLOT(pw, pw->plotter.nonbar_children[i], region);
    }
    else /* draw children according to birth */
      for(i=0; i<pw->composite.num_children; i++)
!       REDRAWCHILD(pw, i, region);
      
      return;
  }    
--- 502,516 ----
    if (pw->plotter.rankChildren) { /* draw children according to rank */
      Rank *tmp = pw->plotter.ordered_children;
      while (tmp) {
!       if (ISDISPLAYED(tmp->child)) 
! 	REDRAWPLOT(pw, tmp->child, region);
        tmp = tmp->next;
      }
    }
    else /* draw children according to birth */
      for(i=0; i<pw->composite.num_children; i++)
!       if (NTHCHILDISDISPLAYED(pw, i)) 
! 	REDRAWCHILD(pw, i, region);
      
      return;
  }    
***************
*** 564,572 ****
      XtFree(tmp);
    }
  
-   /* free the list of nonbar_children */
-   XtFree(pw->plotter.nonbar_children);
- 
    return;
  }
  
--- 561,566 ----
***************
*** 585,592 ****
      ResizeLegend(pw);
  	
      /* Resize the plots */
!     for(i=0; i<pw->composite.num_children; i++) 
!       RESIZECHILD(pw,i);
    }
  }
  
--- 579,587 ----
      ResizeLegend(pw);
  	
      /* Resize the plots */
!     for(i=0; i<pw->composite.num_children; i++)
!       if (NTHCHILDISDISPLAYED(pw, i))
! 	RESIZECHILD(pw,i);
    }
  }
  
***************
*** 639,645 ****
  
    if (Changed(fontFamily)) {
      XtFree(current->plotter.fontFamily);
!     new->plotter.fontFamily = AtNewString(new->plotter.title);
      AtFontFamilyRelease(new->plotter.ff);
      new->plotter.ff = AtFontFamilyGet(XtDisplay(new),
  				      new->plotter.fontFamily);
--- 634,640 ----
  
    if (Changed(fontFamily)) {
      XtFree(current->plotter.fontFamily);
!     new->plotter.fontFamily = AtNewString(new->plotter.fontFamily);
      AtFontFamilyRelease(new->plotter.ff);
      new->plotter.ff = AtFontFamilyGet(XtDisplay(new),
  				      new->plotter.fontFamily);
***************
*** 967,974 ****
  			  w->plotter.yaxis->axis.subtics);
    }
      
!   for(i=0; i<NUMCHILDREN(w); i++) 
!     RESIZECHILD(w, i);
  }
  
  
--- 962,970 ----
  			  w->plotter.yaxis->axis.subtics);
    }
      
!   for(i=0; i<NUMCHILDREN(w); i++)
!     if (NTHCHILDISDISPLAYED(w, i))
!       RESIZECHILD(w, i);
  }
  
  
***************
*** 1018,1023 ****
--- 1014,1027 ----
    int i, j;
    Boolean redrawn = False;
  
+   if (Changed(boundingBox.xmin) || Changed(boundingBox.xmax) ||
+       Changed(boundingBox.ymin) || Changed(boundingBox.ymax) ||
+       Changed(useY2Axis)) { 
+     parent->plotter.newBoundingBox = True;
+   }
+ 
+   if (!XtWindow(parent)) { return False;  }
+   
    if (Changed(legendName)) {
      FreeLegendText(curc,newc);
      GetLegendText(newc, (AtPlotterWidget)XtParent(new));
***************
*** 1025,1035 ****
      RedrawLegend(parent);
    }
  
-   if (Changed(boundingBox.xmin) || Changed(boundingBox.xmax) ||
-       Changed(boundingBox.ymin) || Changed(boundingBox.ymax)) {
-     parent->plotter.newBoundingBox = True;
-   }
- 
    if (parent->plotter.rankChildren && Changed(rankOrder))  {
      ReRankOrderChildren(new);
      newc->plotter.needsRedraw = True;
--- 1029,1034 ----
***************
*** 1042,1048 ****
    }
    else if (newc->plotter.needsRefresh == True)  {
      if (!redrawn)  {
!       if (XtIsSubclass(new, atBarchartWidgetClass))  {
  	XRectangle *rlist;
  	int num_rlist;
  	parent->plotter.clip_region = XCreateRegion();
--- 1041,1047 ----
    }
    else if (newc->plotter.needsRefresh == True)  {
      if (!redrawn)  {
!       if (XtIsSubclass(new, atBarchartWidgetClass)) {
  	XRectangle *rlist;
  	int num_rlist;
  	parent->plotter.clip_region = XCreateRegion();
***************
*** 1059,1065 ****
  		tmp = tmp->next;
  		continue; /* dont draw the child that shrunk */
  	      }
! 	      else 
  		BARREDRAW(parent, tmp->child, &rlist[i]);
  	      tmp = tmp->next;
  	    }
--- 1058,1064 ----
  		tmp = tmp->next;
  		continue; /* dont draw the child that shrunk */
  	      }
! 	      else if (ISDISPLAYED(tmp->child))
  		BARREDRAW(parent, tmp->child, &rlist[i]);
  	      tmp = tmp->next;
  	    }
***************
*** 1066,1077 ****
  	  }
  	  else   /* draw children according to birthorder */
  	    for (j = 0; j < parent->composite.num_children; j++)
! 	      if ((parent->composite.children[j] == (Widget) new) ||
! 		  !XtIsSubclass(parent->composite.children[j],
! 				atBarchartWidgetClass))
! 		continue; /* dont draw the child that shrunk. Also dont
! 			     draw non-barchart children */
! 	      else
  		BARREDRAW(parent, parent->composite.children[j], &rlist[i]);
  	}
  	XtFree(rlist);
--- 1065,1071 ----
  	  }
  	  else   /* draw children according to birthorder */
  	    for (j = 0; j < parent->composite.num_children; j++)
! 	      if (NTHCHILDISDISPLAYED(parent, j))
  		BARREDRAW(parent, parent->composite.children[j], &rlist[i]);
  	}
  	XtFree(rlist);
***************
*** 1096,1112 ****
  	}
  	else   /* draw children according to birthorder */
  	  for (i = 0; i < parent->composite.num_children; i++)
! 	    if (!XtIsSubclass(parent->composite.children[i],
! 			      atBarchartWidgetClass))
! 	      continue; /*  dont draw non-barchart children */
! 	    else
  	      BARDRAWINC(parent, parent->composite.children[i], 
  			 parent->plotter.clip_region);
  	
- 	for (i = 0; i < parent->plotter.num_nonbar_children; i++)
- 	  REDRAWPLOT(parent, parent->plotter.nonbar_children[i],
- 		     parent->plotter.clip_region);
- 
  	/* we don't need the region anymore. So destroy it. */
  	XDestroyRegion(parent->plotter.clip_region);
        }
--- 1090,1099 ----
  	}
  	else   /* draw children according to birthorder */
  	  for (i = 0; i < parent->composite.num_children; i++)
! 	    if (NTHCHILDISDISPLAYED(parent, i))
  	      BARDRAWINC(parent, parent->composite.children[i], 
  			 parent->plotter.clip_region);
  	
  	/* we don't need the region anymore. So destroy it. */
  	XDestroyRegion(parent->plotter.clip_region);
        }
***************
*** 1134,1141 ****
    if(XtIsRealized(pw))
      AtPlotterLayout(pw);
      
!   for(i=0; i<NUMCHILDREN(pw); i++) 
!     RESCALECHILD(pw, i);
  }
  
  
--- 1121,1129 ----
    if(XtIsRealized(pw))
      AtPlotterLayout(pw);
      
!   for(i=0; i<NUMCHILDREN(pw); i++)
!     if (NTHCHILDISDISPLAYED(pw, i))
!       RESCALECHILD(pw, i);
  }
  
  
***************
*** 1148,1153 ****
--- 1136,1142 ----
    double tmp;
  
    for(i = 0; i < NUMCHILDREN(pw); i++) {
+     if (!NTHCHILDISDISPLAYED(pw, i)) continue; /* Don't scale on undisplayed */
      /* if bounding box doesn't make sense, ignore it! */
      /* by default, text plots have non-sensical boxes */
      if (child(xmin) > child(xmax)) continue;
***************
*** 1272,1277 ****
--- 1261,1267 ----
    h += w->plotter.marginHeight;
      
    for(i = 0; i < NUMCHILDREN(w); i++) {
+     if (!NTHCHILDISDISPLAYED(w, i)) continue; 
      c = CONSTRAINT(w,i);
      if (i == w->plotter.legendItem)
        w->plotter.legendItemY = h;
***************
*** 1330,1335 ****
--- 1320,1326 ----
  
    y += AtTextHeight(w->plotter.legendTitleText) + w->plotter.marginWidth;
    for(i = 0; i < NUMCHILDREN(w); i++ ) {
+     if (!NTHCHILDISDISPLAYED(w, i)) continue; 
      t = CONSTRAINT(w,i)->plotter.legendText;
      if (t != NULL) {
        AtTextDraw(XtDisplay(w), XtWindow(w), w->plotter.legendGC, t,
***************
*** 1450,1455 ****
--- 1441,1447 ----
    }
      
    for(i=0; i < NUMCHILDREN(pw); i++) {
+     if (!NTHCHILDISDISPLAYED(pw, i)) continue; 
      t = CONSTRAINT(pw,i)->plotter.legendText;
      if (t != NULL) {
        if ((event->y >= h) &&
***************
*** 1760,1766 ****
      AtPlotterLayout(w);
      
    for(i=0; i<NUMCHILDREN(w); i++)
!     RESCALECHILD(w, i);
  
    Redraw(w, (Region) NULL);
  }    
--- 1752,1759 ----
      AtPlotterLayout(w);
      
    for(i=0; i<NUMCHILDREN(w); i++)
!     if (NTHCHILDISDISPLAYED(w, i)) 
!       RESCALECHILD(w, i);
  
    Redraw(w, (Region) NULL);
  }    
***************
*** 1779,1785 ****
    if(XtIsRealized(w))  {
      AtPlotterLayout(w);
      for(i=0; i<NUMCHILDREN(w); i++)
!       RESCALECHILD(w, i);
      Redraw(w, (Region) NULL);
    }
  }
--- 1772,1779 ----
    if(XtIsRealized(w))  {
      AtPlotterLayout(w);
      for(i=0; i<NUMCHILDREN(w); i++)
!       if (NTHCHILDISDISPLAYED(w, i)) 
! 	RESCALECHILD(w, i);
      Redraw(w, (Region) NULL);
    }
  }
***************
*** 1798,1804 ****
    int i;
  
    for(i = 0; i < NUMCHILDREN(pw); i++)
!     if (CHECKHIT(pw,i,x,y)) return (AtPlotWidget)CHILD(pw,i);
    
    return NULL;
  }   
--- 1792,1799 ----
    int i;
  
    for(i = 0; i < NUMCHILDREN(pw); i++)
!     if (NTHCHILDISDISPLAYED(pw, i)) 
!       if (CHECKHIT(pw,i,x,y)) return (AtPlotWidget)CHILD(pw,i);
    
    return NULL;
  }   
***************
*** 1808,1824 ****
   ******************************************************************
   *
   * RankOrderChildren()
!  * Sorts those children of Plotter widget who are subclasses 
!  * of Barchart object (eg, Barcharts, FBarcharts), on a list
!  * according to their Ranking rather than their birth order.
!  * The lowest ranking child is drawn first, whereas, the highest
!  * ranking one is drawn last. The highest ranking plot is therfore
!  * always visible (never covered by its siblings, if they overlap).
!  * This is useful, for example, if you have several sets of Barcharts
!  * that overlap and you want to control which set should be completely
!  * visible (in the foreground) at a given time, and in what order the
!  * others should cover each other. It also maintains a nonbar_children
!  * list; See comments below.
   *
   ********************************************************************
  */
--- 1803,1817 ----
   ******************************************************************
   *
   * RankOrderChildren()
!  * Sorts the children of Plotter widget on a list according to their
!  * Ranking rather than their birth order.  The lowest ranking child is
!  * drawn first, whereas, the highest ranking one is drawn last. The
!  * highest ranking plot is therfore always visible (never covered by
!  * its siblings, if they overlap).  This is useful, for example, if
!  * you have several sets of Barcharts that overlap and you want to
!  * control which set should be completely visible (in the foreground)
!  * at a given time, and in what order the others should cover each
!  * other.
   *
   ********************************************************************
  */
***************
*** 1825,1830 ****
--- 1818,1825 ----
  
  #define ORDLIST parent->plotter.ordered_children
  
+ Rank *getnode(void);
+ 
  static void RankOrderChildren(Widget w)
  {
    AtPlotterWidget parent = (AtPlotterWidget)XtParent(w);
***************
*** 1831,1905 ****
    AtPlotterConstraints pcons = (AtPlotterConstraints) w->core.constraints;
    Rank *locate, *newnode;
    Rank *getnode(void);
  
! /* if w is a atBarchart or atFBarchart widget add it to the ordered_children
!    list. Else (e.g. atXYPlot), add it to nonbar_children list. The later
!    list is used to redraw the none barchart plots after incremental update
!    to a barchart child. This ensures that none bar plots will always be
!    on top of barcharts, and therefore always visible.
! */
  
!   if (XtIsSubclass(w, atBarchartWidgetClass)) {
!     if (ORDLIST == NULL) {
!       ORDLIST = getnode();
!       ORDLIST->prev = NULL;
!       ORDLIST->next = NULL;
!       ORDLIST->child = w;  
!       ORDLIST->rank_order = pcons->plotter.rankOrder; 
!       /* higher rank children go on top of lower rank ones.
! 	 rankOrder is a constraint resource of Plotter. */
!       
      }
!     else {
!       Boolean found = False;
!       for (locate = ORDLIST; locate != NULL; locate = locate->next)
! 	if (pcons->plotter.rankOrder < locate->rank_order) { 
! 	  /* should be inserted right before locate */
! 	  newnode = getnode(); /* get a new node */ 
! 	  newnode->child = w;
! 	  newnode->rank_order = pcons->plotter.rankOrder;
! 	  newnode->prev = locate->prev;
! 	  newnode->next = locate;
! 	  locate->prev = newnode;
! 	  if (newnode->prev == NULL) /* first on the list */
! 	    ORDLIST = newnode;
! 	  else
! 	    (newnode->prev)->next = newnode;
! 	  found = True;
! 	  break;
! 	}
!       if (!found) { /* Highest order so far, insert at end of list */
! 	for (locate=ORDLIST; locate->next != NULL; locate=locate->next)
! 	  ;
! 	newnode = getnode(); /* get a new node */ 
! 	newnode->child = w;
! 	newnode->rank_order = pcons->plotter.rankOrder;
  	newnode->prev = locate;
! 	newnode->next = locate->next;
! 	locate->next = newnode;
!       }
!     }
    }
-   else { /* the child is not a barchart */
-     if (parent->plotter.num_nonbar_children == 
- 	parent->plotter.nonbar_children_size)  {
-       parent->plotter.nonbar_children_size += 
- 	(parent->plotter.nonbar_children_size / 2) + 2;
-       parent->plotter.nonbar_children = (Widget *) 
- 	XtRealloc(parent->plotter.nonbar_children, 
- 		  parent->plotter.nonbar_children_size * sizeof(Widget));
-     }
-     parent->plotter.nonbar_children[parent->plotter.num_nonbar_children++] = w;
-   }
  }
  
- 
  /*
   ***************************************************************
   * 
   *   ReRankOrderChildren
!  *   If the child is a Barchart object it will
!  *   remove the child whose ranking changed form the 
   *   ordered_children list. Then it will reinsert the removed
   *   child into the list according to its new rankOrder.
   *
--- 1826,1877 ----
    AtPlotterConstraints pcons = (AtPlotterConstraints) w->core.constraints;
    Rank *locate, *newnode;
    Rank *getnode(void);
+   Boolean found = False;
  
!   if (ORDLIST == NULL) {
!     ORDLIST = getnode();
!     ORDLIST->prev = NULL;
!     ORDLIST->next = NULL;
!     ORDLIST->child = w;  
!     ORDLIST->rank_order = pcons->plotter.rankOrder; 
!     /* higher rank children go on top of lower rank ones.
!      * rankOrder is a constraint resource of Plotter. */
  
!     return;
!   }
!   for (locate = ORDLIST; locate != NULL; locate = locate->next)
!     if (pcons->plotter.rankOrder < locate->rank_order) { 
!       /* should be inserted right before locate */
!       newnode = getnode(); /* get a new node */ 
!       newnode->child = w;
!       newnode->rank_order = pcons->plotter.rankOrder;
!       newnode->prev = locate->prev;
!       newnode->next = locate;
!       locate->prev = newnode;
!       if (newnode->prev == NULL) /* first on the list */
! 	ORDLIST = newnode;
!       else
! 	(newnode->prev)->next = newnode;
!       found = True;
!       break;
      }
!   if (!found) { /* Highest order so far, insert at end of list */
!     for (locate=ORDLIST; locate->next != NULL; locate=locate->next)
!       ;
!     newnode = getnode(); /* get a new node */ 
!     newnode->child = w;
!     newnode->rank_order = pcons->plotter.rankOrder;
  	newnode->prev = locate;
!     newnode->next = locate->next;
!     locate->next = newnode;
    }
  }
  
  /*
   ***************************************************************
   * 
   *   ReRankOrderChildren
!  *   Remove the child whose ranking changed form the 
   *   ordered_children list. Then it will reinsert the removed
   *   child into the list according to its new rankOrder.
   *
***************
*** 1908,1931 ****
  
  void ReRankOrderChildren(Widget w)
  {
    AtPlotterWidget parent = (AtPlotterWidget)XtParent(w);
!   AtPlotterConstraints pcons = (AtPlotterConstraints) w->core.constraints;
!   Rank *locate, *newnode;
!   Rank *getnode(void);
  
! /* if the child is not a barchart, dont do anything. */
! 
!   if (!XtIsSubclass(w, atBarchartWidgetClass)) {
!     AtWarning(w, "Illegal attempt to change ranking of a non-AtBarchart object\n");
!     return;
!   }
! 
! /* Find the child whose rankOrder changed. Then remove it
!    from the list. */
! 
!   for (locate = ORDLIST; locate != NULL; locate = locate->next) 
      if (locate->child == w) { 
!       if (locate->next) 
  	(locate->next)->prev = locate->prev;
        if (locate->prev == NULL) /* head of list */
  	ORDLIST = locate->next;
--- 1880,1898 ----
  
  void ReRankOrderChildren(Widget w)
  {
+   RankOrderRemove(w); 
+   RankOrderChildren(w); 
+ }
+  
+ static void RankOrderRemove(Widget w)
+ {
    AtPlotterWidget parent = (AtPlotterWidget)XtParent(w);
!   Rank *locate;
!   int i, position;
  
!   for (locate = ORDLIST; locate != NULL; locate = locate->next)  {
      if (locate->child == w) { 
!       if (locate->next)
  	(locate->next)->prev = locate->prev;
        if (locate->prev == NULL) /* head of list */
  	ORDLIST = locate->next;
***************
*** 1934,2013 ****
        XtFree (locate);
        break;
      }
- 
- 
- /* Now, reinsert the removed child into the list 
-    according to its new rankOrder. */
- 
-   if (ORDLIST == NULL) {
-     ORDLIST = getnode();
-     ORDLIST->prev = NULL;
-     ORDLIST->next = NULL;
-     ORDLIST->child = w;
-     ORDLIST->rank_order = pcons->plotter.rankOrder; 
-     /* higher rank children go on top of lower rank ones. */
-   }
-   else {
-     Boolean found = False;
-     for (locate = ORDLIST; locate != NULL; locate = locate->next)
-       if (pcons->plotter.rankOrder < locate->rank_order) { 
- 	/* should be inserted right before locate */
- 	newnode = getnode(); /* get a new node */
-         newnode->child = w;
-         newnode->rank_order = pcons->plotter.rankOrder;
-         newnode->prev = locate->prev;
-         newnode->next = locate;
-         locate->prev = newnode;
-         if (newnode->prev == NULL) /* first on the list */
-           ORDLIST = newnode;
-         else
-           (newnode->prev)->next = newnode;
-         found = True;
-         break;
-       }
-     if (!found) { /* Highest order so far, insert at end of list */
-       for (locate=ORDLIST; locate->next != NULL; locate=locate->next)
-         ;
-       newnode = getnode(); /* get a new node */
-       newnode->child = w;
-       newnode->rank_order = pcons->plotter.rankOrder;
-       newnode->prev = locate;
-       newnode->next = locate->next;
-       locate->next = newnode;
-     }
-   }  
- }
-  
- static void RankOrderRemove(Widget w)
- {
-   AtPlotterWidget parent = (AtPlotterWidget)XtParent(w);
-   Rank *locate;
-   int i, position;
- 
-   if (XtIsSubclass(w, atBarchartWidgetClass))
-     for (locate = ORDLIST; locate != NULL; locate = locate->next)  {
-       if (locate->child == w) { 
- 	if (locate->next)
- 	  (locate->next)->prev = locate->prev;
- 	if (locate->prev == NULL) /* head of list */
- 	  ORDLIST = locate->next;
- 	else
- 	  (locate->prev)->next = locate->next;
- 	XtFree (locate);
- 	break;
-       }
-     }
-   else  {
-     for (position = 0; position < parent->plotter.num_nonbar_children;
- 	 position++)
-       if (parent->plotter.nonbar_children[position] == w)
- 	break;
-     if (position == parent->plotter.num_nonbar_children)
-       return;
-     parent->plotter.num_nonbar_children--;
-     for (i = position; i < parent->plotter.num_nonbar_children; i++)
-       parent->plotter.nonbar_children[i] = 
- 	parent->plotter.nonbar_children[i+1];
    }
  }
  
--- 1901,1906 ----
