aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/gtools
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /pkg/xtools/gtools
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'pkg/xtools/gtools')
-rw-r--r--pkg/xtools/gtools/Revisions172
-rw-r--r--pkg/xtools/gtools/gtascale.x100
-rw-r--r--pkg/xtools/gtools/gtcolon.x754
-rw-r--r--pkg/xtools/gtools/gtcopy.x85
-rw-r--r--pkg/xtools/gtools/gtctran.x34
-rw-r--r--pkg/xtools/gtools/gtcur.x21
-rw-r--r--pkg/xtools/gtools/gtcur1.x38
-rw-r--r--pkg/xtools/gtools/gtfree.x26
-rw-r--r--pkg/xtools/gtools/gtget.x210
-rw-r--r--pkg/xtools/gtools/gtgui.x160
-rw-r--r--pkg/xtools/gtools/gthelp.x12
-rw-r--r--pkg/xtools/gtools/gtinit.x164
-rw-r--r--pkg/xtools/gtools/gtlabax.x139
-rw-r--r--pkg/xtools/gtools/gtools.h168
-rw-r--r--pkg/xtools/gtools/gtools.hd3
-rw-r--r--pkg/xtools/gtools/gtools.hlp91
-rw-r--r--pkg/xtools/gtools/gtplot.x82
-rw-r--r--pkg/xtools/gtools/gtreset.x83
-rw-r--r--pkg/xtools/gtools/gtset.x224
-rw-r--r--pkg/xtools/gtools/gtswind.x65
-rw-r--r--pkg/xtools/gtools/gtvplot.x51
-rw-r--r--pkg/xtools/gtools/gtwindow.x180
-rw-r--r--pkg/xtools/gtools/mkpkg27
23 files changed, 2889 insertions, 0 deletions
diff --git a/pkg/xtools/gtools/Revisions b/pkg/xtools/gtools/Revisions
new file mode 100644
index 00000000..cca0335c
--- /dev/null
+++ b/pkg/xtools/gtools/Revisions
@@ -0,0 +1,172 @@
+.help revisions Jun88 pkg.xtools.gtools
+.nf
+=====
+V2.12
+=====
+
+pkg$xtools/gtools/gtlabax.x
+ Added workaround to avoid GUI message. (2/1/99, Valdes)
+
+=======
+V2.11.2
+=======
+
+pkg$xtools/gtools/gtcolon.x
+ Corrected definition of btoi. (8/11/99, Valdes)
+
+pkg$xtools/gtools/gtreset.x
+ This routine was declared as a function rather than a subroutine
+ as it should be. (7/21/99, Valdes)
+
+pkg$xtools/gtools/gtlabax.x
+ Gmsg call is only made if there is a GUI. (7/14/99, Valdes)
+
+*
+pkg$xtools/gtools/gthelp.x -
+pkg$xtools/gtools/gtpage.x -
+ New version with access to most of the GIO parameters and with
+ GUI messages. (5/11/99, Valdes)
+
+=======
+V2.11.1
+=======
+
+=====
+V2.11
+=====
+lib$pkg/gtools.h
+pkg$xtools/gtools/gtools.h
+pkg$xtools/gtools/gtcolon.x
+pkg$xtools/gtools/gtset.x
+pkg$xtools/gtools/gtget.x
+pkg$xtools/gtools/gtlabax.x
+pkg$xtools/gtools/gtinit.x
+pkg$xtools/gtools/gtools.hlp
+ Added GTDRAWTITLE, GTDRAWXLABELS, and GTDRAWYLABELS to control the
+ three label components as blocks and independent of the user or
+ application settings of the title parameters and label parameters.
+ The help and key files were updated.
+ (4/26/96, Valdes)
+
+=========
+V2.10.4p2
+=========
+
+pkg$xtools/gtools/gtascale.x
+ The case with gt==NULL was not correct. (8/16/95, Valdes)
+
+lib$pkg/gtools.h
+pkg$xtools/gtools/gtools.h
+pkg$xtools/gtools/gtget.x
+pkg$xtools/gtools/gtset.x
+pkg$xtools/gtools/gtwindow.x
+pkg$xtools/gtools/gtcopy.x
+pkg$xtools/gtools/gtinit.x
+pkg$xtools/gtools/gtswind.x
+pkg$xtools/gtools/gtcolon.x
+pkg$xtools/gtools/gtascale.x
+ Two new parameters, GTXFLIP and GTYFLIP, were added. These boolean
+ parameters can be set to flip vectors plotted with the gtools
+ functions. In the gt_window functions flips are now done using
+ these new parameters rather than explicitly setting the plot
+ limits. Previously this meant that any use of the flip would
+ not allow autoscaling; that is a new graph with different limits
+ would only cover the fixed limits. It also mean that the 'a'
+ window function would reset the flip. (12/8/93, Valdes)
+
+pkg$xtools/gtools/gtplot.x
+ The gio color marks are drawn using the G_PLCOLOR rather than G_PMCOLOR
+ so the code was change to work appropriately. (11/11/93, Valdes)
+
+===========
+V2.10.3Beta
+===========
+
+pgk$xtools/gtools/gtools.hlp
+pgk$xtools/gtools/gtinit.x
+pgk$xtools/gtools/gtcolon.x
+pgk$xtools/gtools/Revisions
+pgk$xtools/gtools/gtvplot.x
+pgk$xtools/gtools/gtset.x
+pgk$xtools/gtools/gtplot.x
+pgk$xtools/gtools/gtget.x
+pgk$xtools/gtools/gtcopy.x
+pgk$xtools/gtools/gtools.h
+ Added color option. (10/29/92, Valdes)
+
+pkg$xtools/gtools/gtcolon.x
+ The :/parameters case was resetting the subtitle string.
+ (12/28/90, Valdes, diagnosed by Jeff Munn)
+
+pkg$xtools/gtools/gtget.x
+ When the sysid option was added the gtgets routine was not modified
+ to return the setting. This has been added. (7/12/90, Valdes)
+
+pkg$xtools/gtools/gtget.x
+ When the histogram type was added the gtgets routine was not modified
+ to return this type. This has been added. (6/28/90, Valdes)
+
+====
+V2.9
+====
+
+pkg$xtools/gtools
+ 1. Added new colon command :/sysid to turn off system ID banner.
+ 2. Added new colon command :/type hist to plot histogram type lines.
+ (10/5/89, Valdes)
+
+pkg$xtools/gtools/gtascale.x
+ Made a trivial change, a temp variable is now used for switching two
+ variables, to work around an optimizer bug on Sun3/OS4/f68881.
+ (9/21/89, Valdes)
+
+====
+V2.8
+====
+
+pkg$xtools/gtools/gtascale.x +
+ Added a procedure to complement GSCALE to scale data only within
+ a GTOOLS window. (11/30/87 Valdes)
+
+pkg$xtools/gtools/gtvplot.x +
+ Added a vector version of GT_PLOT. (11/5/87 Valdes)
+
+====
+V2.5
+====
+
+pkg$xtools/gtools/*.x
+ Valdes, February 17, 1987
+ 1. Requires GIO changes.
+ 2. Eliminated GT_PAGE, GT_HELP, GT_WAITPAGE.
+ 3. Argument change to GT_COLON.
+
+pkg$xtools/gtools/gtset.x
+ Valdes, January 30, 1987
+ 1. In gtsets if the specified value string is not recognized an
+ error message is printed to STDERR.
+
+pkg$xtools/gtools/gthelp.x
+pkg$xtools/gtools/gtwindow.x
+pkg$xtools/gtools/gtcolon.x
+ Valdes, January 13, 1987
+ 1. GT_HELP now calls the system PAGEFILE procedure. This procedure
+ should now be obsolete.
+ 2. Modified GT_WINDOW and GT_COLON to call PAGEFILE instead of GT_HELP.
+
+gtools$gtwindow.x: Valdes, June 11, 1986
+ 1. Added new procedure gt_window. It is a cursor driven procedure
+ for windowing graphs using the gtools pointer. The help
+ page for gtools was also modified to show the windowing options.
+
+gtools$gtcur.x: Valdes, May 10, 1986
+ 1. Took out "Confirm:" prompt so that cursor input from a file does
+ not cause anything to be printed. Two EOF's (carriage return or
+ actual EOF) or a 'q' are required to exit thus protecting the user
+ from an inadvertent carriage return.
+
+From Valdes Oct 29, 1985:
+
+Added call to gmftitle in gtlabax. This insures that graphics written to
+a metacode file can use the metacode tools locate graphics.
+.endhelp
diff --git a/pkg/xtools/gtools/gtascale.x b/pkg/xtools/gtools/gtascale.x
new file mode 100644
index 00000000..06f5c0ef
--- /dev/null
+++ b/pkg/xtools/gtools/gtascale.x
@@ -0,0 +1,100 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "gtools.h"
+
+# GT_ASCALE -- Set graphics window to the range of the data.
+# Unlike GASCALE the data is limited to the GTOOLS window.
+# It also clips a fraction of the high and low points.
+
+procedure gt_ascale (gp, gt, x, y, npts)
+
+pointer gp # GIO pointer
+pointer gt # GTOOLS pointer
+real x[npts], y[npts] # Data to scale
+int npts # Number of data points
+
+int i, j, k, n
+real xmin, xmax, ymin, ymax, x1, x2, y1, y2, temp
+pointer buf
+
+begin
+ if (gt == NULL) {
+ call gascale (gp, x, npts, 1)
+ call gascale (gp, y, npts, 1)
+ return
+ }
+
+ if (GT_TRANSPOSE(gt) == NO) {
+ xmin = GT_XMIN(gt)
+ xmax = GT_XMAX(gt)
+ ymin = GT_YMIN(gt)
+ ymax = GT_YMAX(gt)
+ } else {
+ ymin = GT_XMIN(gt)
+ ymax = GT_XMAX(gt)
+ xmin = GT_YMIN(gt)
+ xmax = GT_YMAX(gt)
+ }
+
+ if (IS_INDEF(xmin))
+ xmin = -MAX_REAL
+ if (IS_INDEF(xmax))
+ xmax = MAX_REAL
+ if (IS_INDEF(ymin))
+ ymin = -MAX_REAL
+ if (IS_INDEF(ymax))
+ ymax = MAX_REAL
+
+ temp = max (xmin, xmax)
+ xmin = min (xmin, xmax)
+ xmax = temp
+ temp = max (ymin, ymax)
+ ymin = min (ymin, ymax)
+ ymax = temp
+
+ x1 = xmax
+ x2 = xmin
+ y1 = ymax
+ y2 = ymin
+ n = 0
+ do i = 1, npts {
+ if ((x[i]<xmin)||(x[i]>xmax)||(y[i]<ymin)||(y[i]>ymax))
+ next
+ x1 = min (x1, x[i])
+ x2 = max (x2, x[i])
+ y1 = min (y1, y[i])
+ y2 = max (y2, y[i])
+ n = n + 1
+ }
+ if ((GT_LCLIP(gt) > 0. || GT_HCLIP(gt) > 0.) && n > 0) {
+ call malloc (buf, n, TY_REAL)
+ n = 0
+ do i = 1, npts {
+ if ((x[i]<xmin)||(x[i]>xmax)||(y[i]<ymin)||(y[i]>ymax))
+ next
+ Memr[buf+n] = y[i]
+ n = n + 1
+ }
+ call asrtr (Memr[buf], Memr[buf], n)
+ if (GT_LCLIP(gt) > 1.)
+ j = GT_LCLIP(gt) / 100. * n
+ else
+ j = max (0., GT_LCLIP(gt) * n)
+ if (GT_HCLIP(gt) > 1.)
+ k = GT_HCLIP(gt) / 100. * n
+ else
+ k = max (0., GT_HCLIP(gt) * n)
+ k = n - 1 - k
+ if (j > k) {
+ y1 = Memr[buf+j]
+ y2 = Memr[buf+k]
+ }
+ call mfree (buf, TY_REAL)
+ }
+
+ if (x1 <= x2)
+ call gswind (gp, x1, x2, INDEF, INDEF)
+ if (y1 <= y2)
+ call gswind (gp, INDEF, INDEF, y1, y2)
+end
diff --git a/pkg/xtools/gtools/gtcolon.x b/pkg/xtools/gtools/gtcolon.x
new file mode 100644
index 00000000..b2a918fb
--- /dev/null
+++ b/pkg/xtools/gtools/gtcolon.x
@@ -0,0 +1,754 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <ctype.h>
+include <gset.h>
+include "gtools.h"
+
+define KEY "lib$scr/gtools.key"
+define PROMPT "graph format options"
+
+# Defined colon commands for the GTOOLS package
+define CMDS "|help|xview|yview|xwindow|ywindow|sysid|parameters|title|subtitle\
+ |comments|xlabel|ylabel|xunits|yunits|drawtitle|drawxlabels|drawylabels\
+ |type|mark|line|xsize|ysize|color|xtransform|ytransform|xflip|yflip\
+ |transpose|xformat|yformat|xbuf|ybuf|clip|redraw|expand|shift|expand\
+ |uivalues|"
+
+define HELP 1 # Get help
+define XVIEW 2 # Set X viewport
+define YVIEW 3 # Set Y viewport
+define XWINDOW 4 # Set X window
+define YWINDOW 5 # Set Y window
+define SYSID 6 # Draw SYSID?
+define PARAMETERS 7 # Set parameters string
+define TITLE 8 # Set title
+define SUBTITLE 9 # Set subtitle string
+define COMMENTS 10 # Set comment string
+define XLABEL 11 # Set X label
+define YLABEL 12 # Set Y label
+define XUNITS 13 # Set X unit label
+define YUNITS 14 # Set Y unit label
+define DRAWTITLE 15 # Draw title block?
+define DRAWXLABELS 16 # Draw X label block?
+define DRAWYLABELS 17 # Draw Y label block?
+define TYPE 18 # Set graph type
+define MARK 19 # Set symbol mark type
+define LINE 20 # Set line type
+define XSIZE 21 # Set X symbol size
+define YSIZE 22 # Set Y symbol size
+define COLOR 23 # Set color
+define XTRANSFORM 24 # Set X transformation function
+define YTRANSFORM 25 # Set Y transformation function
+define XFLIP 26 # X flip
+define YFLIP 27 # Y flip
+define TRANSPOSE 28 # Transpose graph
+define XFORMAT 29 # X format
+define YFORMAT 30 # Y format
+define XBUF 31 # X buffer distance
+define YBUF 32 # X buffer distance
+define CLIP 33 # Clipping factors
+define REDRAW 34 # Redraw graph
+define EXPAND 35 # Expand world coordinates
+define SHIFT 36 # Shift world coordinates
+define WINDOW 37 # Window command
+define UIVALUES 38 # Send UI values
+
+
+# GT_COLON -- Process standard gtools colon commands.
+
+procedure gt_colon (cmdstr, gp, gt, newgraph)
+
+char cmdstr[ARB] # Command string
+pointer gp # GIO pointer
+pointer gt # GTOOLS pointer
+int newgraph # Update graph?
+
+char cmd[SZ_LINE]
+int ip, ncmd, ival
+real x, y, rval[4]
+bool bval
+
+int nscan(), strdic(), gt_geti(), btoi()
+real gt_getr()
+
+begin
+ # All GTOOLS commands start with '/'.
+ if (cmdstr[1] != '/')
+ return
+
+ # Parse the command string matched against a dictionary.
+ call sscan (cmdstr[2])
+ call gargwrd (cmd, SZ_LINE)
+ ncmd = strdic (cmd, cmd, SZ_LINE, CMDS)
+
+ # Switch on the command and parse the arguments.
+ switch (ncmd) {
+ case HELP: # help: Print help
+ call gpagefile (gp, KEY, PROMPT)
+
+ case XVIEW: # xview: List or set x viewport.
+ call gargr (rval[1])
+ call gargr (rval[2])
+ if (nscan() == 3) {
+ call gt_setr (gt, GTVXMIN, rval[1])
+ call gt_setr (gt, GTVXMAX, rval[2])
+ } else {
+ call printf ("xview = %g %g\n")
+ call pargr (gt_getr (gt, GTVXMIN))
+ call pargr (gt_getr (gt, GTVXMAX))
+ }
+
+ case YVIEW: # yview: List or set y viewport.
+ call gargr (rval[1])
+ call gargr (rval[2])
+ if (nscan() == 3) {
+ call gt_setr (gt, GTVYMIN, rval[1])
+ call gt_setr (gt, GTVYMAX, rval[2])
+ } else {
+ call printf ("yview = %g %g\n")
+ call pargr (gt_getr (gt, GTVYMIN))
+ call pargr (gt_getr (gt, GTVYMAX))
+ }
+
+ case XWINDOW: # xwindow: List or set x window.
+ call gargr (rval[1])
+ call gargr (rval[2])
+ if (nscan() == 3) {
+ call gt_setr (gt, GTXMIN, rval[1])
+ call gt_setr (gt, GTXMAX, rval[2])
+ } else {
+ call printf ("xwindow = %g %g\n")
+ call pargr (gt_getr (gt, GTXMIN))
+ call pargr (gt_getr (gt, GTXMAX))
+ }
+
+ case YWINDOW: # ywindow: List or set y window.
+ call gargr (rval[1])
+ call gargr (rval[2])
+ if (nscan() == 3) {
+ call gt_setr (gt, GTYMIN, rval[1])
+ call gt_setr (gt, GTYMAX, rval[2])
+ } else {
+ call printf ("ywindow = %g %g\n")
+ call pargr (gt_getr (gt, GTYMIN))
+ call pargr (gt_getr (gt, GTYMAX))
+ }
+
+ case SYSID: # sysid: Write SYSID string?
+ call gargb (bval)
+ if (nscan() == 2)
+ call gt_seti (gt, GTSYSID, btoi (bval))
+ else {
+ call printf ("sysid = %b\n")
+ call pargi (gt_geti (gt, GTSYSID))
+ }
+
+ case PARAMETERS: # parameters: Set parameters string
+ call gargstr (cmd, SZ_LINE)
+ for (ip=1; IS_WHITE(cmd[ip]); ip=ip+1)
+ ;
+ call gt_sets (gt, GTPARAMS, cmd[ip])
+
+ case TITLE: # title: Set graph title
+ call gargstr (cmd, SZ_LINE)
+ for (ip=1; IS_WHITE(cmd[ip]); ip=ip+1)
+ ;
+ call gt_sets (gt, GTTITLE, cmd[ip])
+
+ case SUBTITLE: # subtitle: Set subtitle string
+ call gargstr (cmd, SZ_LINE)
+ for (ip=1; IS_WHITE(cmd[ip]); ip=ip+1)
+ ;
+ call gt_sets (gt, GTSUBTITLE, cmd[ip])
+
+ case COMMENTS: # comments: Set graph comments
+ call gargstr (cmd, SZ_LINE)
+ for (ip=1; IS_WHITE(cmd[ip]); ip=ip+1)
+ ;
+ call gt_sets (gt, GTCOMMENTS, cmd[ip])
+
+ case XLABEL: # xlabel: Set graph x label
+ call gargstr (cmd, SZ_LINE)
+ for (ip=1; IS_WHITE(cmd[ip]); ip=ip+1)
+ ;
+ call gt_sets (gt, GTXLABEL, cmd[ip])
+
+ case YLABEL: # ylabel: Set graph y label
+ call gargstr (cmd, SZ_LINE)
+ for (ip=1; IS_WHITE(cmd[ip]); ip=ip+1)
+ ;
+ call gt_sets (gt, GTYLABEL, cmd[ip])
+
+ case XUNITS: # xunits: Set graph x units
+ call gargstr (cmd, SZ_LINE)
+ for (ip=1; IS_WHITE(cmd[ip]); ip=ip+1)
+ ;
+ call gt_sets (gt, GTXUNITS, cmd[ip])
+
+ case YUNITS: # yunits: Set graph y units
+ call gargstr (cmd, SZ_LINE)
+ for (ip=1; IS_WHITE(cmd[ip]); ip=ip+1)
+ ;
+ call gt_sets (gt, GTYUNITS, cmd[ip])
+
+ case DRAWTITLE: # drawtitle: Draw title block?
+ call gargb (bval)
+ if (nscan() == 2)
+ call gt_seti (gt, GTDRAWTITLE, btoi (bval))
+ else {
+ call printf ("drawtitle = %b\n")
+ call pargi (gt_geti (gt, GTDRAWTITLE))
+ }
+
+ case DRAWXLABELS: # drawxlabels: Draw x label block?
+ call gargb (bval)
+ if (nscan() == 2)
+ call gt_seti (gt, GTDRAWXLABELS, btoi (bval))
+ else {
+ call printf ("drawxlabel = %b\n")
+ call pargi (gt_geti (gt, GTDRAWXLABELS))
+ }
+
+ case DRAWYLABELS: # drawylabels: Draw y label block?
+ call gargb (bval)
+ if (nscan() == 2)
+ call gt_seti (gt, GTDRAWYLABELS, btoi (bval))
+ else {
+ call printf ("drawylabel = %b\n")
+ call pargi (gt_geti (gt, GTDRAWYLABELS))
+ }
+
+ case TYPE: # type: Graph type
+ call gargwrd (cmd, SZ_LINE)
+ if (nscan() == 2)
+ call gt_sets (gt, GTTYPE, cmd)
+ else {
+ call gt_gets (gt, GTTYPE, cmd, SZ_LINE)
+ call printf ("type = %s\n")
+ call pargstr (cmd)
+ }
+
+ case MARK: # mark: Mark type
+ call gargwrd (cmd, SZ_LINE)
+ if (nscan() == 2)
+ call gt_sets (gt, GTMARK, cmd)
+ else {
+ call gt_gets (gt, GTMARK, cmd, SZ_LINE)
+ call printf ("mark = %s\n")
+ call pargstr (cmd)
+ }
+
+ case LINE: # line: Line type
+ call gargi (ival)
+ if (nscan() == 2)
+ call gt_seti (gt, GTLINE, ival)
+ else {
+ call printf ("line = %s\n")
+ call pargi (gt_geti (gt, GTLINE))
+ }
+
+ case XSIZE: # xsize: List or set x mark size.
+ call gargr (rval[1])
+ if (nscan() == 2) {
+ call gt_setr (gt, GTXSIZE, rval[1])
+ } else {
+ call printf ("xsize = %g\n")
+ call pargr (gt_getr (gt, GTXSIZE))
+ }
+
+
+ case YSIZE: # ysize: List or set y mark size.
+ call gargr (rval[1])
+ if (nscan() == 2) {
+ call gt_setr (gt, GTYSIZE, rval[1])
+ } else {
+ call printf ("ysize = %g\n")
+ call pargr (gt_getr (gt, GTYSIZE))
+ }
+
+ case COLOR: # color: line/mark color
+ call gargi (ival)
+ if (nscan() == 2)
+ call gt_seti (gt, GTCOLOR, ival)
+ else {
+ call printf ("color = %s\n")
+ call pargi (gt_geti (gt, GTCOLOR))
+ }
+
+ case XTRANSFORM: # xtransform: List or set ytransform.
+ call gargwrd (cmd, SZ_LINE)
+ if (nscan() == 2)
+ call gt_sets (gt, GTXTRAN, cmd)
+ else {
+ call gt_gets (gt, GTXTRAN, cmd, SZ_LINE)
+ call printf ("xtransform = %s\n")
+ call pargstr (cmd)
+ }
+
+ case YTRANSFORM: # ytransform: List or set ytransform.
+ call gargwrd (cmd, SZ_LINE)
+ if (nscan() == 2)
+ call gt_sets (gt, GTYTRAN, cmd)
+ else {
+ call gt_gets (gt, GTYTRAN, cmd, SZ_LINE)
+ call printf ("ytransform = %s\n")
+ call pargstr (cmd)
+ }
+
+ case XFLIP: # xflip: Toggle x flip flag
+ call gargb (bval)
+ if (nscan() == 2)
+ call gt_seti (gt, GTXFLIP, btoi (bval))
+ else {
+ call printf ("xflip = %b\n")
+ call pargi (gt_geti (gt, GTXFLIP))
+ }
+
+ case YFLIP: # yflip: Toggle y flip flag
+ call gargb (bval)
+ if (nscan() == 2)
+ call gt_seti (gt, GTYFLIP, btoi (bval))
+ else {
+ call printf ("yflip = %b\n")
+ call pargi (gt_geti (gt, GTYFLIP))
+ }
+
+ case TRANSPOSE: # transpose: Toggle transpose flag
+ if (gt_geti (gt, GTTRANSPOSE) == NO)
+ call gt_seti (gt, GTTRANSPOSE, YES)
+ else
+ call gt_seti (gt, GTTRANSPOSE, NO)
+
+ case XFORMAT: # xformat: Set graph x format
+ call gargstr (cmd, SZ_LINE)
+ for (ip=1; IS_WHITE(cmd[ip]); ip=ip+1)
+ ;
+ call gt_sets (gt, GTXFORMAT, cmd[ip])
+
+ case YFORMAT: # yformat: Set graph y format
+ call gargstr (cmd, SZ_LINE)
+ for (ip=1; IS_WHITE(cmd[ip]); ip=ip+1)
+ ;
+ call gt_sets (gt, GTYFORMAT, cmd[ip])
+
+ case XBUF: # xbuf: List or set x buffer.
+ call gargr (rval[1])
+ if (nscan() == 2)
+ call gt_setr (gt, GTXBUF, rval[1])
+ else {
+ call printf ("xbuf = %g\n")
+ call pargr (gt_getr (gt, GTXBUF))
+ }
+
+ case YBUF: # ybuf: List or set y buffer.
+ call gargr (rval[1])
+ if (nscan() == 2)
+ call gt_setr (gt, GTYBUF, rval[1])
+ else {
+ call printf ("ybuf = %g\n")
+ call pargr (gt_getr (gt, GTYBUF))
+ }
+
+ case CLIP: # clip: autoscaling clipping
+ call gargr (rval[1])
+ call gargr (rval[2])
+ if (nscan() == 3) {
+ call gt_setr (gt, GTLCLIP, rval[1])
+ call gt_setr (gt, GTHCLIP, rval[2])
+ } else {
+ call printf ("clip = %g %g\n")
+ call pargr (gt_getr (gt, GTLCLIP))
+ call pargr (gt_getr (gt, GTHCLIP))
+ }
+
+ case REDRAW: # redraw: Redraw the graph
+ newgraph = 1
+
+ case EXPAND: # :expand x1 x2 y1 y2
+ call gargr (rval[1])
+ call gargr (rval[2])
+ call gargr (rval[3])
+ call gargr (rval[4])
+ if (nscan() == 5) {
+ if (rval[1] != gt_getr (gt, GTXMIN)) {
+ call gt_setr (gt, GTXMIN, rval[1])
+ newgraph = 1
+ }
+ if (rval[2] != gt_getr (gt, GTXMAX)) {
+ call gt_setr (gt, GTXMAX, rval[2])
+ newgraph = 1
+ }
+ if (rval[3] != gt_getr (gt, GTYMIN)) {
+ call gt_setr (gt, GTYMIN, rval[3])
+ newgraph = 1
+ }
+ if (rval[4] != gt_getr (gt, GTYMAX)) {
+ call gt_setr (gt, GTYMAX, rval[4])
+ newgraph = 1
+ }
+ }
+
+ case SHIFT: # :shift x y
+ call gargr (x)
+ call gargr (y)
+ rval[1] = gt_getr (gt, GTXMIN)
+ rval[2] = gt_getr (gt, GTXMAX)
+ if (IS_INDEFR(x)) {
+ if (!IS_INDEFR(rval[1]) || !IS_INDEFR(rval[2])) {
+ call gt_setr (gt, GTXMIN, INDEFR)
+ call gt_setr (gt, GTXMAX, INDEFR)
+ newgraph = 1
+ }
+ } else {
+ if (!IS_INDEFR(rval[1]) && !IS_INDEFR(rval[2])) {
+ rval[3] = rval[2] - rval[1]
+ rval[4] = x - (rval[1] + rval[2]) / 2
+ if (abs (rval[4] / rval[3]) > 0.001) {
+ call gt_setr (gt, GTXMIN, rval[1] + rval[4])
+ call gt_setr (gt, GTXMAX, rval[2] + rval[4])
+ }
+ newgraph = 1
+ }
+ }
+
+ rval[1] = gt_getr (gt, GTYMIN)
+ rval[2] = gt_getr (gt, GTYMAX)
+ if (IS_INDEFR(y)) {
+ if (!IS_INDEFR(rval[1]) || !IS_INDEFR(rval[2])) {
+ call gt_setr (gt, GTYMIN, INDEFR)
+ call gt_setr (gt, GTYMAX, INDEFR)
+ newgraph = 1
+ }
+ } else {
+ if (!IS_INDEFR(rval[1]) && !IS_INDEFR(rval[2])) {
+ rval[3] = rval[2] - rval[1]
+ rval[4] = y - (rval[1] + rval[2]) / 2
+ if (abs (rval[4] / rval[3]) > 0.001) {
+ call gt_setr (gt, GTYMIN, rval[1] + rval[4])
+ call gt_setr (gt, GTYMAX, rval[2] + rval[4])
+ }
+ newgraph = 1
+ }
+ }
+
+ case WINDOW: # window: window x y wcs key cmd
+ call gargr (x)
+ call gargr (y)
+ call gargi (ip)
+ call gargwrd (cmd, SZ_LINE)
+ ival = cmd[1]
+ if (nscan() < 5)
+ return
+ if (ival == ':')
+ call gargwrd (cmd, SZ_LINE)
+ call gt_window1 (gt, gp, x, y, ip, ival, cmd, newgraph)
+
+ case UIVALUES: # uivalues: send values to UI
+ call gt_uivalues (gp, gt)
+
+ default: # Check for more colon command
+ call gt_colon1 (cmdstr, gp, gt, newgraph)
+ }
+end
+
+
+# Defined colon commands
+define CMDS1 "|txup|txsize|txpath|txspacing|txhjustify|txvjustify|txfont\
+ |txquality|txcolor|drawtitle|titlesize|titlejust|ntitlelines|aspect\
+ |charsize|titlecolor|framecolor|drawaxes|setaxispos|axispos1|axispos2\
+ |drawgrid|round|labelaxis|axislabelsize|drawticks|labelticks|nmajor\
+ |nminor|majorlength|minorlength|majorwidth|minorwidth|axiswidth\
+ |ticklabelsize|gridcolor|axislabelcolor|axiscolor|ticklabelcolor\
+ |tickcolor|axes|ticks|colors|"
+
+define TXUP 1 # Text parameters
+define TXSIZE 2
+define TXPATH 3
+define TXSPACING 4
+define TXHJUSTIFY 5
+define TXVJUSTIFY 6
+define TXFONT 7
+define TXQUALITY 8
+define TXCOLOR 9
+
+define DRAWTITLE 10 # GLABAX, general parameters
+define TITLESIZE 11
+define TITLEJUST 12
+define NTITLELINES 13
+define ASPECT 14
+define CHARSIZE 15
+define TITLECOLOR 16
+define FRAMECOLOR 17
+
+define DRAWAXES 18 # GLABAX, x/y axis parameters
+define SETAXISPOS 19
+define AXISPOS1 20
+define AXISPOS2 21
+define DRAWGRID 22
+define ROUND 23
+define LABELAXIS 24
+define AXISLABELSIZE 25
+define DRAWTICKS 26
+define LABELTICKS 27
+define NMAJOR 28
+define NMINOR 29
+define MAJORLENGTH 30
+define MINORLENGTH 31
+define MAJORWIDTH 32
+define MINORWIDTH 33
+define AXISWIDTH 34
+define TICKLABELSIZE 35
+define GRIDCOLOR 36
+define AXISLABELCOLOR 37
+define AXISCOLOR 38
+define TICKLABELCOLOR 39
+define TICKCOLOR 40
+
+define AXES 41 # Grouped parameters
+define TICKS 42
+define COLORS 43
+
+
+# GT_COLON1 -- Interpret colon commands.
+
+procedure gt_colon1 (cmdstr, gp, gt, newgraph)
+
+char cmdstr[ARB] # Command string
+pointer gp # GIO pointer
+pointer gt # GTOOLS pointer
+int newgraph # Update graph?
+
+bool bval
+real rval[12]
+pointer sp, cmd
+int ncmd, btoi(), nscan(), strdic()
+
+begin
+ # All GTOOLS commands start with '/'.
+ if (cmdstr[1] != '/')
+ return
+
+ # Parse the command string matched against a dictionary.
+ call smark (sp)
+ call salloc (cmd, SZ_LINE, TY_CHAR)
+
+ call sscan (cmdstr[2])
+ call gargwrd (Memc[cmd], SZ_LINE)
+ ncmd = strdic (Memc[cmd], Memc[cmd], SZ_LINE, CMDS1)
+
+ # Get arguments and return if there are insufficient arguments.
+ if (ncmd < DRAWAXES) {
+ call gargr (rval[1])
+ if (nscan() != 2) {
+ call sfree (sp)
+ return
+ }
+ } else if (ncmd < AXES) {
+ switch (ncmd) {
+ case DRAWAXES:
+ call gargwrd (Memc[cmd], SZ_LINE)
+ rval[1] = strdic (Memc[cmd], Memc[cmd], SZ_LINE, GT_XAXES)
+ call gargwrd (Memc[cmd], SZ_LINE)
+ rval[2] = strdic (Memc[cmd], Memc[cmd], SZ_LINE, GT_YAXES)
+ case DRAWGRID, ROUND, LABELAXIS, DRAWTICKS, LABELTICKS:
+ call gargb (bval)
+ rval[1] = btoi (bval)
+ call gargb (bval)
+ rval[2] = btoi (bval)
+ default:
+ call gargr (rval[1])
+ call gargr (rval[2])
+ }
+ if (nscan() != 3) {
+ call sfree (sp)
+ return
+ }
+ }
+
+ # Switch on the command and parse the arguments.
+ switch (ncmd) {
+ case TXUP:
+ Memi[gt+GT_TXUP] = nint (rval[1])
+ case TXSIZE:
+ Memr[P2R(gt+GT_TXSIZE)] = rval[1]
+ case TXPATH:
+ Memi[gt+GT_TXPATH] = nint (rval[1])
+ case TXSPACING:
+ Memr[P2R(gt+GT_TXSPACING)] = rval[1]
+ case TXHJUSTIFY:
+ Memi[gt+GT_TXHJUSTIFY] = nint (rval[1])
+ case TXVJUSTIFY:
+ Memi[gt+GT_TXVJUSTIFY] = nint (rval[1])
+ case TXFONT:
+ Memi[gt+GT_TXFONT] = nint (rval[1])
+ case TXQUALITY:
+ Memi[gt+GT_TXQUALITY] = nint (rval[1])
+ case TXCOLOR:
+ Memi[gt+GT_TXCOLOR] = nint (rval[1])
+
+ case DRAWTITLE:
+ Memi[gt+GT_DRAWTITLE] = nint (rval[1])
+ case TITLESIZE:
+ Memr[P2R(gt+GT_TITLESIZE)] = rval[1]
+ case TITLEJUST:
+ Memi[gt+GT_TITLEJUST] = nint (rval[1])
+ case NTITLELINES:
+ Memi[gt+GT_NTITLELINES] = nint (rval[1])
+ case ASPECT:
+ Memr[P2R(gt+GT_ASPECT)] = rval[1]
+ case CHARSIZE:
+ Memr[P2R(gt+GT_CHARSIZE)] = rval[1]
+ case TITLECOLOR:
+ Memi[gt+GT_TITLECOLOR] = nint (rval[1])
+ case FRAMECOLOR:
+ Memi[gt+GT_FRAMECOLOR] = nint (rval[1])
+
+ case DRAWAXES:
+ if (rval[1] > 0)
+ Memi[gt+GT_XDRAWAXES] = nint (rval[1]) - 1
+ if (rval[2] > 0)
+ Memi[gt+GT_YDRAWAXES] = nint (rval[2]) - 1
+ case SETAXISPOS:
+ Memi[gt+GT_XSETAXISPOS] = nint (rval[1])
+ Memi[gt+GT_YSETAXISPOS] = nint (rval[2])
+ case AXISPOS1:
+ Memr[P2R(gt+GT_XAXISPOS1)] = rval[1]
+ Memr[P2R(gt+GT_YAXISPOS1)] = rval[2]
+ case AXISPOS2:
+ Memr[P2R(gt+GT_XAXISPOS2)] = rval[1]
+ Memr[P2R(gt+GT_YAXISPOS2)] = rval[2]
+ case DRAWGRID:
+ Memi[gt+GT_XDRAWGRID] = nint (rval[1])
+ Memi[gt+GT_YDRAWGRID] = nint (rval[2])
+ case ROUND:
+ Memi[gt+GT_XROUND] = nint (rval[1])
+ Memi[gt+GT_YROUND] = nint (rval[2])
+ case LABELAXIS:
+ Memi[gt+GT_XLABELAXIS] = nint (rval[1])
+ Memi[gt+GT_YLABELAXIS] = nint (rval[2])
+ case AXISLABELSIZE:
+ Memr[P2R(gt+GT_XAXISLABELSIZE)] = rval[1]
+ Memr[P2R(gt+GT_YAXISLABELSIZE)] = rval[2]
+ case DRAWTICKS:
+ Memi[gt+GT_XDRAWTICKS] = nint (rval[1])
+ Memi[gt+GT_YDRAWTICKS] = nint (rval[2])
+ case LABELTICKS:
+ Memi[gt+GT_XLABELTICKS] = nint (rval[1])
+ Memi[gt+GT_YLABELTICKS] = nint (rval[2])
+ case NMAJOR:
+ Memi[gt+GT_XNMAJOR] = nint (rval[1])
+ Memi[gt+GT_YNMAJOR] = nint (rval[2])
+ case NMINOR:
+ Memi[gt+GT_XNMINOR] = nint (rval[1])
+ Memi[gt+GT_YNMINOR] = nint (rval[2])
+ case MAJORLENGTH:
+ Memr[P2R(gt+GT_XMAJORLENGTH)] = rval[1]
+ Memr[P2R(gt+GT_YMAJORLENGTH)] = rval[2]
+ case MINORLENGTH:
+ Memr[P2R(gt+GT_XMINORLENGTH)] = rval[1]
+ Memr[P2R(gt+GT_YMINORLENGTH)] = rval[2]
+ case MAJORWIDTH:
+ Memr[P2R(gt+GT_XMAJORWIDTH)] = rval[1]
+ Memr[P2R(gt+GT_YMAJORWIDTH)] = rval[2]
+ case MINORWIDTH:
+ Memr[P2R(gt+GT_XMINORWIDTH)] = rval[1]
+ Memr[P2R(gt+GT_YMINORWIDTH)] = rval[2]
+ case AXISWIDTH:
+ Memr[P2R(gt+GT_XAXISWIDTH)] = rval[1]
+ Memr[P2R(gt+GT_YAXISWIDTH)] = rval[2]
+ case TICKLABELSIZE:
+ Memr[P2R(gt+GT_XTICKLABELSIZE)] = rval[1]
+ Memr[P2R(gt+GT_YTICKLABELSIZE)] = rval[2]
+ case GRIDCOLOR:
+ Memi[gt+GT_XGRIDCOLOR] = nint (rval[1])
+ Memi[gt+GT_YGRIDCOLOR] = nint (rval[2])
+ case AXISLABELCOLOR:
+ Memi[gt+GT_XAXISLABELCOLOR] = nint (rval[1])
+ Memi[gt+GT_YAXISLABELCOLOR] = nint (rval[2])
+ case AXISCOLOR:
+ Memi[gt+GT_XAXISCOLOR] = nint (rval[1])
+ Memi[gt+GT_YAXISCOLOR] = nint (rval[2])
+ case TICKLABELCOLOR:
+ Memi[gt+GT_XTICKLABELCOLOR] = nint (rval[1])
+ Memi[gt+GT_YTICKLABELCOLOR] = nint (rval[2])
+ case TICKCOLOR:
+ Memi[gt+GT_XTICKCOLOR] = nint (rval[1])
+ Memi[gt+GT_YTICKCOLOR] = nint (rval[2])
+
+ case AXES:
+ call gargwrd (Memc[cmd], SZ_LINE)
+ rval[1] = strdic (Memc[cmd], Memc[cmd], SZ_LINE, GT_XAXES)
+ call gargr (rval[2])
+ call gargb (bval)
+ rval[3] = btoi (bval)
+ call gargwrd (Memc[cmd], SZ_LINE)
+ rval[4] = strdic (Memc[cmd], Memc[cmd], SZ_LINE, GT_XAXES)
+ call gargr (rval[5])
+ call gargb (bval)
+ rval[6] = btoi (bval)
+ if (nscan() == 7) {
+ Memi[gt+GT_XDRAWAXES] = nint (rval[1])
+ Memr[P2R(gt+GT_XAXISWIDTH)] = rval[2]
+ Memr[P2R(gt+GT_XMAJORWIDTH)] = rval[2]
+ Memr[P2R(gt+GT_XMINORWIDTH)] = rval[2]
+ Memi[gt+GT_XDRAWGRID] = nint (rval[3])
+ Memi[gt+GT_YDRAWAXES] = nint (rval[4])
+ Memr[P2R(gt+GT_YAXISWIDTH)] = rval[5]
+ Memr[P2R(gt+GT_YMAJORWIDTH)] = rval[5]
+ Memr[P2R(gt+GT_YMINORWIDTH)] = rval[5]
+ Memi[gt+GT_YDRAWGRID] = nint (rval[6])
+ }
+ case TICKS:
+ call gargb (bval)
+ rval[1] = btoi (bval)
+ call gargb (bval)
+ rval[2] = btoi (bval)
+ call gargr (rval[3])
+ call gargr (rval[4])
+ call gargb (bval)
+ rval[5] = btoi (bval)
+ call gargb (bval)
+ rval[6] = btoi (bval)
+ call gargr (rval[7])
+ call gargr (rval[8])
+ if (nscan() == 9) {
+ Memi[gt+GT_XDRAWTICKS] = nint (rval[1])
+ Memi[gt+GT_XLABELTICKS] = nint (rval[2])
+ Memi[gt+GT_XNMAJOR] = nint (rval[3])
+ Memi[gt+GT_XNMINOR] = nint (rval[4])
+ Memi[gt+GT_YDRAWTICKS] = nint (rval[5])
+ Memi[gt+GT_YLABELTICKS] = nint (rval[6])
+ Memi[gt+GT_YNMAJOR] = nint (rval[7])
+ Memi[gt+GT_YNMINOR] = nint (rval[8])
+ }
+ case COLORS:
+ call gargr (rval[1])
+ call gargr (rval[2])
+ call gargr (rval[3])
+ call gargr (rval[4])
+ call gargr (rval[5])
+ call gargr (rval[6])
+ call gargr (rval[7])
+ call gargr (rval[8])
+ call gargr (rval[9])
+ call gargr (rval[10])
+ call gargr (rval[11])
+ call gargr (rval[12])
+ if (nscan() == 13) {
+ Memi[gt+GT_FRAMECOLOR] = nint (rval[1])
+ Memi[gt+GT_TITLECOLOR] = nint (rval[2])
+ Memi[gt+GT_XGRIDCOLOR] = nint (rval[3])
+ Memi[gt+GT_XAXISLABELCOLOR] = nint (rval[4])
+ Memi[gt+GT_XAXISCOLOR] = nint (rval[5])
+ Memi[gt+GT_XTICKLABELCOLOR] = nint (rval[6])
+ Memi[gt+GT_XTICKCOLOR] = nint (rval[7])
+ Memi[gt+GT_YGRIDCOLOR] = nint (rval[8])
+ Memi[gt+GT_YAXISLABELCOLOR] = nint (rval[9])
+ Memi[gt+GT_YAXISCOLOR] = nint (rval[10])
+ Memi[gt+GT_YTICKLABELCOLOR] = nint (rval[11])
+ Memi[gt+GT_YTICKCOLOR] = nint (rval[12])
+ }
+ }
+
+ call sfree (sp)
+end
diff --git a/pkg/xtools/gtools/gtcopy.x b/pkg/xtools/gtools/gtcopy.x
new file mode 100644
index 00000000..5c79da9e
--- /dev/null
+++ b/pkg/xtools/gtools/gtcopy.x
@@ -0,0 +1,85 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include "gtools.h"
+
+# GT_COPY -- Copy values of one structure to another.
+
+procedure gt_copy (gt1, gt2)
+
+pointer gt1, gt2
+
+int len, strlen()
+pointer gt_init()
+
+begin
+ if (gt1 == NULL)
+ call error (0, "gt_copy: Undefined gtools structure")
+
+ if (gt2 == NULL)
+ gt2 = gt_init ()
+ else {
+ call mfree (GT_PARAMS(gt2), TY_CHAR)
+ call mfree (GT_TITLE(gt2), TY_CHAR)
+ call mfree (GT_SUBTITLE(gt2), TY_CHAR)
+ call mfree (GT_COMMENTS(gt2), TY_CHAR)
+ call mfree (GT_XLABEL(gt2), TY_CHAR)
+ call mfree (GT_YLABEL(gt2), TY_CHAR)
+ call mfree (GT_XUNITS(gt2), TY_CHAR)
+ call mfree (GT_YUNITS(gt2), TY_CHAR)
+ call mfree (GT_XFORMAT(gt2), TY_CHAR)
+ call mfree (GT_YFORMAT(gt2), TY_CHAR)
+ }
+
+ call amovi (Memi[gt1], Memi[gt2], LEN_GT)
+
+ if (GT_PARAMS(gt1) != NULL) {
+ len = strlen (Memc[GT_PARAMS(gt1)])
+ call malloc (GT_PARAMS(gt2), len, TY_CHAR)
+ call strcpy (Memc[GT_PARAMS(gt1)], Memc[GT_PARAMS(gt2)], len)
+ }
+ if (GT_TITLE(gt1) != NULL) {
+ len = strlen (Memc[GT_TITLE(gt1)])
+ call malloc (GT_TITLE(gt2), len, TY_CHAR)
+ call strcpy (Memc[GT_TITLE(gt1)], Memc[GT_TITLE(gt2)], len)
+ }
+ if (GT_SUBTITLE(gt1) != NULL) {
+ len = strlen (Memc[GT_SUBTITLE(gt1)])
+ call malloc (GT_SUBTITLE(gt2), len, TY_CHAR)
+ call strcpy (Memc[GT_SUBTITLE(gt1)], Memc[GT_SUBTITLE(gt2)], len)
+ }
+ if (GT_COMMENTS(gt1) != NULL) {
+ len = strlen (Memc[GT_COMMENTS(gt1)])
+ call malloc (GT_COMMENTS(gt2), len, TY_CHAR)
+ call strcpy (Memc[GT_COMMENTS(gt1)], Memc[GT_COMMENTS(gt2)], len)
+ }
+ if (GT_XLABEL(gt1) != NULL) {
+ len = strlen (Memc[GT_XLABEL(gt1)])
+ call malloc (GT_XLABEL(gt2), len, TY_CHAR)
+ call strcpy (Memc[GT_XLABEL(gt1)], Memc[GT_XLABEL(gt2)], len)
+ }
+ if (GT_YLABEL(gt1) != NULL) {
+ len = strlen (Memc[GT_YLABEL(gt1)])
+ call malloc (GT_YLABEL(gt2), len, TY_CHAR)
+ call strcpy (Memc[GT_YLABEL(gt1)], Memc[GT_YLABEL(gt2)], len)
+ }
+ if (GT_XUNITS(gt1) != NULL) {
+ len = strlen (Memc[GT_XUNITS(gt1)])
+ call malloc (GT_XUNITS(gt2), len, TY_CHAR)
+ call strcpy (Memc[GT_XUNITS(gt1)], Memc[GT_XUNITS(gt2)], len)
+ }
+ if (GT_YUNITS(gt1) != NULL) {
+ len = strlen (Memc[GT_YUNITS(gt1)])
+ call malloc (GT_YUNITS(gt2), len, TY_CHAR)
+ call strcpy (Memc[GT_YUNITS(gt1)], Memc[GT_YUNITS(gt2)], len)
+ }
+ if (GT_XFORMAT(gt1) != NULL) {
+ len = strlen (Memc[GT_XFORMAT(gt1)])
+ call malloc (GT_XFORMAT(gt2), len, TY_CHAR)
+ call strcpy (Memc[GT_XFORMAT(gt1)], Memc[GT_XFORMAT(gt2)], len)
+ }
+ if (GT_YFORMAT(gt1) != NULL) {
+ len = strlen (Memc[GT_YFORMAT(gt1)])
+ call malloc (GT_YFORMAT(gt2), len, TY_CHAR)
+ call strcpy (Memc[GT_YFORMAT(gt1)], Memc[GT_YFORMAT(gt2)], len)
+ }
+end
diff --git a/pkg/xtools/gtools/gtctran.x b/pkg/xtools/gtools/gtctran.x
new file mode 100644
index 00000000..1b62688f
--- /dev/null
+++ b/pkg/xtools/gtools/gtctran.x
@@ -0,0 +1,34 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+# GT_XCTRAN -- Transform x between two WCS. Return new value as a function.
+
+real procedure gt_xctran (gp, x1, wcs1, wcs2)
+
+pointer gp # GIO pointer
+real x1 # X value to be transformed
+int wcs1 # Input WCS
+int wcs2 # Output WCS
+
+real x2, y2
+
+begin
+ call gctran (gp, x1, 0., x2, y2, wcs1, wcs2)
+ return (x2)
+end
+
+
+# GT_YCTRAN -- Transform y between two WCS. Return new value as a function.
+
+real procedure gt_yctran (gp, y1, wcs1, wcs2)
+
+pointer gp # GIO pointer
+real y1 # Y value to be transformed
+int wcs1 # Input WCS
+int wcs2 # Output WCS
+
+real x2, y2
+
+begin
+ call gctran (gp, 0., y1, x2, y2, wcs1, wcs2)
+ return (y2)
+end
diff --git a/pkg/xtools/gtools/gtcur.x b/pkg/xtools/gtools/gtcur.x
new file mode 100644
index 00000000..7103bf9c
--- /dev/null
+++ b/pkg/xtools/gtools/gtcur.x
@@ -0,0 +1,21 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+# GT_GCUR -- Interface to clgcur to confirm EOF, map key 'q' to EOF.
+
+int procedure gt_gcur (cur, wx, wy, wcs, key, cmd, sz_cmd)
+
+char cur[ARB] # Cursor parameter
+real wx, wy # Cursor position
+int wcs, key # WCS and cursor key
+char cmd[sz_cmd] # Command string
+int sz_cmd # Size of command string
+
+int curval, clgcur()
+
+begin
+ curval = clgcur (cur, wx, wy, wcs, key, cmd, sz_cmd)
+ if (key == 'q')
+ curval = EOF
+
+ return (curval)
+end
diff --git a/pkg/xtools/gtools/gtcur1.x b/pkg/xtools/gtools/gtcur1.x
new file mode 100644
index 00000000..edb42299
--- /dev/null
+++ b/pkg/xtools/gtools/gtcur1.x
@@ -0,0 +1,38 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include "gtools.h"
+
+# GT_GCUR1 -- Interface to clgcur to confirm EOF, map key 'q' to EOF.
+# Transposes X and Y if needed.
+
+int procedure gt_gcur1 (gt, cur, wx, wy, wcs, key, cmd, sz_cmd)
+
+pointer gt # GTOOLS pointer
+char cur[ARB] # Cursor parameter
+real wx, wy # Cursor position
+int wcs, key # WCS and cursor key
+char cmd[sz_cmd] # Command string
+int sz_cmd # Size of command string
+
+int curval, clgcur()
+real temp
+
+begin
+ curval = clgcur (cur, wx, wy, wcs, key, cmd, sz_cmd)
+
+ if (curval == EOF) {
+ curval = clgcur (cur, wx, wy, wcs, key, cmd, sz_cmd)
+ if (curval != EOF) {
+ if (key == 'q')
+ curval = EOF
+ }
+ } else if (key == 'q')
+ curval = EOF
+
+ if (GT_TRANSPOSE(gt) == YES) {
+ temp = wx
+ wx = wy
+ wy = temp
+ }
+ return (curval)
+end
diff --git a/pkg/xtools/gtools/gtfree.x b/pkg/xtools/gtools/gtfree.x
new file mode 100644
index 00000000..da4bec03
--- /dev/null
+++ b/pkg/xtools/gtools/gtfree.x
@@ -0,0 +1,26 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include "gtools.h"
+
+# GT_FREE -- Free extended graphics tools structure.
+
+procedure gt_free (gt)
+
+pointer gt # Graphic tools pointer
+
+begin
+ if (gt == NULL)
+ return
+
+ call mfree (GT_PARAMS(gt), TY_CHAR)
+ call mfree (GT_TITLE(gt), TY_CHAR)
+ call mfree (GT_SUBTITLE(gt), TY_CHAR)
+ call mfree (GT_COMMENTS(gt), TY_CHAR)
+ call mfree (GT_XLABEL(gt), TY_CHAR)
+ call mfree (GT_YLABEL(gt), TY_CHAR)
+ call mfree (GT_XUNITS(gt), TY_CHAR)
+ call mfree (GT_YUNITS(gt), TY_CHAR)
+ call mfree (GT_XFORMAT(gt), TY_CHAR)
+ call mfree (GT_YFORMAT(gt), TY_CHAR)
+ call mfree (gt, TY_STRUCT)
+end
diff --git a/pkg/xtools/gtools/gtget.x b/pkg/xtools/gtools/gtget.x
new file mode 100644
index 00000000..8274dab9
--- /dev/null
+++ b/pkg/xtools/gtools/gtget.x
@@ -0,0 +1,210 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <gset.h>
+include "gtools.h"
+
+# GT_GETI -- Set integer parameters.
+
+int procedure gt_geti (gt, param)
+
+pointer gt # GTOOLS pointer
+int param # Parameter to set
+
+begin
+ switch (param) {
+ case GTLINE:
+ return (GT_LINE(gt))
+ case GTTRANSPOSE:
+ return (GT_TRANSPOSE(gt))
+ case GTSYSID:
+ return (GT_SYSID(gt))
+ case GTCOLOR:
+ return (GT_COLOR(gt))
+ case GTXFLIP:
+ return (GT_XFLIP(gt))
+ case GTYFLIP:
+ return (GT_YFLIP(gt))
+ case GTDRAWTITLE:
+ return (GT_DRWTITLE(gt))
+ case GTDRAWXLABELS:
+ return (GT_DRWXLABELS(gt))
+ case GTDRAWYLABELS:
+ return (GT_DRWYLABELS(gt))
+ }
+end
+
+
+# GT_GETR -- Set real parameters.
+
+real procedure gt_getr (gt, param)
+
+pointer gt # GTOOLS pointer
+int param # Parameter to set
+
+begin
+ switch (param) {
+ case GTVXMIN:
+ return (GT_VXMIN(gt))
+ case GTVXMAX:
+ return (GT_VXMAX(gt))
+ case GTVYMIN:
+ return (GT_VYMIN(gt))
+ case GTVYMAX:
+ return (GT_VYMAX(gt))
+ case GTXMIN:
+ if (GT_XFLIP(gt) == NO)
+ return (GT_XMIN(gt))
+ else
+ return (GT_XMAX(gt))
+ case GTXMAX:
+ if (GT_XFLIP(gt) == NO)
+ return (GT_XMAX(gt))
+ else
+ return (GT_XMIN(gt))
+ case GTYMIN:
+ if (GT_YFLIP(gt) == NO)
+ return (GT_YMIN(gt))
+ else
+ return (GT_YMAX(gt))
+ case GTYMAX:
+ if (GT_YFLIP(gt) == NO)
+ return (GT_YMAX(gt))
+ else
+ return (GT_YMIN(gt))
+ case GTXBUF:
+ return (GT_XBUF(gt))
+ case GTYBUF:
+ return (GT_YBUF(gt))
+ case GTLCLIP:
+ return (GT_LCLIP(gt))
+ case GTHCLIP:
+ return (GT_HCLIP(gt))
+ case GTXSIZE:
+ return (GT_XSIZE(gt))
+ case GTYSIZE:
+ return (GT_YSIZE(gt))
+ }
+end
+
+
+# GT_GETS -- Get string parameters.
+
+procedure gt_gets (gt, param, str, sz_str)
+
+pointer gt # GTOOLS pointer
+int param # Parameter to set
+char str[sz_str] # String
+int sz_str # Size of string
+
+begin
+ str[1] = EOS
+ switch (param) {
+ case GTPARAMS:
+ if (GT_PARAMS(gt) != NULL)
+ call strcpy (Memc[GT_PARAMS(gt)], str, sz_str)
+ case GTTITLE:
+ if (GT_TITLE(gt) != NULL)
+ call strcpy (Memc[GT_TITLE(gt)], str, sz_str)
+ case GTSUBTITLE:
+ if (GT_SUBTITLE(gt) != NULL)
+ call strcpy (Memc[GT_SUBTITLE(gt)], str, sz_str)
+ case GTCOMMENTS:
+ if (GT_COMMENTS(gt) != NULL)
+ call strcpy (Memc[GT_COMMENTS(gt)], str, sz_str)
+ case GTXLABEL:
+ if (GT_XLABEL(gt) != NULL)
+ call strcpy (Memc[GT_XLABEL(gt)], str, sz_str)
+ case GTYLABEL:
+ if (GT_YLABEL(gt) != NULL)
+ call strcpy (Memc[GT_YLABEL(gt)], str, sz_str)
+ case GTXUNITS:
+ if (GT_XUNITS(gt) != NULL)
+ call strcpy (Memc[GT_XUNITS(gt)], str, sz_str)
+ case GTYUNITS:
+ if (GT_YUNITS(gt) != NULL)
+ call strcpy (Memc[GT_YUNITS(gt)], str, sz_str)
+ case GTXFORMAT:
+ if (GT_XFORMAT(gt) != NULL)
+ call strcpy (Memc[GT_XFORMAT(gt)], str, sz_str)
+ case GTYFORMAT:
+ if (GT_YFORMAT(gt) != NULL)
+ call strcpy (Memc[GT_YFORMAT(gt)], str, sz_str)
+ case GTXTRAN:
+ switch (GT_XTRAN(gt)) {
+ case GW_LINEAR:
+ call strcpy ("linear", str, sz_str)
+ case GW_ELOG:
+ call strcpy ("logarithmic", str, sz_str)
+ }
+ case GTYTRAN:
+ switch (GT_YTRAN(gt)) {
+ case GW_LINEAR:
+ call strcpy ("linear", str, sz_str)
+ case GW_ELOG:
+ call strcpy ("logarithmic", str, sz_str)
+ }
+ case GTTYPE:
+ #switch (GT_TYPE(gt)) {
+ #case 1:
+ # call strcpy ("mark", str, sz_str)
+ #case 2:
+ # call strcpy ("line", str, sz_str)
+ #case 3:
+ # call strcpy ("histogram", str, sz_str)
+ #}
+ switch (GT_TYPE(gt)) {
+ case 1:
+ switch (GT_MARK(gt)) {
+ case GM_POINT:
+ call strcpy ("point", str, sz_str)
+ case GM_BOX:
+ call strcpy ("box", str, sz_str)
+ case GM_PLUS:
+ call strcpy ("plus", str, sz_str)
+ case GM_CROSS:
+ call strcpy ("cross", str, sz_str)
+ case GM_DIAMOND:
+ call strcpy ("diamond", str, sz_str)
+ case GM_HLINE:
+ call strcpy ("hline", str, sz_str)
+ case GM_VLINE:
+ call strcpy ("vline", str, sz_str)
+ case GM_HEBAR:
+ call strcpy ("hebar", str, sz_str)
+ case GM_VEBAR:
+ call strcpy ("vebar", str, sz_str)
+ case GM_CIRCLE:
+ call strcpy ("circle", str, sz_str)
+ }
+ case 2:
+ call sprintf (str, sz_str, "line%d")
+ call pargi (GT_LINE(gt))
+ case 3:
+ call sprintf (str, sz_str, "hist%d")
+ call pargi (GT_LINE(gt))
+ }
+ case GTMARK:
+ switch (GT_MARK(gt)) {
+ case GM_POINT:
+ call strcpy ("point", str, sz_str)
+ case GM_BOX:
+ call strcpy ("box", str, sz_str)
+ case GM_PLUS:
+ call strcpy ("plus", str, sz_str)
+ case GM_CROSS:
+ call strcpy ("cross", str, sz_str)
+ case GM_DIAMOND:
+ call strcpy ("diamond", str, sz_str)
+ case GM_HLINE:
+ call strcpy ("hline", str, sz_str)
+ case GM_VLINE:
+ call strcpy ("vline", str, sz_str)
+ case GM_HEBAR:
+ call strcpy ("hebar", str, sz_str)
+ case GM_VEBAR:
+ call strcpy ("vebar", str, sz_str)
+ case GM_CIRCLE:
+ call strcpy ("circle", str, sz_str)
+ }
+ }
+end
diff --git a/pkg/xtools/gtools/gtgui.x b/pkg/xtools/gtools/gtgui.x
new file mode 100644
index 00000000..16981ee3
--- /dev/null
+++ b/pkg/xtools/gtools/gtgui.x
@@ -0,0 +1,160 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <gset.h>
+include "gtools.h"
+
+# GT_UIVALUES -- Send UI parameters values.
+
+procedure gt_uivalues (gp, gt)
+
+pointer gp # GIO pointer
+pointer gt # GTOOLS pointer
+
+int fd, stropen()
+pointer sp, msg, str1, str2
+
+begin
+ if (gt == NULL)
+ return
+
+ call smark (sp)
+ call salloc (msg, 20 * SZ_LINE, TY_CHAR)
+ call salloc (str1, SZ_LINE, TY_CHAR)
+ call salloc (str2, SZ_LINE, TY_CHAR)
+
+ fd = stropen (Memc[msg], 20 * SZ_LINE, WRITE_ONLY)
+
+ # SysID
+ call fprintf (fd, "%b ")
+ call pargi (GT_SYSID(gt))
+
+ # Titles
+ call fprintf (fd, "\"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" ")
+ if (GT_TITLE(gt) == NULL)
+ call pargstr ("")
+ else
+ call pargstr (Memc[GT_TITLE(gt)])
+ if (GT_SUBTITLE(gt) == NULL)
+ call pargstr ("")
+ else
+ call pargstr (Memc[GT_SUBTITLE(gt)])
+ if (GT_XLABEL(gt) == NULL)
+ call pargstr ("")
+ else
+ call pargstr (Memc[GT_XLABEL(gt)])
+ if (GT_XUNITS(gt) == NULL)
+ call pargstr ("")
+ else
+ call pargstr (Memc[GT_XUNITS(gt)])
+ if (GT_YLABEL(gt) == NULL)
+ call pargstr ("")
+ else
+ call pargstr (Memc[GT_YLABEL(gt)])
+ if (GT_YUNITS(gt) == NULL)
+ call pargstr ("")
+ else
+ call pargstr (Memc[GT_YUNITS(gt)])
+
+ # Viewport
+ call fprintf (fd, "%4.2f %4.2f %4.2f %4.2f ")
+ call pargr (GT_VXMIN(gt))
+ call pargr (GT_VXMAX(gt))
+ call pargr (GT_VYMIN(gt))
+ call pargr (GT_VYMAX(gt))
+
+ # Window
+ call fprintf (fd, "%4.2f %4.2f %4.2f %4.2f ")
+ call pargr (GT_XMIN(gt))
+ call pargr (GT_XMAX(gt))
+ call pargr (GT_YMIN(gt))
+ call pargr (GT_YMAX(gt))
+
+ # Gtools
+ call fprintf (fd, "%b %b %b %4.2f %4.2f %g %g ")
+ call pargi (GT_TRANSPOSE(gt))
+ call pargi (GT_XFLIP(gt))
+ call pargi (GT_YFLIP(gt))
+ call pargr (GT_XBUF(gt))
+ call pargr (GT_YBUF(gt))
+ call pargr (GT_LCLIP(gt))
+ call pargr (GT_HCLIP(gt))
+
+ # Plot types
+ call gt_gets (gt, GTTYPE, Memc[str1], SZ_LINE)
+ call fprintf (fd, "%s %g %g %d ")
+ call pargstr (Memc[str1])
+ call pargr (GT_XSIZE(gt))
+ call pargr (GT_YSIZE(gt))
+ call pargi (GT_COLOR(gt))
+
+ # Axes
+ call gt_gets (gt, GTXTRAN, Memc[str1], SZ_LINE)
+ call gt_gets (gt, GTYTRAN, Memc[str2], SZ_LINE)
+ call fprintf (fd, "%s %s %g %g %s %s %b %b ")
+ switch (Memi[gt+GT_XDRAWAXES]) {
+ case 0:
+ call pargstr ("none")
+ case 1:
+ call pargstr ("bottom")
+ case 2:
+ call pargstr ("top")
+ case 3:
+ call pargstr ("both")
+ }
+ switch (Memi[gt+GT_YDRAWAXES]) {
+ case 0:
+ call pargstr ("none")
+ case 1:
+ call pargstr ("left")
+ case 2:
+ call pargstr ("right")
+ case 3:
+ call pargstr ("both")
+ }
+ call pargr (Memr[P2R(gt+GT_XAXISWIDTH)])
+ call pargr (Memr[P2R(gt+GT_YAXISWIDTH)])
+ call pargstr (Memc[str1])
+ call pargstr (Memc[str2])
+ call pargi (Memi[gt+GT_XDRAWGRID])
+ call pargi (Memi[gt+GT_YDRAWGRID])
+
+ # Ticks
+ call fprintf (fd, "%b %b %d %d %d %d %b %b \"%s\" \"%s\" ")
+ call pargi (Memi[gt+GT_XDRAWTICKS])
+ call pargi (Memi[gt+GT_YDRAWTICKS])
+ call pargi (Memi[gt+GT_XNMAJOR])
+ call pargi (Memi[gt+GT_YNMAJOR])
+ call pargi (Memi[gt+GT_XNMINOR])
+ call pargi (Memi[gt+GT_YNMINOR])
+ call pargi (Memi[gt+GT_XLABELTICKS])
+ call pargi (Memi[gt+GT_YLABELTICKS])
+ if (GT_XFORMAT(gt) == NULL)
+ call pargstr ("")
+ else
+ call pargstr (Memc[GT_XFORMAT(gt)])
+ if (GT_YFORMAT(gt) == NULL)
+ call pargstr ("")
+ else
+ call pargstr (Memc[GT_YFORMAT(gt)])
+
+ # Colors
+ call fprintf (fd, "%d %d %d %d %d %d %d %d %d %d %d %d %d")
+ call pargi (Memi[gt+GT_FRAMECOLOR])
+ call pargi (Memi[gt+GT_TITLECOLOR])
+ call pargi (Memi[gt+GT_XGRIDCOLOR])
+ call pargi (Memi[gt+GT_YGRIDCOLOR])
+ call pargi (Memi[gt+GT_XAXISLABELCOLOR])
+ call pargi (Memi[gt+GT_YAXISLABELCOLOR])
+ call pargi (Memi[gt+GT_XAXISCOLOR])
+ call pargi (Memi[gt+GT_YAXISCOLOR])
+ call pargi (Memi[gt+GT_XTICKLABELCOLOR])
+ call pargi (Memi[gt+GT_YTICKLABELCOLOR])
+ call pargi (Memi[gt+GT_XTICKCOLOR])
+ call pargi (Memi[gt+GT_YTICKCOLOR])
+ call pargi (Memi[gt+GT_TXCOLOR])
+
+ call strclose (fd)
+ call gmsg (gp, "gtvalues", Memc[msg])
+
+ call sfree (sp)
+end
diff --git a/pkg/xtools/gtools/gthelp.x b/pkg/xtools/gtools/gthelp.x
new file mode 100644
index 00000000..6267ced4
--- /dev/null
+++ b/pkg/xtools/gtools/gthelp.x
@@ -0,0 +1,12 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+# GT_HELP -- Page graphics help from a file.
+# This routine should not be called anymore.
+
+procedure gt_help (file)
+
+char file[ARB] # File to be paged
+
+begin
+ call pagefile (file, "")
+end
diff --git a/pkg/xtools/gtools/gtinit.x b/pkg/xtools/gtools/gtinit.x
new file mode 100644
index 00000000..11e0c5bb
--- /dev/null
+++ b/pkg/xtools/gtools/gtinit.x
@@ -0,0 +1,164 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <gset.h>
+include "gtools.h"
+
+# GT_INIT1 -- Open the GTOOLS pointer.
+
+pointer procedure gt_init1 (gp)
+
+pointer gp
+pointer gt
+
+pointer gt_init()
+errchk gt_init, gt_ireset
+
+begin
+ # Initialize the graphics.
+
+ gt = gt_init()
+ call gt_ireset (gp, gt)
+
+ return (gt)
+end
+
+
+# GT_INIT -- Allocate and initialize GTOOLS pointer.
+#
+# This is an older version. To properly set things either gt_ireset
+# should be called after gt_init or use the new gt_init1.
+
+pointer procedure gt_init ()
+
+pointer gt
+
+begin
+ # Initialize the graphics.
+
+ call calloc (gt, LEN_GT, TY_STRUCT)
+ GT_VXMIN(gt) = INDEFR
+ GT_VXMAX(gt) = INDEFR
+ GT_VYMIN(gt) = INDEFR
+ GT_VYMAX(gt) = INDEFR
+ GT_XMIN(gt) = INDEFR
+ GT_XMAX(gt) = INDEFR
+ GT_YMIN(gt) = INDEFR
+ GT_YMAX(gt) = INDEFR
+ call gt_sets (gt, GTXTRAN, "linear")
+ call gt_sets (gt, GTYTRAN, "linear")
+ GT_XSIZE(gt) = 2.
+ GT_YSIZE(gt) = 2.
+ GT_SYSID(gt) = YES
+ GT_PARAMS(gt) = NULL
+ GT_TITLE(gt) = NULL
+ GT_SUBTITLE(gt) = NULL
+ GT_COMMENTS(gt) = NULL
+ GT_XLABEL(gt) = NULL
+ GT_YLABEL(gt) = NULL
+ GT_XUNITS(gt) = NULL
+ GT_YUNITS(gt) = NULL
+ GT_DRWTITLE(gt) = YES
+ GT_DRWXLABELS(gt) = YES
+ GT_DRWYLABELS(gt) = YES
+ GT_XFORMAT(gt) = NULL
+ GT_YFORMAT(gt) = NULL
+ GT_XBUF(gt) = .03
+ GT_YBUF(gt) = .03
+ GT_LCLIP(gt) = 0.
+ GT_HCLIP(gt) = 0.
+ GT_XFLIP(gt) = NO
+ GT_YFLIP(gt) = NO
+ GT_TRANSPOSE(gt) = NO
+ call gt_sets (gt, GTTYPE, "mark")
+ call gt_sets (gt, GTMARK, "plus")
+ call gt_seti (gt, GTLINE, 1)
+ call gt_seti (gt, GTCOLOR, 1)
+
+ GT_RESET(gt) = NO
+
+ return (gt)
+end
+
+
+# GT_IRESET -- Initialize GTOOLS values from GP pointer.
+
+procedure gt_ireset (gp, gt)
+
+pointer gp #I GIO pointer
+pointer gt #I GTOOLS pointer
+
+int gstati()
+real gstatr()
+
+begin
+ Memi[gt+GT_TXUP] = gstati (gp, G_TXUP)
+ Memr[P2R(gt+GT_TXSIZE)] = gstatr (gp, G_TXSIZE)
+ Memi[gt+GT_TXPATH] = gstati (gp, G_TXPATH)
+ Memr[P2R(gt+GT_TXSPACING)] = gstatr (gp, G_TXSPACING)
+ Memi[gt+GT_TXHJUSTIFY] = gstati (gp, G_TXHJUSTIFY)
+ Memi[gt+GT_TXVJUSTIFY] = gstati (gp, G_TXVJUSTIFY)
+ Memi[gt+GT_TXFONT] = gstati (gp, G_TXFONT)
+ Memi[gt+GT_TXQUALITY] = gstati (gp, G_TXQUALITY)
+ Memi[gt+GT_TXCOLOR] = gstati (gp, G_TXCOLOR)
+
+ Memi[gt+GT_DRAWTITLE] = gstati (gp, G_DRAWTITLE)
+ Memr[P2R(gt+GT_TITLESIZE)] = gstatr (gp, G_TITLESIZE)
+ #Memi[gt+GT_TITLEJUST] = gstati (gp, G_TITLEJUST)
+ Memi[gt+GT_NTITLELINES] = gstati (gp, G_NTITLELINES)
+ Memr[P2R(gt+GT_ASPECT)] = gstatr (gp, G_ASPECT)
+ #Memr[P2R(gt+GT_CHARSIZE)] = gstatr (gp, G_CHARSIZE)
+ Memi[gt+GT_TITLECOLOR] = gstati (gp, G_TITLECOLOR)
+ Memi[gt+GT_FRAMECOLOR] = gstati (gp, G_FRAMECOLOR)
+
+ Memi[gt+GT_XDRAWAXES] = gstati (gp, G_XDRAWAXES)
+ Memi[gt+GT_XSETAXISPOS] = gstati (gp, G_XSETAXISPOS)
+ Memr[P2R(gt+GT_XAXISPOS1)] = gstatr (gp, G_XAXISPOS1)
+ Memr[P2R(gt+GT_XAXISPOS2)] = gstatr (gp, G_XAXISPOS2)
+ Memi[gt+GT_XDRAWGRID] = gstati (gp, G_YDRAWGRID)
+ Memi[gt+GT_XROUND] = gstati (gp, G_XROUND)
+ Memi[gt+GT_XLABELAXIS] = gstati (gp, G_XLABELAXIS)
+ Memr[P2R(gt+GT_XAXISLABELSIZE)] = gstatr (gp, G_XAXISLABELSIZE)
+ Memi[gt+GT_XDRAWTICKS] = gstati (gp, G_XDRAWTICKS)
+ Memi[gt+GT_XLABELTICKS] = gstati (gp, G_XLABELTICKS)
+ Memi[gt+GT_XNMAJOR] = gstati (gp, G_XNMAJOR)
+ #Memi[gt+GT_XNMINOR] = gstati (gp, G_XNMINOR)
+ Memi[gt+GT_XNMINOR] = 0
+ Memr[P2R(gt+GT_XMAJORLENGTH)] = gstatr (gp, G_XMAJORLENGTH)
+ Memr[P2R(gt+GT_XMINORLENGTH)] = gstatr (gp, G_XMINORLENGTH)
+ Memr[P2R(gt+GT_XMAJORWIDTH)] = gstatr (gp, G_XMAJORWIDTH)
+ Memr[P2R(gt+GT_XMINORWIDTH)] = gstatr (gp, G_XMINORWIDTH)
+ Memr[P2R(gt+GT_XAXISWIDTH)] = gstatr (gp, G_XAXISWIDTH)
+ Memr[P2R(gt+GT_XTICKLABELSIZE)] = gstatr (gp, G_XTICKLABELSIZE)
+ Memi[gt+GT_XGRIDCOLOR] = gstati (gp, G_XGRIDCOLOR)
+ Memi[gt+GT_XAXISLABELCOLOR] = gstati (gp, G_XAXISLABELCOLOR)
+ Memi[gt+GT_XAXISCOLOR] = gstati (gp, G_XAXISCOLOR)
+ Memi[gt+GT_XTICKLABELCOLOR] = gstati (gp, G_XTICKLABELCOLOR)
+ Memi[gt+GT_XTICKCOLOR] = gstati (gp, G_XTICKCOLOR)
+
+ Memi[gt+GT_YDRAWAXES] = gstati (gp, G_YDRAWAXES)
+ Memi[gt+GT_YSETAXISPOS] = gstati (gp, G_YSETAXISPOS)
+ Memr[P2R(gt+GT_YAXISPOS1)] = gstatr (gp, G_YAXISPOS1)
+ Memr[P2R(gt+GT_YAXISPOS2)] = gstatr (gp, G_YAXISPOS2)
+ Memi[gt+GT_YDRAWGRID] = gstati (gp, G_XDRAWGRID)
+ Memi[gt+GT_YROUND] = gstati (gp, G_YROUND)
+ Memi[gt+GT_YLABELAXIS] = gstati (gp, G_YLABELAXIS)
+ Memr[P2R(gt+GT_YAXISLABELSIZE)] = gstatr (gp, G_YAXISLABELSIZE)
+ Memi[gt+GT_YDRAWTICKS] = gstati (gp, G_YDRAWTICKS)
+ Memi[gt+GT_YLABELTICKS] = gstati (gp, G_YLABELTICKS)
+ Memi[gt+GT_YNMAJOR] = gstati (gp, G_YNMAJOR)
+ #Memi[gt+GT_YNMINOR] = gstati (gp, G_YNMINOR)
+ Memi[gt+GT_YNMINOR] = 0
+ Memr[P2R(gt+GT_YMAJORLENGTH)] = gstatr (gp, G_YMAJORLENGTH)
+ Memr[P2R(gt+GT_YMINORLENGTH)] = gstatr (gp, G_YMINORLENGTH)
+ Memr[P2R(gt+GT_YMAJORWIDTH)] = gstatr (gp, G_YMAJORWIDTH)
+ Memr[P2R(gt+GT_YMINORWIDTH)] = gstatr (gp, G_YMINORWIDTH)
+ Memr[P2R(gt+GT_YAXISWIDTH)] = gstatr (gp, G_YAXISWIDTH)
+ Memr[P2R(gt+GT_YTICKLABELSIZE)] = gstatr (gp, G_YTICKLABELSIZE)
+ Memi[gt+GT_YGRIDCOLOR] = gstati (gp, G_YGRIDCOLOR)
+ Memi[gt+GT_YAXISLABELCOLOR] = gstati (gp, G_YAXISLABELCOLOR)
+ Memi[gt+GT_YAXISCOLOR] = gstati (gp, G_YAXISCOLOR)
+ Memi[gt+GT_YTICKLABELCOLOR] = gstati (gp, G_YTICKLABELCOLOR)
+ Memi[gt+GT_YTICKCOLOR] = gstati (gp, G_YTICKCOLOR)
+
+ GT_RESET(gt) = YES
+end
diff --git a/pkg/xtools/gtools/gtlabax.x b/pkg/xtools/gtools/gtlabax.x
new file mode 100644
index 00000000..28f80367
--- /dev/null
+++ b/pkg/xtools/gtools/gtlabax.x
@@ -0,0 +1,139 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <ctype.h>
+include <gset.h>
+include <gio.h>
+include "gtools.h"
+
+# GT_LABAX -- Set graphics axis.
+
+procedure gt_labax (gp, gt)
+
+pointer gp # GIO pointer
+pointer gt # GTOOLS pointer
+
+int nl, len
+real vx1, vx2, vy1, vy2, wx1, wx2, wy1, wy2
+pointer title, xlabel, ylabel
+
+int strlen()
+
+begin
+ if (gt != NULL) {
+ call gt_reset (gp, gt)
+
+ call ggview (gp, vx1, vx2, vy1, vy2)
+ if (!IS_INDEF(GT_VXMIN(gt)))
+ vx1 = GT_VXMIN(gt)
+ if (!IS_INDEF(GT_VXMAX(gt)))
+ vx2 = GT_VXMAX(gt)
+ if (!IS_INDEF(GT_VYMIN(gt)))
+ vy1 = GT_VYMIN(gt)
+ if (!IS_INDEF(GT_VYMAX(gt)))
+ vy2 = GT_VYMAX(gt)
+ call gsview (gp, vx1, vx2, vy1, vy2)
+
+ call malloc (title, SZ_LINE, TY_CHAR)
+ len = SZ_LINE
+ Memc[title] = EOS
+ if (GT_DRWTITLE(gt) == YES) {
+ nl = NO
+ if (GT_SYSID(gt) == YES) {
+ call sysid (Memc[title], len)
+ len = len + strlen (Memc[title]) + 1
+ call realloc (title, len, TY_CHAR)
+ nl = YES
+ }
+ if (GT_PARAMS(gt) != NULL) {
+ len = len + strlen (Memc[GT_PARAMS(gt)]) + 1
+ call realloc (title, len, TY_CHAR)
+ if (nl == YES)
+ call strcat ("\n", Memc[title], len)
+ call strcat (Memc[GT_PARAMS(gt)], Memc[title], len)
+ nl = YES
+ }
+ if (GT_TITLE(gt) != NULL) {
+ len = len + strlen (Memc[GT_TITLE(gt)]) + 1
+ call realloc (title, len, TY_CHAR)
+ if (nl == YES)
+ call strcat ("\n", Memc[title], len)
+ call strcat (Memc[GT_TITLE(gt)], Memc[title], len)
+ nl = YES
+ }
+ if (GT_SUBTITLE(gt) != NULL) {
+ len = len + strlen (Memc[GT_SUBTITLE(gt)]) + 1
+ call realloc (title, len, TY_CHAR)
+ if (nl == YES)
+ call strcat ("\n", Memc[title], len)
+ call strcat (Memc[GT_SUBTITLE(gt)], Memc[title], len)
+ nl = YES
+ }
+ if (GT_COMMENTS(gt) != NULL) {
+ len = len + strlen (Memc[GT_COMMENTS(gt)]) + 1
+ call realloc (title, len, TY_CHAR)
+ if (nl == YES)
+ call strcat ("\n", Memc[title], len)
+ call strcat (Memc[GT_COMMENTS(gt)], Memc[title], len)
+ nl = YES
+ }
+ }
+
+ call malloc (xlabel, SZ_LINE, TY_CHAR)
+ Memc[xlabel] = EOS
+ if (GT_DRWXLABELS(gt) == YES) {
+ if (GT_XLABEL(gt) != NULL)
+ call strcat (Memc[GT_XLABEL(gt)], Memc[xlabel], SZ_LINE)
+ if (GT_XUNITS(gt) != NULL) {
+ call strcat (" (", Memc[xlabel], SZ_LINE)
+ call strcat (Memc[GT_XUNITS(gt)], Memc[xlabel], SZ_LINE)
+ call strcat (")", Memc[xlabel], SZ_LINE)
+ }
+ }
+ if (GT_XFORMAT(gt) != NULL)
+ call gsets (gp, G_XTICKFORMAT, Memc[GT_XFORMAT(gt)])
+
+ call malloc (ylabel, SZ_LINE, TY_CHAR)
+ Memc[ylabel] = EOS
+ if (GT_DRWYLABELS(gt) == YES) {
+ if (GT_YLABEL(gt) != NULL)
+ call strcat (Memc[GT_YLABEL(gt)], Memc[ylabel], SZ_LINE)
+ if (GT_YUNITS(gt) != NULL) {
+ call strcat (" (", Memc[ylabel], SZ_LINE)
+ call strcat (Memc[GT_YUNITS(gt)], Memc[ylabel], SZ_LINE)
+ call strcat (")", Memc[ylabel], SZ_LINE)
+ }
+ }
+ if (GT_YFORMAT(gt) != NULL)
+ call gsets (gp, G_YTICKFORMAT, Memc[GT_YFORMAT(gt)])
+
+ call gseti (gp, G_XNMINOR, Memi[gt+GT_XNMINOR])
+ call gseti (gp, G_YNMINOR, Memi[gt+GT_YNMINOR])
+ if (GT_TRANSPOSE(gt) == NO)
+ call glabax (gp, Memc[title], Memc[xlabel], Memc[ylabel])
+ else
+ call glabax (gp, Memc[title], Memc[ylabel], Memc[xlabel])
+
+ call ggview (gp, vx1, vx2, vy1, vy2)
+ call ggwind (gp, wx1, wx2, wy1, wy2)
+ call sprintf (Memc[title], SZ_LINE, "%g %g %g %g %g %g %g %g")
+ call pargr (vx1)
+ call pargr (vx2)
+ call pargr (vy1)
+ call pargr (vy2)
+ call pargr (wx1)
+ call pargr (wx2)
+ call pargr (wy1)
+ call pargr (wy2)
+ if (GP_UIFNAME(gp) != EOS)
+ call gmsg (gp, "gtwcs", Memc[title])
+
+ call mfree (title, TY_CHAR)
+ call mfree (xlabel, TY_CHAR)
+ call mfree (ylabel, TY_CHAR)
+ } else {
+ call gmftitle (gp, "UNTITLED")
+ call gseti (gp, G_XNMINOR, Memi[gt+GT_XNMINOR])
+ call gseti (gp, G_YNMINOR, Memi[gt+GT_YNMINOR])
+ call glabax (gp, "", "", "")
+ }
+end
diff --git a/pkg/xtools/gtools/gtools.h b/pkg/xtools/gtools/gtools.h
new file mode 100644
index 00000000..672510b5
--- /dev/null
+++ b/pkg/xtools/gtools/gtools.h
@@ -0,0 +1,168 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+# Public Definitions
+
+define GTVXMIN 0 # Viewport X minimum
+define GTVXMAX 1 # Viewport X maximum
+define GTVYMIN 2 # Viewport Y minimum
+define GTVYMAX 3 # Viewport Y maximum
+define GTXMIN 4 # WCS X minimum
+define GTXMAX 5 # WCS X maximum
+define GTYMIN 6 # WCS Y minimum
+define GTYMAX 7 # WCS Y maximum
+
+define GTSYSID 8 # Add SYSID?
+define GTPARAMS 9 # Graph parameters
+define GTTITLE 10 # Graph title
+define GTSUBTITLE 11 # Graph subtitle
+define GTCOMMENTS 12 # Comments
+define GTXLABEL 13 # X label
+define GTYLABEL 14 # Y label
+define GTXUNITS 15 # X units
+define GTYUNITS 16 # Y units
+
+define GTDRAWTITLE 17 # Draw title block?
+define GTDRAWXLABELS 18 # Draw x axis label block?
+define GTDRAWYLABELS 19 # Draw y axis label block?
+
+define GTTYPE 20 # Graph type
+define GTMARK 21 # Mark type
+define GTLINE 22 # Line type
+define GTXSIZE 23 # X Mark size
+define GTYSIZE 24 # Y Mark size
+define GTCOLOR 25 # Color
+
+define GTXTRAN 26 # WCS X transform
+define GTYTRAN 27 # WCS Y transform
+define GTXFLIP 28 # Flip X axis
+define GTYFLIP 29 # Flip Y axis
+define GTTRANSPOSE 30 # Transpose X and Y axes?
+
+define GTXFORMAT 31 # X format
+define GTYFORMAT 32 # Y format
+
+define GTXBUF 33 # Autoscaling buffer factor
+define GTYBUF 34 # Autoscaling buffer factor
+define GTLCLIP 35 # Low clipping factor
+define GTHCLIP 36 # High clipping factor
+
+# Private Definitions
+
+define GTRESET 37 # Initialized from GIO structure?
+
+define GT_TXUP 51 # Text parameters
+define GT_TXSIZE 52
+define GT_TXPATH 53
+define GT_TXSPACING 54
+define GT_TXHJUSTIFY 55
+define GT_TXVJUSTIFY 56
+define GT_TXFONT 57
+define GT_TXQUALITY 58
+define GT_TXCOLOR 59
+
+define GT_DRAWTITLE 60 # GLABAX, general parameters
+define GT_TITLESIZE 61
+define GT_TITLEJUST 62
+define GT_NTITLELINES 63
+define GT_ASPECT 64
+define GT_CHARSIZE 65
+define GT_TITLECOLOR 66
+define GT_FRAMECOLOR 67
+define GT_DRIDCOLOR 68
+
+define GT_XDRAWAXES 71 # GLABAX, x axis parameters
+define GT_XSETAXISPOS 72
+define GT_XAXISPOS1 73
+define GT_XAXISPOS2 74
+define GT_XDRAWGRID 75
+define GT_XROUND 76
+define GT_XLABELAXIS 77
+define GT_XAXISLABELSIZE 78
+define GT_XDRAWTICKS 79
+define GT_XLABELTICKS 80
+define GT_XNMAJOR 81
+define GT_XNMINOR 82
+define GT_XMAJORLENGTH 83
+define GT_XMINORLENGTH 84
+define GT_XMAJORWIDTH 85
+define GT_XMINORWIDTH 86
+define GT_XAXISWIDTH 87
+define GT_XTICKLABELSIZE 88
+define GT_XTICKFORMAT 89
+define GT_XGRIDCOLOR 90
+define GT_XAXISLABELCOLOR 91
+define GT_XAXISCOLOR 92
+define GT_XTICKLABELCOLOR 93
+define GT_XTICKCOLOR 94
+
+define GT_YDRAWAXES 101 # GLABAX, y axis parameters
+define GT_YSETAXISPOS 102
+define GT_YAXISPOS1 103
+define GT_YAXISPOS2 104
+define GT_YDRAWGRID 105
+define GT_YROUND 106
+define GT_YLABELAXIS 107
+define GT_YAXISLABELSIZE 108
+define GT_YDRAWTICKS 109
+define GT_YLABELTICKS 110
+define GT_YNMAJOR 111
+define GT_YNMINOR 112
+define GT_YMAJORLENGTH 113
+define GT_YMINORLENGTH 114
+define GT_YMAJORWIDTH 115
+define GT_YMINORWIDTH 116
+define GT_YAXISWIDTH 117
+define GT_YTICKLABELSIZE 118
+define GT_YTICKFORMAT 119
+define GT_YGRIDCOLOR 120
+define GT_YAXISLABELCOLOR 121
+define GT_YAXISCOLOR 122
+define GT_YTICKLABELCOLOR 123
+define GT_YTICKCOLOR 124
+
+define LEN_GT 125 # Length of graphics tools extension
+
+define GT_VXMIN Memr[P2R($1+GTVXMIN)]
+define GT_VXMAX Memr[P2R($1+GTVXMAX)]
+define GT_VYMIN Memr[P2R($1+GTVYMIN)]
+define GT_VYMAX Memr[P2R($1+GTVYMAX)]
+define GT_XMIN Memr[P2R($1+GTXMIN)]
+define GT_XMAX Memr[P2R($1+GTXMAX)]
+define GT_YMIN Memr[P2R($1+GTYMIN)]
+define GT_YMAX Memr[P2R($1+GTYMAX)]
+define GT_SYSID Memi[$1+GTSYSID]
+define GT_PARAMS Memi[$1+GTPARAMS]
+define GT_TITLE Memi[$1+GTTITLE]
+define GT_SUBTITLE Memi[$1+GTSUBTITLE]
+define GT_COMMENTS Memi[$1+GTCOMMENTS]
+define GT_XLABEL Memi[$1+GTXLABEL]
+define GT_YLABEL Memi[$1+GTYLABEL]
+define GT_XUNITS Memi[$1+GTXUNITS]
+define GT_YUNITS Memi[$1+GTYUNITS]
+define GT_DRWTITLE Memi[$1+GTDRAWTITLE]
+define GT_DRWXLABELS Memi[$1+GTDRAWXLABELS]
+define GT_DRWYLABELS Memi[$1+GTDRAWYLABELS]
+define GT_TYPE Memi[$1+GTTYPE]
+define GT_MARK Memi[$1+GTMARK]
+define GT_LINE Memi[$1+GTLINE]
+define GT_XSIZE Memr[P2R($1+GTXSIZE)]
+define GT_YSIZE Memr[P2R($1+GTYSIZE)]
+define GT_COLOR Memi[$1+GTCOLOR]
+define GT_XTRAN Memi[$1+GTXTRAN]
+define GT_YTRAN Memi[$1+GTYTRAN]
+define GT_XFLIP Memi[$1+GTXFLIP]
+define GT_YFLIP Memi[$1+GTYFLIP]
+define GT_TRANSPOSE Memi[$1+GTTRANSPOSE]
+define GT_XFORMAT Memi[$1+GTXFORMAT]
+define GT_YFORMAT Memi[$1+GTYFORMAT]
+define GT_XBUF Memr[P2R($1+GTXBUF)]
+define GT_YBUF Memr[P2R($1+GTYBUF)]
+define GT_LCLIP Memr[P2R($1+GTLCLIP)]
+define GT_HCLIP Memr[P2R($1+GTHCLIP)]
+define GT_RESET Memi[$1+GTRESET]
+
+define GTTYPES "|mark|line|histogram|"
+define GTMARKS "|point|box|plus|cross|diamond|hline|vline|hebar|vebar|circle|"
+
+define GT_XAXES "|none|bottom|top|both|"
+define GT_YAXES "|none|left|right|both|"
diff --git a/pkg/xtools/gtools/gtools.hd b/pkg/xtools/gtools/gtools.hd
new file mode 100644
index 00000000..bc88b47b
--- /dev/null
+++ b/pkg/xtools/gtools/gtools.hd
@@ -0,0 +1,3 @@
+# Help directory for the GTOOLS (graphics tools) package.
+
+revisions sys = Revisions
diff --git a/pkg/xtools/gtools/gtools.hlp b/pkg/xtools/gtools/gtools.hlp
new file mode 100644
index 00000000..43d5e3ab
--- /dev/null
+++ b/pkg/xtools/gtools/gtools.hlp
@@ -0,0 +1,91 @@
+.help gtools Apr96 xtools.gtools
+.ih
+NAME
+gtools -- Graphics tools
+.ih
+SYNOPSIS
+A number of application tasks use the graphics tools in the \fBgtools\fR
+package. The graphics tools control labeling and titling of graphs and
+interactive formatting. The user changes the defaults via colon commands
+and with cursor keys. The windowing options are usually entered with the
+'w' key from an application program but other keys may be used instead.
+Not all of the formatting options may be available in a particular
+application; for example the graph type and mark type options. Check the
+documentation for the application program. Some applications set the
+values every time the graph is redraw so any user changes will be
+overridden.
+
+The title block consists of a system identification banner, a parameter
+string, a title string, a subtitle string, and a comment string in
+that order. The \fIdrawtitle\fR parameter can be used to turn off all
+the title block. There are parameters to control each of the
+parts of the title block. The \fIsubtitle\fR and \fIcomments\fR
+parameters are rarely used by applications and so may be used to
+annotate graphs. The x and y labels consist of label and units strings.
+The \fIdrawxlabels\fR and \fIdrawylabels\fR parameters can be used to
+turn off both parts of the axis labels.
+.ih
+WINDOW COMMANDS
+The following keystroke cursor commands may be available in an application.
+
+.nf
+a Autoscale x and y axes
+b Set bottom edge of window
+c Center window at cursor position
+d Shift window down
+e Expand window (mark lower left and upper right of new window)
+f Flip x axis
+g Flip y axis
+j Set left edge of window
+k Set right edge of window
+l Shift window left
+m Autoscale x axis
+n Autoscale y axis
+p Pan x and y axes about cursor
+r Shift window right
+t Set top edge of window
+u Shift window up
+x Zoom x axis about cursor
+y Zoom y axis about cursor
+z Zoom x and y axes about cursor
+.fi
+.ih
+COLON COMMANDS
+.nf
+:/help Print help menu
+:/redraw Redraw the graph
+
+:/drawtitle [yes|no] Draw title block?
+:/sysid [yes|no] Include the standard IRAF user/date banner?
+:/parameters string Parameter string (usual set by application)
+:/title string Title
+:/subtitle string Subtitle
+:/comments string Comments
+
+:/type string Type of graph (line, hist, or mark)
+:/mark string Mark type (point, box, plus, cross, diamond,
+ hline, vline, hebar, vebar, circle)
+:/line [0-9] Line style
+:/color [0-9] Line or mark color
+
+:/drawxlabels [yes|no] Draw X axis label?
+:/xlabel string Label for X axis
+:/xunits string Units for X axis
+:/xsize size Size of marks along the X axis
+:/xtransform type X coordinate transform type (linear or logarithmic)
+:/xwindow x1 x2 X graph window (INDEF defaults to min or max)
+:/xflip [yes|no] Flip X axis
+
+:/drawylabels [yes|no] Draw Y axis label?
+:/ylabel string Label for Y axis
+:/yunits string Units for Y axis
+:/ysize size Size of marks along the Y axis
+:/ytransform type Y coordinate transform type (linear or logarithmic)
+:/ywindow y1 y2 Y graph window (INDEF defaults to min or max)
+:/yflip [yes|no] Flip Y axis
+
+:/transpose Transpose the graph axes
+
+Format changes do not take effect until the graph is redrawn.
+.fi
+.endhelp
diff --git a/pkg/xtools/gtools/gtplot.x b/pkg/xtools/gtools/gtplot.x
new file mode 100644
index 00000000..3591e6ab
--- /dev/null
+++ b/pkg/xtools/gtools/gtplot.x
@@ -0,0 +1,82 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <gset.h>
+include "gtools.h"
+
+# GT_GRAPH -- Plot polymarks or polypoints.
+
+procedure gt_plot (gp, gt, x, y, npts)
+
+pointer gp # GIO pointer
+pointer gt # GTOOLS pointer
+real x[npts] # Abscissas
+real y[npts] # Ordinates
+int npts # Number of points
+
+int i, color, pltype, gstati()
+real x1, x2
+
+begin
+ switch (GT_TYPE(gt)) {
+ case 1:
+ #color = gstati (gp, G_PMCOLOR)
+ #call gseti (gp, G_PMCOLOR, GT_COLOR(gt))
+ color = gstati (gp, G_PLCOLOR)
+ call gseti (gp, G_PLCOLOR, GT_COLOR(gt))
+ if (GT_TRANSPOSE(gt) == NO)
+ call gpmark (gp, x, y, npts, GT_MARK(gt), GT_XSIZE(gt),
+ GT_YSIZE(gt))
+ else
+ call gpmark (gp, y, x, npts, GT_MARK(gt), GT_YSIZE(gt),
+ GT_XSIZE(gt))
+ #call gseti (gp, G_PMCOLOR, color)
+ call gseti (gp, G_PLCOLOR, color)
+ case 2:
+ color = gstati (gp, G_PLCOLOR)
+ call gseti (gp, G_PLCOLOR, GT_COLOR(gt))
+ pltype = gstati (gp, G_PLTYPE)
+ call gseti (gp, G_PLTYPE, GT_LINE(gt))
+ if (GT_TRANSPOSE(gt) == NO)
+ call gpline (gp, x, y, npts)
+ else
+ call gpline (gp, y, x, npts)
+ call gseti (gp, G_PLTYPE, pltype)
+ call gseti (gp, G_PLCOLOR, color)
+ case 3:
+ color = gstati (gp, G_PLCOLOR)
+ call gseti (gp, G_PLCOLOR, GT_COLOR(gt))
+ pltype = gstati (gp, G_PLTYPE)
+ call gseti (gp, G_PLTYPE, GT_LINE(gt))
+ if (GT_TRANSPOSE(gt) == NO) {
+ x1 = x[1]
+ x2 = (x[1] + x[2]) / 2
+ call gline (gp, x1, y[1], x2, y[1])
+ do i = 2, npts - 1 {
+ x1 = x2
+ x2 = (x[i] + x[i+1]) / 2
+ call gline (gp, x1, y[i-1], x1, y[i])
+ call gline (gp, x1, y[i], x2 , y[i])
+ }
+ x1 = x2
+ x2 = x[npts]
+ call gline (gp, x1, y[i-1], x1, y[i])
+ call gline (gp, x1, y[i], x2 , y[i])
+ } else {
+ x1 = y[1]
+ x2 = (y[1] + y[2]) / 2
+ call gline (gp, x1, x[1], x2, x[1])
+ do i = 2, npts - 1 {
+ x1 = x2
+ x2 = (y[i] + y[i+1]) / 2
+ call gline (gp, x1, x[i-1], x1, x[i])
+ call gline (gp, x1, x[i], x2 , x[i])
+ }
+ x1 = x2
+ x2 = y[npts]
+ call gline (gp, x1, y[i-1], x1, y[i])
+ call gline (gp, x1, y[i], x2 , y[i])
+ }
+ call gseti (gp, G_PLTYPE, pltype)
+ call gseti (gp, G_PLCOLOR, color)
+ }
+end
diff --git a/pkg/xtools/gtools/gtreset.x b/pkg/xtools/gtools/gtreset.x
new file mode 100644
index 00000000..696db0cd
--- /dev/null
+++ b/pkg/xtools/gtools/gtreset.x
@@ -0,0 +1,83 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <gset.h>
+include "gtools.h"
+
+# GT_RESET -- Reset parameters after a gclear, greset, or gcancel.
+
+procedure gt_reset (gp, gt)
+
+pointer gp #I GIO pointer
+pointer gt #I GTOOLS pointer
+
+begin
+ if (GT_RESET(gt) == NO)
+ call gt_ireset (gp, gt)
+
+ call gseti (gp, G_TXUP, Memi[gt+GT_TXUP])
+ call gsetr (gp, G_TXSIZE, Memr[P2R(gt+GT_TXSIZE)])
+ call gseti (gp, G_TXPATH, Memi[gt+GT_TXPATH])
+ call gsetr (gp, G_TXSPACING, Memr[P2R(gt+GT_TXSPACING)])
+ call gseti (gp, G_TXHJUSTIFY, Memi[gt+GT_TXHJUSTIFY])
+ call gseti (gp, G_TXVJUSTIFY, Memi[gt+GT_TXVJUSTIFY])
+ call gseti (gp, G_TXFONT, Memi[gt+GT_TXFONT])
+ call gseti (gp, G_TXQUALITY, Memi[gt+GT_TXQUALITY])
+ call gseti (gp, G_TXCOLOR, Memi[gt+GT_TXCOLOR])
+
+ call gseti (gp, G_DRAWTITLE, Memi[gt+GT_DRAWTITLE])
+ call gsetr (gp, G_TITLESIZE, Memr[P2R(gt+GT_TITLESIZE)])
+ #call gseti (gp, G_TITLEJUST, Memi[gt+GT_TITLEJUST])
+ call gseti (gp, G_NTITLELINES, Memi[gt+GT_NTITLELINES])
+ call gsetr (gp, G_ASPECT, Memr[P2R(gt+GT_ASPECT)])
+ #call gsetr (gp, G_CHARSIZE, Memr[P2R(gt+GT_CHARSIZE)])
+ call gseti (gp, G_TITLECOLOR, Memi[gt+GT_TITLECOLOR])
+ call gseti (gp, G_FRAMECOLOR, Memi[gt+GT_FRAMECOLOR])
+
+ call gseti (gp, G_XDRAWAXES, Memi[gt+GT_XDRAWAXES])
+ call gseti (gp, G_XSETAXISPOS, Memi[gt+GT_XSETAXISPOS])
+ call gsetr (gp, G_XAXISPOS1, Memr[P2R(gt+GT_XAXISPOS1)])
+ call gsetr (gp, G_XAXISPOS2, Memr[P2R(gt+GT_XAXISPOS2)])
+ call gseti (gp, G_YDRAWGRID, Memi[gt+GT_XDRAWGRID])
+ call gseti (gp, G_XROUND, Memi[gt+GT_XROUND])
+ call gseti (gp, G_XLABELAXIS, Memi[gt+GT_XLABELAXIS])
+ call gsetr (gp, G_XAXISLABELSIZE, Memr[P2R(gt+GT_XAXISLABELSIZE)])
+ call gseti (gp, G_XDRAWTICKS, Memi[gt+GT_XDRAWTICKS])
+ call gseti (gp, G_XLABELTICKS, Memi[gt+GT_XLABELTICKS])
+ call gseti (gp, G_XNMAJOR, Memi[gt+GT_XNMAJOR])
+ call gseti (gp, G_XNMINOR, Memi[gt+GT_XNMINOR])
+ call gsetr (gp, G_XMAJORLENGTH, Memr[P2R(gt+GT_XMAJORLENGTH)])
+ call gsetr (gp, G_XMINORLENGTH, Memr[P2R(gt+GT_XMINORLENGTH)])
+ call gsetr (gp, G_XMAJORWIDTH, Memr[P2R(gt+GT_XMAJORWIDTH)])
+ call gsetr (gp, G_XMINORWIDTH, Memr[P2R(gt+GT_XMINORWIDTH)])
+ call gsetr (gp, G_XAXISWIDTH, Memr[P2R(gt+GT_XAXISWIDTH)])
+ call gsetr (gp, G_XTICKLABELSIZE, Memr[P2R(gt+GT_XTICKLABELSIZE)])
+ call gseti (gp, G_XGRIDCOLOR, Memi[gt+GT_XGRIDCOLOR])
+ call gseti (gp, G_XAXISLABELCOLOR, Memi[gt+GT_XAXISLABELCOLOR])
+ call gseti (gp, G_XAXISCOLOR, Memi[gt+GT_XAXISCOLOR])
+ call gseti (gp, G_XTICKLABELCOLOR, Memi[gt+GT_XTICKLABELCOLOR])
+ call gseti (gp, G_XTICKCOLOR, Memi[gt+GT_XTICKCOLOR])
+
+ call gseti (gp, G_YDRAWAXES, Memi[gt+GT_YDRAWAXES])
+ call gseti (gp, G_YSETAXISPOS, Memi[gt+GT_YSETAXISPOS])
+ call gsetr (gp, G_YAXISPOS1, Memr[P2R(gt+GT_YAXISPOS1)])
+ call gsetr (gp, G_YAXISPOS2, Memr[P2R(gt+GT_YAXISPOS2)])
+ call gseti (gp, G_XDRAWGRID, Memi[gt+GT_YDRAWGRID])
+ call gseti (gp, G_YROUND, Memi[gt+GT_YROUND])
+ call gseti (gp, G_YLABELAXIS, Memi[gt+GT_YLABELAXIS])
+ call gsetr (gp, G_YAXISLABELSIZE, Memr[P2R(gt+GT_YAXISLABELSIZE)])
+ call gseti (gp, G_YDRAWTICKS, Memi[gt+GT_YDRAWTICKS])
+ call gseti (gp, G_YLABELTICKS, Memi[gt+GT_YLABELTICKS])
+ call gseti (gp, G_YNMAJOR, Memi[gt+GT_YNMAJOR])
+ call gseti (gp, G_YNMINOR, Memi[gt+GT_YNMINOR])
+ call gsetr (gp, G_YMAJORLENGTH, Memr[P2R(gt+GT_YMAJORLENGTH)])
+ call gsetr (gp, G_YMINORLENGTH, Memr[P2R(gt+GT_YMINORLENGTH)])
+ call gsetr (gp, G_YMAJORWIDTH, Memr[P2R(gt+GT_YMAJORWIDTH)])
+ call gsetr (gp, G_YMINORWIDTH, Memr[P2R(gt+GT_YMINORWIDTH)])
+ call gsetr (gp, G_YAXISWIDTH, Memr[P2R(gt+GT_YAXISWIDTH)])
+ call gsetr (gp, G_YTICKLABELSIZE, Memr[P2R(gt+GT_YTICKLABELSIZE)])
+ call gseti (gp, G_YGRIDCOLOR, Memi[gt+GT_YGRIDCOLOR])
+ call gseti (gp, G_YAXISLABELCOLOR, Memi[gt+GT_YAXISLABELCOLOR])
+ call gseti (gp, G_YAXISCOLOR, Memi[gt+GT_YAXISCOLOR])
+ call gseti (gp, G_YTICKLABELCOLOR, Memi[gt+GT_YTICKLABELCOLOR])
+ call gseti (gp, G_YTICKCOLOR, Memi[gt+GT_YTICKCOLOR])
+end
diff --git a/pkg/xtools/gtools/gtset.x b/pkg/xtools/gtools/gtset.x
new file mode 100644
index 00000000..d5eb33cb
--- /dev/null
+++ b/pkg/xtools/gtools/gtset.x
@@ -0,0 +1,224 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <ctype.h>
+include <gset.h>
+include "gtools.h"
+
+# GT_SETI -- Set integer parameters.
+
+procedure gt_seti (gt, param, ival)
+
+pointer gt # GTOOLS pointer
+int param # Parameter to set
+int ival # Integer value to set
+
+begin
+ if (gt == NULL)
+ return
+
+ switch (param) {
+ case GTLINE:
+ GT_LINE(gt) = ival
+ case GTTRANSPOSE:
+ GT_TRANSPOSE(gt) = ival
+ case GTSYSID:
+ GT_SYSID(gt) = ival
+ case GTCOLOR:
+ GT_COLOR(gt) = ival
+ case GTXFLIP:
+ GT_XFLIP(gt) = ival
+ case GTYFLIP:
+ GT_YFLIP(gt) = ival
+ case GTDRAWTITLE:
+ GT_DRWTITLE(gt) = ival
+ case GTDRAWXLABELS:
+ GT_DRWXLABELS(gt) = ival
+ case GTDRAWYLABELS:
+ GT_DRWYLABELS(gt) = ival
+ }
+end
+
+
+# GT_SETR -- Set real parameters.
+
+procedure gt_setr (gt, param, rval)
+
+pointer gt # GTOOLS pointer
+int param # Parameter to set
+real rval # Real value to set
+
+begin
+ if (gt == NULL)
+ return
+
+ switch (param) {
+ case GTVXMIN:
+ GT_VXMIN(gt) = rval
+ case GTVXMAX:
+ GT_VXMAX(gt) = rval
+ case GTVYMIN:
+ GT_VYMIN(gt) = rval
+ case GTVYMAX:
+ GT_VYMAX(gt) = rval
+ case GTXMIN:
+ if (GT_XFLIP(gt) == NO)
+ GT_XMIN(gt) = rval
+ else
+ GT_XMAX(gt) = rval
+ case GTXMAX:
+ if (GT_XFLIP(gt) == NO)
+ GT_XMAX(gt) = rval
+ else
+ GT_XMIN(gt) = rval
+ case GTYMIN:
+ if (GT_YFLIP(gt) == NO)
+ GT_YMIN(gt) = rval
+ else
+ GT_YMAX(gt) = rval
+ case GTYMAX:
+ if (GT_YFLIP(gt) == NO)
+ GT_YMAX(gt) = rval
+ else
+ GT_YMIN(gt) = rval
+ case GTXBUF:
+ GT_XBUF(gt) = rval
+ case GTYBUF:
+ GT_YBUF(gt) = rval
+ case GTLCLIP:
+ GT_LCLIP(gt) = rval
+ case GTHCLIP:
+ GT_HCLIP(gt) = rval
+ case GTXSIZE:
+ GT_XSIZE(gt) = rval
+ case GTYSIZE:
+ GT_YSIZE(gt) = rval
+ }
+end
+
+
+# GT_SETS -- Set string parameters.
+
+procedure gt_sets (gt, param, str)
+
+pointer gt # GTOOLS pointer
+int param # Parameter to set
+char str[ARB] # String
+
+char dummy[10]
+int len
+
+int marks[10]
+data marks /GM_POINT,GM_BOX,GM_PLUS,GM_CROSS,GM_DIAMOND,GM_HLINE,GM_VLINE,
+ GM_HEBAR,GM_VEBAR,GM_CIRCLE/
+int trans[2]
+data trans /GW_LINEAR, GW_ELOG/
+
+int strlen(), strdic()
+
+begin
+ if (gt == NULL)
+ return
+
+ len = strlen (str)
+ switch (param) {
+ case GTPARAMS:
+ call mfree (GT_PARAMS(gt), TY_CHAR)
+ if (len > 0) {
+ call malloc (GT_PARAMS(gt), len, TY_CHAR)
+ call strcpy (str, Memc[GT_PARAMS(gt)], len)
+ }
+ case GTTITLE:
+ call mfree (GT_TITLE(gt), TY_CHAR)
+ if (len > 0) {
+ call malloc (GT_TITLE(gt), len, TY_CHAR)
+ call strcpy (str, Memc[GT_TITLE(gt)], len)
+ }
+ case GTSUBTITLE:
+ call mfree (GT_SUBTITLE(gt), TY_CHAR)
+ if (len > 0) {
+ call malloc (GT_SUBTITLE(gt), len, TY_CHAR)
+ call strcpy (str, Memc[GT_SUBTITLE(gt)], len)
+ }
+ case GTCOMMENTS:
+ call mfree (GT_COMMENTS(gt), TY_CHAR)
+ if (len > 0) {
+ call malloc (GT_COMMENTS(gt), len, TY_CHAR)
+ call strcpy (str, Memc[GT_COMMENTS(gt)], len)
+ }
+ case GTXLABEL:
+ call mfree (GT_XLABEL(gt), TY_CHAR)
+ if (len > 0) {
+ call malloc (GT_XLABEL(gt), len, TY_CHAR)
+ call strcpy (str, Memc[GT_XLABEL(gt)], len)
+ }
+ case GTYLABEL:
+ call mfree (GT_YLABEL(gt), TY_CHAR)
+ if (len > 0) {
+ call malloc (GT_YLABEL(gt), len, TY_CHAR)
+ call strcpy (str, Memc[GT_YLABEL(gt)], len)
+ }
+ case GTXUNITS:
+ call mfree (GT_XUNITS(gt), TY_CHAR)
+ if (len > 0) {
+ call malloc (GT_XUNITS(gt), len, TY_CHAR)
+ call strcpy (str, Memc[GT_XUNITS(gt)], len)
+ }
+ case GTYUNITS:
+ call mfree (GT_YUNITS(gt), TY_CHAR)
+ if (len > 0) {
+ call malloc (GT_YUNITS(gt), len, TY_CHAR)
+ call strcpy (str, Memc[GT_YUNITS(gt)], len)
+ }
+ case GTXFORMAT:
+ call mfree (GT_XFORMAT(gt), TY_CHAR)
+ if (len > 0) {
+ call malloc (GT_XFORMAT(gt), len, TY_CHAR)
+ call strcpy (str, Memc[GT_XFORMAT(gt)], len)
+ }
+ case GTYFORMAT:
+ call mfree (GT_YFORMAT(gt), TY_CHAR)
+ if (len > 0) {
+ call malloc (GT_YFORMAT(gt), len, TY_CHAR)
+ call strcpy (str, Memc[GT_YFORMAT(gt)], len)
+ }
+ case GTXTRAN:
+ len = strdic (str, dummy, 10, "|linear|logarithmic|")
+ if (len == 0) {
+ call eprintf ("Unknown X transformation type `%s'\n")
+ call pargstr (str)
+ } else
+ GT_XTRAN(gt) = trans[len]
+ case GTYTRAN:
+ len = strdic (str, dummy, 10, "|linear|logarithmic|")
+ if (len == 0) {
+ call eprintf ("Unknown Y transformation type `%s'\n")
+ call pargstr (str)
+ } else
+ GT_YTRAN(gt) = trans[len]
+ case GTTYPE:
+ len = strdic (str, dummy, 10, GTMARKS)
+ if (len > 0) {
+ GT_TYPE(gt) = 1
+ GT_MARK(gt) = marks[len]
+ return
+ }
+ call strcpy (str, dummy, 10)
+ if (IS_DIGIT(str[5])) {
+ GT_LINE(gt) = TO_INTEG(str[5])
+ dummy[5] = EOS
+ }
+ len = strdic (dummy, dummy, 10, GTTYPES)
+ if (len == 0) {
+ call eprintf ("Unknown graph type `%s'\n")
+ call pargstr (str)
+ } else
+ GT_TYPE(gt) = len
+ case GTMARK:
+ len = strdic (str, dummy, 10, GTMARKS)
+ if (len == 0) {
+ call eprintf ("Unknown mark type `%s'\n")
+ call pargstr (str)
+ } else
+ GT_MARK(gt) = marks[len]
+ }
+end
diff --git a/pkg/xtools/gtools/gtswind.x b/pkg/xtools/gtools/gtswind.x
new file mode 100644
index 00000000..02766326
--- /dev/null
+++ b/pkg/xtools/gtools/gtswind.x
@@ -0,0 +1,65 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <gset.h>
+include <mach.h>
+include "gtools.h"
+
+# GT_SWIND -- Set graphics window.
+
+procedure gt_swind (gp, gt)
+
+pointer gp # GIO pointer
+pointer gt # GTOOLS pointer
+
+real xmin, xmax, dx, ymin, ymax, dy
+
+begin
+ if (gt != NULL) {
+ if (GT_TRANSPOSE(gt) == NO) {
+ call gseti (gp, G_XTRAN, GT_XTRAN(gt))
+ call gseti (gp, G_YTRAN, GT_YTRAN(gt))
+ } else {
+ call gseti (gp, G_YTRAN, GT_XTRAN(gt))
+ call gseti (gp, G_XTRAN, GT_YTRAN(gt))
+ }
+ call ggwind (gp, xmin, xmax, ymin, ymax)
+ dx = xmax - xmin
+ dy = ymax - ymin
+
+ if (IS_INDEF (GT_XMIN(gt)))
+ xmin = xmin - GT_XBUF(gt) * dx
+ else
+ xmin = GT_XMIN(gt)
+
+ if (IS_INDEF (GT_XMAX(gt)))
+ xmax = xmax + GT_XBUF(gt) * dx
+ else
+ xmax = GT_XMAX(gt)
+
+ if (IS_INDEF (GT_YMIN(gt)))
+ ymin = ymin - GT_YBUF(gt) * dy
+ else
+ ymin = GT_YMIN(gt)
+
+ if (IS_INDEF (GT_YMAX(gt)))
+ ymax = ymax + GT_YBUF(gt) * dy
+ else
+ ymax = GT_YMAX(gt)
+
+ if (GT_XFLIP(gt) == YES) {
+ dx = xmin
+ xmin = xmax
+ xmax = dx
+ }
+ if (GT_YFLIP(gt) == YES) {
+ dy = ymin
+ ymin = ymax
+ ymax = dy
+ }
+
+ if (GT_TRANSPOSE(gt) == NO)
+ call gswind (gp, xmin, xmax, ymin, ymax)
+ else
+ call gswind (gp, ymin, ymax, xmin, xmax)
+ }
+end
diff --git a/pkg/xtools/gtools/gtvplot.x b/pkg/xtools/gtools/gtvplot.x
new file mode 100644
index 00000000..23550c3d
--- /dev/null
+++ b/pkg/xtools/gtools/gtvplot.x
@@ -0,0 +1,51 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <gset.h>
+include "gtools.h"
+
+# GT_VPLOT -- Plot vector polymarks or polylines.
+
+procedure gt_vplot (gp, gt, v, npts, x1, x2)
+
+pointer gp # GIO pointer
+pointer gt # GTOOLS pointer
+real v[npts] # Abscissas
+int npts # Number of points
+real x1, x2 # Vector range
+
+int i, pltype, color, gstati()
+real x, dx
+
+begin
+ switch (GT_TYPE(gt)) {
+ case 1:
+ color = gstati (gp, G_PMCOLOR)
+ call gseti (gp, G_PMCOLOR, GT_COLOR(gt))
+ call gvmark (gp, v, npts, x1, x2, GT_MARK(gt), GT_XSIZE(gt),
+ GT_YSIZE(gt))
+ call gseti (gp, G_PMCOLOR, color)
+ case 2:
+ color = gstati (gp, G_PLCOLOR)
+ call gseti (gp, G_PLCOLOR, GT_COLOR(gt))
+ pltype = gstati (gp, G_PLTYPE)
+ call gseti (gp, G_PLTYPE, GT_LINE(gt))
+ call gvline (gp, v, npts, x1, x2)
+ call gseti (gp, G_PLTYPE, pltype)
+ call gseti (gp, G_PLCOLOR, color)
+ case 3:
+ color = gstati (gp, G_PLCOLOR)
+ call gseti (gp, G_PLCOLOR, GT_COLOR(gt))
+ pltype = gstati (gp, G_PLTYPE)
+ call gseti (gp, G_PLTYPE, GT_LINE(gt))
+ dx = (x2 - x1) / (npts - 1)
+ x = x1 - dx / 2
+ do i = 1, npts-1 {
+ x = x + dx
+ call gline (gp, x-dx, v[i], x, v[i])
+ call gline (gp, x, v[i], x, v[i+1])
+ }
+ call gline (gp, x, v[npts], x+dx, v[npts])
+ call gseti (gp, G_PLTYPE, pltype)
+ call gseti (gp, G_PLCOLOR, color)
+ }
+end
diff --git a/pkg/xtools/gtools/gtwindow.x b/pkg/xtools/gtools/gtwindow.x
new file mode 100644
index 00000000..4a150d74
--- /dev/null
+++ b/pkg/xtools/gtools/gtwindow.x
@@ -0,0 +1,180 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include "gtools.h"
+
+define HELP "lib$scr/gtwindow.key"
+define PROMPT "window options"
+
+# GT_WINDOW -- Set graph window with the cursor.
+
+procedure gt_window (gt, gp, cursor, redraw)
+
+pointer gt # GTOOLS pointer
+pointer gp # GIO pointer
+char cursor[ARB] # Cursor
+int redraw # Redraw flag
+
+char cmd[1]
+int wcs1, key1, wcs2, key2, clgcur()
+real wx1, wy1, wx2, wy2
+
+begin
+ call printf ( "window:")
+ if (clgcur (cursor, wx1, wy1, wcs1, key1, cmd, SZ_LINE) == EOF)
+ return
+ switch (key1) {
+ case 'e':
+ call printf ("again:")
+ if (clgcur (cursor, wx2, wy2, wcs2, key2, cmd, SZ_LINE) == EOF)
+ return
+ call gt_window2 (gt, gp, wx1, wy1, wcs1, key1, cmd,
+ wx2, wy2, wcs2, key2, cmd, redraw)
+ default:
+ call gt_window1 (gt, gp, wx1, wy1, wcs1, key1, cmd, redraw)
+ }
+ call printf ("")
+end
+
+
+# GT_WINDOW1 -- Act on window command.
+
+procedure gt_window1 (gt, gp, wx, wy, wcs, key, cmd, redraw)
+
+pointer gt #I GTOOLS pointer
+pointer gp #I GIO pointer
+real wx #I X Coordinate
+real wy #I Y Coordinate
+int wcs #I WCS
+int key #I Key
+char cmd[ARB] #I Command
+int redraw #O Redraw flag
+
+int gt_geti()
+real x1, x2, y1, y2, dx, dy, wx1, wy1
+
+begin
+ redraw = YES
+ call ggwind (gp, x1, x2, y1, y2)
+ dx = x2 - x1
+ dy = y2 - y1
+
+ wx1 = wx
+ wy1 = wy
+ if (IS_INDEF(wx1))
+ wx1 = (x1 + x2) / 2.
+ if (IS_INDEF(wy1))
+ wy1 = (y1 + y2) / 2.
+
+
+ switch (key) {
+ case '?': # Print help text
+ call gpagefile (gp, HELP, PROMPT)
+ redraw = NO
+ case 'a': # Autoscale x and y axes
+ call gt_setr (gt, GTXMIN, INDEF)
+ call gt_setr (gt, GTXMAX, INDEF)
+ call gt_setr (gt, GTYMIN, INDEF)
+ call gt_setr (gt, GTYMAX, INDEF)
+ case 'b': # Bottom edge
+ call gt_setr (gt, GTYMIN, wy1)
+ case 'c':
+ call gt_setr (gt, GTXMIN, wx1 - dx / 2)
+ call gt_setr (gt, GTXMAX, wx1 + dx / 2)
+ call gt_setr (gt, GTYMIN, wy1 - dy / 2)
+ call gt_setr (gt, GTYMAX, wy1 + dy / 2)
+ case 'd': # Shift down
+ call gt_setr (gt, GTYMIN, y1 - 0.75 * dy)
+ call gt_setr (gt, GTYMAX, y2 - 0.75 * dy)
+ case 'f': # Flip x axis
+ if (gt_geti (gt, GTXFLIP) == NO)
+ call gt_seti (gt, GTXFLIP, YES)
+ else
+ call gt_seti (gt, GTXFLIP, NO)
+ case 'g': # Flip y axis
+ if (gt_geti (gt, GTYFLIP) == NO)
+ call gt_seti (gt, GTYFLIP, YES)
+ else
+ call gt_seti (gt, GTYFLIP, NO)
+ case 'j': # Left edge
+ call gt_setr (gt, GTXMIN, wx1)
+ case 'k': # Right edge
+ call gt_setr (gt, GTXMAX, wx1)
+ case 'l': # Shift left
+ call gt_setr (gt, GTXMIN, x1 - 0.75 * dx)
+ call gt_setr (gt, GTXMAX, x2 - 0.75 * dx)
+ case 'm': # Autoscale x axis
+ call gt_setr (gt, GTXMIN, INDEF)
+ call gt_setr (gt, GTXMAX, INDEF)
+ case 'n': # Autoscale y axis
+ call gt_setr (gt, GTYMIN, INDEF)
+ call gt_setr (gt, GTYMAX, INDEF)
+ case 'p': # Pan
+ call gt_setr (gt, GTXMIN, wx1 - dx)
+ call gt_setr (gt, GTXMAX, wx1 + dx)
+ call gt_setr (gt, GTYMIN, wy1 - dy)
+ call gt_setr (gt, GTYMAX, wy1 + dy)
+ case 'r': # Shift right
+ call gt_setr (gt, GTXMIN, x1 + 0.75 * dx)
+ call gt_setr (gt, GTXMAX, x2 + 0.75 * dx)
+ case 't': # Top edge
+ call gt_setr (gt, GTYMAX, wy1)
+ case 'u': # Shift up
+ call gt_setr (gt, GTYMIN, y1 + 0.75 * dy)
+ call gt_setr (gt, GTYMAX, y2 + 0.75 * dy)
+ case 'x': # Zoom x axis
+ call gt_setr (gt, GTXMIN, wx1 - dx / 4)
+ call gt_setr (gt, GTXMAX, wx1 + dx / 4)
+ case 'y': # Zoom y axis
+ call gt_setr (gt, GTYMIN, wy1 - dy / 4)
+ call gt_setr (gt, GTYMAX, wy1 + dy / 4)
+ case 'z': # Zoom x and y axis
+ call gt_setr (gt, GTXMIN, wx1 - dx / 4)
+ call gt_setr (gt, GTXMAX, wx1 + dx / 4)
+ call gt_setr (gt, GTYMIN, wy1 - dy / 4)
+ call gt_setr (gt, GTYMAX, wy1 + dy / 4)
+ case 'I':
+ call fatal (0, "Interrupt")
+ default:
+ call printf ("\07")
+ redraw = NO
+ }
+end
+
+
+# GT_WINDOW2 -- Act on window command.
+
+procedure gt_window2 (gt, gp, wx1, wy1, wcs1, key1, cmd1,
+ wx2, wy2, wcs2, key2, cmd2, redraw)
+
+pointer gt #I GTOOLS pointer
+pointer gp #I GIO pointer
+real wx1, wx2 #I X Coordinate
+real wy1, wy2 #I Y Coordinate
+int wcs1, wcs2 #I WCS
+int key1, key2 #I Key
+char cmd1[ARB], cmd2[ARB] #I Command
+int redraw #O Redraw flag
+
+real x1, x2, y1, y2, dx, dy
+
+begin
+ redraw = YES
+ call ggwind (gp, x1, x2, y1, y2)
+ dx = x2 - x1
+ dy = y2 - y1
+
+ switch (key1) {
+ case 'e': # Expand window
+ if (abs (wx2 - wx1) > 0.001 * abs (dx)) {
+ call gt_setr (gt, GTXMIN, wx1)
+ call gt_setr (gt, GTXMAX, wx2)
+ }
+ if (abs (wy2 - wy1) > 0.001 * abs (dy)) {
+ call gt_setr (gt, GTYMIN, wy1)
+ call gt_setr (gt, GTYMAX, wy2)
+ }
+ default:
+ call printf ("\07\n")
+ redraw = NO
+ }
+end
diff --git a/pkg/xtools/gtools/mkpkg b/pkg/xtools/gtools/mkpkg
new file mode 100644
index 00000000..bbad01aa
--- /dev/null
+++ b/pkg/xtools/gtools/mkpkg
@@ -0,0 +1,27 @@
+# GTOOLS
+
+update:
+ $checkout libxtools.a lib$
+ $update libxtools.a
+ $checkin libxtools.a lib$
+ ;
+
+libxtools.a:
+ gtascale.x gtools.h <mach.h>
+ gtcolon.x gtools.h <ctype.h> <gset.h>
+ gtcopy.x gtools.h
+ gtctran.x
+ gtcur.x
+ gtcur1.x gtools.h
+ gtfree.x gtools.h
+ gtget.x gtools.h <gset.h>
+ gtgui.x gtools.h <gset.h>
+ gtinit.x gtools.h <gset.h>
+ gtlabax.x gtools.h <ctype.h> <gset.h> <gio.h>
+ gtplot.x gtools.h <gset.h>
+ gtreset.x gtools.h <gset.h>
+ gtset.x gtools.h <ctype.h> <gset.h>
+ gtswind.x gtools.h <gset.h> <mach.h>
+ gtvplot.x gtools.h <gset.h>
+ gtwindow.x gtools.h
+ ;