/* _______________________________________________________________________ * * RDPARM/PTRAJ: APR 2000 * _______________________________________________________________________ * * $Header: /thr/gamow/cvsroot/amber7/src/ptraj/display.c,v 1.4 2000/05/10 21:53:18 cheatham Exp $ * * Revision: $Revision: 1.4 $ * Date: $Date: 2000/05/10 21:53:18 $ * Last checked in by $Author: cheatham $ * * This source is now archived under CVS at Scripps in the amber7 tree. * * NOTE: this is a beta, pre-release version, is under constant development, * probably contains some bugs and is under constant revision; therefore * take care. Please report bugs (and fixes!) to cheatham@chpc.utah.edu or * cheatham@cgl.ucsf.edu * * Do not distribute this code without explicit permission. * Do not incorporate into other codes without explicit permission. * * Current contact information: * * Thomas Cheatham, III * 2000 East, 30 South, Skaggs Hall 201 * Department of Medicinal Chemistry * University of Utah * Salt Lake City, UT 84112-5820 * cheatham@chpc.utah.edu * (801) 587-9653 * FAX: (801) 585-5366 * * Other contributors: * * David Case (Scripps) * Michael Crowley (Scripps) * Jed Pitera (UCSF) * Vickie Tsui (Scripps) * _______________________________________________________________________ */ #include #include #include #define DISPLAY_MODULE #include "ptraj.h" /* * Code to dump out graphs/plots, etc should be placed here */ /* the box size and margins in inches */ #define BOX_SIZE 6.0 #define X_MARGIN 1.25 #define Y_MARGIN 1.25 /* * dumpTopo(): this routine will dump a postscript file which represents a 2D * grid with the third dimension represented by various gray scale values over * the range. * * input parameters: * * fileOut -- the FILE * of the already opened file * maxValues -- the size of 1 dimension of the square array in values * values -- values[i+maxValues*j] is the height at point i,j * entries -- the actual number of set values (i.e. max i) * shades -- the number of shades to use (sort of...) * = 0 -- implies continuous shading over entire range * = n -- implies "n" shading levels * shadeCut -- IF NULL, then "n" snading levels are used over the range. * IF not NULL, then shadeCut(i)->shadeCut(i+1) is the * interval for the shade. As i gets larger, the color gets * darker... * */ void dumpTopo(FILE *fileOut, int max_values, float *values, int entries, int shades, float *shadeCut) { int i, j, k; float box_size; float x, y, z; float max_entry, min_entry; float range; float value; max_entry = values[0]; min_entry = values[0]; for (i=0; i < entries; i++) { for (j=0; j < entries; j++ ) { if (max_entry < values[i+max_values*j]) max_entry = values[i+max_values*j]; if (min_entry > values[i+max_values*j]) min_entry = values[i+max_values*j]; } } range = max_entry - min_entry; box_size = BOX_SIZE / (float) entries; /* write out the head are start defining procedures */ fprintf(fileOut, "%%!PS\n %% -- define procedures --\n"); fprintf(fileOut, " /inch {72 mul} def\n"); /* define a box */ fprintf(fileOut, " /box\n"); fprintf(fileOut, " { newpath moveto\n"); fprintf(fileOut, " %8.4f inch %8.4f inch rlineto\n", box_size, 0.0); fprintf(fileOut, " %8.4f inch %8.4f inch rlineto\n", 0.0, box_size); fprintf(fileOut, " %8.4f inch %8.4f inch rlineto\n", -box_size, 0.0); fprintf(fileOut, " closepath } def\n"); /* define how to fill a box with gray */ fprintf(fileOut, " /fillbox { setgray fill } def\n"); for (i=0; i < entries; i++) { for (j=0; j < entries; j++ ) { x = (float) i / (float) entries * BOX_SIZE + X_MARGIN; y = (float) j / (float) entries * BOX_SIZE + Y_MARGIN; if (shades == 0 ) { z = (max_entry - values[i+max_values*j]) / range; } else if ( shadeCut == NULL) { z = (max_entry - values[i+max_values*j]) / range; z = z * shades; z = (int) z / (float) shades; } else { z = -1.0; value = values[i+max_values*j]; for (k = 0; k < 2*shades; k += 2) { if ( value >= shadeCut[k] && value <= shadeCut[k+1] ) z = (float) k / (float) (2.0 * shades); } if (z == -1.0) z = 1.0; } fprintf(fileOut, " %8.4f inch %8.4f inch box\n", x, y); fprintf(fileOut, " %8.4f fillbox\n", z); } } fprintf(fileOut, " showpage\n"); # ifdef DISPLAY_MODULE safe_fclose(fileOut); # else fclose(fileOut); #endif }