home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-07-21 | 64.9 KB | 1,748 lines |
- diff -uwr gnuplot-3.7.0.8/config/makefile.os2 gnuplot-pm3d/config/makefile.os2
- --- gnuplot-3.7.0.8/config/makefile.os2 Tue Jun 15 15:32:16 1999
- +++ gnuplot-pm3d/config/makefile.os2 Tue Jun 15 15:31:10 1999
- @@ -45,6 +45,11 @@
- # MOUSE support for PM terminal
- MOUSE=1
-
- +# PM3D splot mode + colours and filled polygons
- +# (not yet supported in official release)
- +# if all around PM3D runs well, this option will be omitted from makefiles
- +PM3D=1
- +
- #
- # ****************** End of Configuration section ****************************
- #
- @@ -183,6 +188,11 @@
- # MOUSE support for PM terminal
- ifdef MOUSE
- TERMFLAGS += -DUSE_MOUSE
- +endif
- +# PM3D support
- +ifdef PM3D
- +CFLAGS += -DPM3D
- +CFLAGS2 += -DPM3D
- endif
-
- #
- diff -uwr gnuplot-3.7.0.8/docs/gnuplot.doc gnuplot-pm3d/docs/gnuplot.doc
- --- gnuplot-3.7.0.8/docs/gnuplot.doc Sun May 30 18:12:54 1999
- +++ gnuplot-pm3d/docs/gnuplot.doc Tue Jun 15 14:39:18 1999
- @@ -4990,6 +4990,216 @@
- and `set vrange`, or by specifying the range on the `plot` or `splot`
- commands. Currently the default range for these parametric variables is
- [-5:5]. Setting the ranges to something more meaningful is expected.
- +3 pm3d
- +?commands set pm3d
- +?commands show pm3d
- +?set pm3d
- +?show pm3d
- +?pm3d
- + pm3d is a [new] type of `splot` mode for drawing colour/gray maps and
- + surfaces. It can be used for plotting gridded as well as non-gridded data.
- + The main power of the pm3d algorithm (see also my program pm3d) is that
- + it can draw maps or surfaces from large data sets without preprocessing even
- + when the data are non-gridded and the scans do not have same number of
- + points---thus it produces no artefacts.
- +
- + The pm3d algorithm fills the region between two neighbouring points in one scan
- + with another two points in the next scan by a gray (or colour) according to the
- + average of the z data in these four points. From this follows, that the
- + neighbouring scans should not cross and the number of points in the
- + neighbouring scans should not differ too much (you see---scans can have
- + different number of points). No other requirements (e.g. the data must be
- + gridded) are needed. Another advantage is that the algorithm does not draw
- + anything outside of the input (measured or calculated) region.
- +
- + The gray is obtained by mapping the averaged z coordinate of the four corners
- + of the quadrangle into the range [min_z,max_z] providing range of grays [0:1].
- + This value can be used directly as the gray for gray maps. The gray value can
- + be mapped into a colour. See `set palette` for the complete description.
- +
- + The pm3d mode requires a terminal supporting filled coloured polygons and
- + palettes of smooth colours. See `help set palette` for the list of currently
- + available terminals.
- +
- + Notes:
- + 1. What I call scan, it is called iso_curve in gnuplot sources. I am
- + physicist and we measure maps taking one scan after another scan,
- + that's why
- + 2. Map is obtained by `set view 180,0,1.25; set yrange [*:*] reverse`.
- + This can be easily switched on by using `set pm3d map`.
- + 3. If you find this help unclear, then your assistance is welcome.
- + Similarly, any feedback for the code is welcome as well as the
- + required terminal entries for other terminals, like X11
- +
- + pm3d mode has been developed by Petr Mikulik. It is currently in a
- + development stage and distributed as a patch to the current gnuplot beta
- + sources. Please read the READMEs enclosed with the pm3d patch distribution.
- + You may find the current version of the patch and snapshots at my web page:
- + http://www.sci.muni.cz/~mikulik/gnuplot.html#pm3d
- +
- + Syntax:
- + set pm3d
- + set pm3d {
- + { at <bst combination> }
- + { scansforward | scansbackward }
- + { flush { begin | center | end } }
- + { clip1in | clip4in }
- + { zrange [{<z_from>|*}:{<z_to>|*}] }
- + { map }
- + }
- + set nopm3d
- + show pm3d
- +
- + `set pm3d` (i.e. without options) sets up the default values.
- + Otherwise, the options can be given in any order.
- +
- + pm3d can be drawn at the base or top (colour/gray map) or as surface
- + (colour/gray surface). This is defined by the `at` option with a
- + a string of up to 6 combinations of `b`, `t` and `s`. For instance, `at b`
- + plots at bottom only, `at st` plots firstly surface, then top, `at bstbst`...
- +
- + Coloured quadrangles are plotted one after another. When plotting surfaces
- + (`at s`), the later overlaps the previous ones. You may try to switch
- + between `scansforward` and `scansbackward` to change whether the first scan
- + of the data is plotted first or last.
- +
- + If two subsequent scans do not have the same number of points, then it
- + has to be decided whether to start taking points for quadrangles from the
- + beginning of both scans (`flush begin`), from their ends (`flush end`) or to
- + center them (`flush center`).
- +
- + Clipping with respect to the x,y coordinates can be done in two ways.
- + `clip1in`: all 4 points of the quadrangle must be defined and at least
- + 1 point of the quadrangle must be in the x and y ranges. `clip4in`: all 4
- + points of the quadrangle must be in the x and y ranges.
- +
- + The above clipping is OK for plotting maps. For surfaces, clipping with
- + respect to the z coordinate will be necessary. Maybe in future... (maybe
- + something like "clipz1in" and "clipz4in"). Really needed?
- +
- + By default, the z range for colouring is the same as that from `set zrange`.
- + That's OK for maps; for surfaces, however, using separate z ranges for plotting
- + and colouring can be of advantage. Then use `set pm3d zrange`.
- +
- + The `set pm3d map` is actually a macro which facilitates plotting maps. It is
- + equivalent to these user commands:
- + set pm3d at b; set nosurface; set nocontour
- + set view 180,0,1.3
- + set yrange [*:*] reverse
- + ... and something on size, origin (no! gnuplot bug!)
- + Notice that *now* y label goes away from screen since it is not rotated as
- + I would expect. Adjust it with sth like `set ylabel "hogo fogo" 12`. Or
- + implement a 2D LAYOUT FOR 3D MAPS, please!!!
- +
- + The colouring setup as well as the colour box drawing are determinated by `set
- + palette`. Maybe in future there could be a possibility of using more palettes,
- + which will add new option `set pm3d palette <n>`.
- +
- +3 palette
- +?commands set palette
- +?commands show palette
- +?set palette
- +?show palette
- +?palette
- + Palette is a colour storage for use by `pm3d`, filled colour contours or
- + polygons, colour histograms, colour gradient background, and whatever it is or
- + it will be implemented... Here it stays for a palette of smooth "continuous"
- + colours or grays, but let's call it just a palette.
- +
- + Colour palettes, or requires terminal entries for filled colour
- + polygons and palettes of smooth colours, are currently available for
- + `*** fig, gif, pm and postscript ***`
- + terminals. You are welcome to implement other terminals, mainly X11 and png!
- +
- +
- + Syntax:
- + set palette
- + set palette {
- + { gray | color }
- + { rgbformulae <r>,<g>,<b> }
- + { positive | negative }
- + { nops_allcF | ps_allcF }
- + { maxcolors <maxcolors> }
- + { nocb | cbdefault | cbuser }
- + { cbvertical | set cbhorizontal }
- + { cbat <user position --- not implemented> }
- + { cbsize <user size --- not implemented> }
- + }
- + show palette
- + show palette palette <n>
- +
- + `set palette` (i.e. without options) sets up the default values.
- + Otherwise, the options can be given in any order. `show palette` shows the
- + current palette properties. `show palette palette <n>` shows RGB triplets for
- + the current settings and a palette having <n> discrete colours.
- +
- + The following options determine the colouring properties.
- +
- + Figure using this palette can be `gray` or `color`. For instance, in `pm3d`
- + the gray is obtained by mapping the averaged z coordinate of the 4 corners of
- + the quadrangle into the range [min_z,max_z] providing range of grays [0:1].
- + This value can be used directly as the gray for gray maps. The colour map
- + requires a transformation gray->(R,G,B), i.e. a mapping
- + [0:1]->([0:1],[0:1],[0:1]). Therefore three suitable mapping functions have to
- + be chosen. This is done via `rgbformulae <r>,<g>,<b>`. The available mapping
- + functions are listed by `show palette`. Default is `7,5,15`, some other
- + examples are `3,11,6`, `21,23,3` or `3,23,21`. Negative numbers, like
- + `3,-11,-6`, mean inverted color (i.e. 1-gray passed into the formula, see also
- + `positive` and `negative` options below).
- +
- + Some nice schemes:
- + 7,5,15 ... traditional pm3d (black-blue-red-yellow)
- + 3,11,6 ... green-red-violet
- + 23,28,3 ... ocean (green-blue-white); try also all other permutations
- + 21,22,23 ... hot (black-red-yellow-white)
- + 30,31,32 ... color printable on gray (black-blue-violet-yellow-white)
- +
- + Use `positive` and `negative` to invert the figure colours.
- +
- + In order to reduce the size of postscript files, the gray value is written
- + there and not all three calculated r,g,b values. Therefore the analytical
- + formulae are coded in postscript in a header before the pm3d draw therein
- + (see /g and /cF definitions). Usually, it makes sense to write down
- + definitions of only those 3 formulae chosen. But in the case of multiplot or
- + some other reasons you may want to manually edit the transformations directly
- + in the postscript file. Then you may enjoy the option `ps_allcF` which
- + writes down definitions of all formulae. It was like that I have got the
- + Rosenbrock multiplot figure on my gnuplot.html#pm3d demo page. The default
- + is `nops_allcF`.
- + If a postscript file has been produced for grided (or mostly regular) data,
- + then it is possible to reduce the size of that postscript file up to at about
- + 50% by the enclosed awk script `pm3dCompress.awk`. This you may find
- + interesting if you intend to keep the file for including it into your
- + publication or before downloading a very large file into a slow printer. Usage:
- + `awk -f pm3dCompress.awk thefile.ps >smallerfile.ps`.
- +
- + Other (non-postscript) terminals have discrete number of colours. All entries
- + of the palette remaining after linetype colours declaration are allocated by
- + default. Then multiplot will fail since no more colour positions are available
- + (aha, that's also because sharing same palette is not implemented! todo?!).
- + Then use `set palette maxcolors <maxcolors>` with a reasonably small value.
- + Default is 0 for allocating all remaining entries.
- +
- + PROPOSAL for future: list of palettes, like it is currently for labels, arrows
- + etc. Proposed usage: `set pm3d palette <n>`, `set contour ... filled palette
- + <n>`, etc.
- +
- +
- + *** Color box properties ***
- +
- + The colour scheme, i.e. the gradient of the smooth colour with min_z and max_z
- + values of pm3d, is drawn in a colour box unless `nocb`. Its position can be
- + `cbdefault` or `cbuser`. The latter is not implemented, see `cbat` and
- + `cbsize`.
- +
- + `cbvertical` and `cbhorizontal` switches the orientation of the colour
- + gradient.
- +
- + `cbat <position>` and `cbsize <size>` are planned for positioning and sizing
- + of the colour box. Their parameters should be `coordvals` similarly to `set
- + label at` or `set arrow from to`. This feature waits for someone to implement
- + it...
- +
- 3 pointsize
- ?commands set pointsize
- ?commands show pointsize
- diff -uwr gnuplot-3.7.0.8/src/gnuplot.opt gnuplot-pm3d/src/gnuplot.opt
- --- gnuplot-3.7.0.8/src/gnuplot.opt Sun May 30 18:10:48 1999
- +++ gnuplot-pm3d/src/gnuplot.opt Mon Jun 14 09:30:38 1999
- @@ -1,6 +1,7 @@
- alloc
- binary
- bitmap
- +color
- command
- contour
- datafile
- @@ -18,6 +19,7 @@
- plot
- plot2d
- plot3d
- +pm3d
- scanner
- set
- show
- diff -uwr gnuplot-3.7.0.8/src/graph3d.c gnuplot-pm3d/src/graph3d.c
- --- gnuplot-3.7.0.8/src/graph3d.c Fri Jun 11 19:53:14 1999
- +++ gnuplot-pm3d/src/graph3d.c Wed Jul 21 17:24:08 1999
- @@ -52,6 +52,9 @@
-
- #include "plot.h"
- #include "setshow.h"
- +#ifdef PM3D
- +#include "pm3d.h"
- +#endif
-
- static int p_height;
- static int p_width; /* pointsize * t->h_tic */
- @@ -116,7 +119,6 @@
- static void key_sample_point __PROTO((int xl, int yl, int pointtype));
- static void key_text __PROTO((int xl, int yl, char *text));
-
- -
- #if defined(sun386) || defined(AMIGA_SC_6_1)
- static double CheckLog __PROTO((TBOOLEAN is_log, double base_log, double x));
- #endif
- @@ -582,6 +584,49 @@
-
- term_apply_lp_properties(&border_lp); /* border linetype */
-
- +#ifdef PM3D
- + /* DRAW PM3D COLOUR MAPS */
- + if (pm3d.where[0] && /* is pm3d plot requested? */
- + set_pm3d_zminmax() && /* set and test z-range */
- + !make_palette() /* (can) make palette of smooth colours */
- + ) {
- + int i = 0;
- + extern FILE *gpoutfile;
- + if (!strcmp(term->name,"postscript") || !strcmp(term->name,"pstex"))
- + fprintf(gpoutfile,"%%pm3d_map_begin\n"); /* for pm3dCompress.awk */
- + for ( ; pm3d.where[i]; i++ ) {
- + this_plot = plots;
- + for (surface = 0;
- + surface < pcount;
- + this_plot = this_plot->next_sp, surface++)
- + pm3d_plot(this_plot,pm3d.where[i]);
- + }
- +
- + if (strchr(pm3d.where,'C') != NULL)
- + /* !!!!! CONTOURS, UNDOCUMENTED
- + !!!!! LATER CHANGE TO STH LIKE (if_filled_contours_requested)
- + !!!!! ... */
- + for (this_plot = plots; this_plot; this_plot = this_plot->next_sp) {
- + if (draw_contour & CONTOUR_SRF)
- + filled_color_contour_plot ( this_plot, CONTOUR_SRF );
- + if (draw_contour & CONTOUR_BASE)
- + filled_color_contour_plot ( this_plot, CONTOUR_BASE );
- + }
- +
- + if (!strcmp(term->name,"postscript") || !strcmp(term->name,"pstex"))
- + fprintf(gpoutfile,"%%pm3d_map_end\n"); /* for pm3dCompress.awk */
- +
- + /* draw colour box */
- + draw_color_smooth_box();
- +
- + /* release the palette we have made use of (some terminals may need this)
- + ...no, remove this, also remove it from plot.h !!!!
- + */
- + if (term->previous_palette)
- + term->previous_palette();
- + }
- +#endif
- +
- /* PLACE TITLE */
- if (*title.text != 0) {
- safe_strncpy(ss, title.text, sizeof(ss));
- @@ -736,6 +781,7 @@
- (*t->move) (xl - key_size_left, yt - (ktitle_lines) * t->v_char);
- (*t->vector) (xl + key_size_right, yt - (ktitle_lines) * t->v_char);
- }
- +
- /* DRAW SURFACES AND CONTOURS */
-
- #ifndef LITE
- @@ -1057,7 +1103,6 @@
- hidden_active = FALSE;
- }
- #endif /* not LITE */
- -
- }
-
- /* plot3d_impulses:
- @@ -1542,7 +1587,12 @@
- if (draw_border & 8)
- draw_clip_line(br_x, br_y, bb_x, bb_y);
-
- +#ifndef PM3D
- if (draw_surface || (draw_contour & CONTOUR_SRF)) {
- +#else
- + if (draw_surface || (draw_contour & CONTOUR_SRF) ||
- + strpbrk(pm3d.where,"st") != NULL) {
- +#endif
- int save = hidden_active;
- /* map the 8 corners to screen */
- unsigned int fl_x, fl_y; /* floor left */
- @@ -1722,7 +1772,12 @@
- }
- /* do z tics */
-
- +#ifndef PM3D
- if (ztics && (draw_surface || (draw_contour & CONTOUR_SRF))) {
- +#else
- + if (ztics && (draw_surface || (draw_contour & CONTOUR_SRF) ||
- + strchr(pm3d.where,'s') != NULL)) {
- +#endif
- gen_tics(FIRST_Z_AXIS, &zticdef, work_grid.l_type & (GRID_Z | GRID_MZ),
- mztics, mztfreq, ztick_callback);
- }
- @@ -1741,7 +1796,12 @@
- draw_clip_line(x, y, x1, y1);
- }
- /* PLACE ZLABEL - along the middle grid Z axis - eh ? */
- +#ifndef PM3D
- if (*zlabel.text && (draw_surface || (draw_contour & CONTOUR_SRF))) {
- +#else
- + if (*zlabel.text && (draw_surface || (draw_contour & CONTOUR_SRF) ||
- + strpbrk(pm3d.where,"st") != NULL)) {
- +#endif
- map3d_xy(zaxis_x, zaxis_y, z_max3d + (z_max3d - base_z) / 4, &x, &y);
-
- x += zlabel.xoffset * t->h_char;
- diff -uwr gnuplot-3.7.0.8/src/graphics.c gnuplot-pm3d/src/graphics.c
- --- gnuplot-3.7.0.8/src/graphics.c Fri Jun 11 19:53:14 1999
- +++ gnuplot-pm3d/src/graphics.c Mon Jun 14 09:43:30 1999
- @@ -151,8 +151,6 @@
- unsigned int *y, char *what));
- static void mant_exp __PROTO((double log_base, double x, int scientific,
- double *m, int *p));
- -static void gprintf __PROTO((char *dest, size_t count, char *format,
- - double log_base, double x));
-
- #if defined(sun386) || defined(AMIGA_SC_6_1)
- static double CheckLog __PROTO((TBOOLEAN is_log, double base_log, double x));
- @@ -4067,7 +4065,7 @@
-
- /*{{{ gprintf */
- /* extended snprintf */
- -static void
- +void
- gprintf(dest, count, format, log_base, x)
- char *dest, *format;
- size_t count;
- diff -uwr gnuplot-3.7.0.8/src/makefile.all gnuplot-pm3d/src/makefile.all
- --- gnuplot-3.7.0.8/src/makefile.all Thu May 27 21:55:24 1999
- +++ gnuplot-pm3d/src/makefile.all Mon Jun 14 09:30:38 1999
- @@ -1,10 +1,10 @@
- # makefile.all generated automatically by GNU make
-
- # List of core object files except version.$(O)
- -COREOBJS = alloc.$(O) binary.$(O) bitmap.$(O) command.$(O) contour.$(O) \
- +COREOBJS = alloc.$(O) binary.$(O) bitmap.$(O) color.$(O) command.$(O) contour.$(O) \
- datafile.$(O) eval.$(O) fit.$(O) graph3d.$(O) graphics.$(O) help.$(O) \
- hidden3d.$(O) internal.$(O) interpol.$(O) matrix.$(O) misc.$(O) parse.$(O) \
- -plot.$(O) plot2d.$(O) plot3d.$(O) readline.$(O) scanner.$(O) set.$(O) \
- +plot.$(O) plot2d.$(O) plot3d.$(O) pm3d.$(O) readline.$(O) scanner.$(O) set.$(O) \
- show.$(O) specfun.$(O) standard.$(O) stdfn.$(O) term.$(O) time.$(O) \
- util.$(O) util3d.$(O) variable.$(O)
-
- diff -uwr gnuplot-3.7.0.8/src/Makefile.in gnuplot-pm3d/src/Makefile.in
- --- gnuplot-3.7.0.8/src/Makefile.in Sat Jun 12 17:45:58 1999
- +++ gnuplot-pm3d/src/Makefile.in Mon Jun 14 09:30:38 1999
- @@ -95,7 +95,7 @@
- XLIBS = @LIBRARIES_FOR_X@
- AM_CPPFLAGS = -I../term -I$(top_srcdir)/term -DBINDIR=\"$(bindir)\" -DCONTACT=\"$(EMAIL)\" -DHELPFILE=\"$(HELPFILE)\"
-
- -gnuplot_SOURCES = alloc.c alloc.h ansichek.h binary.c binary.h bitmap.c bitmap.h command.c command.h contour.c datafile.c eval.c fit.c fit.h graph3d.c graphics.c graphics.h help.c help.h hidden3d.c internal.c interpol.c matrix.c matrix.h misc.c national.h parse.c plot.c plot.h plot2d.c plot3d.c protos.h readline.c scanner.c set.c setshow.h show.c specfun.c standard.c stdfn.c stdfn.h syscfg.h term.c term.h time.c util.c util3d.c variable.c variable.h version.c
- +gnuplot_SOURCES = alloc.c alloc.h ansichek.h binary.c binary.h bitmap.c bitmap.h color.c command.c command.h contour.c datafile.c eval.c fit.c fit.h graph3d.c graphics.c graphics.h help.c help.h hidden3d.c internal.c interpol.c matrix.c matrix.h misc.c national.h parse.c plot.c plot.h plot2d.c plot3d.c pm3d.c protos.h readline.c scanner.c set.c setshow.h show.c specfun.c standard.c stdfn.c stdfn.h syscfg.h term.c term.h time.c util.c util3d.c variable.c variable.h version.c
-
-
- EXTRA_gnuplot_SOURCES = @NEXTOBJS@
- @@ -120,7 +120,7 @@
- O = o
- T = $(top_srcdir)/term/
-
- -COREOBJS = alloc.$(O) binary.$(O) bitmap.$(O) command.$(O) contour.$(O) datafile.$(O) eval.$(O) fit.$(O) graph3d.$(O) graphics.$(O) help.$(O) hidden3d.$(O) internal.$(O) interpol.$(O) matrix.$(O) misc.$(O) parse.$(O) plot.$(O) plot2d.$(O) plot3d.$(O) readline.$(O) scanner.$(O) set.$(O) show.$(O) specfun.$(O) standard.$(O) stdfn.$(O) term.$(O) time.$(O) util.$(O) util3d.$(O) variable.$(O)
- +COREOBJS = alloc.$(O) binary.$(O) bitmap.$(O) color.$(O) command.$(O) contour.$(O) datafile.$(O) eval.$(O) fit.$(O) graph3d.$(O) graphics.$(O) help.$(O) hidden3d.$(O) internal.$(O) interpol.$(O) matrix.$(O) misc.$(O) parse.$(O) plot.$(O) plot2d.$(O) plot3d.$(O) pm3d.$(O) readline.$(O) scanner.$(O) set.$(O) show.$(O) specfun.$(O) standard.$(O) stdfn.$(O) term.$(O) time.$(O) util.$(O) util3d.$(O) variable.$(O)
-
-
- # List of terminal driver sources
- @@ -132,7 +132,7 @@
- PROGRAMS = $(bin_PROGRAMS)
-
-
- -DEFS = @DEFS@ -I. -I$(srcdir) -I..
- +DEFS = @DEFS@ -I. -I$(srcdir) -I.. -DPM3D=1
- CPPFLAGS = @CPPFLAGS@
- LDFLAGS = @LDFLAGS@
- LIBS = @LIBS@
- @@ -144,10 +144,10 @@
- gnuplot_x11_OBJECTS = gplt_x11$U.o stdfn$U.o
- gnuplot_x11_DEPENDENCIES =
- gnuplot_x11_LDFLAGS =
- -gnuplot_OBJECTS = alloc$U.o binary$U.o bitmap$U.o command$U.o \
- +gnuplot_OBJECTS = alloc$U.o binary$U.o bitmap$U.o color$U.o command$U.o \
- contour$U.o datafile$U.o eval$U.o fit$U.o graph3d$U.o graphics$U.o \
- help$U.o hidden3d$U.o internal$U.o interpol$U.o matrix$U.o misc$U.o \
- -parse$U.o plot$U.o plot2d$U.o plot3d$U.o readline$U.o scanner$U.o \
- +parse$U.o plot$U.o plot2d$U.o plot3d$U.o pm3d$U.o readline$U.o scanner$U.o \
- set$U.o show$U.o specfun$U.o standard$U.o stdfn$U.o term$U.o time$U.o \
- util$U.o util3d$U.o variable$U.o version$U.o
- gnuplot_DEPENDENCIES =
- @@ -267,6 +267,8 @@
- $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/binary.c; then echo $(srcdir)/binary.c; else echo binary.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > binary_.c
- bitmap_.c: bitmap.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/bitmap.c; then echo $(srcdir)/bitmap.c; else echo bitmap.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > bitmap_.c
- +color_.c: color.c $(ANSI2KNR)
- + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/color.c; then echo $(srcdir)/color.c; else echo color.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > color_.c
- command_.c: command.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/command.c; then echo $(srcdir)/command.c; else echo command.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > command_.c
- contour_.c: contour.c $(ANSI2KNR)
- @@ -303,6 +305,8 @@
- $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/plot2d.c; then echo $(srcdir)/plot2d.c; else echo plot2d.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > plot2d_.c
- plot3d_.c: plot3d.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/plot3d.c; then echo $(srcdir)/plot3d.c; else echo plot3d.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > plot3d_.c
- +pm3d_.c: pm3d.c $(ANSI2KNR)
- + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/pm3d.c; then echo $(srcdir)/pm3d.c; else echo pm3d.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > pm3d_.c
- readline_.c: readline.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/readline.c; then echo $(srcdir)/readline.c; else echo readline.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > readline_.c
- scanner_.c: scanner.c $(ANSI2KNR)
- @@ -329,10 +333,10 @@
- $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/variable.c; then echo $(srcdir)/variable.c; else echo variable.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > variable_.c
- version_.c: version.c $(ANSI2KNR)
- $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/version.c; then echo $(srcdir)/version.c; else echo version.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > version_.c
- -alloc_.o bf_test_.o binary_.o bitmap_.o command_.o contour_.o \
- +alloc_.o bf_test_.o binary_.o bitmap_.o color_o.c command_.o contour_.o \
- datafile_.o eval_.o fit_.o gplt_x11_.o graph3d_.o graphics_.o help_.o \
- hidden3d_.o internal_.o interpol_.o matrix_.o misc_.o parse_.o plot_.o \
- -plot2d_.o plot3d_.o readline_.o scanner_.o set_.o show_.o specfun_.o \
- +plot2d_.o plot3d_.o pm3d_.o readline_.o scanner_.o set_.o show_.o specfun_.o \
- standard_.o stdfn_.o term_.o time_.o util_.o util3d_.o variable_.o \
- version_.o : $(ANSI2KNR)
-
- diff -uwr gnuplot-3.7.0.8/src/os2/gclient.c gnuplot-pm3d/src/os2/gclient.c
- --- gnuplot-3.7.0.8/src/os2/gclient.c Tue Jun 15 15:32:14 1999
- +++ gnuplot-pm3d/src/os2/gclient.c Mon Jun 14 09:30:38 1999
- @@ -1660,7 +1660,11 @@
- HPS hps ;
- HAB hab ;
- int linewidth = DEFLW ;
- -
- +#ifdef PM3D
- + HPAL pm3d_hpal = 0; // palette used for make_palette()
- + HPAL pm3d_hpal_old = 0; // default palette used before make_palette()
- + LONG pm3d_color = 0; // current colour
- +#endif
- hab = WinInitialize( 0 ) ;
- DosEnterCritSec() ;
- pszPipeName = malloc( 256 ) ;
- @@ -2076,6 +2080,88 @@
- //PM notification of being connected to a mouse-enabled terminal
- mouseTerminal = 1;
- break ;
- +
- +#ifdef PM3D
- + case 'p': { // GR_MAKE_PALETTE
- +/* Implementation problems (I haven't understood that from .INF doc):
- +what is the difference between GpiCreateLogColorTable and
- +GpiCreatePalette?
- +
- +Bugs: and why
- +*/
- + char c;
- + int i;
- + const int nColors = 16;
- + LONG lRetCount;
- + /* must be equal to that from InitScreenPS() and
- + must be synchronized with:
- + * the value in pm.trm: PM_make_palette (otherwise
- + this values would have to be piped there, but
- + nowadays exactly 16 is used
- + * with the offset SetColor in GR_FILLED_POLYGON
- + */
- + ULONG rgbTable[256];
- + /* read switch */
- + BufRead(hRead, &c, sizeof(c), &cbR);
- + if (c == 0) {
- + // gnuplot asks for the number of colours in palette
- + i = 256 - nColors;
- + DosWrite( hRead, &i, sizeof(int), &cbR ) ;
- + break;
- + }
- + /* retrieve the current table */
- + lRetCount = GpiQueryLogColorTable(hps, 0L, 0L, nColors, alColourTable);
- +//{FILE *ff; ff=fopen("deb","a");
- +//fprintf(ff,"lret=%li ncol=%li\n",lRetCount,nColors);fclose(ff);}
- + if (lRetCount>0 && lRetCount!=nColors) // ring for developers!
- + DosBeep(880,777);
- + for (i=0; i<nColors; i++)
- + rgbTable[i] = alColourTable[i];
- + /* append new RGB table after */
- + BufRead(hRead, &rgbTable[nColors], (256-nColors)*sizeof(rgbTable[0]), &cbR);
- + if (pm3d_hpal != 0) GpiDeletePalette( pm3d_hpal );
- + pm3d_hpal = GpiCreatePalette(hab,0L,LCOLF_CONSECRGB, 256L, rgbTable);
- + pm3d_hpal_old = GpiSelectPalette( hps, pm3d_hpal );
- + }
- + break ;
- + case 'e': // GR_RELEASE_PALETTE
- +#if 0 // REMOVE THIS ROUTINE COMPLETELY!
- + if (pm3d_hpal) {
- + GpiDeletePalette( pm3d_hpal );
- + pm3d_hpal = 0;
- + }
- +// GpiSelectPalette( hps, pm3d_hpal_old );
- +#endif
- + break ;
- + case 'c': { // GR_SET_COLOR
- + unsigned char c;
- + BufRead(hRead,&c, 1, &cbR) ;
- + pm3d_color = c;
- + }
- + break ;
- + case 'f': { // GR_FILLED_POLYGON
- + int points, x,y, i;
- + POINTL p;
- + BufRead(hRead,&points, sizeof(points), &cbR) ;
- + // GpiSetPattern(hps,PATSYM_SOLID);
- + // GpiSetBackMix(hps,BM_OVERPAINT);
- + GpiSetColor( hps, pm3d_color);
- + // using colours defined in the palette
- +// FILE *ff;ff=fopen("deb","a");
- +//fprintf(ff,"f --- GpiSetColor %li\n",pm3d_color); fclose(ff);}
- + GpiBeginArea( hps, BA_BOUNDARY | BA_ALTERNATE);
- + for (i = 0; i < points; i++) {
- + BufRead(hRead,&x, sizeof(x), &cbR) ;
- + BufRead(hRead,&y, sizeof(y), &cbR) ;
- + p.x = x; p.y = y;
- + if (i) GpiLine( hps, &p );
- + else GpiMove( hps, &p );
- + }
- + GpiEndArea(hps);
- + }
- + break ;
- +
- +#endif //PM3D
-
- default : /* should handle error */
- break ;
- diff -uwr gnuplot-3.7.0.8/src/plot.h gnuplot-pm3d/src/plot.h
- --- gnuplot-3.7.0.8/src/plot.h Fri Jun 11 19:53:16 1999
- +++ gnuplot-pm3d/src/plot.h Mon Jun 14 17:16:14 1999
- @@ -615,6 +615,11 @@
- struct iso_curve *iso_crvs;
- };
-
- +#ifdef PM3D
- +/* color.h is included here, since it requires the definition of `coordinate' */
- +#include "color.h"
- +#endif
- +
- /* It should go without saying that additional entries may be made
- * only at the end of this structure. Any fields added must be
- * optional - a value of 0 (or NULL pointer) means an older driver
- @@ -664,6 +669,33 @@
- void (*resume) __PROTO((void)); /* called before plots of multiplot */
- void (*fillbox) __PROTO((int, unsigned int, unsigned int, unsigned int, unsigned int)); /* clear in multiplot mode */
- void (*linewidth) __PROTO((double linewidth));
- +#ifdef PM3D
- + int (*make_palette) __PROTO((t_sm_palette *palette));
- + /* 1. if palette==NULL, then return nice/suitable
- + maximal number of colours supported by this terminal.
- + Returns 0 if it can make colours without palette (like
- + postscript).
- + 2. if palette!=NULL, then allocate its own palette
- + return value is undefined
- + 3. available: some negative values of max_colors for whatever
- + can be useful
- + */
- + void (*previous_palette) __PROTO((void));
- + /* release the palette that the above routine allocated and get
- + back the palette that was active before.
- + Some terminals, like displays, may draw parts of the figure
- + using their own palette. Those terminals that possess only
- + one palette for the whole plot don't need this routine.
- + */
- +
- + void (*set_color) __PROTO((double gray));
- + /* gray is from [0;1], terminal uses its palette or another way
- + to transform in into gray or r,g,b
- + This routine (for each terminal separately) remembers or not
- + this colour so that it can apply it for the subsequent drawings
- + */
- + void (*filled_polygon) __PROTO((int points, gpiPoint *corners));
- +#endif
- };
-
- #ifdef WIN16
- diff -uwr gnuplot-3.7.0.8/src/protos.h gnuplot-pm3d/src/protos.h
- --- gnuplot-3.7.0.8/src/protos.h Fri Jun 11 19:55:08 1999
- +++ gnuplot-pm3d/src/protos.h Mon Jun 14 09:30:38 1999
- @@ -102,6 +102,7 @@
- typedef void (*tic_callback) __PROTO((int axis, double place, char *text, struct lp_style_type grid));
- void gen_tics __PROTO((int axis, struct ticdef *def, int grid, int minitic, double minifreq, tic_callback callback));
- void write_multiline __PROTO((unsigned int x, unsigned int y, char *text_will_be_mangled, enum JUSTIFY hor, int vert, int angle, char *font));
- +void gprintf __PROTO((char *dest, size_t count, char *format, double log_base, double x));
-
- /* Prototypes from file "graph3d.c" */
-
- diff -uwr gnuplot-3.7.0.8/src/set.c gnuplot-pm3d/src/set.c
- --- gnuplot-3.7.0.8/src/set.c Fri Jun 11 19:53:16 1999
- +++ gnuplot-pm3d/src/set.c Tue Jun 15 14:34:42 1999
- @@ -46,6 +46,9 @@
- #include "setshow.h"
- #include "national.h"
- #include "alloc.h"
- +#ifdef PM3D
- +#include "pm3d.h"
- +#endif
-
- #define DEF_FORMAT "%g" /* default format for tic mark labels */
- #define SIGNIF (0.01) /* less than one hundredth of a tic mark */
- @@ -571,6 +574,10 @@
- pointsize = 1.0;
- encoding = ENCODING_DEFAULT;
-
- + #ifdef PM3D
- + pm3d.where[0] = 0;
- + #endif
- +
- set_locale("C"); /* default */
- clear_loadpath();
-
- @@ -759,6 +766,220 @@
- int_error(c_token, "expecting 'base', 'surface', or 'both'");
- c_token++;
- }
- +#ifdef PM3D
- + } else if (equals(c_token,"nopm3d")) {
- + pm3d.where[0] = 0;
- + c_token++;
- + } else if (equals(c_token,"pm3d")) {
- + char *c = pm3d.where;
- + c_token++;
- + if (END_OF_COMMAND) { /* assume default settings */
- + strcpy(pm3d.where,"b"); /* draw at bottom (map) */
- + pm3d.direction = PM3D_SCANS_FORWARD;
- + pm3d.flush = PM3D_FLUSH_BEGIN;
- + pm3d.clip = PM3D_CLIP_1IN;
- + pm3d.pm3d_zmin = 0; pm3d.pm3d_zmax = 0;
- + pm3d.zmin = 0; pm3d.zmax = 100;
- + }
- + else { /* go through all options of 'set pm3d' */
- + for ( ; !END_OF_COMMAND && !equals(c_token,";"); c_token++ ) {
- + if (equals(c_token, "at")) {
- + c_token++;
- + if (token[c_token].length >= sizeof(pm3d.where)) {
- + int_error(c_token,"ignoring so many redrawings");
- + return (TRUE);
- + }
- + strncpy(pm3d.where, input_line + token[c_token].start_index, token[c_token].length);
- + pm3d.where[ token[c_token].length ] = 0;
- + while (*c) {
- + if (*c != 'C') /* !!!!! CONTOURS, UNDOCUMENTED, THIS LINE IS TEMPORARILY HERE !!!!! */
- + if (*c != PM3D_AT_BASE && *c != PM3D_AT_TOP && *c != PM3D_AT_SURFACE) {
- + int_error(c_token,"parameter to pm3d requires combination of characters b,s,t\n\t(drawing at bottom, surface, top)");
- + return (TRUE);
- + }
- + c++;
- + }
- + continue;
- + } /* at */
- + /* forward and backward drawing direction */
- + if (almost_equals(c_token, "scansfor$ward")) {
- + pm3d.direction = PM3D_SCANS_FORWARD;
- + continue;
- + }
- + if (almost_equals(c_token, "scansback$ward")) {
- + pm3d.direction = PM3D_SCANS_BACKWARD;
- + continue;
- + }
- + /* flush scans: left, right or center */
- + if (almost_equals(c_token, "fl$ush")) {
- + c_token++;
- + if (almost_equals(c_token, "b$egin"))
- + pm3d.flush = PM3D_FLUSH_BEGIN;
- + else if (almost_equals(c_token, "c$enter"))
- + pm3d.flush = PM3D_FLUSH_CENTER;
- + else if (almost_equals(c_token, "e$nd"))
- + pm3d.flush = PM3D_FLUSH_END;
- + else int_error(c_token,"expecting flush 'begin', 'center' or 'end'");
- + continue;
- + }
- + /* clipping method */
- + if (almost_equals(c_token, "clip1$in")) {
- + pm3d.clip = PM3D_CLIP_1IN;
- + continue;
- + }
- + if (almost_equals(c_token, "clip4$in")) {
- + pm3d.clip = PM3D_CLIP_4IN;
- + continue;
- + }
- + /* zrange [{zmin|*}:{zmax|*}] */
- + /* Note: here, we cannot use neither PROCESS_RANGE or load_range */
- + if (almost_equals(c_token, "zr$ange")) {
- + struct value a;
- + if (!equals(++c_token,"[")) int_error(c_token,"expecting '['");
- + c_token++;
- + if (!equals(c_token,":")) { /* no change for zmin */
- + if (equals(c_token,"*")) {
- + pm3d.pm3d_zmin = 0; /* from gnuplot's set zrange */
- + c_token++;
- + }
- + else {
- + pm3d.pm3d_zmin = 1; /* use pm3d's zmin */
- + pm3d.zmin = real(const_express(&a)); /* explicit value given */
- + }
- + }
- + if (!equals(c_token,":")) int_error(c_token,"expecting ':'");
- + c_token++;
- + if (!equals(c_token,"]")) { /* no change for zmax */
- + if (equals(c_token,"*")) {
- + pm3d.pm3d_zmax = 0; /* from gnuplot's set zrange */
- + c_token++;
- + }
- + else {
- + pm3d.pm3d_zmax = 1; /* use pm3d's zmin */
- + pm3d.zmax = real(const_express(&a)); /* explicit value given */
- + }
- + }
- + if (!equals(c_token,"]")) int_error(c_token,"expecting ']'");
- + continue;
- + }
- + /* setup everything for plotting a map */
- + if (equals(c_token, "map")) {
- + pm3d.where[0] = 'b'; pm3d.where[1] = 0; /* set pm3d at b */
- + draw_surface = FALSE; /* set nosurface */
- + draw_contour = CONTOUR_NONE; /* set nocontour */
- + surface_rot_x = 180; /* set view 180,0,1.3 */
- + surface_rot_z = 0;
- + surface_scale = 1.3;
- + range_flags[FIRST_Y_AXIS] |= RANGE_REVERSE; /* set yrange reverse */
- + continue;
- + }
- + int_error(c_token,"invalid pm3d option");
- + } /* end of while over pm3d options */
- + }
- + } else if (almost_equals(c_token,"pal$ette")) {
- + c_token++;
- + if (END_OF_COMMAND) { /* assume default settings */
- + sm_palette.colorMode = SMPAL_COLOR_MODE_RGB;
- + sm_palette.formulaR = 7; sm_palette.formulaG = 5;
- + sm_palette.formulaB = 15;
- + sm_palette.positive = SMPAL_POSITIVE;
- + sm_palette.ps_allcF = 0;
- + sm_palette.use_maxcolors = 0;
- +
- + color_box.where = SMCOLOR_BOX_DEFAULT;
- + color_box.rotation = 'v';
- + }
- + else { /* go through all options of 'set palette' */
- + for ( ; !END_OF_COMMAND && !equals(c_token,";"); c_token++ ) {
- + /* positive and negative picture */
- + if (almost_equals(c_token, "pos$itive")) {
- + sm_palette.positive = SMPAL_POSITIVE;
- + continue;
- + }
- + if (almost_equals(c_token, "neg$ative")) {
- + sm_palette.positive = SMPAL_NEGATIVE;
- + continue;
- + }
- + /* Now the options that determine the palette of smooth colours */
- + /* gray or rgb-coloured */
- + if (equals(c_token, "gray")) {
- + sm_palette.colorMode = SMPAL_COLOR_MODE_GRAY;
- + continue;
- + }
- + if (almost_equals(c_token, "col$or")) {
- + sm_palette.colorMode = SMPAL_COLOR_MODE_RGB;
- + continue;
- + }
- + /* rgb color mapping formulae: rgb$formulae r,g,b (three integers) */
- + if (almost_equals(c_token, "rgb$formulae")) {
- + struct value a;
- + int i;
- + c_token++;
- + i = (int)real(const_express(&a));
- + if ( abs(i) >= sm_palette.colorFormulae )
- + int_error(c_token,"color formula out of range (use `show pm3d' to display the range)");
- + sm_palette.formulaR = i;
- + if (!equals(c_token,",")) { c_token--; continue; }
- + c_token++;
- + i = (int)real(const_express(&a));
- + if ( abs(i) >= sm_palette.colorFormulae )
- + int_error(c_token,"color formula out of range (use `show pm3d' to display the range)");
- + sm_palette.formulaG = i;
- + if (!equals(c_token,",")) { c_token--; continue; }
- + c_token++;
- + i = (int)real(const_express(&a));
- + if ( abs(i) >= sm_palette.colorFormulae )
- + int_error(c_token,"color formula out of range (`show pm3d' displays the range)");
- + sm_palette.formulaB = i;
- + c_token--;
- + continue;
- + } /* rgbformulae */
- + /* ps_allcF: write all rgb formulae into PS file? */
- + if (equals(c_token, "nops_allcF")) {
- + sm_palette.ps_allcF = 0;
- + continue;
- + }
- + if (equals(c_token, "ps_allcF")) {
- + sm_palette.ps_allcF = 1;
- + continue;
- + }
- + /* max colors used */
- + if (almost_equals(c_token, "maxc$olors")) {
- + struct value a;
- + int i;
- + c_token++;
- + i = (int)real(const_express(&a));
- + if (i<0) int_error(c_token,"non-negative number required");
- + sm_palette.use_maxcolors = i;
- + continue;
- + }
- + /* Now color box properties */
- + /* vertical or horizontal color gradient */
- + if (almost_equals(c_token, "cbv$ertical")) {
- + color_box.rotation = 'v';
- + continue;
- + }
- + if (almost_equals(c_token, "cbh$orizontal")) {
- + color_box.rotation = 'h';
- + continue;
- + }
- + /* color box where: no box, default position, position by user */
- + if (equals(c_token, "nocb")) {
- + color_box.where = SMCOLOR_BOX_NO;
- + continue;
- + }
- + if (almost_equals(c_token, "cbdef$ault")) {
- + color_box.where = SMCOLOR_BOX_DEFAULT;
- + continue;
- + }
- + if (almost_equals(c_token, "cbuser")) {
- + color_box.where = SMCOLOR_BOX_USER;
- + continue;
- + }
- + int_error(c_token,"invalid palette option");
- + } /* end of while over palette options */
- + }
- +#endif
- } else if (almost_equals(c_token,"noco$ntour")) {
- c_token++;
- draw_contour = CONTOUR_NONE;
- diff -uwr gnuplot-3.7.0.8/src/setshow.h gnuplot-pm3d/src/setshow.h
- --- gnuplot-3.7.0.8/src/setshow.h Fri Jun 11 19:53:16 1999
- +++ gnuplot-pm3d/src/setshow.h Mon Jun 14 09:30:38 1999
- @@ -264,7 +264,7 @@
- \t'dummy', 'encoding', 'format', 'function', 'grid', 'hidden',\n\
- \t'isosamples', 'key', 'label', 'linestyle', 'loadpath', 'locale',\n\
- \t'logscale', 'mapping', 'margin', 'missing', 'offsets', 'origin',\n\
- -\t'output', 'plot', 'parametric', 'pointsize', 'polar', '[rtuv]range',\n\
- +\t'output', 'plot', 'parametric', 'pm3d', 'pointsize', 'polar', '[rtuv]range',\n\
- \t'samples', 'size', 'terminal', 'tics', 'timestamp', 'timefmt', 'title',\n\
- \t'variables', 'version', 'view', '[xyz]{2}label', '[xyz]{2}range',\n\
- \t'{m}[xyz]{2}tics', '[xyz]{2}[md]tics', '[xyz]{2}zeroaxis',\n\
- diff -uwr gnuplot-3.7.0.8/src/show.c gnuplot-pm3d/src/show.c
- --- gnuplot-3.7.0.8/src/show.c Fri Jun 11 19:54:36 1999
- +++ gnuplot-pm3d/src/show.c Tue Jun 15 14:18:02 1999
- @@ -44,6 +44,9 @@
- #include "plot.h"
- #include "command.h"
- #include "setshow.h"
- +#ifdef PM3D
- +#include "pm3d.h"
- +#endif
-
- #define DEF_FORMAT "%g" /* default format for tic mark labels */
- #define SIGNIF (0.01) /* less than one hundredth of a tic mark */
- @@ -105,6 +108,10 @@
- static void show_encoding __PROTO((void));
- static void show_polar __PROTO((void));
- static void show_parametric __PROTO((void));
- +#ifdef PM3D
- +static void show_pm3d __PROTO((void));
- +static void show_palette __PROTO((void));
- +#endif
- static void show_tics __PROTO((int showx, int showy, int showz, int showx2, int showy2));
- static void show_ticdef __PROTO((int tics, int axis, struct ticdef * tdef, char *text, int rotate_tics, char *ticfmt));
- static void show_term __PROTO((void));
- @@ -401,6 +408,16 @@
- (void) putc('\n', stderr);
- show_parametric();
- c_token++;
- +#ifdef PM3D
- + } else if (equals(c_token, "pm3d")) {
- + (void) putc('\n', stderr);
- + show_pm3d();
- + c_token++;
- + } else if (almost_equals(c_token, "pal$ette")) {
- + (void) putc('\n', stderr);
- + show_palette();
- + c_token++;
- +#endif
- } else if (almost_equals(c_token, "poi$ntsize")) {
- (void) putc('\n', stderr);
- show_pointsize();
- @@ -590,6 +607,10 @@
- show_margin();
- show_output();
- show_parametric();
- +#ifdef PM3D
- + show_pm3d();
- + show_palette();
- +#endif
- show_pointsize();
- show_encoding();
- show_polar();
- @@ -1165,6 +1186,135 @@
- fprintf(stderr, "\tparametric is %s\n", (parametric) ? "ON" : "OFF");
- }
-
- +#ifdef PM3D
- +static void show_pm3d()
- +{
- + if (!pm3d.where[0]) {
- + fprintf(stderr, "\tpm3d is OFF\n");
- + return;
- + }
- + fprintf(stderr,"\tpm3d plotted at ");
- + { int i=0;
- + for ( ; pm3d.where[i]; i++ ) {
- + if (i>0) fprintf(stderr,", then ");
- + switch (pm3d.where[i]) {
- + case PM3D_AT_BASE: fprintf(stderr,"BOTTOM"); break;
- + case PM3D_AT_SURFACE: fprintf(stderr,"SURFACE"); break;
- + case PM3D_AT_TOP: fprintf(stderr,"TOP"); break;
- + }
- + }
- + fprintf(stderr,"\n");
- + }
- + fprintf(stderr,"\ttaking scans in %s direction\n",
- + pm3d.direction == PM3D_SCANS_FORWARD ? "FORWARD" : "BACKWARD");
- + fprintf(stderr,"\tsubsequent scans with different nb of pts are ");
- + if (pm3d.flush == PM3D_FLUSH_CENTER) fprintf(stderr,"CENTERED\n");
- + else fprintf(stderr,"flushed from %s\n",
- + pm3d.flush == PM3D_FLUSH_BEGIN ? "BEGIN" : "END");
- + fprintf(stderr,"\tclipping: ");
- + if (pm3d.clip == PM3D_CLIP_1IN)
- + fprintf(stderr,"at least 1 point of the quadrangle in x,y ranges\n");
- + else
- + fprintf(stderr, "all 4 points of the quadrangle in x,y ranges\n");
- + fprintf(stderr,"\tz-range is ");
- + if (pm3d.pm3d_zmin==0 && pm3d.pm3d_zmax==0)
- + fprintf(stderr,"the same as `set zrange`\n");
- + else {
- + fprintf(stderr,"[");
- + if (pm3d.pm3d_zmin) fprintf(stderr,"%g,",pm3d.zmin);
- + else fprintf(stderr,"*,");
- + if (pm3d.pm3d_zmax) fprintf(stderr,"%g]\n",pm3d.zmax);
- + else fprintf(stderr,"*]\n");
- + }
- +}
- +
- +static void show_palette()
- +{
- + c_token++;
- + /* no option given, i.e. "show palette" */
- + if (END_OF_COMMAND) {
- + fprintf(stderr,"\tfigure is %s\n",
- + sm_palette.colorMode == SMPAL_COLOR_MODE_GRAY ? "GRAY" : "COLOR");
- + fprintf(stderr,"\trgb color mapping formulae are %i,%i,%i\n",
- + sm_palette.formulaR, sm_palette.formulaG, sm_palette.formulaB);
- + fprintf(stderr,"\t * there are %i available rgb color mapping formulae:",
- + sm_palette.colorFormulae);
- + /* take the description of the color formulae from the comment to their
- + PostScript definition */
- + {
- + extern char *( PostScriptColorFormulae[] );
- + char *s;
- + int i = 0;
- + while ( *(PostScriptColorFormulae[i]) ) {
- + if (i % 3 == 0) fprintf(stderr, "\n\t ");
- + s = strchr( PostScriptColorFormulae[ i ], '%' ) + 2;
- + fprintf(stderr, "%2i: %-15s",i,s);
- + i++;
- + }
- + fprintf(stderr, "\n");
- + }
- + fprintf(stderr,"\t * negative numbers mean inverted=negative colour component\n");
- + fprintf(stderr,"\t * thus the ranges in `set pm3d rgbformulae' are -%i..%i\n",
- + sm_palette.colorFormulae-1,sm_palette.colorFormulae-1);
- + fprintf(stderr,"\tfigure is %s\n",
- + sm_palette.positive == SMPAL_POSITIVE ? "POSITIVE" : "NEGATIVE");
- + fprintf(stderr,"\tall color formulae ARE%s written into output postscript file\n",
- + sm_palette.ps_allcF == 0 ? "" : " NOT");
- + fprintf(stderr,"\tallocating ");
- + if (sm_palette.use_maxcolors) fprintf(stderr,"MAX %i",sm_palette.use_maxcolors);
- + else fprintf(stderr,"ALL remaining");
- + fprintf(stderr," color positions for discrete palette terminals\n");
- + fprintf(stderr,"\tcolor box is ");
- + if (color_box.where == SMCOLOR_BOX_NO )
- + fprintf(stderr,"NOT drawn\n");
- + else {
- + fprintf(stderr,"drawn at %s position\n",
- + color_box.where == SMCOLOR_BOX_DEFAULT ? "DEFAULT" : "USER");
- + }
- + fprintf(stderr,"\tuser position and size is not yet implemented (you are welcome!)\n");
- + fprintf(stderr,"\tcolor gradient is %s in the color box\n",
- + color_box.rotation == 'v' ? "VERTICAL" : "HORIZONTAL");
- + return;
- + }
- + /* option: "show palette palette <n>" */
- + if (almost_equals(c_token, "pal$ette")) {
- + int colors, i;
- + struct value a;
- + double gray, r, g, b;
- + extern double GetColorValueFromFormula (int formula, double x);
- + c_token++;
- + if (END_OF_COMMAND)
- + int_error(c_token,"palette size required");
- + colors = (int) real(const_express(&a));
- + if (colors<2) colors = 100;
- + if (sm_palette.colorMode == SMPAL_COLOR_MODE_GRAY)
- + printf("Gray palette with %i discrete colors\n", colors);
- + else
- + printf("Color palette with %i discrete colors, formulae R=%i, G=%i, B=%i\n",
- + colors, sm_palette.formulaR, sm_palette.formulaG, sm_palette.formulaB);
- + for (i = 0; i < colors; i++) {
- + gray = (double)i / (colors - 1); /* colours equidistantly from [0,1] */
- + if (sm_palette.positive == SMPAL_NEGATIVE)
- + gray = 1 - gray; /* needed, since printing without call to set_color() */
- + if (sm_palette.colorMode == SMPAL_COLOR_MODE_GRAY) /* gray scale only */
- + r = g = b = gray;
- + else { /* i.e. sm_palette.colorMode == SMPAL_COLOR_MODE_RGB */
- + r = GetColorValueFromFormula(sm_palette.formulaR, gray);
- + g = GetColorValueFromFormula(sm_palette.formulaG, gray);
- + b = GetColorValueFromFormula(sm_palette.formulaB, gray);
- + }
- + printf("%3i. gray=%0.4f, (r,g,b)=(%0.4f,%0.4f,%0.4f), #%02x%02x%02x = %3i %3i %3i\n",
- + i, gray, r,g,b,
- + (int)(colors*r),(int)(colors*g),(int)(colors*b),
- + (int)(colors*r),(int)(colors*g),(int)(colors*b));
- + }
- + return;
- + }
- + /* wrong option to "show palette" */
- + int_error(c_token,"required 'show palette' or 'show palette palette <n>'");
- +}
- +#endif
- +
- static void
- show_pointsize()
- {
- @@ -1607,6 +1757,12 @@
- p, help_email,
- p, bug_email,
- p); /* empty line */
- +#ifdef PM3D
- +fprintf(fp,"\
- +%s\tCompiled with the new 'pm3d' splot mode (version " PM3D_VERSION ").\n\
- +%s\tSee `help set pm3d' for more details.\n\n",
- +p, p);
- +#endif
- }
-
- void
- diff -uwr gnuplot-3.7.0.8/term/fig.trm gnuplot-pm3d/term/fig.trm
- --- gnuplot-3.7.0.8/term/fig.trm Mon May 31 19:33:50 1999
- +++ gnuplot-pm3d/term/fig.trm Fri Jul 9 12:24:52 1999
- @@ -58,6 +58,7 @@
- * Point-count option joachim.selinger@ins.uni-stuttgart.de (JFS) Feb 9 1996
- * More options (portrait/landscape, metric/inches, size, fontsize, thickness)
- * plus symbols and depth/thickness by bernlohr@eu1.mpi-hd.mpg.de (KB) Aug 15 1996
- + * Added PM3D functionality Ian MacPhedran, April 15 1999
- */
-
- #include "driver.h"
- @@ -82,6 +83,12 @@
- TERM_PUBLIC void FIG_linewidth __PROTO((double linewidth));
- TERM_PUBLIC void FIG_reset __PROTO((void));
- TERM_PUBLIC void FIG_lpoint __PROTO((unsigned int x, unsigned int y, int number));
- +#ifdef PM3D
- +TERM_PUBLIC int FIG_make_palette (t_sm_palette *);
- +/* TERM_PUBLIC void FIG_previous_palette (void); */
- +TERM_PUBLIC void FIG_set_color (double);
- +TERM_PUBLIC void FIG_filled_polygon (int, gpiPoint *);
- +#endif
-
- #define GOT_FIG_PROTO
- #endif /* TERM_PROTO */
- @@ -177,6 +184,13 @@
- static int FIG_font_s = FIG_FONT_S;
- static int FIG_portrait = FALSE;
- static int FIG_inches = FALSE;
- +#ifdef PM3D
- +static int FIG_palette_set = FALSE; /* PM3D Palette Set ? */
- +static int FIG_palette_size = 128; /* Number of colours in palette */
- +static int FIG_palette_offst = 32; /* Offset from zero for user colours */
- +static int FIG_fill_style = 20; /* Full saturation */
- +static int FIG_fill_color; /* Current PM3D fill colour */
- +#endif /* PM3D */
-
- static void FIG_poly_clean __PROTO((enum FIG_poly_stat fig_stat));
-
- @@ -410,6 +424,10 @@
- FIG_justify_text(LEFT);
- FIG_text_angle(0);
-
- +#ifdef PM3D
- + FIG_palette_set = FALSE; /* PM3D Palette Set ? */
- +#endif /* PM3D */
- +
- FIG_line.tagged = FIG_DEFAULT;
- FIG_line.distrib = FIG_DEFAULT;
- FIG_line.type = T_POLYLINE;
- @@ -772,6 +790,100 @@
- fflush(gpoutfile);
- }
-
- +#ifdef PM3D
- +TERM_PUBLIC int FIG_make_palette(t_sm_palette *palette)
- +{
- + int i;
- +
- + /* Query to determine palette size */
- + if (palette==NULL) {
- + return(FIG_palette_size); /* How big is palette ? */
- + }
- +
- + FIG_poly_clean(FIG_polyvec_stat); /* Clean up current data */
- +
- + if (FIG_palette_set == FALSE) {
- + /* Create new palette */
- + FIG_palette_set = TRUE;
- + if ((FIG_use_color != TRUE) && (sm_palette.colorMode == SMPAL_COLOR_MODE_RGB)) { /* Force mono palette */
- + /* NOTE: This is a bad way of doing this, but we have no way
- + at this time of telling the main program to use grey */
- + fprintf(stderr,
- + "Attempt to set colour palette in monochrome mode\n");
- + sm_palette.colorMode = SMPAL_COLOR_MODE_GRAY;
- + for (i = 0; i < sm_palette.colors; i++) {
- + int j = i * 255 / sm_palette.colors + 0.5;
- + fprintf(gpoutfile, "%d %d #%2.2x%2.2x%2.2x\n",
- + O_COLOR_DEF, (i + FIG_palette_offst),j,j,j);
- + }
- + } else {
- + /* Create colour/normal palette */
- + for (i = 0; i < sm_palette.colors; i++) {
- + fprintf(gpoutfile, "%d %d #%2.2x%2.2x%2.2x\n",
- + O_COLOR_DEF, (i + FIG_palette_offst),
- + (int)( palette->color[i].r * 255 + 0.5 ),
- + (int)( palette->color[i].g * 255 + 0.5 ),
- + (int)( palette->color[i].b * 255 + 0.5 ) );
- + }
- + }
- + } else {
- + fprintf(stderr, "Attempt to set palette twice\n");
- + }
- + return(0);
- +}
- +
- +/* This doesn't apply for FIG format files
- +TERM_PUBLIC void FIG_previous_palette()
- +{
- +}
- +*/
- +
- +TERM_PUBLIC void FIG_set_color(double gray)
- +{
- + if (FIG_palette_set == FALSE) {
- + fprintf(stderr,"Palette used before set\n"); /* Error condition */
- + }
- + FIG_fill_color = (int)((gray*(FIG_palette_size-1)) + 0.5)
- + + FIG_palette_offst;
- +}
- +
- +TERM_PUBLIC void FIG_filled_polygon(int points, gpiPoint *corners)
- +{
- + int i,j;
- +
- + if (FIG_palette_set == FALSE) {
- + fprintf(stderr,"Palette used before set\n"); /* Error condition */
- + }
- +
- + FIG_poly_clean(FIG_polyvec_stat); /* Clean up current data */
- +
- + fprintf(gpoutfile, "%d %d %d %d %d %d %d %d %d %9.3f %d %d %d %d %d %ld\n\t"
- +,
- + O_POLYLINE, T_POLYGON, FIG_line.style, 0,
- + FIG_fill_color, FIG_fill_color, FIG_line.depth,
- + FIG_line.pen_style, FIG_fill_style, FIG_line.style_val,
- + FIG_line.join_style, FIG_line.cap_style, FIG_line.radius,
- + 0, 0, (long)(points+1));
- +/* set thickness (arg 4) to 0 */
- +
- + j = 0;
- + for (i = 0; i < points; i++) {
- + fprintf(gpoutfile, " %d %d", FIG_xoff + corners[i].x,
- + term->ymax + FIG_yoff - corners[i].y);
- + if (j++ > 4 && i != points - 1) {
- + fputs("\n\t", gpoutfile);
- + j = 0; /* JFS */
- + }
- + }
- + fprintf(gpoutfile, " %d %d", FIG_xoff + corners[0].x,
- + term->ymax + FIG_yoff - corners[0].y);
- + j++;
- + if (j != 0) {
- + putc('\n', gpoutfile);
- + }
- +}
- +#endif /* PM3D */
- +
- #endif /* TERM_BODY */
-
- #ifdef TERM_TABLE
- @@ -785,6 +897,9 @@
- FIG_lpoint, FIG_arrow, set_font_null, FIG_pointsize,
- 0 /*flags */ , 0 /*suspend */ , 0 /*resume */ , 0 /*fillbox */ ,
- FIG_linewidth
- +#ifdef PM3D
- + , FIG_make_palette, 0 /*previous_palette*/, FIG_set_color, FIG_filled_polygon
- +#endif /* PM3D */
- TERM_TABLE_END(fig_driver)
-
- #undef LAST_TERM
- diff -uwr gnuplot-3.7.0.8/term/gif.trm gnuplot-pm3d/term/gif.trm
- --- gnuplot-3.7.0.8/term/gif.trm Wed Jun 9 13:05:10 1999
- +++ gnuplot-pm3d/term/gif.trm Mon Jun 14 09:30:38 1999
- @@ -87,6 +87,7 @@
- * [Update: as of version 1.3, gd does not use any more UNISYS licensed
- * code. The gnuplot team may decide to include this version some day.]
- *
- + * Petr Mikulik, Jan 1999: terminal entries for PM3D functionality
- */
-
- #include "driver.h"
- @@ -106,6 +107,12 @@
- TERM_PUBLIC void GIF_put_text __PROTO((unsigned int x, unsigned int y, char str[]));
- TERM_PUBLIC int GIF_text_angle __PROTO((int ang));
- TERM_PUBLIC void GIF_reset __PROTO((void));
- +#ifdef PM3D
- +TERM_PUBLIC int GIF_make_palette (t_sm_palette *);
- +/* TERM_PUBLIC void GIF_previous_palette (void); */
- +TERM_PUBLIC void GIF_set_color (double);
- +TERM_PUBLIC void GIF_filled_polygon (int, gpiPoint *);
- +#endif
-
- #include "gd.h"
- extern gdFontPtr gdFontSmall; /* 6x12 */
- @@ -411,6 +418,96 @@
- {
- }
-
- +#ifdef PM3D
- +
- +#if 1
- +/* use #if 1 that's just for debuggin */
- +void GIF_show_current_palette()
- +{
- +int i;
- +fprintf(stderr,"*****\n SHOW THE PALETTE! total=%i\n",gdImageColorsTotal(gif_state.image));
- +for (i=0; i < gdImageColorsTotal(gif_state.image); i++) {
- + /* Use access macros to learn colors. */
- + fprintf(stderr,"%i\tr=%d\t g=%d\tb=%d\n", i,
- + gdImageRed(gif_state.image,i),
- + gdImageGreen(gif_state.image,i),
- + gdImageBlue(gif_state.image,i));
- + }
- +}
- +#endif
- +
- +/*
- +How this works:
- +Gray interval [0;1] will be mapped to interval [0;sm_palette.colors-1]
- +those r,g,b components are mapped by the array below
- +palette.offset equals 0 since gif_smooth_color[0..colors] are from ColorAllocate
- +*/
- +int gif_smooth_color[ gdMaxColors ];
- + /* chooser from the colour palette */
- + /* TODO: how to recover from a multiplot with two colour pm3d maps?
- + They must use the same palette! Or palette size must be
- + restricted to certain number of colours---a new user's option
- + */
- +
- +TERM_PUBLIC int GIF_make_palette (t_sm_palette *palette)
- +{
- +int i;
- +if (palette == NULL) {
- + /* return maximal number of colours in a GIF palette */
- + i = gdMaxColors /*256*/ - gdImageColorsTotal(gif_state.image);
- + /* the latter is the number of currently allocated colours. We want
- + to allocate the rest */
- +//BACK PLEASE fprintf(stderr,"colors in GIF palette=%i\n",(int)gdMaxColors);
- + return i;
- + }
- +for (i = 0; i < sm_palette.colors; i++) {
- + gif_smooth_color[i] = gdImageColorAllocate(gif_state.image,
- + (int)( palette->color[i].r * 255 + 0.5 ), /* r,g,b values for gif */
- + (int)( palette->color[i].g * 255 + 0.5 ), /* terminal are [0;255] */
- + (int)( palette->color[i].b * 255 + 0.5 ) );
- + if (gif_smooth_color[i] < 0) { /* this should never happen! take away? */
- + FPRINTF("gif_smooth_color[i]<0 cannot happen")
- + exit(1);
- + }
- +#if 0
- +fprintf(stderr,"ALLOCATED: i=%i\t=> pal_index=%i\tr=%g g=%g b=%g\n",
- + i, gif_smooth_color[i],
- + palette->color[i].r, palette->color[i].g, palette->color[i].b );
- +#endif
- + }
- +return 0;
- +}
- +
- +int gif_color;
- + /* keep here the last set color */
- +
- +TERM_PUBLIC void GIF_set_color (double gray)
- +{
- +gif_color = (int)( gray * (sm_palette.colors-1) + 0.5 );
- + /* map [0;1] to interval [0;gif_smooth_colors-1] */
- +gif_color = gif_smooth_color[ gif_color ]; /* index to the palette */
- +//fprintf(stderr,"GIF terminal sets color gif_color=%i\n",gif_color);
- +}
- +
- +
- +TERM_PUBLIC void GIF_filled_polygon ( int points, gpiPoint *corners )
- +{
- +int i;
- +for (i = 0; i < points; i++)
- + corners[i].y = gif_state.height - corners[i].y;
- +gdImageFilledPolygon(gif_state.image, (gdPointPtr)corners, points, gif_color);
- + /* easy, since gdPointPtr is the same as (gdiPoint*) */
- +/* if someone someday needs this routine to be NON-DESTRUCTIVE, then change
- + the following line to #if 1 */
- +#if 0
- +for (i = 0; i < points; i++)
- + corners[i].y = gif_state.height - corners[i].y;
- +#endif
- +}
- +
- +
- +#endif
- +
- /*
- * _graphics() Called just before a plot is going to be displayed. This
- * procedure should set the device into graphics mode. Devices which can't
- @@ -588,6 +685,14 @@
- null_justify_text, do_point, do_arrow, GIF_set_font,
- 0, /* pointsize */
- TERM_CAN_MULTIPLOT | TERM_BINARY
- +#ifdef PM3D
- + , 0 /*suspend*/, 0 /*resume*/,
- + 0 /*fillbox*/, 0 /*linewidth*/,
- + GIF_make_palette,
- + 0, /* previous_palette() ... no, single array of 256 colours for GIF */
- + GIF_set_color,
- + GIF_filled_polygon
- +#endif
- TERM_TABLE_END(gif_driver)
-
- #undef LAST_TERM
- diff -uwr gnuplot-3.7.0.8/term/pm.trm gnuplot-pm3d/term/pm.trm
- --- gnuplot-3.7.0.8/term/pm.trm Thu Jun 10 20:55:26 1999
- +++ gnuplot-pm3d/term/pm.trm Mon Jun 14 09:30:38 1999
- @@ -43,6 +43,8 @@
- * last change: 7. 4. 1998
- * for mouse support, pm.trm has to be compiled with USE_MOUSE, e.g.
- * gcc ... -DUSE_MOUSE ...
- + *
- + * January 1999: terminal entries for PM3D functionality by Petr Mikulik
- */
-
- #include "driver.h"
- @@ -67,6 +69,12 @@
- TERM_PUBLIC void PM_suspend __PROTO((void));
- TERM_PUBLIC void PM_resume __PROTO((void));
- TERM_PUBLIC void PM_linewidth __PROTO((double linewidth));
- +#ifdef PM3D
- +TERM_PUBLIC int PM_make_palette (t_sm_palette *);
- +TERM_PUBLIC void PM_previous_palette (void);
- +TERM_PUBLIC void PM_set_color (double);
- +TERM_PUBLIC void PM_filled_polygon (int, gpiPoint *);
- +#endif
-
- /* define PM world coordinate limits */
-
- @@ -113,6 +121,12 @@
- #define GR_PAUSE 'P'
- #define GR_HELP 'H'
- #define GR_MOUSECAPABLE 'm' //PM: say gnupmdrv we are mouseable
- +#ifdef PM3D
- +#define GR_MAKE_PALETTE 'p'
- +#define GR_RELEASE_PALETTE 'e'
- +#define GR_SET_COLOR 'c'
- +#define GR_FILLED_POLYGON 'f'
- +#endif
- #define PM_nopts 1
-
- /* path for pm program */
- @@ -676,6 +690,82 @@
- fwrite(&lw, sizeof(int), 1, PM_pipe);
- }
-
- +
- +#ifdef PM3D
- +
- +/* note: gvpm sources have also limit 256, is it limit of PM palette?
- + I suppose yes, thus let colours passed as unsigned char through the pipe
- + But there must be 16 subtracted since nColors = 16 in gclient.c ... colours
- + of the default palette which has to be kept
- +*/
- +/* gray interval [0;1] will be mapped to interval [0;255]
- + those r,g,b components are mapped by the array below */
- +
- +TERM_PUBLIC int PM_make_palette (t_sm_palette *palette)
- +{
- +int i, r, g, b;
- +int rc;
- +ULONG cbR;
- +unsigned long rgbTable[256-16];
- +// unsigned long *rgbTable; // [256-16];
- +putc(GR_MAKE_PALETTE, PM_pipe);
- +if (palette == NULL) {
- + /* return maximal number of colours in palette */
- + putc(0, PM_pipe);
- + fflush(PM_pipe);
- + rc = DosRead(fileno(PM_pipe), &i, sizeof(int), &cbR);
- + return i; // = 256-16;
- + }
- +putc(1, PM_pipe);
- +for (i = 0; i < 256-16; i++) {
- + r = (int)( palette->color[i].r * 255 + 0.5 );
- + g = (int)( palette->color[i].g * 255 + 0.5 );
- + b = (int)( palette->color[i].b * 255 + 0.5 );
- + rgbTable[i] = (r<<16) + (g<<8) + b; // PM API likes this form
- + }
- +fwrite(&rgbTable, sizeof(rgbTable), 1, PM_pipe);
- +return 0;
- +}
- +
- +
- +/* switch back to the palette used before calling make_palette */
- +TERM_PUBLIC void PM_previous_palette ()
- +{
- +putc(GR_RELEASE_PALETTE, PM_pipe);
- +}
- +
- +
- +int pm_color = -1;
- + /* keep here the last set color
- + it is not unsigned char since -1 says that no value has been set
- + */
- +
- +TERM_PUBLIC void PM_set_color (double gray)
- +{
- +unsigned char c = 16 + (unsigned char)( gray * (255-16) + 0.5 );
- + /* map [0;1] to interval [16;255] */
- +if (c == pm_color) return;
- +pm_color = c;
- +putc(GR_SET_COLOR, PM_pipe);
- +//{int k=c; fprintf(stderr,"pm.trm: PM_set_color c=%i\n",k);}
- +putc(c, PM_pipe);
- +}
- +
- +
- +TERM_PUBLIC void PM_filled_polygon ( int points, gpiPoint *corners )
- +{
- +int i;
- +putc(GR_FILLED_POLYGON, PM_pipe);
- +fwrite(&points, sizeof(int), 1, PM_pipe); // tell him number of corners
- +for (i = 0; i < points; i++) {
- + fwrite(&corners[i].x, sizeof(int), 1, PM_pipe);
- + fwrite(&corners[i].y, sizeof(int), 1, PM_pipe);
- + }
- +}
- +
- +
- +#endif
- +
- #endif
-
- #ifdef TERM_TABLE
- @@ -688,6 +778,12 @@
- PM_justify_text, PM_point, do_arrow, PM_set_font,
- 0 /*pointsize */ , TERM_CAN_MULTIPLOT, PM_suspend, PM_resume,
- 0 /*fillbox */ , PM_linewidth
- +#ifdef PM3D
- + , PM_make_palette,
- + PM_previous_palette,
- + PM_set_color,
- + PM_filled_polygon
- +#endif
- TERM_TABLE_END(PM_driver)
-
- #undef LAST_TERM
- diff -uwr gnuplot-3.7.0.8/term/post.trm gnuplot-pm3d/term/post.trm
- --- gnuplot-3.7.0.8/term/post.trm Wed May 12 14:53:18 1999
- +++ gnuplot-pm3d/term/post.trm Mon Jun 14 09:30:38 1999
- @@ -55,6 +55,7 @@
- *
- * Erik Luijten 30/5/97: added %%CreationDate, made %%DocumentFonts conform
- * to DSC, added version no. and patchl. to %%Creator
- + * Petr Mikulik, Jan 1999: terminal entries for PM3D functionality
- */
-
- #include "driver.h"
- @@ -83,6 +84,12 @@
- TERM_PUBLIC void PS_fillbox __PROTO((int style, unsigned int x1, unsigned int y1, unsigned int width, unsigned int height));
- TERM_PUBLIC void PS_linewidth __PROTO((double linewidth)); /* JFi [linewidth] */
- TERM_PUBLIC void PS_pointsize __PROTO((double ptsize)); /* JFi [pointsize] */
- +#ifdef PM3D
- +TERM_PUBLIC int PS_make_palette (t_sm_palette *);
- +TERM_PUBLIC void PS_previous_palette (void);
- +TERM_PUBLIC void PS_set_color (double);
- +TERM_PUBLIC void PS_filled_polygon (int, gpiPoint *);
- +#endif
-
- #define PS_POINT_TYPES 8
- #define PS_XOFF 50 /* page offset in pts */
- @@ -1685,7 +1692,152 @@
- }
-
-
- +#ifdef PM3D
- +
- +/* implementation of pm3dGetColorValue() in the postscript way.
- + Notice that the description, i.e. the part after %, is important
- + since it is used in `show pm3d' for displaying the analytical formulae.
- +*/
- +char *( PostScriptColorFormulae[] ) = {
- + "/cF0 {pop 0} bind def\t% 0",
- + "/cF1 {pop 0.5} bind def\t% 0.5",
- + "/cF2 {pop 1} bind def\t% 1",
- + "/cF3 {} bind def\t% x",
- + "/cF4 {dup mul} bind def\t% x^2",
- + "/cF5 {dup dup mul mul} bind def\t% x^3",
- + "/cF6 {dup mul dup mul} bind def\t% x^4",
- + "/cF7 {sqrt} bind def\t% sqrt(x)",
- + "/cF8 {sqrt sqrt} bind def\t% sqrt(sqrt(x))",
- + "/cF9 {90 mul sin} bind def\t% sin(90x)",
- + "/cF10 {90 mul cos} bind def\t% cos(90x)",
- + "/cF11 {0.5 sub abs} bind def\t% |x-0.5|",
- + "/cF12 {2 mul 1 sub dup mul} bind def\t% (2x-1)^2",
- + "/cF13 {180 mul sin} bind def\t% sin(180x)",
- + "/cF14 {180 mul cos abs} bind def\t% |cos(180x)|",
- + "/cF15 {360 mul sin} bind def\t% sin(360x)",
- + "/cF16 {360 mul cos} bind def\t% cos(360x)",
- + "/cF17 {360 mul sin abs} bind def\t% |sin(360x)|",
- + "/cF18 {360 mul cos abs} bind def\t% |cos(360x)|",
- + "/cF19 {720 mul sin abs} bind def\t% |sin(720x)|",
- + "/cF20 {720 mul cos abs} bind def\t% |cos(720x)|",
- + "/cF21 {3 mul} bind def\t% 3x",
- + "/cF22 {3 mul 1 sub} bind def\t% 3x-1",
- + "/cF23 {3 mul 2 sub} bind def\t% 3x-2",
- + "/cF24 {3 mul 1 sub abs} bind def\t% |3x-1|",
- + "/cF25 {3 mul 2 sub abs} bind def\t% |3x-2|",
- + "/cF26 {1.5 mul .5 sub} bind def\t% (3x-1)/2",
- + "/cF27 {1.5 mul 1 sub} bind def\t% (3x-2)/2",
- + "/cF28 {1.5 mul .5 sub abs} bind def\t% |(3x-1)/2|",
- + "/cF29 {1.5 mul 1 sub abs} bind def\t% |(3x-2)/2|",
- + "/cF30 {0.32 div 0.78125 sub} def\t% x/0.32-0.78125",
- + "/cF31 {2 mul 0.84 sub} def\t% 2*x-0.84",
- + "/cF32 {dup 0.42 le {4 mul} {dup 0.92 le {-2 mul 1.84 add} {0.08 div 11.5 sub} ifelse} ifelse } def\t% 4x;1;-2x+1.84;x/0.08-11.5",
- + "" };
- +
- +TERM_PUBLIC int PS_make_palette (t_sm_palette *palette)
- +{
- +#define R sm_palette.formulaR
- +#define G sm_palette.formulaG
- +#define B sm_palette.formulaB
- +if (palette == NULL)
- + /* postscript can do continous number of colours */
- + return 0;
- +/* write header for smooth colours */
- +
- +fprintf(gpoutfile, "gsave %% colour palette begin\n");
- +/* print the definition of R,G,B formulae */
- +
- +if (sm_palette.ps_allcF == 0) { /* print only those 3 used formulae */
- + fprintf(gpoutfile, "%s\n",PostScriptColorFormulae[ abs(R) ]);
- + if (abs(G) != abs(R))
- + fprintf(gpoutfile, "%s\n",PostScriptColorFormulae[ abs(G) ]);
- + if ((abs(B) != abs(R)) && (abs(B) != abs(G)))
- + fprintf(gpoutfile, "%s\n",PostScriptColorFormulae[ abs(B) ]);
- + }
- + else { /* all color formulae are written into the output PostScript file */
- + int i = 0;
- + while ( *(PostScriptColorFormulae[i]) )
- + fprintf(gpoutfile, "%s\n",PostScriptColorFormulae[ i++ ]);
- + }
- +
- +/* now print something like
- +/g {dup cF7 exch dup cF5 exch cF15 setrgbcolor} bind def
- +*/
- +fprintf(gpoutfile,"Color %s and { %% COLOUR vs. GRAY map\n",
- + (sm_palette.colorMode == SMPAL_COLOR_MODE_RGB) ? "true" : "false"
- + );
- +fprintf(gpoutfile," /g {dup ");
- +if (R < 0) fprintf(gpoutfile, "1 exch sub "); /* negate */
- +fprintf(gpoutfile,"cF%i exch dup ", abs(R));
- +if (G < 0) fprintf(gpoutfile, "1 exch sub "); /* negate */
- +fprintf(gpoutfile,"cF%i exch ", abs(G));
- +if (R<0 || G<0 || B<0) fprintf(gpoutfile,"\n\t");
- +if (B < 0) fprintf(gpoutfile, "1 exch sub "); /* negate */
- +fprintf(gpoutfile,"cF%i ", abs(B));
- +fprintf(gpoutfile,"setrgbcolor} def\n}{\n");
- +fprintf(gpoutfile, " /g {setgray} def\n");
- +fprintf(gpoutfile, "} ifelse\n");
- +fprintf(gpoutfile, "/N {newpath moveto} def\n");
- +fprintf(gpoutfile, "/f {rlineto fill} bind def\n");
- +fprintf(gpoutfile, "/h {rlineto rlineto rlineto fill} bind def\n");
- +return 0;
- +#undef R
- +#undef G
- +#undef B
- +}
- +
- +
- +double pm3d_last_color;
- + /* last choosen colour */
- +
- +double pm3d_ps_color;
- + /* keep here the last set color */
- +
- +TERM_PUBLIC void PS_set_color (double gray)
- +{
- +pm3d_ps_color = gray;
- + /* map [0;1] to interval [0;1] */
- +pm3d_last_color = gray;
- +/* printing the gray with 4 digits and without the leading 0 ... saving space */
- +if (gray <= 0) fprintf(gpoutfile, "0 g "); else
- +if (gray >= 1) fprintf(gpoutfile, "1 g "); else {
- + char s[15];
- + gray = 0.0001*(int)(gray*10000+0.5); /* round it to 4 digits */
- + sprintf(s,"%.4g g ",gray);
- + if (s[0] == '0' && s[1] == '.') fprintf(gpoutfile, "%s", &(s[1]));
- + else fprintf(gpoutfile, "%s", s);
- + }
- +}
- +
- +TERM_PUBLIC void PS_filled_polygon ( int points, gpiPoint *corners )
- +{
- +int i;
- +/* produce lines like:
- +.9335 g 9055 29350 N 695 0 V 0 564 V -695 0 f
- +.9335 g 9055 29350 N 695 0 V 0 564 V -695 0 f
- +*/
- +fprintf(gpoutfile, "%i %i N", corners[0].x, corners[0].y);
- +if (points == 4) /* shorter version */
- + fprintf(gpoutfile, " %i %i %i %i %i %i h\n",
- + corners[3].x-corners[2].x, corners[3].y-corners[2].y,
- + corners[2].x-corners[1].x, corners[2].y-corners[1].y,
- + corners[1].x-corners[0].x, corners[1].y-corners[0].y
- + );
- + else {
- + for (i = 1; i < points-1; i++)
- + fprintf(gpoutfile, " %i %i V",
- + corners[i].x-corners[i-1].x, corners[i].y-corners[i-1].y);
- + fprintf(gpoutfile, " %i %i f\n",
- + corners[i].x-corners[i-1].x, corners[i].y-corners[i-1].y);
- + }
- +}
- +
- +TERM_PUBLIC void PS_previous_palette(void)
- +{
- +fprintf(gpoutfile, "grestore %% colour palette end\n");
- +}
-
- +#endif /* PM3D */
-
-
- #endif /* TERM_BODY */
- @@ -1702,7 +1854,12 @@
- PS_linetype, PS_put_text, PS_text_angle,
- PS_justify_text, PS_point, do_arrow, PS_set_font, PS_pointsize,
- 0 /*flags*/, 0 /*suspend*/, 0 /*resume*/, PS_fillbox, PS_linewidth
- -
- +#ifdef PM3D
- + ,PS_make_palette,
- + PS_previous_palette, /* write grestore */
- + PS_set_color,
- + PS_filled_polygon
- +#endif
- TERM_TABLE_END(post_driver)
-
- #undef LAST_TERM
-