# include "display.h"

static int Xgraph;

int PrepPlotting (int Npts, Graphdata *graphmode) {

  char buffer[128], buffer2[128];

  if (!GetGraph (NULL, &Xgraph, NULL)) return (FALSE);
  
  /* tell kapa to look for the incoming image */
  write (Xgraph, "PLOT", 4); 

  /* send Xgraph the plot details */
  sprintf (buffer, "%8d %8d %d %d %d %d %d %f %f ", 
	   Npts, graphmode[0].style, 
	   graphmode[0].ptype, graphmode[0].ltype, 
	   graphmode[0].etype, graphmode[0].ebar, graphmode[0].color, 
	   graphmode[0].lweight, graphmode[0].size);
  sprintf (buffer2, "NBYTES: %6d ", strlen (buffer));
  write (Xgraph, buffer2, 16);
  write (Xgraph, buffer, strlen (buffer));
  
  sprintf (buffer, "%f %f %f %f ", 
	   graphmode[0].xmin, graphmode[0].xmax, 
	   graphmode[0].ymin, graphmode[0].ymax);
  sprintf (buffer2, "NBYTES: %6d ", strlen (buffer));
  write (Xgraph, buffer2, 16);
  write (Xgraph, buffer, strlen (buffer));
  return (TRUE);
}

int PlotVector (int Npts, float *values) {

  int Nbytes;

  Nbytes = Npts * sizeof (float);
  write (Xgraph, values, Nbytes);
  return (TRUE);
}

/* we don't use GetGraph in PlotVector because it flushes the connection */
