yade.qt module

Common initialization core for yade.

This file is executed when anything is imported from yade for the first time. It loads yade plugins and injects c++ class constructors to the __builtins__ (that might change in the future, though) namespace, making them available everywhere.

class yade.qt._GLViewer.GLViewer
__init__()

Raises an exception This class cannot be instantiated from Python

axes

Show arrows for axes.

center((GLViewer)arg1[, (bool)median=True[, (float)suggestedRadius=-1.0]]) → None :

Center view. View is centered either so that all bodies fit inside (median = False), or so that 75% of bodies fit inside (median = True). If radius cannot be determined automatically then suggestedRadius is used.

close((GLViewer)arg1) → None
eyePosition

Camera position.

fitAABB((GLViewer)arg1, (Vector3)mn, (Vector3)mx) → None :

Adjust scene bounds so that Axis-aligned bounding box given by its lower and upper corners mn, mx fits in.

fitSphere((GLViewer)arg1, (Vector3)center, (float)radius) → None :

Adjust scene bounds so that sphere given by center and radius fits in.

fps

Show frames per second indicator.

grid

Display square grid in zero planes, as 3-tuple of bools for yz, xz, xy planes.

loadState((GLViewer)arg1[, (str)stateFilename='.qglviewer.xml']) → None :

Load display parameters from file saved previously into.

lookAt

Point at which camera is directed.

ortho

Whether orthographic projection is used; if false, use perspective projection.

saveSnapshot((GLViewer)arg1, (str)filename) → None :

Save the current view to image file

saveState((GLViewer)arg1[, (str)stateFilename='.qglviewer.xml']) → None :

Save display parameters into a file. Saves state for both GLViewer and associated OpenGLRenderer.

scale

Scale of the view (?)

sceneRadius

Visible scene radius.

screenSize

Size of the viewer’s window, in screen pixels

selection
showEntireScene((GLViewer)arg1) → None
timeDisp

Time displayed on in the vindow; is a string composed of characters r, v, i standing respectively for real time, virtual time, iteration number.

upVector

Vector that will be shown oriented up on the screen.

viewDir

Camera orientation (as vector).

yade.qt._GLViewer.Renderer() → OpenGLRenderer

Return the active OpenGLRenderer object.

yade.qt._GLViewer.View([(float)timeout=5.0]) → GLViewer

Create a new 3d view.

yade.qt._GLViewer.center([(float)suggestedRadius=-1.0[, (Vector3)gridOrigin=Vector3(0, 0, 0)[, (Vector3)suggestedCenter=Vector3(0, 0, 0)[, (int)gridDecimalPlaces=4]]]]) → None

Center all views.

Parameters:
  • suggestedRadius – optional parameter, if provided and positive then it will be used instead of automatic radius detection. This parameter affects the (1) size of grid being drawn (2) the Z-clipping distance in OpenGL, it means that if clipping is too large and some of your scene is not being drawn but is “cut” or “sliced” then this parameter needs to be bigger.
  • gridOrigin – optional parameter, if provided it will be used as the origin for drawing the grid. Meaning the intersection of all three grids will not be at 0,0,0; but at the provided coordinate rounded to the nearest gridStep.
  • suggestedCenter – optional parameter, if provided other than (0,0,0) then it will be used instead of automatic calculation of scene center using bounding boxes. This parameter affects the drawn rotation-center. If you try to rotate the view, and the rotation is around some strange point, then this parameter needs to be changed.
  • gridDecimalPlaces – default value=4, determines the number of decimal places to be shown on grid labels using stringstream (extra zeros are not shown).

Note

You can get the current values of all these four arguments by invoking command: qt.centerValues()

yade.qt._GLViewer.centerValues() → dict
Returns:a dictionary with all parameters currently used by yade.qt.center(…), see qt.center or type yade.qt.center? for details. Returns zeros if view is closed.
yade.qt._GLViewer.views() → list
Returns:a list of all open qt.GLViewer objects

If one needs to exactly copy camera position and settings between two different yade sessions, the following commands can be used:

v=yade.qt.views()[0]                           ## to obtain a handle of currently opened view.
v.lookAt, v.viewDir, v.eyePosition, v.upVector ## to print the current camera parameters of the view.

## Then copy the output of this command into the second yade session to reposition the camera.
v.lookAt, v.viewDir, v.eyePosition, v.upVector = (Vector3(-0.5,1.6,0.47),Vector3(-0.5,0.6,0.4),Vector3(0.015,0.98,-0.012),Vector3(0.84,0.46,0.27))
## Since these parameters depend on each other it might be necessary to execute this command twice.

Also one can call qt.centerValues() to obtain current settings of axis and scene radius (if defaults are not used) and apply them via call to qt.center in the second yade session.

This cumbersome method above may be improved in the future.