# include "Ximage.h"

int LoadFrame (int sock) {
  
  int i;
  char Axis[16], Labels[16], Ticks[16];
  Section *section;
  KapaGraphWidget *graph;

  section = GetActiveSection();
  if (section->graph == NULL) {
    section->graph = InitGraph ();
    SetSectionSizes (section);
  }
  graph = section->graph;

  KiiScanMessage (sock, "%lf %lf %lf %lf", 
		  &graph[0].axis[0].min, &graph[0].axis[0].max, 
		  &graph[0].axis[1].min, &graph[0].axis[1].max);

  graph[0].axis[3].min = graph[0].axis[1].min;
  graph[0].axis[3].max = graph[0].axis[1].max;
  graph[0].axis[2].min = graph[0].axis[0].min;
  graph[0].axis[2].max = graph[0].axis[0].max;
  
  KiiScanMessage (sock, "%s %s %s", Axis, Labels, Ticks);

  for (i = 0; i < 4; i++) {
    switch (Axis[i]) {
    case '0':
      graph[0].axis[i].isaxis = FALSE;
      break;
    case '1':
      graph[0].axis[i].isaxis = TRUE;
      break;
    case '2':
      graph[0].axis[i].isaxis = TRUE;
      break;
    }
    switch (Ticks[i]) {
    case '0':
      graph[0].axis[i].areticks = FALSE;
      break;
    case '1':
      graph[0].axis[i].areticks = TRUE;
      break;
    case '2':
      graph[0].axis[i].areticks = 2;
      break;
    }
    switch (Labels[i]) {
    case '0':
      graph[0].axis[i].islabel = FALSE;
      break;
    case '1':
      graph[0].axis[i].islabel = TRUE;
      break;
    case '2':
      graph[0].axis[i].islabel = (i < 2);
      break;
    }
  }

  SetSectionSizes (section);
  if (USE_XWINDOW) DrawFrame (graph);
  FlushDisplay ();

  /* XXX why did I do this??? */
# if (0)
  status = TRUE;
  if (status) {
    for (i = 0; i < Nsection; i++) {
      PositionPicture (&section[i]);
    }
    if (USE_XWINDOW) XClearWindow (graphic.display, graphic.window);
    Refresh (1);
  } else {
    FlushDisplay ();
  } 
# endif

  return (TRUE);
  
}
