| IdfViewer {eplusr} | R Documentation |
Visualize an EnergyPlus Model Geometry and Simulation Results
Description
IdfViewer is a class designed to view geometry of an Idf and map
simulation results to the geometries.
Usage
idf_viewer(geometry)
Arguments
geometry |
An IdfGeometry object. |
Value
An IdfViewer object.
Methods
Public methods
Method new()
Create an IdfViewer object
Usage
IdfViewer$new(geometry)
Arguments
geometryAn IdfGeometry object.
geometrycan also be a path to an IDF file or an Idf object. In this case, anIdfGeometryis created based on input Idf.
Returns
An IdfViewer object.
Examples
\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)
}
Method parent()
Get parent Idf object
Usage
IdfViewer$parent()
Details
$parent() returns the parent Idf object of current IdfGeometry
object.
Returns
An Idf object.
Examples
\dontrun{
viewer$parent()
}
Method geometry()
Get parent IdfGeometry object
Usage
IdfViewer$geometry()
Details
$geometry() returns the parent IdfGeometry object.
Returns
An IdfGeometry object.
Examples
\dontrun{
viewer$geometry()
}
Method device()
Get Rgl device ID
Usage
IdfViewer$device()
Details
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.
Returns
A number or NULL
Examples
\dontrun{
viewer$device()
}
Method background()
Set the background color of the scene
Usage
IdfViewer$background(color = "white")
Arguments
colorA single string giving the background color. Default:
white.
Examples
\dontrun{
viewer$background("blue")
}
Method viewpoint()
Set the viewpoint orientation of the scene
Usage
IdfViewer$viewpoint( look_at = "iso", theta = NULL, phi = NULL, fov = NULL, zoom = NULL, scale = NULL )
Arguments
look_atA single string indicating a standard view. If specified,
thetaandphiwill be ignored. Should be one ofc("top", "bottom", "left", "right", "front", "back", "iso").look_atwill be ignored if any ofthetaandphiis specified. Default:iso(i.e. isometric).thetaTheta in polar coordinates. If
NULL, no changes will be made to current scene. Default:NULL.phiPhi in polar coordinates. If
NULL, no changes will be made to current scene. Default:NULL.fovField-of-view angle in degrees. If
0, a parallel or orthogonal projection is used. IfNULL, no changes will be made to current scene. Default:NULL.zoomZoom factor. If
NULL, no changes will be made to current scene. Default:NULL.scaleA 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.
Examples
\dontrun{
viewer$viewpoint()
}
Method win_size()
Set the window size
Usage
IdfViewer$win_size(left = 0, top = 0, right = 600, bottom = 600)
Arguments
left, top, right, bottomA single number indicating the pixels of the displayed window. Defaults:
0(left),0(top),600(right) and600(bottom).
Examples
\dontrun{
viewer$win_size(0, 0, 400, 500)
}
Method mouse_mode()
Set the handlers of mouse control
Usage
IdfViewer$mouse_mode( left = "trackball", right = "pan", middle = "fov", wheel = "pull" )
Arguments
left, right, middleRefer to the buttons on a three button mouse, or simulations of them on other mice. Defaults:
"trackball"(left),"pan"(right) and"fov"(middle).wheelRefer to the mouse wheel. Default:
"pull".
Details
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 |
Examples
\dontrun{
viewer$mouse_mode()
}
Method axis()
Toggle axis in the scene
Usage
IdfViewer$axis(
add = TRUE,
expand = 2,
width = 1.5,
color = c("red", "green", "blue", "orange"),
alpha = 1
)Arguments
addIf
TRUE, axis is added to the scene. IfFALSE, axis is removed in the scene.expandA single number giving the factor to expand based on the largest X, Y and Z coordinate values. Default:
2.0.widthA number giving the line width of axis.
width * 2is used for the true north axis. Default:1.5.colorA character of length 4 giving the color of X, Y, Z and true north axis. Default:
c("red", "green", "blue", "orange").alphaA number giving the alpha value of axis. Default:
1.0.
Details
$axis() adds or removes X, Y and Z axis in the scene.
Returns
A single logical value as add.
Examples
\dontrun{
viewer$axis()
}
Method ground()
Toggle ground in the scene
Usage
IdfViewer$ground(add = TRUE, expand = 1.02, color = "#EDEDEB", alpha = 1)
Arguments
addIf
TRUE, ground is added to the scene. IfFALSE, ground is removed in the scene.expandA single number giving the factor to expand based on the largest X, Y and Z coordinate values. Default:
1.02.colorA string giving the color of ground. Default:
#EDEDEB.alphaA number giving the alpha value of ground. Default:
1.0.
Details
$ground() adds or removes ground in the scene.
Returns
A single logical value as add.
Examples
\dontrun{
viewer$ground()
}
Method wireframe()
Toggle wireframe
Usage
IdfViewer$wireframe(add = TRUE, width = 1.5, color = "black", alpha = 1)
Arguments
addIf
TRUE, wireframe is turned on. IfFALSE, wireframe is turned off. Default:TRUE.widthA number giving the line width of axis. Default:
1.5.colorA character of length 3 giving the color of X, Y and Z axis. Default:
c("red", "green", "blue").alphaA number giving the alpha value of axis. Default:
1.0.
Details
$wireframe() turns on/off wireframes.
Returns
A single logical value as add.
Examples
\dontrun{
viewer$wireframe()
}
Method x_ray()
Toggle X-ray face style
Usage
IdfViewer$x_ray(on = TRUE)
Arguments
onIf
TRUE, X-ray is turned on. IfFALSE, X-ray is turned off. Default:TRUE.
Details
$x_ray() turns on/off X-ray face style.
Returns
A single logical value as on.
Examples
\dontrun{
viewer$x_ray()
}
Method render_by()
Set render style
Usage
IdfViewer$render_by(type = "surface_type")
Arguments
typeA 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.
-
Details
$render_by() sets the render style of geometries.
Returns
A same value as style.
Examples
\dontrun{
viewer$render_by()
}
Method show()
Show Idf geometry
Usage
IdfViewer$show( type = "all", zone = NULL, space = NULL, surface = NULL, width = 1.5, dayl_color = "red", dayl_size = 5 )
Arguments
typeA character vector of geometry components to show. If
"all"(default), all geometry components will be shown. IfNULL, no geometry faces will be shown. Otherwise, should be a subset of following:-
"floor" -
"wall" -
"roof" -
"window" -
"door" -
"shading" -
"daylighting"
-
zoneA character vector of names or an integer vector of IDs of zones in current Idf to show. If
NULL, no subsetting is performed.spaceA character vector of names or an integer vector of IDs of spaces in current Idf to show. If
NULL, no subsetting is performed.surfaceA character vector of names or an integer vector of IDs of surfaces in current Idf to show. If
NULL, no subsetting is performed.widthThe line width for the geometry components. Default:
1.5.dayl_color, dayl_sizeThe color and size of daylighting reference points. Defaults:
"red"(dayl_color) and5(dayl_size).
Returns
The IdfViewer itself, invisibly.
Examples
\dontrun{
viewer$show()
}
Method focus()
Bring the scene window to the top
Usage
IdfViewer$focus()
Examples
\dontrun{
viewer$top()
}
Method close()
Close the scene window
Usage
IdfViewer$close()
Examples
\dontrun{
viewer$close()
}
Method snapshot()
Capture and save current rgl view as an image
Usage
IdfViewer$snapshot(filename, webshot = FALSE, ...)
Arguments
filenameA single string specifying the file name. Current supported formats are
png,pdf,svg,ps,eps,texandpgf.webshotWhether to use the 'webshot2' package to take the snapshot. For more details, please see
rgl::snapshot3d(). Default:FALSE....Arguments to pass to
webshot2::webshot().
Details
$snapshot() captures the current rgl view and saves it as an image
file to disk using rgl::snapshot3d() and rgl::rgl.postscript().
Returns
A single string of the file path.
Examples
\dontrun{
viewer$show()
viewer$snapshot(tempfile(fileext = ".png"))
}
Method print()
Print an IdfViewer object
Usage
IdfViewer$print()
Returns
The IdfViewer itself, invisibly.
Examples
\dontrun{
viewer$print()
}
Author(s)
Hongyuan Jia
See Also
IdfGeometry class
Examples
## ------------------------------------------------
## 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)