sas.qtgui.GL package

Submodules

sas.qtgui.GL.color module

class sas.qtgui.GL.color.ColorMap(colormap_name='rainbow', min_value=0.0, max_value=1.0)

Bases: object

vertex_coloring(values: ndarray)

Evaluate the color map and return a ColorSpecification object

class sas.qtgui.GL.color.ColorSpecification(method: ColorSpecificationMethod, data: ndarray)

Bases: object

Specification of how to colour an object, and the data needed to do so

data: ndarray
method: ColorSpecificationMethod
class sas.qtgui.GL.color.ColorSpecificationMethod(*values)

Bases: Enum

Specifies how to colour an object

BY_COMPONENT = 2
BY_VERTEX = 3
UNIFORM = 1
sas.qtgui.GL.color.edge_coloring(data: Sequence[Sequence[float] | ndarray]) ColorSpecification

Create a ColorSpecification for colouring each edge within an object a single colour

sas.qtgui.GL.color.mesh_coloring(data: Sequence[Sequence[float] | ndarray]) ColorSpecification

Create a ColorSpecification for colouring each mesh within an object a single colour

sas.qtgui.GL.color.uniform_coloring(r, g, b, alpha=1.0)

Create a ColorSpecification for colouring with a single colour

sas.qtgui.GL.color.vertex_coloring(data: ndarray) ColorSpecification

Create a ColorSpecification for using vertex colouring

sas.qtgui.GL.cone module

class sas.qtgui.GL.cone.Cone(n: int = 20, colors: ColorSpecification | None = None, edge_colors: ColorSpecification | None = None)

Bases: FullModel

Graphics primitive: Radius 1, Height 2 cone “centred” at (0,0,0)

static cone_base_triangles(n) list[tuple[int, int, int]]

Helper function: Triangles in base the cone primitive

static cone_edges(n)

Helper function: Edges of the cone primitive

static cone_tip_triangles(n) list[tuple[int, int, int]]

Helper function: Triangles in tip of the cone primitive

static cone_triangles(n) list[list[tuple[int, int, int]]]

Helper function: The two separate meshes for triangles of the cone primitive

static cone_vertices(n) list[tuple[float, float, float]]

Helper function: Vertices of the cone primitive

sas.qtgui.GL.cube module

class sas.qtgui.GL.cube.Cube(colors: ColorSpecification | None = None, edge_colors: ColorSpecification | None = None)

Bases: FullModel

Unit cube centred at 0,0,0

cube_edges = [(0, 1), (1, 5), (5, 4), (4, 0), (2, 3), (3, 7), (7, 6), (6, 2), (1, 3), (5, 7), (4, 6), (0, 2)]
cube_triangles = [[(1, 2, 3), (1, 0, 2)], [(0, 6, 2), (0, 4, 6)], [(4, 7, 6), (4, 5, 7)], [(5, 3, 7), (5, 1, 3)], [(2, 7, 3), (2, 6, 7)], [(1, 4, 0), (1, 5, 4)]]
cube_vertices = [(-0.5, -0.5, -0.5), (-0.5, -0.5, 0.5), (-0.5, 0.5, -0.5), (-0.5, 0.5, 0.5), (0.5, -0.5, -0.5), (0.5, -0.5, 0.5), (0.5, 0.5, -0.5), (0.5, 0.5, 0.5)]

sas.qtgui.GL.cylinder module

class sas.qtgui.GL.cylinder.Cylinder(n: int = 20, colors: ColorSpecification | None = None, edge_colors: ColorSpecification | None = None)

Bases: FullModel

Graphics primitive: Radius 1, Height 2 cone “centred” at (0,0,0)

static cylinder_edges(n)

Helper function: Edges of the cylinder primitive

static cylinder_face_triangles(n, offset) list[tuple[int, int, int]]

Helper function: Faces of the ends of cylinder primitive

static cylinder_side_triangles(n) list[tuple[int, int, int]]

Helper function: Faces of the sides of the cylinder primitive

static cylinder_triangles(n) list[list[tuple[int, int, int]]]

Helper function: All faces of the cylinder primitive

static cylinder_vertices(n) list[tuple[float, float, float]]

Helper function: Vertices of the cylinder primitive

sas.qtgui.GL.icosahedron module

class sas.qtgui.GL.icosahedron.Icosahedron(colors: ColorSpecification | None = None, edge_colors: ColorSpecification | None = None)

Bases: FullModel

Icosahedron centred at 0,0,0

ico_edges = [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 2), (2, 3), (3, 4), (4, 5), (5, 1), (1, 6), (2, 7), (3, 8), (4, 9), (5, 10), (1, 10), (2, 6), (3, 7), (4, 8), (5, 9), (6, 7), (7, 8), (8, 9), (9, 10), (10, 6), (6, 11), (7, 11), (8, 11), (9, 11), (10, 11)]
ico_triangles = [[(0, 1, 2), (0, 2, 3), (0, 3, 4), (0, 4, 5), (0, 5, 1), (2, 1, 6), (3, 2, 7), (4, 3, 8), (5, 4, 9), (1, 5, 10), (6, 10, 1), (7, 6, 2), (8, 7, 3), (9, 8, 4), (10, 9, 5), (6, 7, 11), (7, 8, 11), (8, 9, 11), (9, 10, 11), (10, 6, 11)]]
ico_vertices = [(0.0, 0.0, 1.0), (np.float64(0.8944271909999159), np.float64(0.0), np.float64(0.4472135954999579)), (np.float64(0.27639320225002106), np.float64(0.8506508083520399), np.float64(0.4472135954999579)), (np.float64(-0.7236067977499788), np.float64(0.5257311121191337), np.float64(0.4472135954999579)), (np.float64(-0.723606797749979), np.float64(-0.5257311121191335), np.float64(0.4472135954999579)), (np.float64(0.27639320225002084), np.float64(-0.85065080835204), np.float64(0.4472135954999579)), (np.float64(0.7236067977499789), np.float64(0.5257311121191336), np.float64(-0.4472135954999579)), (np.float64(-0.27639320225002095), np.float64(0.85065080835204), np.float64(-0.4472135954999579)), (np.float64(-0.8944271909999159), np.float64(1.0953573965284052e-16), np.float64(-0.4472135954999579)), (np.float64(-0.2763932022500211), np.float64(-0.8506508083520399), np.float64(-0.4472135954999579)), (np.float64(0.7236067977499788), np.float64(-0.5257311121191338), np.float64(-0.4472135954999579)), (0.0, 0.0, -1.0)]

sas.qtgui.GL.models module

3D Model classes

class sas.qtgui.GL.models.FullModel(vertices: Sequence[tuple[float, float, float]] | ndarray, edges: Sequence[tuple[int, int]] | ndarray, triangle_meshes: Sequence[Sequence[tuple[int, int, int]] | ndarray], edge_colors: ColorSpecification | None, colors: ColorSpecification | None)

Bases: SolidVertexModel, WireModel

Model that has both wireframe and solid, vertex coloured rendering enabled,

See SolidVertexModel and WireModel

class sas.qtgui.GL.models.ModelBase(vertices: Sequence[tuple[float, float, float]] | ndarray)

Bases: Renderable

Base class for all models

property vertices
class sas.qtgui.GL.models.SolidModel(vertices: Sequence[tuple[float, float, float]] | ndarray, triangle_meshes: Sequence[Sequence[tuple[int, int, int]] | ndarray])

Bases: ModelBase

Base class for the solid models

property triangle_meshes: Sequence[Sequence[tuple[int, int, int]] | ndarray]
class sas.qtgui.GL.models.SolidVertexModel(vertices: Sequence[tuple[float, float, float]] | ndarray, triangle_meshes: Sequence[Sequence[tuple[int, int, int]] | ndarray], colors: ColorSpecification | None)

Bases: SolidModel

render_solid()
class sas.qtgui.GL.models.WireModel(vertices: Sequence[tuple[float, float, float]] | ndarray, edges: Sequence[tuple[int, int]] | ndarray, edge_colors: ColorSpecification | None)

Bases: ModelBase

render_wireframe()

sas.qtgui.GL.renderable module

class sas.qtgui.GL.renderable.Renderable

Bases: ABC

Interface for everything that can be rendered with the OpenGL widget

render_solid()
render_wireframe()

sas.qtgui.GL.scene module

class sas.qtgui.GL.scene.Scene(parent=None, on_key: ~collections.abc.Callable[[int], None] = <function Scene.<lambda>>)

Bases: QOpenGLWidget

add(item: Renderable)
default_viewport()
initializeGL()
keyPressEvent(event: QKeyEvent)
mouseMoveEvent(ev)
mousePressEvent(ev)
mouseReleaseEvent(ev)
paintGL()

Paint the GL viewport

projection_matrix()
set_model_view()
set_projection()
staticMetaObject = PySide6.QtCore.QMetaObject("Scene" inherits "QOpenGLWidget": )
wheelEvent(event: QWheelEvent)
sas.qtgui.GL.scene.main()

Show a demo of the opengl.rst window

sas.qtgui.GL.sphere module

class sas.qtgui.GL.sphere.Sphere(n_horizontal: int = 21, n_segments: int = 28, grid_gap: int = 1, colors: ColorSpecification | None = None, edge_colors: ColorSpecification | None = None)

Bases: FullModel

static sphere_edges(n_horizontal, n_segments, grid_gap)

Helper function: Edges of the UV sphere primitive

static sphere_triangles(n_horizontal, n_segments)

Helper function: Triangles of the UV sphere primitive

static sphere_vertices(n_horizontal, n_segments)

Helper function: Vertices of the UV sphere primitive

sas.qtgui.GL.surface module

class sas.qtgui.GL.surface.Surface(x_values: ndarray, y_values: ndarray, z_data: ndarray, colormap: str = 'rainbow', c_range: tuple[float, float] = (0, 1), edge_skip: int = 1)

Bases: FullModel

static calculate_edge_indices(nx, ny, gap=1)

Helper function to calculate the indices of the edges

static calculate_triangles(nx, ny)

Helper function to calculate the indices of the triangles in the mesh

property colormap: str

Name of the colormap

set_z_data(z_data)

Set the z data on this surface plot

sas.qtgui.GL.transforms module

class sas.qtgui.GL.transforms.MatrixTransform(matrix: ndarray, *children: Renderable)

Bases: SceneGraphNode

apply()

GL operations needed to apply any transformations associated with this node

class sas.qtgui.GL.transforms.Rotation(angle, x, y, z, *children: Renderable)

Bases: SceneGraphNode

apply()

GL operations needed to apply any transformations associated with this node

class sas.qtgui.GL.transforms.Scaling(x: float, y: float, z: float, *children: Renderable)

Bases: SceneGraphNode

apply()

GL operations needed to apply any transformations associated with this node

class sas.qtgui.GL.transforms.SceneGraphNode(*children: Renderable)

Bases: Renderable

General transform - also doubles as a scene graph node

For the sake of speed, the transformation matrix shape is not checked. It should be a 4x4 transformation matrix

add_child(child: Renderable)

Add a renderable object to this scene graph node

apply()

GL operations needed to apply any transformations associated with this node

render_solid()
render_wireframe()
class sas.qtgui.GL.transforms.Translation(x: float, y: float, z: float, *children: Renderable)

Bases: SceneGraphNode

apply()

GL operations needed to apply any transformations associated with this node

Module contents