Subversion Repositories bdplot

Rev

Rev 5 | Rev 11 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

### bdopen
### Used to open a graphics driver with BDplot.

### In both jpeg and X11,  height  and width are scaled to
### jpeg: get a decent resolution (can't get it working with the true distances...)
### X11: to get a nicer window on the screen.
### This hack is ugly. At least there should be a scaling factor in stead so that all measures are scaled (fonts, etc).

bdopen <- function(file=bdp()$file,paper=bdp()$paper,mfrow=bdp()$mfrow)
{
  .bdcalcsizes(paper=paper)
  prm <- .bdgetpars()
  if( !is.na(prm$file) )
    {
      ## If figdir is supplied, prepending it to filename.
      if(!is.null(prm$figdir)&!is.na(prm$figdir))
        {
          prm$file <- paste(prm$figdir,prm$file,sep="")
        }
      ## determining device driver from filename
      nchars <- nchar(prm$file)

      if( any( substr(prm$file,nchars-2,nchars)==".ps",substr(prm$file,nchars-3,nchars)==".eps")){
        m <- {
          cat("B/D plotting writing to postscript file\n")
          postscript(file=prm$file, width=prm$width, height=prm$height, paper="special", horizontal=FALSE, family = "Helvetica")
        }
      } else if ( substr(prm$file,nchars-3,nchars)==".pdf")
        {
          pdf(file=prm$file, width=prm$width, height=prm$height)
        } else if (any(substr(prm$file,nchars-3,nchars)==".jpg", substr(prm$file,nchars-4,nchars)==".jpeg")) {
          cat("Writing to jpeg file\n")
          jpeg(filename=prm$file,width=prm$width*2,height=prm$height*2,units=prm$size.unit,quality=prm$jpeg.quality,res=prm$jpeg.res,type="cairo")
##          bitmap(file=prm$file,type="jpeg",width=prm$width,height=prm$height,units=prm$size.unit,res=prm$jpeg.res,pointsize=.3)
        }
    }
  else {
    ## to X. Note that this doesn't work on win and osx.
    X11(height=prm$height*2,width=prm$width*2)
    }

  par(mfrow=mfrow)
 }