void champg(char *name, int colored, double *x, double *y, double *fx, double *fy, int *n1, int *n2, char *strflag, double *brect, double *arfact, int lstr) { int iSubwinUID = 0; int iNewSegsUID = 0; int clipState = 0; char textLogFlags[3]; double xx[2]; double yy[2]; double* boundingBox = NULL; double rotationAngles[2]; int nn1 = 1; int nn2 = 2; int autoScale = 0; int* piAutoScale = &autoScale; int firstPlot = 0; int* piFirstPlot = &firstPlot; int logFlags[3]; int flag, type = 1; double arsize1 = 0.; int *style = NULL; int iTmp = 0; int* piTmp = &iTmp; int i = 0; double drect[6]; BOOL bounds_changed = FALSE; BOOL axes_properties_changed = FALSE; /* champ with color inherited from subwin */ /* or champ1 (normed vector + color) is enabled */ int typeofchamp = (colored == 0 ? 0 : 1); /* First create champ object */ /* F.Leray Allocation de style[dim = Nbr1] */ if ((style = (int*)MALLOC ((*n1) * sizeof (int))) == NULL) { Scierror(999, _("%s: No more memory.\n"), "champg"); return; } flag = 1; /* je le mets � 1 pour voir F.Leray 19.02.04*/ arsize1 = *arfact; iSubwinUID = getCurrentSubWin(); /* then modify subwindow if needed */ checkRedrawing(); /* Force clipping to CLIPGRF (1) */ clipState = 1; setGraphicObjectProperty(iSubwinUID, __GO_CLIP_STATE__, &clipState, jni_int, 1); for (i = 0; i < (*n1); i++) { style[i] = i; } iNewSegsUID = createChamp(iSubwinUID, x, *n1, y, *n2, fx, *n1 * *n2, fy, *n1 * *n2, arsize1, typeofchamp != 0); if (iNewSegsUID == 0) { Scierror(999, _("%s: No more memory.\n"), "champg"); if (style != NULL) { FREE(style); } return; } setCurrentObject(iNewSegsUID); if (style != NULL) { FREE(style); style = NULL; } /* Get segs bounding box */ getGraphicObjectProperty(iNewSegsUID, __GO_BOUNDING_BOX__, jni_double_vector, (void **)&boundingBox); if (!boundingBox) { Scierror(999, _("%s: Could not retrive bounding box.\n"), "champg"); return; } xx[0] = boundingBox[0]; xx[1] = boundingBox[1]; yy[0] = boundingBox[2]; yy[1] = boundingBox[3]; releaseGraphicObjectProperty(__GO_BOUNDING_BOX__, boundingBox, jni_double_vector, 4); rotationAngles[0] = 0.0; rotationAngles[1] = 270.0; setGraphicObjectProperty(iSubwinUID, __GO_ROTATION_ANGLES__, rotationAngles, jni_double_vector, 2); getGraphicObjectProperty(iSubwinUID, __GO_AUTO_SCALE__, jni_bool, (void **)&piAutoScale); getGraphicObjectProperty(iSubwinUID, __GO_FIRST_PLOT__, jni_bool, (void **)&piFirstPlot); 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': 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, 'g', textLogFlags, xx, yy, nn1, nn2, drect); break; } /* merge data bounds and drect */ if (!firstPlot && (strflag[1] == '7' || strflag[1] == '8' || strflag[1] == '9')) { 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); /* just after strflag2axes_properties */ firstPlot = 0; setGraphicObjectProperty(iSubwinUID, __GO_FIRST_PLOT__, &firstPlot, jni_bool, 1); }
int plot2dn(int ptype, char *logflags, double *x, double *y, int *n1, int *n2, int *style, char *strflag, char *legend, double *brect, int *aaint, BOOL flagNax, int lstr1, int lstr2) { int iSubwinUID = 0; int iCurFigureUID = 0; int closeflag = 0; int jj = 0; long hdl = 0; int *pObj = NULL; int cmpt = 0; int with_leg = 0; double drect[6]; char dataflag = 0; BOOL bounds_changed = FALSE; BOOL axes_properties_changed = FALSE; double rotationAngles[2]; int clipState = 0; int autoScale = 0; int logFlags[3]; int iTmp = 0; int *piTmp = &iTmp; char textLogFlags[3]; int firstPlot = 0; int newFirstPlot = 0; int autoSubticks = 0; iSubwinUID = getOrCreateDefaultSubwin(); /* * Check if the auto_clear property is on and then erase everything * To be implemented */ checkRedrawing(); rotationAngles[0] = 0.0; rotationAngles[1] = 270.0; setGraphicObjectProperty(iSubwinUID, __GO_ROTATION_ANGLES__, rotationAngles, jni_double_vector, 2); /* Force logflags to those given by argument */ getGraphicObjectProperty(iSubwinUID, __GO_FIRST_PLOT__, jni_bool, (void **)&piTmp); firstPlot = 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); } /* Forces "clipgrf" clipping (1) */ clipState = 1; setGraphicObjectProperty(iSubwinUID, __GO_CLIP_STATE__, &clipState, jni_int, 1); getGraphicObjectProperty(iSubwinUID, __GO_AUTO_SCALE__, jni_bool, (void **)&piTmp); autoScale = iTmp; 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]); compute_data_bounds2(0, dataflag, textLogFlags, x, y, *n1, *n2, drect); break; } /* merge data bounds and drect */ if (!firstPlot && (strflag[1] == '5' || strflag[1] == '7' || strflag[1] == '8' || strflag[1] == '9')) { 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; } /* Adapted to the MVC */ axes_properties_changed = strflag2axes_properties(iSubwinUID, strflag); /* just after strflag2axes_properties */ newFirstPlot = 0; setGraphicObjectProperty(iSubwinUID, __GO_FIRST_PLOT__, &newFirstPlot, jni_bool, 1); with_leg = (strflag[0] == '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) { 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; if (logFlags[0] == 0 && logFlags[1] == 0) { int autoTicks = 0; int i = 0; int iSize = 0; double dblFabs = 0; char** stringVector = NULL; if (aaint[1] == -1) { autoTicks = 1; setGraphicObjectProperty(iSubwinUID, __GO_X_AXIS_AUTO_TICKS__, &autoTicks, jni_bool, 1); } else if (aaint[1] == 0) { setGraphicObjectProperty(iSubwinUID, __GO_X_AXIS_TICKS_LOCATIONS__, NULL, jni_double_vector, 0); autoTicks = 0; setGraphicObjectProperty(iSubwinUID, __GO_X_AXIS_AUTO_TICKS__, &autoTicks, jni_bool, 1); } else { double* dXGrads = (double*) MALLOC(aaint[1] * sizeof(double)); // Compute X grads dXGrads[0] = drect[0]; if (aaint[1] > 1) { double pas = (drect[1] - drect[0]) / (aaint[1] - 1); for (i = 0; i < aaint[1]; i++) { dXGrads[i] = drect[0] + pas * i; } } autoTicks = 0; setGraphicObjectProperty(iSubwinUID, __GO_X_AXIS_AUTO_TICKS__, &autoTicks, jni_bool, 1); setGraphicObjectProperty(iSubwinUID, __GO_X_AXIS_TICKS_LOCATIONS__, dXGrads, jni_double_vector, aaint[1]); // Create X Labels stringVector = (char **) MALLOC(aaint[1] * sizeof(char*)); for (i = 0; i < aaint[1]; i++) { iSize = 6; if (dXGrads[i] < 0) { iSize += 2; } dblFabs = fabs(dXGrads[i]); if (dblFabs >= 10) { iSize = iSize + (int)floor(log10(dblFabs)); } stringVector[i] = (char*) MALLOC(iSize * sizeof(char)); sprintf(stringVector[i], "%.3f", dXGrads[i]); stringVector[i][iSize - 1] = '\0'; } setGraphicObjectProperty(iSubwinUID, __GO_X_AXIS_TICKS_LABELS__, stringVector, jni_string_vector, aaint[1]); for (i = 0; i < aaint[1]; i++) { FREE(stringVector[i]); } FREE(stringVector); FREE(dXGrads); stringVector = NULL; } if (aaint[3] == -1) { autoTicks = 1; setGraphicObjectProperty(iSubwinUID, __GO_Y_AXIS_AUTO_TICKS__, &autoTicks, jni_bool, 1); } else if (aaint[3] == 0) { setGraphicObjectProperty(iSubwinUID, __GO_Y_AXIS_TICKS_LOCATIONS__, NULL, jni_double_vector, 0); autoTicks = 0; setGraphicObjectProperty(iSubwinUID, __GO_Y_AXIS_AUTO_TICKS__, &autoTicks, jni_bool, 1); } else { double* dYGrads = (double*) MALLOC(aaint[3] * sizeof(double)); // Compute Y grads dYGrads[0] = drect[2]; if (aaint[3] > 1) { double pas = (drect[3] - drect[2]) / (aaint[3] - 1); for (i = 0; i < aaint[3]; i++) { dYGrads[i] = drect[2] + pas * i; } } autoTicks = 0; setGraphicObjectProperty(iSubwinUID, __GO_Y_AXIS_AUTO_TICKS__, &autoTicks, jni_bool, 1); setGraphicObjectProperty(iSubwinUID, __GO_Y_AXIS_TICKS_LOCATIONS__, dYGrads, jni_double_vector, aaint[3]); // Create Y Labels stringVector = (char**) MALLOC(aaint[3] * sizeof(char*)); for (i = 0; i < aaint[3]; i++) { iSize = 6; if (dYGrads[i] < 0) { iSize += 2; } dblFabs = fabs(dYGrads[i]); if (dblFabs >= 10) { iSize = iSize + (int)floor(log10(dblFabs)); } stringVector[i] = (char*) MALLOC(iSize * sizeof(char)); sprintf(stringVector[i], "%.3f", dYGrads[i]); stringVector[i][iSize - 1] = '\0'; } setGraphicObjectProperty(iSubwinUID, __GO_Y_AXIS_TICKS_LABELS__, stringVector, jni_string_vector, aaint[3]); for (i = 0; i < aaint[3]; i++) { FREE(stringVector[i]); } FREE(stringVector); FREE(dYGrads); stringVector = NULL; } // X and Y subticks setGraphicObjectProperty(iSubwinUID, __GO_X_AXIS_SUBTICKS__, aaint, jni_int, 1); setGraphicObjectProperty(iSubwinUID, __GO_Y_AXIS_SUBTICKS__, &aaint[2], jni_int, 1); } else { sciprint(_("Warning: Nax does not work with logarithmic scaling.\n")); } } /*---- Drawing the curves and the legends ----*/ if (*n1 != 0) { if ((pObj = (int*)MALLOC((*n1 + 1) * sizeof(int))) == NULL) { Scierror(999, _("%s: No more memory.\n"), "plot2d"); return -1; } /*A.Djalel 3D axes */ for (jj = 0; jj < *n1; jj++) { int iObjUID = 0; if (style[jj] > 0) { BOOL isline = TRUE; if (ptype == 3) { isline = FALSE; } iObjUID = ConstructPolyline(getCurrentSubWin(), &(x[jj * (*n2)]), &(y[jj * (*n2)]), PD0, closeflag, *n2, ptype, &style[jj], NULL, NULL, NULL, NULL, isline, FALSE, FALSE, FALSE); } else { int minusstyle = -style[jj]; iObjUID = ConstructPolyline(getCurrentSubWin(), &(x[jj * (*n2)]), &(y[jj * (*n2)]), PD0, closeflag, *n2, ptype, NULL, NULL, &minusstyle, NULL, NULL, FALSE, FALSE, TRUE, FALSE); } if (iObjUID == 0) { // skip Scierror(999, _("%s: No more memory.\n"), "plot2d"); } else { setCurrentObject(iObjUID); pObj[cmpt] = iObjUID; cmpt++; } } /*---- Drawing the Legends ----*/ if (with_leg) { int iLegUID = 0; char **Str; int nleg; if (scitokenize(legend, &Str, &nleg)) { FREE(pObj); Scierror(999, _("%s: No more memory.\n"), "plot2d"); return 0; } iLegUID = ConstructLegend(getCurrentSubWin(), Str, pObj, Min(nleg, cmpt)); if (iLegUID != 0) { int legendLocation; int contourMode; /* 9: LOWER_CAPTION */ legendLocation = 9; setGraphicObjectProperty(iLegUID, __GO_LEGEND_LOCATION__, &legendLocation, jni_int, 1); contourMode = 0; setGraphicObjectProperty(iLegUID, __GO_FILL_MODE__, &contourMode, jni_bool, 1); setGraphicObjectProperty(iLegUID, __GO_LINE_MODE__, &contourMode, jni_bool, 1); } freeArrayOfString(Str, nleg); } /*---- construct Compound ----*/ if (cmpt > 0) { int parentVisible = 0; int *piParentVisible = &parentVisible; int iCompoundUID = createCompound(iSubwinUID, pObj, cmpt); setCurrentObject(iCompoundUID); } FREE(pObj); } /* End of the curves and legend block */ return 0; }
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); }