Subversion Repositories bdplot

Rev

Rev 47 | Rev 53 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 pdel 1
### bdopen
2
### Used to open a graphics driver with BDplot.
3
 
13 pdel 4
### In X11, height  and width are scaled to get a nicer window on the screen.
7 pdel 5
### This hack is ugly. At least there should be a scaling factor in stead so that all measures are scaled (fonts, etc).
6
 
47 pdel 7
bdopen <- function(file=bdp()$file,paper=bdp()$paper,mfrow=bdp()$mfrow,scale=TRUE,quality=NULL,scaleheight=1)
5 pdel 8
{
47 pdel 9
  .bdcalcsizes(paper=paper,mfrow=mfrow,scaleheight=scaleheight)
5 pdel 10
  prm <- .bdgetpars()
51 pdel 11
  print(prm$height)
23 pdel 12
  if( !is.na(file) )
5 pdel 13
    {
14
      ## If figdir is supplied, prepending it to filename.
15
      if(!is.null(prm$figdir)&!is.na(prm$figdir))
16
        {
34 pdel 17
          file <- paste(prm$figdir,file,sep="/")
5 pdel 18
        }
19
      ## determining device driver from filename
23 pdel 20
      nchars <- nchar(file)
5 pdel 21
 
23 pdel 22
      if( any( substr(file,nchars-2,nchars)==".ps",substr(file,nchars-3,nchars)==".eps")){
5 pdel 23
        m <- {
24
          cat("B/D plotting writing to postscript file\n")
23 pdel 25
          postscript(file=file, width=prm$width, height=prm$height, paper="special", family = "Helvetica", horizontal=FALSE)
5 pdel 26
        }
23 pdel 27
      } else if ( substr(file,nchars-3,nchars)==".pdf")
5 pdel 28
        {
23 pdel 29
          pdf(file=file, width=prm$width, height=prm$height, paper="special",family = "Helvetica")
30
        } else if (any(substr(file,nchars-3,nchars)==".jpg", substr(file,nchars-4,nchars)==".jpeg")) {
5 pdel 31
          cat("Writing to jpeg file\n")
29 pdel 32
          if(is.null(quality))
33
            quality=prm$jpeg.quality
34
          jpeg(filename=file,width=prm$width,height=prm$height,units=prm$size.unit,quality=quality,res=prm$jpeg.res,type="cairo")
23 pdel 35
### bitmap(file=file,type="jpeg",width=prm$width,height=prm$height,units=prm$size.unit,res=prm$jpeg.res,pointsize=.3)
5 pdel 36
        }
37
    }
38
  else {
27 pdel 39
 
40
    if(scale){
41
      prm$height <- prm$height*2
42
      prm$width <- prm$width*2
43
    }
5 pdel 44
    ## to X. Note that this doesn't work on win and osx.
27 pdel 45
    X11(height=prm$height,width=prm$width)
46
  }
5 pdel 47
 
48
  par(mfrow=mfrow)
27 pdel 49
}
15 pdel 50