annotate xaim/xreview.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. 1993
tomwalters@0 3 ===========================================================================
tomwalters@0 4
tomwalters@0 5 Permission to use, copy, modify, and distribute this software without fee
tomwalters@0 6 is hereby granted for research purposes, provided that this copyright
tomwalters@0 7 notice appears in all copies and in all supporting documentation, and that
tomwalters@0 8 the software is not redistributed for any fee (except for a nominal
tomwalters@0 9 shipping charge). Anyone wanting to incorporate all or part of this
tomwalters@0 10 software in a commercial product must obtain a license from the Medical
tomwalters@0 11 Research Council.
tomwalters@0 12
tomwalters@0 13 The MRC makes no representations about the suitability of this
tomwalters@0 14 software for any purpose. It is provided "as is" without express or
tomwalters@0 15 implied warranty.
tomwalters@0 16
tomwalters@0 17 THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
tomwalters@0 18 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
tomwalters@0 19 THE A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
tomwalters@0 20 OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
tomwalters@0 21 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
tomwalters@0 22 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
tomwalters@0 23 SOFTWARE.
tomwalters@0 24 */
tomwalters@0 25
tomwalters@0 26 /*
tomwalters@0 27 * xreview
tomwalters@0 28 * ----------
tomwalters@0 29 *
tomwalters@0 30 * A program for animating an AIM 'cartoon bitmap'.
tomwalters@0 31 * Requires X windows, but most varieties, r4, r5, Sun OpenWindows
tomwalters@0 32 * (but see also the makefile)
tomwalters@0 33 *
tomwalters@0 34 * The underlying algorithm is:
tomwalters@0 35 * 1. load the entire cartoon into memory, as one contiguos block.
tomwalters@0 36 * 2. compute, and save, the memory locations of each frame's start.
tomwalters@0 37 * 3. Set the memory pointer of an XImage structure to the first one, and draw
tomwalters@0 38 * 4. Reset the pointer to the next frame, and redraw ...
tomwalters@0 39 * 5. Continue for however many frames there are.
tomwalters@0 40 *
tomwalters@0 41 *
tomwalters@0 42 *
tomwalters@0 43 * A large proportion of this was inspired by the "basic window"
tomwalters@0 44 * program of the O'Reilly X manuals, vol 1. More inspiritaion came from
tomwalters@0 45 * John Holdsworth's code.
tomwalters@0 46 *
tomwalters@0 47 *
tomwalters@0 48 * M.Akeroyd July 1993. version 1.00
tomwalters@0 49 *
tomwalters@0 50 * revisions: MAA: Christmas 1993. rewrites for public release, also some
tomwalters@0 51 * bug fixes.
tomwalters@0 52 * Includes the linux hacks.
tomwalters@0 53 */
tomwalters@0 54
tomwalters@0 55
tomwalters@0 56 #include <X11/Xlib.h>
tomwalters@0 57 #include <X11/Xutil.h>
tomwalters@0 58 #include <X11/Xos.h>
tomwalters@0 59 #include <X11/Xatom.h>
tomwalters@0 60 #include <X11/Xmu/Xmu.h>
tomwalters@0 61 #include <X11/keysym.h>
tomwalters@0 62 #include <X11/cursorfont.h>
tomwalters@0 63
tomwalters@0 64 #include <stdio.h>
tomwalters@0 65 #include <string.h>
tomwalters@0 66 #include <stdlib.h>
tomwalters@0 67 #include <math.h>
tomwalters@0 68 #include <time.h>
tomwalters@0 69
tomwalters@0 70 #include "xreview.h"
tomwalters@0 71 #include "./stipple_a" /* for the Control Window background */
tomwalters@0 72
tomwalters@0 73
tomwalters@0 74
tomwalters@0 75
tomwalters@0 76 /* Function declarations */
tomwalters@0 77 /*-------------------------------------------------------------------------*/
tomwalters@0 78
tomwalters@0 79 void parsecommandline (int argc, char *argv[], char inputfn[], char titlestring[], char fontname[]);
tomwalters@0 80 int readheader(FILE *inputfp, char filefn[]);
tomwalters@0 81 FILE *open_file (char filefn[], FILE *dir_default, int streamtype);
tomwalters@0 82 void close_files (FILE *fp);
tomwalters@0 83
tomwalters@0 84
tomwalters@0 85 void initialise_control_window(char *inputfn, char *titlestring, FILE *inputfp, char *argv[], int argc);
tomwalters@0 86 void initialise_axes_window(char *inputfn, char *titlestring, FILE *inputfp, char *argv[], int argc);
tomwalters@0 87 void initialise_buttons();
tomwalters@0 88 void initialise_image();
tomwalters@0 89
tomwalters@0 90
tomwalters@0 91 void drawimage(int frame);
tomwalters@0 92 void drawtext(Window win, GC gc, XFontStruct *font_info, unsigned int width, \
tomwalters@0 93 unsigned int height, char *text);
tomwalters@0 94 void drawbutton(Window control_win, Window button_local, GC *button_local_gc,\
tomwalters@0 95 int width, int height, char *text, int fill_ground, \
tomwalters@0 96 int text_ground);
tomwalters@0 97 void flashbutton(Window top_win, Window button_local, GC *button_local_gc, \
tomwalters@0 98 int width, int height, char *text);
tomwalters@0 99
tomwalters@0 100 void initialise_X_screen();
tomwalters@0 101 void load_font();
tomwalters@0 102
tomwalters@0 103
tomwalters@0 104
tomwalters@0 105 /* Data arrays: global */
tomwalters@0 106 /*-------------------------------------------------------------------------*/
tomwalters@0 107
tomwalters@0 108 char *data_pointer;
tomwalters@0 109 char *data_pointer_sideways;
tomwalters@0 110 long location[MAX_FRAMES]; /* frames: a reasonably big number */
tomwalters@0 111 int frame = 1; /* start frame */
tomwalters@0 112 FILE *inputfp;
tomwalters@0 113 char inputfn[MAX_STRING_LENGTH];
tomwalters@0 114
tomwalters@0 115 /* .ctn header */
tomwalters@0 116 /*-------------------------------------------------------------------------*/
tomwalters@0 117
tomwalters@0 118 char header[MAX_LINES_HEADER][MAX_LINE_LENGTH];
tomwalters@0 119 int header_lines;
tomwalters@0 120
tomwalters@0 121 int no_frames;
tomwalters@0 122 int frameheight; /* number of channels */
tomwalters@0 123 int framewidth_samples; /* pwidth + nwidth * samplerate */
tomwalters@0 124 int frameshift_samples; /* frstep_aid * samplerate */
tomwalters@0 125 double frstep_aid; /* msecs */
tomwalters@0 126 double pwidth; /* msecs */
tomwalters@0 127 double nwidth; /* msecs: NEGATIVE */
tomwalters@0 128 int width_ctn; /* pixels */
tomwalters@0 129 int height_ctn; /* pixels */
tomwalters@0 130 int x_ctn; /* pixels */
tomwalters@0 131 int y_ctn; /* pixels */
tomwalters@0 132 long samplerate; /* samples per sec */
tomwalters@0 133 int mincf; /* Hz */
tomwalters@0 134 int maxcf; /* Hz */
tomwalters@0 135
tomwalters@0 136
tomwalters@0 137 /* misc */
tomwalters@0 138 /*-------------------------------------------------------------------------*/
tomwalters@0 139
tomwalters@0 140 char progname[MAX_STRING_LENGTH];
tomwalters@0 141 char fontname[MAX_STRING_LENGTH];
tomwalters@0 142 char display_name[MAX_STRING_LENGTH];
tomwalters@0 143
tomwalters@0 144 int verboseflag = OFF; /* -v option */
tomwalters@0 145 int axes_xflag = OFF; /* -image_x option */
tomwalters@0 146 int axes_yflag = OFF; /* -image_y option */
tomwalters@0 147 int controls_xflag = OFF; /* -controls_x option */
tomwalters@0 148 int controls_yflag = OFF; /* -controls_y option */
tomwalters@0 149 int titleflag = OFF; /* -title option */
tomwalters@0 150 int bytesflag = OFF; /* -lsb, -msb options */
tomwalters@0 151 int bitmap_pad_flag = OFF; /* ditto */
tomwalters@0 152 int new_axes_x, new_axes_y;
tomwalters@0 153 int new_control_x, new_control_y;
tomwalters@0 154 int controlwindowflag = OFF; /* -controls option */
tomwalters@0 155 double scale = 1.0;
tomwalters@0 156
tomwalters@0 157 long waittime_millisecs = 1; /* time to wait imbetween frames */
tomwalters@0 158 long waittime_microsecs ;
tomwalters@0 159
tomwalters@0 160 int animate_start = 1; /* animation start frame */
tomwalters@0 161 int animate_stop = 9999; /* animation end frame: gets set to EOF */
tomwalters@0 162 int animate_skip = 1; /* animation skip */
tomwalters@0 163
tomwalters@0 164 int sidewaysflag = OFF;
tomwalters@0 165
tomwalters@0 166
tomwalters@0 167
tomwalters@0 168 /* X variables */
tomwalters@0 169 /*-------------------------------------------------------------------------*/
tomwalters@0 170 /* There are 3 classes of window:
tomwalters@0 171 * "axes window": where the cartoon itself is. Called "axes" for historical
tomwalters@0 172 * reasons. Button presses cause (1) animations, or (2) mapping
tomwalters@0 173 * of the Controls Window, or (3) exit. This window CANNOT
tomwalters@0 174 * be resized.
tomwalters@0 175 * Used, reasonably interchangealby, with 'image'
tomwalters@0 176 * "controls window": where the Animation Control buttons are. Button presses
tomwalters@0 177 * --- if not on a 'button' --- do nothing. This window
tomwalters@0 178 * can't be resized either.
tomwalters@0 179 * "buttons": there are lots of them. eg button_startf. These are subwindows
tomwalters@0 180 * of the Controls Window. Pressing the left mouse button causes
tomwalters@0 181 * something exciting to happen.
tomwalters@0 182 * There are also 'information buttons', which say things
tomwalters@0 183 * like the filename, number of frames, etc. Pressing one of these
tomwalters@0 184 * doesn't do anything.
tomwalters@0 185 */
tomwalters@0 186
tomwalters@0 187 Display *display;
tomwalters@0 188 int screen_num;
tomwalters@0 189 Screen *screen_ptr;
tomwalters@0 190 int depth = 1;
tomwalters@0 191 unsigned int display_width_X, display_height_X;
tomwalters@0 192 unsigned int display_width, display_height;
tomwalters@0 193
tomwalters@0 194 Pixmap stipple_pixmap;
tomwalters@0 195
tomwalters@0 196
tomwalters@0 197 /* Windows */
tomwalters@0 198
tomwalters@0 199 toplevelWindow axes;
tomwalters@0 200 toplevelWindow control;
tomwalters@0 201
tomwalters@0 202 buttonWindow button_quit, button_close;
tomwalters@0 203 buttonWindow button_animate;
tomwalters@0 204 buttonWindow button_startf, button_startb, button_stopf, button_stopb;
tomwalters@0 205 buttonWindow button_skipf, button_skipb, button_faster, button_slower;
tomwalters@0 206 buttonWindow button_firstframe, button_lastframe, button_middle;
tomwalters@0 207 buttonWindow button_stepb, button_stepbb;
tomwalters@0 208 buttonWindow button_stepf, button_stepff;
tomwalters@0 209 buttonWindow info_speed, info_start, info_stop, info_skip;
tomwalters@0 210 buttonWindow info_title, info_frame;
tomwalters@0 211 buttonWindow info_time, info_freq, info_frstep;
tomwalters@0 212
tomwalters@0 213 XFontStruct *font_info;
tomwalters@0 214 int pointsize = DEFAULT_POINTSIZE;
tomwalters@0 215 GC button_gc;
tomwalters@0 216 int button_borderwidth = 0;
tomwalters@0 217
tomwalters@0 218 XImage *reviewimage;
tomwalters@0 219 int reviewimage_bytesperline = BYTES_PER_LINE;
tomwalters@0 220 int reviewimage_bitmap_pad = BITMAP_PAD;
tomwalters@0 221
tomwalters@0 222 Cursor cursor;
tomwalters@0 223
tomwalters@0 224 XEvent report;
tomwalters@0 225 int depthflag = MONO; /* assume a monochrome screen */
tomwalters@0 226 int planemask = 0x1; /* works with my colour sparc */
tomwalters@0 227 int xsyncflag = OFF;
tomwalters@0 228 int reversevideoflag = OFF; /* gets set to ON if DECstation */
tomwalters@0 229 int byteorderflag = SERVER; /* ie, the physical screen */
tomwalters@0 230
tomwalters@0 231
tomwalters@0 232
tomwalters@0 233
tomwalters@0 234
tomwalters@0 235 /* ...................... Main ..............................*/
tomwalters@0 236 /* .........................................................................*/
tomwalters@0 237 /* .........................................................................*/
tomwalters@0 238
tomwalters@0 239
tomwalters@0 240
tomwalters@0 241
tomwalters@0 242 void main (int argc, char *argv[])
tomwalters@0 243 {
tomwalters@0 244 int n;
tomwalters@0 245 int header_bytes = 0;
tomwalters@0 246 int alreadydrawnflag = OFF;
tomwalters@0 247
tomwalters@0 248 char titlestring[MAX_STRING_LENGTH];
tomwalters@0 249 char tempstring[MAX_STRING_LENGTH];
tomwalters@0 250
tomwalters@0 251
tomwalters@0 252 int required_bytes;
tomwalters@0 253 long status;
tomwalters@0 254 long starttime, localtime;
tomwalters@0 255 long x;
tomwalters@0 256
tomwalters@0 257
tomwalters@0 258 /*-----------------------------*/
tomwalters@0 259
tomwalters@0 260 strcpy(progname, argv[0]);
tomwalters@0 261 strcpy(fontname, "");
tomwalters@0 262 strcpy(inputfn, "");
tomwalters@0 263 strcpy(titlestring, "");
tomwalters@0 264
tomwalters@0 265 /* Machine specific defaults */
tomwalters@0 266 #ifdef HOST_SPARC
tomwalters@0 267 byteorderflag = SUN;
tomwalters@0 268 reversevideoflag = OFF;
tomwalters@0 269 #endif
tomwalters@0 270 #ifdef HOST_DECSTATION
tomwalters@0 271 byteorderflag = DEC;
tomwalters@0 272 reversevideoflag = ON;
tomwalters@0 273 #endif
tomwalters@0 274 #ifdef HOST_LINUXPC
tomwalters@0 275 byteorderflag = DEC;
tomwalters@0 276 reversevideoflag = ON;
tomwalters@0 277 #endif
tomwalters@0 278
tomwalters@0 279 parsecommandline(argc, argv, inputfn, titlestring, fontname);
tomwalters@0 280
tomwalters@0 281 /*-----------------------------*/
tomwalters@0 282
tomwalters@0 283 /* Open Display: this also finds the screen size */
tomwalters@0 284 initialise_X_screen();
tomwalters@0 285
tomwalters@0 286 /*-----------------------------*/
tomwalters@0 287
tomwalters@0 288
tomwalters@0 289 if (xsyncflag == ON) {
tomwalters@0 290 XSynchronize(display, True);
tomwalters@0 291 fprintf(stderr, "XSynchronize on \n");}
tomwalters@0 292
tomwalters@0 293 inputfp = open_file(inputfn, stdin, READ);
tomwalters@0 294 header_bytes = readheader(inputfp, inputfn);
tomwalters@0 295
tomwalters@0 296 /*-----------------------------*/
tomwalters@0 297
tomwalters@0 298 /* define bytes_per_line of the XImage. This seems to be, at least on a
tomwalters@0 299 * Colour SS-10, to be
tomwalters@0 300 * (width-1)
tomwalters@0 301 * ( --------- +1 ) *4
tomwalters@0 302 * 32
tomwalters@0 303 * where the INTEGER part of the division is all that is needed.
tomwalters@0 304 *
tomwalters@0 305 * Examples:
tomwalters@0 306 * width=100 to 128 bytes=16 (100 is the smallest AIM window allowed.-
tomwalters@0 307 * 129 -- 160 20
tomwalters@0 308 * 161 -- 192 24
tomwalters@0 309 * 193 -- 224 28
tomwalters@0 310 */
tomwalters@0 311
tomwalters@0 312 reviewimage_bytesperline = (int) ((int) ((width_ctn -1) / 32) +1) *4;
tomwalters@0 313
tomwalters@0 314 /*-----------------------------*/
tomwalters@0 315
tomwalters@0 316 /* Allocate lots of space:
tomwalters@0 317 * no of frames by .ctn size
tomwalters@0 318 */
tomwalters@0 319
tomwalters@0 320 if (depthflag == MONO)
tomwalters@0 321 depth = 1;
tomwalters@0 322 else
tomwalters@0 323 depth = DefaultDepth(display, screen_num);
tomwalters@0 324
tomwalters@0 325 required_bytes = no_frames*height_ctn*reviewimage_bytesperline*depth;
tomwalters@0 326
tomwalters@0 327 if (verboseflag == ON) {
tomwalters@0 328 fprintf(stderr, "xreview : reserving %i * %i * %i = %i bytes.\n", no_frames, (height_ctn*reviewimage_bytesperline), depth, required_bytes); }
tomwalters@0 329
tomwalters@0 330 data_pointer = (char *) malloc((size_t) required_bytes);
tomwalters@0 331 if (data_pointer == NULL) {
tomwalters@0 332 fprintf(stderr, "xreview : unable to allocate %i bytes for XImage.\n", required_bytes);
tomwalters@0 333 fclose(inputfp);
tomwalters@0 334 exit(-1);}
tomwalters@0 335
tomwalters@0 336 /* sideways scroll */
tomwalters@0 337 if (sidewaysflag == ON) {
tomwalters@0 338 required_bytes = no_frames*height_ctn*reviewimage_bytesperline*depth;
tomwalters@0 339 if (verboseflag == ON) {
tomwalters@0 340 fprintf(stderr, "xreview : reserving %i * %i = %i bytes.\n", (no_frames*height_ctn*reviewimage_bytesperline), depth, required_bytes); }
tomwalters@0 341 data_pointer_sideways = (char *) malloc((size_t) required_bytes);
tomwalters@0 342 if (data_pointer_sideways == NULL) {
tomwalters@0 343 fprintf(stderr, "xreview : unable to allocate %i bytes for XImage.\n", required_bytes);
tomwalters@0 344 fclose(inputfp);
tomwalters@0 345 exit(-1);}}
tomwalters@0 346
tomwalters@0 347 /*-----------------------------*/
tomwalters@0 348
tomwalters@0 349 /* load .ctn data */
tomwalters@0 350 loaddata(inputfp);
tomwalters@0 351 close_files(inputfp);
tomwalters@0 352 if (animate_stop == 9999)
tomwalters@0 353 animate_stop = no_frames;
tomwalters@0 354
tomwalters@0 355 if (sidewaysflag == ON) {
tomwalters@0 356 for (x=location[0]; x<=location[0]+required_bytes-1; x++)
tomwalters@0 357 data_pointer_sideways[x] = data_pointer[x];}
tomwalters@0 358
tomwalters@0 359 /*-----------------------------*/
tomwalters@0 360
tomwalters@0 361 /* Find a font, in this order:
tomwalters@0 362 * 1. command-line
tomwalters@0 363 * 2. Times family
tomwalters@0 364 * 3. Lucida family.
tomwalters@0 365 * If can't find any, should crash.
tomwalters@0 366 */
tomwalters@0 367
tomwalters@0 368 font_info = NULL;
tomwalters@0 369
tomwalters@0 370 if ((strcmp(fontname, "") == 0 ) ||
tomwalters@0 371 ((font_info = XLoadQueryFont(display, fontname)) == NULL)) {
tomwalters@0 372 sprintf(fontname, "-adobe-times-medium-r-normal--%i-*-*-*-*-*-*-*", pointsize);
tomwalters@0 373 if ((font_info = XLoadQueryFont(display, fontname)) == NULL) {
tomwalters@0 374 sprintf(fontname, "-b&h-lucida-medium-r-normal-sans-%i-*-*-*-*-*-*-*", pointsize);
tomwalters@0 375 if ((font_info = XLoadQueryFont(display, fontname)) == NULL) {
tomwalters@0 376 fprintf(stderr, "xreview : unable to find fonts.\n");
tomwalters@0 377 exit(-1); }}}
tomwalters@0 378
tomwalters@0 379 /*-----------------------------*/
tomwalters@0 380
tomwalters@0 381 /* define a cursor */
tomwalters@0 382 cursor = XCreateFontCursor(display, XC_top_left_arrow);
tomwalters@0 383
tomwalters@0 384 /*-----------------------------*/
tomwalters@0 385
tomwalters@0 386 initialise_axes_window(inputfn, titlestring, inputfp, argv, argc);
tomwalters@0 387 XMapWindow(display, axes.win);
tomwalters@0 388
tomwalters@0 389 /* define the background pixmap */
tomwalters@0 390 stipple_pixmap = XCreatePixmapFromBitmapData(display, \
tomwalters@0 391 RootWindow(display, screen_num), stipple_a_bits, \
tomwalters@0 392 stipple_a_width, stipple_a_height, \
tomwalters@0 393 BlackPixel(display, screen_num), \
tomwalters@0 394 WhitePixel(display, screen_num), \
tomwalters@0 395 DefaultDepth(display, screen_num));
tomwalters@0 396
tomwalters@0 397 initialise_control_window(inputfn, titlestring, inputfp, argv, argc);
tomwalters@0 398 if (controlwindowflag == ON)
tomwalters@0 399 XMapWindow(display, control.win);
tomwalters@0 400
tomwalters@0 401 initialise_buttons();
tomwalters@0 402
tomwalters@0 403 initialise_image();
tomwalters@0 404
tomwalters@0 405 /*------------------------------*/
tomwalters@0 406
tomwalters@0 407
tomwalters@0 408
tomwalters@0 409 /*-----------------------------
tomwalters@0 410 * EVENT LOOP
tomwalters@0 411 *-----------------------------
tomwalters@0 412 */
tomwalters@0 413
tomwalters@0 414
tomwalters@0 415
tomwalters@0 416 while (1) {
tomwalters@0 417 XNextEvent(display, &report);
tomwalters@0 418
tomwalters@0 419 if (report.xany.window == axes.win)
tomwalters@0 420 switch_axes();
tomwalters@0 421 else if (report.xany.window == control.win)
tomwalters@0 422 switch_control();
tomwalters@0 423 else
tomwalters@0 424 switch_buttons();
tomwalters@0 425
tomwalters@0 426 } /* while */
tomwalters@0 427
tomwalters@0 428
tomwalters@0 429 /*---------------------------------------------------------*/
tomwalters@0 430
tomwalters@0 431
tomwalters@0 432 } /* main */
tomwalters@0 433
tomwalters@0 434
tomwalters@0 435
tomwalters@0 436
tomwalters@0 437
tomwalters@0 438 /*......................................................................*/
tomwalters@0 439 /*......................................................................*/
tomwalters@0 440
tomwalters@0 441
tomwalters@0 442
tomwalters@0 443
tomwalters@0 444
tomwalters@0 445 void parsecommandline(int argc, char *argv[], char inputfn[], char titlestring[], char fontname[])
tomwalters@0 446 {
tomwalters@0 447 int x=1, helpflag = OFF;
tomwalters@0 448 int control_width =0;
tomwalters@0 449 char control_size[MAX_STRING_LENGTH];
tomwalters@0 450
tomwalters@0 451 strcpy(control_size, "");
tomwalters@0 452
tomwalters@0 453 while (x < argc){
tomwalters@0 454 if (!strcmp(argv[x], "-input")) {strcpy(inputfn, argv[x+1]); x+=2;}
tomwalters@0 455 else if (!strcmp(argv[x], "-inp")) {strcpy(inputfn, argv[x+1]); x+=2;}
tomwalters@0 456 else if (!strcmp(argv[x], "-i")) {strcpy(inputfn, argv[x+1]); x+=2;}
tomwalters@0 457
tomwalters@0 458 else if (!strcmp(argv[x], "-help")) {helpflag = ON; x+=1;}
tomwalters@0 459 else if (!strcmp(argv[x], "-h")) {helpflag = ON; x+=1;}
tomwalters@0 460 else if (!strcmp(argv[x], "-verbose")) {verboseflag = ON; x+=1;}
tomwalters@0 461 else if (!strcmp(argv[x], "-ver")) {verboseflag = ON; x+=1;}
tomwalters@0 462 else if (!strcmp(argv[x], "-v")) {verboseflag = ON; x+=1;}
tomwalters@0 463
tomwalters@0 464 else if (!strcmp(argv[x], "-side")) {sidewaysflag = ON; x+=1;}
tomwalters@0 465 else if (!strcmp(argv[x], "-sideways")) {sidewaysflag = ON; x+=1;}
tomwalters@0 466 else if (!strcmp(argv[x], "-controls")) {controlwindowflag = ON; x+=1;}
tomwalters@0 467 else if (!strcmp(argv[x], "-con")) {controlwindowflag = ON; x+=1;}
tomwalters@0 468 else if (!strcmp(argv[x], "-c")) {controlwindowflag = ON; x+=1;}
tomwalters@0 469 else if (!strcmp(argv[x], "-controls_x")) {controls_xflag = ON; new_control_x = atoi(argv[x+1]); x+=2;}
tomwalters@0 470 else if (!strcmp(argv[x], "-cx")) {controls_xflag = ON; new_control_x = atoi(argv[x+1]); x+=2;}
tomwalters@0 471 else if (!strcmp(argv[x], "-controls_y")) {controls_yflag = ON; new_control_y = atoi(argv[x+1]); x+=2;}
tomwalters@0 472 else if (!strcmp(argv[x], "-cy")) {controls_yflag = ON; new_control_y = atoi(argv[x+1]); x+=2;}
tomwalters@0 473 else if (!strcmp(argv[x], "-image_x")) {axes_xflag = ON; new_axes_x = atoi(argv[x+1]); x+=2;}
tomwalters@0 474 else if (!strcmp(argv[x], "-ix")) {axes_xflag = ON; new_axes_x = atoi(argv[x+1]); x+=2;}
tomwalters@0 475 else if (!strcmp(argv[x], "-image_y")) {axes_yflag = ON; new_axes_y = atoi(argv[x+1]); x+=2;}
tomwalters@0 476 else if (!strcmp(argv[x], "-iy")) {axes_yflag = ON; new_axes_y = atoi(argv[x+1]); x+=2;}
tomwalters@0 477 else if (!strcmp(argv[x], "-controls_scale")) {scale = atof(argv[x+1]); x+=2;}
tomwalters@0 478 else if (!strcmp(argv[x], "-cscale")) {scale = atof(argv[x+1]); x+=2;}
tomwalters@0 479 else if (!strcmp(argv[x], "-controls_width")) {control_width = atoi(argv[x+1]); x+=2;}
tomwalters@0 480 else if (!strcmp(argv[x], "-cw")) {control_width = atoi(argv[x+1]); x+=2;}
tomwalters@0 481 else if (!strcmp(argv[x], "-controls_size")) {strcpy(control_size, argv[x+1]); x+=2;}
tomwalters@0 482 else if (!strcmp(argv[x], "-csize")) {strcpy(control_size, argv[x+1]); x+=2;}
tomwalters@0 483
tomwalters@0 484 else if (!strcmp(argv[x], "-display")) {strcpy(display_name, argv[x+1]); x+=2;}
tomwalters@0 485 else if (!strcmp(argv[x], "-d")) {strcpy(display_name, argv[x+1]); x+=2;}
tomwalters@0 486 else if (!strcmp(argv[x], "-font")) {strcpy(fontname, argv[x+1]); x+=2;}
tomwalters@0 487 else if (!strcmp(argv[x], "-fn")) {strcpy(fontname, argv[x+1]); x+=2;}
tomwalters@0 488 else if (!strcmp(argv[x], "-point")) {pointsize = atoi(argv[x+1]); x+=2;}
tomwalters@0 489 else if (!strcmp(argv[x], "-p")) {pointsize = atoi(argv[x+1]); x+=2;}
tomwalters@0 490
tomwalters@0 491 else if (!strcmp(argv[x], "-wait")) {waittime_millisecs = atol(argv[x+1]); x+=2;}
tomwalters@0 492 else if (!strcmp(argv[x], "-w")) {waittime_millisecs = atol(argv[x+1]); x+=2;}
tomwalters@0 493 else if (!strcmp(argv[x], "-speed")) {waittime_millisecs = atol(argv[x+1]); x+=2;}
tomwalters@0 494 else if (!strcmp(argv[x], "-start")) {animate_start = atoi(argv[x+1]); x+=2;}
tomwalters@0 495 else if (!strcmp(argv[x], "-stop")) {animate_stop = atoi(argv[x+1]); x+=2;}
tomwalters@0 496 else if (!strcmp(argv[x], "-skip")) {animate_skip = atoi(argv[x+1]); x+=2;}
tomwalters@0 497 else if (!strcmp(argv[x], "-frame")) {frame = atoi(argv[x+1]); x+=2;}
tomwalters@0 498 else if (!strcmp(argv[x], "-fra")) {frame = atoi(argv[x+1]); x+=2;}
tomwalters@0 499
tomwalters@0 500 else if (!strcmp(argv[x], "-title")) {titleflag = ON; strcpy(titlestring, argv[x+1]); x+=2;}
tomwalters@0 501 else if (!strcmp(argv[x], "-tit")) {titleflag = ON; strcpy(titlestring, argv[x+1]); x+=2;}
tomwalters@0 502 else if (!strcmp(argv[x], "-t")) {titleflag = ON; strcpy(titlestring, argv[x+1]); x+=2;}
tomwalters@0 503 else if (!strcmp(argv[x], "-mono")) {depthflag = MONO; x+=1;}
tomwalters@0 504 else if (!strcmp(argv[x], "-colour")) {depthflag = COLOUR; planemask = AllPlanes; x+=1; }
tomwalters@0 505 else if (!strcmp(argv[x], "-planemask")) {planemask = atoi(argv[x+1]); x+=2;}
tomwalters@0 506 else if (!strcmp(argv[x], "-xsync")) {xsyncflag = ON; x+=1;}
tomwalters@0 507 else if (!strcmp(argv[x], "-rv")) {if (reversevideoflag == ON)
tomwalters@0 508 reversevideoflag = OFF;
tomwalters@0 509 else
tomwalters@0 510 reversevideoflag = ON;
tomwalters@0 511 x+=1;}
tomwalters@0 512 else if (!strcmp(argv[x], "-lsb")) {byteorderflag = DEC; x+=1;}
tomwalters@0 513 else if (!strcmp(argv[x], "-msb")) {byteorderflag = SUN; x+=1;}
tomwalters@0 514 else if (!strcmp(argv[x], "-dec")) {byteorderflag = DEC; reversevideoflag = ON; x+=1;}
tomwalters@0 515 else if (!strcmp(argv[x], "-sun")) {byteorderflag = SUN; reversevideoflag = OFF; x+=1;}
tomwalters@0 516 else if (x = (argc-1)) {strcpy(inputfn, argv[x]); x+=1;}
tomwalters@0 517
tomwalters@0 518 else {fprintf(stderr, "xreview: unknown option %s\n", argv[x]);
tomwalters@0 519 exit(-1);}
tomwalters@0 520
tomwalters@0 521 }
tomwalters@0 522
tomwalters@0 523 if (helpflag == ON)
tomwalters@0 524 {
tomwalters@0 525 fprintf(stderr, "\n");
tomwalters@0 526 fprintf(stderr, "--------------------------------------------------------------------------------\n");
tomwalters@0 527 fprintf(stderr, " xreview\n");
tomwalters@0 528 fprintf(stderr, "--------------------------------------------------------------------------------\n\n");
tomwalters@0 529 fprintf(stderr, " usage: xreview -input 'filename.ctn' <options> \n");
tomwalters@0 530 fprintf(stderr, " or xreview <options> 'filename.ctn' \n");
tomwalters@0 531 fprintf(stderr, " or cat 'filename.ctn' | xreview <options> \n\n\n");
tomwalters@0 532 fprintf(stderr, " Command line options Abbrev.\n");
tomwalters@0 533 fprintf(stderr, "--------------------------------------------------------------------------------\n");
tomwalters@0 534 fprintf(stderr, "-input <.ctn file> Input file (default = stdin). -i\n");
tomwalters@0 535 fprintf(stderr, "\n");
tomwalters@0 536 fprintf(stderr, "-controls Map Controls window. -con\n");
tomwalters@0 537 fprintf(stderr, "-controls_x <int> Controls window position (pixels). -cx\n");
tomwalters@0 538 fprintf(stderr, "-controls_y <int> Controls window position (pixels). -cy\n");
tomwalters@0 539 fprintf(stderr, "-controls_width <int> Controls window width (pixels). -cw\n");
tomwalters@0 540 fprintf(stderr, "-controls_scale <flt> Scale factor for size of Controls Window. -cscale\n");
tomwalters@0 541 fprintf(stderr, "-controls_size Controls Window size: 'tiny', 'small' or 'normal'. -csize\n");
tomwalters@0 542 fprintf(stderr, "-image_x <int> Image position (pixels). -ix\n");
tomwalters@0 543 fprintf(stderr, "-image_y <int> Image position (pixels). -iy\n");
tomwalters@0 544 fprintf(stderr, "\n");
tomwalters@0 545 fprintf(stderr, "-display <string> X Display server to use. -d\n");
tomwalters@0 546 fprintf(stderr, "-font <string> Font. -fn\n");
tomwalters@0 547 fprintf(stderr, "-point <int> Point-size of default font (Times, medium weight). -p\n");
tomwalters@0 548 fprintf(stderr, "-title <string> Title of Image window & icon. -t\n");
tomwalters@0 549 fprintf(stderr, "-mono Assume Monochrome (single-plane) cartoons. (default) \n");
tomwalters@0 550 fprintf(stderr, "-colour Assume Colour (multiplane) cartoons. \n");
tomwalters@0 551 fprintf(stderr, "-planemask <int> Value of PlaneMask for copying XImage (default=1) \n");
tomwalters@0 552 fprintf(stderr, "-rv Reverse-video the cartoon window colours. \n");
tomwalters@0 553 fprintf(stderr, "-lsb Assume cartoon's bit & byte orders are LSBFirst (ie, DEC).\n");
tomwalters@0 554 fprintf(stderr, "-msb Assume cartoon's bit & byte orders are MSBFirst (ie, Sun).\n");
tomwalters@0 555 fprintf(stderr, "-dec Alias for -lsb -rv \n");
tomwalters@0 556 fprintf(stderr, "-sun Alias for -msb \n");
tomwalters@0 557 fprintf(stderr, "\n");
tomwalters@0 558 fprintf(stderr, "-speed <int> Wait-time between frames (msecs) (default = %i). -speed\n", waittime_millisecs);
tomwalters@0 559 fprintf(stderr, "-start <int> Animation start (frames) (default=1). -start\n");
tomwalters@0 560 fprintf(stderr, "-stop <int> Animation stop (frames) (default=last frame). -stop\n");
tomwalters@0 561 fprintf(stderr, "-skip <int> Animation skip (frames) (default=1). -skip\n");
tomwalters@0 562 fprintf(stderr, "-frame <int> Initial display frame (default=1). -fra\n");
tomwalters@0 563 fprintf(stderr, "-sideways Scroll cartoon sideways (right->left) -side\n");
tomwalters@0 564 fprintf(stderr, "\n");
tomwalters@0 565 fprintf(stderr, "-verbose Print some running information (to stderr). -v\n");
tomwalters@0 566 fprintf(stderr, "-help Print this page (to stderr). -h\n");
tomwalters@0 567 fprintf(stderr, "\n\n" );
tomwalters@0 568 fprintf(stderr, " Image Window Controls \n");
tomwalters@0 569 fprintf(stderr, "--------------------------------------------------------------------------------\n");
tomwalters@0 570 fprintf(stderr, " Left button Animate cartoon. \n");
tomwalters@0 571 fprintf(stderr, " Middle button Map Controls window. \n");
tomwalters@0 572 fprintf(stderr, " Right button Quit. \n\n");
tomwalters@0 573 fprintf(stderr, " SPACE or RET Animate cartoon. \n");
tomwalters@0 574 fprintf(stderr, " F or f Set speed faster by x2. \n");
tomwalters@0 575 fprintf(stderr, " S or s Set speed slower by x2. \n");
tomwalters@0 576 fprintf(stderr, " N or n Next frame. \n");
tomwalters@0 577 fprintf(stderr, " P or p Previous frame. \n");
tomwalters@0 578 fprintf(stderr, " Q or q Quit. \n");
tomwalters@0 579 fprintf(stderr, "\n\n");
tomwalters@0 580 exit(-1);}
tomwalters@0 581
tomwalters@0 582 if (strcmp(control_size, "") != 0){
tomwalters@0 583 if (strcmp(control_size, "normal") == 0) {
tomwalters@0 584 scale=1.00;
tomwalters@0 585 pointsize=18;}
tomwalters@0 586 else if (strcmp(control_size, "small") == 0) {
tomwalters@0 587 scale=0.80;
tomwalters@0 588 pointsize=14;}
tomwalters@0 589 else if (strcmp(control_size, "tiny") == 0) {
tomwalters@0 590 scale=0.60;
tomwalters@0 591 pointsize=10;}
tomwalters@0 592 else {
tomwalters@0 593 fprintf(stderr, "xreview : illegal control_size value.\n");
tomwalters@0 594 exit(-1);}
tomwalters@0 595 }
tomwalters@0 596
tomwalters@0 597 if (control_width != 0)
tomwalters@0 598 scale = (double) control_width / CONTROL_WIDTH;
tomwalters@0 599
tomwalters@0 600
tomwalters@0 601 }
tomwalters@0 602
tomwalters@0 603
tomwalters@0 604 /* The end.*/
tomwalters@0 605
tomwalters@0 606
tomwalters@0 607 /*-------------------------------------------------------------------------*/
tomwalters@0 608 /*-------------------------------------------------------------------------*/
tomwalters@0 609
tomwalters@0 610
tomwalters@0 611
tomwalters@0 612
tomwalters@0 613
tomwalters@0 614