Index: /branches/eam_branches/ipp-20110213/Ohana/src/kapa2/src/SetImageData.c
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/kapa2/src/SetImageData.c	(revision 31077)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/kapa2/src/SetImageData.c	(revision 31078)
@@ -128,5 +128,5 @@
   Picture_to_Image (&Xmax, &Ymax, image[0].picture.dx, image[0].picture.dy, &image[0].picture);
 
-  KiiSendMessage (sock, "%g %g %g %g", Xmin, Xmax, Ymin, Ymax);
+  KiiSendMessage (sock, "%g %g %g %g %d %d", Xmin, Xmax, Ymin, Ymax, image[0].picture.dx, image[0].picture.dy);
 
   return (TRUE);
Index: /branches/eam_branches/ipp-20110213/Ohana/src/libkapa/include/kapa.h
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/libkapa/include/kapa.h	(revision 31077)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/libkapa/include/kapa.h	(revision 31078)
@@ -154,5 +154,5 @@
 int KapaSetImageCoords (int fd, Coords *coords);
 int KapaGetImageCoords (int fd, Coords *coords);
-int KapaGetImageRange (int fd, double *Xmin, double *Xmax, double *Ymin, double *Ymax);
+int KapaGetImageRange (int fd, double *Xmin, double *Xmax, double *Ymin, double *Ymax, int *dX, int *dY);
 
 /* KiiOverlay.c */
Index: /branches/eam_branches/ipp-20110213/Ohana/src/libkapa/src/KiiPicture.c
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/libkapa/src/KiiPicture.c	(revision 31077)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/libkapa/src/KiiPicture.c	(revision 31078)
@@ -203,10 +203,10 @@
 }
 
-int KapaGetImageRange (int fd, double *Xmin, double *Xmax, double *Ymin, double *Ymax) {
+int KapaGetImageRange (int fd, double *Xmin, double *Xmax, double *Ymin, double *Ymax, int *dX, int *dY) {
 
   /* tell kapa to look for the incoming image */
   KiiSendCommand (fd, 4, "GIMR"); 
   
-  KiiScanMessage (fd, "%lf %lf %lf %lf", Xmin, Xmax, Ymin, Ymax);
+  KiiScanMessage (fd, "%lf %lf %lf %lf %d %d", Xmin, Xmax, Ymin, Ymax, dX, dY);
 
   KiiWaitAnswer (fd, "DONE");
Index: /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.data/densify.c
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.data/densify.c	(revision 31077)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.data/densify.c	(revision 31078)
@@ -1,8 +1,10 @@
 # include "data.h"
+
+# define CHECKVAL(ARG) if (!isfinite(ARG)) { gprint (GP_ERR, "illegal value for %s: %f\n", #ARG, ARG); return (FALSE); }
 
 int densify (int argc, char **argv) {
 
-  int i, Nx, Ny, Xb, Yb, Normalize, N;
-  float Xmin, Xmax, dX, Ymin, Ymax, dY;
+  int i, Nx, Ny, Xb, Yb, Normalize, N, Xpix, Ypix, good, UseGraph;
+  double Xmin, Xmax, dX, Ymin, Ymax, dY;
   float *val;
   Buffer *bf;
@@ -16,6 +18,14 @@
   }
 
-  if (argc != 10) {
+  UseGraph = FALSE;
+  if ((N = get_argument (argc, argv, "-graph"))) {
+    remove_argument (N, &argc, argv);
+    UseGraph = TRUE;
+  }
+
+  good = UseGraph ? (argc == 4) : (argc == 10);
+  if (!good) {
     gprint (GP_ERR, "USAGE: densify buffer x y Xmin Xmax dX Ymin Ymax dY\n");
+    gprint (GP_ERR, "   OR: densify buffer x y -graph\n");
     return (FALSE);
   }
@@ -30,11 +40,32 @@
   REQUIRE_VECTOR_FLT (vy, FALSE); 
 
-  Xmin = atof (argv[4]);
-  Xmax = atof (argv[5]);
-  dX   = atof (argv[6]);
+  if (UseGraph) {
+    int kapa;
+    Graphdata graphmode;
+    if (!GetGraph (&graphmode, &kapa, NULL)) return (FALSE);
+    KapaGetImageRange (kapa, &Xmin, &Xmax, &Ymax, &Ymin, &Xpix, &Ypix);
+    Xmax = graphmode.xmax;
+    Xmin = graphmode.xmin;
+    Ymax = graphmode.ymax;
+    Ymin = graphmode.ymin;
+    dX = (Xmax - Xmin) / (Xpix - 1);
+    dY = (Ymax - Ymin) / (Ypix - 1);
+  } else {
+    Xmin = atof (argv[4]);
+    Xmax = atof (argv[5]);
+    dX   = atof (argv[6]);
 
-  Ymin = atof (argv[7]);
-  Ymax = atof (argv[8]);
-  dY   = atof (argv[9]);
+    Ymin = atof (argv[7]);
+    Ymax = atof (argv[8]);
+    dY   = atof (argv[9]);
+  }
+
+  CHECKVAL(Xmin);
+  CHECKVAL(Xmax);
+  CHECKVAL(dX);
+
+  CHECKVAL(Ymin);
+  CHECKVAL(Ymax);
+  CHECKVAL(dY);
 
   Nx = (Xmax - Xmin) / dX + 1;
Index: /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.data/limits.c
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.data/limits.c	(revision 31077)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/opihi/cmd.data/limits.c	(revision 31078)
@@ -3,5 +3,5 @@
 int limits (int argc, char **argv) {
 
-  int N, APPLY;
+  int N, APPLY, dX, dY;
   int kapa;
   char *name;
@@ -28,5 +28,5 @@
   if ((N = get_argument (argc, argv, "-image"))) {
     remove_argument (N, &argc, argv);
-    KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin);
+    KapaGetImageRange (kapa, &graphmode.xmin, &graphmode.xmax, &graphmode.ymax, &graphmode.ymin, &dX, &dY);
 
     set_variable ("XMIN", graphmode.xmin);
@@ -34,4 +34,12 @@
     set_variable ("YMIN", graphmode.ymin);
     set_variable ("YMAX", graphmode.ymax);
+
+    set_variable ("KAPA_XMIN", graphmode.xmin);
+    set_variable ("KAPA_XMAX", graphmode.xmax);
+    set_variable ("KAPA_YMIN", graphmode.ymin);
+    set_variable ("KAPA_YMAX", graphmode.ymax);
+
+    set_variable ("KAPA_XPIX", dX);
+    set_variable ("KAPA_YPIX", dY);
 
     // if (!NoClear) KapaClearSections (kapa);
Index: /branches/eam_branches/ipp-20110213/Ohana/src/opihi/lib.data/graphtools.c
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/opihi/lib.data/graphtools.c	(revision 31077)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/opihi/lib.data/graphtools.c	(revision 31078)
@@ -59,4 +59,9 @@
   set_variable ("YMIN", graphmode[0].ymin);
   set_variable ("YMAX", graphmode[0].ymax);
+
+  set_variable ("KAPA_XMIN", graphmode[0].xmin);
+  set_variable ("KAPA_XMAX", graphmode[0].xmax);
+  set_variable ("KAPA_YMIN", graphmode[0].ymin);
+  set_variable ("KAPA_YMAX", graphmode[0].ymax);
 }
 
@@ -95,4 +100,9 @@
   SetGraph (graphmode);
 
+  set_variable ("KAPA_XMIN", graphmode[0].xmin);
+  set_variable ("KAPA_XMAX", graphmode[0].xmax);
+  set_variable ("KAPA_YMIN", graphmode[0].ymin);
+  set_variable ("KAPA_YMAX", graphmode[0].ymax);
+
   set_variable ("XMIN", graphmode[0].xmin);
   set_variable ("XMAX", graphmode[0].xmax);
Index: /branches/eam_branches/ipp-20110213/Ohana/src/opihi/lib.shell/VectorOps.c
===================================================================
--- /branches/eam_branches/ipp-20110213/Ohana/src/opihi/lib.shell/VectorOps.c	(revision 31077)
+++ /branches/eam_branches/ipp-20110213/Ohana/src/opihi/lib.shell/VectorOps.c	(revision 31078)
@@ -218,5 +218,5 @@
     }
     free (vec[0].elements.Int);
-    vec[0].elements.Flt = vo;
+    vec[0].elements.Flt = temp;
     vec[0].type = OPIHI_FLT;
   } else {
@@ -229,5 +229,5 @@
     }
     free (vec[0].elements.Flt);
-    vec[0].elements.Int = vo;
+    vec[0].elements.Int = temp;
     vec[0].type = OPIHI_INT;
   }
