annotate glib/ps.c @ 0:5242703e91d3 tip

Initial checkin for AIM92 aimR8.2 (last updated May 1997).
author tomwalters
date Fri, 20 May 2011 15:19:45 +0100
parents
children
rev   line source
tomwalters@0 1 /*
tomwalters@0 2 Copyright (c) Applied Psychology Unit, Medical Research Council. 1988, 1989
tomwalters@0 3 ===========================================================================
tomwalters@0 4 Permission to use, copy, modify, and distribute this software without fee
tomwalters@0 5 is hereby granted for research purposes, provided that this copyright
tomwalters@0 6 notice appears in all copies and in all supporting documentation, and that
tomwalters@0 7 the software is not redistributed for any fee (except for a nominal shipping
tomwalters@0 8 charge). Anyone wanting to incorporate all or part of this software in a
tomwalters@0 9 commercial product must obtain a license from the Medical Research Council.
tomwalters@0 10 The MRC makes no representations about the suitability of this
tomwalters@0 11 software for any purpose. It is provided "as is" without express or implied
tomwalters@0 12 warranty.
tomwalters@0 13
tomwalters@0 14 THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
tomwalters@0 15 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE
tomwalters@0 16 A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
tomwalters@0 17 DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
tomwalters@0 18 AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
tomwalters@0 19 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
tomwalters@0 20 */
tomwalters@0 21
tomwalters@0 22 /*
tomwalters@0 23 ps.c
tomwalters@0 24 ====
tomwalters@0 25 primitive PostScript interface ala windows.h interface.
tomwalters@0 26 Copyright (c), 1989 The Medical Research Council, Applied Psychology Unit.
tomwalters@0 27 Author : John Holdsworth 22nd March, 1989.
tomwalters@0 28 Michael Akeroyd Summer 1994.
tomwalters@0 29
tomwalters@0 30 Edited : Roy P 27-11-92: commented out two if statements with this->hidden
tomwalters@0 31 in them to force hiddenline.
tomwalters@0 32 Also added '(void)' at start of line after second of the lines
tomwalters@0 33 commented out to make it symmetric with similar lines.
tomwalters@0 34
tomwalters@0 35 : MAA. Summer 1994. rebuild. Notes:
tomwalters@0 36 (1) don't print windows bigger than 800 pixels wide; they aren't scaled
tomwalters@0 37 properly.
tomwalters@0 38 (2) all windows get drawn in the centre of the page.
tomwalters@0 39 (3) because of the 'fill's in drawing the data, the tick-marks can
tomwalters@0 40 get blanked out. To avoid this, the whole frame+marks are drawn
tomwalters@0 41 twice, at the begining (to get the coorect clipppath) and at the
tomwalters@0 42 end
tomwalters@0 43 : MAA. Autumn 1994. rebuilt to avoid note (3).
tomwalters@0 44
tomwalters@0 45 */
tomwalters@0 46
tomwalters@0 47
tomwalters@0 48 #include <stdio.h>
tomwalters@0 49 #if defined(THINK_C) || defined(NeXT)
tomwalters@0 50 #include <stdlib.h>
tomwalters@0 51 #else
tomwalters@0 52 #include <malloc.h>
tomwalters@0 53 #endif
tomwalters@0 54 #include "windows.h"
tomwalters@0 55 #include "grey.h"
tomwalters@0 56 #include "options.h" /* MAA: 23-4-1994: required for isON() */
tomwalters@0 57 #include "string.h" /* MAA: Summer 1994: required for atof() */
tomwalters@0 58 #ifndef NeXT
tomwalters@0 59 /* extern int fprintf() ; */ /* mha 8/4/97: sgi stops here */
tomwalters@0 60 #endif
tomwalters@0 61
tomwalters@0 62 static char *sccs_id = "@(#)ps.c 1.31 J. Holdsworth (MRC-APU) 7/7/93 Revised MAA 1994" ;
tomwalters@0 63
tomwalters@0 64
tomwalters@0 65 /* resolution parameters for line width */
tomwalters@0 66 #define POINTS_PER_INCH 72 /* standard definition of "points" */
tomwalters@0 67 #define PIXELS_PER_INCH 300 /* laserwriterII */
tomwalters@0 68 #define PIXELS_PER_POINT ( ( double ) PIXELS_PER_INCH / POINTS_PER_INCH )
tomwalters@0 69
tomwalters@0 70
tomwalters@0 71 /* limitation on graphics path lengths */
tomwalters@0 72 #define MAX_PATH 350
tomwalters@0 73
tomwalters@0 74
tomwalters@0 75 typedef struct {
tomwalters@0 76 windowEntries *entries ; /* pointers to method routines below */
tomwalters@0 77 char *xptr ; /* general pointer to postscript device */
tomwalters@0 78 int (*sender)(), (*closer)() ; /* function to transmit postscript */
tomwalters@0 79 int (*storer)(), (*recaller)(), (*reader)(), (*writer)(), (*pauser)() ; /* functions which may be used */
tomwalters@0 80 int x, y, width, height, pixels, hidden, page ; /* window paramaters */
tomwalters@0 81 enum { False, True } drawn, showpage ; /* if drawn and if clear not used and
tomwalters@0 82 window can be included in document */
tomwalters@0 83 struct _lookup *lookup ; /* state structure for dithering routines in grey.c*/
tomwalters@0 84 } *psWindowObject ;
tomwalters@0 85
tomwalters@0 86 static windowsClass psClass ;
tomwalters@0 87
tomwalters@0 88
tomwalters@0 89
tomwalters@0 90 /* MAA: lots of new options */
tomwalters@0 91 extern *rotateaxesstr;
tomwalters@0 92 extern char *xstartstr, *ystartstr, *xendstr, *yendstr;
tomwalters@0 93 extern char *xnewtitlestr, *ynewtitlestr;
tomwalters@0 94 extern char *portraitstr, *landscapestr;
tomwalters@0 95 extern char *fontnamestr, *fontsizestr, *titlesizestr;
tomwalters@0 96 extern char *xticksstr, *yticksstr, *outsidestr;
tomwalters@0 97 extern char *axistopstr, *axisbottomstr, *axisleftstr, *axisrightstr;
tomwalters@0 98 extern char *xmajorticksstr, *xminorticksstr;
tomwalters@0 99 extern char *ymajorticksstr, *yminorticksstr;
tomwalters@0 100 extern char *axislinewidthstr, *figurelinewidthstr;
tomwalters@0 101 extern char *boxstr;
tomwalters@0 102 static double temp_xmin;
tomwalters@0 103 static double temp_xmax;
tomwalters@0 104 static double temp_ymin;
tomwalters@0 105 static double temp_ymax;
tomwalters@0 106
tomwalters@0 107
tomwalters@0 108 /*-----------------------------------------------------------------------*/
tomwalters@0 109
tomwalters@0 110
tomwalters@0 111 WindowObject newPostScriptWindow( xptr, default_x, default_y, default_width, default_height, pixels, sender, closer, storer, recaller, reader, writer, pauser, pshidden )
tomwalters@0 112 char *xptr ;
tomwalters@0 113 int default_x, default_y, default_width, default_height, pixels ;
tomwalters@0 114 int (*sender)(), (*closer)() ;
tomwalters@0 115 int (*storer)(), (*recaller)(), (*reader)(), (*writer)(), (*pauser)() ;
tomwalters@0 116 int pshidden; /* =0 if off, =1 if on */
tomwalters@0 117 {
tomwalters@0 118 psWindowObject this = ( psWindowObject ) malloc( sizeof ( *this ) ) ;
tomwalters@0 119 char psfontstr[30];
tomwalters@0 120 char **ptr ;
tomwalters@0 121
tomwalters@0 122 if( psClass.super == (windowsClass *) 0 )
tomwalters@0 123 (void) initPostScriptClass( &psClass ) ;
tomwalters@0 124 this->entries = &psClass.entries ;
tomwalters@0 125 this->xptr = xptr ;
tomwalters@0 126 this->sender = sender ;
tomwalters@0 127 this->storer = storer ;
tomwalters@0 128 this->recaller = recaller ;
tomwalters@0 129 this->reader = reader ;
tomwalters@0 130 this->writer = writer ;
tomwalters@0 131 this->pauser = pauser ;
tomwalters@0 132 this->closer = closer ;
tomwalters@0 133 this->x = default_x ;
tomwalters@0 134 this->y = default_y ;
tomwalters@0 135 this->width = default_width ;
tomwalters@0 136 this->height = default_height ;
tomwalters@0 137 this->hidden = pshidden ;
tomwalters@0 138 this->pixels = abs( pixels ) ;
tomwalters@0 139 this->lookup = 0 ;
tomwalters@0 140 this->drawn = False ;
tomwalters@0 141
tomwalters@0 142 (void) this->sender( this->xptr, "%%!PS-Adobe-2.0 EPSF-1.2\n");
tomwalters@0 143 (void) this->sender( this->xptr, "%%%%Title: Windows postscript file\n");
tomwalters@0 144 (void) this->sender( this->xptr, "%%%%Creator: %s\n", sccs_id);
tomwalters@0 145 (void) this->sender( this->xptr, "%%%%BoundingBox: %d %d %d %d\n", this->x, this->y, this->x+this->width, this->y+this->height);
tomwalters@0 146 (void) this->sender( this->xptr, "%%%%Pages: (atend)\n", this->y);
tomwalters@0 147 /* (void) this->sender( this->xptr, "%%%%DocumentFonts: Times-Roman\n");*/
tomwalters@0 148 (void) this->sender( this->xptr, "%%%%EndComments\n") ;
tomwalters@0 149
tomwalters@0 150 if ( this->hidden == 0 ) {
tomwalters@0 151 (void) this->sender( this->xptr, "\n%%/fill workaround: no hidden lines. MAA. 22-1-1993\n" );
tomwalters@0 152 (void) this->sender( this->xptr, "/fill {} def\n\n" );}
tomwalters@0 153 else ;
tomwalters@0 154
tomwalters@0 155 /* Fonts. The only allowed ones are Times-Roman, Helvetica and Courier,
tomwalters@0 156 * because they are the only three you get in the Adobe Red Book, and
tomwalters@0 157 * so are presumably the onyl three you get in all printers.*/
tomwalters@0 158 if (!strcmp(fontnamestr, "Times")) {strcpy(psfontstr, "Times-Roman");}
tomwalters@0 159 else if (!strcmp(fontnamestr, "times")) {strcpy(psfontstr, "Times-Roman");}
tomwalters@0 160 else if (!strcmp(fontnamestr, "Roman")) {strcpy(psfontstr, "Times-Roman");}
tomwalters@0 161 else if (!strcmp(fontnamestr, "roman")) {strcpy(psfontstr, "Times-Roman");}
tomwalters@0 162 else if (!strcmp(fontnamestr, "times-roman")) {strcpy(psfontstr, "Times-Roman");}
tomwalters@0 163 else if (!strcmp(fontnamestr, "Times-Roman")) {strcpy(psfontstr, "Times-Roman");}
tomwalters@0 164 else if (!strcmp(fontnamestr, "timesroman")) {strcpy(psfontstr, "Times-Roman");}
tomwalters@0 165 else if (!strcmp(fontnamestr, "RimesRoman")) {strcpy(psfontstr, "Times-Roman");}
tomwalters@0 166 else if (!strcmp(fontnamestr, "TimesBold")) {strcpy(psfontstr, "Times-Bold");}
tomwalters@0 167 else if (!strcmp(fontnamestr, "timesbold")) {strcpy(psfontstr, "Times-Bold");}
tomwalters@0 168 else if (!strcmp(fontnamestr, "timesbold")) {strcpy(psfontstr, "Times-Bold");}
tomwalters@0 169 else if (!strcmp(fontnamestr, "times-bold")) {strcpy(psfontstr, "Times-Bold");}
tomwalters@0 170 else if (!strcmp(fontnamestr, "Times-Bold")) {strcpy(psfontstr, "Times-Bold");}
tomwalters@0 171
tomwalters@0 172 else if (!strcmp(fontnamestr, "Helvetica")) {strcpy(psfontstr, "Helvetica");}
tomwalters@0 173 else if (!strcmp(fontnamestr, "helvetica")) {strcpy(psfontstr, "Helvetica");}
tomwalters@0 174 else if (!strcmp(fontnamestr, "Hel")) {strcpy(psfontstr, "Helvetica");}
tomwalters@0 175 else if (!strcmp(fontnamestr, "hel")) {strcpy(psfontstr, "Helvetica");}
tomwalters@0 176 else if (!strcmp(fontnamestr, "HelveticaBold")) {strcpy(psfontstr, "Helvetica-Bold");}
tomwalters@0 177 else if (!strcmp(fontnamestr, "Helveticabold")) {strcpy(psfontstr, "Helvetica-Bold");}
tomwalters@0 178 else if (!strcmp(fontnamestr, "helveticabold")) {strcpy(psfontstr, "Helvetica-Bold");}
tomwalters@0 179 else if (!strcmp(fontnamestr, "Helvetica-Bold")) {strcpy(psfontstr, "Helvetica-Bold");}
tomwalters@0 180 else if (!strcmp(fontnamestr, "helvetica-bold")) {strcpy(psfontstr, "Helvetica-Bold");}
tomwalters@0 181 else if (!strcmp(fontnamestr, "helbold")) {strcpy(psfontstr, "Helvetica-Bold");}
tomwalters@0 182 else if (!strcmp(fontnamestr, "HelBold")) {strcpy(psfontstr, "Helvetica-Bold");}
tomwalters@0 183
tomwalters@0 184 else if (!strcmp(fontnamestr, "Courier")) {strcpy(psfontstr, "Courier");}
tomwalters@0 185 else if (!strcmp(fontnamestr, "courier")) {strcpy(psfontstr, "Courier");}
tomwalters@0 186 else if (!strcmp(fontnamestr, "Cou")) {strcpy(psfontstr, "Courier");}
tomwalters@0 187 else if (!strcmp(fontnamestr, "cou")) {strcpy(psfontstr, "Courier");}
tomwalters@0 188 else if (!strcmp(fontnamestr, "Courier-Bold")) {strcpy(psfontstr, "Courier-Bold");}
tomwalters@0 189 else if (!strcmp(fontnamestr, "courier-bold")) {strcpy(psfontstr, "Courier-Bold");}
tomwalters@0 190 else if (!strcmp(fontnamestr, "courierbold")) {strcpy(psfontstr, "Courier-Bold");}
tomwalters@0 191 else if (!strcmp(fontnamestr, "CourierBold")) {strcpy(psfontstr, "Courier-Bold");}
tomwalters@0 192 else if (!strcmp(fontnamestr, "CouBold")) {strcpy(psfontstr, "Courier-Bold");}
tomwalters@0 193 else if (!strcmp(fontnamestr, "coubold")) {strcpy(psfontstr, "Courier-Bold");}
tomwalters@0 194
tomwalters@0 195 else {
tomwalters@0 196 fprintf(stderr, "WARNING: Unknown font %s. (allowed time, helvetica or courier.)\n", fontnamestr);
tomwalters@0 197 fprintf(stderr, "WARNING: Stopping here; no Postscript generated\n");
tomwalters@0 198 exit(-1);}
tomwalters@0 199
tomwalters@0 200
tomwalters@0 201 /* copy postscript code for axes into output file */
tomwalters@0 202 (void) this->sender( this->xptr, "%%! simple postscript axes\n");
tomwalters@0 203 (void) this->sender( this->xptr, "%% v1.10 John Holdsworth (5/31/91).\n");
tomwalters@0 204 (void) this->sender( this->xptr, "%% Revised M Akeroyd (Summer, Autumn 1994)\n");
tomwalters@0 205 (void) this->sender( this->xptr, "\n");
tomwalters@0 206 (void) this->sender( this->xptr, " /midprint { %% str x y midprint -\n");
tomwalters@0 207 (void) this->sender( this->xptr, " moveto\n");
tomwalters@0 208 (void) this->sender( this->xptr, " dup\n");
tomwalters@0 209 (void) this->sender( this->xptr, " stringwidth pop 2 div neg 0 rmoveto\n");
tomwalters@0 210 (void) this->sender( this->xptr, " show\n");
tomwalters@0 211 (void) this->sender( this->xptr, " } def\n");
tomwalters@0 212 (void) this->sender( this->xptr, "\n");
tomwalters@0 213 (void) this->sender( this->xptr, " /leftprint { %% str x y leftprint -\n");
tomwalters@0 214 (void) this->sender( this->xptr, " moveto\n");
tomwalters@0 215 (void) this->sender( this->xptr, " dup\n");
tomwalters@0 216 (void) this->sender( this->xptr, " stringwidth pop neg fontsize 0.4 mul neg rmoveto\n");
tomwalters@0 217 (void) this->sender( this->xptr, " show\n");
tomwalters@0 218 (void) this->sender( this->xptr, " } def\n");
tomwalters@0 219 (void) this->sender( this->xptr, "\n");
tomwalters@0 220 (void) this->sender( this->xptr, " /ticks { %% min max <float> <float> ticker -\n");
tomwalters@0 221 (void) this->sender( this->xptr, " /ticker exch def %% procedure to draw ticks\n");
tomwalters@0 222 (void) this->sender( this->xptr, " /fmax exch cvr def %% relative spacing of max ticks (0.5x, etc)\n");
tomwalters@0 223 (void) this->sender( this->xptr, " /fmin exch cvr def %% relative spacing of min ticks (0.5x, etc)\n");
tomwalters@0 224 (void) this->sender( this->xptr, " /max exch cvr def %% axis maximum\n");
tomwalters@0 225 (void) this->sender( this->xptr, " /min exch cvr def %% axis minimum\n");
tomwalters@0 226 (void) this->sender( this->xptr, " /maxsubticks 50 def\n");
tomwalters@0 227 (void) this->sender( this->xptr, " max min ne {\n");
tomwalters@0 228 (void) this->sender( this->xptr, " %% calculate order of magnitude\n");
tomwalters@0 229 (void) this->sender( this->xptr, " /delta max min sub log ceiling 1 sub 10 exch exp def\n");
tomwalters@0 230 (void) this->sender( this->xptr, " %% do ticks\n");
tomwalters@0 231 (void) this->sender( this->xptr, " min delta div ceiling delta mul\n");
tomwalters@0 232 (void) this->sender( this->xptr, " delta fmax mul\n");
tomwalters@0 233 (void) this->sender( this->xptr, " max delta div floor delta mul\n");
tomwalters@0 234 (void) this->sender( this->xptr, " {\n");
tomwalters@0 235 (void) this->sender( this->xptr, " min sub max min sub div 1.333333 exch ticker\n");
tomwalters@0 236 (void) this->sender( this->xptr, " }\n");
tomwalters@0 237 (void) this->sender( this->xptr, " for\n");
tomwalters@0 238 (void) this->sender( this->xptr, " %% do sub ticks (but only if fmin != 0)\n");
tomwalters@0 239 (void) this->sender( this->xptr, " fmin 0 ne {");
tomwalters@0 240 (void) this->sender( this->xptr, " max min sub delta div dup\n");
tomwalters@0 241 (void) this->sender( this->xptr, " 10 mul maxsubticks lt {.1} {5 mul maxsubticks lt {.2} {.5} ifelse } ifelse\n");
tomwalters@0 242 (void) this->sender( this->xptr, " delta mul /delta exch def\n");
tomwalters@0 243 (void) this->sender( this->xptr, " min delta div ceiling delta mul\n");
tomwalters@0 244 (void) this->sender( this->xptr, " delta fmin mul \n");
tomwalters@0 245 (void) this->sender( this->xptr, " max delta div floor delta mul\n");
tomwalters@0 246 (void) this->sender( this->xptr, " {\n");
tomwalters@0 247 /* MAA: This used to be 0.25; I've changed it (0.25 * 1.33), so its in real points.*/
tomwalters@0 248 (void) this->sender( this->xptr, " min sub max min sub div 0.666666 exch ticker\n");
tomwalters@0 249 (void) this->sender( this->xptr, " }\n");
tomwalters@0 250 (void) this->sender( this->xptr, " for\n");
tomwalters@0 251 (void) this->sender( this->xptr, " } if\n");
tomwalters@0 252 (void) this->sender( this->xptr, " } if\n");
tomwalters@0 253 (void) this->sender( this->xptr, " } def\n");
tomwalters@0 254 (void) this->sender( this->xptr, "\n");
tomwalters@0 255 (void) this->sender( this->xptr, "/Axes { %% title xmin xmax xtitle ymin ymax ytitle Axes -\n");
tomwalters@0 256 (void) this->sender( this->xptr, "/AxesDict 50 dict def\n");
tomwalters@0 257 (void) this->sender( this->xptr, "AxesDict begin\n");
tomwalters@0 258 (void) this->sender( this->xptr, " /ytitle exch def\n");
tomwalters@0 259 (void) this->sender( this->xptr, " /ymax exch def\n");
tomwalters@0 260 (void) this->sender( this->xptr, " /ymin exch def\n");
tomwalters@0 261 (void) this->sender( this->xptr, " /xtitle exch def\n");
tomwalters@0 262 (void) this->sender( this->xptr, " /xmax exch def\n");
tomwalters@0 263 (void) this->sender( this->xptr, " /xmin exch def\n");
tomwalters@0 264 (void) this->sender( this->xptr, " /title exch def\n");
tomwalters@0 265 (void) this->sender( this->xptr, " newpath clippath pathbbox /height exch def\n");
tomwalters@0 266 (void) this->sender( this->xptr, " /width exch def\n");
tomwalters@0 267 (void) this->sender( this->xptr, " pop pop\n");
tomwalters@0 268 (void) this->sender( this->xptr, " /tagsize 0.05 height mul neg def\n");
tomwalters@0 269 if (isOFF(xticksstr))
tomwalters@0 270 (void) this->sender( this->xptr, " /xtagsize tagsize 1.33 mul def\n");
tomwalters@0 271 else
tomwalters@0 272 (void) this->sender( this->xptr, " /xtagsize %s neg 1.33 mul def\n", xticksstr);
tomwalters@0 273 if (isOFF(yticksstr))
tomwalters@0 274 (void) this->sender( this->xptr, " /ytagsize tagsize 1.33 mul def\n");
tomwalters@0 275 else
tomwalters@0 276 (void) this->sender( this->xptr, " /ytagsize %s neg 1.33 mul def\n", yticksstr);
tomwalters@0 277 if (isOFF(fontsizestr))
tomwalters@0 278 (void) this->sender( this->xptr, " /fontsize 0.05 height mul def\n");
tomwalters@0 279 else {
tomwalters@0 280 /* note 1.333 multiplier: required to get rid of the 0.75 later on */
tomwalters@0 281 (void) this->sender( this->xptr, " /fontsize %s 1.333 mul def\n", fontsizestr);}
tomwalters@0 282 (void) this->sender( this->xptr, " /space 0.10 height mul def\n");
tomwalters@0 283 (void) this->sender( this->xptr, " /%s findfont fontsize scalefont setfont\n", psfontstr);
tomwalters@0 284 /* MAA: What do these 0.75/0.75 do? Quite a lot: they seem to be a screen -> paper multiplu constant*/
tomwalters@0 285 (void) this->sender( this->xptr, " width 0.20 mul 0.15 height mul translate 0.75 0.75 scale\n");
tomwalters@0 286 (void) this->sender( this->xptr, " gsave\n");
tomwalters@0 287 (void) this->sender( this->xptr, " gsave\n");
tomwalters@0 288 (void) this->sender( this->xptr, " %s setlinewidth\n", axislinewidthstr);
tomwalters@0 289 /* MAA: I do not knwo why this (2,2) translation is here, but it seems to get in the way */
tomwalters@0 290 /* (void) this->sender( this->xptr, " currentlinewidth 2 div neg dup translate\n");*/
tomwalters@0 291 (void) this->sender( this->xptr, " newpath\n");
tomwalters@0 292 if (isOFF(titlesizestr))
tomwalters@0 293 (void) this->sender( this->xptr, " title width 2 div height tagsize 1.75 mul sub midprint\n");
tomwalters@0 294 else {
tomwalters@0 295 (void) this->sender( this->xptr, " gsave\n");
tomwalters@0 296 /* note 1.333 multiplier: required to get rid of the 0.75 later on */
tomwalters@0 297 (void) this->sender( this->xptr, " /%s findfont %s 1.333 mul scalefont setfont\n", psfontstr, titlesizestr);
tomwalters@0 298 (void) this->sender( this->xptr, " title width 2 div height tagsize 1.75 mul sub midprint\n");}
tomwalters@0 299 if (isON(axisbottomstr)){
tomwalters@0 300 (void) this->sender( this->xptr, " xmin 0 xtagsize fontsize sub midprint\n");
tomwalters@0 301 (void) this->sender( this->xptr, " xmax width xtagsize fontsize sub midprint\n");
tomwalters@0 302 (void) this->sender( this->xptr, " xmin cvr 0 lt \n");
tomwalters@0 303 (void) this->sender( this->xptr, " {xmax cvr 0 ge \n");
tomwalters@0 304 (void) this->sender( this->xptr, " {(0) width xmin cvr neg xmin cvr neg xmax cvr add div mul xtagsize 1.0 mul fontsize sub midprint \n");
tomwalters@0 305 (void) this->sender( this->xptr, " /xtitleconstant 2.0 def} \n");
tomwalters@0 306 (void) this->sender( this->xptr, " {/xtitleconstant 1.0 def} \n");
tomwalters@0 307 (void) this->sender( this->xptr, " ifelse}\n");
tomwalters@0 308 (void) this->sender( this->xptr, " {/xtitleconstant 1.0 def} \n");
tomwalters@0 309 (void) this->sender( this->xptr, " ifelse\n");
tomwalters@0 310 (void) this->sender( this->xptr, " xtitle width 2 div xtagsize xtitleconstant mul fontsize sub midprint\n");
tomwalters@0 311 }
tomwalters@0 312 if (isON(axisleftstr)) {
tomwalters@0 313 (void) this->sender( this->xptr, " ymin ytagsize 2.0 mul 0 leftprint\n");
tomwalters@0 314 (void) this->sender( this->xptr, " ymax ytagsize 2.0 mul height leftprint\n");
tomwalters@0 315 (void) this->sender( this->xptr, " ymin cvr 0 lt { \n");
tomwalters@0 316 (void) this->sender( this->xptr, " ymax cvr 0 ge {\n");
tomwalters@0 317 (void) this->sender( this->xptr, " (0) ytagsize 2.0 mul height ymin cvr neg ymin cvr neg ymax cvr add div mul leftprint} \n");
tomwalters@0 318 (void) this->sender( this->xptr, " if}\n");
tomwalters@0 319 (void) this->sender( this->xptr, " if\n");}
tomwalters@0 320 (void) this->sender( this->xptr, " 90 rotate\n");
tomwalters@0 321 (void) this->sender( this->xptr, " ytitle height 2 div space 1.75 mul midprint\n");
tomwalters@0 322 (void) this->sender( this->xptr, " grestore\n");
tomwalters@0 323 (void) this->sender( this->xptr, " grestore\n");
tomwalters@0 324 (void) this->sender( this->xptr, "end } def\n");
tomwalters@0 325
tomwalters@0 326
tomwalters@0 327
tomwalters@0 328 /* MAA: New procedure AxesBox, which draws the box ... This is actually a revised workaround
tomwalters@0 329 * for the 'borderframe' problem. */
tomwalters@0 330 (void) this->sender( this->xptr, "\n\n" ) ;
tomwalters@0 331 (void) this->sender( this->xptr, "/AxesBox { %% xmin xmax ymin ymax AxesBox -\n");
tomwalters@0 332 (void) this->sender( this->xptr, "/AxesBoxDict 50 dict def\n");
tomwalters@0 333 (void) this->sender( this->xptr, "AxesBoxDict begin\n");
tomwalters@0 334 (void) this->sender( this->xptr, " /ymax exch def\n");
tomwalters@0 335 (void) this->sender( this->xptr, " /ymin exch def\n");
tomwalters@0 336 (void) this->sender( this->xptr, " /xmax exch def\n");
tomwalters@0 337 (void) this->sender( this->xptr, " /xmin exch def\n");
tomwalters@0 338 (void) this->sender( this->xptr, " newpath clippath pathbbox /height exch def\n");
tomwalters@0 339 (void) this->sender( this->xptr, " /width exch def\n");
tomwalters@0 340 (void) this->sender( this->xptr, " pop pop\n");
tomwalters@0 341 (void) this->sender( this->xptr, " /tagsize 0.05 height mul neg def\n");
tomwalters@0 342 if (isOFF(xticksstr))
tomwalters@0 343 (void) this->sender( this->xptr, " /xtagsize tagsize def\n");
tomwalters@0 344 else
tomwalters@0 345 (void) this->sender( this->xptr, " /xtagsize %s neg def\n", xticksstr);
tomwalters@0 346 if (isOFF(yticksstr))
tomwalters@0 347 (void) this->sender( this->xptr, " /ytagsize tagsize def\n");
tomwalters@0 348 else
tomwalters@0 349 (void) this->sender( this->xptr, " /ytagsize %s neg def\n", yticksstr);
tomwalters@0 350 (void) this->sender( this->xptr, " /space 0.10 height mul def\n");
tomwalters@0 351 (void) this->sender( this->xptr, " width 0.20 mul 0.15 height mul translate 0.75 0.75 scale\n");
tomwalters@0 352 (void) this->sender( this->xptr, " gsave\n");
tomwalters@0 353 (void) this->sender( this->xptr, " %s setlinewidth\n", axislinewidthstr);
tomwalters@0 354 (void) this->sender( this->xptr, " newpath\n");
tomwalters@0 355 if (isON(outsidestr)){
tomwalters@0 356 (void) this->sender( this->xptr, " /toptagsize xtagsize neg def\n");
tomwalters@0 357 (void) this->sender( this->xptr, " /bottomtagsize xtagsize def\n");
tomwalters@0 358 (void) this->sender( this->xptr, " /lefttagsize ytagsize def\n");
tomwalters@0 359 (void) this->sender( this->xptr, " /righttagsize ytagsize neg def\n");}
tomwalters@0 360 else{
tomwalters@0 361 (void) this->sender( this->xptr, " /toptagsize xtagsize def\n");
tomwalters@0 362 (void) this->sender( this->xptr, " /bottomtagsize xtagsize neg def\n");
tomwalters@0 363 (void) this->sender( this->xptr, " /lefttagsize ytagsize neg def\n");
tomwalters@0 364 (void) this->sender( this->xptr, " /righttagsize ytagsize def\n");}
tomwalters@0 365 if (isON(axisbottomstr)){
tomwalters@0 366 (void) this->sender( this->xptr, " 0 bottomtagsize moveto 0 0 lineto stroke\n");
tomwalters@0 367 (void) this->sender( this->xptr, " width bottomtagsize moveto width 0 lineto stroke\n");}
tomwalters@0 368 if (isON(axistopstr)){
tomwalters@0 369 (void) this->sender( this->xptr, " 0 height moveto 0 toptagsize rmoveto 0 height lineto stroke\n");
tomwalters@0 370 (void) this->sender( this->xptr, " width height moveto 0 toptagsize rmoveto width height lineto stroke\n");}
tomwalters@0 371 if (isON(axisleftstr)){
tomwalters@0 372 (void) this->sender( this->xptr, " 0 0 moveto lefttagsize 0 rmoveto 0 0 lineto stroke\n");
tomwalters@0 373 (void) this->sender( this->xptr, " 0 height moveto lefttagsize 0 rmoveto 0 height lineto stroke\n");}
tomwalters@0 374 if (isON(axisrightstr)){
tomwalters@0 375 (void) this->sender( this->xptr, " width 0 moveto righttagsize 0 rmoveto width 0 lineto stroke\n");
tomwalters@0 376 (void) this->sender( this->xptr, " width height moveto righttagsize 0 rmoveto width height lineto stroke\n");}
tomwalters@0 377 if (isON(axisbottomstr))
tomwalters@0 378 (void) this->sender( this->xptr, " xmin xmax %s %s {width mul 0 moveto bottomtagsize mul 0 exch rlineto stroke} ticks\n", xminorticksstr, xmajorticksstr);
tomwalters@0 379 if (isON(axistopstr))
tomwalters@0 380 (void) this->sender( this->xptr, " xmin xmax %s %s {width mul height moveto toptagsize mul 0 exch rlineto stroke} ticks\n", xminorticksstr, xmajorticksstr);
tomwalters@0 381 if (isON(axisleftstr))
tomwalters@0 382 (void) this->sender( this->xptr, " ymin ymax %s %s {height mul 0 exch moveto lefttagsize mul 0 rlineto stroke} ticks\n", yminorticksstr, ymajorticksstr);
tomwalters@0 383 if (isON(axisrightstr))
tomwalters@0 384 (void) this->sender( this->xptr, " ymin ymax %s %s {height mul width exch moveto righttagsize mul 0 rlineto stroke} ticks\n", yminorticksstr, ymajorticksstr);
tomwalters@0 385 (void) this->sender( this->xptr, " grestore\n");
tomwalters@0 386 (void) this->sender( this->xptr, " newpath 0 0 moveto width 0 lineto width height lineto 0 height lineto closepath stroke clip\n");
tomwalters@0 387 (void) this->sender( this->xptr, "end } def\n");
tomwalters@0 388 (void) this->sender( this->xptr, "\ngsave\n\n" ) ;
tomwalters@0 389
tomwalters@0 390 /* rotate for landscape mode */
tomwalters@0 391 if( this->width > this->height ) {
tomwalters@0 392 (void) this->sender( this->xptr, "%% shift orgin and rotate for landscape mode\n" ) ;
tomwalters@0 393 (void) this->sender( this->xptr, "newpath clippath pathbbox pop exch translate pop 90 rotate %% notstand\n" ) ; }
tomwalters@0 394 (void) this->sender( this->xptr, "%% center image on page\n" ) ;
tomwalters@0 395 (void) this->sender( this->xptr, "newpath clippath pathbbox exch %d sub 2 div exch %d sub 2 div translate pop pop %%notstand\n", this->width, this->height ) ;
tomwalters@0 396
tomwalters@0 397 /* set clippath - used by axis routine */
tomwalters@0 398 (void) this->sender( this->xptr, "newpath 0 0 moveto %d 0 rlineto 0 %d rlineto %d neg 0 rlineto closepath clip\n", this->width, this->height, this->width ) ;
tomwalters@0 399 /* (void) this->sender( this->xptr, "%f setlinewidth\n/l { lineto } def\n", this->pixels / PIXELS_PER_POINT ) ;*/
tomwalters@0 400 (void) this->sender( this->xptr, "%s setlinewidth\n/l { lineto } def\n", figurelinewidthstr) ;
tomwalters@0 401
tomwalters@0 402 (void) this->sender( this->xptr, "1 setlinecap\n/pt {moveto 0 0 rlineto stroke} def\n" ) ;
tomwalters@0 403 (void) this->sender( this->xptr, "106 45 { dup mul exch\n dup mul add 1.0\n exch sub } setscreen\n" ) ;
tomwalters@0 404
tomwalters@0 405 this->page = 1 ;
tomwalters@0 406 (void) this->sender( this->xptr, "%%%%EndProlog\n%%%%Page %d %d\ngsave\n", this->page, this->page ) ;
tomwalters@0 407 this->showpage = False ;
tomwalters@0 408 return ( ( WindowObject ) this ) ;
tomwalters@0 409 }
tomwalters@0 410
tomwalters@0 411
tomwalters@0 412
tomwalters@0 413 /*---------------------------------------------------------------*/
tomwalters@0 414
tomwalters@0 415
tomwalters@0 416
tomwalters@0 417 WindowObject newFILEWindow( fp, default_x, default_y, default_width, default_height, pixels, pshidden)
tomwalters@0 418 FILE *fp ;
tomwalters@0 419 int default_x, default_y, default_width, default_height, pixels ;
tomwalters@0 420 int pshidden;
tomwalters@0 421 {
tomwalters@0 422 extern int fflush() ;
tomwalters@0 423
tomwalters@0 424 return ( newPostScriptWindow( fp, default_x, default_y, default_width, default_height, pixels, fprintf, (int (*)())0, (int (*)())0, (int (*)())0, (int (*)())0, (int (*)())0, fflush, pshidden )) ;
tomwalters@0 425 }
tomwalters@0 426
tomwalters@0 427
tomwalters@0 428
tomwalters@0 429 WindowObject newPSWindow( name, default_x, default_y, default_width, default_height, pixels, pshidden )
tomwalters@0 430 char *name ;
tomwalters@0 431 int default_x, default_y, default_width, default_height, pixels ;
tomwalters@0 432 int pshidden ;
tomwalters@0 433 {
tomwalters@0 434 extern int fclose() ;
tomwalters@0 435 FILE *fp = stdout ;
tomwalters@0 436
tomwalters@0 437 if( name != ( char * ) 0 && name[0] != '\000' )
tomwalters@0 438 if( ( fp = fopen( name, "w" ) ) == ( FILE * ) 0 ) {
tomwalters@0 439 (void) fprintf( stderr, "Could not open file \"%s\" for output\n", name ) ;
tomwalters@0 440 exit( 1 ) ;}
tomwalters@0 441
tomwalters@0 442 return ( newPostScriptWindow( fp, default_x, default_y, default_width, default_height, pixels, fprintf, fclose, (int (*)())0, (int (*)())0, (int (*)())0, (int (*)())0, (int (*)()) 0 , pshidden ) ) ;
tomwalters@0 443 }
tomwalters@0 444
tomwalters@0 445
tomwalters@0 446
tomwalters@0 447 static short ps__x( this )
tomwalters@0 448 psWindowObject this ;
tomwalters@0 449 {
tomwalters@0 450 return( this->x ) ;
tomwalters@0 451 }
tomwalters@0 452
tomwalters@0 453
tomwalters@0 454 static short ps__y( this )
tomwalters@0 455 psWindowObject this ;
tomwalters@0 456 {
tomwalters@0 457 return( this->y ) ;
tomwalters@0 458 }
tomwalters@0 459
tomwalters@0 460
tomwalters@0 461 static short ps__width( this )
tomwalters@0 462 psWindowObject this ;
tomwalters@0 463 {
tomwalters@0 464 return( this->width ) ;
tomwalters@0 465 }
tomwalters@0 466
tomwalters@0 467
tomwalters@0 468 static short ps__height( this )
tomwalters@0 469 psWindowObject this ;
tomwalters@0 470 {
tomwalters@0 471 return( this->height ) ;
tomwalters@0 472 }
tomwalters@0 473
tomwalters@0 474
tomwalters@0 475 static void ps__draw( this, xs, ys, points )
tomwalters@0 476 psWindowObject this ;
tomwalters@0 477 short xs[], ys[] ;
tomwalters@0 478 int points ;
tomwalters@0 479 {
tomwalters@0 480 int path, point ;
tomwalters@0 481
tomwalters@0 482 (void) this->sender( this->xptr, "newpath\n" ) ;
tomwalters@0 483 if( points > 0 )
tomwalters@0 484 for( point=1 ; point < points ; point+=path ) {
tomwalters@0 485 (void) this->sender( this->xptr, "%d %d moveto\n", xs[point-1], ys[point-1] ) ;
tomwalters@0 486 for( path=0 ; point+path < points && path < MAX_PATH ; path++ )
tomwalters@0 487 (void) this->sender( this->xptr, "%d %d l\n", xs[point+path], ys[point+path] ) ;
tomwalters@0 488 if( this->hidden && xs[point+path] == xs[point-1] &&
tomwalters@0 489 ys[point+path] == ys[point-1] ) /*Roy 27-11-92 */
tomwalters@0 490 (void) this->sender( this->xptr, "gsave 1 setgray fill grestore\n" ) ;
tomwalters@0 491 (void) this->sender( this->xptr, "stroke\n" ) ;}
tomwalters@0 492 else {
tomwalters@0 493 (void) this->sender( this->xptr, "gsave currentlinewidth 10. mul setlinewidth\n" ) ;
tomwalters@0 494 for( point=1 ; point < abs(points) ; point++ )
tomwalters@0 495 (void) this->sender( this->xptr, "%d %d pt\n", xs[point], ys[point] ) ;
tomwalters@0 496 (void) this->sender( this->xptr, "grestore\n" ) ;}
tomwalters@0 497
tomwalters@0 498 this->drawn = True ;
tomwalters@0 499 return ;
tomwalters@0 500 }
tomwalters@0 501
tomwalters@0 502
tomwalters@0 503
tomwalters@0 504 static void ps__clear( this )
tomwalters@0 505 psWindowObject this ;
tomwalters@0 506 {
tomwalters@0 507 if( this->drawn ) {
tomwalters@0 508 ++this->page ;
tomwalters@0 509 (void) this->sender( this->xptr, "grestore\n") ;
tomwalters@0 510 (void) this->sender( this->xptr, "%s setlinewidth\n", axislinewidthstr) ;
tomwalters@0 511 if (isON(boxstr))
tomwalters@0 512 (void) this->sender( this->xptr, "(%g) (%g) (%g) (%g) AxesBox\n", temp_xmin, temp_xmax, temp_ymin, temp_ymax) ;
tomwalters@0 513 (void) this->sender( this->xptr, "showpage\ngrestore\n%%%%Page: %d %d\ngsave\n", this->page, this->page ) ; }
tomwalters@0 514 (void) this->sender( this->xptr, "gsave clippath 1 setgray fill grestore\n" ) ;
tomwalters@0 515 this->showpage = True ;
tomwalters@0 516 return ;
tomwalters@0 517 }
tomwalters@0 518
tomwalters@0 519
tomwalters@0 520
tomwalters@0 521 static void ps__close( this )
tomwalters@0 522 psWindowObject this ;
tomwalters@0 523 {
tomwalters@0 524 (void) this->sender( this->xptr, "grestore\n") ;
tomwalters@0 525 (void) this->sender( this->xptr, "%s setlinewidth\n", axislinewidthstr) ;
tomwalters@0 526 if (isON(boxstr))
tomwalters@0 527 (void) this->sender( this->xptr, "(%g) (%g) (%g) (%g) AxesBox\n", temp_xmin, temp_xmax, temp_ymin, temp_ymax) ;
tomwalters@0 528 if( this->showpage )
tomwalters@0 529 (void) this->sender( this->xptr, "showpage %% notstand\n" ) ;
tomwalters@0 530 else
tomwalters@0 531 this->page = 0 ;
tomwalters@0 532 (void) this->sender( this->xptr, "grestore\n%%%%Trailer\ngrestore\n%%%%Pages: %d\n", this->page ) ;
tomwalters@0 533 if( this->closer != 0 )
tomwalters@0 534 this->closer( this ) ;
tomwalters@0 535 free( (char *) this ) ;
tomwalters@0 536 return ;
tomwalters@0 537 }
tomwalters@0 538
tomwalters@0 539
tomwalters@0 540
tomwalters@0 541 static int ps__store( this )
tomwalters@0 542 psWindowObject this ;
tomwalters@0 543 {
tomwalters@0 544 if( this->storer != 0 )
tomwalters@0 545 return ( this->storer( this->xptr ) ) ;
tomwalters@0 546 else
tomwalters@0 547 (void) fprintf( stderr, "Invalid call to restore postscript image from memory!!" ) ;
tomwalters@0 548 return 0 ;
tomwalters@0 549 }
tomwalters@0 550
tomwalters@0 551
tomwalters@0 552
tomwalters@0 553 static void ps__recall( this, which )
tomwalters@0 554 psWindowObject this ;
tomwalters@0 555 int which ;
tomwalters@0 556 {
tomwalters@0 557 if( this->recaller != 0 )
tomwalters@0 558 this->recaller( this->xptr, which ) ;
tomwalters@0 559 else
tomwalters@0 560 (void) fprintf( stderr, "Invalid call to store postscript image in memory!!" ) ;
tomwalters@0 561 return ;
tomwalters@0 562 }
tomwalters@0 563
tomwalters@0 564
tomwalters@0 565
tomwalters@0 566 static char *cmap( npixels )
tomwalters@0 567 int *npixels ;
tomwalters@0 568 {
tomwalters@0 569 #ifdef NeXT
tomwalters@0 570 static char ps_grey_scale[] = "04bf" ;
tomwalters@0 571 #else
tomwalters@0 572 static char ps_grey_scale[] = "0123456789abcdef" ;
tomwalters@0 573 #endif
tomwalters@0 574
tomwalters@0 575 *npixels = sizeof ( ps_grey_scale ) - 1 ;
tomwalters@0 576 return ( ps_grey_scale ) ;
tomwalters@0 577 }
tomwalters@0 578
tomwalters@0 579
tomwalters@0 580
tomwalters@0 581 static void ps__fill( this, col, input, black, white, match, length, row_flag )
tomwalters@0 582 psWindowObject this ;
tomwalters@0 583 int col ;
tomwalters@0 584 short *input;
tomwalters@0 585 int black, white ;
tomwalters@0 586 int *match, length ;
tomwalters@0 587 int row_flag ;
tomwalters@0 588 {
tomwalters@0 589 int chans, chan, y, blacky ;
tomwalters@0 590
tomwalters@0 591 if( this->lookup == 0 ) {
tomwalters@0 592 this->lookup = makeLookup( cmap, black, white, length ) ;
tomwalters@0 593 (void) this->sender( this->xptr, "/picstr %d string def\n", length ) ;}
tomwalters@0 594 if( col == 1 ) {
tomwalters@0 595 if( row_flag )
tomwalters@0 596 (void) this->sender( this->xptr, "%d %d 4\n[1 0 0 -1 0 %d]\n", this->width, this->height, this->height ) ;
tomwalters@0 597 else
tomwalters@0 598 (void) this->sender( this->xptr, "%d %d 4\n[0 1 -1 0 %d 0]\n", this->height, this->width, this->height ) ;
tomwalters@0 599 (void) this->sender( this->xptr, "{currentfile\npicstr readhexstring pop}\nimage\n" ) ;}
tomwalters@0 600
tomwalters@0 601 (void) this->sender( this->xptr, "%s\n", Lookup( col, this->lookup, input, match, length ) ) ;
tomwalters@0 602 this->drawn = True ;
tomwalters@0 603 return ;
tomwalters@0 604 }
tomwalters@0 605
tomwalters@0 606
tomwalters@0 607
tomwalters@0 608 static void ps__fillRow( this, row, input, black, white, match, width )
tomwalters@0 609 psWindowObject this ;
tomwalters@0 610 int row ;
tomwalters@0 611 short *input ;
tomwalters@0 612 int black, white ;
tomwalters@0 613 int *match, width ;
tomwalters@0 614 {
tomwalters@0 615 ps__fill( this, row, input, black, white, match, width, 1 ) ;
tomwalters@0 616 return ;
tomwalters@0 617 }
tomwalters@0 618
tomwalters@0 619
tomwalters@0 620
tomwalters@0 621 static void ps__fillCol( this, col, input, black, white, match, height )
tomwalters@0 622 psWindowObject this ;
tomwalters@0 623 int col ;
tomwalters@0 624 short *input ;
tomwalters@0 625 int black, white ;
tomwalters@0 626 int *match, height ;
tomwalters@0 627 {
tomwalters@0 628 ps__fill( this, col, input, black, white, match, height, 0 ) ;
tomwalters@0 629 return ;
tomwalters@0 630 }
tomwalters@0 631
tomwalters@0 632
tomwalters@0 633
tomwalters@0 634 static void ps__function( this, ys, segment, skip, offset, yspan, start, points )
tomwalters@0 635 psWindowObject this ;
tomwalters@0 636 short *ys ;
tomwalters@0 637 int segment, skip ;
tomwalters@0 638 double offset, yspan ;
tomwalters@0 639 int start, points ;
tomwalters@0 640 {
tomwalters@0 641 int stop = start + abs( segment ) ;
tomwalters@0 642 int point, path = MAX_PATH, count, miny ;
tomwalters@0 643 short *yptr = ys ;
tomwalters@0 644
tomwalters@0 645 for( point = start ; point < stop-1 ; point += path-1 ) {
tomwalters@0 646 if( path > stop - point )
tomwalters@0 647 path = stop - point ;
tomwalters@0 648 /* too-wide windows: something to do with Width( this) / (points -1.):
tomwalters@0 649 * next line. No fix attempted. MAA, 22-1-1993.
tomwalters@0 650 */
tomwalters@0 651 this->sender( this->xptr, "newpath 0 0 moveto %d 0 rlineto 0 %d rlineto %d neg 0 rlineto closepath clip\n", this->width, this->height, this->width ) ;
tomwalters@0 652 this->sender( this->xptr, "matrix currentmatrix [0 %g %g 0 0 %g] concat newpath %d %d moveto\n",
tomwalters@0 653 Height( this ) / yspan, Width( this ) / ( points - 1. ), offset, miny = yptr[0], point ) ;
tomwalters@0 654 this->sender( this->xptr, "%s setlinewidth\n", figurelinewidthstr) ;
tomwalters@0 655
tomwalters@0 656 #if defined(NeXT)
tomwalters@0 657 this->sender( this->xptr, "[\n" ) ;
tomwalters@0 658 for( count=1 ; count < path ; count++ ) {
tomwalters@0 659 yptr += skip ;
tomwalters@0 660 (void) this->sender( this->xptr, "%d\n", yptr[0]-yptr[-skip] ) ;
tomwalters@0 661 if( miny > yptr[0] )
tomwalters@0 662 miny = yptr[0] ;}
tomwalters@0 663 this->sender( this->xptr, "] {1 rlineto} forall\n" ) ;
tomwalters@0 664
tomwalters@0 665 #else
tomwalters@0 666 this->sender( this->xptr, "/r {1 rlineto} bind def\n" ) ;
tomwalters@0 667 for( count=1 ; count < path ; count++ ) {
tomwalters@0 668 yptr += skip ;
tomwalters@0 669 (void) this->sender( this->xptr, "%d r\n", yptr[0]-yptr[-skip] ) ;
tomwalters@0 670 if( miny > yptr[0] )
tomwalters@0 671 miny = yptr[0] ;}
tomwalters@0 672 #endif
tomwalters@0 673
tomwalters@0 674 if( this->hidden ) /* roy 27-11-92 */
tomwalters@0 675 this->sender( this->xptr, "gsave %d 0 rlineto 0 -%d rlineto closepath 1 setgray fill grestore\n", miny-yptr[0], path-1 ) ;
tomwalters@0 676 (void) this->sender( this->xptr, "setmatrix stroke\n" ) ;}
tomwalters@0 677 return ;
tomwalters@0 678 }
tomwalters@0 679
tomwalters@0 680
tomwalters@0 681
tomwalters@0 682 static int ps__read( this, fp, which )
tomwalters@0 683 psWindowObject this ;
tomwalters@0 684 FILE *fp ;
tomwalters@0 685 int which ;
tomwalters@0 686 {
tomwalters@0 687 if( this->reader != 0 )
tomwalters@0 688 this->reader( this->xptr, fp, which ) ;
tomwalters@0 689 else
tomwalters@0 690 (void) fprintf( stderr, "Invalid call to read postscript image from file!!" ) ;
tomwalters@0 691 return ;
tomwalters@0 692 }
tomwalters@0 693
tomwalters@0 694
tomwalters@0 695
tomwalters@0 696 static void ps__write( this, fp )
tomwalters@0 697 psWindowObject this ;
tomwalters@0 698 FILE *fp ;
tomwalters@0 699 {
tomwalters@0 700 if( this->writer != 0 )
tomwalters@0 701 this->writer( this->xptr, fp ) ;
tomwalters@0 702 else
tomwalters@0 703 (void) fprintf( stderr, "Invalid call to write postscript image to file!!" ) ;
tomwalters@0 704 return ;
tomwalters@0 705 }
tomwalters@0 706
tomwalters@0 707
tomwalters@0 708
tomwalters@0 709 static char ps__pause( this )
tomwalters@0 710 psWindowObject this ;
tomwalters@0 711 {
tomwalters@0 712 if( this->pauser != (int (*)()) 0 )
tomwalters@0 713 return this->pauser( this->xptr ) ;
tomwalters@0 714 return '\000' ;
tomwalters@0 715 }
tomwalters@0 716
tomwalters@0 717
tomwalters@0 718 static void ps__axes( this, title, xmin, xmax, xtitle, ymin, ymax, ytitle )
tomwalters@0 719 psWindowObject this ;
tomwalters@0 720 char *title ;
tomwalters@0 721 double xmin, xmax ;
tomwalters@0 722 char *xtitle ;
tomwalters@0 723 double ymin, ymax ;
tomwalters@0 724 char *ytitle ;
tomwalters@0 725 {
tomwalters@0 726 if (strcmp(xstartstr, "")) xmin = atoi(xstartstr);
tomwalters@0 727 if (strcmp(xendstr, "")) xmax = atoi(xendstr);
tomwalters@0 728 if (strcmp(ystartstr, "")) ymin = atoi(ystartstr);
tomwalters@0 729 if (strcmp(yendstr, "")) ymax = atoi(yendstr);
tomwalters@0 730 if (!strcmp(xnewtitlestr, "")) xnewtitlestr=xtitle;
tomwalters@0 731 if (!strcmp(ynewtitlestr, "")) ynewtitlestr=ytitle;
tomwalters@0 732
tomwalters@0 733 temp_xmin = (double) xmin;
tomwalters@0 734 temp_xmax = (double) xmax;
tomwalters@0 735 temp_ymin = (double) ymin;
tomwalters@0 736 temp_ymax = (double) ymax;
tomwalters@0 737
tomwalters@0 738 if ( isOFF (rotateaxesstr) )
tomwalters@0 739 (void) this->sender( this->xptr, "(%s) (%g) (%g) (%s) (%g) (%g) (%s) Axes\n", title, xmin, xmax, xnewtitlestr, ymin, ymax, ynewtitlestr ) ;
tomwalters@0 740 else
tomwalters@0 741 (void) this->sender( this->xptr, "(%s) (%g) (%g) (%s) (%g) (%g) (%s) Axes\n", title, ymin, ymax, ytitle, (xmax * -1), (xmin * -1), xtitle ) ;
tomwalters@0 742 this->drawn = True ;
tomwalters@0 743 return ;
tomwalters@0 744 }
tomwalters@0 745
tomwalters@0 746
tomwalters@0 747
tomwalters@0 748 static void ps__marker( this, label, p, points )
tomwalters@0 749 psWindowObject this ;
tomwalters@0 750 char *label ;
tomwalters@0 751 int p, points ;
tomwalters@0 752 {
tomwalters@0 753 short pos = ( this->entries->width( this ) * p + points / 2 ) / points ;
tomwalters@0 754
tomwalters@0 755 (void) this->sender( this->xptr, "newpath %d %d moveto %d %d rlineto stroke\n", pos, 0, 0, this->entries->height( this ) ) ;
tomwalters@0 756
tomwalters@0 757 this->drawn = True ;
tomwalters@0 758 return ;
tomwalters@0 759 }
tomwalters@0 760
tomwalters@0 761 static int ps__special( this, code, data )
tomwalters@0 762 psWindowObject this ;
tomwalters@0 763 int code ;
tomwalters@0 764 char *data ;
tomwalters@0 765 {
tomwalters@0 766 this->drawn = True ;
tomwalters@0 767 switch( code ) {
tomwalters@0 768 case 1 :
tomwalters@0 769 (void) this->sender( this->xptr, "%s\n", data ) ;
tomwalters@0 770 return 1 ;
tomwalters@0 771 }
tomwalters@0 772 return 0 ;
tomwalters@0 773 }
tomwalters@0 774
tomwalters@0 775
tomwalters@0 776
tomwalters@0 777 windowsClass *initPostScriptClass( class )
tomwalters@0 778 windowsClass *class ;
tomwalters@0 779 {
tomwalters@0 780 class->super = &psClass ;
tomwalters@0 781 class->entries.x = ps__x ;
tomwalters@0 782 class->entries.y = ps__y ;
tomwalters@0 783 class->entries.width = ps__width ;
tomwalters@0 784 class->entries.height = ps__height ;
tomwalters@0 785 class->entries.draw = ps__draw ;
tomwalters@0 786 class->entries.clear = ps__clear ;
tomwalters@0 787 class->entries.close = ps__close ;
tomwalters@0 788 class->entries.store = ps__store ;
tomwalters@0 789 class->entries.recall = ps__recall ;
tomwalters@0 790 class->entries.fillRow = ps__fillRow ;
tomwalters@0 791 class->entries.fillCol = ps__fillCol ;
tomwalters@0 792 class->entries.function = ps__function ;
tomwalters@0 793 class->entries.read = ps__read ;
tomwalters@0 794 class->entries.write = ps__write ;
tomwalters@0 795 class->entries.pause = ps__pause ;
tomwalters@0 796 class->entries.axes = ps__axes ;
tomwalters@0 797 class->entries.marker = ps__marker ;
tomwalters@0 798 class->entries.special = ps__special ;
tomwalters@0 799
tomwalters@0 800 if( psClass.super == (windowsClass *) 0 )
tomwalters@0 801 (void) initPostScriptClass( &psClass ) ;
tomwalters@0 802 return ( &psClass ) ;
tomwalters@0 803 }
tomwalters@0 804
tomwalters@0 805
tomwalters@0 806
tomwalters@0 807 /* The End */
tomwalters@0 808 /*----------------------------------------------------------------------*/
tomwalters@0 809
tomwalters@0 810