Index: trunk/Ohana/src/opihi/cmd.astro/cgrid.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/cgrid.c	(revision 12879)
+++ trunk/Ohana/src/opihi/cmd.astro/cgrid.c	(revision 13479)
@@ -14,8 +14,8 @@
   double x, y;
   Vector Xvec, Yvec;
-  int NorthPole, SouthPole, N, OnPic, LOnPic, status, NELEMENTS, First;
+  int kapa, NorthPole, SouthPole, N, OnPic, LOnPic, status, NELEMENTS, First;
   Graphdata graphmode;
 
-  if (!style_args (&graphmode, &argc, argv, 0)) return FALSE;
+  if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
 
   if (argc != 1) {
@@ -23,5 +23,4 @@
     return (FALSE);
   }
-  SetGraph (graphmode);
 
   /* are we plotting one of the poles? */
@@ -392,7 +391,5 @@
   graphmode.ptype = 100; /* connect a pair */
   graphmode.etype = 0;
-  PrepPlotting (N, &graphmode);
-  PlotVector (N, Xvec.elements);
-  PlotVector (N, Yvec.elements);
+  PlotVectorPair (kapa, N, Xvec.elements, Yvec.elements, &graphmode);
 
   free (Xvec.elements);
Index: trunk/Ohana/src/opihi/cmd.astro/cplot.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/cplot.c	(revision 12879)
+++ trunk/Ohana/src/opihi/cmd.astro/cplot.c	(revision 13479)
@@ -3,10 +3,10 @@
 int cplot (int argc, char **argv) {
   
-  int i, Npts, status;
+  int i, kapa, Npts, status;
   float *x, *y, *r, *d, Rmin, Rmax;
   Vector Xvec, Yvec, *xvec, *yvec;
   Graphdata graphmode;
 
-  if (!style_args (&graphmode, &argc, argv, 0)) return FALSE;
+  if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
 
   if (argc != 3) {
@@ -14,5 +14,4 @@
     return (FALSE);
   }
-  SetGraph (graphmode);
 
   Rmin = graphmode.coords.crval1 - 182.0;
@@ -67,7 +66,5 @@
 
   graphmode.etype = 0;
-  PrepPlotting (Npts, &graphmode);
-  PlotVector (Npts, Xvec.elements);
-  PlotVector (Npts, Yvec.elements);
+  PlotVectorPair (kapa, Npts, Xvec.elements, Yvec.elements, &graphmode);
   
   free (Xvec.elements);
Index: trunk/Ohana/src/opihi/cmd.astro/czplot.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/czplot.c	(revision 12879)
+++ trunk/Ohana/src/opihi/cmd.astro/czplot.c	(revision 13479)
@@ -3,5 +3,5 @@
 int czplot (int argc, char **argv) {
   
-  int i, Npts;
+  int i, kapa, Npts;
   double min, range, Rmin, Rmax;
   float *in, *out, *r, *d, *x, *y;
@@ -9,5 +9,5 @@
   Graphdata graphmode;
 
-  if (!style_args (&graphmode, &argc, argv, 0)) return FALSE;
+  if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
 
   if (argc != 6) {
@@ -15,5 +15,4 @@
     return (FALSE);
   }
-  SetGraph (graphmode);
 
   min = atof(argv[4]);
@@ -59,9 +58,5 @@
   graphmode.etype = 0;
   Npts = Xvec.Nelements;
-  PrepPlotting (Npts, &graphmode);
-
-  PlotVector (Npts, Xvec.elements);
-  PlotVector (Npts, Yvec.elements);
-  PlotVector (Npts, Zvec.elements);
+  PlotVectorTriplet (kapa, Npts, Xvec.elements, Yvec.elements, Zvec.elements, &graphmode);
 
   free (Xvec.elements);
Index: trunk/Ohana/src/opihi/cmd.astro/gauss.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/gauss.c	(revision 12879)
+++ trunk/Ohana/src/opihi/cmd.astro/gauss.c	(revision 13479)
@@ -5,15 +5,18 @@
   char key[20];
   int i, N, Npix, Nborder, Nspot;
-  double X, Y, Z, max;
-  int Ximage, Nimage;
+  double X, Y, Z, ZP, RA, DEC, max;
+  int kapa;
+  char *name;
   Buffer *buf;
+  KapaImageData data;
 
-  Nimage = -1;
+  name = NULL;
   if ((N = get_argument (argc, argv, "-n"))) {
     remove_argument (N, &argc, argv);
-    Nimage = atof (argv[N]);
+    name = strcreate (argv[N]);
     remove_argument (N, &argc, argv);
   }
-  if (!GetImage (&Ximage, &Nimage)) return (FALSE);
+  if (!GetImageData (&data, &kapa, name)) return (FALSE);
+  FREE (name);
 
   Nborder = 3;
@@ -37,5 +40,5 @@
   }
   
-  if (Ximage < 1) {
+  if (kapa < 1) {
     gprint (GP_ERR, "no active TV\n");
     return (FALSE);
@@ -48,14 +51,14 @@
   }
 
-  if ((buf = SelectBuffer (GetImageName(), OLDBUFFER, TRUE)) == NULL) return (FALSE);
+  if ((buf = SelectBuffer (data.name, OLDBUFFER, TRUE)) == NULL) return (FALSE);
 
-  KiiCursorOn (Ximage);
+  KiiCursorOn (kapa);
 
   for (i = 0; (i < Nspot) || (Nspot == 0); i++) {
-    KiiCursorRead (Ximage, &X, &Y, key);
+    KiiCursorRead (kapa, &X, &Y, &ZP, &RA, &DEC, key);
     if (!strcasecmp (key, "Q")) break;
     Z = get_aperture_stats (&buf[0].matrix, (int)(X+0.5), (int)(Y+0.5), Npix, Nborder, max);
   }
-  KiiCursorOff (Ximage);
+  KiiCursorOff (kapa);
   return (TRUE);
 }
Index: trunk/Ohana/src/opihi/cmd.astro/objload.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/objload.c	(revision 12879)
+++ trunk/Ohana/src/opihi/cmd.astro/objload.c	(revision 13479)
@@ -7,15 +7,16 @@
   int i, N, Objtype, type, Nline, status;
   FILE *f;
-  char *buffer, *line;
-  int Ximage, Nimage, Noverlay, NOVERLAY;
+  char *buffer, *line, *name;
+  int kapa, Noverlay, NOVERLAY;
   KiiOverlay *overlay;
   
-  Nimage = -1;
+  name = NULL;
   if ((N = get_argument (argc, argv, "-n"))) {
     remove_argument (N, &argc, argv);
-    Nimage = atof (argv[N]);
+    name = strcreate (argv[N]);
     remove_argument (N, &argc, argv);
   }
-  if (!GetImage (&Ximage, &Nimage)) return (FALSE);
+  if (!GetImage (NULL, &kapa, name)) return (FALSE);
+  FREE (name);
 
   Objtype = 0;
@@ -63,5 +64,5 @@
   free (buffer);
 
-  KiiLoadOverlay (Ximage, overlay, Noverlay, argv[1]);
+  KiiLoadOverlay (kapa, overlay, Noverlay, argv[1]);
 
   free (overlay);
Index: trunk/Ohana/src/opihi/cmd.astro/outline.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/outline.c	(revision 12879)
+++ trunk/Ohana/src/opihi/cmd.astro/outline.c	(revision 13479)
@@ -145,5 +145,5 @@
     /* code to draw dots on Ximage */
     {
-      int Nimage, Ximage;
+      int kapa;
       float xp, yp, x, y;
       float dx, dy, theta, t, dt;
@@ -151,6 +151,5 @@
       KiiOverlay *overlay;
       
-      Nimage = -1;
-      if (!GetImage (&Ximage, &Nimage)) return (FALSE);
+      if (!GetImage (NULL, &kapa, NULL)) return (FALSE);
       
       Noverlay = 0;
@@ -179,5 +178,5 @@
 	CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000);
       }
-      KiiLoadOverlay (Ximage, overlay, Noverlay, "red");
+      KiiLoadOverlay (kapa, overlay, Noverlay, "red");
       free (overlay);
     }
Index: trunk/Ohana/src/opihi/cmd.astro/outline2.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/outline2.c	(revision 12879)
+++ trunk/Ohana/src/opihi/cmd.astro/outline2.c	(revision 13479)
@@ -303,5 +303,5 @@
 int plot_outline () {
   
-  int Nimage, Ximage;
+  int kapa;
   float xp, yp, x, y;
   float dx, dy, theta, t, dt;
@@ -309,6 +309,5 @@
   KiiOverlay *overlay;
   
-  Nimage = -1;
-  if (!GetImage (&Ximage, &Nimage)) return (FALSE);
+  if (!GetImage (NULL, &kapa, NULL)) return (FALSE);
   
   Noverlay = 0;
@@ -337,5 +336,5 @@
     CHECK_REALLOCATE (overlay, KiiOverlay, NOVERLAY, Noverlay, 1000);
   }
-  KiiLoadOverlay (Ximage, overlay, Noverlay, "red");
+  KiiLoadOverlay (kapa, overlay, Noverlay, "red");
   free (overlay);
   return (TRUE);
Index: trunk/Ohana/src/opihi/cmd.astro/region.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/region.c	(revision 12879)
+++ trunk/Ohana/src/opihi/cmd.astro/region.c	(revision 13479)
@@ -5,10 +5,17 @@
   char string[256];
   double Ra, Dec, Radius;
-  double dx, dy;
-  int N, Ngraph, Xgraph;
+  float dx, dy;
+  int N, kapa;
+  char *name;
   Graphdata graphmode;
 
-  Ngraph = 0;
-  if (!GetGraph (&graphmode, &Xgraph, &Ngraph)) return (FALSE);
+  name = NULL;
+  if ((N = get_argument (argc, argv, "-n"))) {
+    remove_argument (N, &argc, argv);
+    name = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if (!GetGraph (&graphmode, &kapa, name)) return (FALSE);
+  FREE (name);
 
   if ((N = get_argument (argc, argv, "-ew"))) {
@@ -60,6 +67,5 @@
   
   /* ask kapa for coordinate limits, so get the right aspect ratio */
-  KiiSendCommand (Xgraph, 4, "LIMS"); 
-  KiiScanMessage (Xgraph, "%lf %lf", &dx, &dy); 
+  KapaGetLimits (kapa, &dx, &dy);
   dx = fabs (dx);
   dy = fabs (dy); 
@@ -101,12 +107,13 @@
   graphmode.coords.cdelt1 = graphmode.coords.cdelt2 = 1.0;
 
-  KapaClear (Xgraph, TRUE);
-  KapaSetLimits (Xgraph, &graphmode);
+  KapaClearSections (kapa);
+  KapaSetLimits (kapa, &graphmode);
 
   /* drop this? */
   sprintf (string, "%8.4f %8.4f (%f)", Ra, Dec, Radius);
-  KapaSendLabel (Xgraph, string, 2);
+  KapaSendLabel (kapa, string, 2);
 
-  SetGraph (graphmode);
+  // XXX is this the right thing to be doing?
+  SetGraph (&graphmode);
   return (TRUE);
 }
