Subversion Repositories bdplot

Rev

Rev 5 | Rev 11 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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