summaryrefslogtreecommitdiffstats
path: root/src/cmd/grap/coord.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-05-15 23:24:00 +0000
committerrsc <devnull@localhost>2004-05-15 23:24:00 +0000
commit5cedca1b69d020c32466f70843a11767773d7e3b (patch)
treea15a3d84e92aa262543b0010763a5e6920c9ba24 /src/cmd/grap/coord.c
parent76e6aca867e3e48ea04fbcf7284c45369a69829e (diff)
downloadplan9port-5cedca1b69d020c32466f70843a11767773d7e3b.tar.gz
plan9port-5cedca1b69d020c32466f70843a11767773d7e3b.zip
Let's try this. It's BUGGERED.
Diffstat (limited to 'src/cmd/grap/coord.c')
-rw-r--r--src/cmd/grap/coord.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/cmd/grap/coord.c b/src/cmd/grap/coord.c
new file mode 100644
index 00000000..72f0fc3a
--- /dev/null
+++ b/src/cmd/grap/coord.c
@@ -0,0 +1,71 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "grap.h"
+#include "y.tab.h"
+
+char *dflt_coord = "gg";
+char *curr_coord = "gg";
+int ncoord = 0; /* number of explicit coord's given */
+
+Point xcoord;
+Point ycoord;
+int xcflag = 0; /* 1 if xcoord set */
+int ycflag = 0;
+int logcoord = 0;
+
+void coord_x(Point pt) /* remember x coord */
+{
+ xcoord = pt;
+ xcflag = 1;
+ margin = 0; /* no extra space around picture if explicit coords */
+}
+
+void coord_y(Point pt)
+{
+ ycoord = pt;
+ ycflag = 1;
+ margin = 0; /* no extra space if explicit coords */
+}
+
+void coordlog(int n) /* remember log scaling */
+{
+ logcoord = n;
+}
+
+void coord(Obj *p) /* set coord range */
+{
+ static char buf[10];
+
+ ncoord++;
+ if (ncoord > 1 && strcmp(p->name, dflt_coord) == 0) {
+ /* resetting default coordinate by implication */
+ sprintf(buf, "gg%d", ncoord);
+ dflt_coord = buf;
+ p = lookup(dflt_coord, 1);
+ }
+ if (xcflag) {
+ p->coord |= XFLAG;
+ p->pt.x = min(xcoord.x,xcoord.y); /* "xcoord" is xmin, xmax */
+ p->pt1.x = max(xcoord.x,xcoord.y);
+ if ((logcoord&XFLAG) && p->pt.x <= 0.0)
+ ERROR "can't have log of x coord %g,%g", p->pt.x, p->pt1.x FATAL;
+ xcflag = 0;
+ }
+ if (ycflag) {
+ p->coord |= YFLAG;
+ p->pt.y = min(ycoord.x,ycoord.y); /* "ycoord" is ymin, ymax */
+ p->pt1.y = max(ycoord.x,ycoord.y);
+ if ((logcoord&YFLAG) && p->pt.y <= 0.0)
+ ERROR "can't have log of y coord %g,%g", p->pt.y, p->pt1.y FATAL;
+ ycflag = 0;
+ }
+ p->log = logcoord;
+ logcoord = 0;
+ auto_x = 0;
+}
+
+void resetcoord(Obj *p) /* reset current coordinate */
+{
+ curr_coord = p->name;
+}