/***********************************************************************/ /* Open Visualization Data Explorer */ /* (C) Copyright IBM Corp. 1989,1999 */ /* ALL RIGHTS RESERVED */ /* This code licensed under the */ /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */ /***********************************************************************/ #include #include #include extern Object _dxfAxes2D(Pointer); #define MINTICPIX 5 typedef struct { float x; float y; } Point2D; extern int _dxfIsImportedColorMap(Object, int *, Object *, Object *); extern Pointer _dxfNew2DAxesObject(void); extern Error _dxfTransposePositions(Array); static Error TransposeColors(Array); static Error SimpleBar(Array *, Array *, RGBColor *); extern _dxfFreeAxesHandle(Pointer); extern Error _dxfSet2DAxesCharacteristic(Pointer, char *, Pointer); extern Error _dxfGetColorBarAnnotationColors(Object, Object, RGBColor, RGBColor, RGBColor *, RGBColor *, RGBColor *, int *); extern Error _dxfHowManyStrings(Object, int *); extern Error _dxfLowerCase(char *, char **); static RGBColor DEFAULTTICCOLOR = {0.3, 0.3, 0.3}; static RGBColor DEFAULTLABELCOLOR = {1.0, 1.0, 1.0}; static RGBColor DEFAULTAXESCOLOR = {-1.0, -1.0, -1.0}; static RGBColor DEFAULTGRIDCOLOR = {-1.0, -1.0, -1.0}; m_ColorBar(Object *in, Object *out) { Pointer axeshandle=NULL; Group outgroup; Object outo, outscreen, o, oo, withaxes, mintext, maxtext, axes, ooo; Object newo, ob; Array a_positions, a_newpositions=NULL; Array a_newcolors=NULL, a_colors, a_newconnections=NULL; Array corners; float floatzero=0.0, floatone=1.0; char *nullstring="", *fontname, extralabel[80]; int numpos, numcolors, i, flag, horizontal, intzero = 0, intone=1, frame; int tics, usedobject, adjust, curcount, lastin, thisin; int colorcount, lastok; float *pos_ptr, *newpos_ptr, frac, minticsize, *actualcorners = NULL; int *con_ptr, numarrayitems; float textheight, textdepth, widthmin, widthmax, textwidth; float minvalue, maxvalue, fuzz; Point min, max, up; float *newcol_ptr, *col_ptr_f; int *col_ptr_i; Point box[8], to, from, translation, corner1, corner2, point; float length, scalewidth, scaleheight, captionsize, labelscale=1.0; char minlabel[10], maxlabel[10]; RGBColor color, *color_ptr, ticcolor, labelcolor, axescolor, gridcolor; RGBColor framecolor; Class class; Type type, colortype; int rank, shapearray[32], axeslines=1; Category category; char *att, *label; Object labelobj; Field colormap; int doaxes = 1; Array ticklocations=NULL; float *list_ptr; int numlist; int dofixedfontsize=0; float fixedfontsize=0; int fixedfontsizepixels=10; typedef struct { float height, width, thickness; } Shape; Shape shape; strcpy(extralabel,nullstring); adjust = 0; captionsize = 15.0; outo = NULL; corners = NULL; withaxes = NULL; o = NULL; oo = NULL; if (!in[0]) DXErrorGoto(ERROR_BAD_PARAMETER, "missing colormap"); class = DXGetObjectClass(in[0]); if ((class != CLASS_FIELD)&&(class != CLASS_ARRAY)&&(class != CLASS_GROUP)) { DXSetError(ERROR_BAD_PARAMETER, "#10111","colormap"); goto error; } if (class == CLASS_ARRAY) { if (!DXGetArrayInfo((Array)in[0], &numarrayitems, &type, &category, &rank, shapearray)){ goto error; } if (numarrayitems != 1) { DXSetError(ERROR_BAD_PARAMETER,"#10111","colormap"); goto error; } if ((type!=TYPE_FLOAT)||(category!=CATEGORY_REAL)||(rank!=1)|| (shapearray[0]!=3)) { DXSetError(ERROR_BAD_PARAMETER,"#10111","colormap"); goto error; } DXWarning("colormap is a single color--no axes information available"); colormap=(Field)in[0]; } else { if (class==CLASS_FIELD && DXEmptyField((Field)in[0])) { return OK; } /* see if it's an imported colormap */ if (!_dxfIsImportedColorMap(in[0], NULL, (Object *)&colormap, NULL)) { if (!(_dxfIsColorMap(in[0]))) { goto error; } colormap=(Field)in[0]; } } if (!in[3]) { horizontal = 0; } else { if (!(DXExtractInteger(in[3], &horizontal))) { DXSetError(ERROR_BAD_PARAMETER,"#10070","horizontal"); goto error; } if ((horizontal != 0)&&(horizontal != 1)) { DXSetError(ERROR_BAD_PARAMETER,"#10070","horizontal"); goto error; } } if (!in[1]) { if (horizontal==0) { translation.x = 0.95; translation.y = 0.95; translation.z = 0.0; } else { translation.x = 0.5; translation.y = 0.95; translation.z = 0.0; } } else { if (!DXExtractParameter(in[1], TYPE_FLOAT, 3, 1, (Pointer)&translation)) { if (!DXExtractParameter(in[1], TYPE_FLOAT, 2, 1, (Pointer)&translation)) { DXSetError(ERROR_BAD_PARAMETER,"#10231","position", 2, 3); goto error; } } translation.z = 0.0; } if ((translation.x < 0)||(translation.x > 1)||(translation.y<0.0)|| (translation.y>1.0)) { DXSetError(ERROR_BAD_PARAMETER, "#10110", "position", 0, 1); goto error; } if (!in[2]) { shape.height = 300.0; shape.width = 25.0; shape.thickness = 1.0; } else { if (!DXExtractParameter(in[2], TYPE_FLOAT, 3, 1, (Pointer)&shape)) { if (!DXExtractParameter(in[2], TYPE_FLOAT, 2, 1, (Pointer)&shape)) { DXSetError(ERROR_BAD_PARAMETER,"#10231","shape", 2, 3); goto error; } shape.thickness = 1; } if (shape.height <= 0.0) { DXSetError(ERROR_BAD_PARAMETER,"#10531","shape"); goto error; } if (shape.width <= 0.0) { DXSetError(ERROR_BAD_PARAMETER,"#10531","shape"); goto error; } } if (!in[4]) { /* magic formula to figure out how many ticks */ tics = shape.height/(captionsize*2.0); } else { if (!DXExtractInteger(in[4],&tics)) { DXSetError(ERROR_BAD_PARAMETER, "#10030","ticks"); goto error; } } if (!_dxfGetColorBarAnnotationColors(in[8], in[9], DEFAULTTICCOLOR, DEFAULTLABELCOLOR, &ticcolor, &labelcolor, &framecolor, &frame)) goto error; if (frame==1) axeslines=1; else axeslines=0; if (in[10]) { if (!DXExtractFloat(in[10],&labelscale)) { DXSetError(ERROR_BAD_PARAMETER,"#10090","labelscale"); goto error; } if (labelscale < 0) { DXSetError(ERROR_BAD_PARAMETER,"#10090","labelscale"); goto error; } } if (in[11]) { if (!DXExtractString(in[11],&fontname)) { DXSetError(ERROR_BAD_PARAMETER,"#10200","font"); goto error; } } else { fontname = "standard"; } if (class == CLASS_ARRAY) { /* make a simple, simple, bar, all one color */ color_ptr = (RGBColor *)DXGetArrayData((Array)colormap); if (!SimpleBar(&a_newpositions, &a_newcolors, color_ptr)) goto error; curcount = 4; minvalue = 0; maxvalue = 1; att = "positions"; doaxes = 0; } /* a "normal" field color map */ else { if (class == CLASS_GROUP) { DXSetError(ERROR_INVALID_DATA, "colormap must be a single field; not a group"); goto error; } else if (class != CLASS_FIELD) { DXSetError(ERROR_INVALID_DATA, "colormap must be a single field"); goto error; } usedobject = 0; if (in[5]) { if (!DXExtractFloat(in[5], &minvalue)) { if (!DXStatistics(in[5],"data",&minvalue, &maxvalue, NULL, NULL)) { DXSetError(ERROR_BAD_PARAMETER, "min must be a field with data or scalar"); goto error; } usedobject = 1; } } else { if (!DXStatistics((Object)colormap, "positions",&minvalue, NULL, NULL, NULL)) { DXAddMessage("invalid colormap"); goto error; } } if (in[6]) { if (!DXExtractFloat(in[6], &maxvalue)) { if (!DXStatistics(in[6],"data",NULL, &maxvalue, NULL, NULL)) { DXSetError(ERROR_BAD_PARAMETER, "max must be a field with data or scalar"); goto error; } } } else { if (!usedobject) { if (!DXStatistics((Object)colormap, "positions",NULL, &maxvalue, NULL, NULL)) { DXAddMessage("invalid colormap"); goto error; } } } if (minvalue == maxvalue) { color_ptr = (RGBColor *)DXGetArrayData((Array)DXGetComponentValue(colormap, "data")); if (!SimpleBar(&a_newpositions, &a_newcolors, color_ptr)) goto error; att = "positions"; curcount = 4; sprintf(extralabel,"%f",minvalue); minvalue = 0; maxvalue = 1; doaxes = 1; tics = 0; goto drawbar; } if (minvalue > maxvalue) { DXSetError(ERROR_BAD_PARAMETER,"#11220","min","max"); goto error; } if (!(a_positions = (Array)DXGetComponentValue((Field)colormap, "positions"))) { DXSetError(ERROR_BAD_PARAMETER,"colormap has no positions"); goto error; } if (!(a_colors = (Array)DXGetComponentValue((Field)colormap,"data"))) { DXSetError(ERROR_BAD_PARAMETER,"colormap has no data"); goto error; } if (!DXGetArrayInfo(a_positions,&numpos, NULL, NULL, NULL, NULL)) { goto error; } if (!DXGetArrayInfo(a_colors,&numcolors, &colortype, NULL, NULL, NULL)) { goto error; } switch (colortype) { case (TYPE_FLOAT): if (!(col_ptr_f = (float *)DXGetArrayData(a_colors))) goto error; break; case (TYPE_INT): if (!(col_ptr_i = (int *)DXGetArrayData(a_colors))) goto error; break; default: DXSetError(ERROR_INVALID_DATA, "colormap colors must be integer or float"); goto error; } if (numcolors == 0) { DXSetError(ERROR_INVALID_DATA,"colormap has no colors (data component)"); goto error; } if (!(pos_ptr = (float *)DXGetArrayData(a_positions))) { goto error; } if (!(a_newpositions = DXNewArray(TYPE_FLOAT,CATEGORY_REAL, 1, 2))) { goto error; } if (!(a_newcolors = DXNewArray(TYPE_FLOAT,CATEGORY_REAL, 1, 3))) { goto error; } if (horizontal == 0) { corner1 = DXPt(0.0, minvalue, 0.0); corner2 = DXPt(1.0, maxvalue, 0.0); } else { corner1 = DXPt(minvalue, 0.0, 0.0); corner2 = DXPt(maxvalue, 1.0, 0.0); } if (in[5]||in[6]) { corners = DXNewArray(TYPE_FLOAT,CATEGORY_REAL,1,3); if (!(DXAddArrayData(corners, 0, 1, (Pointer)&corner1))) goto error; if (!(DXAddArrayData(corners, 1, 1, (Pointer)&corner2))) goto error; } if (!(att = DXGetString((String)DXGetComponentAttribute((Field)colormap, "data","dep")))) { DXSetError(ERROR_INVALID_DATA,"missing data dependency attribute"); goto error; } if (strcmp(att,"positions") && strcmp(att,"connections")) { DXSetError(ERROR_INVALID_DATA,"unknown data dependent attribute %s", att); goto error; } curcount = 0; colorcount = 0; lastok = 0; if (!strcmp(att,"positions")) { if (corners) { lastin = 0; if (horizontal == 0) { for (i=0; i=corner1.y) && (pos_ptr[i]<=corner2.y)) { if ((i > 0) && (lastin == 0)) { point = DXPt(0.0, corner1.y, 0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; point = DXPt(1.0, corner1.y, 0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; frac = (corner1.y - pos_ptr[i-1])/(pos_ptr[i]-pos_ptr[i-1]); switch (colortype) { case (TYPE_FLOAT): color = DXRGB(frac*(col_ptr_f[3*i]-col_ptr_f[3*(i-1)]) + col_ptr_f[3*(i-1)], frac*(col_ptr_f[3*i+1]-col_ptr_f[3*(i-1)+1]) + col_ptr_f[3*(i-1)+1], frac*(col_ptr_f[3*i+2]-col_ptr_f[3*(i-1)+2]) + col_ptr_f[3*(i-1)+2]); break; case (TYPE_INT): color = DXRGB(frac*(col_ptr_i[3*i]-col_ptr_i[3*(i-1)]) + col_ptr_i[3*(i-1)], frac*(col_ptr_i[3*i+1]-col_ptr_i[3*(i-1)+1]) + col_ptr_i[3*(i-1)+1], frac*(col_ptr_i[3*i+2]-col_ptr_i[3*(i-1)+2]) + col_ptr_i[3*(i-1)+2]); break; } if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) { goto error; } colorcount++; if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) { goto error; } colorcount++; } point = DXPt(0.0, pos_ptr[i],0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; switch (colortype) { case (TYPE_FLOAT): color = DXRGB(col_ptr_f[3*i], col_ptr_f[3*i+1], col_ptr_f[3*i+2]); break; case (TYPE_INT): color = DXRGB(col_ptr_i[3*i], col_ptr_i[3*i+1], col_ptr_i[3*i+2]); break; } if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) { goto error; } colorcount++; point = DXPt(1.0, pos_ptr[i],0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) { goto error; } colorcount++; lastin=1; } else { if (lastin == 1) { point = DXPt(0.0, corner2.y, 0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; point = DXPt(1.0, corner2.y, 0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; frac = (corner2.y - pos_ptr[i-1])/(pos_ptr[i]-pos_ptr[i-1]); switch (colortype) { case (TYPE_FLOAT): color = DXRGB(frac*(col_ptr_f[3*i]-col_ptr_f[3*(i-1)]) + col_ptr_f[3*(i-1)], frac*(col_ptr_f[3*i+1]-col_ptr_f[3*(i-1)+1]) + col_ptr_f[3*(i-1)+1], frac*(col_ptr_f[3*i+2]-col_ptr_f[3*(i-1)+2]) + col_ptr_f[3*(i-1)+2]); break; case (TYPE_INT): color = DXRGB(frac*(col_ptr_i[3*i]-col_ptr_i[3*(i-1)]) + col_ptr_i[3*(i-1)], frac*(col_ptr_i[3*i+1]-col_ptr_i[3*(i-1)+1]) + col_ptr_i[3*(i-1)+1], frac*(col_ptr_i[3*i+2]-col_ptr_i[3*(i-1)+2]) + col_ptr_i[3*(i-1)+2]); break; } if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) { goto error; } colorcount++; if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) { goto error; } colorcount++; } lastin = 0; } } } else { for (i=0; i=corner1.x) && (pos_ptr[i]<=corner2.x)) { if ((i > 0) && (lastin == 0)) { point = DXPt(corner1.x, 0.0, 0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; point = DXPt(corner1.x, 1.0, 0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; frac = (corner1.x - pos_ptr[i-1])/(pos_ptr[i]-pos_ptr[i-1]); switch (colortype) { case (TYPE_FLOAT): color = DXRGB(frac*(col_ptr_f[3*i]-col_ptr_f[3*(i-1)]) + col_ptr_f[3*(i-1)], frac*(col_ptr_f[3*i+1]-col_ptr_f[3*(i-1)+1]) + col_ptr_f[3*(i-1)+1], frac*(col_ptr_f[3*i+2]-col_ptr_f[3*(i-1)+2]) + col_ptr_f[3*(i-1)+2]); break; case (TYPE_INT): color = DXRGB(frac*(col_ptr_i[3*i]-col_ptr_i[3*(i-1)]) + col_ptr_i[3*(i-1)], frac*(col_ptr_i[3*i+1]-col_ptr_i[3*(i-1)+1]) + col_ptr_i[3*(i-1)+1], frac*(col_ptr_i[3*i+2]-col_ptr_i[3*(i-1)+2]) + col_ptr_i[3*(i-1)+2]); break; } if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) { goto error; } colorcount++; if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) { goto error; } colorcount++; } point = DXPt(0.0, pos_ptr[i],0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } point = DXPt(pos_ptr[i],0.0,0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; switch (colortype) { case (TYPE_FLOAT): color = DXRGB(col_ptr_f[3*i], col_ptr_f[3*i+1], col_ptr_f[3*i+2]); break; case (TYPE_INT): color = DXRGB(col_ptr_i[3*i], col_ptr_i[3*i+1], col_ptr_i[3*i+2]); break; } if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) { goto error; } colorcount++; point = DXPt(pos_ptr[i],1.0,0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) { goto error; } colorcount++; lastin=1; } else { if (lastin == 1) { point = DXPt(corner2.x, 0.0, 0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; point = DXPt(corner2.x, 1.0, 0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; frac = (corner2.x - pos_ptr[i-1])/(pos_ptr[i]-pos_ptr[i-1]); switch (colortype) { case (TYPE_FLOAT): color = DXRGB(frac*(col_ptr_f[3*i]-col_ptr_f[3*(i-1)]) + col_ptr_f[3*(i-1)], frac*(col_ptr_f[3*i+1]-col_ptr_f[3*(i-1)+1]) + col_ptr_f[3*(i-1)+1], frac*(col_ptr_f[3*i+2]-col_ptr_f[3*(i-1)+2]) + col_ptr_f[3*(i-1)+2]); break; case (TYPE_INT): color = DXRGB(frac*(col_ptr_i[3*i]-col_ptr_i[3*(i-1)]) + col_ptr_i[3*(i-1)], frac*(col_ptr_i[3*i+1]-col_ptr_i[3*(i-1)+1]) + col_ptr_i[3*(i-1)+1], frac*(col_ptr_i[3*i+2]-col_ptr_i[3*(i-1)+2]) + col_ptr_i[3*(i-1)+2]); break; } if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) { goto error; } colorcount++; if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) { goto error; } colorcount++; } lastin = 0; } } } } else { if (horizontal == 0) { for (i=0; i=corner1.y) && (pos_ptr[i]<=corner2.y)) { point = DXPt(0.0, pos_ptr[i],0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; if ((!lastok)&&(i <= numcolors)) { /* deal with the first bin */ if (i==0) /* make first bin black */ { color = DXRGB(0.0, 0.0, 0.0); if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) goto error; colorcount++; } else { switch (colortype) { case (TYPE_FLOAT): color = DXRGB(col_ptr_f[3*(i-1)], col_ptr_f[3*(i-1)+1], col_ptr_f[3*(i-1)+2]); break; case (TYPE_INT): color = DXRGB(col_ptr_i[3*(i-1)], col_ptr_i[3*(i-1)+1], col_ptr_i[3*(i-1)+2]); break; } if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) goto error; colorcount++; } } if (lastok && (i <= numcolors)) { switch (colortype) { case (TYPE_FLOAT): color = DXRGB(col_ptr_f[3*(i-1)], col_ptr_f[3*(i-1)+1], col_ptr_f[3*(i-1)+2]); break; case (TYPE_INT): color = DXRGB(col_ptr_i[3*(i-1)], col_ptr_i[3*(i-1)+1], col_ptr_i[3*(i-1)+2]); break; } if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) { goto error; } colorcount++; } point = DXPt(1.0, pos_ptr[i],0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; lastok=1; } if (pos_ptr[i]>corner2.y) break; } /* add the maximum if given */ point = DXPt(0.0, corner2.y,0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) goto error; curcount++; point = DXPt(1.0, corner2.y,0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) goto error; curcount++; if (i>numcolors) /* make last bin black */ { color = DXRGB(0.0, 0.0, 0.0); if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) goto error; colorcount++; } else { switch (colortype) { case (TYPE_FLOAT): color = DXRGB(col_ptr_f[3*(i-1)], col_ptr_f[3*(i-1)+1], col_ptr_f[3*(i-1)+2]); break; case (TYPE_INT): color = DXRGB(col_ptr_i[3*(i-1)], col_ptr_i[3*(i-1)+1], col_ptr_i[3*(i-1)+2]); break; } if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) goto error; colorcount++; } } /* else horizontal = 1 */ else { /* add the minimum if given */ point = DXPt(corner1.x,0.0, 0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) goto error; curcount++; point = DXPt(corner1.x,1.0, 0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) goto error; curcount++; for (i=0; i=corner1.x) && (pos_ptr[i]<=corner2.x)) { point = DXPt(pos_ptr[i],0.0,0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; if ((!lastok)&&(i <= numcolors)) { /* deal with the first bin */ if (i==0) /* make first bin black */ { color = DXRGB(0.0, 0.0, 0.0); if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) goto error; colorcount++; } else { switch (colortype) { case (TYPE_FLOAT): color = DXRGB(col_ptr_f[3*(i-1)], col_ptr_f[3*(i-1)+1], col_ptr_f[3*(i-1)+2]); break; case (TYPE_INT): color = DXRGB(col_ptr_i[3*(i-1)], col_ptr_i[3*(i-1)+1], col_ptr_i[3*(i-1)+2]); break; } if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) goto error; colorcount++; } } if (lastok&&(i<=numcolors)) { switch (colortype) { case (TYPE_FLOAT): color = DXRGB(col_ptr_f[3*(i-1)], col_ptr_f[3*(i-1)+1], col_ptr_f[3*(i-1)+2]); break; case (TYPE_INT): color = DXRGB(col_ptr_i[3*(i-1)], col_ptr_i[3*(i-1)+1], col_ptr_i[3*(i-1)+2]); break; } if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) { goto error; } colorcount++; } point = DXPt(pos_ptr[i],1.0,0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) { goto error; } curcount++; lastok=1; } if (pos_ptr[i]>corner2.x) break; } /* add the maximum if given */ point = DXPt(corner2.x,0.0, 0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) goto error; curcount++; point = DXPt(corner2.x, 1.0, 0.0); if (!(DXAddArrayData(a_newpositions, curcount, 1, (Pointer)&point))) goto error; curcount++; if (i>numcolors) /* make last bin black */ { color = DXRGB(0.0, 0.0, 0.0); if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) goto error; colorcount++; } else { switch (colortype) { case (TYPE_FLOAT): color = DXRGB(col_ptr_f[3*(i-1)], col_ptr_f[3*(i-1)+1], col_ptr_f[3*(i-1)+2]); break; case (TYPE_INT): color = DXRGB(col_ptr_i[3*(i-1)], col_ptr_i[3*(i-1)+1], col_ptr_i[3*(i-1)+2]); break; } if (!(DXAddArrayData(a_newcolors, colorcount, 1, (Pointer)&color))) goto error; colorcount++; } } } /* else no corners */ else { if (horizontal == 0) { for (i=0; i