R/enum.R

Defines functions rgl.enum.depthtest rgl.enum.pixelcomponent rgl.enum.gl2ps rgl.enum.texmagfilter rgl.enum.texminfilter rgl.enum.primtype rgl.enum.fogtype rgl.enum.textype rgl.enum.polymode rgl.enum.pixfmt rgl.enum.attribtype rgl.enum.nodetype rgl.enum

Documented in rgl.enum rgl.enum.fogtype rgl.enum.gl2ps rgl.enum.nodetype rgl.enum.pixfmt rgl.enum.polymode rgl.enum.primtype rgl.enum.texmagfilter rgl.enum.texminfilter rgl.enum.textype

# enumerations

rgl.enum <- function( name, ..., multi = FALSE) {
  choices <- list( ... )
  names   <- attr(choices,"names")

  if (multi) pos <- pmatch( name, c(names, "all") )
  else pos <- pmatch( name, names )
 
  max <- length(names)

  if ( any( is.na(pos) ) )
    stop(gettextf("Symbolic value must be chosen from: %s", list(names)), domain = NA)
  else if ( (max+1) %in% pos )
    pos <- seq_along(names)
    
  id  <- unlist(choices[pos])
  
  if ( length(id) > 1 && !multi )
    stop("Multiple choices not allowed")
 
  return( id )
}

rgl.enum.nodetype <- function(type) 
rgl.enum( type, shapes=1, lights=2, bboxdeco=3, userviewpoint=4, material=5, background=6, subscene=7, modelviewpoint=8, 
          multi = TRUE )

rgl.enum.attribtype <- function(attrib)
rgl.enum( attrib, vertices=1, normals=2, colors=3, texcoords=4, dim=5, 
          texts=6, cex=7, adj=8, radii=9, centers=10, ids=11, 
          usermatrix=12, types=13, flags=14, offsets=15,
	        family=16, font=17, pos=18, fogscale=19)

rgl.enum.pixfmt <- function(fmt)
rgl.enum( fmt, png=0 )

rgl.enum.polymode <- function(mode)
rgl.enum( mode, filled=1, lines=2, points=3, culled=4)

rgl.enum.textype <- function(textype)
rgl.enum( textype, alpha=1, luminance=2, luminance.alpha=3, rgb=4, rgba=5 )

rgl.enum.fogtype <- function(fogtype)
rgl.enum(fogtype, none=1, linear=2, exp=3, exp2=4)

rgl.enum.primtype <- function(primtype)
rgl.enum( primtype, points=1, lines=2, triangles=3, quadrangles=4, linestrips=5 )
  
rgl.enum.texminfilter <- function(minfiltertype)
rgl.enum(minfiltertype, nearest=0, linear=1, nearest.mipmap.nearest=2, nearest.mipmap.linear=3, linear.mipmap.nearest=4, linear.mipmap.linear=5)
  
rgl.enum.texmagfilter <- function(magfiltertype)
rgl.enum(magfiltertype, nearest=0, linear=1)

rgl.enum.gl2ps <- function(postscripttype)
rgl.enum(postscripttype, ps=0, eps=1, tex=2, pdf=3, svg=4, pgf=5)

rgl.enum.pixelcomponent <- function(component)
rgl.enum(component, red=0, green=1, blue=2, alpha=3, depth=4, luminance=5)

rgl.enum.depthtest <- function(depthtest)
rgl.enum(depthtest, never=0, less=1, equal=2, lequal=3, greater=4, 
                    notequal=5, gequal=6, always= 7)

Try the rgl package in your browser

Any scripts or data that you put into this service are public.

rgl documentation built on Feb. 1, 2021, 3:01 a.m.