SEXP viewportTransform(SEXP vp) { return VECTOR_ELT(vp, PVP_TRANS); }
const char* viewportFontFamily(SEXP vp) { return CHAR(STRING_ELT(VECTOR_ELT(VECTOR_ELT(vp, PVP_GPAR), GP_FONTFAMILY), 0)); }
double viewportFontSize(SEXP vp) { return REAL(VECTOR_ELT(VECTOR_ELT(vp, PVP_GPAR), GP_FONTSIZE))[0]; }
double viewportVJust(SEXP vp) { return REAL(VECTOR_ELT(vp, VP_VALIDJUST))[1]; }
SEXP viewportLayoutPosCol(SEXP vp) { return VECTOR_ELT(vp, VP_VALIDLPOSCOL); }
double viewportXScaleMin(SEXP vp) { return numeric(VECTOR_ELT(vp, VP_XSCALE), 0); }
double viewportAngle(SEXP vp) { return numeric(VECTOR_ELT(vp, VP_ANGLE), 0); }
SEXP viewportClipRect(SEXP vp) { return VECTOR_ELT(vp, PVP_CLIPRECT); }
SEXP viewportParent(SEXP vp) { return VECTOR_ELT(vp, PVP_PARENT); }
SEXP viewportHeightCM(SEXP vp) { return VECTOR_ELT(vp, PVP_HEIGHTCM); }
SEXP viewportRotation(SEXP vp) { return VECTOR_ELT(vp, PVP_ROTATION); }
SEXP viewportWidthCM(SEXP vp) { return VECTOR_ELT(vp, PVP_WIDTHCM); }
SEXP viewportLayoutHeights(SEXP vp) { return VECTOR_ELT(vp, PVP_HEIGHTS); }
SEXP viewportLayoutWidths(SEXP vp) { return VECTOR_ELT(vp, PVP_WIDTHS); }
SEXP viewportHeight(SEXP vp) { return VECTOR_ELT(vp, VP_HEIGHT); }
SEXP viewportChildren(SEXP vp) { return VECTOR_ELT(vp, PVP_CHILDREN); }
Rboolean viewportClip(SEXP vp) { return LOGICAL(VECTOR_ELT(vp, VP_CLIP))[0]; }
SEXP viewportDevWidthCM(SEXP vp) { return VECTOR_ELT(vp, PVP_DEVWIDTHCM); }
double viewportYScaleMax(SEXP vp) { return numeric(VECTOR_ELT(vp, VP_YSCALE), 1); }
SEXP viewportDevHeightCM(SEXP vp) { return VECTOR_ELT(vp, PVP_DEVHEIGHTCM); }
SEXP viewportLayout(SEXP vp) { return VECTOR_ELT(vp, VP_LAYOUT); }
SEXP viewportParentGPar(SEXP vp) { return VECTOR_ELT(vp, PVP_PARENTGPAR); }
SEXP viewportLayoutPosRow(SEXP vp) { return VECTOR_ELT(vp, VP_VALIDLPOSROW); }
/* Some access methods for viewports */ SEXP viewportX(SEXP vp) { return VECTOR_ELT(vp, VP_X); }
SEXP viewportgpar(SEXP vp) { return VECTOR_ELT(vp, PVP_GPAR); }
SEXP viewportY(SEXP vp) { return VECTOR_ELT(vp, VP_Y); }
int viewportFont(SEXP vp) { return INTEGER(VECTOR_ELT(VECTOR_ELT(vp, PVP_GPAR), GP_FONT))[0]; }
SEXP viewportWidth(SEXP vp) { return VECTOR_ELT(vp, VP_WIDTH); }
SEXP readChunkPorStream(SEXP porStream, SEXP what, SEXP s_vars, SEXP s_ncases, SEXP s_types){ porStreamBuf *b = get_porStreamBuf(porStream); PROTECT(s_vars = coerceVector(s_vars,LGLSXP)); PROTECT(s_ncases = coerceVector(s_ncases,INTSXP)); PROTECT(s_types = coerceVector(s_types,INTSXP)); int nvar = length(s_types); int ncases = INTEGER(s_ncases)[0]; int *types = INTEGER(s_types); // if(LENGTH(s_vars)!=nvar) error("\'s_vars\' argument has wrong length"); int ii,i,j,k, m=0; for(j = 0; j < nvar; j++) m+=LOGICAL(s_vars)[j]; SEXP x, y, data; char *charbuf; int charbuflen = 0; PROTECT(data = allocVector(VECSXP,m)); k = 0; for(j = 0; j < nvar; j++){ if(types[j] > charbuflen) charbuflen = types[j]; if(LOGICAL(s_vars)[j]){ if(types[j]==0) SET_VECTOR_ELT(data,k,allocVector(REALSXP,ncases)); else { SET_VECTOR_ELT(data,k,allocVector(STRSXP,ncases)); } k++; } } charbuf = R_alloc(charbuflen+1,sizeof(char)); ii = 0; for(i = 0; i < ncases; i++){ if(atEndPorStream(b) || (b->pos < 80 && b->buf[b->pos] == 'Z')){ int new_length = ii; for(j = 0; j < m; j++){ x = VECTOR_ELT(data,j); SET_VECTOR_ELT(data,j,lengthgets(x,new_length)); } break; } k = 0; for(j = 0; j < nvar; j++){ if(atEndPorStream(b)) { printPorStreamBuf(b); warning("\nPremature end of data"); } if(types[j]==0){ if(LOGICAL(s_vars)[j]){ REAL(VECTOR_ELT(data,k))[ii] = readDoublePorStream1(b); k++; } else { readDoublePorStream1(b); } } else { if(LOGICAL(s_vars)[j]){ SET_STRING_ELT(VECTOR_ELT(data,k), ii, mkChar(readCHARPorStream(b,charbuf,types[j]))); k++; } else { readCHARPorStream(b,charbuf,types[j]); } } } ii++; } k = 0; for(j = 0; j < nvar; j++){ if(LOGICAL(s_vars)[j]){ x = VECTOR_ELT(what,j); y = VECTOR_ELT(data,k); copyMostAttrib(x,y); k++; } } UNPROTECT(4); return data; }
double viewportCex(SEXP vp) { return numeric(VECTOR_ELT(VECTOR_ELT(vp, PVP_GPAR), GP_CEX), 0); }