The R Project SVN R

Rev

Rev 11510 | Rev 12778 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 11510 Rev 12256
Line 735... Line 735...
735
	    buffer[strlen(buffer)+1] = '\0';
735
	    buffer[strlen(buffer)+1] = '\0';
736
	    buffer[strlen(buffer)] = ' ';
736
	    buffer[strlen(buffer)] = ' ';
737
 
737
 
738
	    if (vectorFonts) {
738
	    if (vectorFonts) {
739
		/* 1, 1 => sans serif, basic font */
739
		/* 1, 1 => sans serif, basic font */
-
 
740
		labelDistance = 
740
		labelDistance = GVStrWidth(buffer, typeface, fontindex,
741
		    GVStrWidth((unsigned char *)buffer, typeface, fontindex,
741
					   INCHES, dd);
742
			       INCHES, dd);
-
 
743
		labelHeight = 
742
		labelHeight = GVStrHeight(buffer, typeface, fontindex,
744
		    GVStrHeight((unsigned char *)buffer, typeface, fontindex,
743
					  INCHES, dd);
745
				INCHES, dd);
744
	    }
746
	    }
745
	    else {
747
	    else {
746
		labelDistance = GStrWidth(buffer, INCHES, dd);
748
		labelDistance = GStrWidth(buffer, INCHES, dd);
747
		labelHeight = GStrHeight(buffer, INCHES, dd);
749
		labelHeight = GStrHeight(buffer, INCHES, dd);
748
	    }
750
	    }
Line 1888... Line 1890...
1888
static void PerspAxis(double *x, double *y, double *z,
1890
static void PerspAxis(double *x, double *y, double *z,
1889
		      int axis, int axisType, int nTicks, int tickType,
1891
		      int axis, int axisType, int nTicks, int tickType,
1890
		      char *label, DevDesc *dd) {
1892
		      char *label, DevDesc *dd) {
1891
    Vector3d u1, u2, u3, v1, v2, v3;
1893
    Vector3d u1, u2, u3, v1, v2, v3;
1892
    double tickLength = .03; /* proportion of axis length */
1894
    double tickLength = .03; /* proportion of axis length */
1893
    double min, max;
1895
    double min, max, d_frac;
1894
    double *range = NULL; /* -Wall */
1896
    double *range = NULL; /* -Wall */
1895
    double axp[3];
1897
    double axp[3];
1896
    int nint, i;
1898
    int nint, i;
1897
    SEXP at, lab;
1899
    SEXP at, lab;
1898
    switch (axisType) {
1900
    switch (axisType) {
1899
    case 0:
1901
    case 0:
1900
	min = x[0];
-
 
1901
	max = x[1];
1902
	min = x[0];	max = x[1];	range = x;	break;
1902
	range = x;
-
 
1903
	break;
-
 
1904
    case 1:
1903
    case 1:
1905
	min = y[0];
-
 
1906
	max = y[1];
1904
	min = y[0];	max = y[1];	range = y;	break;
1907
	range = y;
-
 
1908
	break;
-
 
1909
    case 2:
1905
    case 2:
1910
	min = z[0];
-
 
1911
	max = z[1];
1906
	min = z[0];	max = z[1];	range = z;	break;
1912
	range = z;
-
 
1913
	break;
-
 
1914
    }
1907
    }
-
 
1908
    d_frac = 0.1*(max - min);
-
 
1909
    nint = nTicks - 1; if(!nint) nint++;
1915
    nint = nTicks-1;
1910
    i = nint;
1916
    GPretty(&min, &max, &nint);
1911
    GPretty(&min, &max, &nint);
-
 
1912
    /* GPretty() rarely gives values too much outside range ..
-
 
1913
       2D axis() clip these, we play cheaper */ 
-
 
1914
    while((min < range[0] - d_frac || range[1] + d_frac < max) && i < 20) {
-
 
1915
	nint = ++i;
-
 
1916
	min = range[0];
-
 
1917
	max = range[1];
-
 
1918
	GPretty(&min, &max, &nint);
-
 
1919
    }
1917
    axp[0] = min;
1920
    axp[0] = min;
1918
    axp[1] = max;
1921
    axp[1] = max;
1919
    axp[2] = nint;
1922
    axp[2] = nint;
1920
    /* Do the following calculations for both ticktypes */
1923
    /* Do the following calculations for both ticktypes */
1921
    switch (axisType) {
1924
    switch (axisType) {
Line 2107... Line 2110...
2107
    double ltheta, lphi;
2110
    double ltheta, lphi;
2108
    double expand, xc, yc, zc, xs, ys, zs;
2111
    double expand, xc, yc, zc, xs, ys, zs;
2109
    int i, j, scale, ncol, dobox, doaxes, nTicks, tickType;
2112
    int i, j, scale, ncol, dobox, doaxes, nTicks, tickType;
2110
    DevDesc *dd;
2113
    DevDesc *dd;
2111
 
2114
 
2112
    if (length(args) < 18)
2115
    if (length(args) < 24)
2113
	errorcall(call, "too few parameters");
2116
	errorcall(call, "too few parameters");
2114
    gcall = call;
2117
    gcall = call;
2115
    originalArgs = args;
2118
    originalArgs = args;
2116
 
2119
 
2117
    PROTECT(x = coerceVector(CAR(args), REALSXP));
2120
    PROTECT(x = coerceVector(CAR(args), REALSXP));
Line 2243... Line 2246...
2243
    PROTECT(depth = allocVector(REALSXP, (nrows(z) - 1)*(ncols(z) - 1)));
2246
    PROTECT(depth = allocVector(REALSXP, (nrows(z) - 1)*(ncols(z) - 1)));
2244
    PROTECT(indx = allocVector(INTSXP, (nrows(z) - 1)*(ncols(z) - 1)));
2247
    PROTECT(indx = allocVector(INTSXP, (nrows(z) - 1)*(ncols(z) - 1)));
2245
    DepthOrder(REAL(z), REAL(x), REAL(y), nrows(z), ncols(z),
2248
    DepthOrder(REAL(z), REAL(x), REAL(y), nrows(z), ncols(z),
2246
	       REAL(depth), INTEGER(indx));
2249
	       REAL(depth), INTEGER(indx));
2247
 
2250
 
2248
    /* Now we order the facets by depth */
2251
    /* Now we order the facets by depth and then draw them back to front.
2249
    /* and then draw them back to front. */
-
 
2250
    /* This is the "painters" algorithm. */
2252
     * This is the "painters" algorithm. */
2251
 
2253
 
2252
    GMode(1, dd);
2254
    GMode(1, dd);
2253
 
2255
 
2254
    if (dobox) {
2256
    if (dobox) {
2255
        PerspBox(0, REAL(xlim), REAL(ylim), REAL(zlim), dd);
2257
        PerspBox(0, REAL(xlim), REAL(ylim), REAL(zlim), dd);
Line 2274... Line 2276...
2274
        recordGraphicOperation(op, originalArgs, dd);
2276
        recordGraphicOperation(op, originalArgs, dd);
2275
 
2277
 
2276
    PROTECT(x = allocVector(REALSXP, 16));
2278
    PROTECT(x = allocVector(REALSXP, 16));
2277
    PROTECT(y = allocVector(INTSXP, 2));
2279
    PROTECT(y = allocVector(INTSXP, 2));
2278
    for (i = 0; i < 4; i++)
2280
    for (i = 0; i < 4; i++)
2279
      for (j = 0; j < 4; j++) {
2281
	for (j = 0; j < 4; j++)
2280
        REAL(x)[i + j * 4] = VT[i][j];
2282
	    REAL(x)[i + j * 4] = VT[i][j];
2281
      }
-
 
2282
    INTEGER(y)[0] = 4;
2283
    INTEGER(y)[0] = 4;
2283
    INTEGER(y)[1] = 4;
2284
    INTEGER(y)[1] = 4;
2284
    setAttrib(x, R_DimSymbol, y);
2285
    setAttrib(x, R_DimSymbol, y);
2285
    UNPROTECT(2);
2286
    UNPROTECT(2);
2286
    return x;
2287
    return x;