Ilya Zakharevich on Wed, 6 Oct 1999 20:44:47 -0400 (EDT)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Update Gnuplot support to future 3.7.1


I checked gnuplot support of Pari with soon-to-be-released gnuplot
3.7.1, and of course a new development moved Gnuplot.h out of sync.

However, the thing which broke the compile is that the official
distribution started to support "interactive" plotting, when user can
(say) click on a point on the graph and obtain the info about
coordinates of this point.

This patch updates gnuplot support in PARI to compile with 3.7.1, and
to provide necessary info for "interactive terminals".

Enjoy,
Ilya

--- ./src/graph/rect.h~	Thu Sep 16 09:50:21 1999
+++ ./src/graph/rect.h	Wed Oct  6 19:34:04 1999
@@ -44,6 +44,8 @@ typedef struct PariRect {
   double cursorx,cursory;
   double xscale,yscale;
   double xshift,yshift;
+  long has_graph;	   /* xy-ranges of this rectangle should be used
+			      for interactive operations.  */
 } PariRect;
 
 /* The structures below are "subclasses" of RectObj. */
@@ -139,6 +141,7 @@ typedef struct RectObjPS {
 #define RYshift(rp) ((rp)->yshift)
 #define RXscale(rp) ((rp)->xscale)
 #define RYscale(rp) ((rp)->yscale)
+#define RHasGraph(rp) ((rp)->has_graph)
 
 #define RoNext(rop) ((rop)->next)
 #define RoType(rop) ((rop)->code)
--- ./src/graph/plotport.c~	Thu Sep 16 09:50:20 1999
+++ ./src/graph/plotport.c	Wed Oct  6 20:08:23 1999
@@ -229,6 +229,7 @@ initrect(long ne, long x, long y)
   RXcursor(e)=0; RYcursor(e)=0;
   RXscale(e)=1; RXshift(e)=0;
   RYscale(e)=1; RYshift(e)=0;
+  RHasGraph(e) = 0;
 }
 
 GEN
@@ -1427,6 +1435,7 @@ rectplothrawin(long stringrect, long dra
     initrect(stringrect, W.width-1, W.height-1);
     if (drawrect != stringrect) initrect(drawrect, is-1, js-1);
   }
+  RHasGraph(check_rect(drawrect)) = 1;
 
   if (!(flags & PLOT_NO_RESCALE))
     rectscale0(drawrect, xsml, xbig, ysml, ybig);
--- ./src/graph/plotgnuplot.c~	Thu Sep 16 09:50:20 1999
+++ ./src/graph/plotgnuplot.c	Wed Oct  6 20:06:15 1999
@@ -26,7 +26,7 @@ rectdraw0(long *w, long *x, long *y, lon
 {
   long *ptx,*pty;
   long i,j,x0,y0;
-  long good;
+  long good, seen_graph = 0;
   int point_type = -1, line_type = 0;
   PariRect *e;
   RectObj *p1;
@@ -40,6 +41,38 @@ rectdraw0(long *w, long *x, long *y, lon
 #endif
   linetype(line_type);			/* X does not work otherwise. */
   setpointsize(pointsize);
+
+  /* Find the info about the *actual* x and y-coords of the
+     rectangles.  Use the first rectangle with has_graph attribute. */
+
+  for(i=0;i<lw;i++) {
+      e=rectgraph[w[i]];
+      if (RHasGraph(e)) {
+	  double t;
+
+	  xleft = x[i]; xright = xleft + RXsize(e) - 1;
+	  ytop = w_height - 1 - y[i]; ybot = ytop - (RYsize(e) - 1);
+	  t = (0 - RXshift(e))/RXscale(e);
+	  min_array[FIRST_X_AXIS] = min_array[SECOND_X_AXIS] = t;
+	  t = (RXsize(e) - 1 - RXshift(e))/RXscale(e);
+	  max_array[FIRST_X_AXIS] = max_array[SECOND_X_AXIS] = t;
+	  t = (RYsize(e) - 1 - RYshift(e))/RYscale(e);
+	  min_array[FIRST_Y_AXIS] = min_array[SECOND_Y_AXIS] = t;
+	  t = (0 - RYshift(e))/RYscale(e);
+	  max_array[FIRST_Y_AXIS] = max_array[SECOND_Y_AXIS] = t;
+	  seen_graph = 1;
+	  break;
+      }
+  }
+  if (!seen_graph) {			/* Put some reasonable values */
+      xleft = 0; xright = w_width - 1;
+      ybot  = 0; ytop   = w_height - 1;
+      min_array[FIRST_X_AXIS] = min_array[SECOND_X_AXIS] = 0;
+      max_array[FIRST_X_AXIS] = max_array[SECOND_X_AXIS] = 0;
+      min_array[FIRST_Y_AXIS] = min_array[SECOND_Y_AXIS] = 0;
+      max_array[FIRST_Y_AXIS] = max_array[SECOND_Y_AXIS] = 0;
+  }
+  
   for(i=0;i<lw;i++)
   {
     e=rectgraph[w[i]]; p1=RHead(e); x0=x[i]; y0=y[i];
--- ./src/graph/Gnuplot.h~	Thu Sep 16 09:50:19 1999
+++ ./src/graph/Gnuplot.h	Wed Oct  6 19:25:41 1999
@@ -127,6 +127,38 @@ struct lexical_unit *token = tokens;
 long c_token = 0, num_tokens = 0;
 char term_options[200] = "";
 
+/* New with 3.7.1: */
+
+#define FIRST_Z_AXIS 0
+#define FIRST_Y_AXIS 1
+#define FIRST_X_AXIS 2
+#define SECOND_Z_AXIS 4 /* for future expansion ;-) */
+#define SECOND_Y_AXIS 5
+#define SECOND_X_AXIS 6
+/* extend list for datatype[] for t,u,v,r though IMHO
+ * they are not relevant to time data [being parametric dummies]
+ */
+#define T_AXIS 3  /* fill gap */
+#define R_AXIS 7  /* never used ? */
+#define U_AXIS 8
+#define V_AXIS 9
+
+#define AXIS_ARRAY_SIZE 10
+#define DATATYPE_ARRAY_SIZE 10
+
+extern double min_array[], max_array[], base_array[], log_base_array[];
+extern TBOOLEAN log_array[];
+/* graphics.c */
+extern int xleft, xright, ybot, ytop;
+extern TBOOLEAN is_3d_plot;
+
+double min_array[AXIS_ARRAY_SIZE], max_array[AXIS_ARRAY_SIZE], base_array[AXIS_ARRAY_SIZE], log_base_array[AXIS_ARRAY_SIZE];
+TBOOLEAN log_array[AXIS_ARRAY_SIZE];
+int xleft, xright, ybot, ytop;
+TBOOLEAN is_3d_plot;
+
+/* End of 3.7.1 additions */
+
 /* Here are the only missing functions: */
 
 struct value*