/*------------------------------------------------------------------------*/ static void getDrect(const double vector[], int nbElements, double* dMin, double* dMax, double defaultMin, double defaultMax) { if (containsOneFiniteElement(vector, nbElements)) { *dMin = Mini(vector, nbElements); *dMax = Maxi(vector, nbElements); } else { *dMin = defaultMin; *dMax = defaultMax; } }
int C2F(contourif)(double *x, double *y, double *z, int *n1, int *n2, int *flagnz, int *nz, double *zz, int *style) { int err = 0; static double *zconst = NULL; double zmin = 0., zmax = 0.; int N[3], i = 0; zmin = (double) Mini(z, *n1 * (*n2)); zmax = (double) Maxi(z, *n1 * (*n2)); if (*flagnz == 0) { if ( ( zconst = MALLOC( (*nz) * sizeof(double) ) ) == 0 ) { Scierror(999, _("%s: No more memory.\n"), "contourif"); return -1; } for ( i = 0 ; i < *nz ; i++) { zconst[i] = zmin + (i + 1) * (zmax - zmin) / (*nz + 1); } N[0] = *n1; N[1] = *n2; N[2] = *nz; contourI(GContStore2, x, y, z, zconst, N, style, &err); FREE(zconst) ; zconst = NULL ; } else { N[0] = *n1; N[1] = *n2; N[2] = *nz; contourI(GContStore2, x, y, z, zz, N, style, &err); } return 0 ; }
/* Given two set of coordinates x and y this routine computes the corresponding * data bounds rectangle drect=[xmin,ymin,xmax,ymax] taking into account the logflag * -> means we have to find among the data the min > 0. */ void compute_data_bounds2(int cflag, char dataflag, char *logflags, double *x, double *y, int n1, int n2, double *drect) { int size_x = 0, size_y = 0; double xd[2]; double *x1 = NULL; switch (dataflag) { case 'e': xd[0] = 1.0; xd[1] = (double)n2; x1 = xd; size_x = (n2 != 0) ? 2 : 0; break; case 'o': x1 = x; size_x = n2; break; case 'g': default: x1 = x; size_x = (cflag == 1) ? n1 : (n1 * n2); break; } if (size_x != 0) { if (logflags[0] != 'l') { MiniMaxi(x1, size_x, drect, drect + 1); //drect[0] = Mini(x1, size_x); //drect[1] = Maxi(x1, size_x); } else { /* log. case */ drect[0] = sciFindStPosMin(x1, size_x); drect[1] = Maxi(x1, size_x); } } else { if (logflags[0] != 'l') { drect[0] = 0.0; drect[1] = 10.0; } else { /* log. case */ drect[0] = 1.0; drect[1] = 10.0; } } size_y = (cflag == 1) ? n2 : (n1 * n2); if (size_y != 0) { if (logflags[1] != 'l') { MiniMaxi(y, size_y, drect + 2, drect + 3); //drect[2] = Mini(y, size_y); //drect[3] = Maxi(y, size_y); } else { /* log. case */ drect[2] = sciFindStPosMin(y, size_y); drect[3] = Maxi(y, size_y); } } else { if (logflags[1] != 'l') { drect[2] = 0.0; drect[3] = 10.0; } else { /* log. case */ drect[2] = 1.0; drect[3] = 10.0; } } /* back to default values for x=[] and y = [] */ if (drect[2] == LARGEST_REAL || drect[3] == -LARGEST_REAL || C2F(isanan)(&drect[2]) || C2F(isanan)(&drect[3])) { if (logflags[1] != 'l') { drect[2] = 0.0; } else { drect[2] = 1.0; } drect[3] = 10.0; } if (drect[0] == LARGEST_REAL || drect[1] == -LARGEST_REAL || C2F(isanan)(&drect[0]) || C2F(isanan)(&drect[1])) { if (logflags[0] != 'l') { drect[0] = 0.0; } else { drect[0] = 1.0; } drect[1] = 10.0; } }
int Max(const int* A, const int sz) { return A[Maxi(A,sz)]; }
int C2F(xgray)(double *x, double *y, double *z, int *n1, int *n2, char *strflag, double *brect, int *aaint, BOOL flagNax, char *logflags, long int l1) { int iSubwinUID = 0; int iGrayplotUID = 0; double xx[2], yy[2]; int nn1 = 1, nn2 = 2; double drect[6]; BOOL bounds_changed = FALSE; BOOL isRedrawn = FALSE; BOOL axes_properties_changed = FALSE; char textLogFlags[3]; double rotationAngles[2]; int clipState = 0; int autoScale = 0; int firstPlot = 0; int logFlags[3]; char dataflag = 0; int autoSubticks = 0; int iTmp = 0; int* piTmp = &iTmp; xx[0] = Mini(x, *n1); xx[1] = Maxi(x, *n1); yy[0] = Mini(y, *n2); yy[1] = Maxi(y, *n2); /* Adding F.Leray 22.04.04 */ iSubwinUID = getCurrentSubWin(); isRedrawn = checkRedrawing(); rotationAngles[0] = 0.0; rotationAngles[1] = 270.0; setGraphicObjectProperty(iSubwinUID, __GO_ROTATION_ANGLES__, rotationAngles, jni_double_vector, 2); /* Force "cligrf" clipping (1) */ clipState = 1; setGraphicObjectProperty(iSubwinUID, __GO_CLIP_STATE__, &clipState, jni_int, 1); getGraphicObjectProperty(iSubwinUID, __GO_FIRST_PLOT__, jni_bool, (void **)&piTmp); firstPlot = iTmp; getGraphicObjectProperty(iSubwinUID, __GO_AUTO_SCALE__, jni_bool, (void **)&piTmp); autoScale = iTmp; /* Reset x and y logflags */ if (firstPlot) { logFlags[0] = getBooleanLogFlag(logflags[1]); logFlags[1] = getBooleanLogFlag(logflags[2]); setGraphicObjectProperty(iSubwinUID, __GO_X_AXIS_LOG_FLAG__, &logFlags[0], jni_bool, 1); setGraphicObjectProperty(iSubwinUID, __GO_Y_AXIS_LOG_FLAG__, &logFlags[1], jni_bool, 1); } if (autoScale) { /* compute and merge new specified bounds with the data bounds */ switch (strflag[1]) { case '0': /* do not change data bounds */ break; case '1' : case '3' : case '5' : case '7': /* Force data bounds=brect */ re_index_brect(brect, drect); break; case '2' : case '4' : case '6' : case '8': case '9': /* Force data bounds to the x and y bounds */ if ((int)strlen(logflags) < 1) { dataflag = 'g'; } else { dataflag = logflags[0]; } getGraphicObjectProperty(iSubwinUID, __GO_X_AXIS_LOG_FLAG__, jni_bool, (void **)&piTmp); logFlags[0] = iTmp; getGraphicObjectProperty(iSubwinUID, __GO_Y_AXIS_LOG_FLAG__, jni_bool, (void **)&piTmp); logFlags[1] = iTmp; getGraphicObjectProperty(iSubwinUID, __GO_Z_AXIS_LOG_FLAG__, jni_bool, (void **)&piTmp); logFlags[2] = iTmp; /* Conversion required by compute_data_bounds2 */ textLogFlags[0] = getTextLogFlag(logFlags[0]); textLogFlags[1] = getTextLogFlag(logFlags[1]); textLogFlags[2] = getTextLogFlag(logFlags[2]); /* Force data bounds to the x and y bounds */ compute_data_bounds2(0, dataflag, textLogFlags, xx, yy, nn1, nn2, drect); break; } /* merge data bounds and drect */ if (!firstPlot && (strflag[1] == '7' || strflag[1] == '8')) { double* dataBounds; getGraphicObjectProperty(iSubwinUID, __GO_DATA_BOUNDS__, jni_double_vector, (void **)&dataBounds); drect[0] = Min(dataBounds[0], drect[0]); /*xmin*/ drect[2] = Min(dataBounds[2], drect[2]); /*ymin*/ drect[1] = Max(dataBounds[1], drect[1]); /*xmax*/ drect[3] = Max(dataBounds[3], drect[3]); /*ymax*/ } if (strflag[1] != '0') { bounds_changed = update_specification_bounds(iSubwinUID, drect, 2); } } if (firstPlot) { bounds_changed = TRUE; } axes_properties_changed = strflag2axes_properties(iSubwinUID, strflag); firstPlot = 0; setGraphicObjectProperty(iSubwinUID, __GO_FIRST_PLOT__, &firstPlot, jni_bool, 1); /* F.Leray 07.10.04 : trigger algo to init. manual graduation u_xgrads and u_ygrads if nax (in matdes.c which is == aaint HERE) was specified */ /* The MVC AUTO_SUBTICKS property corresponds to !flagNax */ autoSubticks = !flagNax; setGraphicObjectProperty(iSubwinUID, __GO_AUTO_SUBTICKS__, &autoSubticks, jni_bool, 1); if (flagNax == TRUE) { if (logFlags[0] == 0 && logFlags[1] == 0) { int autoTicks; autoTicks = 0; setGraphicObjectProperty(iSubwinUID, __GO_X_AXIS_AUTO_TICKS__, &autoTicks, jni_bool, 1); setGraphicObjectProperty(iSubwinUID, __GO_Y_AXIS_AUTO_TICKS__, &autoTicks, jni_bool, 1); } else { Sciwarning(_("Warning: Nax does not work with logarithmic scaling.\n")); } } /* Constructs the object */ iGrayplotUID = ConstructGrayplot(getCurrentSubWin(), x, y, z, *n1, *n2, 0); /* Failed allocation */ if (iGrayplotUID == 0) { Scierror(999, _("%s: No more memory.\n"), "grayplot"); return -1; } /* Sets the grayplot as current */ setCurrentObject(iGrayplotUID); return (0); }