Misc Modules¶
- class visualizer.vtk_render[source]¶
Bases: object
Class to render particle data with VTK.
Once this class is created you can easily add ‘actors’ to the scene via the enclosed methods.
Examples
>>> import visualizer as viz >>> >>> obj = viz.vtk_render() >>> obj.point_render(pos[:,0],pos[:,1],pos[:,2], color=[0.2,0.3,0.4],opacity=0.8) >>> obj.sphere(x,y,z,10,color=[1,0,0],alpha=0.2) >>> obj.renderthis()
Methods
Keypress(obj, event) function to perform actions on keypress PRINT() arrow(p1, p2[, shaftR, tipR, tipL, balls, ...]) Draw an arrow in the render window. create_helpers() creates helper text for keyboard shortcuts cube(center, size[, color]) Render a cube in the render window. label(cmx, cmy, cmz, text[, textcolor, ...]) Create label within the VTK object. makebutton() optsWindow() placetext(text[, size, fontsize, loc, textcolor]) Place text in one of the corners of the render window. pointRender(pos[, color, opacity, alpha, ...]) point_render(x, y, z[, color, opacity, ...]) Adds points to the rendering. print_camera_settings() function to print camera setting to screen processrender(xsize, ysize, offscreen) function to setup VTK render windows and data quit() renderthis([xsize, ysize, bgcolor, ...]) Renders the scene. resetSTLcounter() save_frame() function to save current render savethis(filename) setup_axislook(axis) setup_camera(hrotate, vrotate, focalpoint) setup_helper() setup helper text setup_orientmarker(bgcolor) sphere(x, y, z, r[, color, opacity, res]) Add a sphere to the rendering. switch_help(switch) function to turn help on or off entirely toggle_actors() toggle_help([manual]) function to toggle helper text on/off volume_render(grid) Volume rendering currently bugged and unsupported. - arrow(p1, p2, shaftR=0.01, tipR=0.05, tipL=0.2, balls=0, ballcolor=[1.0, 1.0, 0.0], ballradius=1, color=[1, 1, 1], stl='')[source]¶
Draw an arrow in the render window.
Parameters: p1 : numpy_array
base of the arrow location
p2 : numpy_array
tip of the arrow location
- label(cmx, cmy, cmz, text, textcolor=[1, 1, 1], textfontsize=12, labelboxcolor=[0, 0, 0], labelbox=1, labelboxopacity=0.8)[source]¶
Create label within the VTK object.
Parameters: cmx : float
x-coordinate of the label
cmy : float
y-coordinate of the label
cmz : float
z-coordinate of the label
text : string
what to put in the label
textcolor : tuple (default=[1,1,1])
color of the text
textfontsize : int (default=12)
size of the text
labelboxcolor : tuple (default=[0,0,0])
color of the box enclosing the text
labelbox : int (default=1)
enclose the text in a box?
labelboxopacity : float (default=0.8)
opacity of the enclosing box
- placetext(text, size=800, fontsize=18, loc=1, textcolor=[1, 1, 1])[source]¶
Place text in one of the corners of the render window.
Parameters: text : string
text to stick in the corner
loc : int (default=1)
which corner?
textcolor : tuple (default=[1,1,1])
what color should the text be?
- point_render(x, y, z, color=[1, 1, 1], opacity=1, alpha=1, size=800, singlepoint=0, psize=1)[source]¶
Adds points to the rendering.
Parameters: x : numpy_array or float
x-coordinates of particles to render
y : numpy_array or float
y-coordinates of particles to render
z : numpy_array or float
z-coordinates of particles to render
color : numpy_array or tuple (default=[1,1,1])
color of particles. if array is passed then it must be the same size as the x/y/z array with each element corresponding to the color of each particle (ie color[i]=[r,g,b])
opacity : float (default=1)
opacity of said particles
alpha : float (default=1)
interchangable with opacity
singlepoint : int (default=0)
if rendering a single point then this must be set to 1
psize : int (default=1)
size of particles?
- renderthis(xsize=800, ysize=800, bgcolor=[0, 0, 0], orientmarker=1, focalpoint=[], zoom=0, axis=3, hrotate=0, vrotate=0, savefile=None, filetype='png', get_cam_pos=0, set_cam_pos=[], helptext=1, stl=0)[source]¶
Renders the scene.
- sphere(x, y, z, r, color=[1, 1, 1], opacity=1, res=12)[source]¶
Add a sphere to the rendering.
Parameters: x : float
x-coordinate of the sphere center
y : float
y-coordinate of the sphere center
z : float
z-coordinate of the sphere center
r : float
radius of the sphere
color : tuple (default=[1,1,1])
opacity : float (default=1)
res : int (default=12)
resolutuion of the sphere