static void read_color_span( GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[] ) { OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx; GLuint i; GLuint *ptr4 = PIXELADDR4(x,y); for (i=0;i<n;i++) { GLuint pixel = *ptr4++; red[i] = UNPACK_RED(pixel); green[i] = UNPACK_GREEN(pixel); blue[i] = UNPACK_BLUE(pixel); alpha[i] = UNPACK_ALPHA(pixel); } }
static void read_color_pixels( GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLubyte red[], GLubyte green[], GLubyte blue[], GLubyte alpha[], const GLubyte mask[] ) { OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx; GLuint i; for (i=0;i<n;i++) { if (mask[i]) { GLuint *ptr4 = PIXELADDR4(x[i],y[i]); GLuint pixel = *ptr4; red[i] = UNPACK_RED(pixel); green[i] = UNPACK_GREEN(pixel); blue[i] = UNPACK_BLUE(pixel); alpha[i] = UNPACK_ALPHA(pixel); } } }
static void write_monocolor_pixels3( GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte mask[] ) { OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx; GLuint i; GLint rind = osmesa->rind; GLint gind = osmesa->gind; GLint bind = osmesa->bind; GLubyte rval = UNPACK_RED(osmesa->pixel); GLubyte gval = UNPACK_GREEN(osmesa->pixel); GLubyte bval = UNPACK_BLUE(osmesa->pixel); for (i=0;i<n;i++) { if (mask[i]) { GLubyte *ptr3 = PIXELADDR3(x[i],y[i]); ptr3[rind] = rval; ptr3[gind] = gval; ptr3[bind] = bval; } } }
/* * Save colors to a file. * * File format is ASCII: * <table_size> <minval> <maxval> <curve> <bias> * <r> <g> <b> <a> - n lines of rgba values as integers in [0,255] * ..... * <r> <g> <b> <a> */ static void save_colors( LUI_COLORBAR *cb ) { char filename[1000]; /* 16Nov05 Phil McDonald */ char *p_tmp; /* end PM */ FILE *f; int i; printf("Enter filename to save colors to: "); fgets(filename,1000,stdin); /* 16Nov05 Phil McDonald */ if ((p_tmp = strchr (filename, '\n')) != NULL) *p_tmp = '\0'; /* end PM */ if (filename[0]==0) { printf("Save aborted\n"); return; } f = fopen( filename, "w" ); if (!f) { printf("Error: couldn't open %s for writing\n", filename ); return; } fprintf( f, "%d %f %f %f %f\n", cb->table_size, cb->minval, cb->maxval, cb->params[CURVE], cb->params[BIAS] ); for (i=0;i<cb->table_size;i++) { int r, g, b, a; r = UNPACK_RED( cb->table[i] ); g = UNPACK_GREEN( cb->table[i] ); b = UNPACK_BLUE( cb->table[i] ); a = UNPACK_ALPHA( cb->table[i] ); fprintf( f, "%d %d %d %d\n", r, g, b, a ); } fclose(f); printf("Done\n"); }
static void clear( GLcontext *ctx, GLboolean all, GLint x, GLint y, GLint width, GLint height ) { OSMesaContext osmesa = (OSMesaContext) ctx->DriverCtx; if (osmesa->format==OSMESA_COLOR_INDEX) { if (all) { /* Clear whole CI buffer */ MEMSET(osmesa->buffer, osmesa->clearpixel, osmesa->rowlength*osmesa->height); } else { /* Clear part of CI buffer */ GLuint i, j; for (i=0;i<height;i++) { GLubyte *ptr1 = PIXELADDR1( x, (y+i) ); for (j=0;j<width;j++) { *ptr1++ = osmesa->clearpixel; } } } } else if ((osmesa->format==OSMESA_RGB)||(osmesa->format==OSMESA_BGR)) { GLubyte rval = UNPACK_RED(osmesa->clearpixel); GLubyte gval = UNPACK_GREEN(osmesa->clearpixel); GLubyte bval = UNPACK_BLUE(osmesa->clearpixel); GLint rind = osmesa->rind; GLint gind = osmesa->gind; GLint bind = osmesa->bind; if (all) { GLuint i, n; GLubyte *ptr3 = (GLubyte *) osmesa->buffer; /* Clear whole RGB buffer */ n = osmesa->rowlength * osmesa->height; for (i=0;i<n;i++) { ptr3[rind] = rval; ptr3[gind] = gval; ptr3[bind] = bval; ptr3 += 3; } } else { /* Clear part of RGB buffer */ GLuint i, j; for (i=0;i<height;i++) { GLubyte *ptr3 = PIXELADDR3( x, (y+i) ); for (j=0;j<width;j++) { ptr3[rind] = rval; ptr3[gind] = gval; ptr3[bind] = bval; ptr3 += 3; } } } } else { if (all) { /* Clear whole RGBA buffer */ GLuint i, n, *ptr4; n = osmesa->rowlength * osmesa->height; ptr4 = (GLuint *) osmesa->buffer; for (i=0;i<n;i++) { *ptr4++ = osmesa->clearpixel; } } else { /* Clear part of RGBA buffer */ GLuint i, j; for (i=0;i<height;i++) { GLuint *ptr4 = PIXELADDR4( x, (y+i) ); for (j=0;j<width;j++) { *ptr4++ = osmesa->clearpixel; } } } } }
/* * Save current graphics and colors to the 'savefile' as a Tcl script. * Input: savefile - filename to save to. * Return: 0 for success, * VIS5D_BAD_VALUE if unable to open file * VIS5D_FAIL if error while writing file. */ int tcl_save( int index, const char *savefile ) { FILE *f; int cyo, chowmany, cwhichones[VIS5D_MAX_CONTEXTS]; int var, i, k; int numvars; float r, g, b, a; char varname[20]; vis5d_get_num_of_ctxs_in_display( index, &chowmany, cwhichones); f = fopen(savefile,"w"); if (!f) { return VIS5D_BAD_VALUE; } /* Prolog */ fprintf(f,"#Vis5D 4.3 Tcl save file\n\n"); for ( cyo = 0; cyo < chowmany; cyo++){ int vindex = cwhichones[cyo]; vis5d_get_ctx_numvars( cwhichones[cyo], &numvars ); /* misc colors */ fprintf(f,"\n#Box color\n"); vis5d_get_color( index, VIS5D_BOX, 0, &r, &g, &b, &a ); fprintf(f,"vis5d_set_color $dtx VIS5D_BOX 0 %15.7g %15.7g %15.7g %15.7g\n", r,g,b,a ); fprintf(f,"\n#Light map color\n"); vis5d_get_color( index, VIS5D_LIGHT_MAP, 0, &r, &g, &b, &a ); fprintf(f,"vis5d_set_color $dtx VIS5D_LIGHT_MAP 0 %15.7g %15.7g %15.7g %15.7g\n", r,g,b,a ); fprintf(f,"\n#Dark map color\n"); vis5d_get_color( index, VIS5D_DARK_MAP, 0, &r, &g, &b, &a ); fprintf(f,"vis5d_set_color $dtx VIS5D_DARK_MAP 0 %15.7g %15.7g %15.7g %15.7g\n", r,g,b,a ); fprintf(f,"\n#Background color\n"); vis5d_get_color( index, VIS5D_BACKGROUND, 0, &r, &g, &b, &a ); fprintf(f, "vis5d_set_color $dtx VIS5D_BACKGROUND 0 %15.7g %15.7g %15.7g %15.7g\n", r,g,b,a ); /* Text labels */ fprintf(f,"\n#Text labels\n"); { int i = 1; int x, y; char label[1000]; while (vis5d_get_label( index, i, &x, &y, label )==0) { fprintf(f,"vis5d_make_label $dtx %d %d \"%s\"\n", x, y, label ); i++; } } /* View matrix */ fprintf(f,"\n#Viewing matrix\n"); { float mat[4][4]; int i, j; vis5d_get_matrix( index, mat ); fprintf(f,"vis5d_set_matrix $dtx {"); for (i=0;i<4;i++) { for (j=0;j<4;j++) { fprintf(f," %g", mat[i][j] ); } } fprintf(f," }\n"); } /* Camera */ fprintf(f,"\n#Camera\n"); { int perspec; float front, zoom; vis5d_get_camera( index, &perspec, &front, &zoom ); fprintf(f,"vis5d_set_camera $dtx %d %g %g\n", perspec, front, zoom ); } /* Cloned and computed physical variables */ fprintf(f,"\n#Cloned or computed variables\n"); for (var=0; var<numvars; var++) { int type; vis5d_get_var_type( cwhichones[cyo], var, &type ); if (type==VIS5D_CLONE) { int vartoclone; char origname[20], clonename[20]; vis5d_get_ctx_var_name( cwhichones[cyo], var, origname ); vis5d_get_var_info( cwhichones[cyo], var, (void*) &vartoclone ); vis5d_get_ctx_var_name( cwhichones[cyo], vartoclone, clonename ); if (cyo == 0) { fprintf(f,"vis5d_make_clone_variable $ctx \"%s\" \"%s\"\n", origname, clonename ); } else { fprintf(f,"vis5d_make_clone_variable %d \"%s\" \"%s\"\n", cwhichones[cyo], origname, clonename ); } } else if (type==VIS5D_EXT_FUNC) { char funcname[100]; vis5d_get_var_info( cwhichones[cyo], var, (void*) funcname ); fprintf(f,"vis5d_compute_ext_func $dtx \"%s\"\n", funcname ); } else if (type==VIS5D_EXPRESSION) { char expr[100]; vis5d_get_var_info( cwhichones[cyo], var, (void*) expr ); fprintf(f,"vis5d_make_expr_var $dtx \"%s\"\n", expr ); } } /* Isosurfaces */ fprintf(f,"\n#Isosurfaces\n"); for (var=0; var<numvars; var++) { float isolevel, min, max; int colorvarowner, colorvar; vis5d_get_isosurface( cwhichones[cyo], var, &isolevel ); vis5d_get_ctx_var_range( cwhichones[cyo], var, &min, &max ); vis5d_get_isosurface_color_var( cwhichones[cyo], var, &colorvarowner, &colorvar ); vis5d_get_ctx_var_name( cwhichones[cyo], var, varname ); if (isolevel!=min) { if (cyo == 0) { fprintf(f,"vis5d_set_isosurface $ctx \"%s\" %g\n", varname, isolevel); } else { fprintf(f,"vis5d_set_isosurface %d \"%s\" %g\n", cwhichones[cyo], varname, isolevel); } if (colorvar>-1) { char colorvarname[20]; vis5d_get_ctx_var_name( colorvarowner, colorvar, colorvarname ); if (cyo == 0) { fprintf(f,"vis5d_set_isosurface_color_var_and_owner $ctx \"%s\" %d \"%s\"\n", varname, colorvarowner, colorvarname ); } else { fprintf(f,"vis5d_set_isosurface_color_var_and_owner %d \"%s\" %d \"%s\"\n", cwhichones[cyo], varname, colorvarowner, colorvarname ); } } /* command to recompute the isosurface */ if (cyo == 0) { fprintf(f,"vis5d_make_isosurface $ctx VIS5D_ALL_TIMES \"%s\" 0\n", varname ); } else { fprintf(f,"vis5d_make_isosurface %d VIS5D_ALL_TIMES \"%s\" 0\n", cwhichones[cyo], varname ); } } if (vis5d_enable_graphics(cwhichones[cyo],VIS5D_ISOSURF,var,VIS5D_GET)){ if (cyo == 0) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_ISOSURF %d VIS5D_ON\n", var); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_ISOSURF %d VIS5D_ON\n", cwhichones[cyo], var); } } /* WLH 10 Nov 98 */ else { if (cyo == 0) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_ISOSURF %d VIS5D_OFF\n", var); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_ISOSURF %d VIS5D_OFF\n", cwhichones[cyo], var); } } } /* Horizontal contour slices */ fprintf(f,"\n#Horizontal contour slices\n"); for (var=0;var<numvars;var++) { float interval, low, high, level; vis5d_get_hslice( vindex, var, &interval, &low, &high, &level ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_hslice $ctx \"%s\" %g %g %g %g\n", varname, interval, low, high, level ); } else { fprintf(f,"vis5d_set_hslice %d \"%s\" %g %g %g %g\n",vindex, varname, interval, low, high, level ); } if (vis5d_enable_graphics(vindex, VIS5D_HSLICE, var, VIS5D_GET)){ if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_HSLICE %d VIS5D_ON\n", var); fprintf(f,"vis5d_make_hslice $ctx VIS5D_ALL_TIMES %d 1\n", var ); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_HSLICE %d VIS5D_ON\n", vindex, var); fprintf(f,"vis5d_make_hslice %d VIS5D_ALL_TIMES %d 1\n", vindex, var ); } } /* WLH 10 Nov 98 */ else { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_HSLICE %d VIS5D_OFF\n", var); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_HSLICE %d VIS5D_OFF\n", vindex, var); } } /* MJK 12.04.98 begin */ if (vis5d_enable_sfc_graphics (index, VIS5D_HSLICE, var, VIS5D_GET)== VIS5D_ON){ if (vindex == cwhichones[0]) { /* MJK 3.29.99 fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HSLICE %s VIS5D_ON\n",var); */ fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HSLICE %d VIS5D_ON\n",var); } } else{ if (vindex == cwhichones[0]) { /* MJK 3.29.99 fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HSLICE %s VIS5D_OFF\n",var); */ fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HSLICE %d VIS5D_OFF\n",var); } } /* MJK 12.04.98 end */ } /* Vertical contour slices */ fprintf(f,"\n#Vertical contour slices\n"); for (var=0;var<numvars;var++) { float interval, low, high, r0, c0, r1, c1; vis5d_get_vslice( vindex, var, &interval, &low, &high, &r0,&c0, &r1,&c1 ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_vslice $ctx \"%s\" %g %g %g %g %g %g %g\n", varname, interval, low, high, r0,c0, r1,c1 ); } else { fprintf(f,"vis5d_set_vslice %d \"%s\" %g %g %g %g %g %g %g\n", vindex, varname, interval, low, high, r0,c0, r1,c1 ); } if (vis5d_enable_graphics(vindex, VIS5D_VSLICE, var, VIS5D_GET)){ if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_VSLICE %d VIS5D_ON\n", var); fprintf(f,"vis5d_make_vslice $ctx VIS5D_ALL_TIMES %d 1\n", var ); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_VSLICE %d VIS5D_ON\n", vindex, var); fprintf(f,"vis5d_make_vslice %d VIS5D_ALL_TIMES %d 1\n", vindex, var ); } } /* WLH 10 Nov 98 */ else { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_VSLICE %d VIS5D_OFF\n", var); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_VSLICE %d VIS5D_OFF\n", vindex, var); } } } /* Horizontal colored slices */ fprintf(f,"\n#Horizontal colored slices\n"); for (var=0;var<numvars;var++) { float level; vis5d_get_chslice( vindex, var, &level ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_chslice $ctx \"%s\" %g\n", varname, level ); } else { fprintf(f,"vis5d_set_chslice %d \"%s\" %g\n",vindex, varname, level ); } if (vis5d_enable_graphics(vindex, VIS5D_CHSLICE, var, VIS5D_GET)){ if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_CHSLICE %d VIS5D_ON\n", var); fprintf(f,"vis5d_make_chslice $ctx VIS5D_ALL_TIMES %d 1\n", var ); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_CHSLICE %d VIS5D_ON\n", vindex, var); fprintf(f,"vis5d_make_chslice %d VIS5D_ALL_TIMES %d 1\n", vindex, var ); } } /* WLH 10 Nov 98 */ else { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_CHSLICE %d VIS5D_OFF\n", var); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_CHSLICE %d VIS5D_OFF\n", vindex, var); } } } /* Vertical colored slices */ fprintf(f,"\n#Vertical colored slices\n"); for (var=0;var<numvars;var++) { float r0, c0, r1, c1; vis5d_get_cvslice( vindex, var, &r0, &c0, &r1, &c1 ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_cvslice $ctx \"%s\" %g %g %g %g\n", varname, r0, c0, r1, c1 ); } else { fprintf(f,"vis5d_set_cvslice %d \"%s\" %g %g %g %g\n",vindex, varname, r0, c0, r1, c1 ); } if (vis5d_enable_graphics(vindex, VIS5D_CVSLICE, var, VIS5D_GET)){ if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_CVSLICE %d VIS5D_ON\n", var); fprintf(f,"vis5d_make_cvslice $ctx VIS5D_ALL_TIMES %d 1\n", var ); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_CVSLICE %d VIS5D_ON\n", vindex, var); fprintf(f,"vis5d_make_cvslice %d VIS5D_ALL_TIMES %d 1\n", vindex, var ); } } /* WLH 10 Nov 98 */ else { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_CVSLICE %d VIS5D_OFF\n", var); } else { fprintf(f,"vis5d_enable_graphics %d VIS5D_CVSLICE %d VIS5D_OFF\n", vindex, var); } } } /* Current Display Volume */ fprintf(f, "\n#Current Display Volume\n"); { int current_vol_owner, current_vol; vis5d_get_volume(index, ¤t_vol_owner, ¤t_vol); // JCM: Anywhere vis5d_get_volume() is called, have to introduce extra code to deal with more than one volume if (current_vol_owner > -1){ vis5d_printtcl_volume(f, index, current_vol_owner, current_vol, cwhichones[0]); // JCM } else{ fprintf(f,"vis5d_set_volume_and_owner $dtx -1 -1\n"); } } /* Horizontal wind vector slices */ fprintf(f,"\n#Horizontal wind vector slices\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { float density, scale, level; vis5d_get_hwindslice( index, i, &density, &scale, &level ); fprintf(f,"vis5d_set_hwindslice $dtx %d %g %g %g\n", i, density, scale, level ); if (vis5d_enable_graphics(cwhichones[0], VIS5D_HWIND, i, VIS5D_GET)){ fprintf(f,"vis5d_enable_graphics $ctx VIS5D_HWIND %d VIS5D_ON\n", i); fprintf(f,"vis5d_make_hwindslice $dtx VIS5D_ALL_TIMES %d 1\n", i); } /* WLH 10 Nov 98 */ else { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_HWIND %d VIS5D_OFF\n", i); } /* MJK 12.04.98 begin */ if (vis5d_enable_sfc_graphics (vindex, VIS5D_HWIND, i, VIS5D_GET)== VIS5D_ON){ fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HWIND %d VIS5D_ON\n",i); } else{ fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HWIND %d VIS5D_OFF\n",i); } /* MJK 12.04.98 end */ } /* Vertical wind vector slices */ fprintf(f,"\n#Vertical wind vector slices\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { float density, scale, r0, c0, r1, c1; vis5d_get_vwindslice( index, i, &density, &scale, &r0, &c0, &r1, &c1 ); fprintf(f,"vis5d_set_vwindslice $dtx %d %g %g %g %g %g %g\n", i, density, scale, r0, c0, r1, c1 ); if (vis5d_enable_graphics(cwhichones[0], VIS5D_VWIND, i, VIS5D_GET)){ fprintf(f,"vis5d_enable_graphics $ctx VIS5D_VWIND %d VIS5D_ON\n", i); fprintf(f,"vis5d_make_vwindslice $dtx VIS5D_ALL_TIMES %d 1\n", i); } /* WLH 10 Nov 98 */ else { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_VWIND %d VIS5D_OFF\n", i); } } /* Horizontal wind stream slices */ fprintf(f,"\n#Horizontal stream slices\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { float density, level; vis5d_get_hstreamslice( index, i, &density, &level ); fprintf(f,"vis5d_set_hstreamslice $dtx %d %g %g\n", i, density, level ); if (vis5d_enable_graphics(cwhichones[0], VIS5D_HSTREAM, i, VIS5D_GET)){ fprintf(f,"vis5d_enable_graphics $ctx VIS5D_HSTREAM %d VIS5D_ON\n", i); fprintf(f,"vis5d_make_hstreamslice $dtx VIS5D_ALL_TIMES %d 1\n", i); } /* WLH 10 Nov 98 */ else { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_HSTREAM %d VIS5D_OFF\n", i); } /* MJK 12.04.98 begin */ if (vis5d_enable_sfc_graphics (vindex, VIS5D_HSTREAM, i, VIS5D_GET)== VIS5D_ON){ fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HWIND %d VIS5D_ON\n",i); } else{ fprintf (f,"vis5d_enable_sfc_graphics $ctx VIS5D_HSTREAM %d VIS5D_OFF\n",i); } /* MJK 12.04.98 end */ } /* Vertical wind stream slices */ fprintf(f,"\n#Vertical stream slices\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { float density, r0, c0, r1, c1; vis5d_get_vstreamslice( index, i, &density, &r0, &c0, &r1, &c1 ); fprintf(f,"vis5d_set_vstreamslice $dtx %d %g %g %g %g %g\n", i, density, r0, c0, r1, c1 ); if (vis5d_enable_graphics(cwhichones[0], VIS5D_VSTREAM, i, VIS5D_GET)){ fprintf(f,"vis5d_enable_graphics $ctx VIS5D_VSTREAM %d VIS5D_ON\n", i); fprintf(f,"vis5d_make_vstreamslice $dtx VIS5D_ALL_TIMES %d 1\n", i); } /* WLH 10 Nov 98 */ else { fprintf(f,"vis5d_enable_graphics $ctx VIS5D_VSTREAM %d VIS5D_OFF\n", i); } } /* Trajectories */ fprintf(f,"\n#Trajectories\n"); { float prevstep = 0.0, prevlength = 0.0; int prevribbon = 0; int numtraj = vis5d_get_num_traj( index ); for (i=0;i<numtraj;i++) { float row, col, lev, step, length; int timestep, group, ribbon; vis5d_get_traj_info( index, i, &row, &col, &lev, ×tep, &step, &length, &group, &ribbon ); if (i==0 || step!=prevstep || length!=prevlength || ribbon!=prevribbon) { fprintf(f,"vis5d_set_traj $dtx %g %g %d\n", step, length, ribbon ); } prevstep = step; prevlength = length; prevribbon = ribbon; fprintf(f,"vis5d_make_traj $dtx %g %g %g %d %d\n", row, col, lev, timestep, group ); } for (i=0; i<VIS5D_TRAJ_SETS; i++){ if (vis5d_enable_graphics(cwhichones[0], VIS5D_TRAJ, i, VIS5D_GET)){ fprintf(f,"vis5d_enable_graphics $ctx VIS5D_TRAJ %d VIS5D_ON\n", i); } } } /* Isosurface colors */ fprintf(f,"\n#Isosurface colors\n"); for (var=0;var<numvars;var++) { vis5d_get_color( index, VIS5D_ISOSURF, vindex*MAXVARS+var, &r, &g, &b, &a ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f, "vis5d_set_color $dtx VIS5D_ISOSURF $ctx \"%s\" %15.7g %15.7g %15.7g %15.7g\n", varname, r,g,b,a ); } else { fprintf(f, "vis5d_set_color $dtx VIS5D_ISOSURF %d \"%s\" %15.7g %15.7g %15.7g %15.7g\n", vindex, varname, r,g,b,a ); } } /* HSlice colors */ fprintf(f,"\n#Horizontal contour slice colors\n"); for (var=0;var<numvars;var++) { vis5d_get_color( index, VIS5D_HSLICE, vindex*MAXVARS+var, &r, &g, &b, &a ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f, "vis5d_set_color $dtx VIS5D_HSLICE $ctx \"%s\" %15.7g %15.7g %15.7g %15.7g\n", varname, r,g,b,a ); } else { fprintf(f, "vis5d_set_color $dtx VIS5D_HSLICE %d \"%s\" %15.7g %15.7g %15.7g %15.7g\n", vindex, varname, r,g,b,a ); } } /* VSlice colors */ fprintf(f,"\n#Vertical contour slice colors\n"); for (var=0;var<numvars;var++) { vis5d_get_color( index, VIS5D_VSLICE, vindex*MAXVARS+var, &r, &g, &b, &a ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f, "vis5d_set_color $dtx VIS5D_VSLICE $ctx \"%s\" %15.7g %15.7g %15.7g %15.7g\n", varname, r,g,b,a ); } else { fprintf(f, "vis5d_set_color $dtx VIS5D_VSLICE %d \"%s\" %15.7g %15.7g %15.7g %15.7g\n", vindex, varname, r,g,b,a ); } } /* Colored HSlice colors */ fprintf(f,"\n#Horizontal colored slice tickmark colors\n"); for (var=0;var<numvars;var++) { vis5d_get_color( index, VIS5D_CHSLICE, vindex*MAXVARS+var, &r, &g, &b, &a ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f, "vis5d_set_color $dtx VIS5D_CHSLICE $ctx \"%s\" %15.7g %15.7g %15.7g %15.7g\n", varname, r,g,b,a ); } else { fprintf(f, "vis5d_set_color $dtx VIS5D_CHSLICE %d \"%s\" %15.7g %15.7g %15.7g %15.7g\n", vindex, varname, r,g,b,a ); } } /* Colored VSlice colors */ fprintf(f,"\n#Vertical colored slice tickmark colors\n"); for (var=0;var<numvars;var++) { vis5d_get_color( index, VIS5D_CVSLICE, vindex*MAXVARS+var, &r, &g, &b, &a ); vis5d_get_ctx_var_name( vindex, var, varname ); if (vindex == cwhichones[0]) { fprintf(f, "vis5d_set_color $dtx VIS5D_CVSLICE $ctx \"%s\" %15.7g %15.7g %15.7g %15.7g\n", varname, r,g,b,a ); } else { fprintf(f, "vis5d_set_color $dtx VIS5D_CVSLICE %d \"%s\" %15.7g %15.7g %15.7g %15.7g\n", vindex, varname, r,g,b,a ); } } /* HWind colors */ fprintf(f,"\n#Horizontal wind slice colors\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { vis5d_get_color( index, VIS5D_HWIND, i, &r, &g, &b, &a ); fprintf(f, "vis5d_set_color $dtx VIS5D_HWIND %d %15.7g %15.7g %15.7g %15.7g\n", i, r,g,b,a ); } /* VWind colors */ fprintf(f,"\n#Vertical wind slice colors\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { vis5d_get_color( index, VIS5D_VWIND, i, &r, &g, &b, &a ); fprintf(f, "vis5d_set_color $dtx VIS5D_VWIND %d %15.7g %15.7g %15.7g %15.7g\n", i, r,g,b,a ); } /* Horizontal Stream colors */ fprintf(f,"\n#Horizontal stream slice colors\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { vis5d_get_color( index, VIS5D_HSTREAM, i, &r, &g, &b, &a ); fprintf(f, "vis5d_set_color $dtx VIS5D_HSTREAM %d %15.7g %15.7g %15.7g %15.7g\n", i, r,g,b,a ); } /* Vertical Stream colors */ fprintf(f,"\n#Vertical stream slice colors\n"); for (i=0;i<VIS5D_WIND_SLICES;i++) { vis5d_get_color( index, VIS5D_VSTREAM, i, &r, &g, &b, &a ); fprintf(f, "vis5d_set_color $dtx VIS5D_VSTREAM %d %15.7g %15.7g %15.7g %15.7g\n", i, r,g,b,a ); } /* Trajectory colors */ fprintf(f,"\n#Trajectory colors\n"); for (i=0;i<VIS5D_TRAJ_SETS;i++) { int colorvarowner, colorvar; vis5d_get_color( index, VIS5D_TRAJ, i, &r, &g, &b, &a ); fprintf(f,"vis5d_set_color $dtx VIS5D_TRAJ %d %15.7g %15.7g %15.7g %15.7g\n", i, r,g,b,a ); vis5d_get_trajectory_color_var( index, i, &colorvarowner, &colorvar ); if (colorvar>=0) { char varname[20]; vis5d_get_ctx_var_name( colorvarowner, colorvar, varname ); fprintf(f,"vis5d_set_trajectory_color_var_and_owner $dtx %d %d \"%s\"\n", i, colorvarowner, varname ); } } /* TO HERE */ /* Isosurface color tables */ fprintf(f,"\n#Isosurface color tables\n"); for (var=0;var<numvars;var++) { unsigned int *ctable; char varname[20]; float params[NUMCOLORTABLEPARAMS]; vis5d_get_ctx_var_name( index, var, varname ); k = get_colorbar_params( index, VIS5D_ISOSURF, vindex, var, params ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_ISOSURF $ctx"); } else { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_ISOSURF %d", vindex); } output_params(f,varname,params); // JCM if (k) { /* the color table can't be described by the parameters alone */ /* save each individual table entry */ vis5d_get_color_table_address( index, VIS5D_ISOSURF, vindex, var, &ctable ); for (i=0;i<256;i++) { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_ISOSURF $ctx"); } else { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_ISOSURF %d", vindex); } fprintf(f," \"%s\" %d %d %d %d %d\n", varname, i, UNPACK_RED(ctable[i]), UNPACK_GREEN(ctable[i]), UNPACK_BLUE(ctable[i]), UNPACK_ALPHA(ctable[i]) ); } fprintf(f,"\n"); } } /* Horizontal color slice color tables */ fprintf(f,"\n#Horizontal color slice color tables\n"); for (var=0;var<numvars;var++) { unsigned int *ctable; char varname[20]; float params[NUMCOLORTABLEPARAMS]; vis5d_get_ctx_var_name( index, var, varname ); k = get_colorbar_params( index, VIS5D_CHSLICE, vindex, var, params ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_CHSLICE $ctx"); } else { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_CHSLICE %d ", vindex); } output_params(f,varname,params); // JCM if (k) { /* the color table can't be described by the parameters alone */ /* save each individual table entry */ vis5d_get_color_table_address( index, VIS5D_CHSLICE, vindex, var, &ctable ); for (i=0;i<256;i++) { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_CHSLICE $ctx"); } else { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_CHSLICE %d", vindex); } fprintf(f," \"%s\" %d %d %d %d %d\n", varname, i, UNPACK_RED(ctable[i]), UNPACK_GREEN(ctable[i]), UNPACK_BLUE(ctable[i]), UNPACK_ALPHA(ctable[i]) ); } fprintf(f,"\n"); } } /* Vertical color slice color tables */ fprintf(f,"\n#Vertical color slice color tables\n"); for (var=0;var<numvars;var++) { unsigned int *ctable; char varname[20]; float params[NUMCOLORTABLEPARAMS]; vis5d_get_ctx_var_name( index, var, varname ); k = get_colorbar_params( index, VIS5D_CVSLICE, vindex, var, params ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_CVSLICE $ctx"); } else { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_CVSLICE %d", vindex); } output_params(f,varname,params); // JCM if (k) { /* the color table can't be described by the parameters alone */ /* save each individual table entry */ vis5d_get_color_table_address( index, VIS5D_CVSLICE, vindex, var, &ctable ); for (i=0;i<256;i++) { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_CVSLICE $ctx"); } else { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_CVSLICE %d", vindex); } fprintf(f," \"%s\" %d %d %d %d %d\n", varname, i, UNPACK_RED(ctable[i]), UNPACK_GREEN(ctable[i]), UNPACK_BLUE(ctable[i]), UNPACK_ALPHA(ctable[i]) ); } fprintf(f,"\n"); } } /* Volume color tables */ fprintf(f,"\n#Volume color tables\n"); for (var=0;var<numvars;var++) { unsigned int *ctable; char varname[20]; float params[NUMCOLORTABLEPARAMS]; vis5d_get_ctx_var_name( index, var, varname ); k = get_colorbar_params( index, VIS5D_VOLUME, vindex, var, params ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_VOLUME $ctx"); } else { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_VOLUME %d", vindex); } // fprintf(stderr,"%g\n",params[ALPHAVAL]); // DEBUG output_params(f,varname,params); // JCM if (k) { /* the color table can't be described by the parameters alone */ /* save each individual table entry */ vis5d_get_color_table_address( index, VIS5D_VOLUME, vindex, var, &ctable ); for (i=0;i<256;i++) { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_VOLUME $ctx"); } else { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_VOLUME %d", vindex); } fprintf(f," \"%s\" %d %d %d %d %d\n", varname, i, UNPACK_RED(ctable[i]), UNPACK_GREEN(ctable[i]), UNPACK_BLUE(ctable[i]), UNPACK_ALPHA(ctable[i]) ); } fprintf(f,"\n"); } } /* Trajectory color tables */ fprintf(f,"\n#Trajectory color tables\n"); for (var=0;var<numvars;var++) { unsigned int *ctable; float params[NUMCOLORTABLEPARAMS]; vis5d_get_ctx_var_name( index, var, varname ); k = get_colorbar_params( index, VIS5D_TRAJ, vindex, var, params ); if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_TRAJ $ctx"); } else { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_TRAJ %d", vindex); } output_params(f,varname,params); // JCM if (k) { /* the color table can't be described by the parameters alone */ /* save each individual table entry */ vis5d_get_color_table_address( index, VIS5D_TRAJ, vindex, var, &ctable ); for (i=0;i<256;i++) { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_TRAJ $ctx"); } else { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_TRAJ %d", vindex); } fprintf(f," \"%s\" %d %d %d %d %d\n", varname, i, UNPACK_RED(ctable[i]), UNPACK_GREEN(ctable[i]), UNPACK_BLUE(ctable[i]), UNPACK_ALPHA(ctable[i]) ); } fprintf(f,"\n"); } } /* MJK 12.04.98 begin */ /* if (vis5d_enable_sfc_map (index, VIS5D_GET) == VIS5D_ON){ fprintf (f,"vis5d_enable_sfc_map $dtx VIS5D_ON\n"); } else{ fprintf (f,"vis5d_enable_sfc_map $dtx VIS5D_OFF\n"); } */ /* MJK 12.04.98 end */ /* Topography color tables */ fprintf(f,"\n#Topography color tables\n"); for (var=-1;var<numvars;var++) { unsigned int *ctable; float params[NUMCOLORTABLEPARAMS]; if (var>=0) { vis5d_get_ctx_var_name( index, var, varname ); k = get_colorbar_params( index, VIS5D_TOPO, vindex, var, params ); } else { int j; for (j=0; j<NUMCOLORTABLEPARAMS; j++) params[j] = 0; strcpy( varname, "-1" ); k = 1; } if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_TOPO $ctx"); } else { fprintf(f,"vis5d_set_color_table_params $dtx VIS5D_TOPO %d", vindex); } output_params(f,varname,params); // JCM if (k) { /* the color table can't be described by the parameters alone */ /* save each individual table entry */ vis5d_get_color_table_address( index, VIS5D_TOPO, vindex, var, &ctable ); for (i=0;i<256;i++) { if (vindex == cwhichones[0]) { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_TOPO $ctx"); } else { fprintf(f,"vis5d_set_color_table_entry $dtx VIS5D_TOPO %d", vindex); } fprintf(f," \"%s\" %d %d %d %d %d\n", varname, i, UNPACK_RED(ctable[i]), UNPACK_GREEN(ctable[i]), UNPACK_BLUE(ctable[i]), UNPACK_ALPHA(ctable[i]) ); } fprintf(f,"\n"); } } } { int colorvar, colorvarowner; vis5d_get_topo_color_var( index, &colorvarowner, &colorvar ); fprintf(f, "\n"); fprintf(f, "vis5d_set_topo_color_var_and_owner $dtx %d %d\n", colorvarowner, colorvar ); } /* MJK 12.04.98 begin */ /* TODO */ /* if (vis5d_graphics_mode (index, VIS5D_BOX, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_BOX VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_CLOCK, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_CLOCK VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_MAP, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_MAP VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_TOPO, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_TOPO VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_LEGENDS, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_LEGENDS VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_PERSPECTIVE, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_PERSPECTIVE VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_CONTOUR_NUMBERS, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_CONTOUR_NUMBERS VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_GRID_COORDS, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_GRID_COORDS VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_PRETTY, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_PRETTY VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_INFO, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_INFO VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_PROBE, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_PROBE VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_SOUND, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_SOUND VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_CURSOR, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_CURSOR VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_ANIMRECORD, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_ANIMRECORD VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_TEXTURE, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_TEXTURE VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_DEPTHCUE, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_DEPTHCUE VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_JULIAN, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_JULIAN VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_BARBS, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_BARBS VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_SND_THTA, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_SND_THTA VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_SND_THTE, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_SND_THTE VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_SND_W, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_SND_W VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_SND_TICKS, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_SND_TICKS VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_SND_MIXRAT, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_SND_MIXRAT VIS5D_ON\n"); if (vis5d_graphics_mode (index, VIS5D_SND_TEMP, VIS5D_GET) == VIS5D_ON) fprintf (f, "vis5d_graphics_mode $ctx VIS5D_SND_TEMP VIS5D_ON\n"); */ fprintf(f, "\nvis5d_draw_frame %d\n", index ); fclose(f); return 0; }
/* * Given an XEvent, process it if it pertains to a ColorBar, else do * nothing with it. * Input: event - the X event * Output: whichcb - which colorbar this event pertained to. * Return: 1 - if color table was changed. * 2 - if reset key was pressed * 3 - if <shift>+reset key was pressed * 0 - if no change */ static int colorbar_process( LUI_COLORBAR *cb, XEvent *event ) { static int p1 = 0, p2 = 0, p3 = 0, p4 = 0; /* red, green, blue, alpha */ static int pentry; int i, modify, entry, result; static int move_marker; result = modify = 0; if (event->type==KeyPress) { char keybuf[50]; KeySym key; XComposeStatus compose; int count; count = XLookupString( &event->xkey, keybuf, 50, &key, &compose ); if (count==1) { if (keybuf[0]=='r') { /* Reset RGB */ cb->params[DRAWFLAG] = 0.0; result = LUI_RGB_RESET; } else if (keybuf[0]=='R') { /* Reset alpha */ result = LUI_ALPHA_RESET; cb->params[DRAWFLAG] = 0.0; } else if (keybuf[0]=='c' || keybuf[0]=='C') { /* Copy current colors to clipboard */ copy_colors( cb ); } else if (keybuf[0]=='p' || keybuf[0]=='P') { /* Paste clipboard colors to current color widget */ paste_colors( cb ); LUI_ColorBarRedraw( cb ); result = LUI_RGB_CHANGE | LUI_ALPHA_CHANGE; cb->params[DRAWFLAG] = 0.0; result = LUI_RGB_CHANGE | LUI_ALPHA_CHANGE; } /* WLH 7-18-96 */ else if (keybuf[0]=='s' || keybuf[0]=='S') { /* save colors to a file */ save_colors( cb ); } else if (keybuf[0]=='l' || keybuf[0]=='L') { /* load colors from a file */ load_colors( cb ); LUI_ColorBarRedraw( cb ); return 1; } else { /* if unused key, toggle help display */ cb->helpflag = !cb->helpflag; LUI_ColorBarRedraw( cb ); } } else if (key == XK_Left) { /* rotate left */ cb->params[BIAS] -= 0.03/cb->params[CURVE]; result = LUI_RGB_SHAPE; cb->params[DRAWFLAG] = 0.0; } else if (key == XK_Right) { /* rotate right */ cb->params[BIAS] += 0.03/cb->params[CURVE]; result = LUI_RGB_SHAPE; cb->params[DRAWFLAG] = 0.0; } else if (key == XK_Up) { /* expand color map */ if (event->xkey.state & ANY_MODIFIER) { cb->params[ALPHAPOW] -= 0.1; if (cb->params[ALPHAPOW]<0.0) cb->params[ALPHAPOW] = 0.0; result = LUI_ALPHA_SHAPE; cb->params[DRAWFLAG] = 0.0; } else { cb->params[CURVE] -= 0.1; result = LUI_RGB_SHAPE; cb->params[DRAWFLAG] = 0.0; } } else if (key == XK_Down) { /* compress color map */ if (event->xkey.state & ANY_MODIFIER) { cb->params[ALPHAPOW] += 0.1; result = LUI_ALPHA_SHAPE; cb->params[DRAWFLAG] = 0.0; } else { cb->params[CURVE] += 0.1; result = LUI_RGB_SHAPE; cb->params[DRAWFLAG] = 0.0; } } } else if (event->type==Expose && event->xexpose.count==0) { LUI_ColorBarRedraw( cb ); result = 0; } else if (event->type==ConfigureNotify) { /* MJK 4.15.99 */ LUI_ColorBarSetSize( cb, event->xconfigure.width, event->xconfigure.height ); result = 0; } else if (event->type==ButtonPress ) { if (event->xbutton.y<cb->wedge_y) { /* change color function */ move_marker = 0; } else { /* change marker position */ move_marker = 1; } /* determine which curve to modify */ if (event->xbutton.state&ANY_MODIFIER) { p4 = 1; } else { if (event->xbutton.button==Button1) p1 = 1; if (event->xbutton.button==Button2) p2 = 1; if (event->xbutton.button==Button3) p3 = 1; } pentry = x_to_index( cb, event->xbutton.x ); modify = 1; } else if (event->type==ButtonRelease) { if (p1 || p2 || p3) { result = LUI_RGB_CHANGE; } else { result = LUI_ALPHA_CHANGE; } if (event->xbutton.button==Button1) p1 = 0; if (event->xbutton.button==Button2) p2 = 0; if (event->xbutton.button==Button3) p3 = 0; p4 = 0; } else if (event->type==MotionNotify) { /* Flush extra MotionNotify events */ while (QLength(LUI_Display)>0) { XEvent next; XPeekEvent(LUI_Display, &next); if (next.type!=MotionNotify) break; XNextEvent(LUI_Display, event); } modify = 1; } /* Modify one or more of the color curves */ if (modify && (p1 || p2 || p3 || p4)) { /* calculate which entry in color table to change */ entry = x_to_index( cb, event->xbutton.x ); /* update */ if (move_marker) { /* changing marker position */ cb->markerpos = entry; redraw_marker( cb ); } else { /* changing color graph */ int a, b, value; value = y_to_intensity( cb, event->xbutton.y ); if (pentry<=entry) { a = pentry; b = entry; } else { a = entry; b = pentry; } /* update entries from 'pentry' to 'entry' */ for (i=a; i<=b; i++) { int red, green, blue, alpha; red = UNPACK_RED(cb->table[i]); green = UNPACK_GREEN(cb->table[i]); blue = UNPACK_BLUE(cb->table[i]); alpha = UNPACK_ALPHA(cb->table[i]); if (p1) { /* modify red */ red = value; } if (p2) { /* modify green */ green = value; } if (p3) { /* modify blue */ blue = value; } if (p4) { /* modify alpha */ alpha = value; } /* change the color table entry */ cb->table[i] = PACK_COLOR(red,green,blue,alpha); } /* for */ /* redraw the color curves */ if (pentry<entry) redraw_range( cb, pentry-1, entry+1 ); else redraw_range( cb, entry-1, pentry+1 ); pentry = entry; if (p4) { /* update min,max alpha values */ cb->minalpha = 256; cb->maxalpha = 0; for (i=0;i<cb->table_size;i++) { int a = UNPACK_ALPHA( cb->table[i] ); if (a<cb->minalpha) cb->minalpha = a; if (a>cb->maxalpha) cb->maxalpha = a; } } if (p4) { result = LUI_ALPHA_MODIFY; /* result = LUI_ALPHA_CHANGE; */ } else { result = LUI_RGB_MODIFY; /* result = LUI_RGB_CHANGE; */ } cb->params[DRAWFLAG] = 1.0; } } /*modify*/ if (result!=0 && cb->callback) { (*cb->callback)(cb, result); } return result; }
/*** redraw_range ***************************************************** Redraw part of a Color Widget. Input: c - which Color Widget a,b - range of entries of table to redraw. **********************************************************************/ static void redraw_range( LUI_COLORBAR *cb, int a, int b ) { Window win; int i; int x,y, px,py; int x1, y1, x2, y2; win = cb->window; if (a<0) a = 0; if (b>=cb->table_size) b = cb->table_size-1; /* calc region to update */ x1 = index_to_x( cb, a ); x2 = index_to_x( cb, b); y1 = intensity_to_y( cb, 255 ); y2 = intensity_to_y( cb, 0 ); /* erase region */ XFillRectangle( LUI_Display, win, LUI_GC_black, x1,y1, x2-x1+1, y2-y1+1 ); /* redraw region of entries in interval [a,b] */ if (a>0) a--; if (b<cb->table_size-1) b++; /* draw red levels */ for (i=a;i<=b;i++) { x = index_to_x( cb, i ); y = intensity_to_y( cb, UNPACK_RED(cb->table[i]) ); if (i!=a) XDrawLine( LUI_Display, win, LUI_GC_red, px, py, x, y ); px = x; py = y; } /* draw green levels */ for (i=a;i<=b;i++) { x = index_to_x( cb, i ); y = intensity_to_y( cb, UNPACK_GREEN(cb->table[i]) ); if (i!=a) XDrawLine( LUI_Display, win, LUI_GC_green, px,py, x,y ); px = x; py = y; } /* draw blue levels */ for (i=a;i<=b;i++) { x = index_to_x( cb, i ); y = intensity_to_y( cb, UNPACK_BLUE(cb->table[i]) ); if (i!=a) XDrawLine( LUI_Display, win, LUI_GC_blue, px,py, x,y ); px = x; py = y; } /* draw alpha levels */ if (cb->minalpha<255 || cb->maxalpha<255) { for (i=a;i<=b;i++) { x = index_to_x( cb, i ); y = intensity_to_y( cb, UNPACK_ALPHA(cb->table[i]) ); if (i!=a) XDrawLine( LUI_Display, win, LUI_GC_white, px,py, x,y ); px = x; py = y; } } /* draw the color bar */ for (x=x1;x<=x2;x++) { int r, g, b; unsigned int color; i = x_to_index( cb, x ); color = cb->table[i]; r = UNPACK_RED( color ); g = UNPACK_GREEN( color ); b = UNPACK_BLUE( color ); XSetForeground( LUI_Display, LUI_Gc, LUI_AllocateColorInt(r,g,b) ); XDrawLine( LUI_Display, win, LUI_Gc, x, cb->wedge_y, x, cb->wedge_y + WEDGE_HEIGHT ); } if (cb->helpflag) { /* print help messages */ for (i=0;i<HELP_LINES;i++) { XDrawString( LUI_Display, win, LUI_GC_white, cb->framewidth+10, cb->framewidth+12+i*(LUI_Font_height+1), help_strings[i], strlen(help_strings[i]) ); } } }
/* * Draw the topography. * Input: time - the timestep number * texture_flag - 0=no texture, 1=texture map * flat_flag - 0=draw w/ topo heights, 1=draw flat */ void draw_topo( Display_Context dtx, int time, int texture_flag, int flat_flag ) { /* MJK 12.02.98 begin */ int i, j, n, ir, ic, nr, nc, nr2, nc2; int_vert2 *verts; int_1 *norms; uint_1 *color; /* MJK 12.02.98 end */ struct Topo *topo; topo = dtx->topo; set_color( 0xffffffff ); if (flat_flag) { if (texture_flag) { /* flat texture map */ use_texture( dtx, time ); texture_quadmeshnorm( topo->qrows, topo->qcols, (void*) topo->TopoFlatVertex, NULL, (void*) topo->TopoTexcoord ); } else { /* draw nothing */ } } else { if (texture_flag) { /* textured topo */ use_texture( dtx, time ); texture_quadmeshnorm( topo->qrows, topo->qcols, (void*) topo->TopoVertex, (void*) topo->TopoNormal, (void*) topo->TopoTexcoord ); } else { /* untextured topo */ uint_1 *indexes; unsigned int *color_table; if (topo->TopoColorVar<0) { color_table = dtx->ColorTable[VIS5D_TOPO_CT]->Colors[MAXVARS*VIS5D_MAX_CONTEXTS]; indexes = topo->TopoIndexes[MAXTIMES]; } else { color_table = dtx->ColorTable[VIS5D_TOPO_CT]->Colors[ topo->TopoColorVarOwner * MAXVARS + topo->TopoColorVar ]; indexes = topo->TopoIndexes[time]; if (!indexes) { indexes = topo->TopoIndexes[MAXTIMES]; } } /* MJK 12.02.98 begin */ if (topo->TopoStripsVerts == NULL) return; if (topo->TopoStripsNorms == NULL) return; verts = topo->TopoStripsVerts; norms = topo->TopoStripsNorms; nr = topo->qrows; nc = topo->qcols; nr2 = nr * 2; nc2 = nc * 2; n = (nr > nc) ? nr : nc; color = (uint_1 *) malloc ((n * 2 * sizeof (uint_1))); if (color == NULL) return; /* topography */ j = 0; i = nc; for (ir = 1; ir < nr; ir++) { n = 0; for (ic = 0; ic < nc; ic++) { color[n++] = indexes[i++]; color[n++] = indexes[j++]; } draw_colored_triangle_strip (nc2, (void *) verts, (void *) norms, color, color_table, 255); verts += nc2 * 3; norms += nc2 * 3; } if (topo->DisplayTopoBase) { unsigned int base_color = TOPO_BASE_COLOR; int norm_dir = 1; /* MJK 3.29.99 */ clipping_off(); n = (nr > nc) ? nr : nc; memset (color, 0, (n * 2 * sizeof (uint_1))); /* MJK reversed this 2.16.99 norm_dir = (topo->TopoBaseLev < 0.0) ? -1 : 1; */ /* MJK 3.29.99 don't know why this is here norm_dir = (topo->TopoBaseLev < 0.0) ? -1 : 1; */ norm_dir = 1; /* north side */ if ((check_face_norm(verts) * norm_dir > 0)) draw_colored_triangle_strip (nc2, (void *) verts, (void *) norms, color, &base_color, 255); verts += nc2 * 3; norms += nc2 * 3; /* south side */ if ((check_face_norm(verts) * norm_dir) > 0) draw_colored_triangle_strip (nc2, (void *) verts, (void *) norms, color, &base_color, 255); verts += nc2 * 3; norms += nc2 * 3; /* west side */ if ((check_face_norm(verts) * norm_dir) > 0) draw_colored_triangle_strip (nr2, (void *) verts, (void *) norms, color, &base_color, 255); verts += nr2 * 3; norms += nr2 * 3; /* east side */ if ((check_face_norm(verts) * norm_dir) > 0) draw_colored_triangle_strip (nr2, (void *) verts, (void *) norms, color, &base_color, 255); verts += nr2 * 3; norms += nr2 * 3; /* bottom */ if ((check_face_norm(verts) * norm_dir) > 0) { float r, g, b, a, fac = 0.90; /* color the bottom slightly darker than the sides */ r = (((float) UNPACK_RED (base_color)) / 255.0) * fac; g = (((float) UNPACK_GREEN (base_color)) / 255.0) * fac; b = (((float) UNPACK_BLUE (base_color)) / 255.0) * fac; a = ((float) UNPACK_ALPHA (base_color)) / 255.0; base_color = PACK_COLOR ((int) (r * 255.0), (int) (g * 255.0), (int) (b * 255.0), (int) (a * 255.0)); for (ir = 1; ir < nr; ir++) { draw_colored_triangle_strip (nc2, (void *) verts, (void *) norms, color, &base_color, 255); verts += nc2 * 3; norms += nc2 * 3; } } /* MJK 3.29.99 */ clipping_on(); } free (color); } } }