Index: /branches/eam_branches/20090715/psphot/src/psphotVisual.c
===================================================================
--- /branches/eam_branches/20090715/psphot/src/psphotVisual.c	(revision 25273)
+++ /branches/eam_branches/20090715/psphot/src/psphotVisual.c	(revision 25274)
@@ -14,4 +14,6 @@
 # if (HAVE_KAPA)
 # include <kapa.h>
+
+bool pmVisualLimitsFromVectors (Graphdata *graphdata, psVector *xVec, psVector *yVec);
 
 // functions used to visualize the analysis as it goes
@@ -448,5 +450,8 @@
         overlay[Noverlay].dx = 2.0*axes.major;
         overlay[Noverlay].dy = 2.0*axes.minor;
+
         overlay[Noverlay].angle = -axes.theta * PS_DEG_RAD;  // XXXXXXXX the axes angle is negative to display of object on kapa
+	// XXX fixed??
+
         overlay[Noverlay].text = NULL;
         Noverlay ++;
@@ -1624,4 +1629,6 @@
         if (source->type != PM_SOURCE_TYPE_STAR) continue;
         if (!isfinite (source->crNsigma)) continue;
+	if (!isfinite (source->peak->flux)) continue;
+	if (source->peak->flux < 0) continue;
 
         x->data.F32[n] = -2.5*log10(source->peak->flux);
@@ -1679,4 +1686,6 @@
         if (source->type != PM_SOURCE_TYPE_STAR) continue;
         if (!isfinite (source->extNsigma)) continue;
+	if (!isfinite (source->peak->flux)) continue;
+	if (source->peak->flux < 0) continue;
 
         x->data.F32[n] = -2.5*log10(source->peak->flux);
@@ -1828,4 +1837,38 @@
         psWarning("Unable to read option");
     }
+    return true;
+}
+
+bool psphotVisualShowPetrosian (pmSource *source, pmPetrosian *petrosian) {
+
+    KiiOverlay overlay[2];
+
+    if (source == NULL) return true;
+
+    if (!pmVisualIsVisual()) return true;
+
+    if (kapa == -1) {
+        fprintf (stderr, "kapa not opened, skipping\n");
+        return false;
+    }
+
+    overlay[0].type = KII_OVERLAY_CIRCLE;
+    overlay[0].x = source->peak->xf;
+    overlay[0].y = source->peak->yf;
+    overlay[0].dx = 2.0*petrosian->petrosianRadius;
+    overlay[0].dy = 2.0*petrosian->petrosianRadius*petrosian->axes.minor/petrosian->axes.major;
+    overlay[0].angle = petrosian->axes.theta * PS_DEG_RAD;
+    overlay[0].text = NULL;
+
+    overlay[1].type = KII_OVERLAY_CIRCLE;
+    overlay[1].x = source->peak->xf;
+    overlay[1].y = source->peak->yf;
+    overlay[1].dx = 4.0*petrosian->petrosianRadius;
+    overlay[1].dy = 4.0*petrosian->petrosianRadius*petrosian->axes.minor/petrosian->axes.major;
+    overlay[1].angle = petrosian->axes.theta * PS_DEG_RAD;
+    overlay[1].text = NULL;
+
+    KiiLoadOverlay (kapa, overlay, 2, "red");
+
     return true;
 }
