Subversion Repositories bdplot

Rev

Rev 34 | Rev 51 | 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 X11, height  and width are scaled 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,scale=TRUE,quality=NULL,scaleheight=1)
{
  .bdcalcsizes(paper=paper,mfrow=mfrow,scaleheight=scaleheight)
  prm <- .bdgetpars()
  if( !is.na(file) )
    {
      ## If figdir is supplied, prepending it to filename.
      if(!is.null(prm$figdir)&!is.na(prm$figdir))
        {
          file <- paste(prm$figdir,file,sep="/")
        }
      ## determining device driver from filename
      nchars <- nchar(file)

      if( any( substr(file,nchars-2,nchars)==".ps",substr(file,nchars-3,nchars)==".eps")){
        m <- {
          cat("B/D plotting writing to postscript file\n")
          postscript(file=file, width=prm$width, height=prm$height, paper="special", family = "Helvetica", horizontal=FALSE)
        }
      } else if ( substr(file,nchars-3,nchars)==".pdf")
        {
          pdf(file=file, width=prm$width, height=prm$height, paper="special",family = "Helvetica")
        } else if (any(substr(file,nchars-3,nchars)==".jpg", substr(file,nchars-4,nchars)==".jpeg")) {
          cat("Writing to jpeg file\n")
          if(is.null(quality))
            quality=prm$jpeg.quality
          jpeg(filename=file,width=prm$width,height=prm$height,units=prm$size.unit,quality=quality,res=prm$jpeg.res,type="cairo")
### bitmap(file=file,type="jpeg",width=prm$width,height=prm$height,units=prm$size.unit,res=prm$jpeg.res,pointsize=.3)
        }
    }
  else {

    if(scale){
      prm$height <- prm$height*2
      prm$width <- prm$width*2
    }
    ## to X. Note that this doesn't work on win and osx.
    X11(height=prm$height,width=prm$width)
  }

  par(mfrow=mfrow)
}