Index: branches/eam_branches/Ohana.20100407/src/kapa2/src/LoadFrame.c
===================================================================
--- branches/eam_branches/Ohana.20100407/src/kapa2/src/LoadFrame.c	(revision 27713)
+++ branches/eam_branches/Ohana.20100407/src/kapa2/src/LoadFrame.c	(revision 27714)
@@ -16,7 +16,5 @@
   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);
+  KapaScanGraphData (sock, &graph[0].data);
 
   graph[0].axis[3].min = graph[0].axis[1].min;
@@ -25,23 +23,20 @@
   graph[0].axis[2].max = graph[0].axis[0].max;
   
-  KiiScanMessage (sock, "%lf %d", &lweight, &color);
-  color = MAX (0, MIN (15, color));
+  // XXX this is fragile
+  graph[0].data.color = MAX (0, MIN (15, graph[0].data.color));
 
-  KiiScanMessage (sock, "%lf %lf %lf %lf %lf %lf", &ticktextPad, &labelPad, &padXm, &padXp, &padYm, &padYp);
-  graph[0].axis[0].pad = padXm;
-  graph[0].axis[1].pad = padYm;
-  graph[0].axis[2].pad = padXp;
-  graph[0].axis[3].pad = padYp;
-
-  KiiScanMessage (sock, "%s %s %s", Axis, Labels, Ticks);
+  graph[0].axis[0].pad = graph[0].data.padXm;
+  graph[0].axis[1].pad = graph[0].data.padYm;
+  graph[0].axis[2].pad = graph[0].data.padXp;
+  graph[0].axis[3].pad = graph[0].data.padYp;
 
   for (i = 0; i < 4; i++) {
-    graph[0].axis[i].lweight = lweight;
-    graph[0].axis[i].color = color;
+    graph[0].axis[i].lweight = graph[0].data.lweight;
+    graph[0].axis[i].color = graph[0].data.color;
 
     graph[0].axis[i].ticktextPad = ticktextPad;
     graph[0].axis[i].labelPad = labelPad;
 
-    switch (Axis[i]) {
+    switch (graph[0].data.axis[i]) {
     case '0':
       graph[0].axis[i].isaxis = FALSE;
@@ -54,5 +49,5 @@
       break;
     }
-    switch (Ticks[i]) {
+    switch (graph[0].data.ticks[i]) {
     case '0':
       graph[0].axis[i].areticks = FALSE;
@@ -65,5 +60,5 @@
       break;
     }
-    switch (Labels[i]) {
+    switch (graph[0].data.labels[i]) {
     case '0':
       graph[0].axis[i].islabel = FALSE;
Index: branches/eam_branches/Ohana.20100407/src/kapa2/src/SetGraphData.c
===================================================================
--- branches/eam_branches/Ohana.20100407/src/kapa2/src/SetGraphData.c	(revision 27713)
+++ branches/eam_branches/Ohana.20100407/src/kapa2/src/SetGraphData.c	(revision 27714)
@@ -21,22 +21,5 @@
   fprintf (stderr, "pad: %f %f %f\n", section->graph->axis[0].pad, section->graph->axis[0].labelPad, section->graph->axis[0].ticktextPad);
   
-  // get graph data from client 
-  KiiScanMessage (sock, "%d %d %d %d %d %d %lf %lf", 
-		  &graph[0].data.style, 
-		  &graph[0].data.ptype, 
-		  &graph[0].data.ltype, 
-		  &graph[0].data.etype, 
-		  &graph[0].data.ebar, 
-		  &graph[0].data.color, 
-		  &graph[0].data.lweight, 
-		  &graph[0].data.size);
-
-  KiiScanMessage (sock, "%lf %lf %lf %lf %lf %lf", 
-		  &graph[0].data.ticktextPad, 
-		  &graph[0].data.labelPad, 
-		  &graph[0].data.padXm, 
-		  &graph[0].data.padXp, 
-		  &graph[0].data.padYm, 
-		  &graph[0].data.padYp);
+  KapaScanGraphData (sock, &graph[0].data);
 
   for (i = 0; i < 4; i++) {
@@ -48,28 +31,4 @@
   graph[0].axis[2].pad = graph[0].data.padXp;
   graph[0].axis[3].pad = graph[0].data.padYp;
-
-  KiiScanMessage (sock, "%lf %lf %lf %lf", 
-		  &graph[0].data.xmin, 
-		  &graph[0].data.xmax, 
-		  &graph[0].data.ymin, 
-		  &graph[0].data.ymax);
-
-  KiiScanMessage (sock, "%f %f %f %f", 
-		  &graph[0].data.coords.pc1_1, &graph[0].data.coords.pc2_2,
-		  &graph[0].data.coords.pc1_2, &graph[0].data.coords.pc2_1);
-
-  KiiScanMessage (sock, "%d %d %s", 
-		  &graph[0].data.flipeast, &graph[0].data.flipnorth,
-		  graph[0].data.coords.ctype);
-
-  KiiScanMessage (sock, "%lf %lf %f %f %f %f", 
-		  &graph[0].data.coords.crval1,
-		  &graph[0].data.coords.crval2,
-		  &graph[0].data.coords.crpix1,
-		  &graph[0].data.coords.crpix2,
-		  &graph[0].data.coords.cdelt1,
-		  &graph[0].data.coords.cdelt2);
-
-
 
   xmin = graph[0].data.xmin;
@@ -110,37 +69,5 @@
   graph = section->graph;
 
-  KiiSendMessage (sock, "%8d %d %d %d %d %d %f %f", 
-		  graph[0].data.style, 
-		  graph[0].data.ptype, graph[0].data.ltype, 
-		  graph[0].data.etype, graph[0].data.ebar, graph[0].data.color, 
-		  graph[0].data.lweight, graph[0].data.size);
-
-  KiiSendMessage (sock, "%g %g %g %g %g %g", 
-		  graph[0].data.ticktextPad, 
-		  graph[0].data.labelPad, 
-		  graph[0].data.padXm, 
-		  graph[0].data.padXp, 
-		  graph[0].data.padYm, 
-		  graph[0].data.padYp);
-
-  KiiSendMessage (sock, "%g %g %g %g", 
-		  graph[0].data.xmin, graph[0].data.xmax, 
-		  graph[0].data.ymin, graph[0].data.ymax);
-
-  KiiSendMessage (sock, "%g %g %g %g", 
-		  graph[0].data.coords.pc1_1, graph[0].data.coords.pc2_2,
-		  graph[0].data.coords.pc1_2, graph[0].data.coords.pc2_1);
-
-  KiiSendMessage (sock, "%d %d %s", 
-		  graph[0].data.flipeast, graph[0].data.flipnorth,
-		  graph[0].data.coords.ctype);
-
-  KiiSendMessage (sock, "%g %g %g %g %g %g", 
-		  graph[0].data.coords.crval1,
-		  graph[0].data.coords.crval2,
-		  graph[0].data.coords.crpix1,
-		  graph[0].data.coords.crpix2,
-		  graph[0].data.coords.cdelt1,
-		  graph[0].data.coords.cdelt2);
+  KapaSendGraphData (sock, &graph[0].data);
 
   return (TRUE);
Index: branches/eam_branches/Ohana.20100407/src/libkapa/include/kapa.h
===================================================================
--- branches/eam_branches/Ohana.20100407/src/libkapa/include/kapa.h	(revision 27713)
+++ branches/eam_branches/Ohana.20100407/src/libkapa/include/kapa.h	(revision 27714)
@@ -180,4 +180,6 @@
 int KapaSetGraphData (int fd, Graphdata *graphmode);
 int KapaGetGraphData (int fd, Graphdata *graphmode);
+int KapaScanGraphData (int fd, Graphdata *graphmode);
+int KapaSendGraphData (int fd, Graphdata *graphmode);
 int KapaSetImageData (int fd, KapaImageData *graphmode);
 int KapaGetImageData (int fd, KapaImageData *graphmode);
Index: branches/eam_branches/Ohana.20100407/src/libkapa/src/KapaWindow.c
===================================================================
--- branches/eam_branches/Ohana.20100407/src/libkapa/src/KapaWindow.c	(revision 27713)
+++ branches/eam_branches/Ohana.20100407/src/libkapa/src/KapaWindow.c	(revision 27714)
@@ -38,12 +38,7 @@
 
   KiiSendCommand (fd, 4, "DBOX");
-  KiiSendMessage (fd, "%12.6g %12.6g %12.6g %12.6g", 
-		    graphdata[0].xmin, graphdata[0].xmax, graphdata[0].ymin, graphdata[0].ymax);
-
-  KiiSendMessage (fd, "%lf %d", graphdata[0].lweight, graphdata[0].color);
-
-  KiiSendMessage (fd, "%lf %lf %lf %lf %lf %lf", graphdata[0].ticktextPad, graphdata[0].labelPad, graphdata[0].padXm, graphdata[0].padXp, graphdata[0].padYm, graphdata[0].padYp);
-
-  KiiSendMessage (fd, "%s %s %s", graphdata[0].axis, graphdata[0].labels, graphdata[0].ticks);
+
+  KapaSendGraphData (fd, graphdata);
+
   KiiWaitAnswer (fd, "DONE");
   return (TRUE);
@@ -86,4 +81,5 @@
 }
 
+// XXX drop this function? : kapa is responsible for the graph initialization
 int KapaInitGraph (Graphdata *graphdata) {
 
@@ -130,10 +126,11 @@
 }
 
-int KapaSetGraphData (int fd, Graphdata *data) {
-
-  /* tell kapa to look for the incoming image */
-  KiiSendCommand (fd, 4, "SSTY"); 
-  
+int KapaSendGraphData (int fd, Graphdata *data) {
+
   /* send kapa the plot details */
+  KiiSendMessage (fd, "%g %g %g %g", 
+		  data[0].xmin, data[0].xmax, 
+		  data[0].ymin, data[0].ymax);
+
   KiiSendMessage (fd, "%8d %d %d %d %d %d %f %f", 
 		  data[0].style, 
@@ -146,9 +143,4 @@
 		  data[0].padXm, data[0].padXp, 
 		  data[0].padYm, data[0].padYp);
-
-
-  KiiSendMessage (fd, "%g %g %g %g", 
-		  data[0].xmin, data[0].xmax, 
-		  data[0].ymin, data[0].ymax);
 
   KiiSendMessage (fd, "%g %g %g %g", 
@@ -168,14 +160,16 @@
 		  data[0].coords.cdelt2);
 
-  KiiWaitAnswer (fd, "DONE");
-  return (TRUE);
-}
-
-int KapaGetGraphData (int fd, Graphdata *data) {
-
-  /* tell kapa to look for the incoming image */
-  KiiSendCommand (fd, 4, "GSTY"); 
-  
+  KiiSendMessage (fd, "%s %s %s", data[0].axis, data[0].ticks, data[0].labels);
+
+  return (TRUE);
+}
+
+int KapaScanGraphData (int fd, Graphdata *data) {
+
   /* send kapa the plot details */
+  KiiScanMessage (fd, "%lf %lf %lf %lf", 
+		  &data[0].xmin, &data[0].xmax, 
+		  &data[0].ymin, &data[0].ymax);
+
   KiiScanMessage (fd, "%d %d %d %d %d %d %lf %lf", 
 		  &data[0].style, 
@@ -188,8 +182,4 @@
 		  &data[0].padXm, &data[0].padXp, 
 		  &data[0].padYm, &data[0].padYp);
-
-  KiiScanMessage (fd, "%lf %lf %lf %lf", 
-		  &data[0].xmin, &data[0].xmax, 
-		  &data[0].ymin, &data[0].ymax);
 
   KiiScanMessage (fd, "%f %f %f %f", 
@@ -209,8 +199,31 @@
 		  &data[0].coords.cdelt2);
 
+  KiiScanMessage (fd, "%s %s %s", data[0].axis, data[0].ticks, data[0].labels);
+
   // XXX at some point, we need to add polynomials and 2-level mosaic
   // astrometry here.
 
   data[0].coords.Npolyterms = 0;
+
+  return (TRUE);
+}
+
+int KapaSetGraphData (int fd, Graphdata *data) {
+
+  /* tell kapa to look for the incoming image */
+  KiiSendCommand (fd, 4, "SSTY"); 
+  
+  KapaSendGraphData (fd, data);
+
+  KiiWaitAnswer (fd, "DONE");
+  return (TRUE);
+}
+
+int KapaGetGraphData (int fd, Graphdata *data) {
+
+  /* tell kapa to look for the incoming image */
+  KiiSendCommand (fd, 4, "GSTY"); 
+  
+  KapaScanGraphData (fd, data);
 
   KiiWaitAnswer (fd, "DONE");
