ipymd.visualise.opengl package


ipymd.visualise.opengl.buffers module

class ipymd.visualise.opengl.buffers.VertexBuffer(data, usage)[source]

Bases: object

bind_attrib(attribute, size, type, normalized=<Mock object>, stride=0)[source]
bind_colors(size, type, stride=0)[source]
bind_indexes(type, stride=0)[source]
bind_normals(type, stride=0)[source]
bind_texcoords(size, type, stride=0)[source]
bind_vertexes(size, type, stride=0)[source]

ipymd.visualise.opengl.camera module

Module to provide a nice camera for 3d applications

class ipymd.visualise.opengl.camera.Camera[source]

Our viewpoint on the 3D world. The Camera class can be used to access and modify from which point we’re seeing the scene.

It also handle the projection matrix (the matrix we apply to project 3d points onto our 2d screen).

Type:np.ndarray(3, float)
Default:np.array([0.0, 0.0, 5.0])

The position of the camera. You can modify this attribute to move the camera in various directions using the absoule x, y and z coordinates.

a, b, c
Type:np.ndarray(3), np.ndarray(3), np.ndarray(3) dtype=float
Default:a: np.ndarray([1.0, 0.0, 0.0]) b: np.ndarray([0.0, 1.0, 0.0]) c: np.ndarray([0.0, 0.0, -1.0])

Those three vectors represent the camera orientation. The a vector points to our right, the b points upwards and c in front of us.

By default the camera points in the negative z-axis direction.

Type:np.ndarray(3, dtype=float)
Default:np.array([0.0, 0.0, 0.0])

The point we will orbit around by using Camera.orbit_x() and Camera.orbit_y().

Type:np.ndarray((4,4), dtype=float)

Camera matrix, it contains the rotations and translations needed to transform the world according to the camera position. It is generated from the a,``b``,``c`` vectors.

Type:np.ndarray((4, 4),dtype=float)

Projection matrix, generated from the projection parameters.

z_near, z_far
Type:float, float

Near and far clipping planes. For more info refer to: http://www.lighthouse3d.com/tutorials/view-frustum-culling/


field of view in degrees used to generate the projection matrix.


Aspect ratio for the projection matrix, this should be adapted when the application window is resized.


Fit the current view to the correct zoom level to display all points.

The camera viewing direction and rotation pivot match the geometric center of the points and the distance from that point is calculated in order for all points to be in the field of view. This is currently used to provide optimal visualization for molecules and systems


points: np.ndarray((N, 3))
Array of points.
mouse_rotate(dx, dy)[source]

Convenience function to implement the mouse rotation by giving two displacements in the x and y directions.


Convenience function to implement a zoom function.

This is achieved by moving Camera.position in the direction of the Camera.c vector.


Same as orbit_y() but the axis of rotation is the Camera.b vector.

We rotate around the point like if we sit on the side of a salad spinner.


Orbit around the point Camera.pivot by the angle angle expressed in radians. The axis of rotation is the camera “right” vector, Camera.a.

In practice, we move around a point like if we were on a Ferris wheel.


Restore the camera state, passed as a state dictionary. You can obtain a previous state from the method Camera.state.


Return the current camera state as a dictionary, it can be restored with Camera.restore.

unproject(x, y, z=-1.0)[source]

Receive x and y as screen coordinates and returns a point in world coordinates.

This function comes in handy each time we have to convert a 2d mouse click to a 3d point in our space.


x: float in the interval [-1.0, 1.0]
Horizontal coordinate, -1.0 is leftmost, 1.0 is rightmost.
y: float in the interval [1.0, -1.0]
Vertical coordinate, -1.0 is down, 1.0 is up.
z: float in the interval [1.0, -1.0]
Depth, -1.0 is the near plane, that is exactly behind our screen, 1.0 is the far clipping plane.
Return type:np.ndarray(3,dtype=float)
Returns:The point in 3d coordinates (world coordinates).
ipymd.visualise.opengl.camera.fequal(a, b, tol)[source]

ipymd.visualise.opengl.qchemlabwidget module

ipymd.visualise.opengl.qchemlabwidget.create_color_texture(fb, width, height)[source]
ipymd.visualise.opengl.qchemlabwidget.create_depth_texture(fb, width, height)[source]
ipymd.visualise.opengl.qchemlabwidget.create_normal_texture(fb, width, height)[source]

ipymd.visualise.opengl.qtviewer module

class ipymd.visualise.opengl.qtviewer.FpsDraw(parent)[source]

Bases: object


ipymd.visualise.opengl.shaders module

ipymd.visualise.opengl.shaders.compileShader(source, shaderType)[source]

Compile shader source of given type

source – GLSL source-code for the shader shaderType – GLenum GL_VERTEX_SHADER, GL_FRAGMENT_SHADER, etc,

returns GLuint compiled shader reference raises RuntimeError when a compilation failure occurs

ipymd.visualise.opengl.shaders.set_uniform(prog, uni, typ, value)[source]

ipymd.visualise.opengl.textures module

Texture data structures

class ipymd.visualise.opengl.textures.Texture(kind, width, height, intformat, format, dtype, data=None)[source]

Bases: object

set_parameter(par, value)[source]

Module contents