IdfViewer | R Documentation |
IdfViewer
is a class designed to view geometry of an Idf and map
simulation results to the geometries.
idf_viewer(geometry)
geometry |
An IdfGeometry object. |
An IdfViewer
object.
new()
Create an IdfViewer
object
IdfViewer$new(geometry)
geometry
An IdfGeometry object. geometry
can also be a
path to an IDF file or an Idf object. In this case, an
IdfGeometry
is created based on input Idf.
An IdfViewer
object.
\dontrun{ # example model shipped with eplusr from EnergyPlus v8.8 path_idf <- system.file("extdata/1ZoneUncontrolled.idf", package = "eplusr") # v8.8 # create from an Idf object idf <- read_idf(path_idf, use_idd(8.8, "auto")) viewer <- idf_viewer(idf) viewer <- IdfViewer$new(idf) # create from an IDF file viewer <- idf_viewer(path_idf) viewer <- IdfViewer$new(path_idf) }
parent()
Get parent Idf object
IdfViewer$parent()
$parent()
returns the parent Idf object of current IdfGeometry
object.
An Idf object.
\dontrun{ viewer$parent() }
geometry()
Get parent IdfGeometry object
IdfViewer$geometry()
$geometry()
returns the parent IdfGeometry object.
An IdfGeometry object.
\dontrun{ viewer$geometry() }
device()
Get Rgl device ID
IdfViewer$device()
If Rgl is used, the Rgl device ID is returned. If WebGL is
used, the elementID
is returned. If no viewer has been open, NULL
is returned.
A number or NULL
\dontrun{ viewer$device() }
background()
Set the background color of the scene
IdfViewer$background(color = "white")
color
A single string giving the background color. Default:
white
.
\dontrun{ viewer$background("blue") }
viewpoint()
Set the viewpoint orientation of the scene
IdfViewer$viewpoint( look_at = "iso", theta = NULL, phi = NULL, fov = NULL, zoom = NULL, scale = NULL )
look_at
A single string indicating a standard view. If
specified, theta
and phi
will be ignored. Should be
one of c("top", "bottom", "left", "right", "front", "back", "iso")
. look_at
will be ignored if any of theta
and phi
is specified. Default: iso
(i.e. isometric).
theta
Theta in polar coordinates. If NULL
, no changes will
be made to current scene. Default: NULL
.
phi
Phi in polar coordinates. If NULL
, no changes will be
made to current scene. Default: NULL
.
fov
Field-of-view angle in degrees. If 0
, a parallel or
orthogonal projection is used. If NULL
, no changes will
be made to current scene. Default: NULL
.
zoom
Zoom factor. If NULL
, no changes will be made to
current scene. Default: NULL
.
scale
A numeric vector of length 3 giving the rescaling to
apply to each axis. If NULL
, no changes will be made to
current scene. Default: NULL
.
\dontrun{ viewer$viewpoint() }
win_size()
Set the window size
IdfViewer$win_size(left = 0, top = 0, right = 600, bottom = 600)
left, top, right, bottom
A single number indicating the pixels of
the displayed window. Defaults: 0
(left
), 0
(top
),
600
(right
) and 600
(bottom
).
\dontrun{ viewer$win_size(0, 0, 400, 500) }
mouse_mode()
Set the handlers of mouse control
IdfViewer$mouse_mode( left = "trackball", right = "pan", middle = "fov", wheel = "pull" )
left, right, middle
Refer to the buttons on a three button
mouse, or simulations of them on other mice. Defaults:
"trackball"
(left
), "pan"
(right
) and "fov"
(middle
).
wheel
Refer to the mouse wheel. Default: "pull"
.
Possible values are:
Mode | Description |
"none" | No action |
"trackball" | The mouse acts as a virtual trackball. Clicking and dragging rotates the scene |
"xAxis", "yAxis", "zAxis" | Like "trackball", but restricted to rotation about one axis |
"polar" | The mouse affects rotations by controlling polar coordinates directly |
"zoom" | The mouse zooms the display |
"fov" | The mouse affects perspective by changing the field of view |
"pull" | Rotating the mouse wheel towards the user “ pulls the scene closer” |
"push" | The same rotation “pushes the scene away” |
"pan" | Pan the camera view vertically or horizontally |
\dontrun{ viewer$mouse_mode() }
axis()
Toggle axis in the scene
IdfViewer$axis( add = TRUE, expand = 2, width = 1.5, color = c("red", "green", "blue", "orange"), alpha = 1 )
add
If TRUE
, axis is added to the scene. If FALSE
, axis is
removed in the scene.
expand
A single number giving the factor to expand based on
the largest X, Y and Z coordinate values. Default: 2.0
.
width
A number giving the line width of axis. width * 2
is
used for the true north axis. Default: 1.5
.
color
A character of length 4 giving the color of X, Y, Z and
true north axis. Default: c("red", "green", "blue", "orange")
.
alpha
A number giving the alpha value of axis. Default: 1.0
.
$axis()
adds or removes X, Y and Z axis in the scene.
A single logical value as add
.
\dontrun{ viewer$axis() }
ground()
Toggle ground in the scene
IdfViewer$ground(add = TRUE, expand = 1.02, color = "#EDEDEB", alpha = 1)
add
If TRUE
, ground is added to the scene. If FALSE
,
ground is removed in the scene.
expand
A single number giving the factor to expand based on
the largest X, Y and Z coordinate values. Default: 1.02
.
color
A string giving the color of ground. Default: #EDEDEB
.
alpha
A number giving the alpha value of ground. Default: 1.0
.
$ground()
adds or removes ground in the scene.
A single logical value as add
.
\dontrun{ viewer$ground() }
wireframe()
Toggle wireframe
IdfViewer$wireframe(add = TRUE, width = 1.5, color = "black", alpha = 1)
add
If TRUE
, wireframe is turned on. If FALSE
, wireframe
is turned off. Default: TRUE
.
width
A number giving the line width of axis. Default: 1.5
.
color
A character of length 3 giving the color of X, Y and Z
axis. Default: c("red", "green", "blue")
.
alpha
A number giving the alpha value of axis. Default: 1.0
.
$wireframe()
turns on/off wireframes.
A single logical value as add
.
\dontrun{ viewer$wireframe() }
x_ray()
Toggle X-ray face style
IdfViewer$x_ray(on = TRUE)
on
If TRUE
, X-ray is turned on. If FALSE
, X-ray is turned
off. Default: TRUE
.
$x_ray()
turns on/off X-ray face style.
A single logical value as on
.
\dontrun{ viewer$x_ray() }
render_by()
Set render style
IdfViewer$render_by(type = "surface_type")
type
A single string giving the render style. Should be one of:
"surface_type"
: Default. Render the model by surface type
model. Walls, roofs, windows, doors, floors, and shading
surfaces will have unique colors.
"boundary"
: Render the model by outside boundary condition.
Only surfaces that have boundary conditions will be rendered
with a color. All other surfaces will be white.
"construction"
: Render the model by surface constructions.
"zone"
: Render the model by zones assigned.
"space"
: Render the model by spaces assigned.
"normal"
: Render the model by surface normal. The outside
face of a heat transfer face will be rendered as white and the
inside face will be rendered as red.
$render_by()
sets the render style of geometries.
A same value as style
.
\dontrun{ viewer$render_by() }
show()
Show Idf geometry
IdfViewer$show( type = "all", zone = NULL, space = NULL, surface = NULL, width = 1.5, dayl_color = "red", dayl_size = 5 )
type
A character vector of geometry components to show. If
"all"
(default), all geometry components will be shown. If
NULL
, no geometry faces will be shown. Otherwise, should be
a subset of following:
"floor"
"wall"
"roof"
"window"
"door"
"shading"
"daylighting"
zone
A character vector of names or an integer vector of IDs
of zones in current Idf to show. If NULL
, no subsetting is
performed.
space
A character vector of names or an integer vector of IDs
of spaces in current Idf to show. If NULL
, no subsetting is
performed.
surface
A character vector of names or an integer vector of IDs
of surfaces in current Idf to show. If NULL
, no subsetting
is performed.
width
The line width for the geometry components. Default:
1.5
.
dayl_color, dayl_size
The color and size of daylighting
reference points. Defaults: "red"
(dayl_color
) and 5
(dayl_size
).
The IdfViewer
itself, invisibly.
\dontrun{ viewer$show() }
focus()
Bring the scene window to the top
IdfViewer$focus()
\dontrun{ viewer$top() }
close()
Close the scene window
IdfViewer$close()
\dontrun{ viewer$close() }
snapshot()
Capture and save current rgl view as an image
IdfViewer$snapshot(filename, webshot = FALSE, ...)
filename
A single string specifying the file name. Current
supported formats are png
, pdf
, svg
, ps
, eps
, tex
and pgf
.
webshot
Whether to use the 'webshot2' package to take the
snapshot. For more details, please see rgl::snapshot3d()
.
Default: FALSE
.
...
Arguments to pass to webshot2::webshot()
.
$snapshot()
captures the current rgl view and saves it as an image
file to disk using rgl::snapshot3d()
and rgl::rgl.postscript()
.
A single string of the file path.
\dontrun{ viewer$show() viewer$snapshot(tempfile(fileext = ".png")) }
print()
Print an IdfViewer
object
IdfViewer$print()
The IdfViewer
itself, invisibly.
\dontrun{ viewer$print() }
Hongyuan Jia
IdfGeometry class
## ------------------------------------------------
## Method `IdfViewer$new`
## ------------------------------------------------
## Not run:
# example model shipped with eplusr from EnergyPlus v8.8
path_idf <- system.file("extdata/1ZoneUncontrolled.idf", package = "eplusr") # v8.8
# create from an Idf object
idf <- read_idf(path_idf, use_idd(8.8, "auto"))
viewer <- idf_viewer(idf)
viewer <- IdfViewer$new(idf)
# create from an IDF file
viewer <- idf_viewer(path_idf)
viewer <- IdfViewer$new(path_idf)
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$parent`
## ------------------------------------------------
## Not run:
viewer$parent()
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$geometry`
## ------------------------------------------------
## Not run:
viewer$geometry()
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$device`
## ------------------------------------------------
## Not run:
viewer$device()
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$background`
## ------------------------------------------------
## Not run:
viewer$background("blue")
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$viewpoint`
## ------------------------------------------------
## Not run:
viewer$viewpoint()
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$win_size`
## ------------------------------------------------
## Not run:
viewer$win_size(0, 0, 400, 500)
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$mouse_mode`
## ------------------------------------------------
## Not run:
viewer$mouse_mode()
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$axis`
## ------------------------------------------------
## Not run:
viewer$axis()
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$ground`
## ------------------------------------------------
## Not run:
viewer$ground()
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$wireframe`
## ------------------------------------------------
## Not run:
viewer$wireframe()
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$x_ray`
## ------------------------------------------------
## Not run:
viewer$x_ray()
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$render_by`
## ------------------------------------------------
## Not run:
viewer$render_by()
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$show`
## ------------------------------------------------
## Not run:
viewer$show()
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$focus`
## ------------------------------------------------
## Not run:
viewer$top()
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$close`
## ------------------------------------------------
## Not run:
viewer$close()
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$snapshot`
## ------------------------------------------------
## Not run:
viewer$show()
viewer$snapshot(tempfile(fileext = ".png"))
## End(Not run)
## ------------------------------------------------
## Method `IdfViewer$print`
## ------------------------------------------------
## Not run:
viewer$print()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.