aboutsummaryrefslogtreecommitdiff
path: root/vendor/x11iraf/cdl/examples
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 /vendor/x11iraf/cdl/examples
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'vendor/x11iraf/cdl/examples')
-rw-r--r--vendor/x11iraf/cdl/examples/Imakefile36
-rw-r--r--vendor/x11iraf/cdl/examples/Imakefile.standalone54
-rw-r--r--vendor/x11iraf/cdl/examples/Makefile.generic102
-rw-r--r--vendor/x11iraf/cdl/examples/README25
-rw-r--r--vendor/x11iraf/cdl/examples/animate.c153
-rw-r--r--vendor/x11iraf/cdl/examples/coords42
-rw-r--r--vendor/x11iraf/cdl/examples/display.c257
-rw-r--r--vendor/x11iraf/cdl/examples/dpix.fitsbin0 -> 532800 bytes
-rw-r--r--vendor/x11iraf/cdl/examples/fdisplay.f65
-rw-r--r--vendor/x11iraf/cdl/examples/ftvmark.f301
-rw-r--r--vendor/x11iraf/cdl/examples/mosaic.c219
-rw-r--r--vendor/x11iraf/cdl/examples/tvmark.c397
12 files changed, 1651 insertions, 0 deletions
diff --git a/vendor/x11iraf/cdl/examples/Imakefile b/vendor/x11iraf/cdl/examples/Imakefile
new file mode 100644
index 00000000..ef6c3d97
--- /dev/null
+++ b/vendor/x11iraf/cdl/examples/Imakefile
@@ -0,0 +1,36 @@
+#
+# IMakefile for CDL Example tasks.
+#
+
+X11IRAFDIR = ../../
+#include <../../X11IRAF.tmpl>
+
+
+ CDEBUGFLAGS = -g
+ FCFLAGS = -g
+ CDLDIR = ../
+ INCLUDES = -I. -I$(CDLDIR)
+ LOCAL_LDFLAGS = -L$(CDLDIR)
+ LIBS = -lcdl
+
+
+AllTarget(animate display mosaic tvmark fdisplay ftvmark)
+
+NormalFortranObjectRule()
+
+NormalProgramTarget(animate,animate.o,../libcdl.a,$(LIBS),-lm)
+NormalProgramTarget(display,display.o,../libcdl.a,$(LIBS),-lm)
+NormalProgramTarget(mosaic,mosaic.o,../libcdl.a,$(LIBS),-lm)
+NormalProgramTarget(tvmark,tvmark.o,../libcdl.a,$(LIBS),-lm)
+
+fdisplay: fdisplay.o ../libcdl.a
+ f77 -o fdisplay fdisplay.o ../libcdl.a -lm $(LDLIBS)
+
+ftvmark: ftvmark.o ../libcdl.a
+ f77 -o ftvmark ftvmark.o ../libcdl.a -lm $(LDLIBS)
+
+clean::
+ $(RM) fdisplay ftvmark
+
+DependTarget()
+LintTarget()
diff --git a/vendor/x11iraf/cdl/examples/Imakefile.standalone b/vendor/x11iraf/cdl/examples/Imakefile.standalone
new file mode 100644
index 00000000..8886ae9e
--- /dev/null
+++ b/vendor/x11iraf/cdl/examples/Imakefile.standalone
@@ -0,0 +1,54 @@
+#
+# IMakefile for CDL Example tasks.
+#
+
+ CDEBUGFLAGS = -g
+ FCFLAGS = -g
+ CDLDIR = ../
+ INCLUDES = -I. -I$(CDLDIR)
+ LOCAL_LDFLAGS = -L$(CDLDIR)
+ LIBS = -lcdl
+
+
+# Hack to compile under SunPRO V4 on Solaris
+#if defined (SunArchitecture) && OSMajorVersion >= 5 && HasSunC
+#if OSMinorVersion <= 5
+#if !defined (i386Architecture)
+ CCOPTIONS = -Xs
+EXTRA_LDOPTIONS = -xildoff
+#endif
+#else
+ CCOPTIONS =
+EXTRA_LDOPTIONS = -xildoff
+#endif
+
+#else
+#if defined (UltrixArchitecture)
+ CCOPTIONS = -DULTRIX
+#endif
+#if defined (OSF1Architecture) && OSMajorVersion >= 4
+ CCOPTIONS = -DOSF1
+#endif
+#endif
+
+
+AllTarget(animate display mosaic tvmark fdisplay ftvmark)
+
+NormalFortranObjectRule()
+
+NormalProgramTarget(animate,animate.o,../libcdl.a,$(LIBS),-lm)
+NormalProgramTarget(display,display.o,../libcdl.a,$(LIBS),-lm)
+NormalProgramTarget(mosaic,mosaic.o,../libcdl.a,$(LIBS),-lm)
+NormalProgramTarget(tvmark,tvmark.o,../libcdl.a,$(LIBS),-lm)
+
+fdisplay: fdisplay.o ../libcdl.a
+ f77 -o fdisplay fdisplay.o ../libcdl.a -lm $(LDLIBS)
+
+ftvmark: ftvmark.o ../libcdl.a
+ f77 -o ftvmark ftvmark.o ../libcdl.a -lm $(LDLIBS)
+
+clean::
+ $(RM) fdisplay ftvmark
+
+DependTarget()
+LintTarget()
diff --git a/vendor/x11iraf/cdl/examples/Makefile.generic b/vendor/x11iraf/cdl/examples/Makefile.generic
new file mode 100644
index 00000000..fae978aa
--- /dev/null
+++ b/vendor/x11iraf/cdl/examples/Makefile.generic
@@ -0,0 +1,102 @@
+#
+# Generic Makefile for CDL Example tasks.
+#
+
+ CDEBUGFLAGS = -g
+ FCFLAGS = -g
+ RM = rm
+ CDLDIR = ../
+ INCLUDES = -I. -I$(CDLDIR)
+ LDFLAGS = -L$(CDLDIR)
+ LIBS = -lcdl
+
+ LDLIBS =
+
+all:: display mosaic tvmark fdisplay ftvmark
+
+.c.o:
+ $(RM) -f $@
+ $(CC) -c $(INCLUDES) $(CFLAGS) $*.c
+
+.f.o:
+ $(RM) -f $@
+ $(FC) -c $(FCFLAGS) $*.f
+
+display: display.o ../libcdl.a
+ $(RM) -f $@
+ $(CC) -o $@ display.o $(LDFLAGS) $(LDOPTIONS) $(LIBS) $(LDLIBS) -lm
+
+clean::
+ $(RM) -f display
+
+mosaic: mosaic.o ../libcdl.a
+ $(RM) -f $@
+ $(CC) -o $@ mosaic.o $(LDFLAGS) $(LDOPTIONS) $(LIBS) $(LDLIBS) -lm
+
+clean::
+ $(RM) -f mosaic
+
+tvmark: tvmark.o ../libcdl.a
+ $(RM) -f $@
+ $(CC) -o $@ tvmark.o $(LDFLAGS) $(LDOPTIONS) $(LIBS) $(LDLIBS) -lm
+
+clean::
+ $(RM) -f tvmark
+
+fdisplay: fdisplay.o ../libcdl.a
+ f77 -o fdisplay fdisplay.o ../libcdl.a -lm $(LDLIBS)
+
+ftvmark: ftvmark.o ../libcdl.a
+ f77 -o ftvmark ftvmark.o ../libcdl.a -lm $(LDLIBS)
+
+clean::
+ $(RM) -f fdisplay ftvmark
+
+depend::
+
+lint:
+ $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
+lint1:
+ $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
+
+clean::
+ $(RM) -f *.o
+
+# -------------------------------------------------------------------------
+# common rules for all Makefiles - do not edit
+
+emptyrule::
+
+Makefile::
+ -@if [ -f Makefile ]; then set -x; \
+ $(RM) -f Makefile.bak; $(MV) Makefile Makefile.bak; \
+ else exit 0; fi
+ $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
+
+tags::
+ $(TAGS) -w *.[ch]
+ $(TAGS) -xw *.[ch] > TAGS
+
+saber:
+ # load $(ALLDEFINES) $(SRCS)
+
+osaber:
+ # load $(ALLDEFINES) $(OBJS)
+
+# -------------------------------------------------------------------------
+# empty rules for directories that do not have SUBDIRS - do not edit
+
+install::
+ @echo "install in $(CURRENT_DIR) done"
+
+install.man::
+ @echo "install.man in $(CURRENT_DIR) done"
+
+Makefiles::
+
+includes::
+
+# -------------------------------------------------------------------------
+# dependencies generated by makedepend
+
+# DO NOT DELETE
diff --git a/vendor/x11iraf/cdl/examples/README b/vendor/x11iraf/cdl/examples/README
new file mode 100644
index 00000000..fb0f58de
--- /dev/null
+++ b/vendor/x11iraf/cdl/examples/README
@@ -0,0 +1,25 @@
+CDL PACKAGE EXAMPLES -- This directory contains several example programs
+to demostrate usage of the Client Display library. Programs are available
+in both C and Fortran. These are working examples but perhaps not the most
+highly efficient code since they're meant to demonstrate how the package
+might be used. Tasks available so far include
+
+ DISPLAY.C - C program to display an image. Demonstrates how
+ to use the high level format display calls, the
+ midlevel raw pixel display, and the lowest level
+ raw raster display methods.
+ TVMARK.C - C program to display and image and overlay with
+ point marks, optional interactive marking available.
+ Demonstrates usage of cursor reads and call for
+ the various marking routines.
+ MOSAIC.C - C program to mosaic several images on the display.
+ Demonstrates the use of low-level raster I/O to
+ do more complex display operations.
+
+ FDISPLAY.F - Fortran equivalent of the DISPLAY task above.
+ FTVMARK.F - Fortran equivalent of the TVMARK task above.
+
+Misc Files in This Directory:
+
+ DPIX.FITS - 512x512 test image of M51
+ COORDS - sample coordinate file for tvmark task
diff --git a/vendor/x11iraf/cdl/examples/animate.c b/vendor/x11iraf/cdl/examples/animate.c
new file mode 100644
index 00000000..66f487d9
--- /dev/null
+++ b/vendor/x11iraf/cdl/examples/animate.c
@@ -0,0 +1,153 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include "cdl.h"
+
+/* ANIMATE -- Example task to demonstrate rapid display of rasters such as
+ * would be done in an animation sequence, or in an acquisition system
+ * which needs to display guider images repeatedly (the actual inspiration
+ * for this demo.
+ *
+ * Examples:
+ * Display a scrolling test pattern:
+ * % animate
+ *
+ * Usage:
+ * animate [-nx N] [-ny N] [-fbconfig N]
+ *
+ * Note that your choice of frame buffer is important since if it's
+ * larger than the image size you're spending a lot of overhead in writing
+ * blank pixels around the actual image. When writing a true subraster of
+ * the image/frame buffer, the routine first reads back the pixels in the
+ * affected rows, edits the pixels in the subraster columns and then writes
+ * back the entire row. If the subraster width is the same size as the
+ * frame buffer width it does a straight write which will speed up the dis-
+ * play since you avoid the readback overhead. It may be worth defining a
+ * custom frame buffer the size of your image to speed things up.
+ */
+
+#define DIAGONAL 0 /* test pattern flags */
+#define VERTICAL 1
+#define HORIZONTAL 2
+
+#define max(a,b) (a > b ? a : b) /* Utility macros */
+#define min(a,b) (a < b ? a : b)
+
+
+CDLPtr cdl;
+uchar *pix = NULL;
+
+main (argc, argv)
+int argc;
+char *argv[];
+{
+ register int i, frame=1;
+ int nx=256, ny=256, fbconfig=0;
+ int status=0, fb_w, fb_h, nf, lx, ly;
+ uchar *line;
+
+ /* Handle command line args. */
+ if (argc > 1) {
+ for (i=1; i < argc; i++) {
+ if (strcmp (argv[i], "-nx") == 0)
+ nx = atoi (argv[++i]);
+ else if (strcmp (argv[i], "-ny") == 0)
+ ny = atoi (argv[++i]);
+ else if (strcmp (argv[i], "-fbconfig") == 0)
+ fbconfig = atoi (argv[++i]);
+ }
+ }
+
+ /* Open the package and a connection to the server. */
+ if (!(cdl = cdl_open ((char *)getenv("IMTDEV"))) )
+ exit (-1);
+
+ /* Make a test pattern. */
+ pix = (uchar *) malloc (nx * ny);
+ makeTestPattern (pix, nx, ny, DIAGONAL);
+
+ /* Now select a frame buffer large enough for the image. The
+ * fbconfig number is passed in the WCS packet, but the display
+ * calls below will compute the correct WCS for the image and
+ * transmit that prior to display, all we're doing here is
+ * setting up the FB to be used.
+ */
+ if (fbconfig == 0)
+ cdl_selectFB (cdl, nx, ny, &fbconfig, &fb_w, &fb_h, &nf, 1);
+ else
+ cdl_lookupFBSize (cdl, fbconfig, &fb_w, &fb_h, &nf);
+
+
+ /* For the WCS we assume a simple linear transform where the image is
+ * Y-flipped, the (x,y) translation is computed so it is correct
+ * for an frame buffer >= than the image size. The Z-transform is
+ * fixed since we're using a test pattern with known values.
+ */
+ cdl_setWCS (cdl, "test pattern", "", 1., 0., 0., -1.,
+ (float) (nx / 2) - (fb_w / 2) + 1, /* X translation */
+ (float) (fb_h / 2) + (ny / 2), /* Y translation */
+ 0.0, 200.0, CDL_LINEAR); /* Z transform */
+
+
+ /* Select and clear the initial frame prior to display. */
+ cdl_setFrame (cdl, frame);
+ cdl_clearFrame (cdl);
+
+ /* Now display the pixels. We'll compute the image placement
+ * ourselves and write the image as a raw subraster of the frame
+ * buffer in the center of the display.
+ */
+ lx = (fb_w / 2) - (nx / 2);
+ ly = fb_h - ((fb_h / 2) + (ny / 2));
+ status = cdl_writeSubRaster (cdl, lx, ly, nx, ny, pix);
+
+ /* Now animate the image. */
+ line = (uchar *) malloc (nx);
+ while (1) {
+ /* Shift the image down one line, roll the botton line to the
+ * top and redisplay the subraster/
+ */
+ memcpy (pix, line, nx);
+ memmove (pix+nx, pix, (ny-1)*nx);
+ memcpy (line, pix+((ny-1)*nx), nx);
+
+ status = cdl_writeSubRaster (cdl, lx, ly, nx, ny, pix);
+ }
+
+
+ cdl_close (cdl); /* close the package */
+ free ((unsigned char *) pix); /* free the raster */
+ exit (status);
+}
+
+
+/* Make a test pattern. */
+
+makeTestPattern (raster, nx, ny, pattern)
+uchar *raster;
+int nx, ny, pattern;
+{
+ register uchar pix;
+ register int i, j;
+ register float scale;
+
+ for (i = 0; i < nx; i++) {
+ for (j = 0; j < ny; j++) {
+ switch (pattern) {
+ case DIAGONAL: /* Diagonal ramp */
+ scale = 200. / (float)(ny) / 2.;
+ pix = (uchar) max(2, (min(200,(scale*i + scale*j))));
+ break;
+ case VERTICAL: /* Vertical ramp */
+ scale = 200. / (float)(ny);
+ pix = (uchar) max(2, (min(200,(scale * i))));
+ break;
+ case HORIZONTAL: /* Horizontal ramp */
+ scale = 200. / (float)(nx);
+ pix = (uchar) max(2, (min(200,(scale * j))));
+ break;
+ }
+ raster[i * nx + j] = pix;
+ }
+ }
+}
diff --git a/vendor/x11iraf/cdl/examples/coords b/vendor/x11iraf/cdl/examples/coords
new file mode 100644
index 00000000..7f6fcdf5
--- /dev/null
+++ b/vendor/x11iraf/cdl/examples/coords
@@ -0,0 +1,42 @@
+ 49 343
+ 59 226
+ 68 459
+ 87 481
+ 92 319
+ 97 106
+113 143
+126 117
+133 391
+134 109
+134 221
+144 345
+150 83
+179 355
+182 63
+211 328
+218 439
+219 314
+225 129
+241 403
+265 340
+269 355
+288 133
+292 104
+294 178
+320 327
+321 32
+329 409
+338 325
+348 231
+349 188
+364 325
+365 124
+377 368
+381 67
+405 274
+415 187
+442 409
+452 212
+466 62
+472 232
+508 445
diff --git a/vendor/x11iraf/cdl/examples/display.c b/vendor/x11iraf/cdl/examples/display.c
new file mode 100644
index 00000000..67b52c97
--- /dev/null
+++ b/vendor/x11iraf/cdl/examples/display.c
@@ -0,0 +1,257 @@
+#include <stdio.h>
+#ifdef ULTRIX
+#include <sys/types.h>
+#endif
+#include <sys/types.h>
+#include <unistd.h>
+#include "cdl.h"
+
+/*
+ * DISPLAY -- Example task to display an image as a command-line task.
+ * This task is meant to show three ways the CDL can be used to display
+ * and image, it is functional but perhaps not highly efficient for this
+ * reason. See the code comments for a description of each method.
+ *
+ * Examples:
+ * To display a simple IRAF or FITS file:
+ * % ./display -frame 2 image.imh
+ * % ./display image.fits
+ *
+ * To display a FITS file as a raw image:
+ * % ./display -nx 512 -ny 512 -depth 16 -hskip 5760 -raw dpix.fits
+ *
+ * Usage:
+ * display [-depth N] [-fits] [-frame N] [-fbconfig N] [-hskip N]
+ * [-iraf] [-nozscale] [-nx N] [-ny N] [-raw] [-zscale]
+ * [-ns N] [-nl N] [-log] file
+ */
+
+#define NONE -1
+#define IRAF 0
+#define FITS 1
+#define RAW 2
+
+#define ABS(x) (x > 0 ? x : -x)
+
+#ifdef SOLARIS
+char *getcwd();
+#else
+char *getwd();
+#endif
+
+
+main (argc, argv)
+int argc;
+char *argv[];
+{
+ CDLPtr cdl;
+ char *fname;
+ int i, log = 0, status = 0, frame = 1, fbconfig = 0, zscale = 1;
+ int format = NONE, nx = 0, ny = 0, depth = 8, hskip = 0;
+ int ns = -1, nl = -1;
+ float z1, z2;
+ int fb_w, fb_h, nf;
+ unsigned char *pix = NULL;
+ char *path_prefix = (char *) calloc (1025, sizeof(char));
+ char *path = (char *) calloc (512, sizeof(char));
+ char *node = (char *) calloc (512, sizeof(char));
+
+
+ /* Process the command line options. */
+ if (argc > 1) {
+ for (i=1; i < argc; i++) {
+ if (strcmp (argv[i], "-depth") == 0)
+ depth = atoi (argv[++i]);
+ else if (strcmp (argv[i], "-fits") == 0)
+ format = FITS;
+ else if (strcmp (argv[i], "-frame") == 0)
+ frame = atoi (argv[++i]);
+ else if (strcmp (argv[i], "-fbconfig") == 0)
+ fbconfig = atoi (argv[++i]);
+ else if (strcmp (argv[i], "-hskip") == 0)
+ hskip = atoi (argv[++i]);
+ else if (strcmp (argv[i], "-iraf") == 0)
+ format = IRAF;
+ else if (strcmp (argv[i], "-log") == 0)
+ log++;
+ else if (strcmp (argv[i], "-nozscale") == 0)
+ zscale = 0;
+ else if (strcmp (argv[i], "-ns") == 0)
+ ns = atoi (argv[++i]);
+ else if (strcmp (argv[i], "-nl") == 0)
+ nl = atoi (argv[++i]);
+ else if (strcmp (argv[i], "-nx") == 0)
+ nx = atoi (argv[++i]);
+ else if (strcmp (argv[i], "-ny") == 0)
+ ny = atoi (argv[++i]);
+ else if (strcmp (argv[i], "-raw") == 0)
+ format = RAW;
+ else if (strcmp (argv[i], "-zscale") == 0)
+ zscale = 1;
+ }
+ }
+
+ /* Open the package and a connection to the server. */
+ if (!(cdl = cdl_open ((char *)getenv("IMTDEV"))) )
+ exit (-1);
+
+ fname = argv[argc-1];
+
+ if (ns > 0) cdl_setSample (cdl, ns);
+ if (nl > 0) cdl_setSampleLines (cdl, nl);
+ if (log > 0) cdl_setZTrans (cdl, CDL_LOG);
+
+ /* METHOD 1: Displays the image using the high-level format display
+ * call. Display as an IRAF image if the option was set indicating
+ * this is the format, otherwise test the file to see if it is anyway.
+ */
+ if (format == IRAF || (format == NONE && cdl_isIRAF (fname))) {
+ status = cdl_displayIRAF (cdl, fname, 1, frame,
+ (fbconfig==0 ? FB_AUTO : fbconfig), zscale);
+
+
+ /* METHOD 2: Uses the CDL procedure for getting image pixels from
+ * a known format, minimal work required to display an image. The
+ * point here is that you can use this mthod to process the image
+ * yourself prior to display, e.g. subsample the pixels, apply a user
+ * LUT, etc but still use the CDL to get the raw image and do the
+ * display.
+ */
+ } else if (format == FITS || (format == NONE && cdl_isFITS (fname))) {
+ float *bscale, *bzero;
+ char title[80];
+
+ /* Get the FITS image pixels, exit w/ an error status if something
+ * went wrong, the procedure will print what that was.
+ */
+ if (cdl_readFITS (fname, &pix, &nx, &ny, &depth, title)) {
+ cdl_close (cdl); /* close the package */
+ exit (1); /* exit w/ error code */
+ }
+
+ /* Now select a frame buffer large enough for the image. The
+ * fbconfig number is passed in the WCS packet, but the display
+ * call below will compute the correct WCS for the image and
+ * transmit that prior to display, all we're doing here is
+ * setting up the FB to be used.
+ */
+ if (fbconfig == 0)
+ cdl_selectFB (cdl, nx, ny, &fbconfig, &fb_w, &fb_h, &nf, 0);
+
+ /* Lastly, display the pixels to the requested frame, do any
+ * zscaling requested using the CDL procedure.
+ */
+ (void) cdl_setTitle (cdl, title);
+ (void) cdl_setName (cdl, fname);
+ if (cdl_displayPix(cdl, pix, nx, ny, depth, frame, fbconfig,zscale))
+ status = 1;
+
+ /* Now just free the pixel pointer to clean up.
+ */
+ free ((unsigned char *) pix);
+
+
+ /* METHOD 3: Displays an image of raw pixels. The client code is
+ * responsible for reading the image and calling all the procedures
+ * needed for image display, initialize the frame, zscaling pix, etc.
+ * While we assume a simple raster format in this program, the user
+ * code can read a compressed image format such as GIF, mosaic multiple
+ * images for display as a single image, or just about anything that
+ * produces a raster for display. The intent here is to show all the
+ * lowest level calls needed for displaying the image.
+ */
+ } else if (format == RAW) {
+ FILE *fd;
+ int lx, ly;
+
+ if (nx == 0 || ny == 0) {
+ fprintf (stderr, "No size given for raw data.\n");
+ exit (1);
+ }
+
+ /* Open the image file if we can. */
+ if (fd = fopen (fname, "r")) {
+
+ /* Seek to the offset specified. */
+ lseek (fileno(fd), (off_t) hskip, SEEK_SET);
+
+ /* Allocate the pixel pointer and read the data. */
+ pix = (unsigned char *) malloc (nx * ny * (ABS(depth) / 8));
+ fread (pix, ABS(depth)/8, nx * ny, fd);
+
+ /* If we're zscaling and depth is more than 8-bits, do that. */
+ if (zscale && ABS(depth) > 8) {
+ cdl_computeZscale (cdl, pix, nx, ny, depth, &z1, &z2);
+ cdl_zscaleImage (cdl, &pix, nx, ny, depth, z1, z2);
+ }
+
+ /* Select and clear the requested frame prior to display. */
+ cdl_setFrame (cdl, frame);
+ cdl_clearFrame (cdl);
+
+ /* Now select a frame buffer large enough for the image.
+ * We'll ask that this be reset but the change won't go to
+ * the server until we send in the WCS below.
+ */
+ cdl_selectFB (cdl, nx, ny, &fbconfig, &fb_w, &fb_h, &nf, 1);
+
+ /* Compute the image placement so it's centered in the frame,
+ * but note the cdl_writeSubRaster() routine can place an
+ * arbitrary raster anywhere in the frame buffer.
+ lx = (fb_w / 2) - (nx / 2);
+ ly = fb_h - ((fb_h / 2) + (ny / 2));
+
+ /* Set the mapping we'll send with the WCS which must be
+ * called before the cdl_setWCS() call since the data is sent
+ * with the WCS and not as a separate call.
+ */
+
+ /* First we must compose a node!path prefix for the image */
+ gethostname (node, 512);
+#ifdef SOLARIS
+ (void) getcwd (path, 512);
+#else
+ (void) getwd (path);
+#endif
+ if (*fname == '/')
+ (void) sprintf (path_prefix, "%s!%s", node, fname);
+ else
+ (void) sprintf (path_prefix, "%s!%s/%s", node, path, fname);
+
+ cdl_setMapping (cdl, "image", 0., 0., nx, ny, lx, ly, nx, ny,
+ path_prefix);
+
+ /* For the WCS we assume a simple linear transform where the
+ * image is Y-flipped, the (x,y) translation is computed so
+ * it is correct for an frame buffer >= than the image size.
+ */
+ cdl_setWCS (cdl, fname, "", 1., 0., 0., -1.,
+ (float) (nx / 2) - (fb_w / 2) + 1, /* X trans. */
+ (float) (fb_h / 2) + (ny / 2), /* Y trans. */
+ z1, z2, CDL_LINEAR); /* Z transform */
+
+
+ /* Now display the pixels.
+ */
+ if (cdl_writeSubRaster (cdl, lx, ly, nx, ny, pix))
+ status = 1;
+
+ /* Now just free the pixel pointer to clean up.
+ */
+ free ((unsigned char *) pix);
+ fclose (fd);
+
+ } else
+ status = 1;
+
+ } else {
+ if (access (fname, F_OK) == 0)
+ fprintf (stderr, "'%s': unknown image format.\n", fname);
+ else
+ fprintf (stderr, "'%s': image does not exist.\n", fname);
+ status = 1;
+ }
+
+ cdl_close (cdl); /* close the package */
+ exit (status);
+}
diff --git a/vendor/x11iraf/cdl/examples/dpix.fits b/vendor/x11iraf/cdl/examples/dpix.fits
new file mode 100644
index 00000000..33c19cb3
--- /dev/null
+++ b/vendor/x11iraf/cdl/examples/dpix.fits
Binary files differ
diff --git a/vendor/x11iraf/cdl/examples/fdisplay.f b/vendor/x11iraf/cdl/examples/fdisplay.f
new file mode 100644
index 00000000..d14633f6
--- /dev/null
+++ b/vendor/x11iraf/cdl/examples/fdisplay.f
@@ -0,0 +1,65 @@
+C ========================================================================
+C =
+C FDISPLAY -- Example fortran program showing the use of the Client =
+C Display Library (CDL) Fortran interface for displaying images. In =
+C this simple program all input is prompted for on the command line. =
+C =
+C ========================================================================
+
+
+ program fdisplay
+ character*132 imname
+ character*132 imtdev
+
+C --------------------------
+C Initialize the CDL package
+C --------------------------
+ call getenv('IMTDEV',imtdev)
+ call cfopen(imtdev, ier)
+ if (ier .gt. 0) then
+ write (*,*) 'open: Error return from CDL'
+ goto 999
+ endif
+
+ write (*, "('Image Name: ', $)")
+ read (5, *) imname
+ write (*, "('Frame Number: ', $)")
+ read (5, *) iframe
+ write (*, "('Frame buffer configuration number: ', $)")
+ read (5, *) ifb
+
+C ----------------------------------------------------------
+C If we've got a FITS format image, go ahead and display it.
+C ----------------------------------------------------------
+ call cfisfits (imname, isfits)
+ if (isfits .gt. 0) then
+ call cfdisplayfits (imname, iframe, ifb, 1, ier)
+ if (ier .gt. 0) then
+ write (*,*) 'displayFITS: Error return from CDL'
+ goto 999
+ endif
+ else
+C --------------------------------------------------------
+C We've got an IRAF format image, go ahead and display it.
+C --------------------------------------------------------
+ call cfisiraf (imname, isiraf)
+ if (isiraf .gt. 0) then
+ call cfdisplayiraf (imname, 1, iframe, ifb, 1, ier)
+ if (ier .gt. 0) then
+ write (*,*) 'displayIRAF: Error return from CDL'
+ goto 999
+ endif
+ else
+C ----------------------------------
+C Unrecognized image, punt and exit.
+C ----------------------------------
+ write (*,*) 'Unrecognized image format'
+ endif
+ endif
+
+C ------------------
+C Clean up and exit.
+C ------------------
+999 continue
+ call cfclose (ier)
+ end
diff --git a/vendor/x11iraf/cdl/examples/ftvmark.f b/vendor/x11iraf/cdl/examples/ftvmark.f
new file mode 100644
index 00000000..a530895d
--- /dev/null
+++ b/vendor/x11iraf/cdl/examples/ftvmark.f
@@ -0,0 +1,301 @@
+C ==========================================================================
+C =
+C FTVMARK -- Example fortran program showing the use of the Client =
+C Display Library (CDL) Fortran interface for doing graphics overlay. In =
+C this simple program all input is prompted for on the command line. =
+C =
+C ==========================================================================
+
+
+ program ftvmark
+ include "../cdlftn.inc"
+ character*64 imname
+ character*132 imtdev
+
+C --------------------------
+C Initialize the CDL package
+C --------------------------
+ call getenv('IMTDEV',imtdev)
+ call cfopen(imtdev, ier)
+ if (ier .gt. 0) then
+ write (*,*) 'open: Error return from CDL'
+ goto 999
+ endif
+
+ write (*, "('Image Name: ', $)")
+ read (5, *) imname
+ write (*, "('Frame Number: ', $)")
+ read (5, *) iframe
+ write (*, "('Frame buffer configuration number: ', $)")
+ read (5, *) ifb
+
+C ----------------------------------------------------------
+C If we've got a FITS format image, go ahead and display it.
+C ----------------------------------------------------------
+ call cfisfits (imname, isfits)
+ if (isfits .gt. 0) then
+ call cfdisplayfits (imname, iframe, ifb, 1, ier)
+ if (ier .gt. 0) then
+ write (*,*) 'displayFITS: Error return from CDL'
+ goto 999
+ endif
+ else
+
+C --------------------------------------------------------
+C We've got an IRAF format image, go ahead and display it.
+C --------------------------------------------------------
+ call cfisiraf (imname, isiraf)
+ if (isiraf .gt. 0) then
+ call cfdisplayiraf (imname, 1, iframe, ifb, 1, ier)
+ if (ier .gt. 0) then
+ write (*,*) 'displayIRAF: Error return from CDL'
+ goto 999
+ endif
+ else
+C -------------------------------------------------------------
+C No valid image given, so map the current display for marking.
+C -------------------------------------------------------------
+ call cfmapframe (iframe)
+ endif
+ endif
+
+C ---------------------------------------------------------------
+C Now that we've got an image displayed or mapped, enter a cursor
+C loop to mark the image. We do this in a subroutine so all the
+C parameters needed are together.
+C ---------------------------------------------------------------
+ call markInteractive ()
+
+C -----------------
+C Clean up and exit
+C -----------------
+999 continue
+ call cfclose (ier)
+ end
+
+
+C =======================================================================
+C =
+C MARKINTERACTIVE -- Subroutine for processing the cursor loop. =
+C =
+C =======================================================================
+
+ subroutine markInteractive ()
+ include "../cdlftn.inc"
+ real angle, rx, ry, txsize
+ integer nx, ny, x, y, x2, y2, fill, size, color
+ integer number, radius, xrad, yrad, nannuli, sep
+ character key
+ character*64 cmd, str
+
+C -----------------------------------------------------------------
+C Allocate a 1024x1024 array for pixels. This is the largest frame
+C buffer we support in this example task
+C -----------------------------------------------------------------
+ character pix(1048576)
+
+C --------------------------------
+C Initialize the parameters to use
+C --------------------------------
+ color = 205
+ size = 10
+ fill = 0
+ angle = 0.0
+ txsize = 1.0
+ number = 1
+ radius = 11
+ xrad = 11
+ yrad = 6
+ nannuli = 3
+ sep = 5
+
+C ----------------------------------------------
+C Read a cursor keystroke telling us what to do.
+C ----------------------------------------------
+10 call cfreadcursor (0, rx, ry, key, ier)
+ if (ier .gt. 0) then
+ write (*,*) 'cfreadCursor: Error return from CDL'
+ goto 998
+ endif
+
+C ----------------------------------------------------------
+C Round the real cursor position to integer pixel positions.
+C ----------------------------------------------------------
+ x = nint (rx + 0.5)
+ y = nint (ry + 0.5)
+
+C --------------------------------------------------------------
+C Check the keystroke and take the appropriate action. Don't go
+C looking for an error condition.
+C --------------------------------------------------------------
+
+C --------------
+C Colon Commands
+C --------------
+ if (key .eq. ':') then
+C ----------------------------------------------
+C Read a three character command and value field
+C ----------------------------------------------
+ read (*,'(A3, i4)') cmd, ival
+
+C -------------------------
+C Process the colon command
+C -------------------------
+ if (cmd(1:3) .eq. 'ang') then
+ angle = real (ival)
+ else if (cmd(1:3) .eq. 'col') then
+ color = ival
+ else if (cmd(1:3) .eq. 'fil') then
+ fill = ival
+ else if (cmd(1:3) .eq. 'num') then
+ number = ival
+ else if (cmd(1:3) .eq. 'nan') then
+ nannuli = ival
+ else if (cmd(1:3) .eq. 'lab') then
+ label = ival
+ else if (cmd(1:3) .eq. 'sep') then
+ sep = ival
+ else if (cmd(1:3) .eq. 'siz') then
+ size = ival
+ else if (cmd(1:3) .eq. 'txs') then
+ txsize = ival
+ else if (cmd(1:3) .eq. 'xra') then
+ xrad = ival
+ else if (cmd(1:3) .eq. 'yra') then
+ yraf = ival
+ else if (cmd(1:3) .eq. 'pri') then
+ call cfreadframebuffer (pix, nx, ny, ier)
+ call cfprintpix ("lpr", pix, nx, ny, 1, ier)
+ else if (cmd(1:3) .eq. 'sta') then
+ print 201, angle, color
+ print 202, fill, number
+ print 203, nannuli, sep
+ print 204, size, txsize
+ print 205, xrad, yrad
+ print 206, label
+201 format ('angle = ',F5.3, t25, 'color = ',I5)
+202 format ('fill = ',I5, t25, 'number = ',I5)
+203 format ('nannuli = ',I5, t25, 'sep = ',I5)
+204 format ('size = ',I5, t25, 'txsize = ',F5.3)
+205 format ('xrad = ',I5, t25, 'yrad = ',I5)
+206 format ('fill = ',I5)
+ endif
+
+C -------------
+C Point Markers
+C -------------
+ else if (key .eq. 'p') then
+ call cfmarkpoint (x, y, 1, size, M_PLUS, color, ier)
+ else if (key .eq. 'x') then
+ call cfmarkpoint (x, y, 1, size, M_CROSS, color, ier)
+ else if (key .eq. '.') then
+ call cfmarkpoint (x, y, 1, size, M_POINT, color, ier)
+ else if (key .eq. '*') then
+ call cfmarkpoint (x, y, 1, size, M_STAR, color, ier)
+ else if (key .eq. '_') then
+ call cfmarkpoint (x, y, 1, size, M_HBLINE, color, ier)
+ else if (key .eq. '|') then
+ call cfmarkpoint (x, y, 1, size, M_VBLINE, color, ier)
+ else if (key .eq. 'o') then
+ call cfmarkpoint (x, y, 1, size, ior(M_CIRCLE,fill),
+ & color, ier)
+ else if (key .eq. 's') then
+ call cfmarkpoint (x, y, 1, size, ior(M_BOX,fill), color,
+ & ier)
+ else if (key .eq. 'v') then
+ call cfmarkpoint (x, y, 1, size, ior(M_DIAMOND,fill),
+ & color, ier)
+
+C -------------
+C Other Markers
+C -------------
+
+ else if (key .eq. 'b') then
+ print '("Hit another key to define the box ....")'
+ call cfreadcursor (0, rx, ry, key, ier)
+ x2 = nint (rx + 0.5)
+ y2 = nint (ry + 0.5)
+ call cfmarkbox (x, y, x2, y2, fill, color, ier)
+ else if (key .eq. 'c') then
+ print '("Hit another key to set the radius ....")'
+ call cfreadcursor (0, rx, ry, key, ier)
+ x2 = nint (rx + 0.5)
+ y2 = nint (ry + 0.5)
+ radius = nint (sqrt (real((x2-x)**2 + (y2-y)**2)))
+ call cfmarkcircle (x, y, radius, fill, color, ier)
+ else if (key .eq. 'd') then
+ call cfdeletemark (x, y, ier)
+ else if (key .eq. 'e') then
+ call cfmarkellipse (x, y, xrad, yrad, angle, fill, color, ier)
+ else if (key .eq. 'l') then
+ print '("Hit another key to set line endpoint ....")'
+ call cfreadcursor (0, rx, ry, key, ier)
+ x2 = nint (rx + 0.5)
+ y2 = nint (ry + 0.5)
+ call cfmarkline (x, y, x2, y2, color, ier)
+ else if (key .eq. 't') then
+ print '("Test string: ", $)'
+ read (*,'(A64)') str
+ call cfmarktext (x, y, str, txsize, angle, color, ier)
+ else if (key .eq. 'C') then
+ call cfmarkcircannuli (x, y, radius, nannuli, sep, ier)
+ else if (key .eq. 'D') then
+ call cfclearoverlay (ier)
+ else if (key .eq. 'E') then
+ call cfmarkellipannuli (x, y, xrad, yrad, angle, nannuli,
+ & sep, ier)
+
+C -------------
+C Misc Commands
+C -------------
+ else if (key .eq. '?') then
+ call printHelp ()
+ else if (key .eq. 'q') then
+ goto 998
+ endif
+
+C Loop back until we want to quit
+ goto 10
+
+998 continue
+ end
+
+
+C =======================================================================
+C =
+C PRINTHELP -- Utility subroutine to print a help summary for the task. =
+C =
+C =======================================================================
+
+ subroutine printHelp ()
+ print '(" Command Summary")'
+ print '(" ")'
+ print '(" :angle <real> - set ellipse or text angle")'
+ print '(" :color <int> - set marker color")'
+ print '(" :fill <0|1> - set fill option (zero or one)")'
+ print '(" :number <int> - set point number")'
+ print '(" :nannuli <int> - set number of annuli")'
+ print '(" :label <0|1> - set point label option")'
+ print '(" :sep <int> - set annuli separation (pixels)")'
+ print '(" :size <int> - set point marker size")'
+ print '(" :txsize <real> - set relative text size")'
+ print '(" :xrad <int> - set ellipse x radius")'
+ print '(" :yrad <int> - set ellipse y radius")'
+ print '(" :status - print current settings")'
+ print '(" :snap <file> - snap frame buffer as EPS to file")'
+ print '(" :print - print FB to default printer")'
+ print '(" ")'
+ print '("Point Markers:")'
+ print '(" v - diamond mark p - plus mark x - cross mark")'
+ print '(" . - point mark * - star mark _ - horiz dash")'
+ print '(" | - vert dash o - circle mark s - square mark")'
+ print '(" ")'
+ print '("Misc. Commands")'
+ print '(" ? - Print Help q - Quit")'
+ print '(" b - Box c - Circle")'
+ print '(" d - Delete marker e - Ellipse marker")'
+ print '(" l - Line t - Text string")'
+ print '(" C - Circular annuli D - Delete all markers")'
+ print '(" E - Elliptical annuli")'
+ print '(" ")'
+ end
diff --git a/vendor/x11iraf/cdl/examples/mosaic.c b/vendor/x11iraf/cdl/examples/mosaic.c
new file mode 100644
index 00000000..e31ee264
--- /dev/null
+++ b/vendor/x11iraf/cdl/examples/mosaic.c
@@ -0,0 +1,219 @@
+#include <stdio.h>
+#include <unistd.h>
+#include "cdl.h"
+
+/* MOSAIC -- Example task to demostrate a possible mosaic display
+ * application. Image names may optionally be drawn on each tile of
+ * the mosaic by specifying the -label and -color flags. The -pad flag
+ * can be used to put a space between images, -sample is used to sub-
+ * sample an image before display. Assumes all images are the same size.
+ *
+ * Examples:
+ * To display four images with a gap in a 1600x1600 frame buffer
+ * % mosaic -nx 2 -ny 2 -fbconfig 4 -pad 20 foo[1234].imh
+ * To display a set of images, subsampling each by 4 pixels
+ * % mosaic -nx 2 -ny 2 -pad -10 -sample 4 foo[1234].imh
+ *
+ * Usage:
+ * mosaic [-fbconfig N] [-frame N] [-color N] [-label] [-nozscale]
+ * [-raw -xdim N -ydim N -bitpix N [-hskip N] ]
+ * [-nx N] [-ny N] [-pad N] [-sample N]image1 image2 .....
+ */
+
+#define ABS(x) (x > 0 ? x : -x)
+
+
+main (argc, argv)
+int argc;
+char **argv;
+{
+ CDLPtr cdl;
+ char *fname = NULL, title[128];
+ int i, j, k, status=0, label=0, frame=1, fb=FB_AUTO, zscale=1;
+ int sample=1, pad=0, col=204, imx=0, imy=0, nimages, nim;
+ int ii, xinit, rowx, rowy, nnx, nny, fb_w, fb_h, nf, mx, my;
+ int raw = 0, bitpix=0, hskip=0;
+ int nx = 1, ny = 1;
+ float z1, z2;
+ unsigned char *pix = NULL;
+
+
+ /* Process the command line options. */
+ if (argc > 1) {
+ for (i=1; i < argc; i++) {
+ if (strncmp (argv[i], "-fbconfig",3) == 0)
+ fb = atoi (argv[++i]);
+ else if (strncmp (argv[i], "-frame",3) == 0)
+ frame = atoi (argv[++i]);
+ else if (strncmp (argv[i], "-color",3) == 0)
+ col = atoi (argv[++i]);
+ else if (strncmp (argv[i], "-label",4) == 0)
+ label = 1;
+ else if (strncmp (argv[i], "-nozscale",4) == 0)
+ zscale = 0;
+ else if (strncmp (argv[i], "-nx",3) == 0)
+ nx = atoi (argv[++i]);
+ else if (strncmp (argv[i], "-ny",3) == 0)
+ ny = atoi (argv[++i]);
+ else if (strncmp (argv[i], "-pad",4) == 0)
+ pad = atoi (argv[++i]);
+ else if (strncmp (argv[i], "-raw",4) == 0)
+ raw++;
+ else if (strncmp (argv[i], "-xdim",4) == 0)
+ imx = atoi (argv[++i]);
+ else if (strncmp (argv[i], "-ydim",4) == 0)
+ imy = atoi (argv[++i]);
+ else if (strncmp (argv[i], "-bitpix",4) == 0)
+ bitpix = atoi (argv[++i]);
+ else if (strncmp (argv[i], "-hskip",4) == 0)
+ hskip = atoi (argv[++i]);
+ else if (strncmp (argv[i], "-sample",4) == 0) {
+ sample = atoi (argv[++i]);
+ if (sample % 2) {
+ fprintf (stderr, "ERROR: Sample size must be even\n");
+ exit (-1);
+ }
+ } else
+ break;
+ }
+ } else {
+ printf("Usage:\n\tmosaic ");
+ printf("[-fbconfig N] [-frame N] [-color N] [-label] [-nozscale]");
+ printf("\n\t[-raw -xdim N -ydim N -bitpix N [-hskip N] ]");
+ printf("\n\t[-nx N] [-ny N] [-pad N] [-sample N] image1 ....\n");
+ exit (1);
+ }
+ nimages = argc - i;
+
+
+ /* Open the package and a connection to the server. */
+ if (!(cdl = cdl_open ((char *)getenv("IMTDEV"))) )
+ exit (-1);
+
+ /* Clear the frame to begin. */
+ (void) cdl_clearFrame (cdl);
+
+ /* Loop over each of the images in the list. */
+ nim = 0;
+ rowx = rowy = 0;
+ nnx = nny = 0;
+ for (k=0; k < ny && nim < nimages; k++) {
+ rowy += nny + pad;
+ for (rowx = xinit, j=0; j < nx && nim < nimages; j++) {
+
+ /* Get the image name for display. */
+ fname = argv[i++];
+
+ /* Figure out what kind of image it is and get the pixels. */
+ if (!raw && cdl_isIRAF (fname))
+ status = cdl_readIRAF (fname, 1, &pix, &imx, &imy, &bitpix,
+ title);
+ else if (!raw && cdl_isFITS (fname))
+ status = cdl_readFITS (fname, &pix, &imx, &imy, &bitpix,
+ title);
+ else {
+ if (raw) {
+ /* It's a raw data array, be sure we have everyting
+ * we need in order to read it.
+ */
+ if (imx == 0 || imy == 0 || bitpix == 0) {
+ fprintf(stderr, "ERROR: Use of '-raw' requires ");
+ fprintf(stderr, "'-xdim', '-ydim' and '-bitpix'\n");
+ status = 1;
+ } else {
+ FILE *fd;
+
+ /* Open the image file if we can. */
+ if (fd = fopen (fname, "r")) {
+
+ /* Seek to the offset specified. */
+ lseek (fileno(fd), (off_t) hskip, SEEK_SET);
+
+ /* Allocate the pixel pointer and read data. */
+ pix = (pix ? pix : (uchar *) malloc (
+ imx*imy*(ABS(bitpix) / 8)) );
+ fread (pix, ABS(bitpix)/8, imx*imy, fd);
+ fclose (fd);
+ } else
+ status = 1;
+ }
+ } else {
+ /* Didn't set the raw flag, and we don't know what
+ * it is....punt.
+ */
+ if (access (fname, F_OK) == 0)
+ fprintf (stderr, "'%s': unknown image format.\n",
+ fname);
+ else
+ fprintf (stderr, "'%s': image doesn't exist.\n", fname);
+ status = 1;
+ }
+ }
+ if (status) goto err_;
+
+ /* Compute subsampled image size. */
+ if (sample > 1)
+ nnx = imx / sample, nny = imy / sample;
+ else
+ nnx = imx, nny = imy;
+
+ /* Unless we asked for a specific FB size find one large enough
+ * to handle the mosaic. We don't check to be sure what's
+ * returned is really large enough.
+ */
+ if (nim == 0 && fb == FB_AUTO) {
+ cdl_selectFB (cdl, nx*nnx+(pad*(nx-1)), ny*nny+(pad*(ny-1)),
+ &fb, &fb_w, &fb_h, &nf, 1);
+ } else {
+ cdl_setFBConfig (cdl, fb);
+ cdl_lookupFBSize (cdl, fb, &fb_w, &fb_h, &nf);
+ }
+
+ /* Define a WCS for the frame. */
+ cdl_setWCS (cdl, "image mosaic", "", 1., 0., 0., -1., 0.,
+ (float) ny*imy+(pad*(ny+1)), 1., 255., 1);
+
+ /* The first time through figure out the placement so the
+ * entire mosaic is centered in the frame.
+ */
+ if (nim == 0) {
+ mx = (nx * nnx) + pad * (nx-1);
+ my = (ny * nny) + pad * (ny-1);
+ rowy = (fb_h - my) / 2;
+ xinit = rowx = (fb_w - mx) / 2;
+ }
+
+ /* Compute the zscaled imaged pixels. */
+ if (zscale) {
+ cdl_computeZscale (cdl, pix, imx ,imy, bitpix, &z1, &z2);
+ printf ("%s: z1=%g z2=%g\n", fname, z1, z2);
+ cdl_zscaleImage (cdl, &pix, imx ,imy, bitpix, z1, z2);
+ }
+
+ /* Subsample the image if requested. */
+ if (sample > 1) {
+ int l, m, n;
+
+ for (l=0, n=0; l < imy; l+=sample)
+ for (m=0; m < imx; m+=sample)
+ pix[n++] = pix[(l*imx)+m];
+ }
+
+ /* Write the image to the frame buffer. */
+ if (cdl_writeSubRaster (cdl, rowx, rowy, nnx, nny, pix))
+ goto err_;
+
+ /* Draw the image name as a label. */
+ if (label)
+ cdl_markText (cdl, rowx+10, rowy+10, fname, 1., 0., col);
+
+ nim++;
+ rowx += nnx + pad;
+ }
+ }
+
+ /* Close the package and clean up. */
+err_: cdl_close (cdl);
+ free ( (char *) pix);
+ exit (status);
+}
diff --git a/vendor/x11iraf/cdl/examples/tvmark.c b/vendor/x11iraf/cdl/examples/tvmark.c
new file mode 100644
index 00000000..db4413ce
--- /dev/null
+++ b/vendor/x11iraf/cdl/examples/tvmark.c
@@ -0,0 +1,397 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <math.h>
+#include "cdl.h"
+
+/*
+ * TVMARK -- Example task for displaying an marking images. This program
+ * can be used to either display an image and overlay points defined in
+ * a coordinate file, map an existing display frame for marking, or option-
+ * ally enter a cursor command loop after either of these providing other
+ * marking capability. All options support minimum match.
+ *
+ * Examples:
+ * % tvmark dpix.fits
+ * % tvmark -coords coords -color 205 dpix.fits
+ * % tvmark -frame 2
+ * % tvmark -coords coords -interactive dpix.fits
+ *
+ * Usage:
+ * tvmark [-frame N] [-fbconfig N] [-coords <file>] [-size N] [-color N]
+ * [-nolabel] [-fill] [-interactive] [image]
+ */
+
+
+static void tvmInteractive(), tvmPrintHelp();
+
+#define SZ_NAME 128
+
+
+/* typedef unsigned char uchar; */ /* Defined in 'cdl.h' */
+
+
+main (argc, argv)
+int argc;
+char *argv[];
+{
+ CDLPtr cdl;
+ char *fname = NULL, *cfname = NULL;
+ int i, status = 0, fill = 0, frame = 1, fb = FB_AUTO, zscale = 1;
+ int color = 201, label = 1, size = 9, interactive = 0;
+ float z1, z2;
+ int fb_w, fb_h, nf;
+ unsigned char *pix = NULL;
+
+ /* Process the command line options. */
+ if (argc > 1) {
+ for (i=1; i < argc; i++) {
+ if (strncmp (argv[i], "-color",4) == 0)
+ color = atoi (argv[++i]);
+ else if (strncmp (argv[i], "-coords",4) == 0)
+ cfname = argv[++i];
+ else if (strncmp (argv[i], "-fbconfig",3) == 0)
+ fb = atoi (argv[++i]);
+ else if (strncmp (argv[i], "-fill",4) == 0)
+ fill = 1;
+ else if (strncmp (argv[i], "-frame",3) == 0)
+ frame = atoi (argv[++i]);
+ else if (strncmp (argv[i], "-interactive",2) == 0)
+ interactive = 1;
+ else if (strncmp (argv[i], "-nolabel",4) == 0)
+ label = 0;
+ else if (strncmp (argv[i], "-nozscale",4) == 0)
+ zscale = 0;
+ else if (strncmp (argv[i], "-size",2) == 0)
+ size = atoi (argv[++i]);
+ else
+ fname = argv[i];
+ }
+ }
+
+ /* Open the package and a connection to the server. */
+ if (!(cdl = cdl_open ((char *)getenv("IMTDEV"))) )
+ exit (-1);
+
+ /* If an image was specified display it first, otherwise assume the
+ * image has already been loaded in the frame and mark that.
+ */
+ if (fname) {
+ if (cdl_isIRAF (fname))
+ status = cdl_displayIRAF (cdl, fname, 1, frame, fb, zscale);
+ else if (cdl_isFITS (fname))
+ status = cdl_displayFITS (cdl, fname, frame, fb, zscale);
+ else {
+ if (access (cfname, F_OK) == 0)
+ fprintf (stderr, "'%s': unknown image format.\n", fname);
+ else
+ fprintf (stderr, "'%s': image doesn't exist.\n", fname);
+ status = 1;
+ }
+ if (status) goto err_;
+ } else {
+
+ /* If we've requested a special frame buffer, set it now. */
+ if (fb > 0)
+ cdl_setFBConfig (cdl, fb);
+
+ /* Map the current display frame for use as an image. */
+ cdl_mapFrame (cdl, frame);
+ }
+
+ /* If a coordinate file was specified read the file and mark those
+ * coords with points.
+ */
+ if (cfname)
+ (void) cdl_markCoordsFile (cdl, cfname, M_STAR, size, color, label);
+
+ /* Lastly, start up an interactive cursor loop if needed. */
+ if (interactive)
+ tvmInteractive (cdl, label, fill, color, size);
+
+ /* Close the package and clean up. */
+err_: cdl_close (cdl);
+ exit (status);
+}
+
+
+/* TVMINTERACTIVE -- Process commands interactively. */
+
+static void
+tvmInteractive (cdl, label, fill, color, size)
+CDLPtr cdl;
+int label, fill, color, size;
+{
+ float angle = 0.0, rx, ry, txsize = 1.5, off = 0.5;
+ int nx, ny, i, x, y, x2, y2, font = F_ROMAN, mag = 3;
+ int number=1, radius=11, xrad=11, yrad=6, nannuli=3, sep=5;
+ int linewidth = 1, textwidth = 1, linestyle = 0, wcs = 0;
+ char key, *cp, cmd[SZ_NAME], str[SZ_NAME];
+ unsigned char *pix;
+
+
+ /* Process commands until a 'q' keystrke is hit.
+ */
+ while (cdl_readCursor (cdl, 0, &rx, &ry, &wcs, &key) != 'q') {
+ x = (int) (rx + off); /* convert to int pixels */
+ y = (int) (ry + off);
+
+ switch (key) {
+ case ':': /* process a colon command */
+ putchar (':');
+ fgets (str, 64, stdin);
+ for (i=0; str[i] != ' ' && str[i]; i++)
+ cmd[i] = str[i];
+ cmd[i++] = '\0';
+
+ if (strcmp (cmd, "angle") == 0)
+ angle = atof (&str[i]);
+ else if (strcmp (cmd, "color") == 0)
+ color = atoi (&str[i]);
+ else if (strcmp (cmd, "fill") == 0)
+ fill = atoi (&str[i]);
+ else if (strcmp (cmd, "font") == 0) {
+ switch (str[i]) {
+ case 'r': font = F_ROMAN; break;
+ case 'g': font = F_GREEK; break;
+ case 't': font = F_TIMES; break;
+ case 'f': font = F_FUTURA; break;
+ }
+ cdl_setFont (cdl, font);
+ } else if (strcmp (cmd, "number") == 0)
+ number = atoi (&str[i]);
+ else if (strcmp (cmd, "nannuli") == 0)
+ nannuli = atoi (&str[i]);
+ else if (strcmp (cmd, "label") == 0)
+ label = atoi (&str[i]);
+ else if (strcmp (cmd, "mag") == 0)
+ mag = atoi (&str[i]);
+ else if (strcmp (cmd, "sep") == 0)
+ sep = atoi (&str[i]);
+ else if (strcmp (cmd, "size") == 0)
+ size = atoi (&str[i]);
+ else if (strcmp (cmd, "txsize") == 0)
+ txsize = atof (&str[i]);
+ else if (strcmp (cmd, "radius") == 0)
+ radius = atoi (&str[i]);
+ else if (strcmp (cmd, "xrad") == 0)
+ xrad = atoi (&str[i]);
+ else if (strcmp (cmd, "yrad") == 0)
+ yrad = atoi (&str[i]);
+ else if (strcmp (cmd, "linewidth") == 0 ||
+ strcmp (cmd, "width") == 0) {
+ linewidth = atoi (&str[i]);
+ cdl_setLineWidth (cdl, linewidth);
+ } else if (strcmp (cmd, "linestyle") == 0 ||
+ strcmp (cmd, "style") == 0) {
+ linestyle = atoi (&str[i]);
+ cdl_setLineStyle (cdl, linestyle);
+ } else if (strcmp (cmd, "textwidth") == 0) {
+ textwidth = atoi (&str[i]);
+ cdl_setTextWidth (cdl, textwidth);
+ } else if (strcmp (cmd, "print") == 0) {
+ cdl_readFrameBuffer (cdl, &pix, &nx, &ny);
+ cdl_printPix (cdl, NULL, pix, nx, ny, 1);
+ } else if (strcmp (cmd, "snap") == 0) {
+ cdl_readFrameBuffer (cdl, &pix, &nx, &ny);
+ cdl_printPixToFile (cdl, &str[i], pix, nx, ny, 1);
+ } else if (strcmp (cmd, "status") == 0) {
+ printf ("angle = %-5.3g\tcolor = %d\t",angle, color);
+ printf ("fill = %-5d\tnumber = %d\n",fill, number);
+ printf ("nannuli = %-5d\tsep = %d\t",nannuli, sep);
+ printf ("size = %-5d\ttxsize = %g\n",size, txsize);
+ printf ("xrad = %-5d\tyrad = %d\t",xrad, yrad);
+ printf ("label = %-5d\tfont = %d\n",label, font);
+ printf ("linewidth = %-5d\tmag = %d\n",linewidth, mag);
+ printf ("textwidth = %-5d\tstyle = %d\n",
+ textwidth, linestyle);
+ }
+ break;
+
+ case '?':
+ tvmPrintHelp ();
+ break;
+
+ case 'p': /* plus mark */
+ cdl_markPoint (cdl, x, y, (label ? number++ : 0), size,
+ M_PLUS, color);
+ break;
+ case 'x': /* cross mark */
+ cdl_markPoint (cdl, x, y, (label ? number++ : 0), size,
+ M_CROSS, color);
+ break;
+ case '.': /* point mark */
+ cdl_markPoint (cdl, x, y, (label ? number++ : 0), size,
+ M_POINT, color);
+ break;
+ case '*': /* star mark */
+ cdl_markPoint (cdl, x, y, (label ? number++ : 0), size,
+ M_STAR, color);
+ break;
+ case '_': /* horiz dash mark */
+ cdl_markPoint (cdl, x, y, (label ? number++ : 0), size,
+ M_HBLINE, color);
+ break;
+ case '|': /* vert dash mark */
+ cdl_markPoint (cdl, x, y, (label ? number++ : 0), size,
+ M_VBLINE, color);
+ break;
+ case 'o': /* circle mark */
+ cdl_markPoint (cdl, x, y, (label ? number++ : 0), size,
+ M_CIRCLE|fill, color);
+ break;
+ case 's': /* square mark */
+ cdl_markPoint (cdl, x, y, (label ? number++ : 0), size,
+ M_BOX|fill, color);
+ break;
+ case 'v': /* diamond mark */
+ cdl_markPoint (cdl, x, y, (label ? number++ : 0), size,
+ M_DIAMOND|fill, color);
+ break;
+
+ case 'b': /* Box */
+ printf ("Hit another key to define the box...\n");
+ (void) cdl_readCursor (cdl, 0, &rx, &ry, &wcs, &key);
+ x2 = (int) (rx + off); y2 = (int) (ry + off);
+ cdl_markBox (cdl, x, y, x2, y2, fill, color);
+ break;
+ case 'c': /* Circle */
+ /*
+ printf ("Hit another key to set radius ...\n");
+ (void) cdl_readCursor (cdl, 0, &rx, &ry, &wcs, &key);
+ x2 = (int) (rx + off); y2 = (int) (ry + off);
+ radius = (int) sqrt ((double) ((x2-x)*(x2-x) + (y2-y)*(y2-y)));
+ */
+ cdl_markCircle (cdl, x, y, radius, fill, color);
+ break;
+ case 'd': /* Delete marker */
+ cdl_deleteMark (cdl, x, y);
+ break;
+ case 'e': /* Ellipse */
+ cdl_markEllipse (cdl, x, y, xrad, yrad, angle, fill, color);
+ break;
+ case 'l': /* Line */
+ printf ("Hit another key to set line endpoint...\n");
+ (void) cdl_readCursor (cdl, 0, &rx, &ry, &wcs, &key);
+ x2 = (int) (rx + off); y2 = (int) (ry + off);
+ cdl_markLine (cdl, x, y, x2, y2, color);
+ break;
+ case 't': /* Text string */
+ printf ("Text string: ");
+ fgets (str, 64, stdin);
+ for (cp = (char *)str; *cp != NULL && (char)*cp != '\n'; cp++)
+ ;
+ *cp = '\0';
+ cdl_markText (cdl, x, y, str, txsize, angle, color);
+ break;
+ case 'C': /* Circular annuli */
+ cdl_markCircAnnuli (cdl, x, y, radius, nannuli, sep, color);
+ break;
+ case 'D': /* Delete all markers */
+ cdl_clearOverlay (cdl);
+ break;
+ case 'E': /* Elliptical annuli */
+ cdl_markEllipAnnuli (cdl, x, y, xrad, yrad, angle, nannuli,
+ sep, color);
+ break;
+ case 'P': /* Polygon */
+ break;
+
+
+ case 'z':
+ /* A more complex example to display a rectangular region
+ * 'size' pixels wide to an area 'mag' times bigger on each
+ * side. The first keystroke in the center of the zoomed
+ * region, the second is the center of the magnified area.
+ * Corners are connected and boxes drawn around each area.
+ * An expensive oepration but you can a cute result.
+ */
+ printf ("Hit another key to position zoomed raster...\n");
+ (void) cdl_readCursor (cdl, 0, &rx, &ry, &wcs, &key);
+ x2 = (int) (rx + off); y2 = (int) (ry + off);
+
+ { register int i, j, ii, jj;
+ int llx = x - size / 2, lly = y - size / 2,
+ urx = x + size / 2, ury = y + size / 2;
+ int zllx = x2 - (mag*size) / 2, zlly = y2 - (mag*size) / 2,
+ zurx = x2 + (mag*size) / 2, zury = y2 + (mag*size) / 2;
+ uchar *ras = (uchar *) malloc (size*size);
+ uchar *zoom = (uchar *) malloc ((mag*size)*(mag*size));
+ uchar *rp, *zp, *line;
+
+ /* Read the image pixels and magnify it. */
+ cdl_readSubRaster (cdl, llx, lly, size, size, &ras);
+ rp = ras, zp = zoom;
+ for (i=0; i < size; i++) {
+ line = ras + i * size;
+ for (ii=0; ii < mag; ii++) {
+ for (j=0; j < size; j++) {
+ for (jj=0; jj < mag; jj++)
+ *zp++ = *rp;
+ rp++;
+ }
+ rp = line;
+ }
+ }
+
+ /* Draw a box around the zoom area and connect the corners
+ * to the zoomed subraster. */
+ cdl_markBox (cdl, llx, lly, urx, ury, 0, color);
+ cdl_markLine (cdl, llx, lly, zllx, zlly, color);
+ cdl_markLine (cdl, llx, ury, zllx, zury, color);
+ cdl_markLine (cdl, urx, lly, zurx, zlly, color);
+ cdl_markLine (cdl, urx, ury, zurx, zury, color);
+
+ /* Now draw the magnified raster and put a box around it.*/
+ cdl_writeSubRaster (cdl,zllx,zlly,mag*size,mag*size,zoom);
+ cdl_markBox (cdl, zllx, zlly, zurx, zury, 0, color);
+ }
+
+ default:
+ break;
+ }
+ }
+}
+
+
+/* TVMPRINTHELP -- Print a help summary. */
+
+static void
+tvmPrintHelp ()
+{
+ printf ("\t\t\tCommand Summary\n");
+ printf ("\n");
+ printf (" :angle <real> - set ellipse of text rotation angle\n");
+ printf (" :color <int> - set marker color\n");
+ printf (" :fill <0|1> - set fill option (zero or one)\n");
+ printf (" :font <font> - set text font (roman, greek, times)\n");
+ printf (" :number <int> - set point number\n");
+ printf (" :nannuli <int> - set number of annuli\n");
+ printf (" :label <0|1> - set point label option\n");
+ printf (" :linewidth <int> - set line width\n");
+ printf (" :linestyle <int> - set line style\n");
+ printf (" :textwidth <int> - set text width\n");
+ printf (" :mag <val> - set magnify value for 'z' keystroke\n");
+ printf (" :sep <int> - set annuli separation (pixels)\n");
+ printf (" :size <int> - set point marker size\n");
+ printf (" :txsize <real> - set relative text size\n");
+ printf (" :xrad <int> - set ellipse x radius\n");
+ printf (" :yrad <int> - set ellipse y radius\n");
+ printf (" :status - print current settings\n");
+ printf (" :snap <file> - snap frame buffer as EPS to file\n");
+ printf (" :print - print frame buffer to default printer\n");
+ printf ("\n");
+ printf ("Point Markers:\n");
+ printf (" v - diamond mark \tp - plus mark \t\tx - cross mark\n");
+ printf (" . - point mark \t* - star mark \t\t_ - horiz dash mark\n");
+ printf (" | - vert dash mark o - circle mark \ts - square mark\n");
+ printf ("\n");
+ printf ("Misc. Commands\n");
+ printf (" ? - Print Help \tq - Quit\n");
+ printf (" b - Box\t\tc - Circle\n");
+ printf (" d - Delete marker\te - Ellipse marker\n");
+ printf (" l - Line\t\tt - Text string\n");
+ printf (" C - Circular annuli D - Delete all markers\n");
+ printf (" E - Elliptical annuli\n");
+ printf (" z - zoom in on region\n");
+}