Index: /branches/czw_branch/20160809/Ohana/src/kapa2/include/prototypes.h
===================================================================
--- /branches/czw_branch/20160809/Ohana/src/kapa2/include/prototypes.h	(revision 39736)
+++ /branches/czw_branch/20160809/Ohana/src/kapa2/include/prototypes.h	(revision 39737)
@@ -32,11 +32,11 @@
 void          DrawLabelsRaw       PROTO((Graphic *graphic, KapaGraphWidget *graph, int color));
 void	      DrawTextlines	  PROTO((KapaGraphWidget *graph));
-void          DrawConnect         PROTO((KapaGraphWidget *graph, Gobjects *objects));
-void          DrawHistogram       PROTO((KapaGraphWidget *graph, Gobjects *objects));
-int           DrawObjectN         PROTO((KapaGraphWidget *graph, Gobjects *objects));
-void          DrawPoints          PROTO((KapaGraphWidget *graph, Gobjects *objects));
-void          ClipLine            PROTO((double x0, double y0, double x1, double y1, double X0, double Y0, double X1, double Y1));
-void          DrawXErrors         PROTO((KapaGraphWidget *graph, Gobjects *objects));
-void          DrawYErrors         PROTO((KapaGraphWidget *graph, Gobjects *objects));
+void          DrawConnect         PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
+void          DrawHistogram       PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
+int           DrawObjectN         PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
+void          DrawPoints          PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
+void          ClipLine            PROTO((Graphic *graphic, double x0, double y0, double x1, double y1, double X0, double Y0, double X1, double Y1));
+void          DrawXErrors         PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
+void          DrawYErrors         PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
 void	      DrawTick		  PROTO((Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis));
 void	      AxisTickScale	  PROTO((Axis *axis, double *range, double *major, double *minor, int *nsignif));
Index: /branches/czw_branch/20160809/Ohana/src/kapa2/src/DrawObjects.c
===================================================================
--- /branches/czw_branch/20160809/Ohana/src/kapa2/src/DrawObjects.c	(revision 39736)
+++ /branches/czw_branch/20160809/Ohana/src/kapa2/src/DrawObjects.c	(revision 39737)
@@ -14,5 +14,5 @@
 
 // XXX this is not thread safe, but that is OK
-static Graphic *graphic;
+// static Graphic *graphic;
 
 /* draw all objects for this Graph */
@@ -22,5 +22,5 @@
   
   // the functions below use this global value
-  graphic = GetGraphic();
+  Graphic *graphic = GetGraphic();
   
   // this function calls all of the supporting Draw... functions below
@@ -28,5 +28,5 @@
     if (DEBUG) fprintf (stderr, "object: %d\n", i);
     if (DEBUG) fprintf (stderr, "Npts: %d\n", graph[0].objects[i].Npts);
-    DrawObjectN (graph, &graph[0].objects[i]);
+    DrawObjectN (graphic, graph, &graph[0].objects[i]);
   }    
   XSetLineAttributes (graphic->display, graphic->gc, 0, LineSolid, CAPSTYLE, JOINSTYLE);
@@ -36,5 +36,5 @@
 
 /* Draw a specific object in the graph */
-int DrawObjectN (KapaGraphWidget *graph, Gobjects *object) {
+int DrawObjectN (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
   
   static char dot[2] = {2,3};
@@ -87,20 +87,20 @@
   switch (object[0].style) {
     case KAPA_PLOT_CONNECT: 
-      DrawConnect (graph, object);
+      DrawConnect (graphic, graph, object);
       break;
     case KAPA_PLOT_HISTOGRAM:
-      DrawHistogram (graph, object);
+      DrawHistogram (graphic, graph, object);
       break;
     case KAPA_PLOT_POINTS:
     default:
-      DrawPoints (graph, object);
+      DrawPoints (graphic, graph, object);
       break;
   }
     
   if (object[0].etype & 0x01) {
-    DrawYErrors (graph, object);
+    DrawYErrors (graphic, graph, object);
   }
   if (object[0].etype & 0x02) {
-    DrawXErrors (graph, object);
+    DrawXErrors (graphic, graph, object);
   }
   return (TRUE);
@@ -108,5 +108,5 @@
 
 /******/
-void DrawConnect (KapaGraphWidget *graph, Gobjects *object) {
+void DrawConnect (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
   
   int i;
@@ -145,5 +145,5 @@
     sy1 = x[i]*myi + y[i]*myj + by + YCENTER;
     
-    ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
+    ClipLine (graphic, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
     /* DrawLine (sx0, sy0, sx1, sy1); */
     sx0 = sx1; sy0 = sy1;
@@ -152,5 +152,5 @@
 }
 
-void ClipLine (double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0) {
+void ClipLine (Graphic *graphic, double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0) {
 
   /* skip line segement if both points are beyond box */
@@ -208,5 +208,5 @@
 /* simplify the code abit by finding triplets, watch out for a histogram of 2 points */
 # if (1)
-void DrawHistogram (KapaGraphWidget *graph, Gobjects *object) {
+void DrawHistogram (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
 
   int i;
@@ -294,5 +294,5 @@
 # else 
 
-void DrawHistogram (KapaGraphWidget *graph, Gobjects *object) {
+void DrawHistogram (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
 
   int i;
@@ -403,5 +403,5 @@
 
 /******/
-void DrawPoints (KapaGraphWidget *graph, Gobjects *object) {
+void DrawPoints (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
 
   int i;
@@ -423,6 +423,4 @@
   by = byi + byj;
   
-  Graphic *graphic = GetGraphic();
-
   /**** point sizes are scaled by object.size, colors by object.color ***/
   int scaleSize = (object[0].size < 0);
@@ -701,5 +699,5 @@
 	sx2 = x[i+1]*mxi + y[i+1]*mxj + bx + XCENTER;
 	sy2 = x[i+1]*myi + y[i+1]*myj + by + YCENTER;
-	ClipLine (sx1, sy1, sx2, sy2, X0, Y0, X1, Y1);
+	ClipLine (graphic, sx1, sy1, sx2, sy2, X0, Y0, X1, Y1);
       }
       break;
@@ -727,5 +725,5 @@
     
 /******/
-void DrawXErrors (KapaGraphWidget *graph, Gobjects *object) {
+void DrawXErrors (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
   
   int i, bar, dz, ds, D;
@@ -780,9 +778,9 @@
 	 (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy))) 
     {
-      ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
+      ClipLine (graphic, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
       if (bar) {
 	sx10 = sy1 - sz;
 	sx11 = sy1 + sz;
-	ClipLine (sx1, sx10, sx1, sx11, X0, Y0, X1, Y1);
+	ClipLine (graphic, sx1, sx10, sx1, sx11, X0, Y0, X1, Y1);
       }
     }
@@ -799,9 +797,9 @@
 	 (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
     {
-      ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
+      ClipLine (graphic, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
       if (bar) {
 	sx10 = sy1 - sz;
 	sx11 = sy1 + sz;
-	ClipLine (sx1, sx10, sx1, sx11, X0, Y0, X1, Y1);
+	ClipLine (graphic, sx1, sx10, sx1, sx11, X0, Y0, X1, Y1);
       }
     }
@@ -810,5 +808,5 @@
     
 /******/
-void DrawYErrors (KapaGraphWidget *graph, Gobjects *object) {
+void DrawYErrors (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
 
   int i, bar, dz, ds, D;
@@ -863,9 +861,9 @@
 	 (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
     {
-      ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
+      ClipLine (graphic, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
       if (bar) {
 	sx10 = sx1 - sz;
 	sx11 = sx1 + sz;
-	ClipLine (sx10, sy1, sx11, sy1, X0, Y0, X1, Y1);
+	ClipLine (graphic, sx10, sy1, sx11, sy1, X0, Y0, X1, Y1);
       }
     }
@@ -884,9 +882,9 @@
 	 (sy1 < graph[0].axis[1].fy) && (sy1 > graph[0].axis[1].fy + graph[0].axis[1].dfy)))
     {
-      ClipLine (sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
+      ClipLine (graphic, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
       if (bar) {
 	sx10 = sx1 - sz;
 	sx11 = sx1 + sz;
-	ClipLine (sx10, sy1, sx11, sy1, X0, Y0, X1, Y1);
+	ClipLine (graphic, sx10, sy1, sx11, sy1, X0, Y0, X1, Y1);
       }
     }
Index: /branches/czw_branch/20160809/Ohana/src/kapa2/src/LoadObject.c
===================================================================
--- /branches/czw_branch/20160809/Ohana/src/kapa2/src/LoadObject.c	(revision 39736)
+++ /branches/czw_branch/20160809/Ohana/src/kapa2/src/LoadObject.c	(revision 39737)
@@ -102,5 +102,8 @@
   if (DEBUG) fprintf (stderr, "loaded %d objects, using object %d\n", graph[0].objects[N].Npts, N);
 
-  if (USE_XWINDOW) DrawObjectN (graph, &graph[0].objects[graph[0].Nobjects-1]);
+  if (USE_XWINDOW) {
+    Graphic *graphic = GetGraphic();
+    DrawObjectN (graphic, graph, &graph[0].objects[graph[0].Nobjects-1]);
+  }
   FlushDisplay ();
 
