void reset_grafx() { #ifdef IRIS #undef setvaluator setvaluator(MOUSEX,getgdesc(GD_XPMAX)/2,0,getgdesc(GD_XPMAX)); setvaluator(MOUSEY,getgdesc(GD_YPMAX)/2,0,getgdesc(GD_YPMAX)); #define setvaluator gl_setvaluator attachcursor(MOUSEX,MOUSEY); setcursor(0,0,0); curson(); gexit(); #endif }
/* * Allocate a new volume structure and return a pointer to it. If we * can't do volume rendering return NULL. * Input: nr, nc, nl - dimensions of largest volume we'll encounter. * Return: pointer to volume struct or NULL */ struct volume *alloc_volume( Context ctx, int nr, int nc, int nl ) { int volren = 0; struct volume *v = NULL; if (ctx->dpy_ctx->Projection == PROJ_CYLINDRICAL || ctx->dpy_ctx->Projection == PROJ_SPHERICAL){ ctx->dpy_ctx->VolRender = 0; return 0; } if (nl <= 1){ ctx->dpy_ctx->VolRender = 0; return 0; /* no volume variables */ } #if defined (HAVE_SGI_GL) || defined (DENALI) alphabits = getgdesc( GD_BLEND ); if (alphabits==0) { ctx->dpy_ctx->VolRender = 0; /* no alpha support means no volume rendering */ return NULL; } volren = 1; #endif #if defined(HAVE_OPENGL) volren = 1; #endif /* MJK 12.15.98 */ #ifdef HAVE_PEX volren = 1; #endif if (volren) { /* 11Aug06 Phil McDonald */ v = (struct volume *) allocate (ctx, sizeof (struct volume)); v->itime = -1; v->ivar = -1; v->lock = 0; v->valid = 0; v->vertex = NULL; v->index = NULL; v->private_data = NULL; /* 15Feb07 Phil McDonald */ v->nx = 0; v->ny = 0; v->nz = 0; /* end PM */ } ctx->dpy_ctx->VolRender = (v != NULL); return v; }
int main(int argc, char* argv[]) { int c; extern int optind; extern char* optarg; while ((c = getopt(argc, argv, "c:p:r:")) != -1) switch (c) { case 'b': /* save as b&w */ photometric = PHOTOMETRIC_MINISBLACK; break; case 'c': /* compression scheme */ if (streq(optarg, "none")) compression = COMPRESSION_NONE; else if (streq(optarg, "packbits")) compression = COMPRESSION_PACKBITS; else if (strneq(optarg, "jpeg", 4)) { char* cp = strchr(optarg, ':'); if (cp && isdigit(cp[1])) quality = atoi(cp+1); if (cp && strchr(cp, 'r')) jpegcolormode = JPEGCOLORMODE_RAW; compression = COMPRESSION_JPEG; } else if (strneq(optarg, "lzw", 3)) { char* cp = strchr(optarg, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_LZW; } else usage(); break; case 'p': /* planar configuration */ if (streq(optarg, "separate")) config = PLANARCONFIG_SEPARATE; else if (streq(optarg, "contig")) config = PLANARCONFIG_CONTIG; else usage(); break; case 'r': /* rows/strip */ rowsperstrip = atoi(optarg); break; case '?': usage(); /*NOTREACHED*/ } if (argc - optind != 1 && argc - optind != 5) usage(); xmaxscreen = getgdesc(GD_XPMAX)-1; ymaxscreen = getgdesc(GD_YPMAX)-1; foreground(); noport(); winopen("tiffsv"); if (argc - optind == 5) tiffsv(argv[optind], atoi(argv[optind+1]), atoi(argv[optind+2]), atoi(argv[optind+3]), atoi(argv[optind+4])); else tiffsv(argv[optind], 0, xmaxscreen, 0, ymaxscreen); return (0); }
/* OK w95 */ void mainEventLoop() { short sVal, sXCurrent, sYCurrent; long lDevice; int i=0; int state = FALSE; short attached = 1; short value; int dev; int pupval; // make_all(); //init_menu(); nCurrentDir = DIR_NONE; czclear(0x404040, getgdesc(GD_ZMAX)); while (TRUE) { if (qtest()) { lDevice = qread(&sVal); switch (lDevice) { case INPUTCHANGE: #ifdef DOFF printf(" %d, %d, %d\n", Win_ids[0], Win_ids[1], sVal); #endif if ( sVal != 0 ) Input_win = sVal; else Input_win = -1; break; case REDRAW: if ( sVal == Win_ids[1] && Win_ids[1] != -1 ) vDrawHelpScene(); else if ( sVal == Win_ids[0] ) { reshapeviewport(); getsize(&nWinWidth, &nWinHeight); getorigin(&nXWinOrigin, &nYWinOrigin); } break; case RIGHTMOUSE: pupval = dopup(mainmenu); break; case SPACEKEY: state = TRUE; i++; if ( i == 4 ) subEventLoop(); break; case RKEY: if ( Last_Actions[FIRE] == TRUE ) vEventLoop(&vDrawTitle); break; case QKEY: if ( Input_win == Win_ids[1] ) { winclose(Input_win); Win_ids[1] != -1; } else if ( Input_win == Win_ids[0] ) { winclose(Win_ids[0]); if ( Win_ids[1] != -1 ) winclose(Win_ids[1]); exit(0); } break; default: break; } } getdev(DR_NUM_BUT, Devs, Last_Actions); vDrawTitle(state); } }
/* half OK w95 */ void subEventLoop() { short sVal, sXCurrent, sYCurrent; long lDevice; float tmp; nCurrentDir = DIR_NONE; czclear(0x404040, getgdesc(GD_ZMAX)); strcpy(Message, ReadyMesg); vDrawScene(); qreset(); while (TRUE) { if (qtest()) { lDevice = qread(&sVal); switch (lDevice) { case INPUTCHANGE: #ifdef DOFF printf(" %d, %d, %d\n", Win_ids[0], Win_ids[1], sVal); #endif if ( sVal != 0 ) Input_win = sVal; else Input_win = -1; break; case REDRAW: if ( sVal == Win_ids[1] && Win_ids[1] != -1 ) vDrawHelpScene(); else if ( sVal == Win_ids[0] ) { winset(Win_ids[0]); reshapeviewport(); getsize(&nWinWidth, &nWinHeight); getorigin(&nXWinOrigin, &nYWinOrigin); tmp = Speed; Speed = 0.0; vDrawScene(); Speed = tmp; } break; case RIGHTMOUSE: dopup(mainmenu); break; case SPACEKEY: if ( EMode == FALSE ) { p1EventLoop(); strcpy(Message, ""); } if ( EMode == TRUE ) /* game over */ { vDrawOverScene(); } break; case RKEY: if ( Last_Actions[FIRE] == TRUE ) vEventLoop((&vDrawScene)); break; case QKEY: if ( Input_win == Win_ids[1] ) { winclose(Input_win); Win_ids[1] != -1; } else if ( Input_win == Win_ids[0] ) { winclose(Win_ids[0]); if ( Win_ids[1] != -1 ) winclose(Win_ids[1]); exit(0); } break; default: break; } } else getdev(DR_NUM_BUT, Devs, Last_Actions); } }
/* * Allocate a new volume structure and return a pointer to it. If we * can't do volume rendering return NULL. * Input: nr, nc, nl - dimensions of largest volume we'll encounter. * Return: pointer to volume struct or NULL */ struct volume *alloc_volume( Context ctx, int nr, int nc, int nl ) { int volren = 0; struct volume *v = NULL; if (ctx->dpy_ctx->Projection == PROJ_CYLINDRICAL || ctx->dpy_ctx->Projection == PROJ_SPHERICAL){ ctx->dpy_ctx->VolRender = 0; return 0; } if (nl <= 1){ ctx->dpy_ctx->VolRender = 0; return 0; /* no volume variables */ } #if defined (HAVE_SGI_GL) || defined (DENALI) alphabits = getgdesc( GD_BLEND ); if (alphabits==0) { ctx->dpy_ctx->VolRender = 0; /* no alpha support means no volume rendering */ return NULL; } volren = 1; #endif #if defined(HAVE_OPENGL) volren = 1; #endif /* MJK 12.15.98 */ #ifdef HAVE_PEX volren = 1; #endif if (volren) { v = (struct volume *) malloc( sizeof(struct volume) ); /* initialize the volume struct */ v->valid = 0; /* No matter which way we slice it, we need the same size arrays for */ /* storing the vertices and colors. */ v->vertex = (float *) allocate( ctx, nl*nr*nc*3*sizeof(float) ); v->index = (uint_1 *) allocate( ctx, nl*nr*nc*sizeof(uint_1) ); if (!v->vertex || !v->index) { printf("WARNING: insufficient memory for volume rendering (%d bytes needed)\n", nl * nr * nc * ((int) (3*sizeof(float)+sizeof(uint_1))) ); ctx->dpy_ctx->VolRender = 0; return NULL; } v->oldnr = nr; v->oldnc = nc; v->oldnl = nl; /* MJK 12.15.98 */ #ifdef HAVE_PEX v->dir = -1; #endif } if (v){ ctx->dpy_ctx->VolRender = 1; } else{ ctx->dpy_ctx->VolRender = 0; } return v; }
/* init_matplot: initialises distmat plotting. The matrix size should * be Row x Col (which is the min. size in pixels). Title is put on the top * of the window by the window manager. Xorig and Yorig specify * the lower left corner position of the window: if either of them * is negative, then the window will be positioned interactively. * Return value: the 'gid' window ID number. */ long init_matplot(unsigned int Row, unsigned int Col, char *Title, long Xorig, long Yorig) { const unsigned int MINSIZE=500; long Gid, Xsize, Ysize, Xmax, Ymax; float Xmagnif, Ymagnif; unsigned int Rs, Cs; if (!Row) Row=MINSIZE; if (!Col) Col=MINSIZE; Xmagnif=(float)Col/MINSIZE; Ymagnif=(float)Row/MINSIZE; Rs=Row; Cs=Col; if (Col<=Row) { if (Xmagnif<1.0) { Cs=MINSIZE; Rs=round_id(Row/Xmagnif); } } else { if (Ymagnif<1.0) { Rs=MINSIZE; Cs=round_id(Col/Ymagnif); } } foreground(); /* enable signal catch etc. */ Xmax=getgdesc(GD_XPMAX); Ymax=getgdesc(GD_YPMAX); keepaspect(Col, Row); /* Xmax,Ymax: the maximal screen coordinates */ Xmax=getgdesc(GD_XPMAX); Ymax=getgdesc(GD_YPMAX); if (Xorig+Cs>Xmax) Xorig=Xmax-Cs; if (Yorig+Rs>Ymax) Yorig=Ymax-Rs; if (Xorig>=0 && Yorig>=0) prefposition(Xorig, Xorig+Cs, Yorig, Yorig+Rs); iconsize(84, 67); Gid=winopen(Title); /* create window */ RGBmode(); /* check if double buffering is available */ if (Dblbuffer=getgdesc(GD_BITS_NORM_DBL_BLUE)) { doublebuffer(); gconfig(); } else fputs("init_matplot: single-buffer mode\n", stderr); /* enable resize */ winconstraints(); keepaspect(Col, Row); winconstraints(); getsize(&Xsize, &Ysize); /* scale drawing into window */ Xmagnif=(float)Xsize/Col; Ymagnif=(float)Ysize/Row; pushmatrix(); scale(Xmagnif, Ymagnif, 1.0); cpack(RGB_BLACK); clear(); /* clears window to black */ if (Dblbuffer) { swapbuffers(); cpack(RGB_BLACK); clear(); } /* queue input events */ qdevice(ESCKEY); qdevice(WINFREEZE); qdevice(WINTHAW); qdevice(REDRAWICONIC); qdevice(WINQUIT); return(Gid); }