Miscellaneous Utilities

Shader and ShaderProgram wrapper classes for vertex and fragment shaders used in Interactive Data Visualization

class yt_idv.opengl_support.ColormapTexture(*args: t.Any, **kwargs: t.Any)[source]

Bases: Texture1D

colormap_name

A casting version of the unicode trait.

class yt_idv.opengl_support.DepthBuffer(*args: t.Any, **kwargs: t.Any)[source]

Bases: Texture2D

create_texture(w, h)[source]
class yt_idv.opengl_support.Framebuffer(*args: t.Any, **kwargs: t.Any)[source]

Bases: HasTraits

bind(clear=True)[source]
property data

The color buffer, indexed [y, x, channel] with row 0 at the bottom.

db_tex

A trait whose value must be an instance of a specified class.

The value can also be an instance of a subclass of the specified class.

Subclasses can declare default classes by overriding the klass attribute

property depth_data

The depth buffer, indexed [y, x] with row 0 at the bottom.

fb_id

A casting version of the int trait.

fb_tex

A trait whose value must be an instance of a specified class.

The value can also be an instance of a subclass of the specified class.

Subclasses can declare default classes by overriding the klass attribute

initialized

A boolean (True, False) trait.

input_bind(fb_target=0, db_target=1)[source]
rb_id

A casting version of the int trait.

release()[source]
viewport

An instance of a Python tuple.

class yt_idv.opengl_support.GLValue(default_value: Any = traitlets.Undefined, allow_none: bool = False, read_only: bool | None = None, help: str | None = None, config: Any | None = None, **kwargs: Any)[source]

Bases: TraitType

default_value: t.Any = GL_NONE
info_text: str = 'An OpenGL constant.'
validate(obj, value)[source]
class yt_idv.opengl_support.Texture(*args: t.Any, **kwargs: t.Any)[source]

Bases: HasTraits

bind(target=0)[source]
channels
data

A numpy array trait type.

mag_filter
min_filter
release()[source]
texture_name

A casting version of the int trait.

class yt_idv.opengl_support.Texture1D(*args: t.Any, **kwargs: t.Any)[source]

Bases: Texture

boundary_x
dim_enum
dims = 1
class yt_idv.opengl_support.Texture2D(*args: t.Any, **kwargs: t.Any)[source]

Bases: Texture

boundary_x
boundary_y
channels = 1
dim_enum
dims = 2
class yt_idv.opengl_support.Texture3D(*args: t.Any, **kwargs: t.Any)[source]

Bases: Texture

allocate(dims, dtype='float32', channels=1)[source]

Allocate uninitialized storage of shape dims, without uploading data.

Like _set_data, the sampling state is set along with the storage.

boundary_x
boundary_y
boundary_z
dim_enum
dims = 3
set_subdata(offset, data)[source]

Upload data into the region of the texture starting at offset.

class yt_idv.opengl_support.Texture3DIterator(*args: t.Any, **kwargs: t.Any)[source]

Bases: HasTraits

items

A trait which allows any value.

class yt_idv.opengl_support.TextureAtlas(*args: t.Any, **kwargs: t.Any)[source]

Bases: HasTraits

Many 3D blocks packed into a single Texture3D.

The atlas is laid out once, when it is created, from the blocks’ sizes and padding; to change the layout, create a new atlas. No axis of it is larger than GL_MAX_3D_TEXTURE_SIZE, and if the blocks don’t fit, creating it raises a ValueError. Block i’s interior starts at offsets[i], and padding texels on every side of it (filled by __setitem__ with the block’s edge values) keep linear interpolation from reading a neighboring block.

If a vertex array is given, the offsets and sizes are added to it as the integer vertex attributes offset_attribute_name and size_attribute_name (ivec3s in the shaders), one per block, so the sizes have to be given in the vertex array’s block order.

bind(target=0)[source]
channels

A casting version of the int trait.

dims

A numpy array trait type.

dtype

A casting version of the unicode trait.

mag_filter
min_filter
offset_attribute_name

A casting version of the unicode trait.

offsets

A numpy array trait type.

padding

A casting version of the int trait.

release()[source]
size_attribute_name

A casting version of the unicode trait.

sizes

A numpy array trait type.

texture

A trait whose value must be an instance of a specified class.

The value can also be an instance of a subclass of the specified class.

Subclasses can declare default classes by overriding the klass attribute

vertex_array

A trait whose value must be an instance of a specified class.

The value can also be an instance of a subclass of the specified class.

Subclasses can declare default classes by overriding the klass attribute

class yt_idv.opengl_support.TextureBoundary(default_value: Any = traitlets.Undefined, allow_none: bool = False, read_only: bool | None = None, help: str | None = None, config: Any | None = None, **kwargs: Any)[source]

Bases: TraitType

default_value: t.Any = GL_CLAMP_TO_EDGE
info_text: str = 'A boundary type of mirror, clamp, or repeat'
validate(obj, value)[source]
class yt_idv.opengl_support.TransferFunctionTexture(*args: t.Any, **kwargs: t.Any)[source]

Bases: Texture2D

class yt_idv.opengl_support.VertexArray(*args: t.Any, **kwargs: t.Any)[source]

Bases: HasTraits

attributes

An instance of a Python list.

bind(program=None)[source]
each

A casting version of the int trait.

id

A casting version of the int trait.

index_id

A casting version of the int trait.

indices

A numpy array trait type.

keys()[source]
name

A casting version of the unicode trait.

release()[source]
class yt_idv.opengl_support.VertexAttribute(*args: t.Any, **kwargs: t.Any)[source]

Bases: HasTraits

bind(program=None)[source]
data

A numpy array trait type.

divisor

A casting version of the int trait.

each

A casting version of the int trait.

id

A casting version of the int trait.

integer

A boolean (True, False) trait.

name

A casting version of the unicode trait.

opengl_type

A casting version of the int trait.

release()[source]
yt_idv.opengl_support.coerce_uniform_type(val, gl_type)[source]
yt_idv.opengl_support.compute_box_geometry(left_edge, right_edge)[source]

Shader and ShaderProgram wrapper classes for vertex and fragment shaders used in Interactive Data Visualization

class yt_idv.shader_objects.PreprocessorDefinitionState[source]

Bases: object

add_definition(shader_type: str, value: tuple[str, str])[source]

add a definition for specified shader_type, will overwrite existing definitions.

clear_definition(shader_type: str, value: tuple[str, str])[source]

remove the definition of value for specified shader_type

get_shader_defs(shader_type: str) → list[tuple[str, str]][source]

return the preprocessor definition list for specified shader_type

reset(shader_type: str | None = None)[source]
class yt_idv.shader_objects.Shader(*args: t.Any, **kwargs: t.Any)[source]

Bases: HasTraits

Creates a shader from source

Parameters:
  • source (str) – This can either be a string containing a full source of a shader, an absolute path to a source file or a filename of a shader residing in the ./shaders/ directory.

  • allow_null (bool) – If True (default) then shader compilation errors will be caught and printed without raising exception (convenient for general use and for developing new shaders). If False, any compilation errors will raise a RunTimeError (useful for CI testing).

allow_null

A boolean (True, False) trait.

blend_equation
blend_equation_separate

An instance of a Python tuple.

blend_func

An instance of a Python tuple.

blend_func_separate

An instance of a Python tuple.

compile(source=None)[source]
property defines
delete_shader()[source]
depth_test
info

A casting version of the unicode trait.

preprocessor_defs

An instance of a Python list.

setup_blend()[source]
property shader
shader_name

A casting version of the unicode trait.

shader_type

An enum of strings where the case should be ignored.

source

A trait which allows any value.

use_separate_blend

A boolean (True, False) trait.

class yt_idv.shader_objects.ShaderProgram(vertex_shader=None, fragment_shader=None, geometry_shader=None, preprocessor_defs=None)[source]

Bases: object

Wrapper class that compiles and links vertex and fragment shaders into a shader program.

Parameters:
  • vertex_shader (string) – or yt.visualization.volume_rendering.shader_objects.VertexShader The vertex shader used in the Interactive Data Visualization pipeline.

  • fragment_shader (string) – or yt.visualization.volume_rendering.shader_objects.FragmentShader The fragment shader used in the Interactive Data Visualization pipeline.

  • geometry_shader (string) – or yt_idv.shader_objects.GeometryShader The geometry shader used in the pipeline; optional.

  • preprocessor_defs (PreprocessorDefinitionState) – a PreprocessorDefinitionState instance defining any preprocessor definitions if used; optional.

delete_program()[source]
enable()[source]
introspect()[source]
class yt_idv.shader_objects.ShaderTrait(default_value: Any = traitlets.Undefined, allow_none: bool = False, read_only: bool | None = None, help: str | None = None, config: Any | None = None, **kwargs: Any)[source]

Bases: TraitType

default_value: t.Any = None
info_text: str = 'A shader (vertex, fragment or geometry)'
validate(obj, value)[source]
yt_idv.shader_objects.get_shader_combos(component_name, coord_system='cartesian')[source]
class yt_idv.simple_gui.SimpleGUI(window)[source]

Bases: object

callbacks = None
context = None
draw = False
property keyboard_event_handled
property mouse_event_handled
render(scene)[source]
render_camera(scene)[source]
renderer = None
window = None
class yt_idv.traitlets_support.FontTrait(default_value: Any = traitlets.Undefined, allow_none: bool = False, read_only: bool | None = None, help: str | None = None, config: Any | None = None, **kwargs: Any)[source]

Bases: TraitType

info_text: str = 'A font instance from matplotlib'
validate(obj, value)[source]
class yt_idv.traitlets_support.YTPositionTrait(default_value: Any = traitlets.Undefined, allow_none: bool = False, read_only: bool | None = None, help: str | None = None, config: Any | None = None, **kwargs: Any)[source]

Bases: TraitType

default_value: t.Any = None
info_text: str = 'A position in code_length'
validate(obj, value)[source]
yt_idv.traitlets_support.ndarray_ro()[source]
yt_idv.traitlets_support.ndarray_shape(*dimensions)[source]