Added xgraph plotting program.

This commit is contained in:
pnenzi 2004-01-25 09:00:31 +00:00
parent 4b6bef82fe
commit e2d91d1909
61 changed files with 21673 additions and 4 deletions

View File

@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in
SUBDIRS = doc src man tests SUBDIRS = @XGRAPHDIR@ doc src man tests
EXTRA_DIST = FAQ acconfig.h autogen.sh NOTES BUGS AUTHORS ChangeLog \ EXTRA_DIST = FAQ acconfig.h autogen.sh NOTES BUGS AUTHORS ChangeLog \
DEVICES NEWS README DEVICES NEWS README

View File

@ -116,12 +116,20 @@ dnl --enable-numparams: define NUMPARAMS in the code. This is for .param support
AC_ARG_ENABLE(numparam, AC_ARG_ENABLE(numparam,
[ --enable-numparam Enable numparams library support, experimental *not in standard distribution*]) [ --enable-numparam Enable numparams library support, experimental *not in standard distribution*])
dnl --enable-xgraph: Compile the xgraph plotting program. Default is "no".
dnl Xgraph is a plotitng package for X11 once very popular.
AC_ARG_ENABLE(xgraph,
[ --enable-xgraph Enable xgraph compilation.])
dnl --with-readline: Includes GNU readline support into CLI. Default is "no". dnl --with-readline: Includes GNU readline support into CLI. Default is "no".
dnl Including readline into ngspice is a violation of GPL license. It's use dnl Including readline into ngspice is a violation of GPL license. It's use
dnl is discouraged. dnl is discouraged.
AC_ARG_WITH(readline, AC_ARG_WITH(readline,
[ --with-readline[=yes/no] Enable GNU readline support for CLI. Default=no.]) [ --with-readline[=yes/no] Enable GNU readline support for CLI. Default=no.])
dnl Enable maintainer commands only if requested dnl Enable maintainer commands only if requested
AM_MAINTAINER_MODE AM_MAINTAINER_MODE
@ -394,6 +402,16 @@ if test "$enable_pzdebug" = "yes"; then
AC_MSG_RESULT(WARNING: Pole/Zero analysis debug is enabled) AC_MSG_RESULT(WARNING: Pole/Zero analysis debug is enabled)
fi fi
if test "$enable_xgraph" = "yes"; then
AC_MSG_RESULT(Xgraph compilation enabled.)
AC_CONFIG_SUBDIRS(xgraph)
XGRAPHDIR="xgraph"
else
XGRAPHDIR=""
fi
AC_SUBST(XGRAPHDIR)
if test "$enable_ekv" = "yes"; then if test "$enable_ekv" = "yes"; then
AC_MSG_RESULT(Model EKV included) AC_MSG_RESULT(Model EKV included)
AC_DEFINE(HAVE_EKV) AC_DEFINE(HAVE_EKV)
@ -502,9 +520,11 @@ AC_SUBST(NUMPARAMDIR)
AC_SUBST(NUMPARAMLIB) AC_SUBST(NUMPARAMLIB)
dnl ---- Option to include GNU readline support in ngspice CLI ---- dnl ---- Option to include GNU readline support in ngspice CLI ----
if test "$with_readline" != "yes"; then dnl ---- Default: disabled. ----
AC_MSG_RESULT(GNU readline disabled.) dnl ---- Hope to see in the future readline replacement. ----
if test "$with_readline" = "yes"; then
AC_MSG_RESULT(GNU readline disabled.)
else else
AC_MSG_RESULT(Checking for readline:) AC_MSG_RESULT(Checking for readline:)
AC_CHECK_HEADERS([readline/readline.h readline/history.h], AC_CHECK_HEADERS([readline/readline.h readline/history.h],
@ -515,6 +535,8 @@ else
[AC_MSG_ERROR(Couldn't find readline libraries.)]) [AC_MSG_ERROR(Couldn't find readline libraries.)])
fi fi
AC_OUTPUT( \ AC_OUTPUT( \
Makefile \ Makefile \
doc/Makefile \ doc/Makefile \

190
xgraph/INSTALL Normal file
View File

@ -0,0 +1,190 @@
XGRAPH INSTALLATION
===================
Quick Start
-----------
- download the source code
- extract tar file with gzip (gnu zip, not pkzip) and tar
(typically "gunzip <xgraph.tar.gz | tar xvf -")
- run "./configure"
see the file README.CONFIGURE for
- run "make"
- run "make install"
To install xgraph in a special location (perhaps if you don't have
root access), or if you're not familiar with GNU configure, see "Basic
Installation" below.
If you have installation problems or questions, check:
<http://www-mash.cs.berkeley.edu/ns/ns-problems.html#xgraph>
BEFORE posting to the mailing list. Mailing list info can be found at
the xgraph web page.
Xgraph-specific configure options
---------------------------------
Use
--with-additional-includes=/path/to/includes
and
--with-additional-libs=/path/to/libs
if configure can't find particular includes or libraries on your
system.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.

57
xgraph/Makefile.am Normal file
View File

@ -0,0 +1,57 @@
## Process this file with automake to produce Makefile.in
# Copyright (C) 1999 by John Heidemann <johnh@isi.edu>
## shallow
AUTOMAKE_OPTIONS = 1.0 foreign
bin_PROGRAMS = xgraph
xgraph_c_sources = \
xgraph.c xgX.c hard_devices.c dialog.c hpgl.c \
ps.c idraw.c xtb.c st.c params.c alloc.c draw.c \
init.c read.c tgif.c derivative.c \
copyright.h \
general.h \
hard_devices.h \
params.h \
plotter.h \
st.h \
xgout.h \
xgraph.h \
xtb.h
xgraph_SOURCES = $(xgraph_c_sources)
man_MANS = xgraph.man
EXTRA_DIST=\
$(man_MANS) \
README.ANNOUNCE \
README.GENERAL \
README.HARDCOPY \
README.INSTALL \
README.NEWFEATURES \
bitmaps/dot.11 \
bitmaps/gray \
bitmaps/mark1.11 \
bitmaps/mark2.11 \
bitmaps/mark3.11 \
bitmaps/mark4.11 \
bitmaps/mark5.11 \
bitmaps/mark6.11 \
bitmaps/mark7.11 \
bitmaps/mark8.11 \
examples/Animation.xg \
examples/bar.xg \
examples/surface.xg \
examples/surface2.xg \
examples/surface3.xg \
examples/xgtest.xg
# C_WARNINGS = -Wall
C_WARNINGS =
CFLAGS=$(ADDITIONAL_INCLUDES) $(C_WARNINGS) -g $(X_CFLAGS)
xgraph_LDADD= $(ADDITIONAL_LIBS) $(X_LIBS) $(X_PRE_LIBS) $(X_EXTRA_LIBS) -lX11 -lm

444
xgraph/Makefile.in Normal file
View File

@ -0,0 +1,444 @@
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# Copyright (C) 1999 by John Heidemann <johnh@isi.edu>
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
ADDITIONAL_INCLUDES = @ADDITIONAL_INCLUDES@
ADDITIONAL_LIBS = @ADDITIONAL_LIBS@
CC = @CC@
MAKEINFO = @MAKEINFO@
PACKAGE = @PACKAGE@
VERSION = @VERSION@
AUTOMAKE_OPTIONS = 1.0 foreign
bin_PROGRAMS = xgraph
xgraph_c_sources = xgraph.c xgX.c hard_devices.c dialog.c hpgl.c ps.c idraw.c xtb.c st.c params.c alloc.c draw.c init.c read.c tgif.c derivative.c copyright.h general.h hard_devices.h params.h plotter.h st.h xgout.h xgraph.h xtb.h
xgraph_SOURCES = $(xgraph_c_sources)
man_MANS = xgraph.man
EXTRA_DIST = $(man_MANS) README.ANNOUNCE README.GENERAL README.HARDCOPY README.INSTALL README.NEWFEATURES bitmaps/dot.11 bitmaps/gray bitmaps/mark1.11 bitmaps/mark2.11 bitmaps/mark3.11 bitmaps/mark4.11 bitmaps/mark5.11 bitmaps/mark6.11 bitmaps/mark7.11 bitmaps/mark8.11 examples/Animation.xg examples/bar.xg examples/surface.xg examples/surface2.xg examples/surface3.xg examples/xgtest.xg
# C_WARNINGS = -Wall
C_WARNINGS =
CFLAGS = $(ADDITIONAL_INCLUDES) $(C_WARNINGS) -g $(X_CFLAGS)
xgraph_LDADD = $(ADDITIONAL_LIBS) $(X_LIBS) $(X_PRE_LIBS) $(X_EXTRA_LIBS) -lX11 -lm
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = autoconf.h
CONFIG_CLEAN_FILES =
PROGRAMS = $(bin_PROGRAMS)
DEFS = @DEFS@ -I. -I$(srcdir) -I.
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
X_CFLAGS = @X_CFLAGS@
X_LIBS = @X_LIBS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
xgraph_OBJECTS = xgraph.o xgX.o hard_devices.o dialog.o hpgl.o ps.o \
idraw.o xtb.o st.o params.o alloc.o draw.o init.o read.o tgif.o \
derivative.o
xgraph_DEPENDENCIES =
xgraph_LDFLAGS =
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
manmdir = $(mandir)/manm
MANS = $(man_MANS)
NROFF = nroff
DIST_COMMON = README ./stamp-h.in INSTALL Makefile.am Makefile.in \
aclocal.m4 autoconf.h.in configure configure.in install-sh missing \
mkinstalldirs
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
SOURCES = $(xgraph_SOURCES)
OBJECTS = $(xgraph_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .o .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
$(ACLOCAL_M4): configure.in
cd $(srcdir) && $(ACLOCAL)
config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
autoconf.h: stamp-h
@if test ! -f $@; then \
rm -f stamp-h; \
$(MAKE) stamp-h; \
else :; fi
stamp-h: $(srcdir)/autoconf.h.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES= CONFIG_HEADERS=autoconf.h \
$(SHELL) ./config.status
@echo timestamp > stamp-h 2> /dev/null
$(srcdir)/autoconf.h.in: $(srcdir)/stamp-h.in
@if test ! -f $@; then \
rm -f $(srcdir)/stamp-h.in; \
$(MAKE) $(srcdir)/stamp-h.in; \
else :; fi
$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOHEADER)
@echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
mostlyclean-hdr:
clean-hdr:
distclean-hdr:
-rm -f autoconf.h
maintainer-clean-hdr:
mostlyclean-binPROGRAMS:
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
distclean-binPROGRAMS:
maintainer-clean-binPROGRAMS:
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(bindir)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
if test -f $$p; then \
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
list='$(bin_PROGRAMS)'; for p in $$list; do \
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
done
.c.o:
$(COMPILE) -c $<
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
xgraph: $(xgraph_OBJECTS) $(xgraph_DEPENDENCIES)
@rm -f xgraph
$(LINK) $(xgraph_LDFLAGS) $(xgraph_OBJECTS) $(xgraph_LDADD) $(LIBS)
install-manm:
$(mkinstalldirs) $(DESTDIR)$(manmdir)
@list='$(manm_MANS)'; \
l2='$(man_MANS)'; for i in $$l2; do \
case "$$i" in \
*.m*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) $$file $(DESTDIR)$(manmdir)/$$inst"; \
$(INSTALL_DATA) $$file $(DESTDIR)$(manmdir)/$$inst; \
done
uninstall-manm:
@list='$(manm_MANS)'; \
l2='$(man_MANS)'; for i in $$l2; do \
case "$$i" in \
*.m*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f $(DESTDIR)$(manmdir)/$$inst"; \
rm -f $(DESTDIR)$(manmdir)/$$inst; \
done
install-man: $(MANS)
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-manm
uninstall-man:
@$(NORMAL_UNINSTALL)
$(MAKE) $(AM_MAKEFLAGS) uninstall-manm
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) autoconf.h.in $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)autoconf.h.in$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags autoconf.h.in $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
-rm -rf $(distdir)
GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
mkdir $(distdir)/=build
mkdir $(distdir)/=inst
dc_install_base=`cd $(distdir)/=inst && pwd`; \
cd $(distdir)/=build \
&& ../configure --srcdir=.. --prefix=$$dc_install_base \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) dist
-rm -rf $(distdir)
@banner="$(distdir).tar.gz is ready for distribution"; \
dashes=`echo "$$banner" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
echo "$$dashes"
dist: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
dist-all: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
distdir: $(DISTFILES)
-rm -rf $(distdir)
mkdir $(distdir)
-chmod 777 $(distdir)
$(mkinstalldirs) $(distdir)/bitmaps $(distdir)/examples
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
alloc.o: alloc.c
derivative.o: derivative.c xgraph.h autoconf.h xgout.h
dialog.o: dialog.c copyright.h xgout.h xgraph.h autoconf.h \
hard_devices.h xtb.h params.h
draw.o: draw.c copyright.h xgraph.h autoconf.h xgout.h xtb.h \
hard_devices.h params.h
hard_devices.o: hard_devices.c copyright.h xgout.h hard_devices.h \
params.h xgraph.h autoconf.h
hpgl.o: hpgl.c copyright.h xgraph.h autoconf.h xgout.h plotter.h
idraw.o: idraw.c hard_devices.h xgout.h
init.o: init.c copyright.h xgraph.h autoconf.h xgout.h xtb.h \
hard_devices.h params.h
params.o: params.c st.h params.h xgraph.h autoconf.h xgout.h \
hard_devices.h
ps.o: ps.c copyright.h xgraph.h autoconf.h xgout.h
read.o: read.c copyright.h xgraph.h autoconf.h xgout.h xtb.h \
hard_devices.h params.h
st.o: st.c copyright.h st.h xgraph.h autoconf.h xgout.h
tgif.o: tgif.c hard_devices.h xgout.h
xgX.o: xgX.c copyright.h xgout.h params.h xgraph.h autoconf.h \
bitmaps/dot.11 bitmaps/mark1.11 bitmaps/mark2.11 \
bitmaps/mark3.11 bitmaps/mark4.11 bitmaps/mark5.11 \
bitmaps/mark6.11 bitmaps/mark7.11 bitmaps/mark8.11
xgraph.o: xgraph.c copyright.h xgraph.h autoconf.h xgout.h xtb.h \
hard_devices.h params.h
xtb.o: xtb.c xtb.h copyright.h
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
all-recursive-am: autoconf.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
install-exec-am: install-binPROGRAMS
install-exec: install-exec-am
install-data-am: install-man
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-binPROGRAMS uninstall-man
uninstall: uninstall-am
all-am: Makefile $(PROGRAMS) $(MANS) autoconf.h
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/manm
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-hdr mostlyclean-binPROGRAMS \
mostlyclean-compile mostlyclean-tags \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-hdr clean-binPROGRAMS clean-compile clean-tags \
clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-hdr distclean-binPROGRAMS distclean-compile \
distclean-tags distclean-generic clean-am
distclean: distclean-am
-rm -f config.status
maintainer-clean-am: maintainer-clean-hdr maintainer-clean-binPROGRAMS \
maintainer-clean-compile maintainer-clean-tags \
maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
-rm -f config.status
.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile install-manm uninstall-manm install-man \
uninstall-man tags mostlyclean-tags distclean-tags clean-tags \
maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \
installcheck-am installcheck all-recursive-am install-exec-am \
install-exec install-data-am install-data install-am install \
uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

26
xgraph/README Normal file
View File

@ -0,0 +1,26 @@
xgraph 12.1
<http://www-mash.cs.berkeley.edu/vint/xgraph>
distributed by the VINT project
<http://netweb.usc.edu/vint/>
Welcome to the VINT release of xgraph.
Xgraph is an X-Windows application that includes:
- interactive plotting and graphing, by David Harrison of UC Berkeley
- animation and deritives, added by Paul Walker of NCSA
- portability and bug fixes, by the VINT project
See the file "INSTALL" for installation instructions.
If you have installation problems or questions, check:
<http://www-mash.cs.berkeley.edu/ns/ns-problems.html#xgraph>
BEFORE posting to the mailing list. Mailing list info can be found at
the xgraph web page.

84
xgraph/README.ANNOUNCE Normal file
View File

@ -0,0 +1,84 @@
A new version of xgraph is now available. Xgraph is a popular
two-dimensional plotting program that accepts data in a form similar
to the unix program graph and displays line graphs, scatter plots, or
bar charts on an X11 display. These graphs are fully annotated with a
title, axis numbering and labels, and a legend. Zooming in on regions
of a graph is supported. The program can automatically generate
hardcopy output to Postscript printers and HPGL plotters. A new
option allows xgraph output to be directly pasted into idraw for
further annotation.
This program is NOT a widget. It is a stand-alone program written at
the Xlib level and should run on any machine with a reasonable
implementation of X11 release 3 or later. The source for the program
is available through anonymous ftp to shambhala.Berkeley.EDU
(128.32.132.54):
% ftp shambhala.Berkeley.EDU
Name: anonymous
Password: <anything non-null>
ftp> cd pub
ftp> binary
ftp> get xgraph-11.tar.Z
ftp> quit
% uncompress xgraph-11.tar.Z
% tar xf xgraph-11.tar
This will create a directory called xgraph-11. In that directory
you will find a file called README.INSTALL that contains directions
for building the program. I plan to submit the sources to the
moderator of comp.sources.x after I have tested the program under X11
release 4 (meaning a few weeks after the X Consortium releases the
distribution).
Those who do not have ftp access can obtain the source for xgraph
using a mail archive system I have installed on dent.Berkeley.EDU
(courtesy of Brian Reid at Digital). An example is given below:
To: ucbvax!dent!archive-server
Subject: send programs xgraph.shar.01 xgraph.shar.02
send programs xgraph.shar.03 xgraph.shar.04 xgraph.shar.05
send programs xgraph.shar.06 xgraph.shar.07 xgraph.shar.08
The archive server will send you these files as time and load permits.
They are standard shell archives and can be unpacked by running them
through /bin/sh (in order). If you would like to know more about the
mail server, send a message with a subject of "help". I am afraid I
am no mail wizard so I cannot help you determine a path to dent.
For those familar with xgraph, the most important changes are
summarized below:
- A new data reader has been written that allows discontinuous data in
each data set. Also, nearly all of the display options for xgraph
can be set in the data file. The reader is also more forgiving
about blank lines and excess white space.
- A new option has been added to the Postscript hardcopy facility to
allow xgraph output to be included in other documents using psfig.
As mentioned above, xgraph output can be imported into idraw for
further annotation if necessary.
- I received lots of complaints about the way xgraph obtains fonts and
visuals. The new xgraph uses a much simpler scheme to obtain these
resources and has fall back code to insure it will run in almost any
situation.
- Options handling has been cleaned up substantially. Xgraph options
can now be specified as X resources (~/.Xdefaults), in the data
file, or on the command line.
- Drawing is somewhat faster on some servers due to a better choice of
initial defaults.
Please send all bug reports, questions, comments or suggestions to
the electronic address below.
David Harrison
UC Berkeley Electronics Research Lab
(davidh@ic.Berkeley.EDU, ...!ucbvax!ucbcad!davidh)

74
xgraph/README.GENERAL Normal file
View File

@ -0,0 +1,74 @@
This directory contains source for the X11 version of xgraph, a
two-dimensional data plotting program. Those familar with the X10
version of this program will find that is completely compatible.
However, there are a few important notes and changes you should
be aware of:
1. The program was developed and tested on X11 release 3 on a
color VAXstation GPX and on a color DECstation 3100. It should
work on most other servers without change but has not been tested
on these other configurations. If you have problems, please send
a note to:
davidh@ic.Berkeley.EDU
or
...!ucbvax!ucbcad!davidh
2. This version includes an improved hardcopy facility.
An additional option, "Include in Document", has been added since
the first X11 release. A new output type, Idraw, has also been
added. See the manual page for details about the hardcopy dialog.
3. There are several changes to the input format for xgraph. However,
the new format is compatible with the old and there should be no
problem running xgraph with old data sets. The new form allows
discontinuous data in data sets (using the "move" operator),
parameter specification using a format similar to that found in the
~/.Xdefaults file, and comments. See the manual page for details.
4. In some cases, xgraph uses dashed lines to distinguish different
data sets. Some servers are notoriously slow at rendering dashed
lines. Be prepared for a significantly reduced performance on
those servers.
5. Xgraph now uses software clipping to clip data to its display
windows. This means you should be able to zoom in much farther
on large data sets than was possible under the X10 version.
6. Xgraph used to use some rather sophisticated heuristics to handle
visuals and colormaps. Due to complaints, I have removed these
heuristics. Xgraph will display on whatever screen is specified in
the DISPLAY environment variable or on the command line.
7. I plan to add full ICCCM support when X11 release 4 becomes
available. In the meantime, the program should work under most
window mangers (it is somewhat conformant already).
8. As a follow-on to (7), note that the operation of the program
is heavily influenced by your choice of window managers. Focus
based window managers (like dxwm from Digital) will require you
to set focus in the text input slots of the hardcopy dialog box.
9. Many people have sent me notes about the state of code of xgraph.
Xgraph was constructed initially as a challenge from another
programmer here at Berkeley. The first version of the program was
written in an afternoon. Since then, the program has "evolved"
quite dramatically. Since this is not my primary work, I generally
tacked on features quickly as the need became apparent. Some day,
I would truely like to rewrite it. Until then, please bear with
me.
10. Since xgraph has become quite popular, those in positions of power
have recommended I add the standard UC Berkeley copyright notice
to this software. See copyright.h for details.
11. Many people have sent me suggestions and comments. Some have
written new code or sent patches to fix problems. I greately
appreciate these contributions. Special thanks go to Beorn Johnson
and Alan Kramer for the idraw output code.
David Harrison
UC Berkeley Electronics Research Lab
(davidh@ic.Berkeley.EDU, ...!ucbvax!ucbcad!davidh)

288
xgraph/README.HARDCOPY Normal file
View File

@ -0,0 +1,288 @@
/*
* Hardcopy Interface for Xgraph
*
* Major differences from first version:
* A flags argument has been added to xg_init(). This new argument
* is used to specify a new binary option: D_DOCU. See below
* for details.
*
* Four new parameters are passed to the device initialization routine:
* title_family, title_size, axis_family, and axis_size. See the
* description of xg_init() for details.
*
* Clipping is done automatically by xgraph. The xg_clip() routine
* is obsolete.
*
* The xg_line() routine has become the xg_seg() routine. It now
* draws segments rather than a series of lines.
*
* A new field (max_segs) in the device structure now specifies
* the maximum number of segments the device can handle in a group.
*/
/*
* Adding an output device to xgraph
*
* Step 1
* Write versions of the following routines for your device:
* xg_init(), xg_text(), xg_seg(), xg_dot(), and xg_end().
* The interface and function of these routines are described
* in detail below. These routines should be named according
* to your device. For example, the initialization routine
* for the Postscript output device is psInit(). Also, name
* your source file after your device (e.g. the postscript
* routines are in the file ps.c). Instructions continue
* after the description of the interface routines.
*
* The definitions below are quoted here as a convenience. In
* your output module, you can include "xgout.h" to obtain these
* definitions.
*/
#define D_COLOR 0x01
#define ERRBUFSIZE 2048
#define D_DOCU 0x01
typedef struct xg_out {
int dev_flags; /* Device characteristic flags */
int area_w, area_h; /* Width and height in pixels */
int bdr_pad; /* Padding from border */
int axis_pad; /* Extra space around axis labels */
int tick_len; /* Length of a tick mark */
int legend_pad; /* Top of legend text to legend line */
int axis_width; /* Width of big character of axis font */
int axis_height; /* Height of big character of axis font */
int title_width; /* Width of big character of title font */
int title_height; /* Height of big character of title font */
int max_segs; /* Maximum number of segments in group */
void (*xg_text)(); /* Draws text at a location */
void (*xg_seg)(); /* Draws a series of segments */
void (*xg_dot)(); /* Draws a dot or marker at a location */
void (*xg_end)(); /* Stops the drawing sequence */
char *user_state; /* User supplied state information */
} xgOut;
int xg_init(strm, width, height, title_family, title_size,
axis_family, axis_size, out_info, errmsg)
FILE *strm; /* Output stream */
int width, height; /* Size of space (microns) */
char *title_family; /* Name of title font family */
double title_size; /* Title font height (points) */
char *axis_family; /* Name of axis font family */
double axis_size; /* Axis font height (points) */
int flags; /* Flags (see below) */
xgOut *out_info; /* Device info (RETURN) */
char errmsg[ERRBUFSIZE]; /* Error message area */
/*
* This routine is called by xgraph just before drawing is to
* begin. The desired size of the plot is given by `width'
* and `height'. The parameters `title_family', `title_size',
* `axis_family', and `axis_size' specify the names of the
* title and axis fonts and their vertical sizes (in points).
* These parameters can be ignored if your device does not
* support multiple fonts. The `flags' argument specifies
* certain binary flags to the output routines. These
* flags are:
* D_DOCU:
* If this flag is set, it indicates the user has specified that
* the output will be included in some larger document. Devices
* may choose to use this information to produce output that
* can be integrated into documents with less effort. For example,
* the Postscript output routines produce bounding box information
* when this flag is set.
* The routine should fill in all of the fields of `out_info' with
* appropriate values. The values are described below:
* area_w, area_h:
* Size of the drawing space in device coordinates.
* This should take in account the requested area
* given by `width', and `height'.
* bdr_pad:
* Xgraph will leave this number of device coordinates around
* all of the outer edges of the graph.
* axis_pad:
* Additional space around axis labels (in devcoords)
* so that the labels do not appear crowded.
* legend_pad:
* Space (in devcoords) from the top of legend text to
* the representative line drawn above the legend text.
* tick_len:
* Size of a tick mark placed on axis (in devcoords)
* axis_width:
* An estimate of the width of a large character in
* the axis font (in devcoords). This can be an overestimate. An
* underestimate may produce bad results.
* axis_height:
* An estimate of the height of a large character in
* the axis labeling font (in devcoords).
* title_width, title_height:
* Same as above except for the title font.
* max_segs:
* Due to buffering constraints, some devices may not be able to
* handle massive segment lists. This parameter tells xgraph not
* to send more than `max_segs' segments in one request.
* Output to the device should be written to the stream `strm'.
* The functions are described individually below. After filling
* in the parameters and setting the function pointers, the routine
* should initialize its drawing state and store any extra needed
* information in `user_state'. This value will be passed to all
* other routines during the drawing sequence. If the device
* cannot initialize, it should return a zero status and fill
* `errmsg' with an informative error message.
*/
/* Text justifications */
#define T_CENTER 0
#define T_LEFT 1
#define T_UPPERLEFT 2
#define T_TOP 3
#define T_UPPERRIGHT 4
#define T_RIGHT 5
#define T_LOWERRIGHT 6
#define T_BOTTOM 7
#define T_LOWERLEFT 8
/* Text styles */
#define T_AXIS 0
#define T_TITLE 1
void xg_text(user_state, x, y, text, just, style)
char *user_state; /* Value set in xg_init */
int x, y; /* Text position (pixels) */
char *text; /* Null terminated text */
int just; /* Justification (above) */
int style; /* Text style (above) */
/*
* This routine should draw text at the indicated position using
* the indicated justification and style. The justification refers
* to the location of the point in reference to the text. For example,
* if just is T_LOWERLEFT, (x,y) should be located at the lower left
* edge of the text string.
*/
/* Line Styles */
#define L_AXIS 0
#define L_ZERO 1
#define L_VAR 2
void xg_seg(user_state, ns, seglist, width, style, lappr, color)
char *user_state; /* Value set in xg_init */
int ns; /* Number of segments */
XSegment *seglist; /* X array of segments */
int width; /* Width of lines */
int style; /* See above */
int lappr; /* Line appearence */
int color; /* Line color (if any) */
/*
* This routine draws a number of line segments at the points
* given in `seglist'. Note that contiguous segments need not share
* endpoints but often do. All segments should be `width' devcoords wide
* and drawn in style `style'. The `width' may be zero meaning that
* the line should be drawn as thin as the device allows. If `style' is
* L_VAR, the parameters `color' and `lappr' should be used to draw the
* line. Both parameters vary from 0 to 7. If the device is capable of
* color, `color' varies faster than `style'. If the device
* has no color, `style' will vary faster than `color' and
* `color' can be safely ignored. However, if the
* the device has more than 8 line appearences, the two can
* be combined to specify 64 line style variations.
* Xgraph promises not to send more than the `max_segs' in the
* xgOut structure passed back from xg_init().
*/
/* Marker styles */
#define P_PIXEL 0
#define P_DOT 1
#define P_MARK 2
void xg_dot(user_state, x, y, style, type, color)
char *user_state; /* Value set in xg_init */
int x, y; /* Location in pixel units */
int style; /* Dot style */
int type; /* Type of marker */
int color; /* Marker color (if any) */
/*
* This routine should draw a marker at location `x,y'. If the
* style is P_PIXEL, the dot should be a single pixel. If
* the style is P_DOT, the dot should be a reasonably large
* dot. If the style is P_MARK, it should be a distinguished
* mark which is specified by `type' (0-7). If the output
* device is capable of color, the marker should be drawn in
* `color' (0-7) which corresponds with the color for xg_line.
*/
void xg_end(user_state)
char *user_state;
/*
* This routine is called after a drawing sequence is complete.
* It can be used to clean up the user state and set the device
* state appropriately. This routine is optional in the structure.
*/
/*
* Adding an output device to xgraph
*
* Step 2
* Edit the file hard_devices.c. Declare your initialization
* function and add your device to the list of devices,
* hard_devices[]. The structure hard_dev is described below
* and is defined in hard_devices.h:
*/
#define MFNAME 25
typedef enum hard_dev_docu_defn { NONE, NO, YES } hard_dev_docu;
typedef struct hard_dev {
char *dev_name; /* Device name */
int (*dev_init)(); /* Initialization function */
char *dev_spec; /* Default pipe program */
char dev_file[MFNAME]; /* Default file name */
char dev_printer[MFNAME]; /* Default printer name */
double dev_max_dim; /* Default maximum dimension (cm) */
char dev_title_font[MFNAME];/* Default name of title font */
double dev_title_size; /* Default size of title font (pnts) */
char dev_axis_font[MFNAME]; /* Default name of axis font */
double dev_axis_size; /* Default size of axis font (pnts) */
hard_dev_docu dev_docu; /* Document predicate */
};
/*
* dev_spec:
* The dev_spec field should be a command that directly outputs to
* your device. The command should contain one %s directive that
* will be filled in with the name of the device from the hardcopy
* dialog.
* dev_file:
* The default file to write output to if the user selects `To File'.
* dev_printer:
* The default printer to write output to if the user selects
* `To Device'.
* dev_max_dim:
* The default maximum dimension for the device in centimeters.
* dev_title_font, dev_title_size:
* The default title font and size. Sizes are specified in
* points (1/72 inch).
* dev_axis_font, dev_axis_size:
* The default axis font and size.
* dev_docu
* Some devices may require extra preparation when including xgraph
* output in a document. This parameter indicates the default
* value of the Document predicate in the hardcopy dialog. If
* the value is NONE, the device doesn't need any special preparation
* for producing output for inclusion in documents.
*/
/*
* Adding an output device to xgraph
*
* Step 3
* Edit the file Makefile. Add your source file to the SRC variable
* and the corresponding object file to the OBJ variable. Finally,
* remake xgraph. Your device should now be available in the
* hardcopy dialog.
*/

79
xgraph/README.INSTALL Normal file
View File

@ -0,0 +1,79 @@
This file contains instructions for building the X11 version of xgraph.
When unpacked, the source is distributed in three directories:
xgraph-11 Source for the program
xgraph-11/bitmaps Bitmaps used for cursors and markers
xgraph-11/examples Sample data for trying out the program
First, you should examine the file hard_devices.c. This file lists
the default hardcopy parameters for each hardcopy output device. Some
of these defaults are site-specific and should be taylored to your
site. For example, at our site, the default HPGL plotter is called
"paper" and the default Postscript printer is called "lps40". You can
change these names in this file. See hard_devices.h for a description
of the initialization fields.
If you do not like the default values for xgraph options, you can
change these by editing the default values as listed on the third page
in xgraph.c. Remember that changing these values changes the default
behaviour for everyone running the program. Personal preference
should be left for specification in the user's Xresources or Xdefaults
file.
An Imakefile is provided for compiling the program in an X11 release 3
source tree. If you have such a source tree, type the following in
the xgraph-11 directory:
% make TOP=<source-tree-top>
where <source-tree-top> is the top level directory of the X11 release
3 source tree. If you don't have an X11 source tree but you have all
of the X libraries and include files installed in "standard
locations", type the following the in the xgraph-11 directory:
% make -f Makefile.std
Either of these commands will produce an executable xgraph in the
xgraph-11 directory. If you are installing the program in an X11
source tree, you can use the following to install the program and
manual page in the proper locations:
% make TOP=<source-tree-top> install
% make TOP=<source-tree-top> install.man
You might want to try these commands with the "-n" option once to make
sure the program and manual page are installed in the proper
directories. If they aren't, you may want to change the DESTDIR
variable and try again. If you really need to change the Makefile
options, you can generate a new Makefile from the Imakefile using
imake as provided on the X11 release tape.
Several example data sets are provided in the xgraph-11/examples
directory. Try the following to check out xgraph:
% xgraph examples/xgtest.xg
This should produce a graph with a series of parabolic curves.
Other documentation files are included. A summary of these
files is given below:
README.ANNOUNCE Message submitted to comp.windows.x announcing
the program and how to obtain it.
README.GENERAL Important notes about differences and quirks
of the program.
README.HARDCOPY Documenation for writing your own hardcopy
driver library.
README.INSTALL This file.
xgraph.man Xgraph manual page.
David Harrison
UC Berkeley Electronics Research Lab
(davidh@ic.Berkeley.EDU, ...!ucbvax!ucbcad!davidh)

43
xgraph/README.NEWFEATURES Normal file
View File

@ -0,0 +1,43 @@
This code is essentially XGraph release 11.4, with some modifications
which were made for use by the NCSA Relativity group.
These modifications were made by Paul Walker, and he should be
contacted at the below address if you have any problems/questions
regarding these features.
1. Animation. XGraph will now do a *very* crude animation of
your data sets. It occasionally has problems with refreshes
and will consequently run your animation three of four times.
Consider this an undocumented feature! You can adjust the
speed of the animation with the -dl option. I find "2" works
well on a sparc displaying on MacX, "5" on a sparc on its
own display, and "10" on an SGI or RS6K on its own display.
Remeber, this animation is not being advertised as anything
other than very crude, so if you are looking for production
quality video, turn elsewhere. We find it useful as it will
quickly generate animation which shows time evolution.
2. Differentation. You can press the "Derivative" button to
see the first and second derivatives of your data set. The
method is a standard centered difference. You cannot display
higher than second derivatives. Animation, zooming, etc...
work in each of the derivative windows. Endpoints are found
linearly interpolating inner values to ends, so pay them
little heed!
3. New Color Map. We couldn't differentiate the colors once we
got past yellow, so we created a new color map. If you don't
like it, look in init.c for the variable "defColors" and
comment out the new one, replacing it with the commented
old one. Of course, you are free to insert your own choices
here also ... Just use standard X color names.
These modifications were made by Paul Walker, and distributed with the
Original author's consent. See Copyright.h for information about
distribution and ownership of these changes. Contact Paul Walker at
Paul Walker
NCSA
605 E. Springfield Ave
Champaign IL 61820
pwalker@ncsa.uiuc.edu

146
xgraph/aclocal.m4 vendored Normal file
View File

@ -0,0 +1,146 @@
dnl aclocal.m4 generated automatically by aclocal 1.4
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
dnl PARTICULAR PURPOSE.
# Do all the work for Automake. This macro actually does too much --
# some checks are only needed if your package does certain things.
# But this isn't really a big deal.
# serial 1
dnl Usage:
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
AC_DEFUN(AM_INIT_AUTOMAKE,
[AC_REQUIRE([AC_PROG_INSTALL])
PACKAGE=[$1]
AC_SUBST(PACKAGE)
VERSION=[$2]
AC_SUBST(VERSION)
dnl test to see if srcdir already configured
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
ifelse([$3],,
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
AC_REQUIRE([AM_SANITY_CHECK])
AC_REQUIRE([AC_ARG_PROGRAM])
dnl FIXME This is truly gross.
missing_dir=`cd $ac_aux_dir && pwd`
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
AC_REQUIRE([AC_PROG_MAKE_SET])])
#
# Check to make sure that the build environment is sane.
#
AC_DEFUN(AM_SANITY_CHECK,
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftestfile
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
if test "[$]*" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftestfile`
fi
if test "[$]*" != "X $srcdir/configure conftestfile" \
&& test "[$]*" != "X conftestfile $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "[$]2" = conftestfile
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
rm -f conftest*
AC_MSG_RESULT(yes)])
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
dnl The program must properly implement --version.
AC_DEFUN(AM_MISSING_PROG,
[AC_MSG_CHECKING(for working $2)
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if ($2 --version) < /dev/null > /dev/null 2>&1; then
$1=$2
AC_MSG_RESULT(found)
else
$1="$3/missing $2"
AC_MSG_RESULT(missing)
fi
AC_SUBST($1)])
# Like AC_CONFIG_HEADER, but automatically create stamp file.
AC_DEFUN(AM_CONFIG_HEADER,
[AC_PREREQ([2.12])
AC_CONFIG_HEADER([$1])
dnl When config.status generates a header, we must update the stamp-h file.
dnl This file resides in the same directory as the config header
dnl that is generated. We must strip everything past the first ":",
dnl and everything past the last "/".
AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
<<am_indx=1
for am_file in <<$1>>; do
case " <<$>>CONFIG_HEADERS " in
*" <<$>>am_file "*<<)>>
echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
;;
esac
am_indx=`expr "<<$>>am_indx" + 1`
done<<>>dnl>>)
changequote([,]))])
# serial 1
AC_DEFUN(AM_WITH_DMALLOC,
[AC_MSG_CHECKING(if malloc debugging is wanted)
AC_ARG_WITH(dmalloc,
[ --with-dmalloc use dmalloc, as in
ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz],
[if test "$withval" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE(WITH_DMALLOC,1,
[Define if using the dmalloc debugging malloc package])
LIBS="$LIBS -ldmalloc"
LDFLAGS="$LDFLAGS -g"
else
AC_MSG_RESULT(no)
fi], [AC_MSG_RESULT(no)])
])

284
xgraph/alloc.c Normal file
View File

@ -0,0 +1,284 @@
/* $Header$ */
/*
*
* alloc.c : Memory checked Malloc. This malloc keeps track of memory usage.
*
* Routines:
* char * Malloc();
* char * Calloc();
* char * Realloc();
* void Free();
* unsigned MemStat();
* unsigned MemPtr();
* void MemChain();
*
* $Log$
* Revision 1.1 2004-01-25 09:00:49 pnenzi
*
* Added xgraph plotting program.
*
* Revision 1.1.1.1 1999/12/03 23:15:53 heideman
* xgraph-12.0
*
* Revision 1.10 1991/02/01 08:12:55 christos
* Overhaul... Simplified and added calloc.
*
* Revision 1.9 1990/10/02 18:11:24 christos
* Another Realloc() bug!
*
* Revision 1.8 90/10/02 17:32:45 christos
* Fixed Realloc() bug.
*
* Revision 1.7 90/08/24 02:28:15 christos
* Changed bigstruct_t to align_t
* for lint.
*
* Revision 1.6 90/07/15 17:31:33 christos
* Fixed MemPtr Bug
*
* Revision 1.5 90/07/11 16:19:31 christos
* Added Realloc()
*
* Revision 1.4 90/03/21 12:58:44 christos
* Fixed void buggy computations.
*
* Revision 1.3 90/02/26 02:15:11 christos
* ANSI conformance.
*
* Revision 1.2 89/08/29 14:08:25 christos
* Fixed.
*
* Revision 1.1 89/03/27 14:23:40 christos
* Initial revision
*
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif /* lint */
#include <stdio.h>
#ifdef __STDC__
#include <stdlib.h>
#include <memory.h>
#else
extern char *malloc();
extern char *calloc();
extern char *realloc();
extern void free();
extern void abort();
extern char *memset();
#endif
#ifndef NIL
#define NIL(a) ((a *) 0)
#endif /* NIL */
#ifndef MIN
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#endif /* MIN */
#ifndef MAX
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#endif /* MAX */
#ifndef private
#define private static
#endif /* private */
#ifndef public
#define public
#endif /* public */
#define SIG_GOOD 0x01020304
#define SIG_FREE 0x04030201
#define OVERHEAD (sizeof(long) + sizeof(unsigned))
private unsigned memused = 0;
private unsigned memalloc = 0;
#ifdef __STDC__
typedef void *Ptr;
#else
typedef char *Ptr;
#endif
/* _chaina():
* Check things for validity and allocate space
*/
private Ptr
_chaina(n, routine, action, tptr)
unsigned n;
Ptr(*routine) ();
char *action;
Ptr tptr;
{
char *ptr;
if (n == 0) {
(void) fprintf(stderr, "*** %s zero length block.\n",
action);
if (tptr != (Ptr) 0) {
ptr = tptr;
*((long *) ptr) = SIG_GOOD;
memused += *((unsigned *) &ptr[sizeof(long)]);
memalloc++;
}
abort();
}
ptr = (tptr == (Ptr) 0) ? (char *) (*routine) (n + OVERHEAD) :
(char *) (*routine) (tptr, n + OVERHEAD);
if (ptr == NIL(char)) {
if (tptr != (Ptr) 0)
*((long *) tptr) = SIG_GOOD;
(void) fprintf(stderr,
"*** Out of memory in %s (current allocation %d).\n",
action, memused, n);
abort();
}
*((long *) ptr) = SIG_GOOD;
memused += (*((unsigned *) &ptr[sizeof(long)]) = n);
memalloc++;
ptr += OVERHEAD;
return ((Ptr) ptr);
} /* end _chaina */
/* _chainc():
* Check the pointer given
*/
private unsigned
_chainc(ptr, action)
char **ptr;
char *action;
{
static char *msg = "*** %s %s pointer.\n";
if (*ptr == NIL(char)) {
(void) fprintf(stderr, msg, action, "nil");
abort();
}
*ptr -= OVERHEAD;
switch (*((long *) *ptr)) {
case SIG_GOOD:
return (*((unsigned *) &((*ptr)[sizeof(long)])));
case SIG_FREE:
(void) fprintf(stderr, msg, action, "free");
abort();
default:
(void) fprintf(stderr, msg, action, "invalid");
abort();
}
return (0);
} /* end _chainc */
/* Malloc():
* real alloc
*/
public Ptr
Malloc(n)
unsigned n;
{
static char *routine = "malloc";
return (_chaina(n, malloc, routine, (Ptr) 0));
} /* end Malloc */
/* Calloc():
* real alloc
*/
public Ptr
Calloc(n, sz)
unsigned n,
sz;
{
Ptr ptr;
static char *routine = "calloc";
n *= sz;
ptr = _chaina(n, malloc, routine, (Ptr) 0);
memset((char *) ptr, 0, n);
return (ptr);
} /* end Calloc */
/* Realloc():
* real alloc
*/
public Ptr
Realloc(ptr, n)
Ptr ptr;
unsigned n;
{
static char *routine = "realloc";
memused -= _chainc((char **) &ptr, routine);
memalloc--;
*((long *) ptr) = SIG_FREE;
return (_chaina(n, realloc, routine, ptr));
} /* end Realloc */
/* Free():
* free memory counting the number of bytes freed
*/
public void
Free(ptr)
Ptr ptr;
{
static char *routine = "free";
memused -= _chainc((char **) &ptr, routine);
memalloc--;
*((long *) ptr) = SIG_FREE;
free(ptr);
} /* end Free */
/* MemChain():
* Dump the chain
*/
public void
MemChain()
{
if (memused == 0 && memalloc == 0)
(void) fprintf(stdout, "\tNo memory allocated.\n");
else {
(void) fprintf(stdout, "\t%u Bytes allocated in %u chunks.\n", memused,
memalloc);
(void) fprintf(stdout, "\tAverage chunk length %u bytes.\n",
memused / memalloc);
}
} /* end MemChain */
/* MemStat():
* return the amount of memory in use
*/
public unsigned
MemStat()
{
return (memused);
} /* end MemStat */
/* MemPtr():
* return the amount of memory used by the pointer
*/
public unsigned
MemPtr(ptr)
Ptr ptr;
{
static char *routine = "get size";
return (_chainc((char **) &ptr, routine));
} /* end MemPtr */

35
xgraph/autoconf.h.in Normal file
View File

@ -0,0 +1,35 @@
/* autoconf.h.in. Generated automatically from configure.in by autoheader. */
/* Define if the X Window System is missing or not being used. */
#undef X_DISPLAY_MISSING
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
/* Define if you have the <float.h> header file. */
#undef HAVE_FLOAT_H
/* Define if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Name of package */
#undef PACKAGE
/* Version number of package */
#undef VERSION
/* Define if using the dmalloc debugging malloc package */
#undef WITH_DMALLOC

4
xgraph/bitmaps/dot.11 Normal file
View File

@ -0,0 +1,4 @@
#define dot_width 8
#define dot_height 8
static char dot_bits[] = {
0x00, 0x3c, 0x7e, 0x7e, 0x7e, 0x7e, 0x3c, 0x00};

6
xgraph/bitmaps/gray Normal file
View File

@ -0,0 +1,6 @@
#define gray_width 16
#define gray_height 16
static char gray_bits[] = {
0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa};

6
xgraph/bitmaps/mark1.11 Normal file
View File

@ -0,0 +1,6 @@
#define mark1_width 8
#define mark1_height 8
#define mark1_x_hot 3
#define mark1_y_hot 3
static char mark1_bits[] = {
0x00, 0x00, 0x1c, 0x1c, 0x1c, 0x00, 0x00, 0x00};

6
xgraph/bitmaps/mark2.11 Normal file
View File

@ -0,0 +1,6 @@
#define mark2_width 8
#define mark2_height 8
#define mark2_x_hot 3
#define mark2_y_hot 3
static char mark2_bits[] = {
0x00, 0x3e, 0x22, 0x22, 0x22, 0x3e, 0x00, 0x00};

6
xgraph/bitmaps/mark3.11 Normal file
View File

@ -0,0 +1,6 @@
#define mark3_width 8
#define mark3_height 8
#define mark3_x_hot 3
#define mark3_y_hot 3
static char mark3_bits[] = {
0x00, 0x1c, 0x36, 0x22, 0x36, 0x1c, 0x00, 0x00};

6
xgraph/bitmaps/mark4.11 Normal file
View File

@ -0,0 +1,6 @@
#define mark4_width 8
#define mark4_height 8
#define mark4_x_hot 3
#define mark4_y_hot 3
static char mark4_bits[] = {
0x00, 0x22, 0x14, 0x08, 0x14, 0x22, 0x00, 0x00};

6
xgraph/bitmaps/mark5.11 Normal file
View File

@ -0,0 +1,6 @@
#define mark5_width 8
#define mark5_height 8
#define mark5_x_hot 3
#define mark5_y_hot 3
static char mark5_bits[] = {
0x00, 0x08, 0x14, 0x22, 0x14, 0x08, 0x00, 0x00};

6
xgraph/bitmaps/mark6.11 Normal file
View File

@ -0,0 +1,6 @@
#define mark6_width 8
#define mark6_height 8
#define mark6_x_hot 3
#define mark6_y_hot 3
static char mark6_bits[] = {
0x00, 0x1c, 0x14, 0x1c, 0x14, 0x1c, 0x00, 0x00};

6
xgraph/bitmaps/mark7.11 Normal file
View File

@ -0,0 +1,6 @@
#define mark7_width 8
#define mark7_height 8
#define mark7_x_hot 3
#define mark7_y_hot 3
static char mark7_bits[] = {
0x00, 0x1c, 0x2a, 0x36, 0x2a, 0x1c, 0x00, 0x00};

6
xgraph/bitmaps/mark8.11 Normal file
View File

@ -0,0 +1,6 @@
#define mark8_width 8
#define mark8_height 8
#define mark8_x_hot 3
#define mark8_y_hot 3
static char mark8_bits[] = {
0x00, 0x3e, 0x1c, 0x08, 0x1c, 0x3e, 0x00, 0x00};

2442
xgraph/configure vendored Executable file

File diff suppressed because it is too large Load Diff

34
xgraph/configure.in Normal file
View File

@ -0,0 +1,34 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(xgraph.c)
AM_INIT_AUTOMAKE(xgraph,12.1)
AM_CONFIG_HEADER(autoconf.h)
AM_WITH_DMALLOC
dnl Checks for programs.
AC_PROG_CC
dnl Checks for libraries.
AC_PATH_XTRA
dnl check header files.
AC_CHECK_HEADERS(float.h limits.h stdlib.h string.h strings.h unistd.h)
dnl checks for typedefs
dnl checks for structures
dnl checks for compiler characteristics
dnl checks for library functions
AC_CHECK_FUNCS(strcasecmp)
dnl checks for system services
AC_ARG_WITH(additional-includes, --with-additional-includes=path, ADDITIONAL_INCLUDES=$withval,ADDITIONAL_INCLUDES="")
AC_ARG_WITH(additional-libs, --with-additional-libs=path, ADDITIONAL_LIBS=$withval,ADDITIONAL_LIBS="")
AC_SUBST(ADDITIONAL_INCLUDES)
AC_SUBST(ADDITIONAL_LIBS)
AC_OUTPUT([Makefile])

65
xgraph/copyright.h Normal file
View File

@ -0,0 +1,65 @@
/*
* xgraph - program to graphically display numerical data
*
* David Harrison
* University of California, Berkeley
* 1989
*
* Animation, Differentiation by Paul Walker
* NCSA and University of Illinois at Urbana Champaign Dept. of Physics
*
* Copyright (c) 1988, 1989, Regents of the University of California.
* All rights reserved.
*
* Use and copying of this software and preparation of derivative works
* based upon this software are permitted. However, any distribution of
* this software or derivative works must include the above copyright
* notice.
*
* This software is made available AS IS, and neither the Electronics
* Research Laboratory or the University of California make any
* warranty about the software, its performance or its conformity to
* any specification.
*
Animation and differentiation routines were added by Paul Walker,
NCSA and UIUC Dept of Physics. The following copyright and disclaimer
applies to these parts of the code only.
UNIVERSITY OF ILLINOIS (UI), NATIONAL CENTER FOR SUPERCOMPUTING
APPLICATIONS (NCSA), Software Distribution Policy for Copyrighted Software
The above mentioned modifications to XGraph made with the authors consent are
copyrighted, but available without fee for education, academic research
and non-commercial purposes. The modifications are copyrighted in the name of
the UI, and ownership of the modifications remains with the UI. Users may
distribute the binary and source code to third parties provided that the
copyright notice and this statement appears on all copies and that no
charge is made for such copies. Any entity wishing to integrate all or
part of the source code into a product for commercial use or resale,
should contact the University of Illinois, c/o NCSA, to negotiate an
appropriate license for such commercial use.
UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR ANY
PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. THE
UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE USER OF THIS
SOFTWARE. The software may have been developed under agreements between
the UI and the Federal Government which entitle the Government to certain
rights.
By copying this program, you, the user, agree to abide by the copyright
conditions and understandings with respect to any software which is marked
with a copyright notice.
Send all comments about the modifications to Paul Walker,
pwalker@ncsa.uiuc.edu
*
*/
#ifndef _RIGHTS_
#define _RIGHTS_
static char copyright[] = "Copyright (c) 1989, Regents of the University of California. All rights reserved.";
#endif /* _RIGHTS_ */

130
xgraph/derivative.c Normal file
View File

@ -0,0 +1,130 @@
/* This entire routine written by PW. */
#include <stdio.h>
#include <string.h>
#include "xgraph.h"
void
Der1()
{
PointList *theList, *D1List, *D2List;
double m,b;
int i;
for (i=0;i<MAXSETS;i++) {
theList = PlotData[i].list;
if (theList) {
DataD1[i].list = (PointList *)malloc(sizeof(PointList));
DataD2[i].list = (PointList *)malloc(sizeof(PointList));
D1List = DataD1[i].list;
D2List = DataD2[i].list;
} else
DataD1[i].list = DataD2[i].list = NULL;
DataD1[i].setName =
(char *)malloc(sizeof(char)*strlen(PlotData[i].setName));
DataD2[i].setName =
(char *)malloc(sizeof(char)*strlen(PlotData[i].setName));
strcpy(DataD1[i].setName,PlotData[i].setName);
strcpy(DataD2[i].setName,PlotData[i].setName);
while (theList) {
int j;
D1List->numPoints = D2List->numPoints = theList->numPoints;
D1List->xvec = (double *)malloc(sizeof(double)*theList->numPoints);
D1List->yvec = (double *)malloc(sizeof(double)*theList->numPoints);
D1List->next = NULL;
D2List->xvec = (double *)malloc(sizeof(double)*theList->numPoints);
D2List->yvec = (double *)malloc(sizeof(double)*theList->numPoints);
D2List->next = NULL;
for (j=1;j<theList->numPoints-1;j++) {
D1List->xvec[j] = D2List->xvec[j] = theList->xvec[j];
D1List->yvec[j] = (theList->yvec[j+1] - theList->yvec[j-1]) /
(theList->xvec[j+1] - theList->xvec[j-1]);
D2List->yvec[j] = (theList->yvec[j+1] + theList->yvec[j-1] -
2.0*theList->yvec[j]) /
((theList->xvec[j+1] - theList->xvec[j]) *
(theList->xvec[j]-theList->xvec[j-1]));
}
/* Extrapolate to get the endpoints ... */
/* end near 0 */
D1List->xvec[0] = theList->xvec[0];
D1List->xvec[theList->numPoints-1] =
theList->xvec[theList->numPoints-1];
m = (D1List->yvec[2]-D1List->yvec[1]) /
(theList->xvec[2]-theList->xvec[1]);
b = D1List->yvec[1] - m*theList->xvec[1];
D1List->yvec[0] = m*theList->xvec[0] + b;
/* end near numPoints-1 */
m = (D1List->yvec[theList->numPoints-2]-
D1List->yvec[theList->numPoints-3]) /
(theList->xvec[theList->numPoints-2]-
theList->xvec[theList->numPoints-3]);
b = D1List->yvec [theList->numPoints-2] -
m*theList->xvec[theList->numPoints-2];
D1List->yvec[theList->numPoints-1] =
m*theList->xvec[theList->numPoints-1] + b;
/* Extrapolate to get the endpoints ... */
/* end near 0 */
D2List->xvec[0] = theList->xvec[0];
D2List->xvec[theList->numPoints-1] =
theList->xvec[theList->numPoints-1];
m = (D2List->yvec[2]-D2List->yvec[1]) /
(theList->xvec[2]-theList->xvec[1]);
b = D2List->yvec[1] - m*theList->xvec[1];
D2List->yvec[0] = m*theList->xvec[0] + b;
/* end near numPoints-1 */
m = (D2List->yvec[theList->numPoints-2]-
D2List->yvec[theList->numPoints-3]) /
(theList->xvec[theList->numPoints-2]-
theList->xvec[theList->numPoints-3]);
b = D2List->yvec[theList->numPoints-2] -
m*theList->xvec[theList->numPoints-2];
D2List->yvec[theList->numPoints-1] =
m*theList->xvec[theList->numPoints-1] + b;
theList = theList->next;
if (theList) {
D1List->next = (PointList *)malloc(sizeof(PointList));
D2List->next = (PointList *)malloc(sizeof(PointList));
D1List = D1List->next;
D2List = D2List->next;
}
}
}
}
void
Bounds(loX, loY, hiX, hiY, Ord)
double *loX, *loY, *hiX, *hiY;
int Ord;
{
int i;
PointList *theList;
if ((Ord<1) || (Ord>2)) {
printf ("Internal Error - Cannot eval deriv > 2 in Bounds.\n");
exit(1);
}
*loX = *loY = *hiX = *hiY = 0.0;
for (i=0;i<MAXSETS;i++) {
if (Ord == 1)
theList = DataD1[i].list;
else
theList = DataD2[i].list;
while (theList) {
int j;
for (j=0;j<theList->numPoints;j++) {
*loX = (theList->xvec[j]<*loX?theList->xvec[j]:*loX);
*loY = (theList->yvec[j]<*loY?theList->yvec[j]:*loY);
*hiX = (theList->xvec[j]>*hiX?theList->xvec[j]:*hiX);
*hiY = (theList->yvec[j]>*hiY?theList->yvec[j]:*hiY);
}
theList = theList->next;
}
}
}

942
xgraph/dialog.c Normal file
View File

@ -0,0 +1,942 @@
/*
* Xgraph Dialog Boxes
*
* This file constructs the hardcopy and error dialog
* boxes used by xgraph. It uses the mini-toolbox given
* in toolbox.c.
*/
#include "copyright.h"
#include "xgout.h"
#include "xgraph.h"
#include "hard_devices.h"
#include "xtb.h"
#include "params.h"
#include <stdio.h>
#include <X11/Xutil.h>
void do_error();
#define MAXCHBUF 1024
#ifdef SHADOW
#define gray_width 16
#define gray_height 16
static short gray_bits[] =
{
0x5555, 0xaaaa, 0x5555, 0xaaaa,
0x5555, 0xaaaa, 0x5555, 0xaaaa,
0x5555, 0xaaaa, 0x5555, 0xaaaa,
0x5555, 0xaaaa, 0x5555, 0xaaaa};
#endif
static void make_msg_box();
static void del_msg_box();
#define D_VPAD 2
#define D_HPAD 2
#define D_INT 4
#define D_BRDR 2
#define D_INP 35
#define D_DSP 10
#define D_FS 10
struct d_info {
char *prog; /* Program name */
xtb_data cookie; /* Info used by do_harcopy */
Window choices; /* Output device choices */
Window fod; /* File or device flag */
Window fodspec; /* File or device spec */
Window docu_p; /* Document predicate */
Window dimspec; /* Maximum dimension spec */
Window tf_family; /* Title font family spec */
Window tf_size; /* Title font size spec */
Window af_family; /* Axis font family spec */
Window af_size; /* Axis font size spec */
};
#define BACKSPACE 0010
#define DELETE 0177
#define CONTROL_U 0025
#define CONTROL_X 0030
/*ARGSUSED*/
static xtb_hret
df_fun(win, ch, text, val)
Window win; /* Widget window */
int ch; /* Typed character */
char *text; /* Copy of text */
xtb_data val; /* User info */
/*
* This is the handler function for the text widget for
* specifing the file or device name. It supports simple
* line editing operations.
*/
{
if ((ch == BACKSPACE) || (ch == DELETE)) {
if (!xtb_ti_dch(win))
XBell(disp, 0);
}
else if ((ch == CONTROL_U) || (ch == CONTROL_X)) {
(void) xtb_ti_set(win, "", (xtb_data) 0);
}
else {
/* Insert if printable - ascii dependent */
if ((ch < ' ') || (ch >= DELETE) || !xtb_ti_ins(win, ch)) {
XBell(disp, 0);
}
}
return XTB_HANDLED;
}
/*ARGSUSED*/
static xtb_hret
ok_fun(win, bval, info)
Window win; /* Button window */
int bval; /* Button value */
xtb_data info; /* Local button info */
/*
* This is the handler function for when the `Ok' button
* is hit. It sets the button, does the hardcopy output,
* and turns the button off. It returns a status which
* deactivates the dialog.
*/
{
struct d_info *real_info = (struct d_info *) info;
int val,
dev_p,
doc_p;
char file_or_dev[MAXCHBUF],
dim_spec[MAXCHBUF],
*dev_spec;
char tfam[MAXCHBUF],
afam[MAXCHBUF];
char tsizstr[MAXCHBUF],
asizstr[MAXCHBUF];
double centimeters,
tsize,
asize;
xtb_hret rtn;
(void) xtb_bt_set(win, 1, (xtb_data) 0, 0);
val = xtb_br_get(real_info->choices);
if ((val >= 0) && (val < hard_count)) {
dev_p = xtb_br_get(real_info->fod);
if ((dev_p == 0) || (dev_p == 1)) {
xtb_ti_get(real_info->fodspec, file_or_dev, (xtb_data *) 0);
doc_p = xtb_bt_get(real_info->docu_p, (xtb_data *) 0, (int *) 0);
xtb_ti_get(real_info->dimspec, dim_spec, (xtb_data *) 0);
if (sscanf(dim_spec, "%lf", &centimeters) == 1) {
xtb_ti_get(real_info->tf_family, tfam, (xtb_data *) 0);
xtb_ti_get(real_info->af_family, afam, (xtb_data *) 0);
xtb_ti_get(real_info->tf_size, tsizstr, (xtb_data *) 0);
if (sscanf(tsizstr, "%lf", &tsize) == 1) {
xtb_ti_get(real_info->af_size, asizstr, (xtb_data *) 0);
if (sscanf(asizstr, "%lf", &asize) == 1) {
/* Got all the info */
if (dev_p) {
dev_spec = (char *) 0;
}
else {
dev_spec = hard_devices[val].dev_spec;
}
do_hardcopy(real_info->prog, real_info->cookie,
hard_devices[val].dev_init, dev_spec,
file_or_dev, centimeters,
tfam, tsize, afam, asize, doc_p);
rtn = XTB_STOP;
}
else {
/* Bad axis size */
do_error("Bad axis font size\n");
rtn = XTB_HANDLED;
}
}
else {
/* Bad title size */
do_error("Bad title font size\n");
rtn = XTB_HANDLED;
}
}
else {
/* Bad max dimension */
do_error("Bad maximum dimension\n");
rtn = XTB_HANDLED;
}
}
else {
/* Bad device spec */
do_error("Must specify `To File' or `To Device'\n");
rtn = XTB_HANDLED;
}
}
else {
/* Bad value spec */
do_error("Must specify an output device\n");
rtn = XTB_HANDLED;
}
(void) xtb_bt_set(win, 0, (xtb_data) 0, 0);
return rtn;
}
/*ARGSUSED*/
static xtb_hret
can_fun(win, val, info)
Window win; /* Button window */
int val; /* Button value */
xtb_data info; /* Local button info */
/*
* This is the handler function for the cancel button. It
* turns itself on and off and then exits with a status
* which kills the dialog.
*/
{
(void) xtb_bt_set(win, 1, (xtb_data) 0, 0);
(void) xtb_bt_set(win, 0, (xtb_data) 0, 0);
return XTB_STOP;
}
/*ARGSUSED*/
static xtb_hret
docu_fun(win, val, info)
Window win; /* Button window */
int val; /* Button value */
xtb_data info; /* Local button info */
/*
* This is the handler function for the document button. It
* toggles it's state.
*/
{
int state;
state = xtb_bt_get(win, (xtb_data *) 0, (int *) 0);
xtb_bt_set(win, (state == 0), (xtb_data) 0, 0);
return XTB_HANDLED;
}
/*ARGSUSED*/
static xtb_hret
dev_fun(win, old, new, info)
Window win; /* Button row window */
int old; /* Previous button */
int new; /* Current button */
xtb_data info; /* User data */
/*
* This routine swaps the device specific information
* in the dialog based on what device is selected. The
* information passed is the information for the whole
* dialog.
*/
{
struct d_info *data = (struct d_info *) info;
char text[MAXCHBUF];
int fod_spot,
inactive;
fod_spot = xtb_br_get(data->fod);
if ((old >= 0) && (old < hard_count)) {
/* Save old info */
xtb_ti_get(data->fodspec, text, (xtb_data *) 0);
if (fod_spot == 1) {
strncpy(hard_devices[old].dev_file, text, MFNAME - 1);
}
else if (fod_spot == 0) {
strncpy(hard_devices[old].dev_printer, text, MFNAME - 1);
}
if (xtb_bt_get(data->docu_p, (xtb_data *) 0, &inactive)) {
if (inactive)
hard_devices[old].dev_docu = NONE;
else
hard_devices[old].dev_docu = YES;
}
else if (inactive)
hard_devices[old].dev_docu = NONE;
else
hard_devices[old].dev_docu = NO;
xtb_ti_get(data->dimspec, text, (xtb_data *) 0);
if (sscanf(text, "%lf", &hard_devices[old].dev_max_dim) != 1) {
do_error("Warning: can't read maximum dimension");
}
xtb_ti_get(data->tf_family, text, (xtb_data *) 0);
strncpy(hard_devices[old].dev_title_font, text, MFNAME - 1);
xtb_ti_get(data->tf_size, text, (xtb_data *) 0);
if (sscanf(text, "%lf", &hard_devices[old].dev_title_size) != 1) {
do_error("Warning: can't read title font size");
}
xtb_ti_get(data->af_family, text, (xtb_data *) 0);
strncpy(hard_devices[old].dev_axis_font, text, MFNAME - 1);
xtb_ti_get(data->af_size, text, (xtb_data *) 0);
if (sscanf(text, "%lf", &hard_devices[old].dev_axis_size) != 1) {
do_error("Warning: can't read axis font size");
}
}
/* Insert new info */
if ((new >= 0) && (new < hard_count)) {
if (fod_spot == 1) {
xtb_ti_set(data->fodspec, hard_devices[new].dev_file, (xtb_data) 0);
}
else if (fod_spot == 0) {
xtb_ti_set(data->fodspec, hard_devices[new].dev_printer,
(xtb_data) 0);
}
else {
xtb_ti_set(data->fodspec, "", (xtb_data) 0);
}
switch (hard_devices[new].dev_docu) {
case NONE:
(void) xtb_bt_set(data->docu_p, 0, (xtb_data) 0, 1);
break;
case NO:
(void) xtb_bt_set(data->docu_p, 0, (xtb_data) 0, 0);
break;
case YES:
(void) xtb_bt_set(data->docu_p, 1, (xtb_data) 0, 0);
break;
}
(void) sprintf(text, "%lg", hard_devices[new].dev_max_dim);
xtb_ti_set(data->dimspec, text, (xtb_data) 0);
xtb_ti_set(data->tf_family, hard_devices[new].dev_title_font,
(xtb_data) 0);
(void) sprintf(text, "%lg", hard_devices[new].dev_title_size);
xtb_ti_set(data->tf_size, text, (xtb_data) 0);
xtb_ti_set(data->af_family, hard_devices[new].dev_axis_font,
(xtb_data) 0);
(void) sprintf(text, "%lg", hard_devices[new].dev_axis_size);
xtb_ti_set(data->af_size, text, (xtb_data) 0);
}
return XTB_HANDLED;
}
/*ARGSUSED*/
static xtb_hret
fd_fun(win, old, new, info)
Window win; /* Button row window */
int old; /* Previous button */
int new; /* Current button */
xtb_data info; /* User data */
/*
* This routine swaps the default file or device names
* based on the state of the file or device buttons.
* The information passed is the information for the whole
* dialog.
*/
{
struct d_info *data = (struct d_info *) info;
char text[MAXCHBUF];
int which_one;
which_one = xtb_br_get(data->choices);
if ((which_one >= 0) && (which_one < hard_count)) {
if (old == 0) {
/* Save into device space */
xtb_ti_get(data->fodspec, text, (xtb_data *) 0);
strncpy(hard_devices[which_one].dev_printer, text, MFNAME - 1);
}
else if (old == 1) {
/* Save into file space */
xtb_ti_get(data->fodspec, text, (xtb_data *) 0);
which_one = xtb_br_get(data->choices);
strncpy(hard_devices[which_one].dev_file, text, MFNAME - 1);
}
if (new == 0) {
/* Restore into device */
xtb_ti_set(data->fodspec, hard_devices[which_one].dev_printer,
(xtb_data *) 0);
}
else if (new == 1) {
xtb_ti_set(data->fodspec, hard_devices[which_one].dev_file,
(xtb_data *) 0);
}
}
return XTB_HANDLED;
}
/* Indices for frames made in make_dialog */
enum d_frames_defn {
TITLE_F, ODEVLBL_F, ODEVROW_F, DISPLBL_F, DISPROW_F, FDLBL_F,
FDINP_F, OPTLBL_F, DOCU_F, MDIMLBL_F, MDIMI_F, TFLBL_F, TFFAMLBL_F, TFFAM_F,
TFSIZLBL_F, TFSIZ_F, AFLBL_F, AFFAMLBL_F, AFFAM_F, AFSIZLBL_F, AFSIZ_F,
OK_F, CAN_F, BAR_F, LAST_F
} d_frames;
#define AF(ix) af[(int) (ix)]
#define BAR_SLACK 10
static void
make_dialog(win, spawned, prog, cookie, okbtn, frame)
Window win; /* Parent window */
Window spawned; /* Spawned from window */
char *prog; /* Program name */
xtb_data cookie; /* Info for do_hardcopy */
xtb_frame *okbtn; /* Frame for OK button */
xtb_frame *frame; /* Returned window/size */
/*
* This routine constructs a new dialog for asking the user about
* hardcopy devices. The dialog and its size is returned in
* `frame'. The window of the `ok' button is returned in `btnwin'.
* This can be used to reset some of the button state to reuse the dialog.
*/
{
Window overall;
xtb_frame AF(LAST_F);
xtb_fmt *def,
*cntrl,
*mindim,
*tfarea,
*afarea;
Cursor diag_cursor;
XColor fg_color,
bg_color;
XSizeHints hints;
unsigned long wamask;
XSetWindowAttributes wattr;
struct d_info *info;
int i,
found,
max_width,
which_one,
fodi;
char **names;
static char *fodstrs[] =
{"To Device", "To File"};
XFontStruct *bigFont = PM_FONT("TitleFont");
XFontStruct *medFont = PM_FONT("LabelFont");
char *Odevice = PM_STR("Device");
char *Odisp = PM_STR("Disposition");
char *OfileDev = PM_STR("FileOrDev");
wamask = CWBackPixel | CWBorderPixel | CWOverrideRedirect |
CWSaveUnder | CWColormap;
wattr.background_pixel = PM_PIXEL("Background");
wattr.border_pixel = PM_PIXEL("Border");
wattr.override_redirect = True;
wattr.save_under = True;
wattr.colormap = cmap;
overall = XCreateWindow(disp, win, 0, 0, 1, 1, D_BRDR,
depth, InputOutput, vis,
wamask, &wattr);
frame->win = overall;
frame->width = frame->height = frame->x_loc = frame->y_loc = 0;
XStoreName(disp, overall, "Hardcopy Dialog");
XSetTransientForHint(disp, spawned, overall);
info = (struct d_info *) Malloc(sizeof(struct d_info));
info->prog = prog;
info->cookie = cookie;
/* Make all frames */
xtb_to_new(overall, "Hardcopy Options", bigFont, &AF(TITLE_F));
xtb_to_new(overall, "Output device:", medFont, &AF(ODEVLBL_F));
found = -1;
names = (char **) Malloc((unsigned) (sizeof(char *) * hard_count));
for (i = 0; i < hard_count; i++) {
names[i] = hard_devices[i].dev_name;
if (strcmp(Odevice, names[i]) == 0) {
found = i;
}
}
xtb_br_new(overall, hard_count, names, found,
dev_fun, (xtb_data) info, &AF(ODEVROW_F));
info->choices = AF(ODEVROW_F).win;
xtb_to_new(overall, "Disposition:", medFont, &AF(DISPLBL_F));
found = -1;
for (i = 0; i < 2; i++) {
if (strcmp(Odisp, fodstrs[i]) == 0) {
found = i;
}
}
xtb_br_new(overall, 2, fodstrs, found,
fd_fun, (xtb_data) info, &AF(DISPROW_F));
info->fod = AF(DISPROW_F).win;
xtb_to_new(overall, "File or Device Name:", medFont, &AF(FDLBL_F));
xtb_ti_new(overall, "", D_INP, df_fun, (xtb_data) 0, &AF(FDINP_F));
if (OfileDev && strlen(OfileDev)) {
which_one = xtb_br_get(info->choices);
if ((which_one >= 0) && (which_one < hard_count)) {
fodi = xtb_br_get(info->fod);
if (fodi == 0) {
strncpy(hard_devices[which_one].dev_printer, OfileDev, MFNAME - 1);
}
else if (fodi == 1) {
strncpy(hard_devices[which_one].dev_file, OfileDev, MFNAME - 1);
}
}
}
info->fodspec = AF(FDINP_F).win;
xtb_to_new(overall, "Optional Parameters", bigFont, &AF(OPTLBL_F));
xtb_bt_new(overall, "Include in Document", docu_fun, (xtb_data) 0, &AF(DOCU_F));
info->docu_p = AF(DOCU_F).win;
xtb_to_new(overall, "Maximum Dimension (cm):", medFont, &AF(MDIMLBL_F));
xtb_ti_new(overall, "", D_DSP, df_fun, (xtb_data) 0, &AF(MDIMI_F));
info->dimspec = AF(MDIMI_F).win;
xtb_to_new(overall, "Title Font", medFont, &AF(TFLBL_F));
xtb_to_new(overall, "Family:", medFont, &AF(TFFAMLBL_F));
xtb_ti_new(overall, "", MFNAME, df_fun, (xtb_data) 0, &AF(TFFAM_F));
info->tf_family = AF(TFFAM_F).win;
xtb_to_new(overall, "Size (pnts):", medFont, &AF(TFSIZLBL_F));
xtb_ti_new(overall, "", D_FS, df_fun, (xtb_data) 0, &AF(TFSIZ_F));
info->tf_size = AF(TFSIZ_F).win;
xtb_to_new(overall, "Axis Font", medFont, &AF(AFLBL_F));
xtb_to_new(overall, "Family:", medFont, &AF(AFFAMLBL_F));
xtb_ti_new(overall, "", MFNAME, df_fun, (xtb_data) 0, &AF(AFFAM_F));
info->af_family = AF(AFFAM_F).win;
xtb_to_new(overall, "Size (pnts):", medFont, &AF(AFSIZLBL_F));
xtb_ti_new(overall, "", D_FS, df_fun, (xtb_data) 0, &AF(AFSIZ_F));
info->af_size = AF(AFSIZ_F).win;
xtb_bt_new(overall, " Ok ", ok_fun, (xtb_data) info, &AF(OK_F));
xtb_bt_new(overall, "Cancel", can_fun, (xtb_data) 0, &AF(CAN_F));
/* Dividing bar */
max_width = 0;
for (i = 0; i < ((int) BAR_F); i++) {
if (AF(i).width > max_width)
max_width = AF(i).width;
}
xtb_bk_new(overall, max_width - BAR_SLACK, 1, &AF(BAR_F));
/* Set device specific info */
(void) dev_fun(info->choices, -1, xtb_br_get(info->choices), (xtb_data) info);
(void) fd_fun(info->fod, -1, xtb_br_get(info->fod), (xtb_data) info);
/*
* Now place elements - could make this one expression but pcc is too
* wimpy.
*/
cntrl = xtb_vert(XTB_LEFT, D_VPAD, D_INT,
xtb_hort(XTB_CENTER, D_HPAD, D_INT,
xtb_w(&AF(ODEVLBL_F)),
xtb_w(&AF(ODEVROW_F)), NE),
xtb_hort(XTB_CENTER, D_HPAD, D_INT,
xtb_w(&AF(DISPLBL_F)),
xtb_w(&AF(DISPROW_F)), NE),
xtb_hort(XTB_CENTER, D_HPAD, D_INT,
xtb_w(&AF(FDLBL_F)),
xtb_w(&AF(FDINP_F)), NE),
NE);
mindim = xtb_vert(XTB_LEFT, D_VPAD, D_INT,
xtb_hort(XTB_CENTER, D_HPAD, D_INT,
xtb_w(&AF(MDIMLBL_F)),
xtb_w(&AF(MDIMI_F)),
NE),
NE);
tfarea = xtb_vert(XTB_LEFT, D_VPAD, D_INT,
xtb_hort(XTB_CENTER, D_HPAD, D_INT,
xtb_w(&AF(TFFAMLBL_F)),
xtb_w(&AF(TFFAM_F)),
xtb_w(&AF(TFSIZLBL_F)),
xtb_w(&AF(TFSIZ_F)), NE),
NE);
afarea = xtb_vert(XTB_LEFT, D_VPAD, D_INT,
xtb_hort(XTB_CENTER, D_HPAD, D_INT,
xtb_w(&AF(AFFAMLBL_F)),
xtb_w(&AF(AFFAM_F)),
xtb_w(&AF(AFSIZLBL_F)),
xtb_w(&AF(AFSIZ_F)), NE),
NE);
def = xtb_fmt_do
(xtb_vert(XTB_CENTER, D_VPAD, D_INT,
xtb_w(&AF(TITLE_F)),
cntrl,
xtb_w(&AF(BAR_F)),
xtb_w(&AF(OPTLBL_F)),
mindim,
xtb_w(&AF(DOCU_F)),
xtb_w(&AF(TFLBL_F)),
tfarea,
xtb_w(&AF(AFLBL_F)),
afarea,
xtb_hort(XTB_CENTER, D_HPAD, D_INT,
xtb_w(&AF(OK_F)), xtb_w(&AF(CAN_F)), NE),
NE),
&frame->width, &frame->height);
xtb_mv_frames(LAST_F, af);
xtb_fmt_free(def);
/* Make window large enough to contain the info */
XResizeWindow(disp, overall, frame->width, frame->height);
hints.flags = PSize;
hints.width = frame->width;
hints.height = frame->height;
XSetNormalHints(disp, overall, &hints);
diag_cursor = XCreateFontCursor(disp, XC_dotbox);
fg_color.pixel = PM_PIXEL("Foreground");
XQueryColor(disp, cmap, &fg_color);
bg_color.pixel = PM_PIXEL("Background");
XQueryColor(disp, cmap, &bg_color);
XRecolorCursor(disp, diag_cursor, &fg_color, &bg_color);
XDefineCursor(disp, overall, diag_cursor);
frame->width += (2 * D_BRDR);
frame->height += (2 * D_BRDR);
*okbtn = AF(OK_F);
}
#ifdef SHADOW
Window
make_shadow(w, h)
int w,
h;
/*
* Makes a shadow window for a pop-up window of the specified size.
* Needs hint work as well. Try no background window.
*/
{
Window shadow;
Bitmap gray_bm;
Pixmap gray_pm;
gray_bm = XStoreBitmap(gray_width, gray_height, gray_bits);
gray_pm = XMakePixmap(gray_bm, PM_PIXEL("Foreground"), PM_PIXEL("Background"));
shadow = XCreateWindow(RootWindow, 0, 0, w, h, 0, BlackPixmap, gray_pm);
XFreePixmap(gray_pm);
XFreeBitmap(gray_bm);
return shadow;
}
#endif
#define SH_W 5
#define SH_H 5
void
ho_dialog(parent, prog, cookie)
Window parent; /* Parent window */
char *prog; /* Program name */
xtb_data cookie; /* Info passed to do_hardcopy */
/*
* Asks the user about hardcopy devices. A table of hardcopy
* device names and function pointers to their initialization
* functions is assumed to be in the global `hard_devices' and
* `hard_count'. Returns a non-zero status if the dialog was
* sucessfully posted. Calls do_hardcopy in xgraph to actually
* output information.
*/
{
#ifdef SHADOW
static Window shadow;
#endif
static Window dummy;
static xtb_frame overall =
{(Window) 0, 0, 0, 0, 0};
static xtb_frame okbtn;
XEvent evt;
XWindowAttributes winInfo;
XSizeHints hints;
struct d_info *info;
if (!overall.win) {
make_dialog(RootWindow(disp, screen), parent, prog, cookie,
&okbtn, &overall);
#ifdef SHADOW
shadow = make_shadow(d_w, d_h);
#endif
}
else {
/* Change the button information */
(void) xtb_bt_get(okbtn.win, (xtb_data *) & info, (int *) 0);
info->prog = prog;
info->cookie = cookie;
}
XGetWindowAttributes(disp, parent, &winInfo);
XTranslateCoordinates(disp, parent, RootWindow(disp, screen),
0, 0, &winInfo.x, &winInfo.y, &dummy);
XMoveWindow(disp, overall.win,
(int) (winInfo.x + winInfo.width / 2 - overall.width / 2),
(int) (winInfo.y + winInfo.height / 2 - overall.height / 2));
hints.flags = PPosition;
hints.x = winInfo.x + winInfo.width / 2 - overall.width / 2;
hints.y = winInfo.y + winInfo.height / 2 - overall.height / 2;
XSetNormalHints(disp, overall.win, &hints);
#ifdef SHADOW
XMoveWindow(disp, shadow, winInfo.x + winInfo.width / 2 - d_w / 2 + SH_W,
winInfo.y + winInfo.height / 2 - d_h / 2 + SH_H);
hints.flags = PPosition;
hints.x = winInfo.x + winInfo.width / 2 - d_w / 2 + SH_W;
hints.y = winInfo.y + winInfo.height / 2 - d_h / 2 + SH_H;
XSetNormalHints(disp, shadow, &hints);
XRaiseWindow(disp, shadow);
XMapWindow(disp, shadow);
#endif
XRaiseWindow(disp, overall.win);
XMapWindow(disp, overall.win);
do {
XNextEvent(disp, &evt);
} while (xtb_dispatch(&evt) != XTB_STOP);
XUnmapWindow(disp, overall.win);
#ifdef SHADOW
XUnmapWindow(disp, shadow);
#endif
}
/*ARGSUSED*/
static xtb_hret
err_func(win, bval, info)
Window win; /* Button window */
int bval; /* Button value */
xtb_data info; /* Local button info */
/*
* Handler function for button in error box. Simply stops dialog.
*/
{
(void) xtb_bt_set(win, 1, (xtb_data) 0, 0);
(void) xtb_bt_set(win, 0, (xtb_data) 0, 0);
return XTB_STOP;
}
struct err_info {
Window title;
Window contbtn;
int num_lines;
int alloc_lines;
Window *lines;
};
#define E_LINES 2
#define E_VPAD 3
#define E_HPAD 3
#define E_INTER 1
#define ML 256
static void
make_msg_box(text, title, frame)
char *text; /* Error text */
char *title; /* Title text */
xtb_frame *frame; /* Returned frame */
/*
* Makes an error box with a title.
*/
{
XSizeHints hints;
struct err_info *new_info;
xtb_frame tf,
cf,
lf;
char *lineptr,
line[ML];
int y,
i;
unsigned long wamask;
XSetWindowAttributes wattr;
XFontStruct *bigFont = PM_FONT("TitleFont");
XFontStruct *medFont = PM_FONT("LabelFont");
wamask = CWBackPixel | CWBorderPixel | CWOverrideRedirect |
CWSaveUnder | CWColormap;
wattr.background_pixel = PM_PIXEL("Background");
wattr.border_pixel = PM_PIXEL("Border");
wattr.override_redirect = True;
wattr.save_under = True;
wattr.colormap = cmap;
frame->win = XCreateWindow(disp, RootWindow(disp, screen),
0, 0, 1, 1, D_BRDR,
depth, InputOutput, vis,
wamask, &wattr);
frame->x_loc = frame->y_loc = frame->width = frame->height = 0;
XStoreName(disp, frame->win, "Error Dialog");
XSetTransientForHint(disp, RootWindow(disp, screen), frame->win);
new_info = (struct err_info *) Malloc((unsigned) sizeof(struct err_info));
xtb_to_new(frame->win, title, bigFont, &tf);
new_info->title = tf.win;
if (tf.width > frame->width)
frame->width = tf.width;
xtb_bt_new(frame->win, "Dismiss", err_func, (xtb_data) 0, &cf);
new_info->contbtn = cf.win;
if (cf.width > frame->width)
frame->width = cf.width;
new_info->alloc_lines = E_LINES;
new_info->num_lines = 0;
new_info->lines = (Window *) Malloc((unsigned) (sizeof(Window) * E_LINES));
/* zero the memory out of paranoia */
memset(new_info->lines, 0, sizeof(Window) * E_LINES);
lineptr = text;
while (getline(&lineptr, line)) {
if (new_info->num_lines >= new_info->alloc_lines) {
int old_alloc_lines_size = new_info->alloc_lines * sizeof(Window);
new_info->alloc_lines *= 2;
new_info->lines = (Window *) Realloc((char *) new_info->lines,
(unsigned)
(new_info->alloc_lines *
sizeof(Window)));
memset(((char*)new_info->lines) + old_alloc_lines_size,
0, old_alloc_lines_size);
}
xtb_to_new(frame->win, line, medFont, &lf);
new_info->lines[new_info->num_lines] = lf.win;
new_info->num_lines += 1;
if (lf.width > frame->width)
frame->width = lf.width;
}
/* Placement */
frame->width += (2 * E_HPAD);
y = E_VPAD;
/* Title */
XMoveWindow(disp, new_info->title, (int) (frame->width / 2 - tf.width / 2), y);
y += (tf.height + E_INTER);
/* All lines */
for (i = 0; i < new_info->num_lines; i++) {
XMoveWindow(disp, new_info->lines[i], E_HPAD, y);
y += (lf.height + E_INTER);
}
/* Button */
XMoveWindow(disp, new_info->contbtn, (int) (frame->width / 2 - cf.width / 2), y);
y += (cf.height + E_INTER);
/* Make dialog the right size */
y += (E_VPAD - E_INTER);
XResizeWindow(disp, frame->win, frame->width, (unsigned int) y);
hints.flags = PSize;
hints.width = frame->width;
hints.height = (unsigned int) y;
XSetNormalHints(disp, frame->win, &hints);
frame->width += (2 * D_BRDR);
frame->height = y + (2 * D_BRDR);
xtb_register(frame->win, (xtb_hret(*) ()) 0, (xtb_data) new_info);
}
void
msg_box(title, text)
char *title,
*text;
/*
* This posts a dialog that contains lines of text and a continue
* button. The text may be multiple lines. The dialog is remade
* each time.
*/
{
#ifdef SHADOW
Window shadow;
#endif
XWindowAttributes info;
XEvent evt;
XSizeHints hints;
xtb_frame text_frame;
make_msg_box(text, title, &text_frame);
#ifdef SHADOW
shadow = make_shadow(w, h);
#endif
XGetWindowAttributes(disp, RootWindow(disp, screen), &info);
XMoveWindow(disp, text_frame.win, (int) (info.width / 2 - text_frame.width / 2),
(int) (info.height / 2 - text_frame.height / 2));
hints.flags = PPosition;
hints.x = info.width / 2 - text_frame.width / 2;
hints.y = info.height / 2 - text_frame.height / 2;
XSetNormalHints(disp, text_frame.win, &hints);
#ifdef SHADOW
XMoveWindow(disp, shadow, info.width / 2 - w / 2 + SH_W,
info.height / 2 - h / 2 + SH_H);
hints.flags = PPosition;
hints.x = info.width / 2 - w / 2 + SH_W;
hints.y = info.height / 2 - h / 2 + SH_H;
XSetNormalHints(disp, text_frame.win, &hints);
XRaiseWindow(disp, shadow);
XMapWindow(disp, shadow);
#endif
XRaiseWindow(disp, text_frame.win);
XMapWindow(disp, text_frame.win);
do {
XNextEvent(disp, &evt);
} while (xtb_dispatch(&evt) != XTB_STOP);
#ifdef SHADOW
XDestroyWindow(disp, shadow);
#endif
del_msg_box(text_frame.win);
}
void
do_error(err_text)
char *err_text;
{
if (PM_INT("Output Device") == D_XWINDOWS)
msg_box("Xgraph Error", err_text);
else
fputs(err_text, stderr);
}
int
getline(tptr, lptr)
char **tptr;
char *lptr;
/*
* Returns next line from tptr. Assumes `lptr' is large enough to
* accept the line.
*/
{
char *start;
start = *tptr;
while (*tptr && **tptr && (**tptr != '\n')) {
(*tptr)++;
}
if (*tptr > start) {
(void) strncpy(lptr, start, (*tptr - start));
lptr[*tptr - start] = '\0';
if (**tptr == '\n')
(*tptr)++;
return 1;
}
else {
return 0;
}
}
static void
del_msg_box(msg)
Window msg;
/*
* Deletes all components of an msg box
*/
{
struct err_info *info;
char *dummy;
int i;
if (xtb_unregister(msg, (xtb_data *) & info)) {
xtb_to_del(info->title);
xtb_bt_del(info->contbtn, (xtb_data *) & dummy);
for (i = 0; i < info->num_lines; i++) {
xtb_to_del(info->lines[i]);
}
Free((char *) info->lines);
Free((char *) info);
XDestroyWindow(disp, msg);
}
}

1263
xgraph/draw.c Normal file

File diff suppressed because it is too large Load Diff

2047
xgraph/examples/Animation.xg Normal file

File diff suppressed because it is too large Load Diff

21
xgraph/examples/bar.xg Normal file
View File

@ -0,0 +1,21 @@
TitleText: Sample Bar Graph
BarGraph: true
BarBase: 0.0
BarWidth: 0.25
NoLines: true
YUnitText: Widgets/Year
XUnitText: Year
"Frobs"
79.75 5.6
80.75 8.3
81.75 2.2
"Blobs"
80 8.0
81 6.4
82 1.2
"Zygotes"
80.25 9.1
81.25 10.8
82.25 8.3

1805
xgraph/examples/surface.xg Normal file

File diff suppressed because it is too large Load Diff

631
xgraph/examples/surface2.xg Normal file
View File

@ -0,0 +1,631 @@
TitleText: Another Surface Plot
ticks: on
boundbox: on
move 367.000000 10.000000
draw 390.000000 22.000000
move 367.000000 10.000000
draw 390.000000 22.000000
move 320.000000 188.000000
draw 367.000000 10.000000
move 320.000000 188.000000
draw 367.000000 10.000000
move 390.000000 22.000000
draw 412.000000 33.000000
move 390.000000 22.000000
draw 412.000000 33.000000
move 343.000000 200.000000
draw 390.000000 22.000000
move 390.000000 22.000000
draw 390.000000 22.000000
move 412.000000 33.000000
draw 457.000000 56.000000
move 412.000000 33.000000
draw 457.000000 56.000000
move 365.000000 211.000000
draw 412.000000 33.000000
move 412.000000 33.000000
draw 412.000000 33.000000
move 457.000000 56.000000
draw 523.000000 91.000000
move 457.000000 56.000000
draw 523.000000 91.000000
move 410.000000 234.000000
draw 457.000000 56.000000
move 457.000000 56.000000
draw 457.000000 56.000000
move 523.000000 91.000000
draw 545.000000 102.000000
move 523.000000 91.000000
draw 545.000000 102.000000
move 477.000000 267.000000
draw 523.000000 91.000000
move 523.000000 91.000000
draw 523.000000 91.000000
move 545.000000 102.000000
draw 589.000000 125.000000
move 545.000000 102.000000
draw 589.000000 125.000000
move 500.000000 258.000000
draw 545.000000 102.000000
move 545.000000 102.000000
draw 545.000000 102.000000
move 589.000000 125.000000
draw 632.000000 147.000000
move 589.000000 125.000000
draw 632.000000 147.000000
move 544.000000 246.000000
draw 589.000000 125.000000
move 589.000000 125.000000
draw 589.000000 125.000000
move 632.000000 147.000000
draw 675.000000 170.000000
move 632.000000 147.000000
draw 675.000000 170.000000
move 588.000000 242.000000
draw 632.000000 147.000000
move 632.000000 147.000000
draw 632.000000 147.000000
move 675.000000 170.000000
draw 718.000000 192.000000
move 675.000000 170.000000
draw 718.000000 192.000000
move 631.000000 290.000000
draw 675.000000 170.000000
move 675.000000 170.000000
draw 675.000000 170.000000
move 718.000000 192.000000
draw 739.000000 203.000000
move 718.000000 192.000000
draw 739.000000 203.000000
move 674.000000 345.000000
draw 718.000000 192.000000
move 718.000000 192.000000
draw 718.000000 192.000000
move 739.000000 203.000000
draw 803.000000 235.000000
move 739.000000 203.000000
draw 803.000000 235.000000
move 695.000000 376.000000
draw 739.000000 203.000000
move 739.000000 203.000000
draw 739.000000 203.000000
move 803.000000 235.000000
draw 845.000000 257.000000
move 803.000000 235.000000
draw 845.000000 257.000000
move 759.000000 409.000000
draw 803.000000 235.000000
move 803.000000 235.000000
draw 803.000000 235.000000
move 845.000000 257.000000
draw 865.000000 268.000000
move 845.000000 257.000000
draw 865.000000 268.000000
move 801.000000 430.000000
draw 845.000000 257.000000
move 845.000000 257.000000
draw 845.000000 257.000000
move 865.000000 268.000000
draw 886.000000 279.000000
move 865.000000 268.000000
draw 886.000000 279.000000
move 822.000000 440.000000
draw 865.000000 268.000000
move 865.000000 268.000000
draw 865.000000 268.000000
move 843.000000 451.000000
draw 886.000000 279.000000
move 886.000000 279.000000
draw 886.000000 279.000000
move 320.000000 188.000000
draw 343.000000 200.000000
move 320.000000 188.000000
draw 321.000000 189.000000
move 287.000000 245.000000
draw 320.000000 188.000000
move 287.000000 245.000000
draw 320.000000 188.000000
move 343.000000 200.000000
draw 365.000000 211.000000
move 310.000000 257.000000
draw 343.000000 200.000000
move 365.000000 211.000000
draw 410.000000 234.000000
move 332.000000 268.000000
draw 365.000000 211.000000
move 410.000000 234.000000
draw 477.000000 267.000000
move 378.000000 290.000000
draw 410.000000 234.000000
move 477.000000 267.000000
draw 500.000000 258.000000
move 445.000000 323.000000
draw 477.000000 267.000000
move 500.000000 258.000000
draw 544.000000 246.000000
move 467.000000 311.000000
draw 500.000000 258.000000
move 544.000000 246.000000
draw 588.000000 242.000000
move 511.000000 297.000000
draw 544.000000 246.000000
move 588.000000 242.000000
draw 631.000000 290.000000
move 555.000000 287.000000
draw 588.000000 242.000000
move 631.000000 290.000000
draw 674.000000 345.000000
move 599.000000 340.000000
draw 631.000000 290.000000
move 674.000000 345.000000
draw 695.000000 376.000000
move 642.000000 398.000000
draw 674.000000 345.000000
move 695.000000 376.000000
draw 759.000000 409.000000
move 663.000000 431.000000
draw 695.000000 376.000000
move 759.000000 409.000000
draw 801.000000 430.000000
move 727.000000 463.000000
draw 759.000000 409.000000
move 801.000000 430.000000
draw 822.000000 440.000000
move 769.000000 484.000000
draw 801.000000 430.000000
move 822.000000 440.000000
draw 843.000000 451.000000
move 790.000000 495.000000
draw 822.000000 440.000000
move 811.000000 505.000000
draw 843.000000 451.000000
move 287.000000 245.000000
draw 310.000000 257.000000
move 287.000000 245.000000
draw 288.000000 246.000000
move 222.000000 329.000000
draw 287.000000 245.000000
move 222.000000 329.000000
draw 287.000000 245.000000
move 310.000000 257.000000
draw 332.000000 268.000000
move 245.000000 340.000000
draw 310.000000 257.000000
move 332.000000 268.000000
draw 378.000000 290.000000
move 267.000000 351.000000
draw 332.000000 268.000000
move 378.000000 290.000000
draw 445.000000 323.000000
move 313.000000 373.000000
draw 378.000000 290.000000
move 445.000000 323.000000
draw 467.000000 311.000000
move 380.000000 405.000000
draw 445.000000 323.000000
move 467.000000 311.000000
draw 511.000000 297.000000
move 403.000000 389.000000
draw 467.000000 311.000000
move 511.000000 297.000000
draw 555.000000 287.000000
move 447.000000 371.000000
draw 511.000000 297.000000
move 555.000000 287.000000
draw 599.000000 340.000000
move 491.000000 359.000000
draw 555.000000 287.000000
move 599.000000 340.000000
draw 642.000000 398.000000
move 535.000000 414.000000
draw 599.000000 340.000000
move 642.000000 398.000000
draw 663.000000 431.000000
move 578.000000 475.000000
draw 642.000000 398.000000
move 663.000000 431.000000
draw 727.000000 463.000000
move 599.000000 512.000000
draw 663.000000 431.000000
move 727.000000 463.000000
draw 769.000000 484.000000
move 663.000000 543.000000
draw 727.000000 463.000000
move 769.000000 484.000000
draw 790.000000 495.000000
move 705.000000 564.000000
draw 769.000000 484.000000
move 790.000000 495.000000
draw 811.000000 505.000000
move 727.000000 574.000000
draw 790.000000 495.000000
move 748.000000 584.000000
draw 811.000000 505.000000
move 222.000000 329.000000
draw 245.000000 340.000000
move 222.000000 329.000000
draw 223.000000 329.000000
move 190.000000 748.000000
draw 222.000000 329.000000
move 190.000000 748.000000
draw 222.000000 329.000000
move 245.000000 340.000000
draw 267.000000 351.000000
move 213.000000 759.000000
draw 245.000000 340.000000
move 267.000000 351.000000
draw 313.000000 373.000000
move 237.000000 769.000000
draw 267.000000 351.000000
move 313.000000 373.000000
draw 380.000000 405.000000
move 283.000000 790.000000
draw 313.000000 373.000000
move 380.000000 405.000000
draw 403.000000 389.000000
move 352.000000 821.000000
draw 380.000000 405.000000
move 403.000000 389.000000
draw 447.000000 371.000000
move 381.000000 430.000000
draw 403.000000 389.000000
move 447.000000 371.000000
draw 491.000000 359.000000
move 426.000000 407.000000
draw 447.000000 371.000000
move 491.000000 359.000000
draw 535.000000 414.000000
move 470.000000 392.000000
draw 491.000000 359.000000
move 535.000000 414.000000
draw 578.000000 475.000000
move 513.000000 450.000000
draw 535.000000 414.000000
move 578.000000 475.000000
draw 599.000000 512.000000
move 556.000000 514.000000
draw 578.000000 475.000000
move 599.000000 512.000000
draw 663.000000 543.000000
move 576.000000 922.000000
draw 599.000000 512.000000
move 663.000000 543.000000
draw 705.000000 564.000000
move 641.000000 952.000000
draw 663.000000 543.000000
move 705.000000 564.000000
draw 727.000000 574.000000
move 684.000000 971.000000
draw 705.000000 564.000000
move 727.000000 574.000000
draw 748.000000 584.000000
move 706.000000 981.000000
draw 727.000000 574.000000
move 727.000000 991.000000
draw 748.000000 584.000000
move 190.000000 748.000000
draw 213.000000 759.000000
move 190.000000 748.000000
draw 191.000000 748.000000
move 168.000000 759.000000
draw 190.000000 748.000000
move 168.000000 759.000000
draw 190.000000 748.000000
move 213.000000 759.000000
draw 237.000000 769.000000
move 192.000000 769.000000
draw 213.000000 759.000000
move 237.000000 769.000000
draw 283.000000 790.000000
move 215.000000 780.000000
draw 237.000000 769.000000
move 283.000000 790.000000
draw 352.000000 821.000000
move 261.000000 800.000000
draw 283.000000 790.000000
move 352.000000 821.000000
draw 381.000000 430.000000
move 330.000000 831.000000
draw 352.000000 821.000000
move 381.000000 430.000000
draw 426.000000 407.000000
move 381.000000 430.000000
draw 381.000000 430.000000
move 426.000000 407.000000
draw 470.000000 392.000000
move 405.000000 419.000000
draw 426.000000 407.000000
move 470.000000 392.000000
draw 513.000000 450.000000
move 449.000000 404.000000
draw 470.000000 392.000000
move 513.000000 450.000000
draw 556.000000 514.000000
move 492.000000 461.000000
draw 513.000000 450.000000
move 556.000000 514.000000
draw 576.000000 922.000000
move 535.000000 525.000000
draw 556.000000 514.000000
move 576.000000 922.000000
draw 641.000000 952.000000
move 554.000000 932.000000
draw 576.000000 922.000000
move 641.000000 952.000000
draw 684.000000 971.000000
move 620.000000 962.000000
draw 641.000000 952.000000
move 684.000000 971.000000
draw 706.000000 981.000000
move 663.000000 981.000000
draw 684.000000 971.000000
move 706.000000 981.000000
draw 727.000000 991.000000
move 684.000000 991.000000
draw 706.000000 981.000000
move 706.000000 1000.000000
draw 727.000000 991.000000
move 168.000000 759.000000
draw 192.000000 769.000000
move 168.000000 759.000000
draw 170.000000 760.000000
move 145.000000 770.000000
draw 168.000000 759.000000
move 145.000000 770.000000
draw 168.000000 759.000000
move 192.000000 769.000000
draw 215.000000 780.000000
move 168.000000 781.000000
draw 192.000000 769.000000
move 215.000000 780.000000
draw 261.000000 800.000000
move 191.000000 791.000000
draw 215.000000 780.000000
move 261.000000 800.000000
draw 330.000000 831.000000
move 238.000000 812.000000
draw 261.000000 800.000000
move 330.000000 831.000000
draw 331.000000 831.000000
move 306.000000 843.000000
draw 330.000000 831.000000
move 381.000000 431.000000
draw 405.000000 419.000000
move 405.000000 419.000000
draw 449.000000 404.000000
move 381.000000 488.000000
draw 405.000000 419.000000
move 449.000000 404.000000
draw 492.000000 461.000000
move 425.000000 509.000000
draw 449.000000 404.000000
move 492.000000 461.000000
draw 535.000000 525.000000
move 468.000000 530.000000
draw 492.000000 461.000000
move 535.000000 525.000000
draw 554.000000 932.000000
move 512.000000 553.000000
draw 535.000000 525.000000
move 554.000000 932.000000
draw 620.000000 962.000000
move 530.000000 943.000000
draw 554.000000 932.000000
move 620.000000 962.000000
draw 663.000000 981.000000
move 596.000000 972.000000
draw 620.000000 962.000000
move 663.000000 981.000000
draw 684.000000 991.000000
move 639.000000 992.000000
draw 663.000000 981.000000
move 684.000000 991.000000
draw 706.000000 1000.000000
move 661.000000 1001.000000
draw 684.000000 991.000000
move 682.000000 1011.000000
draw 706.000000 1000.000000
move 145.000000 770.000000
draw 168.000000 781.000000
move 145.000000 770.000000
draw 147.000000 771.000000
move 141.000000 772.000000
draw 145.000000 770.000000
move 141.000000 772.000000
draw 145.000000 770.000000
move 168.000000 781.000000
draw 191.000000 791.000000
move 165.000000 782.000000
draw 168.000000 781.000000
move 191.000000 791.000000
draw 238.000000 812.000000
move 188.000000 793.000000
draw 191.000000 791.000000
move 238.000000 812.000000
draw 306.000000 843.000000
move 234.000000 813.000000
draw 238.000000 812.000000
move 306.000000 843.000000
draw 307.000000 843.000000
move 303.000000 844.000000
draw 306.000000 843.000000
move 377.000000 486.000000
draw 381.000000 488.000000
move 381.000000 488.000000
draw 425.000000 509.000000
move 377.000000 492.000000
draw 381.000000 488.000000
move 425.000000 509.000000
draw 468.000000 530.000000
move 421.000000 513.000000
draw 425.000000 509.000000
move 468.000000 530.000000
draw 512.000000 553.000000
move 465.000000 534.000000
draw 468.000000 530.000000
move 512.000000 553.000000
draw 530.000000 943.000000
move 508.000000 556.000000
draw 512.000000 553.000000
move 530.000000 943.000000
draw 596.000000 972.000000
move 527.000000 944.000000
draw 530.000000 943.000000
move 596.000000 972.000000
draw 639.000000 992.000000
move 592.000000 974.000000
draw 596.000000 972.000000
move 639.000000 992.000000
draw 661.000000 1001.000000
move 636.000000 993.000000
draw 639.000000 992.000000
move 661.000000 1001.000000
draw 682.000000 1011.000000
move 657.000000 1003.000000
draw 661.000000 1001.000000
move 679.000000 1012.000000
draw 682.000000 1011.000000
move 141.000000 772.000000
draw 165.000000 782.000000
move 141.000000 772.000000
draw 143.000000 773.000000
move 139.000000 773.000000
draw 141.000000 772.000000
move 139.000000 773.000000
draw 141.000000 772.000000
move 165.000000 782.000000
draw 188.000000 793.000000
move 162.000000 783.000000
draw 165.000000 782.000000
move 188.000000 793.000000
draw 234.000000 813.000000
move 186.000000 794.000000
draw 188.000000 793.000000
move 234.000000 813.000000
draw 303.000000 844.000000
move 232.000000 815.000000
draw 234.000000 813.000000
move 303.000000 844.000000
draw 304.000000 844.000000
move 301.000000 845.000000
draw 303.000000 844.000000
move 377.000000 492.000000
draw 377.000000 492.000000
move 377.000000 492.000000
draw 421.000000 513.000000
move 377.000000 492.000000
draw 377.000000 492.000000
move 421.000000 513.000000
draw 465.000000 534.000000
move 419.000000 517.000000
draw 421.000000 513.000000
move 465.000000 534.000000
draw 508.000000 556.000000
move 463.000000 538.000000
draw 465.000000 534.000000
move 508.000000 556.000000
draw 527.000000 944.000000
move 506.000000 559.000000
draw 508.000000 556.000000
move 527.000000 944.000000
draw 592.000000 974.000000
move 525.000000 946.000000
draw 527.000000 944.000000
move 592.000000 974.000000
draw 636.000000 993.000000
move 590.000000 975.000000
draw 592.000000 974.000000
move 636.000000 993.000000
draw 657.000000 1003.000000
move 634.000000 994.000000
draw 636.000000 993.000000
move 657.000000 1003.000000
draw 679.000000 1012.000000
move 655.000000 1004.000000
draw 657.000000 1003.000000
move 677.000000 1013.000000
draw 679.000000 1012.000000
move 139.000000 773.000000
draw 162.000000 783.000000
move 139.000000 773.000000
draw 141.000000 774.000000
move 138.000000 774.000000
draw 139.000000 773.000000
move 138.000000 774.000000
draw 139.000000 773.000000
move 162.000000 783.000000
draw 186.000000 794.000000
move 161.000000 784.000000
draw 162.000000 783.000000
move 186.000000 794.000000
draw 232.000000 815.000000
move 185.000000 794.000000
draw 186.000000 794.000000
move 232.000000 815.000000
draw 301.000000 845.000000
move 231.000000 815.000000
draw 232.000000 815.000000
move 301.000000 845.000000
draw 302.000000 845.000000
move 300.000000 846.000000
draw 301.000000 845.000000
move 377.000000 497.000000
draw 419.000000 517.000000
move 419.000000 517.000000
draw 463.000000 538.000000
move 418.000000 519.000000
draw 419.000000 517.000000
move 463.000000 538.000000
draw 506.000000 559.000000
move 462.000000 540.000000
draw 463.000000 538.000000
move 506.000000 559.000000
draw 525.000000 946.000000
move 505.000000 562.000000
draw 506.000000 559.000000
move 525.000000 946.000000
draw 590.000000 975.000000
move 523.000000 946.000000
draw 525.000000 946.000000
move 590.000000 975.000000
draw 634.000000 994.000000
move 589.000000 975.000000
draw 590.000000 975.000000
move 634.000000 994.000000
draw 655.000000 1004.000000
move 632.000000 995.000000
draw 634.000000 994.000000
move 655.000000 1004.000000
draw 677.000000 1013.000000
move 654.000000 1004.000000
draw 655.000000 1004.000000
move 675.000000 1014.000000
draw 677.000000 1013.000000
move 138.000000 774.000000
draw 161.000000 784.000000
move 138.000000 774.000000
draw 139.000000 774.000000
move 161.000000 784.000000
draw 185.000000 794.000000
move 185.000000 794.000000
draw 231.000000 815.000000
move 231.000000 815.000000
draw 300.000000 846.000000
move 300.000000 846.000000
draw 301.000000 845.000000
move 376.000000 499.000000
draw 418.000000 519.000000
move 418.000000 519.000000
draw 462.000000 540.000000
move 462.000000 540.000000
draw 505.000000 562.000000
move 505.000000 562.000000
draw 523.000000 946.000000
move 523.000000 946.000000
draw 589.000000 975.000000
move 589.000000 975.000000
draw 632.000000 995.000000
move 632.000000 995.000000
draw 654.000000 1004.000000
move 654.000000 1004.000000
draw 675.000000 1014.000000

667
xgraph/examples/surface3.xg Normal file
View File

@ -0,0 +1,667 @@
TitleText: Last Surface Plot
ticks: on
Boundbox: on
move 641.000000 167.000000
draw 664.000000 156.000000
move 641.000000 167.000000
draw 664.000000 156.000000
move 664.000000 156.000000
draw 664.000000 156.000000
move 661.000000 10.000000
draw 664.000000 156.000000
move 614.000000 32.000000
draw 641.000000 167.000000
move 614.000000 32.000000
draw 641.000000 167.000000
move 641.000000 167.000000
draw 641.000000 167.000000
move 638.000000 21.000000
draw 641.000000 167.000000
move 568.000000 55.000000
draw 614.000000 32.000000
move 568.000000 55.000000
draw 614.000000 32.000000
move 614.000000 32.000000
draw 615.000000 33.000000
move 614.000000 32.000000
draw 615.000000 33.000000
move 501.000000 89.000000
draw 568.000000 55.000000
move 501.000000 89.000000
draw 568.000000 55.000000
move 568.000000 55.000000
draw 570.000000 56.000000
move 568.000000 55.000000
draw 569.000000 56.000000
move 478.000000 100.000000
draw 501.000000 89.000000
move 478.000000 100.000000
draw 501.000000 89.000000
move 501.000000 89.000000
draw 502.000000 90.000000
move 501.000000 89.000000
draw 502.000000 90.000000
move 434.000000 122.000000
draw 478.000000 100.000000
move 434.000000 122.000000
draw 478.000000 100.000000
move 478.000000 100.000000
draw 479.000000 101.000000
move 478.000000 100.000000
draw 479.000000 101.000000
move 389.000000 145.000000
draw 434.000000 122.000000
move 389.000000 145.000000
draw 434.000000 122.000000
move 434.000000 122.000000
draw 435.000000 123.000000
move 434.000000 122.000000
draw 435.000000 123.000000
move 345.000000 167.000000
draw 389.000000 145.000000
move 345.000000 167.000000
draw 389.000000 145.000000
move 389.000000 145.000000
draw 391.000000 145.000000
move 389.000000 145.000000
draw 391.000000 145.000000
move 302.000000 188.000000
draw 345.000000 167.000000
move 302.000000 188.000000
draw 345.000000 167.000000
move 345.000000 167.000000
draw 347.000000 167.000000
move 345.000000 167.000000
draw 347.000000 167.000000
move 280.000000 199.000000
draw 302.000000 188.000000
move 280.000000 199.000000
draw 302.000000 188.000000
move 302.000000 188.000000
draw 303.000000 189.000000
move 302.000000 188.000000
draw 303.000000 189.000000
move 215.000000 232.000000
draw 280.000000 199.000000
move 215.000000 232.000000
draw 280.000000 199.000000
move 280.000000 199.000000
draw 281.000000 200.000000
move 280.000000 199.000000
draw 281.000000 200.000000
move 173.000000 253.000000
draw 215.000000 232.000000
move 173.000000 253.000000
draw 215.000000 232.000000
move 215.000000 232.000000
draw 217.000000 232.000000
move 215.000000 232.000000
draw 217.000000 232.000000
move 152.000000 406.000000
draw 173.000000 253.000000
move 152.000000 406.000000
draw 173.000000 253.000000
move 173.000000 253.000000
draw 174.000000 254.000000
move 173.000000 253.000000
draw 174.000000 254.000000
move 130.000000 417.000000
draw 152.000000 406.000000
move 130.000000 417.000000
draw 152.000000 406.000000
move 152.000000 406.000000
draw 153.000000 399.000000
move 152.000000 406.000000
draw 153.000000 264.000000
move 130.000000 417.000000
draw 131.000000 417.000000
move 130.000000 417.000000
draw 131.000000 275.000000
move 638.000000 21.000000
draw 661.000000 10.000000
move 661.000000 10.000000
draw 663.000000 11.000000
move 615.000000 33.000000
draw 616.000000 32.000000
move 615.000000 33.000000
draw 638.000000 21.000000
move 638.000000 21.000000
draw 639.000000 22.000000
move 570.000000 56.000000
draw 615.000000 33.000000
move 615.000000 33.000000
draw 615.000000 33.000000
move 615.000000 33.000000
draw 617.000000 34.000000
move 615.000000 33.000000
draw 616.000000 34.000000
move 502.000000 90.000000
draw 570.000000 56.000000
move 502.000000 90.000000
draw 503.000000 90.000000
move 570.000000 56.000000
draw 572.000000 57.000000
move 479.000000 101.000000
draw 502.000000 90.000000
move 479.000000 101.000000
draw 502.000000 90.000000
move 502.000000 90.000000
draw 504.000000 91.000000
move 502.000000 90.000000
draw 503.000000 91.000000
move 435.000000 123.000000
draw 479.000000 101.000000
move 435.000000 123.000000
draw 479.000000 101.000000
move 479.000000 101.000000
draw 482.000000 102.000000
move 479.000000 101.000000
draw 481.000000 102.000000
move 391.000000 145.000000
draw 435.000000 123.000000
move 391.000000 145.000000
draw 435.000000 123.000000
move 435.000000 123.000000
draw 437.000000 124.000000
move 435.000000 123.000000
draw 436.000000 124.000000
move 347.000000 167.000000
draw 391.000000 145.000000
move 347.000000 167.000000
draw 391.000000 145.000000
move 391.000000 145.000000
draw 393.000000 146.000000
move 391.000000 145.000000
draw 392.000000 146.000000
move 303.000000 189.000000
draw 347.000000 167.000000
move 303.000000 189.000000
draw 347.000000 167.000000
move 347.000000 167.000000
draw 349.000000 168.000000
move 347.000000 167.000000
draw 348.000000 168.000000
move 281.000000 200.000000
draw 303.000000 189.000000
move 281.000000 200.000000
draw 303.000000 189.000000
move 303.000000 189.000000
draw 305.000000 190.000000
move 303.000000 189.000000
draw 304.000000 190.000000
move 217.000000 232.000000
draw 281.000000 200.000000
move 217.000000 232.000000
draw 281.000000 200.000000
move 281.000000 200.000000
draw 283.000000 201.000000
move 281.000000 200.000000
draw 282.000000 201.000000
move 174.000000 254.000000
draw 217.000000 232.000000
move 174.000000 254.000000
draw 217.000000 232.000000
move 217.000000 232.000000
draw 219.000000 233.000000
move 217.000000 232.000000
draw 218.000000 233.000000
move 173.000000 254.000000
draw 174.000000 254.000000
move 153.000000 264.000000
draw 174.000000 254.000000
move 174.000000 254.000000
draw 176.000000 255.000000
move 174.000000 254.000000
draw 175.000000 255.000000
move 131.000000 275.000000
draw 153.000000 264.000000
move 153.000000 264.000000
draw 154.000000 265.000000
move 131.000000 275.000000
draw 133.000000 276.000000
move 663.000000 11.000000
draw 663.000000 11.000000
move 665.000000 12.000000
draw 667.000000 13.000000
move 663.000000 11.000000
draw 667.000000 13.000000
move 617.000000 34.000000
draw 618.000000 34.000000
move 572.000000 57.000000
draw 617.000000 34.000000
move 617.000000 34.000000
draw 619.000000 35.000000
move 504.000000 91.000000
draw 572.000000 57.000000
move 572.000000 57.000000
draw 575.000000 59.000000
move 482.000000 102.000000
draw 504.000000 91.000000
move 504.000000 91.000000
draw 507.000000 93.000000
move 437.000000 124.000000
draw 482.000000 102.000000
move 482.000000 102.000000
draw 485.000000 104.000000
move 393.000000 146.000000
draw 437.000000 124.000000
move 437.000000 124.000000
draw 440.000000 126.000000
move 349.000000 168.000000
draw 393.000000 146.000000
move 393.000000 146.000000
draw 396.000000 148.000000
move 305.000000 190.000000
draw 349.000000 168.000000
move 349.000000 168.000000
draw 352.000000 170.000000
move 283.000000 201.000000
draw 305.000000 190.000000
move 305.000000 190.000000
draw 308.000000 192.000000
move 219.000000 233.000000
draw 283.000000 201.000000
move 283.000000 201.000000
draw 287.000000 203.000000
move 176.000000 255.000000
draw 219.000000 233.000000
move 219.000000 233.000000
draw 222.000000 235.000000
move 173.000000 256.000000
draw 176.000000 255.000000
move 176.000000 255.000000
draw 179.000000 256.000000
move 665.000000 14.000000
draw 667.000000 13.000000
move 667.000000 13.000000
draw 667.000000 13.000000
move 667.000000 13.000000
draw 690.000000 26.000000
move 667.000000 13.000000
draw 690.000000 26.000000
move 665.000000 36.000000
draw 667.000000 37.000000
move 575.000000 59.000000
draw 620.000000 37.000000
move 507.000000 93.000000
draw 575.000000 59.000000
move 575.000000 59.000000
draw 598.000000 71.000000
move 485.000000 104.000000
draw 507.000000 93.000000
move 507.000000 93.000000
draw 531.000000 105.000000
move 440.000000 126.000000
draw 485.000000 104.000000
move 485.000000 104.000000
draw 508.000000 116.000000
move 396.000000 148.000000
draw 440.000000 126.000000
move 440.000000 126.000000
draw 476.000000 790.000000
move 352.000000 170.000000
draw 396.000000 148.000000
move 396.000000 148.000000
draw 430.000000 812.000000
move 308.000000 192.000000
draw 352.000000 170.000000
move 352.000000 170.000000
draw 384.000000 831.000000
move 287.000000 203.000000
draw 308.000000 192.000000
move 308.000000 192.000000
draw 332.000000 204.000000
move 222.000000 235.000000
draw 287.000000 203.000000
move 287.000000 203.000000
draw 310.000000 215.000000
move 179.000000 256.000000
draw 222.000000 235.000000
move 222.000000 235.000000
draw 245.000000 247.000000
move 173.000000 259.000000
draw 179.000000 256.000000
move 179.000000 256.000000
draw 203.000000 268.000000
move 171.000000 274.000000
draw 181.000000 279.000000
move 667.000000 37.000000
draw 690.000000 26.000000
move 690.000000 26.000000
draw 690.000000 26.000000
move 690.000000 26.000000
draw 711.000000 37.000000
move 690.000000 26.000000
draw 711.000000 37.000000
move 665.000000 38.000000
draw 667.000000 37.000000
move 667.000000 37.000000
draw 688.000000 49.000000
move 598.000000 71.000000
draw 621.000000 60.000000
move 665.000000 60.000000
draw 665.000000 60.000000
move 531.000000 105.000000
draw 598.000000 71.000000
move 598.000000 71.000000
draw 619.000000 82.000000
move 508.000000 116.000000
draw 531.000000 105.000000
move 531.000000 105.000000
draw 552.000000 116.000000
move 476.000000 790.000000
draw 508.000000 116.000000
move 508.000000 116.000000
draw 529.000000 127.000000
move 430.000000 812.000000
draw 476.000000 790.000000
move 476.000000 790.000000
draw 497.000000 801.000000
move 384.000000 831.000000
draw 430.000000 812.000000
move 430.000000 812.000000
draw 451.000000 822.000000
move 332.000000 204.000000
draw 384.000000 831.000000
move 384.000000 831.000000
draw 406.000000 841.000000
move 310.000000 215.000000
draw 332.000000 204.000000
move 332.000000 204.000000
draw 333.000000 205.000000
move 245.000000 247.000000
draw 310.000000 215.000000
move 310.000000 215.000000
draw 331.000000 225.000000
move 203.000000 268.000000
draw 245.000000 247.000000
move 245.000000 247.000000
draw 266.000000 257.000000
move 181.000000 279.000000
draw 203.000000 268.000000
move 203.000000 268.000000
draw 224.000000 279.000000
move 169.000000 285.000000
draw 181.000000 279.000000
move 181.000000 279.000000
draw 202.000000 289.000000
move 168.000000 293.000000
draw 181.000000 300.000000
move 688.000000 49.000000
draw 711.000000 37.000000
move 711.000000 37.000000
draw 711.000000 37.000000
move 711.000000 37.000000
draw 732.000000 49.000000
move 711.000000 37.000000
draw 732.000000 49.000000
move 665.000000 60.000000
draw 688.000000 49.000000
move 688.000000 49.000000
draw 709.000000 60.000000
move 619.000000 82.000000
draw 665.000000 60.000000
move 665.000000 60.000000
draw 686.000000 71.000000
move 552.000000 116.000000
draw 619.000000 82.000000
move 619.000000 82.000000
draw 640.000000 94.000000
move 529.000000 127.000000
draw 552.000000 116.000000
move 552.000000 116.000000
draw 587.000000 732.000000
move 497.000000 801.000000
draw 529.000000 127.000000
move 529.000000 127.000000
draw 565.000000 787.000000
move 451.000000 822.000000
draw 497.000000 801.000000
move 497.000000 801.000000
draw 519.000000 812.000000
move 406.000000 841.000000
draw 451.000000 822.000000
move 451.000000 822.000000
draw 473.000000 832.000000
move 406.000000 841.000000
draw 406.000000 841.000000
move 406.000000 841.000000
draw 428.000000 852.000000
move 331.000000 225.000000
draw 334.000000 224.000000
move 377.000000 747.000000
draw 382.000000 868.000000
move 266.000000 257.000000
draw 331.000000 225.000000
move 331.000000 225.000000
draw 359.000000 833.000000
move 224.000000 279.000000
draw 266.000000 257.000000
move 266.000000 257.000000
draw 287.000000 268.000000
move 202.000000 289.000000
draw 224.000000 279.000000
move 224.000000 279.000000
draw 245.000000 289.000000
move 181.000000 300.000000
draw 202.000000 289.000000
move 202.000000 289.000000
draw 223.000000 300.000000
move 181.000000 300.000000
draw 202.000000 310.000000
move 709.000000 60.000000
draw 732.000000 49.000000
move 732.000000 49.000000
draw 732.000000 49.000000
move 732.000000 49.000000
draw 818.000000 739.000000
move 732.000000 49.000000
draw 818.000000 739.000000
move 686.000000 71.000000
draw 709.000000 60.000000
move 709.000000 60.000000
draw 794.000000 750.000000
move 640.000000 94.000000
draw 686.000000 71.000000
move 686.000000 71.000000
draw 770.000000 760.000000
move 587.000000 732.000000
draw 640.000000 94.000000
move 640.000000 94.000000
draw 723.000000 781.000000
move 565.000000 787.000000
draw 587.000000 732.000000
move 587.000000 732.000000
draw 653.000000 812.000000
move 519.000000 812.000000
draw 565.000000 787.000000
move 565.000000 787.000000
draw 630.000000 822.000000
move 473.000000 832.000000
draw 519.000000 812.000000
move 519.000000 812.000000
draw 583.000000 843.000000
move 428.000000 852.000000
draw 473.000000 832.000000
move 473.000000 832.000000
draw 538.000000 863.000000
move 382.000000 868.000000
draw 428.000000 852.000000
move 428.000000 852.000000
draw 492.000000 882.000000
move 359.000000 833.000000
draw 382.000000 868.000000
move 382.000000 868.000000
draw 447.000000 902.000000
move 287.000000 268.000000
draw 359.000000 833.000000
move 359.000000 833.000000
draw 424.000000 912.000000
move 245.000000 289.000000
draw 287.000000 268.000000
move 287.000000 268.000000
draw 357.000000 941.000000
move 223.000000 300.000000
draw 245.000000 289.000000
move 245.000000 289.000000
draw 313.000000 960.000000
move 202.000000 310.000000
draw 223.000000 300.000000
move 223.000000 300.000000
draw 291.000000 970.000000
move 202.000000 310.000000
draw 269.000000 979.000000
move 794.000000 750.000000
draw 818.000000 739.000000
move 818.000000 739.000000
draw 818.000000 739.000000
move 818.000000 739.000000
draw 850.000000 756.000000
move 818.000000 739.000000
draw 850.000000 756.000000
move 770.000000 760.000000
draw 794.000000 750.000000
move 794.000000 750.000000
draw 826.000000 766.000000
move 723.000000 781.000000
draw 770.000000 760.000000
move 770.000000 760.000000
draw 802.000000 776.000000
move 653.000000 812.000000
draw 723.000000 781.000000
move 723.000000 781.000000
draw 755.000000 797.000000
move 630.000000 822.000000
draw 653.000000 812.000000
move 653.000000 812.000000
draw 685.000000 827.000000
move 583.000000 843.000000
draw 630.000000 822.000000
move 630.000000 822.000000
draw 662.000000 837.000000
move 538.000000 863.000000
draw 583.000000 843.000000
move 583.000000 843.000000
draw 615.000000 858.000000
move 492.000000 882.000000
draw 538.000000 863.000000
move 538.000000 863.000000
draw 570.000000 878.000000
move 447.000000 902.000000
draw 492.000000 882.000000
move 492.000000 882.000000
draw 524.000000 897.000000
move 424.000000 912.000000
draw 447.000000 902.000000
move 447.000000 902.000000
draw 479.000000 917.000000
move 357.000000 941.000000
draw 424.000000 912.000000
move 424.000000 912.000000
draw 456.000000 927.000000
move 313.000000 960.000000
draw 357.000000 941.000000
move 357.000000 941.000000
draw 389.000000 956.000000
move 291.000000 970.000000
draw 313.000000 960.000000
move 313.000000 960.000000
draw 345.000000 975.000000
move 269.000000 979.000000
draw 291.000000 970.000000
move 291.000000 970.000000
draw 323.000000 985.000000
move 269.000000 979.000000
draw 301.000000 994.000000
move 826.000000 766.000000
draw 850.000000 756.000000
move 850.000000 756.000000
draw 850.000000 756.000000
move 850.000000 756.000000
draw 894.000000 777.000000
move 850.000000 756.000000
draw 894.000000 777.000000
move 802.000000 776.000000
draw 826.000000 766.000000
move 826.000000 766.000000
draw 870.000000 787.000000
move 755.000000 797.000000
draw 802.000000 776.000000
move 802.000000 776.000000
draw 846.000000 798.000000
move 685.000000 827.000000
draw 755.000000 797.000000
move 755.000000 797.000000
draw 799.000000 818.000000
move 662.000000 837.000000
draw 685.000000 827.000000
move 685.000000 827.000000
draw 729.000000 848.000000
move 615.000000 858.000000
draw 662.000000 837.000000
move 662.000000 837.000000
draw 706.000000 858.000000
move 570.000000 878.000000
draw 615.000000 858.000000
move 615.000000 858.000000
draw 659.000000 878.000000
move 524.000000 897.000000
draw 570.000000 878.000000
move 570.000000 878.000000
draw 614.000000 898.000000
move 479.000000 917.000000
draw 524.000000 897.000000
move 524.000000 897.000000
draw 568.000000 918.000000
move 456.000000 927.000000
draw 479.000000 917.000000
move 479.000000 917.000000
draw 523.000000 937.000000
move 389.000000 956.000000
draw 456.000000 927.000000
move 456.000000 927.000000
draw 500.000000 947.000000
move 345.000000 975.000000
draw 389.000000 956.000000
move 389.000000 956.000000
draw 433.000000 976.000000
move 323.000000 985.000000
draw 345.000000 975.000000
move 345.000000 975.000000
draw 389.000000 995.000000
move 301.000000 994.000000
draw 323.000000 985.000000
move 323.000000 985.000000
draw 367.000000 1005.000000
move 301.000000 994.000000
draw 345.000000 1014.000000
move 870.000000 787.000000
draw 894.000000 777.000000
move 894.000000 777.000000
draw 894.000000 777.000000
move 846.000000 798.000000
draw 870.000000 787.000000
move 799.000000 818.000000
draw 846.000000 798.000000
move 729.000000 848.000000
draw 799.000000 818.000000
move 706.000000 858.000000
draw 729.000000 848.000000
move 659.000000 878.000000
draw 706.000000 858.000000
move 614.000000 898.000000
draw 659.000000 878.000000
move 568.000000 918.000000
draw 614.000000 898.000000
move 523.000000 937.000000
draw 568.000000 918.000000
move 500.000000 947.000000
draw 523.000000 937.000000
move 433.000000 976.000000
draw 500.000000 947.000000
move 389.000000 995.000000
draw 433.000000 976.000000
move 367.000000 1005.000000
draw 389.000000 995.000000
move 345.000000 1014.000000
draw 367.000000 1005.000000

725
xgraph/examples/xgtest.xg Normal file
View File

@ -0,0 +1,725 @@
Device: Postscript
Disposition: To File
FileOrDev: /usr/tmp/hpgl.out
TitleText: Sample Xgraph Data
"Alpha
-5 29
-4.9 27.91
-4.8 26.84
-4.7 25.79
-4.6 24.76
-4.5 23.75
-4.4 22.76
-4.3 21.79
-4.2 20.84
-4.1 19.91
-4 19
-3.9 18.11
-3.8 17.24
-3.7 16.39
-3.6 15.56
-3.5 14.75
-3.4 13.96
-3.3 13.19
-3.2 12.44
-3.1 11.71
-3 11
-2.9 10.31
-2.8 9.64
-2.7 8.99
-2.6 8.36
-2.5 7.75
-2.4 7.16
-2.3 6.59
-2.2 6.04
-2.1 5.51
-2 5
-1.9 4.51
-1.8 4.04
-1.7 3.59
-1.6 3.16
-1.5 2.75
-1.4 2.36
-1.3 1.99
-1.2 1.64
-1.1 1.31
-1 1
-0.9 0.71
-0.8 0.44
-0.7 0.19
-0.6 -0.04
-0.5 -0.25
-0.4 -0.44
-0.3 -0.61
-0.2 -0.76
-0.1 -0.89
-1.02696E-15 -1
0.1 -1.09
0.2 -1.16
0.3 -1.21
0.4 -1.24
0.5 -1.25
0.6 -1.24
0.7 -1.21
0.8 -1.16
0.9 -1.09
1 -1
1.1 -0.89
1.2 -0.76
1.3 -0.61
1.4 -0.44
1.5 -0.25
1.6 -0.04
1.7 0.19
1.8 0.44
1.9 0.71
2 1
2.1 1.31
2.2 1.64
2.3 1.99
2.4 2.36
2.5 2.75
2.6 3.16
2.7 3.59
2.8 4.04
2.9 4.51
3 5
3.1 5.51
3.2 6.04
3.3 6.59
3.4 7.16
3.5 7.75
3.6 8.36
3.7 8.99
3.8 9.64
3.9 10.31
4 11
4.1 11.71
4.2 12.44
4.3 13.19
4.4 13.96
4.5 14.75
4.6 15.56
4.7 16.39
4.8 17.24
4.9 18.11
5 19
"Beta
-5 33
-4.9 31.81
-4.8 30.64
-4.7 29.49
-4.6 28.36
-4.5 27.25
-4.4 26.16
-4.3 25.09
-4.2 24.04
-4.1 23.01
-4 22
-3.9 21.01
-3.8 20.04
-3.7 19.09
-3.6 18.16
-3.5 17.25
-3.4 16.36
-3.3 15.49
-3.2 14.64
-3.1 13.81
-3 13
-2.9 12.21
-2.8 11.44
-2.7 10.69
-2.6 9.96
-2.5 9.25
-2.4 8.56
-2.3 7.89
-2.2 7.24
-2.1 6.61
-2 6
-1.9 5.41
-1.8 4.84
-1.7 4.29
-1.6 3.76
-1.5 3.25
-1.4 2.76
-1.3 2.29
-1.2 1.84
-1.1 1.41
-1 1
-0.9 0.61
-0.8 0.24
-0.7 -0.11
-0.6 -0.44
-0.5 -0.75
-0.4 -1.04
-0.3 -1.31
-0.2 -1.56
-0.1 -1.79
-1.02696E-15 -2
0.1 -2.19
0.2 -2.36
0.3 -2.51
0.4 -2.64
0.5 -2.75
0.6 -2.84
0.7 -2.91
0.8 -2.96
0.9 -2.99
1 -3
1.1 -2.99
1.2 -2.96
1.3 -2.91
1.4 -2.84
1.5 -2.75
1.6 -2.64
1.7 -2.51
1.8 -2.36
1.9 -2.19
2 -2
2.1 -1.79
2.2 -1.56
2.3 -1.31
2.4 -1.04
2.5 -0.75
2.6 -0.44
2.7 -0.11
2.8 0.24
2.9 0.61
3 1
3.1 1.41
3.2 1.84
3.3 2.29
3.4 2.76
3.5 3.25
3.6 3.76
3.7 4.29
3.8 4.84
3.9 5.41
4 6
4.1 6.61
4.2 7.24
4.3 7.89
4.4 8.56
4.5 9.25
4.6 9.96
4.7 10.69
4.8 11.44
4.9 12.21
5 13
"Gamma
-5 37
-4.9 35.71
-4.8 34.44
-4.7 33.19
-4.6 31.96
-4.5 30.75
-4.4 29.56
-4.3 28.39
-4.2 27.24
-4.1 26.11
-4 25
-3.9 23.91
-3.8 22.84
-3.7 21.79
-3.6 20.76
-3.5 19.75
-3.4 18.76
-3.3 17.79
-3.2 16.84
-3.1 15.91
-3 15
-2.9 14.11
-2.8 13.24
-2.7 12.39
-2.6 11.56
-2.5 10.75
-2.4 9.96
-2.3 9.19
-2.2 8.44
-2.1 7.71
-2 7
-1.9 6.31
-1.8 5.64
-1.7 4.99
-1.6 4.36
-1.5 3.75
-1.4 3.16
-1.3 2.59
-1.2 2.04
-1.1 1.51
-1 1
-0.9 0.51
-0.8 0.04
-0.7 -0.41
-0.6 -0.84
-0.5 -1.25
-0.4 -1.64
-0.3 -2.01
-0.2 -2.36
-0.1 -2.69
-1.02696E-15 -3
0.1 -3.29
0.2 -3.56
0.3 -3.81
0.4 -4.04
0.5 -4.25
0.6 -4.44
0.7 -4.61
0.8 -4.76
0.9 -4.89
1 -5
1.1 -5.09
1.2 -5.16
1.3 -5.21
1.4 -5.24
1.5 -5.25
1.6 -5.24
1.7 -5.21
1.8 -5.16
1.9 -5.09
2 -5
2.1 -4.89
2.2 -4.76
2.3 -4.61
2.4 -4.44
2.5 -4.25
2.6 -4.04
2.7 -3.81
2.8 -3.56
2.9 -3.29
3 -3
3.1 -2.69
3.2 -2.36
3.3 -2.01
3.4 -1.64
3.5 -1.25
3.6 -0.84
3.7 -0.41
3.8 0.04
3.9 0.51
4 1
4.1 1.51
4.2 2.04
4.3 2.59
4.4 3.16
4.5 3.75
4.6 4.36
4.7 4.99
4.8 5.64
4.9 6.31
5 7
"Delta
-5 41
-4.9 39.61
-4.8 38.24
-4.7 36.89
-4.6 35.56
-4.5 34.25
-4.4 32.96
-4.3 31.69
-4.2 30.44
-4.1 29.21
-4 28
-3.9 26.81
-3.8 25.64
-3.7 24.49
-3.6 23.36
-3.5 22.25
-3.4 21.16
-3.3 20.09
-3.2 19.04
-3.1 18.01
-3 17
-2.9 16.01
-2.8 15.04
-2.7 14.09
-2.6 13.16
-2.5 12.25
-2.4 11.36
-2.3 10.49
-2.2 9.64
-2.1 8.81
-2 8
-1.9 7.21
-1.8 6.44
-1.7 5.69
-1.6 4.96
-1.5 4.25
-1.4 3.56
-1.3 2.89
-1.2 2.24
-1.1 1.61
-1 1
-0.9 0.41
-0.8 -0.16
-0.7 -0.71
-0.6 -1.24
-0.5 -1.75
-0.4 -2.24
-0.3 -2.71
-0.2 -3.16
-0.1 -3.59
-1.02696E-15 -4
0.1 -4.39
0.2 -4.76
0.3 -5.11
0.4 -5.44
0.5 -5.75
0.6 -6.04
0.7 -6.31
0.8 -6.56
0.9 -6.79
1 -7
1.1 -7.19
1.2 -7.36
1.3 -7.51
1.4 -7.64
1.5 -7.75
1.6 -7.84
1.7 -7.91
1.8 -7.96
1.9 -7.99
2 -8
2.1 -7.99
2.2 -7.96
2.3 -7.91
2.4 -7.84
2.5 -7.75
2.6 -7.64
2.7 -7.51
2.8 -7.36
2.9 -7.19
3 -7
3.1 -6.79
3.2 -6.56
3.3 -6.31
3.4 -6.04
3.5 -5.75
3.6 -5.44
3.7 -5.11
3.8 -4.76
3.9 -4.39
4 -4
4.1 -3.59
4.2 -3.16
4.3 -2.71
4.4 -2.24
4.5 -1.75
4.6 -1.24
4.7 -0.71
4.8 -0.16
4.9 0.41
5 1
"Epsilon
-5 45
-4.9 43.51
-4.8 42.04
-4.7 40.59
-4.6 39.16
-4.5 37.75
-4.4 36.36
-4.3 34.99
-4.2 33.64
-4.1 32.31
-4 31
-3.9 29.71
-3.8 28.44
-3.7 27.19
-3.6 25.96
-3.5 24.75
-3.4 23.56
-3.3 22.39
-3.2 21.24
-3.1 20.11
-3 19
-2.9 17.91
-2.8 16.84
-2.7 15.79
-2.6 14.76
-2.5 13.75
-2.4 12.76
-2.3 11.79
-2.2 10.84
-2.1 9.91
-2 9
-1.9 8.11
-1.8 7.24
-1.7 6.39
-1.6 5.56
-1.5 4.75
-1.4 3.96
-1.3 3.19
-1.2 2.44
-1.1 1.71
-1 1
-0.9 0.31
-0.8 -0.36
-0.7 -1.01
-0.6 -1.64
-0.5 -2.25
-0.4 -2.84
-0.3 -3.41
-0.2 -3.96
-0.1 -4.49
-1.02696E-15 -5
0.1 -5.49
0.2 -5.96
0.3 -6.41
0.4 -6.84
0.5 -7.25
0.6 -7.64
0.7 -8.01
0.8 -8.36
0.9 -8.69
1 -9
1.1 -9.29
1.2 -9.56
1.3 -9.81
1.4 -10.04
1.5 -10.25
1.6 -10.44
1.7 -10.61
1.8 -10.76
1.9 -10.89
2 -11
2.1 -11.09
2.2 -11.16
2.3 -11.21
2.4 -11.24
2.5 -11.25
2.6 -11.24
2.7 -11.21
2.8 -11.16
2.9 -11.09
3 -11
3.1 -10.89
3.2 -10.76
3.3 -10.61
3.4 -10.44
3.5 -10.25
3.6 -10.04
3.7 -9.81
3.8 -9.56
3.9 -9.29
4 -9
4.1 -8.69
4.2 -8.36
4.3 -8.01
4.4 -7.64
4.5 -7.25
4.6 -6.84
4.7 -6.41
4.8 -5.96
4.9 -5.49
5 -5
"Zeta
-5 49
-4.9 47.41
-4.8 45.84
-4.7 44.29
-4.6 42.76
-4.5 41.25
-4.4 39.76
-4.3 38.29
-4.2 36.84
-4.1 35.41
-4 34
-3.9 32.61
-3.8 31.24
-3.7 29.89
-3.6 28.56
-3.5 27.25
-3.4 25.96
-3.3 24.69
-3.2 23.44
-3.1 22.21
-3 21
-2.9 19.81
-2.8 18.64
-2.7 17.49
-2.6 16.36
-2.5 15.25
-2.4 14.16
-2.3 13.09
-2.2 12.04
-2.1 11.01
-2 10
-1.9 9.01
-1.8 8.04
-1.7 7.09
-1.6 6.16
-1.5 5.25
-1.4 4.36
-1.3 3.49
-1.2 2.64
-1.1 1.81
-1 1
-0.9 0.21
-0.8 -0.56
-0.7 -1.31
-0.6 -2.04
-0.5 -2.75
-0.4 -3.44
-0.3 -4.11
-0.2 -4.76
-0.1 -5.39
-1.02696E-15 -6
0.1 -6.59
0.2 -7.16
0.3 -7.71
0.4 -8.24
0.5 -8.75
0.6 -9.24
0.7 -9.71
0.8 -10.16
0.9 -10.59
1 -11
1.1 -11.39
1.2 -11.76
1.3 -12.11
1.4 -12.44
1.5 -12.75
1.6 -13.04
1.7 -13.31
1.8 -13.56
1.9 -13.79
2 -14
2.1 -14.19
2.2 -14.36
2.3 -14.51
2.4 -14.64
2.5 -14.75
2.6 -14.84
2.7 -14.91
2.8 -14.96
2.9 -14.99
3 -15
3.1 -14.99
3.2 -14.96
3.3 -14.91
3.4 -14.84
3.5 -14.75
3.6 -14.64
3.7 -14.51
3.8 -14.36
3.9 -14.19
4 -14
4.1 -13.79
4.2 -13.56
4.3 -13.31
4.4 -13.04
4.5 -12.75
4.6 -12.44
4.7 -12.11
4.8 -11.76
4.9 -11.39
5 -11
"Eta
-5 53
-4.9 51.31
-4.8 49.64
-4.7 47.99
-4.6 46.36
-4.5 44.75
-4.4 43.16
-4.3 41.59
-4.2 40.04
-4.1 38.51
-4 37
-3.9 35.51
-3.8 34.04
-3.7 32.59
-3.6 31.16
-3.5 29.75
-3.4 28.36
-3.3 26.99
-3.2 25.64
-3.1 24.31
-3 23
-2.9 21.71
-2.8 20.44
-2.7 19.19
-2.6 17.96
-2.5 16.75
-2.4 15.56
-2.3 14.39
-2.2 13.24
-2.1 12.11
-2 11
-1.9 9.91
-1.8 8.84
-1.7 7.79
-1.6 6.76
-1.5 5.75
-1.4 4.76
-1.3 3.79
-1.2 2.84
-1.1 1.91
-1 1
-0.9 0.11
-0.8 -0.76
-0.7 -1.61
-0.6 -2.44
-0.5 -3.25
-0.4 -4.04
-0.3 -4.81
-0.2 -5.56
-0.1 -6.29
-1.02696E-15 -7
0.1 -7.69
0.2 -8.36
0.3 -9.01
0.4 -9.64
0.5 -10.25
0.6 -10.84
0.7 -11.41
0.8 -11.96
0.9 -12.49
1 -13
1.1 -13.49
1.2 -13.96
1.3 -14.41
1.4 -14.84
1.5 -15.25
1.6 -15.64
1.7 -16.01
1.8 -16.36
1.9 -16.69
2 -17
2.1 -17.29
2.2 -17.56
2.3 -17.81
2.4 -18.04
2.5 -18.25
2.6 -18.44
2.7 -18.61
2.8 -18.76
2.9 -18.89
3 -19
3.1 -19.09
3.2 -19.16
3.3 -19.21
3.4 -19.24
3.5 -19.25
3.6 -19.24
3.7 -19.21
3.8 -19.16
3.9 -19.09
4 -19
4.1 -18.89
4.2 -18.76
4.3 -18.61
4.4 -18.44
4.5 -18.25
4.6 -18.04
4.7 -17.81
4.8 -17.56
4.9 -17.29
5 -17

0
xgraph/general.h Normal file
View File

97
xgraph/hard_devices.c Normal file
View File

@ -0,0 +1,97 @@
/* $Header$ */
/*
* Hardcopy Devices
*
* This file contains the basic output device table. The hardcopy
* dialog is automatically constructed from this table.
*
* $Log$
* Revision 1.1 2004-01-25 09:00:49 pnenzi
*
* Added xgraph plotting program.
*
* Revision 1.1.1.1 1999/12/03 23:15:52 heideman
* xgraph-12.0
*
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
#include <stdio.h>
#include "copyright.h"
#include "xgout.h"
#include "hard_devices.h"
#include "params.h"
extern int hpglInit();
extern int psInit();
extern int idrawInit();
extern int tgifInit();
struct hard_dev hard_devices[] =
{
{"HPGL", hpglInit, "lpr -P%s", "xgraph.hpgl", "paper",
27.5, "1", 14.0, "1", 12.0, NONE},
{"Postscript", psInit, "lpr -P%s", "xgraph.ps", "$PRINTER",
19.0, "Times-Bold", 18.0, "Times-Roman", 12.0, NO},
{"Idraw", idrawInit,
"cat > /usr/tmp/idraw.tmp.ps; %s /usr/tmp/idraw.tmp.ps&",
"~/.clipboard", "/usr/bin/X11/idraw", 19.0, "Times-Bold", 18.0,
"Times-Roman", 12.0, NONE},
{"Tgif", tgifInit,
"cat > /usr/tmp/xgraph.obj; %s /usr/tmp/xgraph &",
"xgraph.obj", "/usr/bin/X11/tgif", 19.0, "Times-Bold", 18.0,
"Times-Roman", 12.0, NONE}
};
int hard_count = sizeof(hard_devices) / sizeof(struct hard_dev);
#define CHANGE_D(name, field) \
if (param_get(name, &val)) { \
if (val.type == DBL) { \
hard_devices[idx].field = val.dblv.value; \
} \
}
#define CHANGE_S(name, field) \
if (param_get(name, &val)) { \
if (val.type == STR) { \
(void) strcpy(hard_devices[idx].field, val.strv.value); \
} \
}
void
hard_init()
/*
* Changes values in hard_devices structures in accordance with
* parameters set using the parameters module.
*/
{
char nn[BUFSIZ];
int idx;
params val;
for (idx = 0; idx < hard_count; idx++) {
(void) sprintf(nn, "%s.Dimension", hard_devices[idx].dev_name);
CHANGE_D(nn, dev_max_dim);
(void) sprintf(nn, "%s.OutputTitleFont", hard_devices[idx].dev_name);
CHANGE_S(nn, dev_title_font);
(void) sprintf(nn, "%s.OutputTitleSize", hard_devices[idx].dev_name);
CHANGE_D(nn, dev_title_size);
(void) sprintf(nn, "%s.OutputAxisFont", hard_devices[idx].dev_name);
CHANGE_S(nn, dev_axis_font);
(void) sprintf(nn, "%s.OutputAxisSize", hard_devices[idx].dev_name);
CHANGE_D(nn, dev_axis_size);
if (hard_devices[idx].dev_printer[0] == '$') {
extern char *getenv();
char *ptr;
if ((ptr = getenv(&hard_devices[idx].dev_printer[1]))) {
(void) strncpy(hard_devices[idx].dev_printer, ptr, MFNAME - 1);
hard_devices[idx].dev_printer[MFNAME - 1] = '\0';
}
}
}
}

41
xgraph/hard_devices.h Normal file
View File

@ -0,0 +1,41 @@
/*
* Hardcopy Device Header
*
* This file declares the types required for the hardcopy table
* found in hard_devices.c.
*/
#ifndef _h_hard_devices
#define _h_hard_devices
#define MFNAME 25
typedef enum hard_dev_docu_defn {
NONE, NO, YES
} hard_dev_docu;
struct hard_dev {
char *dev_name; /* Device name */
int (*dev_init) (); /* Initialization function */
char *dev_spec; /* Default pipe program */
char dev_file[MFNAME]; /* Default file name */
char dev_printer[MFNAME];/* Default printer name */
double dev_max_dim; /* Default maximum dimension (cm) */
char dev_title_font[MFNAME]; /* Default name of title font */
double dev_title_size; /* Default size of title font (pnts) */
char dev_axis_font[MFNAME]; /* Default name of axis font */
double dev_axis_size; /* Default size of axis font (pnts) */
hard_dev_docu dev_docu; /* Document predicate */
};
extern int hard_count;
extern struct hard_dev hard_devices[];
#define D_HPGL 0
#define D_POSTSCRIPT 1
#define D_IDRAW 2
#define D_TGIF 3
#define D_XWINDOWS 4
extern void hard_init();
#endif /* _h_hard_devices */

337
xgraph/hpgl.c Normal file
View File

@ -0,0 +1,337 @@
/*
* HPGL Output
*
* Tom Quarles
*/
#define MAPX(state,x) ( (x) + P1X + state->clipminX )
#define MAPY(state,y) ( MAXY - (y) + P1Y - state->clipminY)
#include "copyright.h"
#include "xgraph.h"
#include "plotter.h"
#include <stdio.h>
#include <math.h>
static void hpglText();
static void hpglSeg();
static void hpglDot();
static void hpglEnd();
static xgOut hpglInfo =
{
D_COLOR, /* device characteristics */
MAXX, /* width */
MAXY, /* height */
200, /* border padding */
0, /* extra space around axis labels */
250, /* tick length - approx 1/4 inch */
50, /* spacing above legend lables */
0, /* axis font width */
0, /* axis font height */
0, /* title font width */
0, /* title font height */
1000000, /* maximum number of segments */
hpglText, /* text output function */
hpglSeg, /* segment drawing function */
hpglDot, /* dot/marker drawing function */
hpglEnd, /* end of plot function */
NULL, /* userInfo */
};
typedef struct {
double axis_w;
double axis_h;
double title_w;
double title_h;
FILE *plotterFile;
int clipminX;
int clipminY;
int clipmaxX;
int clipmaxY;
} mydata;
/*ARGSUSED*/
int
hpglInit(stream, width, height, title_family, title_size,
axis_family, axis_size, flags, outInfo, errmsg)
FILE *stream; /* output stream */
int width; /* desired width of space in microns */
int height; /* desired height in microns */
char *title_family; /* name of font for titles */
double title_size; /* size of font for titles */
char *axis_family; /* name of font for axes */
double axis_size; /* size of font for axes */
int flags; /* predicate values (ignored) */
xgOut *outInfo; /* my structure */
char errmsg[ERRBUFSIZE]; /* a place to complain to */
{
mydata *myInfo;
myInfo = (mydata *) Malloc(sizeof(mydata));
if (myInfo == NULL)
return 0;
*outInfo = hpglInfo;
outInfo->area_w = MIN(MAXX, width / 25);
outInfo->area_h = MIN(MAXY, height / 25);
/* magic formulas: input sizes are in points = 1/72 inch */
/* my sizes are in cm */
/* plotter units are in units of .025mm ~= 1/1016 inch */
/*
* have to warn of height 1.5 times larger or get bitten by plotter's
* internal padding
*/
/* widths are (arbitrarily) selected to be 2/3 of the height */
/* (cancels with width factor) */
myInfo->axis_w = axis_size * .666 * 2.54 / 72.;
myInfo->axis_h = axis_size * 2.54 / 72.;
myInfo->title_w = title_size * .666 * 2.54 / 72.;
myInfo->title_h = title_size * 2.54 / 72.;
outInfo->axis_pad = axis_size * 1016. * 1.5 / 72.;
outInfo->axis_width = axis_size * 1016. * 1.5 / 72.;
outInfo->axis_height = axis_size * 1016. * .666 / 72.;
outInfo->title_width = title_size * 1016. * 1.5 / 72.;
outInfo->title_height = title_size * 1016. * .666 / 72.;
outInfo->user_state = (char *) myInfo;
myInfo->plotterFile = stream;
myInfo->clipminX = 0;
myInfo->clipminY = 0;
myInfo->clipmaxX = MAXX;
myInfo->clipmaxY = MAXY;
fprintf(myInfo->plotterFile, "PG;IN;\n");
fprintf(myInfo->plotterFile, "DI1,0;\n");
fprintf(myInfo->plotterFile, "IW%d,%d,%d,%d;\n", MAPX(myInfo, 0),
MAPY(myInfo, myInfo->clipmaxY - myInfo->clipminY),
MAPX(myInfo, myInfo->clipmaxX - myInfo->clipminX),
MAPY(myInfo, 0));
return (1);
}
static void
hpglText(userState, x, y, text, just, style)
mydata *userState; /* my state information */
int x,
y; /* coords of text origin */
char *text; /* what to put there */
int just; /* how to justify */
/*
* where the origin is relative to where the text should go as a function of
* the various values of just
*
* T_UPPERLEFT T_TOP T_UPPERRIGHT T_LEFT T_CENTER T_RIGHT
* T_LOWERLEFT T_BOTTOM T_LOWERRIGHT
*
*/
int style; /* T_AXIS = axis font, T_TITLE = title font */
{
fprintf(userState->plotterFile, "PU;SP%d;", TEXTCOLOR);
fprintf(userState->plotterFile, "PA%d,%d;", MAPX(userState, x), MAPY(userState, y));
switch (style) {
case T_AXIS:
fprintf(userState->plotterFile, "SI%f,%f;", userState->axis_w, userState->axis_h);
break;
case T_TITLE:
fprintf(userState->plotterFile, "SI%f,%f;", userState->title_w, userState->title_h);
break;
default:
printf("bad text style %d in hpglText\n", style);
exit(1);
break;
}
switch (just) {
case T_UPPERLEFT:
fprintf(userState->plotterFile, "LO3;\n");
break;
case T_TOP:
fprintf(userState->plotterFile, "LO6;\n");
break;
case T_UPPERRIGHT:
fprintf(userState->plotterFile, "LO9;\n");
break;
case T_LEFT:
fprintf(userState->plotterFile, "LO2;\n");
break;
case T_CENTER:
fprintf(userState->plotterFile, "LO5;\n");
break;
case T_RIGHT:
fprintf(userState->plotterFile, "LO8;\n");
break;
case T_LOWERLEFT:
fprintf(userState->plotterFile, "LO1;\n");
break;
case T_BOTTOM:
fprintf(userState->plotterFile, "LO4;\n");
break;
case T_LOWERRIGHT:
fprintf(userState->plotterFile, "LO7;\n");
break;
default:
printf("bad justification type %d in hpglText\n", just);
exit(1);
break;
}
fprintf(userState->plotterFile, "LB%s\03;", text);
}
static int penselect[8] =
{PEN1, PEN2, PEN3, PEN4, PEN5, PEN6, PEN7, PEN8};
static int lineselect[8] =
{LINE1, LINE2, LINE3, LINE4, LINE5, LINE6,
LINE7, LINE8};
static void
hpglSeg(userState, ns, segs, width, style, lappr, color)
mydata *userState; /* my state information (not used) */
int ns; /* number of segments */
XSegment *segs; /* X array of segments */
int width; /* width of lines in pixels */
int style; /* L_VAR = dotted, L_AXIS = grid, L_ZERO = axis */
int lappr; /* line style */
int color; /* line color */
{
int i;
if (style == L_ZERO) {
fprintf(userState->plotterFile, "SP%d;", PENAXIS); /* select correct pen */
fprintf(userState->plotterFile, "LT;"); /* solid line style */
}
else if (style == L_AXIS) {
fprintf(userState->plotterFile, "SP%d;", PENGRID); /* select correct pen */
fprintf(userState->plotterFile, "LT;"); /* solid line style */
}
else if (style == L_VAR) {
if ((color < 0) || (color > 7)) {
printf("out of range line color %d in hpglLine\n", color);
exit(1);
}
fprintf(userState->plotterFile, "SP%d;", penselect[color]); /* select correct pen */
if ((lappr < 0) || (lappr > 7)) {
printf("out of range line style %d in hpglLine\n", lappr);
exit(1);
}
if (lappr == 0) {
fprintf(userState->plotterFile, "LT;"); /* select solid line
* type */
}
else {
fprintf(userState->plotterFile, "LT%d;", lineselect[lappr]); /* select line type */
}
}
else {
printf("unknown style %d in hpglLine\n", style);
exit(1);
}
for (i = 0; i < ns; i++) {
if (!i || ((segs[i].x1 != segs[i - 1].x2) || (segs[i].y1 != segs[i - 1].y2))) {
/* MOVE */
fprintf(userState->plotterFile, "PU;PA%d,%d;\n", MAPX(userState, segs[i].x1),
MAPY(userState, segs[i].y1));
}
/* DRAW */
if (width <= 1) {
fprintf(userState->plotterFile, "PD;PA%d,%d;\n", MAPX(userState, segs[i].x2),
MAPY(userState, segs[i].y2));
}
else { /* ugly - wide lines -> rectangles */
double frac;
int lx,
ly;
int urx,
ury,
ulx,
uly,
llx,
lly,
lrx,
lry;
frac = (width / 2) / sqrt((double)
((segs[i].x1 - segs[i].x2) *
(segs[i].x1 - segs[i].x2)) +
((segs[i].y1 - segs[i].y2) *
(segs[i].y1 - segs[i].y2)));
lx = frac * (segs[i].y2 - segs[i].y1);
ly = -frac * (segs[i].x2 - segs[i].x1);
urx = segs[i].x2 + lx;
ury = segs[i].y2 + ly;
ulx = segs[i].x2 - lx;
uly = segs[i].y2 - ly;
llx = segs[i].x1 - lx;
lly = segs[i].y1 - ly;
lrx = segs[i].x1 + lx;
lry = segs[i].y1 + ly;
fprintf(userState->plotterFile, "PU;PA%d,%d;", MAPX(userState, llx),
MAPY(userState, lly));
fprintf(userState->plotterFile, "PM0;");
fprintf(userState->plotterFile, "PD,PA%d,%D;PA%d,%D;PA%d,%d;\n",
MAPX(userState, lrx), MAPY(userState, lry),
MAPX(userState, urx), MAPY(userState, ury),
MAPX(userState, ulx), MAPY(userState, uly));
fprintf(userState->plotterFile, "PM2;FP;EP;");
}
}
fprintf(userState->plotterFile, "PU;");
}
static char *markselect[8] =
{MARK1, MARK2, MARK3, MARK4, MARK5, MARK6,
MARK7, MARK8};
static void
hpglDot(userState, x, y, style, type, color)
mydata *userState; /* my state information (not used) */
int x,
y; /* coord of dot */
int style; /* type of dot */
int type; /* dot style variation */
int color; /* color of dot */
{
/* move to given coord */
fprintf(userState->plotterFile, "PU;PA%d,%d;\n", MAPX(userState, x), MAPY(userState, y));
if ((color < 0) || (color > 7)) {
printf("unknown color %d in hpglDot\n", color);
exit(1);
}
fprintf(userState->plotterFile, "SP%d;", penselect[color]);
if (style == P_PIXEL) {
fprintf(userState->plotterFile, "PD;PU;\n");
}
else if (style == P_DOT) {
fprintf(userState->plotterFile, "LT;PM0;CI40;PM2;FT;EP;\n");
}
else if (style == P_MARK) {
if ((type < 0) || (type > 7)) {
printf("unknown marker type %d in hpglDot\n", type);
exit(1);
}
/*
* fprintf(userState->plotterFile,"LT;CA5;LO4;SI0.1;LB%s\03;\n",marksele
* ct[type]);
*/
fprintf(userState->plotterFile, "LT;CS5;LO4;SI0.15;SM%s;PR0,0;SM;CS;\n", markselect[type]);
}
else {
printf("unknown marker style %d in hpglDot\n", style);
exit(1);
}
}
static void
hpglEnd(userState)
mydata *userState; /* my state information (not used) */
{
fprintf(userState->plotterFile, "SP;PG;IN;\n");
fflush(userState->plotterFile);
return;
}

498
xgraph/idraw.c Normal file
View File

@ -0,0 +1,498 @@
/*
* Idraw Output
*
* Beorn Johnson
* Alan Kramer
* David Harrison
*/
#include <stdio.h>
#include <X11/Xlib.h>
#include "hard_devices.h"
#include "xgout.h"
#define HEIGHT 792
#define FIX(X) X = HEIGHT - X;
typedef struct {
char *title_font;
char *axis_font;
int title_size;
int axis_size;
FILE *strm;
} Info;
char *idraw_prologue[] =
{
"%I Idraw 4",
"Begin",
"%I b u",
"%I cfg u",
"%I cbg u",
"%I f u",
"%I p u",
"%I t",
"[ 1 0 0 1 0 0 ] concat",
"/originalCTM matrix currentmatrix def",
0
};
/*
* Hardcopy Interface for Xgraph
*
* Major differences from first version:
* Four new parameters are passed to the device initialization routine:
* title_family, title_size, axis_family, and axis_size. See the
* description of xg_init() for details.
*
* Clipping is done automatically by xgraph. The xg_clip() routine
* is obsolete.
*
* The xg_line() routine has become the xg_seg() routine. It now
* draws segments rather than a series of lines.
*
* A new field (max_segs) in the device structure now specifies
* the maximum number of segments the device can handle in a group.
*/
/*
* Adding an output device to xgraph
*
* Step 1
* Write versions of the following routines for your device:
* xg_init(), xg_text(), xg_seg(), xg_dot(), and xg_end().
* The interface and function of these routines are described
* in detail below. These routines should be named according
* to your device. For example, the initialization routine
* for the Postscript output device is psInit(). Also, name
* your source file after your device (e.g. the postscript
* routines are in the file ps.c). Instructions continue
* after the description of the interface routines.
*/
void idrawText();
void idrawDot();
void idrawSeg();
void idrawEnd();
int
idrawInit(strm, width, height, title_family, title_size,
axis_family, axis_size, flags, out_info, errmsg)
FILE *strm; /* Output stream */
int width,
height; /* Size of space (microns) */
char *title_family; /* Name of title font family */
double title_size; /* Title font height (points) */
char *axis_family; /* Name of axis font family */
double axis_size; /* Axis font height (points) */
int flags; /* Flags */
xgOut *out_info; /* Device info (RETURN) */
char errmsg[ERRBUFSIZE]; /* Error message area */
/*
* This routine is called by xgraph just before drawing is to
* begin. The desired size of the plot is given by `width'
* and `height'. The parameters `title_family', `title_size',
* `axis_family', and `axis_size' specify the names of the
* title and axis fonts and their vertical sizes (in points).
* These parameters can be ignored if your device does not
* support multiple fonts. Binary flags are specified in
* the `flags' field. These include:
* D_DOCU:
* If this flag is set, it indicates the user has specified that
* the output will be included in some larger document. Devices
* may choose to use this information to produce output that
* can be integrated into documents with less effort. For example,
* the Postscript output routines produce bounding box information
* when this flag is set.
* The routine should fill in all of the fields of `out_info' with
* appropriate values. The values are described below:
* area_w, area_h:
* Size of the drawing space in device coordinates.
* This should take in account the requested area
* given by `width', and `height'.
* bdr_pad:
* Xgraph will leave this number of device coordinates around
* all of the outer edges of the graph.
* axis_pad:
* Additional space around axis labels (in devcoords)
* so that the labels do not appear crowded.
* legend_pad:
* Space (in devcoords) from the top of legend text to
* the representative line drawn above the legend text.
* tick_len:
* Size of a tick mark placed on axis (in devcoords)
* axis_width:
* An estimate of the width of a large character in
* the axis font (in devcoords). This can be an overestimate. An
* underestimate may produce bad results.
* axis_height:
* An estimate of the height of a large character in
* the axis labeling font (in devcoords).
* title_width, title_height:
* Same as above except for the title font.
* max_segs:
* Due to buffering constraints, some devices may not be able to
* handle massive segment lists. This parameter tells xgraph not
* to send more than `max_segs' segments in one request.
* Output to the device should be written to the stream `strm'.
* The functions are described individually below. After filling
* in the parameters and setting the function pointers, the routine
* should initialize its drawing state and store any extra needed
* information in `user_state'. This value will be passed to all
* other routines during the drawing sequence. If the device
* cannot initialize, it should return a zero status and fill
* `errmsg' with an informative error message.
*/
{
Info *idraw_info;
char **l;
double scx,
scy;
idraw_info = (Info *) Malloc(sizeof(*idraw_info));
for (l = idraw_prologue; *l; l++)
fprintf(strm, "%s\n", *l);
out_info->dev_flags = 0;
scx = width / 612;
scy = height / 792.0;
if (scx > scy) {
scy /= scx;
scx = 1;
}
else {
scx /= scy;
scy = 1;
}
out_info->bdr_pad = title_size / 4;
out_info->axis_pad = 2.0 * axis_size;
out_info->legend_pad = 0;
out_info->area_w = width * 0.00283; /* pts per micron */
out_info->area_h = height * 0.00283;
out_info->tick_len = axis_size;
out_info->axis_height = axis_size;
out_info->title_height = title_size;
out_info->axis_width = (axis_size * 5.0) / 12.0;
out_info->title_width = (title_size * 5.0) / 12.0;
out_info->max_segs = 100;
out_info->xg_text = idrawText;
out_info->xg_seg = idrawSeg;
out_info->xg_dot = idrawDot;
out_info->xg_end = idrawEnd;
out_info->user_state = (char *) idraw_info;
idraw_info->title_font = title_family;
idraw_info->axis_font = axis_family;
idraw_info->title_size = title_size;
idraw_info->axis_size = axis_size;
idraw_info->strm = strm;
return 1;
}
/* Text justifications */
#define T_CENTER 0
#define T_LEFT 1
#define T_UPPERLEFT 2
#define T_TOP 3
#define T_UPPERRIGHT 4
#define T_RIGHT 5
#define T_LOWERRIGHT 6
#define T_BOTTOM 7
#define T_LOWERLEFT 8
/* Text styles */
#define T_AXIS 0
#define T_TITLE 1
static void
idraw_just(x, y, just, size, len)
int *x,
*y; /* Given location (lower left) */
int just; /* Justification */
int size; /* Size in points */
int len; /* Number of chars */
/*
* Unfortunately, idraw really can't display text with a justification.
* This is a horrible hack to try to get around the problem. It tries
* to compute a rough bounding box for the text based on the text height
* and the string length and offset `x,y' appropriately for the justification.
* This is only a hack...
*/
{
int t_width,
t_height;
t_height = size;
t_width = (size * len * 5) / 12; /* Horrible estimate */
switch (just) {
case T_CENTER:
*x -= t_width / 2;
*y += t_height / 2;
break;
case T_LEFT:
*y += t_height / 2;
break;
case T_UPPERLEFT:
/* nothing */
break;
case T_TOP:
*x -= t_width / 2;
break;
case T_UPPERRIGHT:
*x -= t_width;
break;
case T_RIGHT:
*x -= t_width;
*y += t_height / 2;
break;
case T_LOWERRIGHT:
*x -= t_width;
*y += t_height;
break;
case T_BOTTOM:
*x -= t_width / 2;
*y += t_height;
break;
case T_LOWERLEFT:
*y += t_height;
break;
}
/*
* Also, idraw seems to put a space above all text it draws. The
* computation below compensates for this.
*/
*y += (size / 3);
}
void
idrawText(user_state, x, y, text, just, style)
char *user_state; /* Value set in xg_init */
int x,
y; /* Text position (pixels) */
char *text; /* Null terminated text */
int just; /* Justification (above) */
int style; /* Text style (above) */
/*
* This routine should draw text at the indicated position using
* the indicated justification and style. The justification refers
* to the location of the point in reference to the text. For example,
* if just is T_LOWERLEFT, (x,y) should be located at the lower left
* edge of the text string.
*/
{
char *font;
int size;
Info *idraw = (Info *) user_state;
FIX(y);
font = style == T_AXIS ? idraw->axis_font :
idraw->title_font;
size = style == T_AXIS ? idraw->axis_size :
idraw->title_size;
idraw_just(&x, &y, just, size, strlen(text));
fprintf(idraw->strm, "Begin %%I Text\n");
fprintf(idraw->strm, "%%I cfg Black\n");
fprintf(idraw->strm, "0 0 0 SetCFg\n");
fprintf(idraw->strm, "%%I f *%s*-%d-*\n", font, size);
fprintf(idraw->strm, "/%s %d SetF\n", font, size);
fprintf(idraw->strm, "%%I t\n");
fprintf(idraw->strm, "[ 1 0 0 1 %d %d ] concat\n", x, y);
fprintf(idraw->strm, "%%I\n");
fprintf(idraw->strm, "[\n");
fprintf(idraw->strm, "(%s)\n", text);
fprintf(idraw->strm, "] Text\n");
fprintf(idraw->strm, "End\n");
}
/* Line Styles */
#define L_AXIS 0
#define L_ZERO 1
#define L_VAR 2
void
idrawSeg(user_state, ns, seglist, width, style, lappr, color)
char *user_state; /* Value set in xg_init */
int ns; /* Number of segments */
XSegment *seglist; /* X array of segments */
int width; /* Width of lines */
int style; /* See above */
int lappr; /* Line appearence */
int color; /* Line color (if any) */
/*
* This routine draws a number of line segments at the points
* given in `seglist'. Note that contiguous segments need not share
* endpoints but often do. All segments should be `width' devcoords wide
* and drawn in style `style'. If `style' is L_VAR, the parameters
* `color' and `lappr' should be used to draw the line. Both
* parameters vary from 0 to 7. If the device is capable of
* color, `color' varies faster than `style'. If the device
* has no color, `style' will vary faster than `color' and
* `color' can be safely ignored. However, if the
* the device has more than 8 line appearences, the two can
* be combined to specify 64 line style variations.
* Xgraph promises not to send more than the `max_segs' in the
* xgOut structure passed back from xg_init().
*/
{
Info *idraw = (Info *) user_state;
short to_style;
int i,
j,
k;
static unsigned short style_list[] =
{
0xffff, 0xf0f0, 0xcccc, 0xaaaa,
0xf060, 0xf198, 0x7f55, 0x0000,
};
to_style = style == L_AXIS ? 65535
: style == L_ZERO ? 65535
: style_list[lappr];
for (i = 0; i < ns; i++) {
FIX(seglist[i].y1);
FIX(seglist[i].y2);
}
for (i = 0; i < ns; i = j) {
for (j = i + 1; j < ns
&& seglist[j - 1].x2 == seglist[j].x1
&& seglist[j - 1].y2 == seglist[j].y1;
j++);
fprintf(idraw->strm, "Begin %%I MLine\n");
fprintf(idraw->strm, "%%I b %d\n", to_style);
fprintf(idraw->strm, "%d 0 0 [", width);
/* fprintf(idraw -> strm, "%d"); */
fprintf(idraw->strm, "] 0 SetB\n");
fprintf(idraw->strm, "%%I cfg Black\n");
fprintf(idraw->strm, "0 0 0 SetCFg\n");
fprintf(idraw->strm, "%%I cbg White\n");
fprintf(idraw->strm, "1 1 1 SetCBg\n");
fprintf(idraw->strm, "none SetP %%I p n\n");
fprintf(idraw->strm, "%%I t u\n");
fprintf(idraw->strm, "%%I %d\n", j - i + 1);
for (k = i; k < j; k++)
fprintf(idraw->strm, "%d %d\n",
seglist[k].x1, seglist[k].y1);
fprintf(idraw->strm, "%d %d\n",
seglist[k - 1].x2, seglist[k - 1].y2);
fprintf(idraw->strm, "%d MLine\n", j - i + 1);
fprintf(idraw->strm, "End\n");
}
}
/* Marker styles */
#define P_PIXEL 0
#define P_DOT 1
#define P_MARK 2
void
idrawDot(user_state, x, y, style, type, color)
char *user_state; /* Value set in xg_init */
int x,
y; /* Location in pixel units */
int style; /* Dot style */
int type; /* Type of marker */
int color; /* Marker color (if any) */
/*
* This routine should draw a marker at location `x,y'. If the
* style is P_PIXEL, the dot should be a single pixel. If
* the style is P_DOT, the dot should be a reasonably large
* dot. If the style is P_MARK, it should be a distinguished
* mark which is specified by `type' (0-7). If the output
* device is capable of color, the marker should be drawn in
* `color' (0-7) which corresponds with the color for xg_line.
*/
{
}
void
idrawEnd(user_state)
char *user_state;
/*
* This routine is called after a drawing sequence is complete.
* It can be used to clean up the user state and set the device
* state appropriately. This routine is optional in the structure.
*/
{
Info *idraw = (Info *) user_state;
fprintf(idraw->strm, "End %%I eop\n");
fclose(idraw->strm);
}
/*
* Adding an output device to xgraph
*
* Step 2
* Edit the file hard_devices.c. Declare your initialization
* function and add your device to the list of devices,
* hard_devices[]. The structure hard_dev is described below:
*/
#ifdef notdef
extern int idrawInit();
struct hard_dev idraw =
{
"idraw format", idrawInit,
0, ".clipboard", 0,
25, "Times-Bold", 18, "Times", 12
};
#endif
/*
* dev_spec:
* The dev_spec field should be a command that directly outputs to
* your device. The command should contain one %s directive that
* will be filled in with the name of the device from the hardcopy
* dialog.
* dev_file:
* The default file to write output to if the user selects `To File'.
* dev_printer:
* The default printer to write output to if the user selects
* `To Device'.
* dev_max_dim:
* The default maximum dimension for the device in centimeters.
* dev_title_font, dev_title_size:
* The default title font and size. Sizes are specified in
* points (1/72 inch).
* dev_axis_font, dev_axis_size:
* The default axis font and size.
*/
/*
* Adding an output device to xgraph
*
* Step 3
* Edit the file Makefile. Add your source file to the SRC variable
* and the corresponding object file to the OBJ variable. Finally,
* remake xgraph. Your device should now be available in the
* hardcopy dialog.
*/

622
xgraph/init.c Normal file
View File

@ -0,0 +1,622 @@
/* $Header$ */
/*
* init.c: xgraph initialization code
*
* Routines:
* InitSets();
* ParseArgs();
* ReadDefaults();
*
* $Log$
* Revision 1.1 2004-01-25 09:00:49 pnenzi
*
* Added xgraph plotting program.
*
* Revision 1.2 1999/12/19 00:52:06 heideman
* warning suppresion, slightly different flot ahndling
*
* Revision 1.1.1.1 1999/12/03 23:15:53 heideman
* xgraph-12.0
*
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
#include "copyright.h"
#include <stdio.h>
#include <math.h>
#include <pwd.h>
#include <ctype.h>
#include "xgraph.h"
#include "xtb.h"
#include "hard_devices.h"
#include "params.h"
/*
* Default settings for xgraph parameters
*/
/* PW */
#define DEF_ANIMATE "off"
#define DEF_DELAY_VALUE "2"
#define DEF_BORDER_WIDTH "2"
#define DEF_BORDER_COLOR "Black"
#define DEF_TITLE_TEXT "X Graph"
#define DEF_XUNIT_TEXT "X"
#define DEF_YUNIT_TEXT "Y"
#define DEF_TICK_FLAG "off"
#define DEF_TICKAXIS_FLAG "off"
#define DEF_MARK_FLAG "off"
#define DEF_PIXMARK_FLAG "off"
#define DEF_LARGEPIX_FLAG "off"
#define DEF_DIFFMARK_FLAG "off"
#define DEF_BB_FLAG "off"
#define DEF_NOLINE_FLAG "off"
#define DEF_NOLEGEND_FLAG "off"
#define DEF_NOBUTTON_FLAG "off"
#define DEF_LOGX_FLAG "off"
#define DEF_LOGY_FLAG "off"
#define DEF_BAR_FLAG "off"
#define DEF_STK_FLAG "off"
#define DEF_FITX_FLAG "off"
#define DEF_FITY_FLAG "off"
#define DEF_BAR_BASE "0.0"
#define DEF_BAR_OFFS "0.0"
#define DEF_BAR_WIDTH "-1.0"
#define DEF_LINE_WIDTH "0"
#define DEF_GRID_SIZE "0"
#define DEF_GRID_STYLE "10"
#define DEF_LABEL_FONT "helvetica-10"
#define DEF_TITLE_FONT "helvetica-18"
#define DEF_GEOMETRY ""
#define DEF_REVERSE "off"
/* PW Changes these to please JM */
#define DEF_FMT_X "%.4f"
#define DEF_FMT_Y "%.4f"
#define DEF_DEVICE ""
#define DEF_OUTPUT_DEVICE D_XWINDOWS
#define DEF_DISPOSITION "To Device"
#define DEF_FILEORDEV ""
#define DEF_DOCUMENT "off"
#define DEF_SCALE "1.0"
#define DEF_MARKER_FLAG "off"
#define DEF_DIFFMARK_FLAG "off"
#define DEF_PIXMARK_FLAG "off"
#define DEF_LARGEPIX_FLAG "off"
/* Low > High means set it based on the data */
#define DEF_LOW_LIMIT "1.0"
#define DEF_HIGH_LIMIT "0.0"
/* Black and white defaults */
#define DEF_BW_BACKGROUND "white"
#define DEF_BW_BORDER "black"
#define DEF_BW_ZEROCOLOR "black"
#define DEF_BW_ZEROWIDTH "3"
#define DEF_BW_ZEROSTYLE "1"
#define DEF_BW_FOREGROUND "black"
/* Color defaults */
#define DEF_COL_BACKGROUND "#ccc"
#define DEF_COL_BORDER "black"
#define DEF_COL_ZEROCOLOR "white"
#define DEF_COL_ZEROWIDTH "0"
#define DEF_COL_ZEROSTYLE "1"
#define DEF_COL_FOREGROUND "black"
#define DEF_COL_FIRSTSTYLE "1"
/* Default line styles */
static char *defStyle[MAXATTR] =
{
"1", "10", "11110000", "010111", "1110",
"1111111100000000", "11001111", "0011000111"
};
/* Default color names */
/*static char *defColors[MAXATTR] =
{
"red", "SpringGreen", "blue", "yellow",
"cyan", "sienna", "orange", "coral"
};*/
static char *defColors[MAXATTR] =
{
"red", "SpringGreen", "blue", "yellow",
"purple", "orange", "hotpink", "cyan"
};
void
InitSets(o)
int o;
/*
* Initializes the data sets with default information. Sets up
* original values for parameters in parameters package.
*/
{
int idx;
char buf[1024];
if (o == D_XWINDOWS) {
/*
* Used to do all kinds of searching through visuals, etc. Got
* complaints -- so back to the simple version.
*/
vis = DefaultVisual(disp, DefaultScreen(disp));
cmap = DefaultColormap(disp, DefaultScreen(disp));
screen = DefaultScreen(disp);
depth = DefaultDepth(disp, DefaultScreen(disp));
param_init(disp, cmap);
}
else
param_init(NULL, 0);
param_set("Debug", BOOL, "false");
param_set("Geometry", STR, DEF_GEOMETRY);
param_set("ReverseVideo", BOOL, DEF_REVERSE);
param_set("BorderSize", INT, DEF_BORDER_WIDTH);
param_set("TitleText", STR, DEF_TITLE_TEXT);
param_set("XUnitText", STR, DEF_XUNIT_TEXT);
param_set("YUnitText", STR, DEF_YUNIT_TEXT); /* YUnits */
param_set("Ticks", BOOL, DEF_TICK_FLAG);
param_set("TickAxis", BOOL, DEF_TICKAXIS_FLAG);
param_set("Markers", BOOL, DEF_MARKER_FLAG); /* markFlag (-m) */
param_set("StyleMarkers", BOOL, DEF_DIFFMARK_FLAG); /* colorMark (-M) */
param_set("PixelMarkers", BOOL, DEF_PIXMARK_FLAG); /* pixelMarks (-p) */
param_set("LargePixels", BOOL, DEF_LARGEPIX_FLAG); /* bigPixel (-P) */
param_set("BoundBox", BOOL, DEF_BB_FLAG);
param_set("NoLines", BOOL, DEF_NOLINE_FLAG);
param_set("NoLegend", BOOL, DEF_NOLEGEND_FLAG);
param_set("NoButton", BOOL, DEF_NOBUTTON_FLAG);
param_set("LogX", BOOL, DEF_LOGX_FLAG);
param_set("LogY", BOOL, DEF_LOGY_FLAG); /* logYFlag */
param_set("BarGraph", BOOL, DEF_BAR_FLAG);
param_set("StackGraph", BOOL, DEF_STK_FLAG);
param_set("FitX", BOOL, DEF_FITX_FLAG);
param_set("FitY", BOOL, DEF_FITY_FLAG);
param_set("BarBase", DBL, DEF_BAR_BASE);
param_set("BarWidth", DBL, DEF_BAR_WIDTH);
param_set("BarOffset", DBL, DEF_BAR_OFFS);
param_set("LineWidth", INT, DEF_LINE_WIDTH);
param_set("GridSize", INT, DEF_GRID_SIZE);
param_set("GridStyle", STYLE, DEF_GRID_STYLE);
param_set("Format X", STR, DEF_FMT_X);
param_set("Format Y", STR, DEF_FMT_Y);
param_set("Device", STR, DEF_DEVICE);
param_set("Disposition", STR, DEF_DISPOSITION);
param_set("FileOrDev", STR, DEF_FILEORDEV);
sprintf(buf, "%d", o);
param_set("Output Device", INT, buf);
param_set("Document", BOOL, DEF_DOCUMENT);
param_set("Scale", DBL, DEF_SCALE);
/* Set the user bounding box */
param_set("XLowLimit", DBL, DEF_LOW_LIMIT);
param_set("YLowLimit", DBL, DEF_LOW_LIMIT);
param_set("XHighLimit", DBL, DEF_HIGH_LIMIT);
param_set("YHighLimit", DBL, DEF_HIGH_LIMIT);
/* Depends critically on whether the display has color */
if (depth < 4) {
/* Its black and white */
param_set("Background", PIXEL, DEF_BW_BACKGROUND);
param_set("Border", PIXEL, DEF_BW_BORDER);
param_set("ZeroColor", PIXEL, DEF_BW_ZEROCOLOR);
param_set("ZeroWidth", INT, DEF_BW_ZEROWIDTH);
param_set("ZeroStyle", STYLE, DEF_BW_ZEROSTYLE);
param_set("Foreground", PIXEL, DEF_BW_FOREGROUND);
/* Initialize set defaults */
for (idx = 0; idx < MAXATTR; idx++) {
(void) sprintf(buf, "%d.Style", idx);
param_set(buf, STYLE, defStyle[idx]);
(void) sprintf(buf, "%d.Color", idx);
param_set(buf, PIXEL, DEF_BW_FOREGROUND);
}
}
else {
/* Its color */
param_set("Background", PIXEL, DEF_COL_BACKGROUND);
param_set("Border", PIXEL, DEF_COL_BORDER);
param_set("ZeroColor", PIXEL, DEF_COL_ZEROCOLOR);
param_set("ZeroWidth", INT, DEF_COL_ZEROWIDTH);
param_set("ZeroStyle", STYLE, DEF_COL_ZEROSTYLE);
param_set("Foreground", PIXEL, DEF_COL_FOREGROUND);
/* Initalize attribute colors defaults */
for (idx = 0; idx < MAXATTR; idx++) {
(void) sprintf(buf, "%d.Style", idx);
param_set(buf, STYLE, defStyle[idx]);
(void) sprintf(buf, "%d.Color", idx);
param_set(buf, PIXEL, defColors[idx]);
}
}
param_set("LabelFont", FONT, DEF_LABEL_FONT);
param_set("TitleFont", FONT, DEF_TITLE_FONT);
/* PW */
param_set("Animate", BOOL, DEF_ANIMATE);
param_set("DelayValue", INT, DEF_DELAY_VALUE);
/* Initialize the data sets */
for (idx = 0; idx < MAXSETS; idx++) {
(void) sprintf(buf, "Set %d", idx);
PlotData[idx].setName = STRDUP(buf);
PlotData[idx].list = (PointList *) 0;
}
}
static char *def_str;
#define DEF(name, type) \
if (def_str = XGetDefault(disp, Prog_Name, name)) { \
param_set(name, type, def_str); \
}
void
ReadDefaults()
/*
* Reads X default values which override the hard-coded defaults
* set up by InitSets.
*/
{
char newname[100];
int idx;
DEF("Debug", BOOL);
DEF("Geometry", STR);
DEF("Background", PIXEL);
DEF("BorderSize", INT);
DEF("Border", PIXEL);
DEF("GridSize", INT);
DEF("GridStyle", STYLE);
DEF("Foreground", PIXEL);
DEF("ZeroColor", PIXEL);
DEF("ZeroStyle", STYLE);
DEF("ZeroWidth", INT);
DEF("LabelFont", FONT);
DEF("TitleFont", FONT);
DEF("Ticks", BOOL);
DEF("TickAxis", BOOL);
DEF("Device", STR);
DEF("Disposition", STR);
DEF("FileOrDev", STR);
DEF("PixelMarkers", BOOL);
DEF("LargePixels", BOOL);
DEF("Markers", BOOL);
DEF("StyleMarkers", BOOL);
DEF("BoundBox", BOOL);
DEF("NoLines", BOOL);
DEF("LineWidth", INT);
/* PW */
DEF("Animate",BOOL);
DEF("DelayValue",INT);
/* End PW */
/* Read device specific parameters */
for (idx = 0; idx < hard_count; idx++) {
sprintf(newname, "%s.Dimension", hard_devices[idx].dev_name);
DEF(newname, DBL); /* hard_devices[idx].dev_max_dim */
sprintf(newname, "%s.OutputTitleFont", hard_devices[idx].dev_name);
DEF(newname, STR); /* hard_devices[idx].dev_title_font */
sprintf(newname, "%s.OutputTitleSize", hard_devices[idx].dev_name);
DEF(newname, DBL); /* hard_devices[idx].dev_title_size */
sprintf(newname, "%s.OutputAxisFont", hard_devices[idx].dev_name);
DEF(newname, STR); /* hard_devices[idx].dev_axis_font */
sprintf(newname, "%s.OutputAxisSize", hard_devices[idx].dev_name);
DEF(newname, DBL); /* hard_devices[idx].dev_axis_size */
}
/* Read the default line and color attributes */
for (idx = 0; idx < MAXATTR; idx++) {
(void) sprintf(newname, "%d.Style", idx);
DEF(newname, STYLE); /* AllAttrs[idx].lineStyleLen */
(void) sprintf(newname, "%d.Color", idx);
DEF(newname, PIXEL); /* AllAttrs[idx].pixelValue */
}
DEF("ReverseVideo", BOOL);
}
#define FS(str) (void) fprintf(stderr, str)
static void
argerror(err, val)
char *err,
*val;
{
(void) fprintf(stderr, "Error: %s: %s\n\n", val, err);
FS("Usage: xgraph [-device <ps|X|hpgl|idraw|tgif>]\n");
FS("\t[-bd border_color] [-bg background_color] [-fg foreground_color]\n");
FS("\t[-bar] [-brb bar_base] [-brw bar_width] [-bof bar_offset] [-stk]\n");
FS("\t[-bw bdr_width] [-db] [-gw grid_size] [-fitx] [-fity]\n");
FS("\t[-gs grid_style] [-lf label_font] [-lnx] [-lny] [-lw line_width]\n");
FS("\t[-lx x1,x2] [-ly y1,y2] [-m] [-M] [-nl] [-ng] [-nb] [-p] [-P]\n");
FS("\t[-rv] [-t title] [-tf title_font] [-tk] [-scale factor]\n");
FS("\t[-x x_unit_name] [-y y_unit_name] [-fmtx format] [-fmty format]\n");
FS("\t[[-geometry |=]W=H+X+Y] [[-display] <host>:<disp>.<screen>]\n");
FS("\t[-Pprinter|-o output_file|-O output_file] [[-<digit> set_name]\n");
FS("\t[-zg zero_color] [-zw zero_size] [-a] [-dl <delay>] input_files...\n\n");
FS("-bar Draw bar graph with base -brb, width -brw, and offset -bof\n");
FS("-stk Draw bar graph stacking data sets.\n");
FS("-fitx Scale all sets to fit the x-axis [0,1].\n");
FS("-fity Scale all sets to fit the y-axis [0,1].\n");
FS("-fmtx Printf format for the x-axis\n");
FS("-fmty Printf format for the y-axis\n");
FS("-scale Scale the output file with factor\n");
FS("-O fn Printer ready output file\n");
FS("-o fn Encapsulated (document) output file\n");
FS("-bb Draw bounding box around data\n");
FS("-db Turn on debugging\n");
FS("-lnx Logarithmic scale for X axis\n");
FS("-lny Logarithmic scale for Y axis\n");
FS("-m -M Mark points distinctively (M varies with color)\n");
FS("-nl Don't draw lines (scatter plot)\n");
FS("-ng Don't draw legend\n");
FS("-nb Don't draw buttons\n");
FS("-p -P Mark points with dot (P means big dot)\n");
FS("-rv Reverse video on black and white displays\n");
FS("-tk Draw tick marks instead of full grid\n");
FS("-a Start in animation mode\n");
FS("-dl Animation delay. Default is 2\n");
exit(1);
}
#define ARG(opt, name) \
if (strcmp(argv[idx], opt) == 0) { \
if (do_it) param_set(name, BOOL, "on"); \
idx++; continue; \
}
#define ARG2(opt, name, type, missing) \
if (strcmp(argv[idx], opt) == 0) { \
if (idx+1 >= argc) argerror(missing, argv[idx]); \
if (do_it) param_set(name, type, argv[idx+1]); \
idx += 2; continue;\
}
#define MAXLO 30
int
ParseArgs(argc, argv, do_it)
int argc;
char *argv[];
int do_it;
/*
* This routine parses the argument list for xgraph. There are too
* many to mention here so I won't. If `do_it' is non-zero, options
* are actually changed. If `do_it' is zero, the argument list
* is parsed but the options aren't set. The routine is called
* once to obtain the input files then again after the data is
* read to set the options.
*/
{
int idx,
set,
dflag;
char *hi;
dflag = DEF_OUTPUT_DEVICE;
idx = 1;
while (idx < argc) {
if (argv[idx][0] == '-') {
/* Check to see if its a data set name */
if (sscanf(argv[idx], "-%d", &set) == 1) {
/* The next string is a set name */
if (idx + 1 >= argc)
argerror("missing set name", argv[idx]);
if (do_it) {
PlotData[set].setName = argv[idx + 1];
}
idx += 2;
}
else {
/* Some non-dataset option */
ARG2("-x", "XUnitText", STR, "missing axis name");
ARG2("-y", "YUnitText", STR, "missing axis name");
ARG2("-t", "TitleText", STR, "missing plot title");
ARG2("-fg", "Foreground", PIXEL, "missing color name");
ARG2("-bg", "Background", PIXEL, "missing color name");
ARG2("-bd", "Border", PIXEL, "missing color name");
ARG2("-bw", "BorderSize", INT, "missing border size");
ARG2("-zg", "ZeroColor", PIXEL, "missing color name");
ARG2("-zw", "ZeroWidth", INT, "missing width");
ARG2("-tf", "TitleFont", FONT, "missing font name");
ARG2("-lf", "LabelFont", FONT, "missing font name");
/* PW */
ARG2("-dl", "DelayValue", INT, "missing delay value");
/* Doesn't make much sense to PW why this must be
switched, but it must. */
ARG2("-digy", "Format X", STR, "Missing C-String");
ARG2("-digx", "Format Y", STR, "Missing C-String");
ARG("-a", "Animate");
/* End PW */
ARG("-rv", "ReverseVideo");
ARG("-tk", "Ticks");
ARG("-tkax", "TickAxis");
ARG("-bb", "BoundBox");
if (strcmp(argv[idx], "-lx") == 0) {
/* Limit the X coordinates */
if (idx + 1 >= argc)
argerror("missing coordinate(s)",
argv[idx]);
if (hi = index(argv[idx + 1], ',')) {
char low[MAXLO];
(void) strncpy(low, argv[idx + 1], hi - argv[idx + 1]);
low[hi - argv[idx + 1]] = '\0';
hi++;
if (do_it) {
param_set("XLowLimit", DBL, argv[idx + 1]);
param_set("XHighLimit", DBL, hi);
}
}
else {
argerror("limit coordinates not specified right",
argv[idx]);
}
idx += 2;
continue;
}
if (strcmp(argv[idx], "-ly") == 0) {
/* Limit the Y coordinates */
if (idx + 1 >= argc)
argerror("missing coordinate(s)",
argv[idx]);
if (hi = index(argv[idx + 1], ',')) {
char low[MAXLO];
(void) strncpy(low, argv[idx + 1], hi - argv[idx + 1]);
low[hi - argv[idx + 1]] = '\0';
hi++;
if (do_it) {
param_set("YLowLimit", DBL, argv[idx + 1]);
param_set("YHighLimit", DBL, hi);
}
}
else {
argerror("limit coordinates not specified right",
argv[idx]);
}
idx += 2;
continue;
}
ARG2("-lw", "LineWidth", INT, "missing line width");
ARG("-nl", "NoLines");
ARG("-ng", "NoLegend");
ARG("-nb", "NoButton");
ARG("-m", "Markers");
ARG("-M", "StyleMarkers");
ARG("-p", "PixelMarkers");
ARG("-P", "LargePixels");
ARG("-lnx", "LogX");
ARG("-lny", "LogY");
ARG("-bar", "BarGraph");
ARG("-stk", "StackGraph");
ARG("-fitx", "FitX");
ARG("-fity", "FitY");
ARG2("-brw", "BarWidth", DBL, "missing width");
ARG2("-bof", "BarOffset", DBL, "missing offset");
ARG2("-brb", "BarBase", DBL, "missing base");
ARG("-db", "Debug");
ARG2("-gw", "GridSize", INT, "missing grid size");
ARG2("-gs", "GridStyle", STYLE, "missing grid style");
if (strcmp(argv[idx], "-display") == 0) {
/* Harmless display specification */
dflag = D_XWINDOWS;
disp_name = argv[idx+1];
idx += 2;
continue;
}
if (strcmp(argv[idx], "-geometry") == 0) {
if (do_it)
param_set("Geometry", STR, argv[idx + 1]);
idx += 2;
continue;
}
if (strcmp(argv[idx], "-device") == 0) {
if (idx + 1 >= argc)
argerror("missing device", argv[idx]);
if (strcmp(argv[++idx], "hpgl") == 0)
dflag = D_HPGL;
else if (strcmp(argv[idx], "idraw") == 0)
dflag = D_IDRAW;
else if (strcmp(argv[idx], "x") == 0)
dflag = D_XWINDOWS;
else if (strcmp(argv[idx], "ps") == 0)
dflag = D_POSTSCRIPT;
else if (strcmp(argv[idx], "tgif") == 0)
dflag = D_TGIF;
else
argerror("bad device specification", argv[idx]);
idx++;
continue;
}
if (strncmp(argv[idx], "-P", 2) == 0) {
/* Printer spec */
if (do_it)
param_set("Disposition", STR, "To Device");
if (do_it)
param_set("FileOrDev", STR, &(argv[idx][2]));
idx++;
continue;
}
if (strcmp(argv[idx], "-o") == 0) {
if (do_it)
param_set("Disposition", STR, "To File");
if (idx + 1 >= argc)
argerror("missing file", argv[idx]);
if (do_it)
param_set("FileOrDev", STR, argv[idx + 1]);
idx += 2;
continue;
}
if (strcmp(argv[idx], "-O") == 0) {
if (do_it)
param_set("Disposition", STR, "To File");
if (do_it)
param_set("Document", BOOL, "on");
if (idx + 1 >= argc)
argerror("missing file", argv[idx]);
if (do_it)
param_set("FileOrDev", STR, argv[idx + 1]);
idx += 2;
continue;
}
if (strcmp(argv[idx], "-fmtx") == 0) {
if (idx + 1 >= argc)
argerror("missing x format", argv[idx]);
if (do_it)
param_set("Format Y", STR, argv[idx + 1]);
idx += 2;
continue;
}
if (strcmp(argv[idx], "-fmty") == 0) {
if (idx + 1 >= argc)
argerror("missing y format", argv[idx]);
if (do_it)
param_set("Format X", STR, argv[idx + 1]);
idx += 2;
continue;
}
if (strcmp(argv[idx], "-scale") == 0) {
if (idx + 1 >= argc)
argerror("scale factor", argv[idx]);
if (do_it)
param_set("Scale", DBL, argv[idx + 1]);
idx += 2;
continue;
}
argerror("unknown option", argv[idx]);
}
}
else if (argv[idx][0] == '=') {
/* Its a geometry specification */
if (do_it)
param_set("Geometry", STR, argv[idx] + 1);
idx++;
}
else {
/* It might be the host:display string */
if (rindex(argv[idx], ':') == (char *) 0) {
/* Should be an input file */
inFileNames[numFiles] = argv[idx];
numFiles++;
}
idx++;
}
}
return (dflag);
}

251
xgraph/install-sh Executable file
View File

@ -0,0 +1,251 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

190
xgraph/missing Executable file
View File

@ -0,0 +1,190 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
case "$1" in
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing - GNU libit 0.0"
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
aclocal)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acinclude.m4' or \`configure.in'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`configure.in'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acconfig.h' or \`configure.in'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequirements for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0

40
xgraph/mkinstalldirs Executable file
View File

@ -0,0 +1,40 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain
# $Id$
errstatus=0
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# mkinstalldirs ends here

567
xgraph/params.c Normal file
View File

@ -0,0 +1,567 @@
/* $Header$ */
/*
* Xgraph Parameters
*
* This file contains routines for setting and retrieving
* various X style display parameters for xgraph.
*
* $Log$
* Revision 1.1 2004-01-25 09:00:49 pnenzi
*
* Added xgraph plotting program.
*
* Revision 1.2 1999/12/08 19:32:41 heideman
* strcasecmp portability fix
*
* Revision 1.1.1.1 1999/12/03 23:15:52 heideman
* xgraph-12.0
*
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
#include <ctype.h>
#include <stdio.h>
#include "st.h"
#include "params.h"
#include "hard_devices.h"
#include "xgraph.h" /* for string.h */
/* For use by convenience macros */
params param_temp,
*param_temp_ptr;
XColor param_null_color =
{0, 0, 0, 0, 0, 0};
param_style param_null_style =
{STYLE, 0, (char *) 0};
static st_table *param_table = (st_table *) 0;
typedef struct param_full_defn {
param_types type;
char *text_form;
params *real_form;
} param_full;
#define ISO_FONT "*-*-%s-medium-r-normal-*-*-%d-*-*-*-*-iso8859-*"
static Display *param_disp;
static Colormap param_cmap;
static int param_scrn;
static void free_resource();
static params *resolve_entry();
static int strihash();
static int do_color();
static int do_font();
static int do_style();
static int do_bool();
#define DEF_INT "0"
#define DEF_STR ""
#define DEF_FONT "fixed"
#define DEF_PIXEL "black"
#define DEF_STYLE "1"
#define DEF_BOOL "false"
#define DEF_DBL "0.0"
#define DEF_MAX_FONT 1024
#define DEF_MAX_NAMES 10
#define DUP(str) \
strcpy((char *) Malloc((unsigned) (strlen(str)+1)), (str))
void
param_init(disp, cmap)
Display *disp; /* X Connection */
Colormap cmap; /* Colormap for colors */
/*
* Initializes parameter package. The display and colormap arguments
* are used to resolve font and pixel values.
*/
{
param_table = st_init_table(stricmp, strihash);
if (disp != NULL) {
param_disp = disp;
param_cmap = cmap;
/* This could also be a parameter for greater generality */
param_scrn = DefaultScreen(disp);
}
}
void
param_set(name, type, val)
char *name; /* Name of parameter */
param_types type; /* Type */
char *val; /* Text form for value */
/*
* Sets the parameter with the given name to have the type
* `type' and the text value `value'. This will be evaluated
* to its full form the first time it is referenced using
* param_get(). If it is already filled, the old value
* will be reclaimed.
*/
{
param_full *entry;
if (!param_table) {
(void) fprintf(stderr, "Parameter table not initialized\n");
return;
}
if (st_lookup(param_table, name, (char **) &entry)) {
if (entry->real_form)
free_resource(entry->real_form);
entry->real_form = (params *) 0;
}
else {
entry = (param_full *) Malloc(sizeof(param_full));
entry->text_form = (char *) 0;
entry->real_form = (params *) 0;
(void) st_insert(param_table, DUP(name), (char *) entry);
}
entry->type = type;
if (entry->text_form)
(void) Free((char *) (entry->text_form));
entry->text_form = DUP(val);
}
void
param_reset(name, val)
char *name; /* Name of parameter */
char *val; /* Text form for value */
/*
* This routine sets the value of an existing parameter to a new
* value. The type of the parameter remains the same. Changes
* in type should be done by using param_set() directly.
*/
{
param_full *entry;
if (!param_table) {
(void) fprintf(stderr, "Parameter table not initialized\n");
return;
}
if (st_lookup(param_table, name, (char **) &entry))
param_set(name, entry->type, val);
else
(void) fprintf(stderr, "Cannot reset unknown parameter `%s'\n", name);
}
params *
param_get(name, val)
char *name; /* Name of parameter */
params *val; /* Result value */
/*
* Retrieves a value from the parameter table. The value
* is placed in `val'. If successful, the routine will
* return `val'. Otherwise, it will return zero.
*/
{
param_full *entry;
if (!param_table) {
(void) fprintf(stderr, "Parameter table not initialized\n");
return (params *) 0;
}
if (st_lookup(param_table, name, (char **) &entry)) {
if (!entry->real_form)
entry->real_form = resolve_entry(name, entry->type,
entry->text_form);
*val = *(entry->real_form);
return val;
}
else {
return (params *) 0;
}
}
static void
free_resource(val)
params *val; /* Value to free */
/*
* Reclaims a resource based on its type.
*/
{
switch (val->type) {
case INT:
case STR:
case BOOL:
case DBL:
/* No reclaimation necessary */
break;
case PIXEL:
if ((val->pixv.value.pixel != WhitePixel(param_disp, param_scrn)) &&
(val->pixv.value.pixel != BlackPixel(param_disp, param_scrn)))
XFreeColors(param_disp, param_cmap, &(val->pixv.value.pixel), 1, 0);
break;
case FONT:
XFreeFont(param_disp, val->fontv.value);
break;
case STYLE:
(void) Free(val->stylev.dash_list);
break;
}
(void) Free((char *) val);
}
static params *
resolve_entry(name, type, form)
char *name; /* Name of item for errors */
param_types type; /* What type of thing */
char *form; /* Textual form */
/*
* Allocates and returns an appropriate parameter structure
* by translating `form' into its native type as given by `type'.
* If it can't translate the given form, it will fall back onto
* the default.
*/
{
static char paramstr[] =
"Parameter %s: can't translate `%s' into a %s (defaulting to `%s')\n";
params *result = (params *) Malloc(sizeof(params));
result->type = type;
switch (type) {
case INT:
if (sscanf(form, "%d", &result->intv.value) != 1) {
(void) fprintf(stderr, paramstr, name, form, "integer", DEF_INT);
result->intv.value = atoi(DEF_INT);
}
break;
case STR:
result->strv.value = form;
break;
case PIXEL:
if (!do_color(form, &result->pixv.value)) {
(void) fprintf(stderr, paramstr, name, form, "color", DEF_PIXEL);
(void) do_color(DEF_PIXEL, &result->pixv.value);
}
break;
case FONT:
if (!do_font(form, &result->fontv.value)) {
(void) fprintf(stderr, paramstr, name, form, "font", DEF_FONT);
(void) do_font(DEF_FONT, &result->fontv.value);
}
break;
case STYLE:
if (!do_style(form, &result->stylev)) {
(void) fprintf(stderr, paramstr, name, form, "line style",
DEF_STYLE);
(void) do_style(DEF_STYLE, &result->stylev);
}
break;
case BOOL:
if (!do_bool(form, &result->boolv.value)) {
(void) fprintf(stderr, paramstr, name, form, "boolean flag",
DEF_BOOL);
(void) do_bool(DEF_BOOL, &result->boolv.value);
}
break;
case DBL:
if (sscanf(form, "%lf", &result->dblv.value) != 1) {
(void) fprintf(stderr, paramstr, name, form, "double", DEF_DBL);
result->dblv.value = atof(DEF_DBL);
}
break;
}
return result;
}
static int
do_color(name, color)
char *name; /* Name for color */
XColor *color; /* Returned color */
/*
* Translates `name' into a color and attempts to get the pixel
* for the color using XAllocColor().
*/
{
int result = 1;
if (PM_INT("Output Device") == D_XWINDOWS) {
if (XParseColor(param_disp, param_cmap, name, color)) {
if (stricmp(name, "black") == 0) {
color->pixel = BlackPixel(param_disp, param_scrn);
XQueryColor(param_disp, param_cmap, color);
}
else if (stricmp(name, "white") == 0) {
color->pixel = WhitePixel(param_disp, param_scrn);
XQueryColor(param_disp, param_cmap, color);
}
else
result = XAllocColor(param_disp, param_cmap, color);
}
else
result = 0;
}
return result;
}
static int
do_font(name, font_info)
char *name; /* Name of desired font */
XFontStruct **font_info; /* Returned font information */
/*
* This routine translates a font name into a font structure. The
* font name can be in two forms. The first form is <family>-<size>.
* The family is a family name (like helvetica) and the size is
* in points (like 12). If the font is not in this form, it
* is assumed to be a regular X font name specification and
* is looked up using the standard means.
*/
{
char name_copy[DEF_MAX_FONT],
query_spec[DEF_MAX_FONT];
char *font_family,
*font_size,
**font_list;
int font_size_value,
font_count,
i;
/* First attempt to interpret as font family/size */
if (PM_INT("Output Device") == D_XWINDOWS) {
(void) strcpy(name_copy, name);
if (font_size = index(name_copy, '-')) {
*font_size = '\0';
font_family = name_copy;
font_size++;
font_size_value = atoi(font_size);
if (font_size_value > 0) {
/*
* Still a little iffy -- what about weight and roman vs. other
*/
(void) sprintf(query_spec, ISO_FONT,
font_family, font_size_value * 10);
font_list = XListFonts(param_disp, query_spec,
DEF_MAX_NAMES, &font_count);
/* Load first one that you can */
for (i = 0; i < font_count; i++)
if (*font_info = XLoadQueryFont(param_disp, font_list[i]))
break;
if (*font_info)
return 1;
}
}
/* Assume normal font name */
return (int) (*font_info = XLoadQueryFont(param_disp, name));
}
}
static int
do_style(list, val)
char *list; /* List of ones and zeros */
param_style *val; /* Line style returned */
/*
* Translates a string representation of a dash specification into
* a form suitable for use in XSetDashes(). Assumes `list'
* is a null terminated string of ones and zeros.
*/
{
char *i,
*spot,
last_char;
int count;
for (i = list; *i; i++)
if ((*i != '0') && (*i != '1'))
break;
if (!*i) {
val->len = 0;
last_char = '\0';
for (i = list; *i; i++) {
if (*i != last_char) {
val->len += 1;
last_char = *i;
}
}
val->dash_list = (char *) Malloc((unsigned)
(sizeof(char) * val->len + 1));
last_char = *list;
spot = val->dash_list;
count = 0;
for (i = list; *i; i++) {
if (*i != last_char) {
*spot++ = (char) count;
last_char = *i;
count = 1;
}
else
count++;
}
*spot = (char) count;
return 1;
}
else {
return 0;
}
}
static char *positive[] =
{"on", "yes", "true", "1", "affirmative", (char *) 0};
static char *negative[] =
{"off", "no", "false", "0", "negative", (char *) 0};
static int
do_bool(name, val)
char *name; /* String representation */
int *val; /* Returned value */
/*
* Translates a string representation into a suitable binary value.
* Can parse all kinds of interesting boolean type words.
*/
{
char **term;
for (term = positive; *term; term++) {
if (stricmp(name, *term) == 0)
break;
}
if (*term) {
*val = 1;
return 1;
}
for (term = negative; *term; term++)
if (stricmp(name, *term) == 0)
break;
if (*term) {
*val = 0;
return 1;
}
return 0;
}
/*ARGSUSED*/
static enum st_retval
dump_it(key, value, arg)
char *key,
*value,
*arg;
{
param_full *val = (param_full *) value;
(void) fprintf(stdout, "%s (", key);
switch (val->type) {
case INT:
(void) fprintf(stdout, "INT");
break;
case STR:
(void) fprintf(stdout, "STR");
break;
case PIXEL:
(void) fprintf(stdout, "PIXEL");
break;
case FONT:
(void) fprintf(stdout, "FONT");
break;
case STYLE:
(void) fprintf(stdout, "STYLE");
break;
case BOOL:
(void) fprintf(stdout, "BOOL");
break;
case DBL:
(void) fprintf(stdout, "DBL");
break;
}
(void) fprintf(stdout, ") = %s\n", val->text_form);
return ST_CONTINUE;
}
void
param_dump()
/*
* Dumps all of the parameter values to standard output.
*/
{
st_foreach(param_table, dump_it, (char *) 0);
}
#ifdef HAVE_STRCASECMP
int
stricmp(a, b)
char *a, *b;
{
return strcasecmp(a, b);
}
#else
int
stricmp(a, b)
register char *a,
*b;
/*
* This routine compares two strings disregarding case.
*/
{
register int value;
if ((a == (char *) 0) || (b == (char *) 0)) {
return a - b;
}
for ( /* nothing */ ;
((*a | *b) &&
!(value = ((isupper(*a) ? *a - 'A' + 'a' : *a) -
(isupper(*b) ? *b - 'A' + 'a' : *b))));
a++, b++)
/* Empty Body */ ;
return value;
}
#endif
static int
strihash(string, modulus)
register char *string;
int modulus;
/* Case insensitive computation */
{
register int val = 0;
register int c;
while ((c = *string++) != '\0') {
if (isupper(c))
c = tolower(c);
val = val * 997 + c;
}
return ((val < 0) ? -val : val) % modulus;
}

127
xgraph/params.h Normal file
View File

@ -0,0 +1,127 @@
/*
* Xgraph parameters
*/
#ifndef _PARAMS_H_
#define _PARAMS_H_
#include "xgraph.h"
/* If you have an ANSI compiler, some checking will be done */
#ifdef __STDC__
#define DECLARE(func, rtn, args) extern rtn func args
#else
#define DECLARE(func, rtn, args) extern rtn func ()
#endif
typedef enum param_types_defn {
INT, STR, PIXEL, FONT, STYLE, BOOL, DBL
} param_types;
typedef struct params_int_defn {
param_types type; /* INT */
int value;
} param_int;
typedef struct params_str_defn {
param_types type; /* STR */
char *value;
} param_str;
typedef struct params_pix_defn {
param_types type; /* PIXEL */
XColor value;
} param_pix;
typedef struct params_font_defn {
param_types type; /* FONT */
XFontStruct *value;
} param_font;
typedef struct params_style_defn {
param_types type; /* STYLE */
int len;
char *dash_list;
} param_style;
typedef struct params_bool_defn {
param_types type; /* BOOL */
int value;
} param_bool;
typedef struct params_dbl_defn {
param_types type; /* DBL */
double value;
} param_dbl;
typedef union params_defn {
param_types type;
param_int intv; /* INT */
param_str strv; /* STR */
param_pix pixv; /* PIXEL */
param_font fontv; /* FONT */
param_style stylev; /* STYLE */
param_bool boolv; /* BOOL */
param_dbl dblv; /* DBL */
} params;
DECLARE(param_init, void, (Display * disp, Colormap cmap));
DECLARE(param_set, void, (char *name, param_types type, char *val));
DECLARE(param_reset, void, (char *name, char *val));
DECLARE(param_get, params *, (char *name, params * val));
DECLARE(param_dump, void, ());
#ifdef stricmp
#undef stricmp
#endif
DECLARE(stricmp, int, (char *a, char *b));
/* Some convenience macros */
extern params param_temp,
*param_temp_ptr;
extern XColor param_null_color;
extern param_style param_null_style;
#define PM_INT(name) \
((param_temp_ptr = param_get(name, &param_temp)) ? \
param_temp_ptr->intv.value : \
(abort(), (int) 0))
#define PM_STR(name) \
((param_temp_ptr = param_get(name, &param_temp)) ? \
param_temp_ptr->strv.value : \
(abort(), (char *) 0))
#define PM_COLOR(name) \
((param_temp_ptr = param_get(name, &param_temp)) ? \
param_temp_ptr->pixv.value : \
(abort(), param_null_color))
#define PM_PIXEL(name) \
((param_temp_ptr = param_get(name, &param_temp)) ? \
param_temp_ptr->pixv.value.pixel : \
(abort(), (Pixel) 0))
#define PM_FONT(name) \
((param_temp_ptr = param_get(name, &param_temp)) ? \
param_temp_ptr->fontv.value : \
(abort(), (XFontStruct *) 0))
#define PM_STYLE(name) \
((param_temp_ptr = param_get(name, &param_temp)) ? \
param_temp_ptr->stylev : \
(abort(), param_null_style))
#define PM_BOOL(name) \
((param_temp_ptr = param_get(name, &param_temp)) ? \
param_temp_ptr->boolv.value : \
(abort(), 0))
#define PM_DBL(name) \
((param_temp_ptr = param_get(name, &param_temp)) ? \
param_temp_ptr->dblv.value : \
(abort(), 0.0))
#endif /* _PARAMS_H_ */

60
xgraph/plotter.h Normal file
View File

@ -0,0 +1,60 @@
#ifndef _h_plotter
#define _h_plotter
/*
* HP plotter definition - these are dependent on the SPECIFIC MODEL of HP
* plotter used, and should always be modified when going to a new
* plotter.
*
* all dimensions are in plotter units.
*
* MINX and MINY are the smallest x and y values that are inside the soft
* clip limits of the plotter MAXX and MAXY are the largest x and y values
* that are inside the soft clip limits of the plotter MINUS MINX and
* MINY, so they give the dimension of the soft clip area.
*
* PLOTTERTYPE is a character string which identifies the plotter that should
* be used. control information will be read for
* ~cad/lib/technology/$TECHNOLOGY/$PLOTTERTYPE.map and output will go to
* /usr/ucb/lpr -Pplt$PLOTTERTYPE
*
*/
#define PLOTTERTYPE "7550"
#define P1X 80
#define P1Y 320
#define P2X 10080
#define P2Y 7520
#define MAXX 10000
#define MAXY 7200
#define PLOTTERNAME "paper"
#define PENGRID 1
#define PENAXIS 2
#define TEXTCOLOR 1
#define PEN1 3
#define PEN2 4
#define PEN3 5
#define PEN4 6
#define PEN5 7
#define PEN6 8
#define PEN7 2
#define PEN8 1
#define LINE1 2
#define LINE2 4
#define LINE3 5
#define LINE4 6
#define LINE5 2
#define LINE6 4
#define LINE7 5
#define LINE8 6
#define MARK1 "L"
#define MARK2 "K"
#define MARK3 "M"
#define MARK4 "O"
#define MARK5 "G"
#define MARK6 "F"
#define MARK7 "E"
#define MARK8 "A"
#endif /* _h_plotter */

620
xgraph/ps.c Normal file
View File

@ -0,0 +1,620 @@
/*
* Postscript output for xgraph
*
* Rick Spickelmier
* David Harrison
*/
#include "copyright.h"
#include <stdio.h>
#include "xgraph.h"
/*
* Basic scaling parameters
*/
#define VDPI 1200.0
#define LDIM 11.0
#define SDIM 8.5
#define MICRONS_PER_INCH 2.54E+04
#define POINTS_PER_INCH 72.0
#define INCHES_PER_POINT 1.0/72.0
/*
* Aesthetic parameters (inches)
*/
#define PS_BDR_PAD 0.075
#define PS_AXIS_PAD 0.1
#define PS_LEG_PAD 0.025
#define PS_TICK_LEN 0.125
#define BASE_DASH (1.0/48.0)
#define BASE_WIDTH (1.0/8.0)
#define PS_AXIS_WBASE 1
#define PS_ZERO_WBASE 4
#define PS_DATA_WBASE 7
#define PS_PIXEL 4
#define PS_DOT 12
#define PS_MARK 12
/*
* Other constants
*/
#define FONT_WIDTH_EST 0.55
#define PS_MAX_SEGS 1000
#define PS_NO_TSTYLE -1
#define PS_NO_DSTYLE -1
#define PS_NO_WIDTH -1
#define PS_NO_LSTYLE -1
#define PS_NO_COLOR -1
/*
* Working macros
*/
#define OUT (void) fprintf
#define PS(str) OUT(psFile, str)
#define PSU(str) OUT(ui->psFile, str)
#define IY(val) (ui->height_devs - val)
#define TEXTCOLOR 0
#define MAXCOLOR 8 /* Number of gray scales supported */
/*
* Globals
*/
static double PS_scale; /* devs/micron */
/*
* Externals and forwards
*/
static void psScale(), psFonts(), psMarks(), psText(), psSeg(), psDot(), psEnd();
/*
* Local structures
*/
struct userInfo {
FILE *psFile;
int currentTextStyle;
int currentDashStyle;
int currentWidth;
int currentLStyle;
int currentColor;
int baseWidth;
int height_devs;
char *title_family;
double title_size;
char *axis_family;
double axis_size;
int flags;
};
int
rd(dbl)
double dbl;
/* Short and sweet rounding function */
{
if (dbl < 0.0) {
return ((int) (dbl - 0.5));
}
else {
return ((int) (dbl + 0.5));
}
}
/*ARGSUSED*/
int
psInit(psFile, width, height, tf, ts, af, as, flags, outInfo, errmsg)
FILE *psFile; /* Output file */
int width,
height; /* In microns */
char *tf,
*af; /* Title and axis font */
double ts,
as; /* Title and axis size */
int flags; /* Predicate flags */
xgOut *outInfo; /* Returned device info */
char errmsg[ERRBUFSIZE]; /* Returned error message */
/*
* The basic coordinate system is points (roughly 1/72 inch).
* However, most laser printers can do much better than that.
* We invent a coordinate system based on VDPI dots per inch.
* This goes along the long side of the page. The long side
* of the page is LDIM inches in length, the short side
* SDIM inches in length. We we call this unit a `dev'.
* We map `width' and `height' into devs.
*/
{
struct userInfo *ui;
double font_size;
ui = (struct userInfo *) Malloc(sizeof(struct userInfo));
ui->psFile = psFile;
ui->currentTextStyle = PS_NO_TSTYLE;
ui->currentDashStyle = PS_NO_DSTYLE;
ui->currentWidth = PS_NO_WIDTH;
ui->currentLStyle = PS_NO_LSTYLE;
ui->currentColor = PS_NO_COLOR;
ui->title_family = tf;
ui->title_size = ts;
ui->axis_family = af;
ui->axis_size = as;
/* Roughly, one-eighth a point in devs */
ui->baseWidth = rd(VDPI / POINTS_PER_INCH * BASE_WIDTH);
ui->flags = flags;
PS_scale = VDPI / MICRONS_PER_INCH;
outInfo->dev_flags = 0;
outInfo->area_w = rd(((double) width) * PS_scale);
outInfo->area_h = rd(((double) height) * PS_scale);
ui->height_devs = outInfo->area_h;
outInfo->bdr_pad = rd(PS_BDR_PAD * VDPI);
outInfo->axis_pad = rd(PS_AXIS_PAD * VDPI);
outInfo->legend_pad = rd(PS_LEG_PAD * VDPI);
outInfo->tick_len = rd(PS_TICK_LEN * VDPI);
/* Font estimates */
font_size = as * INCHES_PER_POINT * VDPI;
outInfo->axis_height = rd(font_size);
outInfo->axis_width = rd(font_size * FONT_WIDTH_EST);
font_size = ts * INCHES_PER_POINT * VDPI;
outInfo->title_height = rd(font_size);
outInfo->title_width = rd(font_size * FONT_WIDTH_EST);
outInfo->max_segs = PS_MAX_SEGS;
outInfo->xg_text = psText;
outInfo->xg_seg = psSeg;
outInfo->xg_dot = psDot;
outInfo->xg_end = psEnd;
outInfo->user_state = (char *) ui;
/* Postscript file identification */
PS("%%!\n");
/* Definitions */
psScale(psFile, width, height, flags);
psFonts(psFile);
psMarks(psFile);
PS("%%\n%% Main body begins here\n%%\n");
return 1;
}
static void
psHeader(psFile, docu_flag)
FILE *psFile;
int docu_flag;
/*
* Prints out a standard greeting to the Postscript file.
*/
{
PS("%%%%EndComments\n");
PS("%%\n");
PS("%% Xgraph postscript output\n");
PS("%% Rick Spickelmier and David Harrison\n");
PS("%% University of California, Berkeley\n");
if (docu_flag) {
PS("%%\n");
PS("%% Output produced for inclusion in another document.\n");
PS("%% This file will not work properly if sent directly to a printer.\n");
}
PS("%%\n");
}
static void
psScale(psFile, width, height, flags)
FILE *psFile; /* Output stream */
int width; /* Output width */
int height; /* Output height */
int flags; /* Output options */
/*
* This routine figures out how transform the basic postscript
* transformation into one suitable for direct use by
* the drawing primitives. Two variables X-CENTER-PLOT
* and Y-CENTER-PLOT determine whether the plot is centered
* on the page. If `flags' has D_DOCU set, then the plot
* will not be rotated or centered and a bounding box will
* be displayed.
*/
{
double factor;
double pnt_width,
pnt_height;
if (flags & D_DOCU) {
OUT(psFile, "%%%%BoundingBox: %ld %ld %ld %ld\n",
0, 0,
(int) (((double) width) /
(MICRONS_PER_INCH * INCHES_PER_POINT) + 0.5),
(int) (((double) height) /
(MICRONS_PER_INCH * INCHES_PER_POINT) + 0.5)
);
psHeader(psFile, 1);
PS("%% Rotation and centering are turned off for inclusion in a document\n");
}
else {
psHeader(psFile, 0);
PS("%% Scaling information\n");
PS("%%\n");
PS("%% Change these if you would like to change the centering\n");
PS("%% of the plot in either dimension\n");
PS("/X-CENTER-PLOT 1 def\n");
PS("/Y-CENTER-PLOT 1 def\n");
PS("%%\n");
/*
* Determine page size
*/
PS("%% Page size computation\n");
PS("clippath pathbbox\n");
PS("/page-height exch def\n");
PS("/page-width exch def\n");
PS("pop pop\n");
/*
* First: rotation. If the width is greater than the short dimension,
* do the rotation.
*/
pnt_width = ((double) width) / MICRONS_PER_INCH * POINTS_PER_INCH;
pnt_height = ((double) height) / MICRONS_PER_INCH * POINTS_PER_INCH;
PS("%% Determine whether rotation is required\n");
OUT(psFile, "%lg page-width gt\n", pnt_width);
PS("{ %% Rotation required\n");
PS(" 90 rotate\n");
PS(" 0 page-width neg translate\n");
PS(" %% Handle centering\n");
PS(" Y-CENTER-PLOT 1 eq { %% Center in y\n");
OUT(psFile, " page-height %lg sub 2 div\n", pnt_width);
PS(" } { %% Don't center in y\n");
PS(" 0\n");
PS(" } ifelse\n");
PS(" X-CENTER-PLOT 1 eq { %% Center in x\n");
OUT(psFile, " page-width %lg sub 2 div\n", pnt_height);
PS(" } { %% Don't center in x\n");
PS(" 0\n");
PS(" } ifelse\n");
PS(" translate\n");
PS("} { %% No rotation - just handle centering\n");
PS(" X-CENTER-PLOT 1 eq { %% Center in x\n");
OUT(psFile, " page-width %lg sub 2 div\n", pnt_width);
PS(" } { %% Don't center in x\n");
PS(" 0\n");
PS(" } ifelse\n");
PS(" Y-CENTER-PLOT 1 eq { %% Center in y\n");
OUT(psFile, " page-height %lg sub 2 div\n", pnt_height);
PS(" } { %% Don't center in y\n");
PS(" 0\n");
PS(" } ifelse\n");
PS(" translate\n");
PS("} ifelse\n");
}
/*
* Now: scaling. We have points. We want devs.
*/
factor = POINTS_PER_INCH / VDPI;
PS("%% Set the scale\n");
OUT(psFile, "%lg %lg scale\n", factor, factor);
}
static void
psFonts(psFile)
FILE *psFile; /* Output stream */
/*
* Downloads code for drawing title and axis labels
*/
{
PS("%% Font Handling Functions\n");
PS("%%\n");
PS("%% Function giving y-offset to center of font\n");
PS("%% Assumes font is set and uses numbers to gauge center\n");
PS("%%\n");
PS("/choose-font %% stack: fontsize fontname => ---\n");
PS("{\n");
PS(" findfont \n");
PS(" exch scalefont \n");
PS(" setfont\n");
PS(" newpath\n");
PS(" 0 0 moveto (0) true charpath flattenpath pathbbox\n");
PS(" /top exch def pop\n");
PS(" /bottom exch def pop\n");
PS(" bottom top bottom top add 2 div\n");
PS(" /center-font-val exch def \n");
PS(" /upper-font-val exch def \n");
PS(" /lower-font-val exch def\n");
PS("} def\n");
PS("%%\n");
PS("%% Justfication offset routines\n");
PS("%%\n");
PS("/center-x-just %% stack: (string) x y => (string) newx y\n");
PS("{\n");
PS(" exch 2 index stringwidth pop 2 div sub exch\n");
PS("} def\n");
PS("%%\n");
PS("/left-x-just %% stack: (string) x y => (string) newx y\n");
PS("{ \n");
PS("} def\n");
PS("%%\n");
PS("/right-x-just %% stack: (string) x y => (string) newx y\n");
PS("{\n");
PS(" exch 2 index stringwidth pop sub exch\n");
PS("} def\n");
PS("%%\n");
PS("/center-y-just %% stack: (string) x y => (string) x newy\n");
PS("{\n");
PS(" center-font-val sub\n");
PS("} def\n");
PS("%%\n");
PS("/lower-y-just %% stack: (string) x y => (string) x newy\n");
PS("{\n");
PS(" lower-font-val sub\n");
PS("} def\n");
PS("%%\n");
PS("/upper-y-just %% stack: (string) x y => (string) x newy\n");
PS("{\n");
PS(" upper-font-val sub\n");
PS("} def\n");
PS("%%\n");
PS("%% Shows a string on the page subject to justification\n");
PS("%% \n");
PS("/just-string %% stack: (string) x y just => ---\n");
PS("{\n");
PS(" dup 0 eq { pop center-x-just center-y-just } if\n");
PS(" dup 1 eq { pop left-x-just center-y-just } if\n");
PS(" dup 2 eq { pop left-x-just upper-y-just } if\n");
PS(" dup 3 eq { pop center-x-just upper-y-just } if\n");
PS(" dup 4 eq { pop right-x-just upper-y-just } if\n");
PS(" dup 5 eq { pop right-x-just center-y-just } if\n");
PS(" dup 6 eq { pop right-x-just lower-y-just } if\n");
PS(" dup 7 eq { pop center-x-just lower-y-just } if\n");
PS(" dup 8 eq { pop left-x-just lower-y-just } if\n");
PS(" moveto show\n");
PS("} def\n");
PS("%%\n");
}
static void
psMarks(psFile)
FILE *psFile;
/*
* Writes out marker definitions
*/
{
PS("%% Marker definitions\n");
PS("/mark0 {/size exch def /y exch def /x exch def\n");
PS("newpath x size sub y size sub moveto\n");
PS("size size add 0 rlineto 0 size size add rlineto\n");
PS("0 size size add sub 0 rlineto closepath fill} def\n");
PS("/mark1 {/size exch def /y exch def /x exch def\n");
PS("newpath x size sub y size sub moveto\n");
PS("size size add 0 rlineto 0 size size add rlineto\n");
PS("0 size size add sub 0 rlineto closepath stroke} def\n");
PS("/mark2 {/size exch def /y exch def /x exch def\n");
PS("newpath x y moveto x y size 0 360 arc stroke} def\n");
PS("/mark3 {/size exch def /y exch def /x exch def\n");
PS("newpath x size sub y size sub moveto x size add y size add lineto\n");
PS("x size sub y size add moveto x size add y size sub lineto stroke} def\n");
PS("/mark4 {/size exch def /y exch def /x exch def\n");
PS("newpath x size sub y moveto x y size add lineto\n");
PS("x size add y lineto x y size sub lineto\n");
PS("closepath stroke} def\n");
PS("/mark5 {/size exch def /y exch def /x exch def\n");
PS("x y size mark1\n");
PS("newpath x size sub y moveto size size add 0 rlineto stroke} def\n");
PS("/mark6 {/size exch def /y exch def /x exch def\n");
PS("newpath x y moveto x y size 0 360 arc fill} def\n");
PS("/mark7 {/size exch def /y exch def /x exch def\n");
PS("newpath x y moveto x size sub y size sub lineto\n");
PS("x size add y size sub lineto closepath fill\n");
PS("newpath x y moveto x size add y size add lineto\n");
PS("x size sub y size add lineto closepath fill} def\n");
}
static void
psText(state, x, y, text, just, style)
char *state; /* Really (struct userInfo *) */
int x,
y; /* Text position (devs) */
char *text; /* Text itself */
int just; /* Justification */
int style; /* Style */
/*
* Draws text at the given location with the given justification
* and style.
*/
{
struct userInfo *ui = (struct userInfo *) state;
if (TEXTCOLOR != ui->currentColor) {
OUT(ui->psFile, "%lg setgray\n", (double) TEXTCOLOR / 8);
ui->currentColor = TEXTCOLOR;
}
if (style != ui->currentTextStyle) {
switch (style) {
case T_AXIS:
OUT(ui->psFile, "%lg /%s choose-font\n",
ui->axis_size * INCHES_PER_POINT * VDPI, ui->axis_family);
break;
case T_TITLE:
OUT(ui->psFile, "%lg /%s choose-font\n",
ui->title_size * INCHES_PER_POINT * VDPI, ui->title_family);
break;
}
ui->currentTextStyle = style;
}
OUT(ui->psFile, "(%s) %d %d %d just-string\n", text, x, IY(y), just);
}
/*ARGSUSED*/
static void
psSeg(state, ns, seglist, width, style, lappr, color)
char *state; /* Really (struct userInfo *) */
int ns; /* Number of segments */
XSegment *seglist; /* X array of segments */
int width; /* Width of lines (devcoords) */
int style; /* L_AXIS, L_ZERO, L_VAR */
int lappr; /* Zero to seven */
int color; /* Zero to seven */
/*
* Draws a number of line segments. Grid lines are drawn using
* light lines. Variable lines (L_VAR) are drawn wider. This
* version ignores the color argument.
*/
{
struct userInfo *ui = (struct userInfo *) state;
int newwidth = 0,
i;
if ((style != ui->currentLStyle) || (width != ui->currentWidth)) {
switch (style) {
case L_AXIS:
newwidth = PS_AXIS_WBASE * ui->baseWidth;
PSU("[] 0 setdash\n");
break;
case L_ZERO:
newwidth = PS_ZERO_WBASE * ui->baseWidth;
PSU("[] 0 setdash\n");
break;
case L_VAR:
newwidth = PS_DATA_WBASE * ui->baseWidth;
break;
}
ui->currentWidth = MAX(newwidth, width);
ui->currentLStyle = style;
OUT(ui->psFile, "%d setlinewidth\n", ui->currentWidth);
}
if (width > 4) {
if (color > MAXCOLOR)
color -= MAXCOLOR;
else
lappr = 0;
}
else
color = TEXTCOLOR;
if ((lappr != ui->currentDashStyle) && (style == L_VAR)) {
if (lappr == 0) {
PSU("[] 0 setdash\n");
}
else {
OUT(ui->psFile, "[%lg] 0 setdash\n",
((double) lappr) * BASE_DASH * VDPI);
}
ui->currentDashStyle = lappr;
}
if ((color != ui->currentColor) && (style == L_VAR)) {
OUT(ui->psFile, "%lg setgray\n", (double) color / MAXCOLOR);
ui->currentColor = color;
}
PSU("newpath\n");
OUT(ui->psFile, " %d %d moveto\n", seglist[0].x1, IY(seglist[0].y1));
OUT(ui->psFile, " %d %d lineto\n", seglist[0].x2, IY(seglist[0].y2));
for (i = 1; i < ns; i++) {
if ((seglist[i].x1 != seglist[i - 1].x2) ||
(seglist[i].y1 != seglist[i - 1].y2)) {
OUT(ui->psFile, " %d %d moveto\n", seglist[i].x1, IY(seglist[i].y1));
}
OUT(ui->psFile, " %d %d lineto\n", seglist[i].x2, IY(seglist[i].y2));
}
PSU("stroke\n");
}
/*ARGSUSED*/
static void
psDot(state, x, y, style, type, color)
char *state; /* state information */
int x,
y; /* coord of dot */
int style; /* type of dot */
int type; /* dot style variation */
int color; /* color of dot */
/*
* Prints out a dot at the given location
*/
{
struct userInfo *ui = (struct userInfo *) state;
if (ui->currentDashStyle != PS_NO_DSTYLE) {
OUT(ui->psFile, "[] 0 setdash ");
ui->currentDashStyle = PS_NO_DSTYLE;
}
if (ui->currentWidth != PS_ZERO_WBASE * ui->baseWidth) {
ui->currentWidth = PS_ZERO_WBASE * ui->baseWidth;
OUT(ui->psFile, "%d setlinewidth ", ui->currentWidth);
}
if (color > MAXCOLOR)
color -= MAXCOLOR;
if ((color != ui->currentColor)) {
OUT(ui->psFile, "%lg setgray\n", (double) color / MAXCOLOR);
ui->currentColor = color;
}
switch (style) {
case P_PIXEL:
OUT(ui->psFile, "newpath %d %d moveto %d %d %d 0 360 arc fill\n",
x, IY(y), x, IY(y), PS_PIXEL * ui->baseWidth);
break;
case P_DOT:
OUT(ui->psFile, "newpath %d %d moveto %d %d %d 0 360 arc fill\n",
x, IY(y), x, IY(y), PS_DOT * ui->baseWidth);
break;
case P_MARK:
OUT(ui->psFile, "%d %d %d mark%d\n",
x, IY(y), PS_MARK * ui->baseWidth, type);
break;
}
return;
}
static void
psEnd(userState)
char *userState; /* state information */
{
struct userInfo *ui = (struct userInfo *) userState;
if (!(ui->flags & D_DOCU)) {
PSU("showpage\n");
}
PSU("%% End of xgraph output\n");
}

365
xgraph/read.c Normal file
View File

@ -0,0 +1,365 @@
/* $Header$ */
/*
* read.c: Dataset read code
*
* Routines:
* int ReadData();
*
* $Log$
* Revision 1.1 2004-01-25 09:00:49 pnenzi
*
* Added xgraph plotting program.
*
* Revision 1.2 1999/12/03 23:17:45 heideman
* apply xgraph_no_animation.patch
*
* Revision 1.1.1.1 1999/12/03 23:15:53 heideman
* xgraph-12.0
*
*/
#ifndef lint
static char rcsid[] = "$Id$";
#endif
#include "copyright.h"
#include <stdio.h>
#include <math.h>
#include <pwd.h>
#include <ctype.h>
#include "xgraph.h"
#include "xtb.h"
#include "hard_devices.h"
#include "params.h"
/*
* New dataset reading code
*/
static int setNumber = 0;
static PointList **curSpot = (PointList **) 0;
static PointList *curList = (PointList *) 0;
static int newGroup = 0;
static int redundant_set = 0;
#ifdef DO_DER
extern void Der1();
#endif
static int
rdSet(fn)
char *fn; /* Reading from file `fn' */
/*
* Set up new dataset. Will return zero if there are too many data sets.
*/
{
char setname[100];
if (!redundant_set) {
if (setNumber < MAXSETS) {
(void) sprintf(setname, "Set %d", setNumber);
if ((strcmp(PlotData[setNumber].setName, setname) == 0) && fn) {
PlotData[setNumber].setName = fn;
}
curSpot = &(PlotData[setNumber].list);
PlotData[setNumber].list = (PointList *) 0;
newGroup = 1;
setNumber++;
redundant_set = 1;
return 1;
}
else {
return 0;
}
}
else {
return 1;
}
}
static void
rdSetName(name)
char *name; /* New set name */
/*
* Sets the name of a data set. Automatically makes a copy.
*/
{
PlotData[setNumber - 1].setName = STRDUP(name);
}
static void
rdGroup()
/*
* Set up for reading new group of points within a dataset.
*/
{
newGroup = 1;
}
static void
rdPoint(xval, yval)
double xval,
yval; /* New point */
/*
* Adds a new point to the current group of the current
* data set.
*/
{
if (newGroup) {
*curSpot = (PointList *) Malloc(sizeof(PointList));
curList = *curSpot;
curSpot = &(curList->next);
curList->numPoints = 0;
curList->allocSize = INITSIZE;
curList->xvec = (double *) Malloc((unsigned)
(INITSIZE * sizeof(double)));
curList->yvec = (double *) Malloc((unsigned)
(INITSIZE * sizeof(double)));
curList->next = (PointList *) 0;
newGroup = 0;
}
if (curList->numPoints >= curList->allocSize) {
curList->allocSize *= 2;
curList->xvec = (double *) Realloc((char *) curList->xvec,
(unsigned) (curList->allocSize *
sizeof(double)));
curList->yvec = (double *) Realloc((char *) curList->yvec,
(unsigned) (curList->allocSize *
sizeof(double)));
}
curList->xvec[curList->numPoints] = xval;
curList->yvec[curList->numPoints] = yval;
(curList->numPoints)++;
redundant_set = 0;
}
static int
rdFindMax()
/*
* Returns the maximum number of items in any one group of any
* data set.
*/
{
int i;
PointList *list;
int max = -1;
for (i = 0; i < setNumber; i++) {
for (list = PlotData[i].list; list; list = list->next) {
if (list->numPoints > max)
max = list->numPoints;
}
}
return max;
}
typedef enum line_type {
EMPTY, COMMENT, SETNAME, DRAWPNT, MOVEPNT, SETPARAM, ERROR
} LineType;
typedef struct point_defn {
double xval,
yval;
} Point;
typedef struct parmval_defn {
char *name,
*value;
} ParmVals;
typedef struct line_info {
LineType type;
union val_defn {
char *str; /* SETNAME, ERROR */
Point pnt; /* DRAWPNT, MOVEPNT */
ParmVals parm; /* SETPARAM */
} val;
} LineInfo;
static LineType
parse_line(line, result)
char *line; /* Line to parse */
LineInfo *result; /* Returned result */
/*
* Parses `line' into one of the types given in the definition
* of LineInfo. The appropriate values are filled into `result'.
* Below are the current formats for each type:
* EMPTY: All white space
* COMMENT: Starts with "#"
* SETNAME: A name enclosed in double quotes
* DRAWPNT: Two numbers optionally preceded by keyword "draw"
* MOVEPNT: Two numbers preceded by keyword "move"
* SETPARAM: Two non-null strings separated by ":"
* ERROR: Not any of the above (an error message is returned)
* Note that often the values are pointers into the line itself
* and should be copied if they are to be used over a long period.
*/
{
char *first;
/* Find first non-space character */
while (*line && isspace(*line))
line++;
if (*line) {
if (*line == '#') {
/* comment */
result->type = COMMENT;
}
else if (*line == '"') {
/* setname */
result->type = SETNAME;
line++;
result->val.str = line;
while (*line && (*line != '\n') && (*line != '"'))
line++;
if (*line)
*line = '\0';
}
else {
first = line;
while (*line && !isspace(*line))
line++;
if (*line) {
*line = '\0';
if (stricmp(first, "move") == 0) {
/* MOVEPNT */
if (sscanf(line + 1, "%lf %lf",
&result->val.pnt.xval,
&result->val.pnt.yval) == 2) {
result->type = MOVEPNT;
}
else {
result->type = ERROR;
result->val.str = "Cannot read move coordinates";
}
}
else if (stricmp(first, "draw") == 0) {
/* DRAWPNT */
if (sscanf(line + 1, "%lf %lf",
&result->val.pnt.xval,
&result->val.pnt.yval) == 2) {
result->type = DRAWPNT;
}
else {
result->type = ERROR;
result->val.str = "Cannot read draw coordinates";
}
}
else if (first[strlen(first) - 1] == ':') {
/* SETPARAM */
first[strlen(first) - 1] = '\0';
result->val.parm.name = first;
line++;
while (*line && isspace(*line))
line++;
/* may be a \n at end of it */
if (line[strlen(line) - 1] == '\n') {
line[strlen(line) - 1] = '\0';
}
result->val.parm.value = line;
result->type = SETPARAM;
}
else if (sscanf(first, "%lf", &result->val.pnt.xval) == 1) {
/* DRAWPNT */
if (sscanf(line + 1, "%lf", &result->val.pnt.yval) == 1) {
result->type = DRAWPNT;
}
else {
result->type = ERROR;
result->val.str = "Cannot read second coordinate";
}
}
else {
/* ERROR */
result->type = ERROR;
result->val.str = "Unknown line type";
}
}
else {
/* ERROR */
result->type = ERROR;
result->val.str = "Premature end of line";
}
}
}
else {
/* empty */
result->type = EMPTY;
}
return result->type;
}
int
ReadData(stream, filename)
FILE *stream;
char *filename;
/*
* Reads in the data sets from the supplied stream. If the format
* is correct, it returns the current maximum number of points across
* all data sets. If there is an error, it returns -1.
*/
{
char buffer[MAXBUFSIZE];
LineInfo info;
int line_count = 0;
int errors = 0;
if (!rdSet(filename)) {
(void) fprintf(stderr, "Error in file `%s' at line %d:\n %s\n",
filename, line_count,
"Too many data sets - extra data ignored");
return -1;
}
while (fgets(buffer, MAXBUFSIZE, stream)) {
line_count++;
switch (parse_line(buffer, &info)) {
case EMPTY:
if (!rdSet(filename)) {
(void) fprintf(stderr, "Error in file `%s' at line %d:\n %s\n",
filename, line_count,
"Too many data sets - extra data ignored");
return -1;
}
break;
case COMMENT:
/* nothing */
break;
case SETNAME:
rdSetName(info.val.str);
break;
case DRAWPNT:
rdPoint(info.val.pnt.xval, info.val.pnt.yval);
break;
case MOVEPNT:
rdGroup();
rdPoint(info.val.pnt.xval, info.val.pnt.yval);
break;
case SETPARAM:
param_reset(info.val.parm.name, info.val.parm.value);
break;
default:
if (filename) {
(void) fprintf(stderr, "Error in file `%s' at line %d:\n %s\n",
filename, line_count, info.val.str);
errors++;
}
break;
}
}
#ifdef DO_DER
Der1();
#endif
if (errors)
return -1;
else
return rdFindMax();
}

571
xgraph/st.c Normal file
View File

@ -0,0 +1,571 @@
/*LINTLIBRARY*/
/*
* String Table (Hash) Package
*
* Peter Moore
* University of California, Berkeley
* 1985
*
* This is a general purpose hash table package.
*/
#include <stdio.h>
#include "copyright.h"
#include "st.h"
#include "xgraph.h"
#define max(a,b) ((a) > (b) ? (a) : (b))
#define nil(type) ((type *) 0)
#define alloc(type) (type *) Malloc(sizeof(type))
#define ABS(x) ((x) < 0 ? -(x) : (x))
#define ST_NUMCMP(x,y) ((int) (x) - (int) (y))
#define ST_NUMHASH(x,size) (ABS((int)x)%(size))
#define ST_PTRHASH(x,size) ((int)((unsigned)(x)>>2)%size)
#define EQUAL(func, x, y) \
((((func) == st_numcmp) || ((func) == st_ptrcmp)) ?\
(ST_NUMCMP((x),(y)) == 0) : ((*func)((x), (y)) == 0))
#define do_hash(key, table)\
((table->hash == st_ptrhash) ? ST_PTRHASH((key),(table)->num_bins) :\
(table->hash == st_numhash) ? ST_NUMHASH((key), (table)->num_bins) :\
(*table->hash)((key), (table)->num_bins))
char st_pkg_name[] = "st";
/* Possible error conditions */
char *st_no_mem = "out of memory";
char *st_bad_ret = "bad return code from function passed to st_foreach";
char *st_bad_gen = "null or zero generator";
/* Forward declarations */
int st_numhash(), st_ptrhash(), st_numcmp(), st_ptrcmp();
static void rehash();
static void errRaise();
st_table *
st_init_table_with_params(compare, hash, size, density, grow_factor,
reorder_flag)
int (*compare) ();
int (*hash) ();
int size;
int density;
double grow_factor;
int reorder_flag;
/* Detailed table allocator */
{
st_table *new;
new = alloc(st_table);
if (!new) {
errRaise(st_pkg_name, ST_NO_MEM, st_no_mem);
/* NOTREACHED */
}
new->compare = compare;
new->hash = hash;
new->num_entries = 0;
new->max_density = density;
new->grow_factor = grow_factor;
new->reorder_flag = reorder_flag;
if (size <= 0) {
size = 1;
}
new->num_bins = size;
new->bins =
(st_table_entry **) Calloc((unsigned) size, sizeof(st_table_entry *));
if (!new->bins) {
Free((char *) new);
errRaise(st_pkg_name, ST_NO_MEM, st_no_mem);
/* NOTREACHED */
}
return new;
}
st_table *
st_init_table(compare, hash)
int (*compare) ();
int (*hash) ();
/* Default table allocator */
{
return st_init_table_with_params(compare, hash, ST_DEFAULT_INIT_TABLE_SIZE,
ST_DEFAULT_MAX_DENSITY,
ST_DEFAULT_GROW_FACTOR,
ST_DEFAULT_REORDER_FLAG);
}
void
st_Free_table(table)
st_table *table;
/* Destroy a table */
{
register st_table_entry *ptr,
*next;
int i;
for (i = 0; i < table->num_bins; i++) {
ptr = table->bins[i];
while (ptr != nil(st_table_entry)) {
next = ptr->next;
Free((char *) ptr);
ptr = next;
}
}
Free((char *) table->bins);
Free((char *) table);
}
#define PTR_NOT_EQUAL(table, ptr, user_key)\
(ptr != nil(st_table_entry) && !EQUAL(table->compare, user_key, (ptr)->key))
#define FIND_ENTRY(table, hash_val, key, ptr, last) \
(last) = &(table)->bins[hash_val];\
(ptr) = *(last);\
while (PTR_NOT_EQUAL((table), (ptr), (key))) {\
(last) = &(ptr)->next; (ptr) = *(last);\
}\
if ((ptr) != nil(st_table_entry) && (table)->reorder_flag) {\
*(last) = (ptr)->next;\
(ptr)->next = (table)->bins[hash_val];\
(table)->bins[hash_val] = (ptr);\
}
int
st_lookup(table, key, value)
st_table *table;
register char *key;
char **value;
/* Look up item in table -- return zero if not found */
{
int hash_val;
register st_table_entry *ptr,
**last;
hash_val = do_hash(key, table);
FIND_ENTRY(table, hash_val, key, ptr, last);
if (ptr == nil(st_table_entry)) {
return 0;
}
else {
if (value != nil(char *))
*value = ptr->record;
return 1;
}
}
#define ADD_DIRECT(table, key, value, hash_val, new)\
{\
if (table->num_entries/table->num_bins >= table->max_density) {\
(void) rehash(table);\
hash_val = do_hash(key,table);\
}\
\
new = alloc(st_table_entry);\
\
if (new) {\
new->key = key;\
new->record = value;\
new->next = table->bins[hash_val];\
table->bins[hash_val] = new;\
table->num_entries++;\
} else {\
errRaise(st_pkg_name, ST_NO_MEM, st_no_mem);\
/* NOTREACHED */ \
} \
}
int
st_insert(table, key, value)
register st_table *table;
register char *key;
char *value;
/* Insert an item into the table - replacing if it already exists */
{
int hash_val;
st_table_entry *new;
register st_table_entry *ptr,
**last;
hash_val = do_hash(key, table);
FIND_ENTRY(table, hash_val, key, ptr, last);
if (ptr == nil(st_table_entry)) {
ADD_DIRECT(table, key, value, hash_val, new);
return 0;
}
else {
ptr->record = value;
return 1;
}
}
void
st_add_direct(table, key, value)
st_table *table;
char *key;
char *value;
/* Add item to table without checking for existing item */
{
int hash_val;
st_table_entry *new;
hash_val = do_hash(key, table);
ADD_DIRECT(table, key, value, hash_val, new);
}
int
st_find_or_add(table, key, slot)
st_table *table;
char *key;
char ***slot;
/* Return slot for key - make one if one doesn't exist */
{
int hash_val;
st_table_entry *new,
*ptr,
**last;
hash_val = do_hash(key, table);
FIND_ENTRY(table, hash_val, key, ptr, last);
if (ptr == nil(st_table_entry)) {
ADD_DIRECT(table, key, (char *) 0, hash_val, new);
if (slot != nil(char **))
*slot = &new->record;
return 0;
}
else {
if (slot != nil(char **))
*slot = &ptr->record;
return 1;
}
}
int
st_find(table, key, slot)
st_table *table;
char *key;
char ***slot;
/* Finds an entry in table */
{
int hash_val;
st_table_entry *ptr,
**last;
hash_val = do_hash(key, table);
FIND_ENTRY(table, hash_val, key, ptr, last);
if (ptr == nil(st_table_entry)) {
return 0;
}
else {
if (slot != nil(char **))
*slot = &ptr->record;
return 1;
}
}
static void
rehash(table)
register st_table *table;
/* Grows table */
{
register st_table_entry *ptr,
*next,
**old_bins = table->bins;
int i,
old_num_bins = table->num_bins,
hash_val;
table->num_bins = table->grow_factor * old_num_bins;
if (table->num_bins % 2 == 0) {
table->num_bins += 1;
}
table->bins =
(st_table_entry **) Calloc((unsigned) table->num_bins,
sizeof(st_table_entry *));
if (!table->bins) {
/* If out of memory: don't resize */
table->bins = old_bins;
table->num_bins = old_num_bins;
return;
}
table->num_entries = 0;
for (i = 0; i < old_num_bins; i++) {
ptr = old_bins[i];
while (ptr != nil(st_table_entry)) {
next = ptr->next;
hash_val = do_hash(ptr->key, table);
ptr->next = table->bins[hash_val];
table->bins[hash_val] = ptr;
table->num_entries++;
ptr = next;
}
}
Free((char *) old_bins);
}
st_table *
st_copy(old_table)
st_table *old_table;
{
st_table *new_table;
st_table_entry *ptr,
*new;
int i,
num_bins = old_table->num_bins;
new_table = alloc(st_table);
if (new_table == nil(st_table)) {
errRaise(st_pkg_name, ST_NO_MEM, st_no_mem);
/* NOTREACHED */
}
*new_table = *old_table;
new_table->bins =
(st_table_entry **) Calloc((unsigned) num_bins, sizeof(st_table_entry *));
if (new_table->bins == nil(st_table_entry *)) {
Free((char *) new_table);
errRaise(st_pkg_name, ST_NO_MEM, st_no_mem);
/* NOTREACHED */
}
for (i = 0; i < num_bins; i++) {
new_table->bins[i] = nil(st_table_entry);
ptr = old_table->bins[i];
while (ptr != nil(st_table_entry)) {
new = alloc(st_table_entry);
if (new == nil(st_table_entry)) {
Free((char *) new_table->bins);
Free((char *) new_table);
errRaise(st_pkg_name, ST_NO_MEM, st_no_mem);
/* NOTREACHED */
}
*new = *ptr;
new->next = new_table->bins[i];
new_table->bins[i] = new;
ptr = ptr->next;
}
}
return new_table;
}
int
st_delete(table, keyp, value)
register st_table *table;
register char **keyp;
char **value;
{
int hash_val;
char *key = *keyp;
register st_table_entry *ptr,
**last;
hash_val = do_hash(key, table);
FIND_ENTRY(table, hash_val, key, ptr, last);
if (ptr == nil(st_table_entry)) {
return 0;
}
*last = ptr->next;
if (value != nil(char *))
*value = ptr->record;
*keyp = ptr->key;
Free((char *) ptr);
table->num_entries--;
return 1;
}
int
st_foreach(table, func, arg)
st_table *table;
enum st_retval (*func) ();
char *arg;
{
st_table_entry *ptr,
**last;
enum st_retval retval;
int i;
for (i = 0; i < table->num_bins; i++) {
last = &table->bins[i];
ptr = *last;
while (ptr != nil(st_table_entry)) {
retval = (*func) (ptr->key, ptr->record, arg);
switch (retval) {
case ST_CONTINUE:
last = &ptr->next;
ptr = *last;
break;
case ST_STOP:
return 0;
case ST_DELETE:
*last = ptr->next;
Free((char *) ptr);
ptr = *last;
break;
default:
errRaise(st_pkg_name, ST_BAD_RET, st_bad_ret);
/* NOTREACHED */
}
}
}
return 1;
}
int
st_strhash(string, modulus)
register char *string;
int modulus;
{
register int val = 0;
register int c;
while ((c = *string++) != '\0') {
val = val * 997 + c;
}
return ((val < 0) ? -val : val) % modulus;
}
int
st_numhash(x, size)
char *x;
int size;
{
return ST_NUMHASH(x, size);
}
int
st_ptrhash(x, size)
char *x;
int size;
{
return ST_PTRHASH(x, size);
}
int
st_numcmp(x, y)
char *x;
char *y;
{
return ST_NUMCMP(x, y);
}
int
st_ptrcmp(x, y)
char *x;
char *y;
{
return ST_NUMCMP(x, y);
}
st_generator *
st_init_gen(table)
st_table *table;
/* Initializes generation of items in table */
{
st_generator *gen;
gen = alloc(st_generator);
if (!gen) {
errRaise(st_pkg_name, ST_NO_MEM, st_no_mem);
/* NOTREACHED */
}
gen->table = table;
gen->entry = nil(st_table_entry);
gen->idx = 0;
return gen;
}
int
st_gen(gen, key_p, value_p)
st_generator *gen;
char **key_p;
char **value_p;
/* Generates next item in generation sequence */
{
register int i;
if (!gen) {
errRaise(st_pkg_name, ST_BAD_GEN, st_bad_gen);
/* NOTREACHED */
}
if (gen->entry == nil(st_table_entry)) {
/* try to find next entry */
for (i = gen->idx; i < gen->table->num_bins; i++) {
if (gen->table->bins[i] != nil(st_table_entry)) {
gen->idx = i + 1;
gen->entry = gen->table->bins[i];
break;
}
}
if (gen->entry == nil(st_table_entry)) {
return 0; /* that's all folks ! */
}
}
*key_p = gen->entry->key;
if (value_p != 0)
*value_p = gen->entry->record;
gen->entry = gen->entry->next;
return 1;
}
void
st_Free_gen(gen)
st_generator *gen;
{
if (gen) {
Free((char *) gen);
}
else {
errRaise(st_pkg_name, ST_BAD_GEN, st_bad_gen);
/* NOTREACHED */
}
}
static void
errRaise(pkg, num, msg)
char *pkg;
int num;
char *msg;
/*
* In this standalone version of st, and error raise causes
* an abort after printing a message.
*/
{
(void) fprintf(stderr, "%s: %s\n", pkg, msg);
abort();
}

119
xgraph/st.h Normal file
View File

@ -0,0 +1,119 @@
/* $Header$ */
#ifndef ST_INCLUDED
#define ST_INCLUDED
/* Function prototypes */
#ifdef __STDC__
#define ARGS(args) args
#else
#define ARGS(args) ()
#endif
extern char st_pkg_name[];
/* Fatal error codes */
#define ST_NO_MEM 0
#define ST_BAD_RET 1
#define ST_BAD_GEN 2
typedef struct st_table_entry st_table_entry;
struct st_table_entry {
char *key;
char *record;
st_table_entry *next;
};
typedef struct st_table st_table;
struct st_table {
int (*compare) ();
int (*hash) ();
int num_bins;
int num_entries;
int max_density;
int reorder_flag;
double grow_factor;
st_table_entry **bins;
};
typedef struct st_generator st_generator;
struct st_generator {
st_table *table;
st_table_entry *entry;
int idx;
};
#define st_is_member(table,key) st_lookup(table,key,(char **) 0)
#define st_count(table) ((table)->num_entries)
enum st_retval {
ST_CONTINUE, ST_STOP, ST_DELETE
};
extern st_table *st_init_table_with_params
ARGS((int (*compare) (), int (*hash) (), int size, int density,
double grow_factor, int reorder_flag));
extern st_table *st_init_table
ARGS((int (*compare) (), int (*hash) ()));
extern void st_free_table
ARGS((st_table * table));
extern int st_lookup
ARGS((st_table * table, char *key, char **value));
extern int st_insert
ARGS((st_table * table, char *key, char *value));
extern void st_add_direct
ARGS((st_table * table, char *key, char *value));
extern int st_find_or_add
ARGS((st_table * table, char *key, char ***slot));
extern int st_find
ARGS((st_table * table, char *key, char ***slot));
extern st_table *st_copy
ARGS((st_table * old_table));
extern int st_delete
ARGS((st_table * table, char **keyp, char **value));
extern int st_foreach
ARGS((st_table * table, enum st_retval(*func) (), char *arg));
extern int st_strhash
ARGS((char *string, int modulus));
extern int st_numhash
ARGS((char *x, int size));
extern int st_ptrhash
ARGS((char *x, int size));
extern int st_numcmp
ARGS((char *x, char *y));
extern int st_ptrcmp
ARGS((char *x, char *y));
extern st_generator *st_init_gen
ARGS((st_table * table));
extern int st_gen
ARGS((st_generator * gen, char **key_p, char **value_p));
extern void st_free_gen
ARGS((st_generator * gen));
#define ST_DEFAULT_MAX_DENSITY 5
#define ST_DEFAULT_INIT_TABLE_SIZE 11
#define ST_DEFAULT_GROW_FACTOR 2.0
#define ST_DEFAULT_REORDER_FLAG 0
#define st_foreach_item(table, gen, key_p, value_p) \
for(gen=st_init_gen(table); st_gen(gen,key_p,value_p) || (st_free_gen(gen),0);)
#endif /* ST_INCLUDED */

1
xgraph/stamp-h.in Normal file
View File

@ -0,0 +1 @@
timestamp

329
xgraph/tgif.c Normal file
View File

@ -0,0 +1,329 @@
/*
* Tgif Output
*
* Christos Zoulas
*/
#include <stdio.h>
#include <X11/Xlib.h>
#include "hard_devices.h"
#include "xgout.h"
#define COLOR "DarkSlateGray"
typedef struct {
char *title_font;
char *axis_font;
int title_size;
int axis_size;
FILE *strm;
} Info;
char *tgif_prologue[] =
{
"state(0,13,0,0,0,16,1,5,1,1,0,0,1,0,1,0,1,0,4,0,0,0,10,0).\n",
"%\n",
"% Tgif xgraph output.\n",
"%\n",
0
};
/*
* Hardcopy Interface for Xgraph
*
* Major differences from first version:
* Four new parameters are passed to the device initialization routine:
* title_family, title_size, axis_family, and axis_size. See the
* description of xg_init() for details.
*
* Clipping is done automatically by xgraph. The xg_clip() routine
* is obsolete.
*
* The xg_line() routine has become the xg_seg() routine. It now
* draws segments rather than a series of lines.
*
* A new field (max_segs) in the device structure now specifies
* the maximum number of segments the device can handle in a group.
*/
void tgifText();
void tgifDot();
void tgifSeg();
void tgifEnd();
int
tgifInit(strm, width, height, title_family, title_size,
axis_family, axis_size, flags, out_info, errmsg)
FILE *strm; /* Output stream */
int width,
height; /* Size of space (microns) */
char *title_family; /* Name of title font family */
double title_size; /* Title font height (points) */
char *axis_family; /* Name of axis font family */
double axis_size; /* Axis font height (points) */
int flags; /* Flags */
xgOut *out_info; /* Device info (RETURN) */
char errmsg[ERRBUFSIZE]; /* Error message area */
{
Info *tgif_info;
char **l;
double scx,
scy;
tgif_info = (Info *) Malloc(sizeof(*tgif_info));
for (l = tgif_prologue; *l; l++)
fprintf(strm, "%s\n", *l);
out_info->dev_flags = 0;
scx = width / 512.0;
scy = height / 512.0;
if (scx > scy) {
scy /= scx;
scx = 1;
}
else {
scx /= scy;
scy = 1;
}
out_info->bdr_pad = title_size / 4;
out_info->axis_pad = 2.0 * axis_size;
out_info->legend_pad = 0;
out_info->area_w = width * 0.00283 * scx; /* pts per micron */
out_info->area_h = height * 0.00283 * scy;
out_info->tick_len = axis_size;
out_info->axis_height = axis_size;
out_info->title_height = title_size;
out_info->axis_width = (axis_size * 5.0) / 12.0;
out_info->title_width = (title_size * 5.0) / 12.0;
out_info->max_segs = 100;
out_info->xg_text = tgifText;
out_info->xg_seg = tgifSeg;
out_info->xg_dot = tgifDot;
out_info->xg_end = tgifEnd;
out_info->user_state = (char *) tgif_info;
tgif_info->title_font = title_family;
tgif_info->axis_font = axis_family;
tgif_info->title_size = title_size;
tgif_info->axis_size = axis_size;
tgif_info->strm = strm;
return 1;
}
/* Text justifications */
#define T_CENTER 0
#define T_LEFT 1
#define T_UPPERLEFT 2
#define T_TOP 3
#define T_UPPERRIGHT 4
#define T_RIGHT 5
#define T_LOWERRIGHT 6
#define T_BOTTOM 7
#define T_LOWERLEFT 8
/* Text styles */
#define T_AXIS 0
#define T_TITLE 1
static void
tgif_just(x, y, just, size, len)
int *x,
*y; /* Given location (lower left) */
int just; /* Justification */
int size; /* Size in points */
int len; /* Number of chars */
/*
* Unfortunately, tgif really can't display text with a justification.
* This is a horrible hack to try to get around the problem. It tries
* to compute a rough bounding box for the text based on the text height
* and the string length and offset `x,y' appropriately for the justification.
* This is only a hack...
*/
{
int t_width,
t_height;
t_height = size;
t_width = (size * len * 5) / 12; /* Horrible estimate */
switch (just) {
case T_CENTER:
*x -= t_width / 2;
*y -= t_height / 2;
break;
case T_LEFT:
*y -= t_height / 2;
break;
case T_UPPERLEFT:
/* nothing */
break;
case T_TOP:
*x -= t_width / 2;
break;
case T_UPPERRIGHT:
*x -= t_width;
break;
case T_RIGHT:
*x -= t_width;
*y -= t_height / 2;
break;
case T_LOWERRIGHT:
*x -= t_width;
*y -= t_height;
break;
case T_BOTTOM:
*x -= t_width / 2;
*y -= t_height;
break;
case T_LOWERLEFT:
*y -= t_height;
break;
}
/*
* Also, tgif seems to put a space above all text it draws. The
* computation below compensates for this.
*/
*y += (size / 3);
}
void
tgifText(user_state, x, y, text, just, style)
char *user_state; /* Value set in xg_init */
int x,
y; /* Text position (pixels) */
char *text; /* Null terminated text */
int just; /* Justification (above) */
int style; /* Text style (above) */
/*
* This routine should draw text at the indicated position using
* the indicated justification and style. The justification refers
* to the location of the point in reference to the text. For example,
* if just is T_LOWERLEFT, (x,y) should be located at the lower left
* edge of the text string.
*/
{
char *font;
int size;
Info *tgif = (Info *) user_state;
/*
* Obj = text(_Color,_X,_Y,_Font,_TextStyle,_TextSize,_NumLines,_TextJust,
* _TextRotate,_PenPat,_BBoxW,_BBoxH,_Id,_TextDPI,_Asc,_Des,
* _ObjFill,_Vspace,StrList),
*/
/* font ok too */
style == T_AXIS ? tgif->axis_font :
tgif->title_font;
/* ok 0, 1 as in tgif */
size = style == T_AXIS ? tgif->axis_size :
tgif->title_size;
tgif_just(&x, &y, just, size, strlen(text));
if (size <= 8)
size = 0;
else if (size <= 10)
size = 1;
else if (size <= 12)
size = 2;
else if (size <= 14)
size = 3;
else if (size <= 18)
size = 4;
else
size = 5;
fprintf(tgif->strm,
"text('%s',%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,[\n\t",
COLOR, x, y, 0, style, size, 1, 0, 0, 1, 0, 0, 0, 0, 18, 4, 0, 0);
fprintf(tgif->strm,
"\"%s\"]).\n", text);
}
/* Line Styles */
#define L_AXIS 0
#define L_ZERO 1
#define L_VAR 2
void
tgifSeg(user_state, ns, seglist, width, style, lappr, color)
char *user_state; /* Value set in xg_init */
int ns; /* Number of segments */
XSegment *seglist; /* X array of segments */
int width; /* Width of lines */
int style; /* See above */
int lappr; /* Line appearence */
int color; /* Line color (if any) */
{
Info *tgif = (Info *) user_state;
int i,
j,
k;
/*
* poly(_Color,_NumVs,_Vs,_LineStyle,_LineWidth,_PenPat,_Id,_Spline,
* _ObjFill,_Dash,AttrList),
*/
static int style_list[] =
{
1, 10, 7, 6, 5, 4, 3, 2
};
for (i = 0; i < ns; i++) {
fprintf(tgif->strm, "poly('%s',2,[%d,%d,%d,%d],", COLOR,
seglist[i].x1, seglist[i].y1,
seglist[i].x2, seglist[i].y2);
fprintf(tgif->strm, "%d,%d,%d,%d,%d,%d,%d,[\n]).\n", 0, width,
style_list[lappr], 0, 0, style_list[lappr], 0);
}
}
/* Marker styles */
#define P_PIXEL 0
#define P_DOT 1
#define P_MARK 2
void
tgifDot(user_state, x, y, style, type, color)
char *user_state; /* Value set in xg_init */
int x,
y; /* Location in pixel units */
int style; /* Dot style */
int type; /* Type of marker */
int color; /* Marker color (if any) */
/*
* This routine should draw a marker at location `x,y'. If the
* style is P_PIXEL, the dot should be a single pixel. If
* the style is P_DOT, the dot should be a reasonably large
* dot. If the style is P_MARK, it should be a distinguished
* mark which is specified by `type' (0-7). If the output
* device is capable of color, the marker should be drawn in
* `color' (0-7) which corresponds with the color for xg_line.
*/
{
}
void
tgifEnd(user_state)
char *user_state;
/*
* This routine is called after a drawing sequence is complete.
* It can be used to clean up the user state and set the device
* state appropriately. This routine is optional in the structure.
*/
{
Info *tgif = (Info *) user_state;
fclose(tgif->strm);
}

480
xgraph/xgX.c Normal file
View File

@ -0,0 +1,480 @@
/*
* Generic Output Driver for X
* X version 11
*
* This is the primary output driver used by the new X graph
* to display output to the X server. It has been factored
* out of the original xgraph to allow mulitple hardcopy
* output devices to share xgraph's capabilities. Note:
* xgraph is still heavily X oriented. This is not intended
* for porting to other window systems.
*/
#include "copyright.h"
#include "xgout.h"
#include "params.h"
#define PADDING 2
#define SPACE 10
#define TICKLENGTH 5
#define MAXSEGS 1000
struct x_state {
Window win; /* Primary window */
};
void text_X();
void seg_X();
void dot_X();
typedef struct attr_set {
char lineStyle[MAXLS];
int lineStyleLen;
Pixel pixelValue;
Pixmap markStyle;
} AttrSet;
static AttrSet AllAttrs[MAXATTR];
static Pixmap dotMap = (Pixmap) 0;
/*
* Marker bitmaps
*/
#include "bitmaps/dot.11"
#include "bitmaps/mark1.11"
#include "bitmaps/mark2.11"
#include "bitmaps/mark3.11"
#include "bitmaps/mark4.11"
#include "bitmaps/mark5.11"
#include "bitmaps/mark6.11"
#include "bitmaps/mark7.11"
#include "bitmaps/mark8.11"
/* Sizes exported for marker drawing */
static unsigned int dot_w = dot_width;
static unsigned int dot_h = dot_height;
static unsigned int mark_w = mark1_width;
static unsigned int mark_h = mark1_height;
static int mark_cx = mark1_x_hot;
static int mark_cy = mark1_y_hot;
void
set_X(new_win, out_info)
Window new_win; /* Newly created window */
xgOut *out_info; /* Information to set */
/*
* Sets some of the common parameters for the X output device.
*/
{
struct x_state *new_state;
XFontStruct *font;
out_info->dev_flags = ((depth > 3) ? D_COLOR : 0);
out_info->area_w = out_info->area_h = 0; /* Set later */
out_info->bdr_pad = PADDING;
out_info->axis_pad = SPACE;
out_info->legend_pad = 0;
out_info->tick_len = TICKLENGTH;
font = PM_FONT("LabelFont");
#ifdef OLD
out_info->axis_width =
font->max_bounds.rbearing - font->max_bounds.lbearing;
#endif
out_info->axis_width = XTextWidth(font, "8", 1);
out_info->axis_height =
font->max_bounds.ascent + font->max_bounds.descent;
font = PM_FONT("TitleFont");
#ifdef OLD
out_info->title_width =
font->max_bounds.rbearing - font->max_bounds.lbearing;
#endif
out_info->title_width = XTextWidth(font, "8", 1);
out_info->title_height =
font->max_bounds.ascent + font->max_bounds.descent;
out_info->max_segs = MAXSEGS;
out_info->xg_text = text_X;
out_info->xg_seg = seg_X;
out_info->xg_dot = dot_X;
out_info->xg_end = (void (*) ()) 0;
new_state = (struct x_state *) Malloc(sizeof(struct x_state));
new_state->win = new_win;
out_info->user_state = (char *) new_state;
}
static void
init_once()
/*
* Initializes AllAttrs.
*/
{
Window temp_win;
XSetWindowAttributes wattr;
char name[1024];
int idx;
params style_val;
/* Get attributes out parameters database */
for (idx = 0; idx < MAXATTR; idx++) {
(void) sprintf(name, "%d.Style", idx);
(void) param_get(name, &style_val);
AllAttrs[idx].lineStyleLen = style_val.stylev.len;
(void) strncpy(AllAttrs[idx].lineStyle, style_val.stylev.dash_list,
style_val.stylev.len);
(void) sprintf(name, "%d.Color", idx);
AllAttrs[idx].pixelValue = PM_PIXEL(name);
}
/* Create a temporary window for representing depth */
temp_win = XCreateWindow(disp, RootWindow(disp, screen),
0, 0, 10, 10, 0, depth, InputOutput,
vis, (unsigned long) 0, &wattr);
/* Store bitmaps for dots and markers */
dotMap = XCreateBitmapFromData(disp, temp_win, dot_bits, dot_w, dot_h);
AllAttrs[0].markStyle = XCreateBitmapFromData(disp, temp_win,
mark1_bits, mark_w, mark_h);
AllAttrs[1].markStyle = XCreateBitmapFromData(disp, temp_win,
mark2_bits, mark_w, mark_h);
AllAttrs[2].markStyle = XCreateBitmapFromData(disp, temp_win,
mark3_bits, mark_w, mark_h);
AllAttrs[3].markStyle = XCreateBitmapFromData(disp, temp_win,
mark4_bits, mark_w, mark_h);
AllAttrs[4].markStyle = XCreateBitmapFromData(disp, temp_win,
mark5_bits, mark_w, mark_h);
AllAttrs[5].markStyle = XCreateBitmapFromData(disp, temp_win,
mark6_bits, mark_w, mark_h);
AllAttrs[6].markStyle = XCreateBitmapFromData(disp, temp_win,
mark7_bits, mark_w, mark_h);
AllAttrs[7].markStyle = XCreateBitmapFromData(disp, temp_win,
mark8_bits, mark_w, mark_h);
XDestroyWindow(disp, temp_win);
}
/*ARGSUSED*/
void
init_X(user_state)
char *user_state;
/*
* Initializes for an X drawing sequence. Sets up drawing attributes
* by reading values from the parameter database.
*/
{
static int initialized = 0;
if (!initialized) {
init_once();
initialized = 1;
}
}
static GC
textGC(t_win, t_font)
Window t_win; /* Window for making GC */
XFontStruct *t_font; /* Text font */
/*
* Sets the fields above in a global graphics context. If
* the graphics context does not exist, it is created.
*/
{
static GC text_gc = (GC) 0;
XGCValues gcvals;
unsigned long gcmask;
gcvals.font = t_font->fid;
gcmask = GCFont;
if (text_gc == (GC) 0) {
gcvals.foreground = PM_PIXEL("Foreground");
gcmask |= GCForeground;
text_gc = XCreateGC(disp, t_win, gcmask, &gcvals);
}
else {
XChangeGC(disp, text_gc, gcmask, &gcvals);
}
return text_gc;
}
static GC
segGC(l_win, l_fg, l_style, l_width, l_chars, l_len)
Window l_win; /* Window for making GC */
Pixel l_fg; /* Foreground color */
int l_style; /* Line style */
int l_width; /* Line width */
char *l_chars; /* Character spec */
int l_len; /* Length of spec */
/*
* Sets the fields above in a global graphics context. If the
* graphics context does not exist, it is created.
*/
{
static GC segment_gc = (GC) 0;
XGCValues gcvals;
unsigned long gcmask;
gcvals.foreground = l_fg;
gcvals.line_style = l_style;
gcvals.line_width = l_width;
gcmask = GCForeground | GCLineStyle | GCLineWidth;
if (segment_gc == (GC) 0) {
segment_gc = XCreateGC(disp, l_win, gcmask, &gcvals);
}
else {
XChangeGC(disp, segment_gc, gcmask, &gcvals);
}
if (l_len > 0) {
XSetDashes(disp, segment_gc, 0, l_chars, l_len);
}
return segment_gc;
}
static GC
dotGC(d_win, d_fg, d_clipmask, d_xorg, d_yorg)
Window d_win; /* Window for making GC */
Pixel d_fg; /* Foreground color */
Pixmap d_clipmask; /* Clipmask */
int d_xorg,
d_yorg; /* Clipmask origin */
/*
* Sets the fields above in a global graphics context. If the
* graphics context does not exist, it is created.
*/
{
static GC dot_gc = (GC) 0;
XGCValues gcvals;
unsigned long gcmask;
gcvals.foreground = d_fg;
gcvals.clip_mask = d_clipmask;
gcvals.clip_x_origin = d_xorg;
gcvals.clip_y_origin = d_yorg;
gcmask = GCForeground | GCClipMask | GCClipXOrigin | GCClipYOrigin;
if (dot_gc == (GC) 0) {
dot_gc = XCreateGC(disp, d_win, gcmask, &gcvals);
}
else {
XChangeGC(disp, dot_gc, gcmask, &gcvals);
}
return dot_gc;
}
void
text_X(user_state, x, y, text, just, style)
char *user_state; /* Value set in xg_init */
int x,
y; /* Text position (pixels) */
char *text; /* Null terminated text */
int just; /* Justification (above) */
int style; /* Text style (above) */
/*
* This routine should draw text at the indicated position using
* the indicated justification and style. The justification refers
* to the location of the point in reference to the text. For example,
* if just is T_LOWERLEFT, (x,y) should be located at the lower left
* edge of the text string.
*/
{
struct x_state *st = (struct x_state *) user_state;
XCharStruct bb;
int rx = 0,
ry = 0,
len,
height,
width,
dir;
int ascent,
descent;
XFontStruct *font;
len = strlen(text);
font = ((style == T_TITLE) ? PM_FONT("TitleFont") : PM_FONT("LabelFont"));
XTextExtents(font, text, len, &dir, &ascent, &descent, &bb);
width = bb.rbearing - bb.lbearing;
height = bb.ascent + bb.descent;
switch (just) {
case T_CENTER:
rx = x - (width / 2);
ry = y - (height / 2);
break;
case T_LEFT:
rx = x;
ry = y - (height / 2);
break;
case T_UPPERLEFT:
rx = x;
ry = y;
break;
case T_TOP:
rx = x - (width / 2);
ry = y;
break;
case T_UPPERRIGHT:
rx = x - width;
ry = y;
break;
case T_RIGHT:
rx = x - width;
ry = y - (height / 2);
break;
case T_LOWERRIGHT:
rx = x - width;
ry = y - height;
break;
case T_BOTTOM:
rx = x - (width / 2);
ry = y - height;
break;
case T_LOWERLEFT:
rx = x;
ry = y - height;
break;
}
XDrawString(disp, st->win,
textGC(st->win, font),
rx, ry + bb.ascent, text, len);
}
void
seg_X(user_state, ns, segs, width, style, lappr, color)
char *user_state; /* Value set in xg_init */
int ns; /* Number of segments */
XSegment *segs; /* X array of segments */
int width; /* Width of lines */
int style; /* See above */
int lappr; /* Line appearence */
int color; /* Line color (if any) */
/*
* This routine draws a number of line segments at the points
* given in `seglist'. Note that contiguous segments need not share
* endpoints but often do. All segments should be `width' devcoords wide
* and drawn in style `style'. If `style' is L_VAR, the parameters
* `color' and `lappr' should be used to draw the line. Both
* parameters vary from 0 to 7. If the device is capable of
* color, `color' varies faster than `style'. If the device
* has no color, `style' will vary faster than `color' and
* `color' can be safely ignored. However, if the
* the device has more than 8 line appearences, the two can
* be combined to specify 64 line style variations.
* Xgraph promises not to send more than the `max_segs' in the
* xgOut structure passed back from xg_init().
*/
{
struct x_state *st = (struct x_state *) user_state;
param_style ps;
GC gc;
if (style == L_AXIS) {
ps = PM_STYLE("GridStyle");
if (ps.len < 2) {
gc = segGC(st->win, PM_PIXEL("Foreground"),
LineSolid, PM_INT("GridSize"), (char *) 0, 0);
}
else {
gc = segGC(st->win, PM_PIXEL("Foreground"),
LineOnOffDash, PM_INT("GridSize"),
ps.dash_list, ps.len);
}
}
else if (style == L_ZERO) {
/* Set the color and line style */
ps = PM_STYLE("ZeroStyle");
if (ps.len < 2) {
gc = segGC(st->win, PM_PIXEL("ZeroColor"),
LineSolid, PM_INT("ZeroWidth"), (char *) 0, 0);
}
else {
gc = segGC(st->win, PM_PIXEL("ZeroColor"),
LineOnOffDash, PM_INT("ZeroWidth"),
ps.dash_list, ps.len);
}
}
else {
/* Color and line style vary */
if (lappr == 0) {
gc = segGC(st->win, AllAttrs[color].pixelValue, LineSolid,
width, (char *) 0, 0);
}
else {
gc = segGC(st->win, AllAttrs[color].pixelValue, LineOnOffDash,
width, AllAttrs[lappr].lineStyle, AllAttrs[lappr].lineStyleLen);
}
/* PW */
if (lappr == 16) {
gc = segGC(st->win, PM_PIXEL("BackGround"), LineSolid,
width, (char *) 0, 0);
}
}
XDrawSegments(disp, st->win, gc, segs, ns);
}
#define LAST_CHECK
void
dot_X(user_state, x, y, style, type, color)
char *user_state; /* Value set in xg_init */
int x,
y; /* Location in pixel units */
int style; /* Dot style */
int type; /* Type of marker */
int color; /* Marker color (if any) */
/*
* This routine should draw a marker at location `x,y'. If the
* style is P_PIXEL, the dot should be a single pixel. If
* the style is P_DOT, the dot should be a reasonably large
* dot. If the style is P_MARK, it should be a distinguished
* mark which is specified by `type' (0-7). If the output
* device is capable of color, the marker should be drawn in
* `color' (0-7) which corresponds with the color for xg_line.
*/
{
struct x_state *st = (struct x_state *) user_state;
switch (style) {
case P_PIXEL:
XDrawPoint(disp, st->win,
dotGC(st->win, AllAttrs[color].pixelValue, (Pixmap) 0, 0, 0),
x, y);
break;
case P_DOT:
XFillRectangle(disp, st->win,
dotGC(st->win, AllAttrs[color].pixelValue, dotMap,
(int) (x - (dot_w >> 1)),
(int) (y - (dot_h >> 1))),
(int) (x - (dot_w >> 1)), (int) (y - (dot_h >> 1)),
dot_w, dot_h);
break;
case P_MARK:
XFillRectangle(disp, st->win,
dotGC(st->win, AllAttrs[color].pixelValue,
AllAttrs[type].markStyle,
(int) (x - mark_cx),
(int) (y - mark_cy)),
(int) (x - mark_cx), (int) (y - mark_cy),
mark_w, mark_h);
break;
}
}

65
xgraph/xgout.h Normal file
View File

@ -0,0 +1,65 @@
/*
* Output Device Information
*
* This file contains definitions for output device interfaces
* to the graphing program xgraph.
*/
#ifndef _h_xgout
#define _h_xgout
/* Passed device option flags */
#define D_DOCU 0x01
/* Returned device capability flags */
#define D_COLOR 0x01
/* Text justifications */
#define T_CENTER 0
#define T_LEFT 1
#define T_UPPERLEFT 2
#define T_TOP 3
#define T_UPPERRIGHT 4
#define T_RIGHT 5
#define T_LOWERRIGHT 6
#define T_BOTTOM 7
#define T_LOWERLEFT 8
/* Text styles */
#define T_AXIS 0
#define T_TITLE 1
/* Line Styles */
#define L_AXIS 0
#define L_ZERO 1
#define L_VAR 2
/* Marker Styles */
#define P_PIXEL 0
#define P_DOT 1
#define P_MARK 2
/* Output device information returned by initialization routine */
typedef struct xg_out {
int dev_flags; /* Device characteristic flags */
int area_w,
area_h; /* Width and height in pixels */
int bdr_pad; /* Padding from border */
int axis_pad; /* Extra space around axis labels */
int tick_len; /* Length of tick mark on axis */
int legend_pad; /* Top of legend text to legend line */
int axis_width; /* Width of big character of axis font */
int axis_height; /* Height of big character of axis font */
int title_width; /* Width of big character of title font */
int title_height; /* Height of big character of title font */
int max_segs; /* Maximum number of segments in group */
void (*xg_text) (); /* Draws text at a location */
void (*xg_seg) (); /* Draws a series of segments */
void (*xg_dot) (); /* Draws a dot or marker at a location */
void (*xg_end) (); /* Stops the drawing sequence */
char *user_state; /* User supplied data */
} xgOut;
#define ERRBUFSIZE 2048
#endif /* _h_xgout */

1279
xgraph/xgraph.c Normal file

File diff suppressed because it is too large Load Diff

210
xgraph/xgraph.h Normal file
View File

@ -0,0 +1,210 @@
/*
* Globally accessible information from xgraph
*/
#ifndef _XGRAPH_H_
#define _XGRAPH_H_
#include "autoconf.h"
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
/*
* Get definitions from headers.
*/
#include <stdio.h> /* sprintf */
#ifdef HAVE_STRING_H
#include <string.h> /* str* */
#else
#ifdef HAVE_STRINGS_H
#include <strings.h> /* str* */
#else
extern char *strcpy();
extern char *strcat();
extern char *rindex();
extern char *index();
#endif /* HAVE_STRINGS_H */
#endif /* HAVE_STRING_H */
#ifdef HAVE_UNISTD_H
#include <unistd.h> /* exit, abort */
#endif /* HAVE_UNISTD_H */
#ifdef HAVE_STDLIB_H
#include <stdlib.h> /* atof */
#endif /* HAVE_STDLIB_H */
#include "xgout.h"
#define VERSION_STRING "12.1 December 1999 "
#define MAXKEYS 50
#define MAXATTR 8
#define MAXSETS 112
#define MAXBUFSIZE 120
#define MAXLS 50
#define STRDUP(xx) (strcpy(Malloc((unsigned) (strlen(xx)+1)), (xx)))
#define SCREENX(ws, userX) \
(((int) (((userX) - ws->UsrOrgX)/ws->XUnitsPerPixel + 0.5)) + ws->XOrgX)
#define SCREENY(ws, userY) \
(ws->XOppY - ((int) (((userY) - ws->UsrOrgY)/ws->YUnitsPerPixel + 0.5)))
#define HARDCOPY_IN_PROGRESS 0x01
/* Portability */
/* try to get those constants */
#include <math.h>
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif /* HAVE_LIMITS */
#ifdef HAVE_FLOAT_H
#include <float.h>
#endif /* HAVE_FLOAT_H */
#ifdef CRAY
#undef MAXFLOAT
#define MAXFLOAT 10.e300
#endif /* CRAY */
#ifndef MAXFLOAT
#if defined(FLT_MAX)
#define MAXFLOAT FLT_MAX
#elif defined(HUGE)
#define MAXFLOAT HUGE
#endif
#endif
#ifndef BIGINT
#if defined(INT_MAX)
#define BIGINT INT_MAX
#elif defined(MAXINT)
#define BIGINT MAXINT
#else
#define BIGINT 0xffffffff
#endif
#endif
#define GRIDPOWER 10
#define INITSIZE 128
#define CONTROL_D '\004'
#define CONTROL_C '\003'
#define TILDE '~'
#define BTNPAD 1
#define BTNINTER 3
#ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef ABS
#define ABS(x) ((x) < 0 ? -(x) : (x))
#endif
#define ZERO_THRES 1.0E-07
/* To get around an inaccurate log */
#define nlog10(x) (x == 0.0 ? 0.0 : log10(x) + 1e-15)
#define ISCOLOR (wi->dev_info.dev_flags & D_COLOR)
#define PIXVALUE(set) ((set) % MAXATTR)
#define LINESTYLE(set) \
(ISCOLOR ? ((set)/MAXATTR) : ((set) % MAXATTR))
#define MARKSTYLE(set) \
(colorMark ? COLMARK(set) : BWMARK(set))
#define COLMARK(set) \
((set) / MAXATTR)
#define BWMARK(set) \
((set) % MAXATTR)
#define LOG_X 0x01
#define LOG_Y 0x02
#define STK 0x04
#define FITX 0x08
#define FITY 0x10
typedef unsigned long Pixel;
/* Globally accessible values */
extern Display *disp; /* Open display */
extern Visual *vis; /* Standard visual */
extern Colormap cmap; /* Standard colormap */
extern int screen; /* Screen number */
extern int depth; /* Depth of screen */
extern void do_hardcopy(); /* Carries out hardcopy */
extern void ho_dialog(); /* Hardcopy dialog */
extern void set_X(); /* Initializes X device */
typedef struct point_list {
int numPoints; /* Number of points in group */
int allocSize; /* Allocated size */
double *xvec; /* X values */
double *yvec; /* Y values */
struct point_list *next; /* Next set of points */
} PointList;
typedef struct new_data_set {
char *setName; /* Name of data set */
PointList *list; /* List of point arrays */
} NewDataSet;
typedef struct local_win {
double loX,
loY,
hiX,
hiY; /* Local bounding box of window */
int XOrgX,
XOrgY; /* Origin of bounding box on screen */
int XOppX,
XOppY; /* Other point defining bounding box */
double UsrOrgX,
UsrOrgY; /* Origin of bounding box in user space */
double UsrOppX,
UsrOppY; /* Other point of bounding box */
double XUnitsPerPixel; /* X Axis scale factor */
double YUnitsPerPixel; /* Y Axis scale factor */
struct xg_out dev_info; /* Device information */
Window close,
hardcopy; /* Buttons for closing and hardcopy */
Window about; /* Version information */
Window rewind; /* PW Added this, for animation. */
Window replot; /* PW Added this, for animation. */
Window deriv; /* PW Added this, for animation. */
int flags; /* Window flags */
int DOrder; /* Which order of Derivative is being set? */
} LocalWin;
extern NewDataSet PlotData[MAXSETS], DataD1[MAXSETS], DataD2[MAXSETS];
extern XSegment *Xsegs[2]; /* Point space for X */
extern double llx, lly, urx, ury; /* Bounding box of all data */
extern int numFiles; /* Number of input files */
extern char *inFileNames[MAXSETS]; /* File names */
/* Total number of active windows */
extern int Num_Windows;
extern char *Prog_Name;
extern char *disp_name;
/* To make lint happy */
extern char *Malloc();
extern char *Realloc();
extern void Free();
#ifndef _POSIX_SOURCE
/* extern int sprintf(); ---conflicts with sunos */
extern void exit();
extern double atof();
extern void abort();
#endif /* _POSIX_SOURCE */
#endif /* _XGRAPH_H_ */

389
xgraph/xgraph.man Normal file
View File

@ -0,0 +1,389 @@
.TH XGRAPH 1 "December, 1989"
.SH NAME
xgraph \- Draw a graph on an X11 Display
.SH SYNOPSIS
.B xgraph
[ options ] [[-geometry |=]WxH+X+Y ] [ -display host:display.screen ] [ file ... ]
.SH DESCRIPTION
The
.I xgraph
program draws a graph on an X display given data read from either
data files or from standard input if no files are specified.
It can display up to 64 independent data sets using different colors
and/or line styles for each set.
It annotates the graph with a title, axis labels, grid lines or tick
marks, grid labels,
and a legend.
There are options to control the appearance of most components of
the graph.
.PP
The input format is similar to
.I graph(1G)
but differs slightly.
The data consists of a number of
.I "data sets."
Data sets are separated by a blank line.
A new data set is also
assumed at the start of each input file.
A data set consists of an ordered list of points of the form "{directive} X Y".
The directive is either "draw" or "move" and can be omitted.
If the directive is "draw", a line will be drawn between the previous
point and the current point (if a line graph is chosen).
Specifying a "move" directive tells xgraph not to draw a line between
the points.
If the directive is omitted, "draw" is assumed for all points in
a data set except the
first point where "move" is assumed.
The "move" directive is used most often to allow discontinuous data
in a data set.
The name of a data set can be specified by
enclosing the name in double quotes on a line by itself in the
body of the data set. The trailing double quote is optional.
Overall graphing options for the graph can be specified in data
files by writing lines of the form "<option>: <value>". The
option names are the same as those used for specifying X
resources (see below). The option and value must be separated by at
bleast one space.
An example input file with three data sets is shown below. Note
that set three is not named, set two has discontinuous data,
and the title of the graph is specified near the top of the file.
.sp 1
.nf
TitleText: Sample Data
0.5 7.8
1.0 6.2
"set one
1.5 8.9
"set two"
-3.4 1.4e-3
-2.0 1.9e-2
move -1.0 2.0e-2
-0.65 2.2e-4
2.2 12.8
2.4 -3.3
2.6 -32.2
2.8 -10.3
.fi
.PP
After
.I xgraph
has read the data, it will create a new window to graphically
display the data.
The interface used to specify the size and location of this window depends
on the window manager currently in use.
Refer to the reference manual of the window manager for details.
.PP
Once the window has been opened, all of the data sets will be displayed
graphically (subject to the options explained below) with a legend in
the upper right corner of the screen.
To zoom in on a portion of the graph, depress a mouse button in
the window and sweep out a region.
.I xgraph
will then open a new window looking at just that portion of the graph.
.I xgraph
also presents three control buttons in the upper left corner of
each window:
.I Close,
.I Hardcopy,
and
.I About.
Windows are closed by depressing a mouse button while the mouse
cursor is inside the
.I Close
button. Typing EOF (control-D) in a window also closes that window.
Depressing a mouse button while the mouse cursor is in the
.I Hardcopy
button causes a dialog to appear asking about hardcopy (printout)
options. These options are described below:
.IP "Output Device"
Specifies the type of the output device (e.g. "HPGL", "Postscript", etc).
An output device is chosen by depressing the mouse inside its name.
The default values of other fields will change when you select a
different output device.
.IP "Disposition"
Specifies whether the output should go directly to a device
or to a file. Again, the default values of other fields will change
when you select a different disposition.
.IP "File or Device Name"
If the disposition is "To Device", this field specifies the device
name.
A device name is the same as the name given for the -P command
of lpr(1).
If the disposition is "To File", this field specifies the name
of the output file.
.IP "Maximum Dimension"
This specifies the maximum size of the plot on the hardcopy
device in centimeters.
.I xgraph
takes in account the aspect ratio of the plot on the screen
and will scale the plot so that the longer side of the plot
is no more than the value of this parameter.
If the device supports it, the plot may also be rotated on the page
based on the value of the maximum dimension.
.IP "Include in Document"
If selected, this option causes
.I xgraph
to produce harcopy output that is suitable for inclusion in other
larger documents.
As an example, when this option is selected the Postscript output
produced by xgraph will have a bounding box suitable for use with
psfig.
.IP "Title Font Family"
This field specifies the name of a font to use when drawing
the graph title. Suitable defaults are initially chosen for
any given hardcopy device.
The value of this field is hardware specific -- refer to
the device reference manual for details.
.IP "Title Font Size"
This field specifies the desired size of the title fonts in points
(1/72 of an inch).
If the device supports scalable fonts, the
font will be scaled to this size.
.IP "Axis Font Family and Axis Font Size"
These fields are like
.I "Title Font Family"
and
.I "Title Font Size"
except they specify values for the font
.I xgraph
uses to draw axis labels, and legend descriptions.
.IP "Control Buttons"
After specifing the parameters for the plot, the "Ok" button causes
.I xgraph
to produce a hardcopy.
Pressing the "Cancel" button will abort the hardcopy operation.
Depressing the
.I About
button causes Xgraph to display a window containing the version of
the program and an electronic mailing address for the author
for comments and suggestions.
.PP
.I xgraph
accepts a large number of options most of which can be specified
either on the command line, in the user's .Xdefaults or .Xresources file,
or in the data files themselves.
A list of these options is given below. The command line
option is specified first with its X default or data file name (if any)
in parenthesis afterward.
The format of the option in the X defaults file is "program.option: value"
where program is the program name (xgraph) and the option name is the
one specified below.
Option specifications in the data file are similar to the X defaults file
specification except the program name is omitted.
.TP
.B \-geometry WxH+X+Y or \=WxH+X+Y (Geometry)
Specifies the initial size and location of the xgraph window.
.TP
.B \-<digit> <name>
These options specify the data set name for the corresponding data set.
The digit should be in the range '0' to '63'.
This name will be used in the legend.
.TP
.B \-bar (BarGraph)
Specifies that vertical bars should be drawn from the data points to
a base point which can be specified with -brb. Usually, the -nl
flag is used with this option. The point itself is located at
the center of the bar.
.TP
.B \-bof (BarGraph)
Offset the bars for additional datasets by the specified amount.
.TP
.B \-device <name>
Set the output device for xgraph. The default is 'X'; other valid
devices are 'ps', 'hpgl', 'idraw' and tgif.
.TP
.B \-o <filename> \-O <filename>
Set the output file name for postscript, hpgl and idraw devices.
Files created with -O can be used other documents, and files generated
with -o can be printed directly.
.TP
.B \-P<printername>
Set the printer name for postscript or hpgl devices. This and the -o or -O
option are mutually exclusive.
.TP
.B \-stk
Stack elements coming from different datasets, instead of plotting them
from the same baseline. Datasets must match exactly.
.TP
.B \-fitx
Translate and scale the x data from all datasets to fit [0..1].
.B \-fity
Translate and scale the y data from all datasets to fit [0..1].
.TP
.B \-scale <factor>
Output scale factor for postscript, hpgl and idraw devices. The default
is 1.0, and 0.5 will generate a 50% reduced plot.
.TP
.B \-fmtx <printf-format> \-fmty <printf-format>
Use the format specified to generate the legents for the x or y axis.
.TP
.B \-bb (BoundBox)
Draw a bounding box around the data region. This is very useful
if you prefer to see tick marks rather than grid lines (see -tk).
.TP
.B \-bd <color> (Border)
This specifies the border color of the
.I xgraph
window.
.TP
.B \-bg <color> (Background)
Background color of the
.I xgraph
window.
.TP
.B \-brb <base> (BarBase)
This specifies the base for a bar graph. By default, the base is zero.
.TP
.B \-brw <width> (BarWidth)
This specifies the width of bars in a bar graph. The amount is specified
in the user's units. By default, a bar one pixel wide is drawn.
.TP
.B \-bw <size> (BorderSize)
Border width (in pixels) of the
.I xgraph
window.
.TP
.B \-db (Debug)
Causes xgraph to run in synchronous mode and prints out the values
of all known defaults.
.TP
.B \-fg <color> (Foreground)
Foreground color. This color is used to draw all text and the normal
grid lines in the window.
.TP
.B \-gw (GridSize)
Width, in pixels, of normal grid lines.
.TP
.B \-gs (GridStyle)
Line style pattern of normal grid lines.
.TP
.B \-lf <fontname> (LabelFont)
Label font. All axis labels and grid labels are drawn using this font.
A font name may be specified exactly (e.g. "9x15" or
"-*-courier-bold-r-normal-*-140-*") or in an abbreviated form: <family>-<size>.
The family is the family name (like helvetica) and the size is the font
size in points (like 12). The default for this parameter is "helvetica-12".
.TP
.B \-lnx (LogX)
Specifies a logarithmic X axis. Grid labels represent powers of ten.
.TP
.B \-lny (LogY)
Specifies a logarithmic Y axis. Grid labels represent powers of ten.
.TP
.B \-lw width (LineWidth)
Specifies the width of the data lines in pixels. The default is zero.
.TP
.B \-lx <xl,xh> (XLowLimit, XHighLimit)
This option limits the range of the X axis to the specified
interval. This (along with -ly) can be used to "zoom in" on a particularly
interesting portion of a larger graph.
.TP
.B \-ly <yl,yh> (YLowLimit, YHighLimit)
This option limits the range of the Y axis to the specified
interval.
.TP
.B \-m (Markers)
Mark each data point with a distinctive marker.
There are eight distinctive markers used by xgraph.
These markers are assigned uniquely to each different line style on
black and white machines and varies with each color on color machines.
.TP
.B \-M (StyleMarkers)
Similar to -m but markers are assigned uniquely to each eight consecutive
data sets (this corresponds to each different line style on color machines).
.TP
.B \-nl (NoLines)
Turn off drawing lines. When used with -m, -M, -p, or -P this can be used to
produce scatter plots. When used with -bar, it can be used to
produce standard bar graphs.
.TP
.B \-ng (NoLegend)
Turn off drawing Legends. Can be used to increase the drawing area.
.TP
.B \-p (PixelMarkers)
Marks each data point with a small marker (pixel sized). This is
usually used with the -nl option for scatter plots.
.TP
.B \-P (LargePixels)
Similar to -p but marks each pixel with a large dot.
.TP
.B \-rv (ReverseVideo)
Reverse video. On black and white displays, this will invert
the foreground and background colors.
The behaviour on color displays is undefined.
.TP
.B \-t <string> (TitleText)
Title of the plot. This string is centered at the top of the graph.
.TP
.B \-tf <fontname> (TitleFont)
Title font. This is the name of the font to use for the graph title.
A font name may be specified exactly (e.g. "9x15" or
"-*-courier-bold-r-normal-*-140-*") or in an abbreviated form: <family>-<size>.
The family is the family name (like helvetica) and the size is the font
size in points (like 12). The default for this parameter is "helvetica-18".
.TP
.B \-tk (Ticks)
This option causes
.I xgraph
to draw tick marks rather than full grid lines. The -bb option
is also useful when viewing graphs with tick marks only.
.TP
.B \-tkax (Tick Axis)
When tick marks are enabled, plot the axes.
.TP
.B \-x <unitname> (XUnitText)
This is the unit name for the X axis. Its default is "X".
.TP
.B \-y <unitname> (YUnitText)
This is the unit name for the Y axis. Its default is "Y".
.TP
.B \-zg <color> (ZeroColor)
This is the color used to draw the zero grid line.
.TP
.B \-zw <width> (ZeroWidth)
This is the width of the zero grid line in pixels.
.PP
Some options can only be specified in the X defaults file or in the
data files. These options are described below:
.TP
.B <digit>.Color
Specifies the color for a data set. Eight independent colors can
be specified. Thus, the digit should be between '0' and '7'.
If there are more than eight data sets, the colors
will repeat but with a new line style (see below).
.TP
.B <digit>.Style
Specifies the line style for a data set. A string of ones
and zeros specifies the pattern used for the line style.
Eight independent line styles can be specified. Thus, the
digit should be between '0' and '7'. If there are more
than eight data sets, these styles will be reused. On color
workstations, one line style is used for each of eight colors.
Thus, 64 unique data sets can be displayed.
.TP
.B Device
The default output form presented in the hardcopy dialog (i.e. "Postscript",
"HPGL", etc).
.TP
.B Disposition
The default setting of whether output goes directly to a device or to a file.
This must be one of the strings "To File" or "To Device".
.TP
.B FileOrDev
The default file name or device string in the hardcopy dialog.
.TP
.B ZeroWidth
Width, in pixels, of the zero grid line.
.TP
.B ZeroStyle
Line style pattern of the zero grid line.
.SH AUTHOR
David Harrison
University of California
.SH BUGS
.br
- Zooming in on bar graphs doesn't work right.
.br
- There is no way to produce hardcopy without running xgraph interactively.

1617
xgraph/xtb.c Normal file

File diff suppressed because it is too large Load Diff

192
xgraph/xtb.h Normal file
View File

@ -0,0 +1,192 @@
/*
* xtb - a mini-toolbox for X11
*
* David Harrison
* University of California, Berkeley
* 1988
*/
#ifndef _XTB_
#define _XTB_
#include "copyright.h"
/* Handler function return codes */
typedef enum xtb_hret_defn {
XTB_NOTDEF, XTB_HANDLED, XTB_STOP
} xtb_hret;
/* If you have an ANSI compiler, some checking will be done */
#ifdef __STDC__
#define DECLARE(func, rtn, args) extern rtn func args
typedef void *xtb_data;
#else
#define DECLARE(func, rtn, args) extern rtn func ()
typedef char *xtb_data;
#endif
/* Basic return value */
typedef struct xtb_frame_defn {
Window win;
int x_loc,
y_loc;
unsigned int width,
height;
} xtb_frame;
DECLARE(xtb_init, void, (Display * disp, int scrn,
unsigned long foreground,
unsigned long background,
XFontStruct * font));
/* Initializes mini-toolbox */
/*
* Basic event handling
*/
DECLARE(xtb_register, void, (Window win,
xtb_hret(*func) (XEvent * evt, xtb_data info),
xtb_data info));
/* Registers call-back function */
DECLARE(xtb_lookup, xtb_data, (Window win));
/* Returns data associated with window */
DECLARE(xtb_dispatch, xtb_hret, (XEvent * evt));
/* Dispatches events for mini-toolbox */
DECLARE(xtb_unregister, int, (Window win, xtb_data * info));
/* Unregisters a call-back function */
/*
* Command button frame
*/
DECLARE(xtb_bt_new, void, (Window win, char *text,
xtb_hret(*func) (Window win, int state,
xtb_data val),
xtb_data val,
xtb_frame * frame));
/* Creates new button */
DECLARE(xtb_bt_get, int, (Window win, xtb_data * stuff, int *na));
/* Returns state of button */
DECLARE(xtb_bt_set, int, (Window win, int val, xtb_data stuff, int na));
/* Sets state of button */
DECLARE(xtb_bt_del, void, (Window win, xtb_data * info));
/* Deletes a button */
/*
* Button row frame - built on top of buttons
*/
DECLARE(xtb_br_new, void, (Window win, int cnt, char *lbls[], int init,
xtb_hret(*func) (Window win, int prev,
int this, xtb_data val),
xtb_data val,
xtb_frame * frame));
/* Creates a new button row frame */
DECLARE(xtb_br_get, int, (Window win));
/* Returns currently selected button */
DECLARE(xtb_br_del, void, (Window win));
/* Deletes a button row */
/*
* Text output (label) frames
*/
DECLARE(xtb_to_new, void, (Window win, char *text,
XFontStruct * ft, xtb_frame * frame));
/* Create new text output frame */
DECLARE(xtb_to_del, void, (Window win));
/*
* Text input (editable text) frames
*/
#define MAXCHBUF 1024
DECLARE(xtb_ti_new, void, (Window win, char *text, int maxchar,
xtb_hret(*func) (Window win, int ch,
char *textcopy, xtb_data * val),
xtb_data val, xtb_frame * frame));
/* Creates a new text input frame */
DECLARE(xtb_ti_get, void, (Window win, char text[MAXCHBUF], xtb_data * val));
/* Returns state of text input frame */
DECLARE(xtb_ti_set, int, (Window win, char *text, xtb_data val));
/* Sets the state of text input frame */
DECLARE(xtb_ti_ins, int, (Window win, int ch));
/* Inserts character onto end of text input frame */
DECLARE(xtb_ti_dch, int, (Window win));
/* Deletes character from end of text input frame */
DECLARE(xtb_ti_del, void, (Window win, xtb_data * info));
/* Deletes an text input frame */
/*
* Block frame
*/
DECLARE(xtb_bk_new, void, (Window win, unsigned width, unsigned height,
xtb_frame * frame));
/* Makes a new block frame */
DECLARE(xtb_bk_del, void, (Window win));
/* Deletes a block frame */
/*
* Formatting support
*/
#define MAX_BRANCH 50
typedef enum xtb_fmt_types_defn {
W_TYPE, A_TYPE
} xtb_fmt_types;
typedef enum xtb_fmt_dir_defn {
HORIZONTAL, VERTICAL
} xtb_fmt_dir;
typedef enum xtb_just_defn {
XTB_CENTER = 0, XTB_LEFT, XTB_RIGHT, XTB_TOP, XTB_BOTTOM
} xtb_just;
typedef struct xtb_fmt_widget_defn {
xtb_fmt_types type; /* W_TYPE */
xtb_frame *w;
} xtb_fmt_widget;
typedef struct xtb_fmt_align_defn {
xtb_fmt_types type; /* A_TYPE */
xtb_fmt_dir dir; /* HORIZONTAL or VERTICAL */
int padding; /* Outside padding */
int interspace; /* Internal padding */
xtb_just just; /* Justification */
int ni; /* Number of items */
union xtb_fmt_defn *items[MAX_BRANCH]; /* Branches themselves */
} xtb_fmt_align;
typedef union xtb_fmt_defn {
xtb_fmt_types type; /* W_TYPE or A_TYPE */
xtb_fmt_widget wid;
xtb_fmt_align align;
} xtb_fmt;
#define NE 0
DECLARE(xtb_w, xtb_fmt *, (xtb_frame * w));
/* Returns formatting structure for frame */
DECLARE(xtb_hort, xtb_fmt *, (xtb_just just, int padding, int interspace,...));
/* Varargs routine for horizontal formatting */
DECLARE(xtb_vert, xtb_fmt *, (xtb_just just, int padding, int interspace,...));
/* Varargs routine for vertical formatting */
DECLARE(xtb_fmt_do, xtb_fmt *, (xtb_fmt * def, unsigned *w, unsigned *h));
/* Carries out formatting */
DECLARE(xtb_mv_frames, void, (int nf, xtb_frame frames[]));
/* Actually moves widgets */
DECLARE(xtb_fmt_free, void, (xtb_fmt * def));
/* Frees resources claimed by xtb_w, xtb_hort, and xtb_vert */
#endif /* _XTB_ */