#include "mview_view.h" #include "mview_misc.h" #include #include static char dumstr[80]; static int gesterreurs(Display *canal_aff, XErrorEvent *errev) { XGetErrorText(canal_aff, errev->error_code, dumstr, 80); fprintf(stderr, "%s\n", dumstr); } void _2DfloatTo2Dbyte(startf, xmin, xmax, ymin, ymax, startb, scalex, scaley, clipdeb, clipfin, incr) float *startf; /* Addresse de depart des donnees 2Dfloat a */ /* extraire */ int xmin, /* Borne inferieure sur la 1ere dimension */ xmax, /* Borne superieure sur la 1ere dimension */ ymin, /* Borne inferieure sur la 2eme dimension */ ymax; /* Borne superieure sur la 2eme dimension */ unsigned char *startb; /* Addresse de depart de la zone memoire */ /* contenant les valeurs de pixel */ int scalex, /* Facteur d'echelle selon la 1ere dimension */ scaley; /* Facteur d'echelle selon la 2eme dimension */ float clipdeb, clipfin; int incr; { int i, x, y, l; int width, height; float sc, tested; unsigned char *p; float *startfsav; startfsav = startf; sc=(clipfin==clipdeb)?0:((float) (ncolors - 1)) / (clipfin - clipdeb); width = (xmax - xmin + 1) * scalex; height = (ymax - ymin + 1) * scaley; startb = startb + (height-1)*width; for (y = ymin; y <= ymax ; y++) { p = startb; for (x = xmin ; x <= xmax ; x++) { tested = *startf; if ((tested == Blank) || (fabs(tested - Blank) <= Tolerance)) l = ncolors; else { l = (int) (sc*(tested - clipdeb)); if (l < 0) { l = 0; } else { if (l > (ncolors-1)) l = ncolors - 1; } } memset(startb, colmap[l], scalex); startb += scalex; startf += incr; } startf -=(xmax - xmin +1)*incr; startb -=2*width; for (i = 1; i < scaley; i++) { (void) memcpy(startb, p, width); startb -= width; } if (startfsav == Buffer) startf += xmax*incr; else startf += npix[0]*incr; } } void draw_wedge(float clip[2]) { int k; char c[12]; float work; float f; XSetErrorHandler(gesterreurs); XSetForeground(display, gc, WhitePixelOfScreen(ecran)); XSetForeground(display, gcx, colmap[ncolors - 1]); for (k=0; k<15; k++) { f = clip[0] + (float) k*(clip[1] - clip[0])/14.; sprintf(c, "%10.3g -", f); XDrawString(display, cpixmap, gc, 0, cpixmapdim[1] - 10 - k*(cpixmapdim[1]/15), c, 12); } work = (float) (cpixmapdim[1])/ncolors; for (k=0; k