Main classes¶
Warning
The Python API reference documentation is still a work-in-progress. Please feel free to contribute.
datoviz._app.App
¶
App(
c_flags: int = 0,
offscreen: bool = False,
background: Optional[str] = None,
)
Main application class for managing figures, textures, visuals, and events.
Initialize the App instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_flags
|
int
|
Datoviz flags for the application, by default 0. |
0
|
offscreen
|
bool
|
Whether to run in offscreen mode, by default False. |
False
|
background
|
str or None
|
Background color ('white' or None), by default None (black). |
None
|
Warnings
The background
parameter is likely to change in future versions.
arcball_gui
¶
arcball_gui(panel, arcball) -> None
Attach an arcball GUI to a panel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
panel
|
Panel
|
Panel instance. |
required |
arcball
|
Arcball
|
Arcball instance. |
required |
basic
¶
basic(
topology: str,
position: ndarray = None,
color: ndarray = None,
group: ndarray = None,
size: float = None,
depth_test: bool = None,
cull: str = None,
) -> vs.Basic
Create a basic visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
topology
|
str
|
Topology type: |
required |
position
|
ndarray
|
Point 3D positions in normalized device coordinates. |
None
|
color
|
ndarray
|
Point RGBA colors in range 0–255. |
None
|
group
|
ndarray
|
Group indices of all points (optional). |
None
|
size
|
float
|
Point size in pixels, when using the |
None
|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
Returns:
Type | Description |
---|---|
Basic
|
The created basic visual instance. |
connect
¶
connect(figure: Figure) -> tp.Callable
Connect an event handler to the given figure, using the decorated function name to
determine the event to attach it to. The name of the decorated function can be on_mouse
,
on_keyboard
, or on_gui
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figure
|
Figure
|
The figure to connect handlers to. |
required |
Returns:
Type | Description |
---|---|
Callable
|
A decorator for event handlers. |
figure
¶
figure(
width: int = cst.DEFAULT_WIDTH,
height: int = cst.DEFAULT_HEIGHT,
c_flags: int = 0,
gui: bool = False,
) -> Figure
Create a new figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
width
|
int
|
Width of the figure, by default cst.DEFAULT_WIDTH. |
DEFAULT_WIDTH
|
height
|
int
|
Height of the figure, by default cst.DEFAULT_HEIGHT. |
DEFAULT_HEIGHT
|
c_flags
|
int
|
Flags for the figure, by default 0. |
0
|
gui
|
bool
|
Whether to enable GUI, by default False. |
False
|
Returns:
Type | Description |
---|---|
Figure
|
The created figure instance. |
Warnings
The gui
parameter must be True
when a GUI is used in the figure, and must be
False
otherwise. This may change in versions.
glyph
¶
glyph(
font_size: int = cst.DEFAULT_FONT_SIZE,
position: ndarray = None,
axis: ndarray = None,
size: ndarray = None,
anchor: ndarray = None,
shift: ndarray = None,
texcoords: ndarray = None,
group_size: ndarray = None,
scale: ndarray = None,
angle: ndarray = None,
color: ndarray = None,
bgcolor: Optional[Tuple[int, int, int, int]] = None,
texture: Optional[Texture] = None,
depth_test: bool = None,
cull: str = None,
) -> vs.Glyph
Create a glyph visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
font_size
|
int
|
Font size for the glyph, by default cst.DEFAULT_FONT_SIZE. |
DEFAULT_FONT_SIZE
|
position
|
ndarray
|
Glyph 3D positions in normalized device coordinates. |
None
|
axis
|
ndarray
|
Glyph axes in 3D space, used for rotation (not implemented yet). |
None
|
size
|
ndarray
|
Glyph sizes in pixels, each row contains the width and height of each glyph. |
None
|
anchor
|
ndarray
|
Glyph anchor points in pixels, each row contains the x and y anchor of each glyph. |
None
|
shift
|
ndarray
|
Glyph shifts in pixels, each row contains the x and y shift of each glyph. |
None
|
texcoords
|
ndarray
|
Glyph texture coordinates, each row contains the u0,v0,u1,v1 coordinates of each glyph within the font atlas texture. |
None
|
group_size
|
ndarray
|
Glyph group sizes, each row contains the width and height of the string (i.e., the group of glyphs) the glyph belongs to. |
None
|
scale
|
ndarray
|
Glyph scales, each row contains the scale factor for each glyph. |
None
|
angle
|
ndarray
|
Glyph rotation angles in radians, each row contains the angle for each glyph. |
None
|
color
|
ndarray
|
Glyph RGBA colors in range 0–255. |
None
|
bgcolor
|
Tuple[int, int, int, int]
|
Background color for the glyph, in RGBA format. |
None
|
texture
|
Texture
|
Texture for the glyph, typically a font atlas texture. |
None
|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
Returns:
Type | Description |
---|---|
Glyph
|
The created glyph visual instance. |
image
¶
image(
position: ndarray = None,
size: ndarray = None,
anchor: ndarray = None,
texcoords: ndarray = None,
facecolor: ndarray = None,
edgecolor: Optional[Tuple[int, int, int, int]] = None,
permutation: Tuple[int, int] = None,
linewidth: float = None,
radius: float = None,
colormap: Optional[str] = None,
texture: Optional[Texture] = None,
unit: str = None,
mode: str = None,
rescale: str = None,
border: bool = None,
depth_test: bool = None,
cull: str = None,
) -> vs.Image
Create an image visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position
|
ndarray
|
Image 3D positions in normalized device coordinates. |
None
|
size
|
ndarray
|
Image sizes in pixels or NDC, each row contains the width and height of each image. |
None
|
anchor
|
ndarray
|
Image anchor in normalized coordinates. |
None
|
texcoords
|
ndarray
|
Image texture coordinates, each row contains the u0,v0,u1,v1 coordinates of each image within the texture. |
None
|
facecolor
|
ndarray
|
Image face colors in RGBA format, each row contains the RGBA color of each image. |
None
|
edgecolor
|
Tuple[int, int, int, int]
|
Image edge color in RGBA format, used for the border. |
None
|
permutation
|
Tuple[int, int]
|
Permutation of the image texture coordinates, e.g., (0, 1) for normal orientation. |
None
|
linewidth
|
float
|
Line width for the image border, in pixels. |
None
|
radius
|
float
|
Radius for the image border, in pixels, or 0 for a square border. |
None
|
colormap
|
str
|
Colormap to apply to the image, when using the |
None
|
texture
|
Texture
|
Texture for the image, typically a 2D texture containing the image data. |
None
|
unit
|
str
|
Specifies the unit for the image size. Can be:
|
None
|
mode
|
str
|
Specifies the image mode. Can be:
|
None
|
rescale
|
str
|
Specifies how the image should be rescaled with transformations. Can be:
|
None
|
border
|
bool
|
Indicates whether to display a border around the image. Defaults to |
None
|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
Returns:
Type | Description |
---|---|
Image
|
The created image visual instance. |
marker
¶
marker(
position: ndarray = None,
color: ndarray = None,
size: ndarray = None,
angle: ndarray = None,
edgecolor: Tuple[int, int, int, int] = None,
linewidth: float = None,
tex_scale: float = None,
mode: str = None,
aspect: str = None,
shape: str = None,
texture: Optional[Texture] = None,
depth_test: bool = None,
cull: str = None,
) -> vs.Marker
Create a marker visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position
|
ndarray
|
Marker 3D positions in normalized device coordinates. |
None
|
color
|
ndarray
|
Marker RGBA colors in range 0–255. |
None
|
size
|
ndarray
|
Marker size in pixels. |
None
|
angle
|
ndarray
|
Marker rotation angle in radians. |
None
|
edgecolor
|
cvec4
|
Marker edge color in RGBA format. |
None
|
linewidth
|
float
|
Marker edge line width in pixels. |
None
|
tex_scale
|
float
|
Marker texture scale. |
None
|
mode
|
str
|
Marker mode, one of |
None
|
aspect
|
str
|
Marker aspect, one of |
None
|
shape
|
str
|
Marker shape, when using the |
None
|
texture
|
Texture
|
Texture for the marker when using another mode than |
None
|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
Returns:
Type | Description |
---|---|
Marker
|
The created marker visual instance. |
mesh
¶
mesh(
shape: ShapeCollection = None,
position: ndarray = None,
color: ndarray = None,
texcoords: ndarray = None,
normal: ndarray = None,
isoline: ndarray = None,
left: ndarray = None,
right: ndarray = None,
contour: Union[ndarray, bool] = None,
index: ndarray = None,
light_pos: Tuple[float, float, float, float] = None,
light_color: Tuple[int, int, int, int] = None,
material_params: Tuple[float, float, float] = None,
shine: float = None,
emit: float = None,
edgecolor: Optional[Tuple[int, int, int, int]] = None,
linewidth: float = None,
density: int = None,
texture: Optional[Texture] = None,
indexed: Optional[bool] = None,
lighting: Optional[bool] = None,
depth_test: bool = None,
cull: str = None,
) -> vs.Mesh
Create a mesh visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape
|
ShapeCollection
|
Create a mesh from a shape collection. |
None
|
position
|
ndarray
|
Vertex 3D positions in normalized device coordinates. |
None
|
color
|
ndarray
|
Vertex RGBA colors in range 0–255. |
None
|
texcoords
|
ndarray
|
Vertex texture coordinates, each row contains the u0,v0,u1,v1 coordinates of each vertex within the texture. |
None
|
normal
|
ndarray
|
Vertex normals in normalized device coordinates. |
None
|
isoline
|
ndarray
|
Scalar field, one value per vertex, is showing isolines. |
None
|
left
|
ndarray
|
Left values for contours (not documented yet). |
None
|
right
|
ndarray
|
Right values for contours (not documented yet). |
None
|
contour
|
ndarray or bool
|
Contour values for the mesh (not documented yet), or a boolean indicating whether to use contours. |
None
|
index
|
ndarray
|
Vertex indices for indexed meshes (three integers per triangle). |
None
|
light_pos
|
Tuple[float, float, float, float]
|
Light position in normalized device coordinates, in the form (x, y, z, w).
If |
None
|
light_color
|
Tuple[int, int, int, int]
|
Light color in RGBA format, in the form (r, g, b, a). |
None
|
material_params
|
Tuple[float, float, float]
|
Material ambient parameters for the mesh, in the form (r, g, b).
For diffuse, specular, and exponent, use |
None
|
shine
|
float
|
Material shine factor for the mesh, in the range [0, 1]. |
None
|
emit
|
float
|
Material emission factor for the mesh, in the range [0, 1]. |
None
|
edgecolor
|
Tuple[int, int, int, int]
|
Edge color for the mesh, in RGBA format, when showing contours or isolines. |
None
|
linewidth
|
float
|
Line width for the mesh edges, in pixels, when showing contours or isolines. |
None
|
density
|
int
|
Density of isolines, in pixels, when showing isolines. |
None
|
texture
|
Texture
|
Texture for the mesh, when using textured mesh. |
None
|
indexed
|
bool
|
Whether the mesh is indexed. If |
None
|
lighting
|
bool
|
Whether lighting is enabled. |
None
|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
Returns:
Type | Description |
---|---|
Mesh
|
The created mesh visual instance. |
on_frame
¶
on_frame(figure: Figure) -> tp.Callable
Register a frame event handler for the given figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figure
|
Figure
|
The figure to attach the handler to. |
required |
Returns:
Type | Description |
---|---|
Callable
|
A decorator for the frame event handler. |
on_gui
¶
on_gui(figure: Figure) -> tp.Callable
Register a GUI event handler for the given figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figure
|
Figure
|
The figure to attach the handler to. |
required |
Returns:
Type | Description |
---|---|
Callable
|
A decorator for the GUI event handler. |
on_keyboard
¶
on_keyboard(figure: Figure) -> tp.Callable
Register a keyboard event handler for the given figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figure
|
Figure
|
The figure to attach the handler to. |
required |
Returns:
Type | Description |
---|---|
Callable
|
A decorator for the keyboard event handler. |
on_mouse
¶
on_mouse(figure: Figure) -> tp.Callable
Register a mouse event handler for the given figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figure
|
Figure
|
The figure to attach the handler to. |
required |
Returns:
Type | Description |
---|---|
Callable
|
A decorator for the mouse event handler. |
path
¶
path(
position: ndarray = None,
color: ndarray = None,
linewidth: ndarray = None,
cap: str = None,
join: str = None,
depth_test: bool = None,
cull: str = None,
) -> vs.Path
Create a path visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position
|
ndarray, or list of ndarray
|
An array of positions, or a list of arrays representing the positions of the paths. |
None
|
color
|
ndarray
|
Point RGBA colors in range 0–255. |
None
|
linewidth
|
ndarray
|
Uniform or varying line width for each path point. |
None
|
cap
|
str
|
Cap style for all paths, one of |
None
|
join
|
str
|
Join style for all paths, one of |
None
|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
Returns:
Type | Description |
---|---|
Path
|
The created path visual instance. |
pixel
¶
pixel(
position: ndarray = None,
color: ndarray = None,
size: float = None,
depth_test: bool = None,
cull: str = None,
) -> vs.Pixel
Create a pixel visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position
|
ndarray
|
Point 3D positions in normalized device coordinates. |
None
|
color
|
ndarray
|
Point RGBA colors in range 0–255. |
None
|
size
|
float
|
Point size in pixels, when using the |
None
|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
Returns:
Type | Description |
---|---|
Pixel
|
The created pixel visual instance. |
point
¶
point(
position: ndarray = None,
color: ndarray = None,
size: ndarray = None,
depth_test: bool = None,
cull: str = None,
) -> vs.Point
Create a point visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position
|
ndarray
|
Point 3D positions in normalized device coordinates. |
None
|
color
|
ndarray
|
Point RGBA colors in range 0–255. |
None
|
size
|
ndarray
|
Point size in pixels. |
None
|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
Returns:
Type | Description |
---|---|
Point
|
The created point visual instance. |
run
¶
run(frame_count: int = 0) -> None
Run the application.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame_count
|
int
|
Number of frames to run. 0 for infinite, by default 0. |
0
|
screenshot
¶
screenshot(figure: Figure, png_path: str) -> None
Take a screenshot of the given figure.
This function first runs one frame before saving the screenshot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figure
|
Figure
|
The figure to capture. |
required |
png_path
|
str
|
Path to save the screenshot. |
required |
segment
¶
segment(
initial: ndarray = None,
terminal: ndarray = None,
shift: ndarray = None,
color: ndarray = None,
linewidth: ndarray = None,
cap: str = None,
depth_test: bool = None,
cull: str = None,
) -> vs.Segment
Create a segment visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
initial
|
ndarray
|
3D positions of the initial end of each segment, in normalized device coordinates. |
None
|
terminal
|
ndarray
|
3D positions of the terminal end of each segment, in normalized device coordinates. |
None
|
color
|
ndarray
|
Segment RGBA colors in range 0–255. |
None
|
shift
|
ndarray
|
Shift vector for each segment, in pixels. Each row of this 2D array contains the pixel shift of the initial and terminal end of each segment (x0,y0,x1,y1), in framebuffer coordinates. |
None
|
linewidth
|
ndarray
|
Line width for each segment, in pixels. |
None
|
cap
|
str
|
Cap style for the segment, one of |
None
|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
Returns:
Type | Description |
---|---|
Segment
|
The created segment visual instance. |
sphere
¶
sphere(
position: ndarray = None,
color: ndarray = None,
size: ndarray = None,
light_pos: Optional[
Tuple[float, float, float, float]
] = None,
light_color: Optional[Tuple[int, int, int, int]] = None,
material_params: Optional[
Tuple[float, float, float]
] = None,
shine: Optional[float] = None,
emit: Optional[float] = None,
texture: Optional[Texture] = None,
lighting: Optional[bool] = None,
size_pixels: Optional[bool] = None,
depth_test: bool = None,
cull: str = None,
) -> vs.Sphere
Create a sphere visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position
|
ndarray
|
Sphere 3D positions in normalized device coordinates. |
None
|
color
|
ndarray
|
Sphere RGBA colors in range 0–255. |
None
|
size
|
ndarray
|
Sphere sizes in pixels or NDC, depending on |
None
|
light_pos
|
Tuple[float, float, float, float]
|
Light position in normalized device coordinates, in the form (x, y, z, w).
If |
None
|
light_color
|
Tuple[int, int, int, int]
|
Light color in RGBA format, in the form (r, g, b, a). |
None
|
material_params
|
Tuple[float, float, float]
|
Material ambient parameters for the sphere, in the form (r, g, b).
For diffuse, specular, and exponent, use |
None
|
shine
|
float
|
Material shine factor for the sphere, in the range [0, 1]. |
None
|
emit
|
float
|
Material emission factor for the sphere, in the range [0, 1]. |
None
|
texture
|
Texture
|
Texture for the sphere, when using a textured sphere. |
None
|
lighting
|
bool
|
Whether lighting is enabled. |
None
|
size_pixels
|
bool
|
Whether to specify the sphere size in pixels rather than NDC. |
None
|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
Returns:
Type | Description |
---|---|
Sphere
|
The created sphere visual instance. |
texture
¶
texture(
image: Optional[ndarray] = None,
ndim: int = 2,
shape: Optional[Tuple[int, ...]] = None,
n_channels: Optional[int] = None,
dtype: Optional[dtype] = None,
interpolation: Optional[str] = None,
address_mode: Optional[str] = None,
) -> Texture
Create a texture, either with or without initial image data. If without, all texture parameters must be specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
ndarray
|
Image data for the texture, by default None. |
None
|
ndim
|
int
|
Number of texture dimensions (1, 2, or 3), by default 2. |
2
|
shape
|
tuple of int
|
Shape of the texture, inferred from |
None
|
n_channels
|
int
|
Number of color channels, inferred from |
None
|
dtype
|
dtype
|
Data type of the texture, inferred from |
None
|
interpolation
|
str
|
Interpolation mode, |
None
|
address_mode
|
str
|
Address mode: |
None
|
Returns:
Type | Description |
---|---|
Texture
|
The created texture instance. |
texture_1D
¶
texture_1D(
data: ndarray,
interpolation: Optional[str] = None,
address_mode: Optional[str] = None,
) -> Texture
Create a 1D texture.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ndarray
|
Data for the texture. |
required |
interpolation
|
str
|
Interpolation mode (see |
None
|
address_mode
|
str
|
Address mode (see |
None
|
Returns:
Type | Description |
---|---|
Texture
|
The created 1D texture instance. |
texture_2D
¶
texture_2D(
image: ndarray,
interpolation: Optional[str] = None,
address_mode: Optional[str] = None,
) -> Texture
Create a 2D texture.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
ndarray
|
Image data for the texture. |
required |
interpolation
|
str
|
Interpolation mode (see |
None
|
address_mode
|
str
|
Address mode (see |
None
|
Returns:
Type | Description |
---|---|
Texture
|
The created 2D texture instance. |
texture_3D
¶
texture_3D(
volume: ndarray,
shape: Optional[Tuple[int, ...]] = None,
interpolation: Optional[str] = None,
address_mode: Optional[str] = None,
) -> Texture
Create a 3D texture.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
volume
|
ndarray
|
Volume data for the texture. |
required |
shape
|
tuple of int
|
Shape of the texture, by default None. |
None
|
interpolation
|
str
|
Interpolation mode (see |
None
|
address_mode
|
str
|
Address mode (see |
None
|
Returns:
Type | Description |
---|---|
Texture
|
The created 3D texture instance. |
timer
¶
timer(
delay: float = 0.0,
period: float = 1.0,
max_count: int = 0,
) -> tp.Callable
Register a timer event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
delay
|
float
|
Initial delay before the timer starts, by default 0.0. |
0.0
|
period
|
float
|
Period of the timer in seconds, by default 1.0 second. |
1.0
|
max_count
|
int
|
Maximum number of timer events, or 0 for unlimited timer ticks, by default 0. |
0
|
Returns:
Type | Description |
---|---|
Callable
|
A decorator for the timer event handler. |
timestamps
¶
timestamps(
figure: Figure, count: int
) -> Tuple[np.ndarray, np.ndarray]
Get presentation timestamps for the given figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figure
|
Figure
|
The figure to get timestamps for. |
required |
count
|
int
|
Number of timestamps. |
required |
Returns:
Type | Description |
---|---|
tuple of np.ndarray
|
Seconds and nanoseconds arrays. |
volume
¶
volume(
bounds: Tuple[tuple, tuple, tuple] = None,
permutation: Tuple[int, int, int] = None,
slice: int = None,
transfer: Tuple[float, float, float, float] = None,
texture: Optional[Texture] = None,
mode: str = "colormap",
) -> vs.Volume
Create a volume visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bounds
|
Tuple[tuple, tuple, tuple]
|
Bounds of the volume in normalized device coordinates, as three tuples (xmin, xmax), (ymin, ymax), (zmin, zmax). |
None
|
permutation
|
Tuple[int, int, int]
|
Permutation of the volume axes, e.g., (0, 1, 2) for normal orientation. |
None
|
slice
|
int
|
Slice index to display (not implemented yet). |
None
|
transfer
|
Tuple[float, float, float, float]
|
Transfer function parameters for the volume (only the first value is used for now). |
None
|
texture
|
Texture
|
Texture for the volume, typically a 3D texture containing the volume data. |
None
|
mode
|
str
|
Volume mode ('rgba', 'colormap'), by default 'colormap'. |
'colormap'
|
Returns:
Type | Description |
---|---|
Volume
|
The created volume visual instance. |
datoviz._figure.Figure
¶
Figure(c_figure: DvzFigure)
Represents a figure, which is a container for panels.
Initialize a Figure instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_figure
|
DvzFigure
|
The underlying C figure object. |
required |
figure_id
¶
figure_id() -> int
Get the Datoviz internal ID of the figure.
Returns:
Type | Description |
---|---|
int
|
The ID of the figure. |
panel
¶
panel(
offset: Tuple[float, float] = None,
size: Tuple[float, float] = None,
background: Tuple[
Tuple[int, int, int, int],
Tuple[int, int, int, int],
Tuple[int, int, int, int],
Tuple[int, int, int, int],
] = None,
) -> Panel
Create a new panel in the figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
tuple of float
|
The (x, y) offset of the panel, in pixels, by default (0, 0). |
None
|
size
|
tuple of float
|
The (width, height) size of the panel, by default the entire window size. |
None
|
background
|
tuple or boolean
|
If True, show a default gradient background. Otherwise, a tuple of four RGBA colors, for each corner of the panel (top-left, top-right, bottom-left, bottom-right). |
None
|
Returns:
Type | Description |
---|---|
Panel
|
The created panel instance. |
datoviz._panel.Panel
¶
Panel(
c_panel: DvzPanel, c_figure: Optional[DvzFigure] = None
)
Represents a panel in a figure, which can contain visuals and interactivity.
Initialize a Panel instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_panel
|
DvzPanel
|
The underlying C panel object. |
required |
c_figure
|
DvzFigure
|
The figure to which the panel belongs, by default None. |
None
|
add
¶
add(visual: Visual) -> None
Add a visual to the panel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
visual
|
Visual
|
The visual to add. |
required |
arcball
¶
arcball(
initial: Optional[Vec3] = None, c_flags: int = 0
) -> Arcball
Add arcball interactivity to the panel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
initial
|
Vec3
|
Initial position of the arcball, by default None. |
None
|
c_flags
|
int
|
Datoviz flags for the arcball interactivity, by default 0. |
0
|
Returns:
Type | Description |
---|---|
Arcball
|
The arcball interactivity instance. |
camera
¶
camera(
initial: Optional[Vec3] = None,
initial_lookat: Optional[Vec3] = None,
initial_up: Optional[Vec3] = None,
c_flags: int = 0,
) -> Camera
Add 3D camera interactivity to the panel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
initial
|
Vec3
|
Initial camera position, by default None. |
None
|
initial_lookat
|
Vec3
|
Initial look-at position, by default None. |
None
|
initial_up
|
Vec3
|
Initial up vector, by default None. |
None
|
c_flags
|
int
|
Datoviz flags for the camera interactivity, by default 0. |
0
|
Returns:
Type | Description |
---|---|
Camera
|
The camera interactivity instance. |
demo_2D
¶
demo_2D() -> Visual
Add a 2D demo visual to the panel.
Returns:
Type | Description |
---|---|
Visual
|
The 2D demo visual instance. |
demo_3D
¶
demo_3D() -> Visual
Add a 3D demo visual to the panel.
Returns:
Type | Description |
---|---|
Visual
|
The 3D demo visual instance. |
gui
¶
gui(title: Optional[str] = None, c_flags: int = 0) -> None
Convert a standard Datoviz panel to a movable GUI panel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
Title of the GUI, by default 'Panel'. |
None
|
c_flags
|
int
|
Datoviz flags for the GUI, by default 0. |
0
|
Warnings
This functionality is still experimental.
margins
¶
margins(
top: float = 0,
right: float = 0,
bottom: float = 0,
left: float = 0,
) -> None
Set the margins of the panel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
top
|
float
|
Top margin in pixels, by default 0. |
0
|
right
|
float
|
Right margin in pixels, by default 0. |
0
|
bottom
|
float
|
Bottom margin in pixels, by default 0. |
0
|
left
|
float
|
Left margin in pixels, by default 0. |
0
|
ortho
¶
ortho(c_flags: int = 0) -> Ortho
Add orthographic interactivity to the panel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_flags
|
int
|
Datoviz flags for the orthographic interactivity, by default 0. |
0
|
Returns:
Type | Description |
---|---|
Ortho
|
The orthographic interactivity instance. |
panzoom
¶
panzoom(
c_flags: int = 0, fixed: Optional[str] = None
) -> Panzoom
Add panzoom interactivity to the panel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_flags
|
int
|
Datoviz flags for the panzoom interactivity, by default 0. |
0
|
fixed
|
str
|
'x' or 'y' to fix the panzoom interactivity along a given axis. |
None
|
Returns:
Type | Description |
---|---|
Panzoom
|
The panzoom interactivity instance. |
remove
¶
remove(visual: Visual) -> None
Remove a visual from the panel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
visual
|
Visual
|
The visual to remove. |
required |
datoviz._axes.Axes
¶
Axes(
c_axes: DvzAxes,
c_ref: DvzRef,
c_panzoom: DvzPanzoom,
c_panel: DvzPanel,
)
Represents 2D axes.
Initialize an Axes instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_axes
|
DvzAxes
|
The underlying C axes object. |
required |
c_ref
|
DvzRef
|
The underlying C ref object. |
required |
c_panzoom
|
DvzPanzoom
|
The underlying C panzoom object. |
required |
c_panel
|
DvzPanel
|
The underlying C panel object. |
required |
bounds
¶
bounds()
Return the bounds of the panzoom area.
This method computes the minimum and maximum bounds for both the x-axis and y-axis of the panzoom area.
Returns:
Type | Description |
---|---|
tuple of xlim (xmin, xmax) and ylim (ymin, ymax)
|
|
normalize
¶
normalize(x: ndarray, y: ndarray = None, z: ndarray = None)
Normalize input coordinates to a standard range.
This function normalizes 1D, 2D, or 3D input coordinates using a reference normalization method. The input can be provided as a single array or as separate arrays for each dimension.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
The array representing the x-coordinates. If |
required |
y
|
ndarray
|
The array representing the y-coordinates. If not provided, the input is assumed to be 1D. |
None
|
z
|
ndarray
|
The array representing the z-coordinates. If not provided, the input is assumed to be 2D. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
A normalized array of shape |
Raises:
Type | Description |
---|---|
AssertionError
|
If the input array does not have the correct dimensions. |
NotImplementedError
|
If the input dimensionality is not 1D, 2D, or 3D. |
Notes
This function uses dvz.ref_normalize_1D
, dvz.ref_normalize_2D
, or
dvz.ref_normalize_3D
for normalization, depending on the dimensionality
of the input.
normalize_polygon
¶
normalize_polygon(points: ndarray)
Normalize a polygon by transforming its points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points
|
ndarray
|
A 2D array of shape (n, 2) containing the coordinates of the polygon's points.
The array must have a dtype of |
required |
Returns:
Type | Description |
---|---|
ndarray
|
A 2D array of shape (n, 2) containing the normalized coordinates of the polygon's points. |
Raises:
Type | Description |
---|---|
AssertionError
|
If |
xlim
¶
xlim(xmin: float, xmax: float)
Set the xlim of the axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xmin
|
float
|
The minimal x in data coordinates. |
required |
xmax
|
float
|
The maximal x in data coordinates. |
required |
ylim
¶
ylim(ymin: float, ymax: float)
Set the ylim of the axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ymin
|
float
|
The minimal y in data coordinates. |
required |
ymax
|
float
|
The maximal y in data coordinates. |
required |
datoviz.interact.Panzoom
¶
Panzoom(c_panzoom: DvzPanzoom, c_panel: DvzPanel = None)
Represents panzoom interactivity for a panel.
Initialize a Panzoom instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_panzoom
|
DvzPanzoom
|
The underlying C panzoom object. |
required |
c_panel
|
DvzPanel
|
The panel to which the panzoom interactivity is attached, by default None. |
None
|
datoviz.interact.Arcball
¶
Arcball(c_arcball: DvzArcball, c_panel: DvzPanel = None)
Represents arcball interactivity for a panel.
Initialize an Arcball instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_arcball
|
DvzArcball
|
The underlying C arcball object. |
required |
c_panel
|
DvzPanel
|
The panel to which the arcball interactivity is attached, by default None. |
None
|
get
¶
get() -> Tuple[float, float, float]
Get the current angles of the arcball.
Returns:
Type | Description |
---|---|
tuple of float
|
The (x, y, z) angles of the arcball. |
set
¶
set(angles: Tuple[float, float, float]) -> None
Set the angles of the arcball.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angles
|
tuple of float
|
The (x, y, z) angles to set. |
required |
datoviz._texture.Texture
¶
Texture(
c_texture: DvzTexture,
c_batch: DvzApp = None,
ndim: int = None,
)
Represents a texture in the application.
Initialize a Texture instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_texture
|
DvzTexture
|
The underlying C texture object. |
required |
c_batch
|
DvzBatch
|
The underlying C app object. |
None
|
ndim
|
int
|
The number of dimensions in the texture. |
None
|
data
¶
data(image: ndarray, offset: Tuple[int, int, int] = None)
Upload an image to the texture with an optional offset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
ndarray
|
The image data to upload. |
required |
offset
|
Tuple[int, int, int]
|
The offset at which to upload the image in the texture. Defaults to (0, 0, 0). |
None
|
Notes
The function determines the width, height, and depth of the image based on its shape.
It then uploads the image data to the texture using the dvz.upload_tex
function.
datoviz._event.Event
¶
Event(c_ev: Any, event_type: str)
Represents an event in the application, such as mouse or keyboard input.
Initialize an Event instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_ev
|
Any
|
The underlying C event object. |
required |
event_type
|
str
|
The type of the event (e.g., 'mouse', 'keyboard'). |
required |
type
property
¶
type: int
Get the C event type.
Returns:
Type | Description |
---|---|
int
|
The C event type as an integer. |
button
¶
button() -> Optional[int]
Get the mouse button C enumeration associated with the event.
Returns:
Type | Description |
---|---|
int or None
|
The mouse button, or None if not a mouse event. |
button_name
¶
button_name() -> Optional[str]
Get the name of the mouse button.
Returns:
Type | Description |
---|---|
str or None
|
The name of the mouse button ( |
is_keyboard
¶
is_keyboard() -> bool
Return whether the event is a keyboard event.
Returns:
Type | Description |
---|---|
bool
|
True if the event is a keyboard event, False otherwise. |
is_mouse
¶
is_mouse() -> bool
Return whether the event is a mouse event.
Returns:
Type | Description |
---|---|
bool
|
True if the event is a mouse event, False otherwise. |
key
¶
key() -> Optional[int]
Get the key C enumeration associated with the keyboard event.
Returns:
Type | Description |
---|---|
int or None
|
The key code, or None if not a keyboard event. |
key_event
¶
key_event(prettify: bool = True) -> Optional[str]
Get the keyboard event type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prettify
|
bool
|
Whether to return a prettified string representation, by default True. |
True
|
Returns:
Type | Description |
---|---|
str or None
|
The keyboard event type, or None if not a keyboard event. |
key_name
¶
key_name() -> Optional[str]
Get the name of the key associated with the keyboard event.
Returns:
Type | Description |
---|---|
str or None
|
The name of the key, or None if not a keyboard event. |
mouse_event
¶
mouse_event(prettify: bool = True) -> Optional[str]
Get the mouse event type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prettify
|
bool
|
Whether to return a prettified string representation, by default True. |
True
|
Returns:
Type | Description |
---|---|
str or None
|
The mouse event type ( |
pos
¶
pos() -> Optional[Tuple[float, float]]
Get the position of the mouse event.
Returns:
Type | Description |
---|---|
tuple of float or None
|
The (x, y) position of the mouse event, or None if not a mouse event. |
press_pos
¶
press_pos() -> Optional[Tuple[float, float]]
Get the position where the mouse was pressed during a drag event.
Returns:
Type | Description |
---|---|
tuple of float or None
|
The (x, y) position of the press event, or None if not applicable. |
wheel
¶
wheel() -> Optional[float]
Get the wheel scroll amount (in vertical direction).
Returns:
Type | Description |
---|---|
float or None
|
The scroll amount, or None if not a wheel event. |
datoviz.shape_collection.ShapeCollection
¶
ShapeCollection()
A collection of shapes that can be transformed, merged, and rendered.
Initialize an empty ShapeCollection.
add
¶
add(
c_shape: Shape,
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
) -> None
Add a shape to the collection with optional transformations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_shape
|
Shape
|
The shape to add. |
required |
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
add_arrow
¶
add_arrow(
count: int = None,
head_length: float = None,
head_radius: float = None,
shaft_radius: float = None,
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
) -> None
Add a 3D arrow (a cylinder and a cone), total length is 1.
Use offset, scale, transform to modify its size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of edges. |
None
|
head_length
|
float
|
The head length. |
None
|
head_radius
|
float
|
The head radius. |
None
|
shaft_radius
|
float
|
The shaft length. |
None
|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the cone, by default None. |
None
|
add_cone
¶
add_cone(
count: int = None,
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
) -> None
Add a cone shape to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of edges. |
None
|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the cone, by default None. |
None
|
add_cube
¶
add_cube(
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
) -> None
Add a cube shape to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the cube, by default None. |
None
|
add_custom
¶
add_custom(
positions: ndarray,
normals: ndarray = None,
colors: ndarray = None,
texcoords: ndarray = None,
indices: ndarray = None,
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
)
Add a custom shape to the collection with optional transformations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
positions
|
ndarray
|
An (N, 3) array with the vertex positions. |
required |
normals
|
ndarray
|
An (N, 3) array with the vertex normal vectors. |
None
|
colors
|
ndarray
|
An (N, 4) array with the vertex colors. |
None
|
texcoords
|
ndarray
|
An (N, 4) array with the vertex texture coordinates. |
None
|
indices
|
ndarray
|
An (M,) array with the face indices. |
None
|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
add_cylinder
¶
add_cylinder(
count: int = None,
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
) -> None
Add a cylinder shape to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of edges. |
None
|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the cylinder, by default None. |
None
|
add_disc
¶
add_disc(
count: int,
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
) -> None
Add a disc shape to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of sides in the disc. |
required |
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the disc, by default None. |
None
|
add_dodecahedron
¶
add_dodecahedron(
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
) -> None
Add a dodecahedron shape to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the dodecahedron, by default None. |
None
|
add_hexahedron
¶
add_hexahedron(
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
) -> None
Add a hexahedron shape to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the hexahedron, by default None. |
None
|
add_icosahedron
¶
add_icosahedron(
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
) -> None
Add an icosahedron shape to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the icosahedron, by default None. |
None
|
add_obj
¶
add_obj(
file_path: str,
contour: str = None,
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
) -> None
Add a shape from an OBJ file to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
The path to the OBJ file. |
required |
contour
|
str
|
The contour type to apply, by default None. |
None
|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
add_octahedron
¶
add_octahedron(
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
) -> None
Add an octahedron shape to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the octahedron, by default None. |
None
|
add_polygon
¶
add_polygon(
points: ndarray,
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
contour: str = None,
indexing: str = None,
) -> None
Add a polygon shape to the collection.
This function uses earcut to triangulate the polygon. More sophisticated triangulations methods will be added in a future version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points
|
ndarray
|
The points defining the polygon. |
required |
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the polygon, by default None. |
None
|
contour
|
str
|
The contour type to apply, by default None. |
None
|
indexing
|
str
|
The indexing type to apply, by default None. |
None
|
Warnings:
Polygon contour is still experimental, it may not work well in some instances.
add_sector
¶
add_sector(
count: int,
angle_start: float,
angle_stop: float,
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
) -> None
Add a disc shape to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of sides in the disc. |
required |
angle_start
|
float
|
The start angle, in radians. |
required |
angle_stop
|
float
|
The stop angle, in radians. |
required |
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the disc, by default None. |
None
|
add_sphere
¶
add_sphere(
rows: int = None,
cols: int = None,
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
) -> None
Add a sphere shape to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rows
|
int
|
The number of rows in the sphere, by default None. |
None
|
cols
|
int
|
The number of columns in the sphere, by default None. |
None
|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the sphere, by default None. |
None
|
add_square
¶
add_square(
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
) -> None
Add a square shape to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the square, by default None. |
None
|
add_surface
¶
add_surface(
heights: ndarray,
colors: ndarray,
contour: str = None,
indexing: str = None,
u: Tuple[float, float, float] = None,
v: Tuple[float, float, float] = None,
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
) -> None
Add a surface shape to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
heights
|
ndarray
|
The height values of the surface. |
required |
colors
|
ndarray
|
The color values of the surface. |
required |
contour
|
str
|
The contour type to apply, by default None. |
None
|
indexing
|
str
|
The indexing type to apply, by default None. |
None
|
u
|
tuple of float
|
The u vector for the surface, by default None. |
None
|
v
|
tuple of float
|
The v vector for the surface, by default None. |
None
|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
add_tetrahedron
¶
add_tetrahedron(
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
) -> None
Add a tetrahedron shape to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the tetrahedron, by default None. |
None
|
add_torus
¶
add_torus(
count_radial: int = None,
count_tubular: int = None,
tube_radius: float = None,
offset: Tuple[float, float, float] = None,
scale: float = None,
transform: Mat4 = None,
color: Color = None,
) -> None
Add a torus shape to the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count_radial
|
int
|
The number of edges. |
None
|
count_tubular
|
int
|
The number of edges around a circular cross-section. |
None
|
tube_radius
|
float
|
The radius of the tube, in NDC. |
None
|
offset
|
tuple of float
|
The (x, y, z) offset to apply, by default None. |
None
|
scale
|
float
|
The scale factor to apply, by default None. |
None
|
transform
|
Mat4
|
A 4x4 transformation matrix, by default None. |
None
|
color
|
Color
|
The color of the cylinder, by default None. |
None
|
datoviz.visuals.Basic
¶
Basic(c_visual: DvzVisual, visual_name: str = None)
Bases: Visual
A basic visual using the default graphical primitives (points, lines, triangles).
Initialize a Visual instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_visual
|
DvzVisual
|
The underlying C visual object. |
required |
visual_name
|
str
|
The name of the visual, by default None. |
None
|
allocate
¶
allocate(count: int) -> None
Allocate memory for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements to allocate. |
required |
clip
¶
clip(clip: str) -> None
Set the clipping mode for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clip
|
str
|
The clipping mode:
- |
required |
fixed
¶
fixed(fixed: Union[bool, str]) -> None
Set whether the visual is fixed along certain axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixed
|
bool or str
|
Use True to fix all x, y, z dimensions, or |
required |
get_count
¶
get_count() -> int
Get the number of elements in the visual.
Returns:
Type | Description |
---|---|
int
|
The number of elements. |
set_color
¶
set_color(array: ndarray, offset: int = 0) -> None
Set the color of the visual's elements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The color array. |
required |
offset
|
int
|
The offset at which to start setting the color, by default 0. |
0
|
set_count
¶
set_count(count: int) -> None
Set the number of elements in the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements. |
required |
set_data
¶
set_data(
depth_test: bool = None, cull: str = None, **kwargs
) -> None
Set data for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
**kwargs
|
Additional data to set. |
{}
|
set_group
¶
set_group(array: ndarray, offset: int = 0) -> None
Set the groups.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The group array. |
required |
offset
|
int
|
The offset at which to start setting the group, by default 0. |
0
|
set_position
¶
set_position(array: ndarray, offset: int = 0) -> None
Set the position of the visual's elements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The position array. |
required |
offset
|
int
|
The offset at which to start setting the position, by default 0. |
0
|
set_prop_class
¶
set_prop_class(prop_name: str, prop_cls: type) -> None
Set the class for a property.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prop_name
|
str
|
The name of the property. |
required |
prop_cls
|
type
|
The class of the property. |
required |
set_size
¶
set_size(value: float) -> None
Set the common size of the visual's elements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The size value. |
required |
show
¶
show(is_visible: bool = True) -> None
Show or hide the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_visible
|
bool
|
Whether to show the visual, by default True. |
True
|
datoviz.visuals.Pixel
¶
Pixel(c_visual: DvzVisual, visual_name: str = None)
Bases: Visual
A visual for rendering individual pixels.
Initialize a Visual instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_visual
|
DvzVisual
|
The underlying C visual object. |
required |
visual_name
|
str
|
The name of the visual, by default None. |
None
|
allocate
¶
allocate(count: int) -> None
Allocate memory for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements to allocate. |
required |
clip
¶
clip(clip: str) -> None
Set the clipping mode for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clip
|
str
|
The clipping mode:
- |
required |
fixed
¶
fixed(fixed: Union[bool, str]) -> None
Set whether the visual is fixed along certain axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixed
|
bool or str
|
Use True to fix all x, y, z dimensions, or |
required |
get_count
¶
get_count() -> int
Get the number of elements in the visual.
Returns:
Type | Description |
---|---|
int
|
The number of elements. |
set_color
¶
set_color(array: ndarray, offset: int = 0) -> None
Set the color of the pixels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The color array. |
required |
offset
|
int
|
The offset at which to start setting the color, by default 0. |
0
|
set_count
¶
set_count(count: int) -> None
Set the number of elements in the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements. |
required |
set_data
¶
set_data(
depth_test: bool = None, cull: str = None, **kwargs
) -> None
Set data for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
**kwargs
|
Additional data to set. |
{}
|
set_position
¶
set_position(array: ndarray, offset: int = 0) -> None
Set the position of the pixels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The position array. |
required |
offset
|
int
|
The offset at which to start setting the position, by default 0. |
0
|
set_prop_class
¶
set_prop_class(prop_name: str, prop_cls: type) -> None
Set the class for a property.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prop_name
|
str
|
The name of the property. |
required |
prop_cls
|
type
|
The class of the property. |
required |
set_size
¶
set_size(value: float) -> None
Set the size of the pixels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The size value. |
required |
show
¶
show(is_visible: bool = True) -> None
Show or hide the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_visible
|
bool
|
Whether to show the visual, by default True. |
True
|
datoviz.visuals.Point
¶
Point(c_visual: DvzVisual, visual_name: str = None)
Bases: Visual
A visual for rendering points.
Initialize a Visual instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_visual
|
DvzVisual
|
The underlying C visual object. |
required |
visual_name
|
str
|
The name of the visual, by default None. |
None
|
allocate
¶
allocate(count: int) -> None
Allocate memory for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements to allocate. |
required |
clip
¶
clip(clip: str) -> None
Set the clipping mode for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clip
|
str
|
The clipping mode:
- |
required |
fixed
¶
fixed(fixed: Union[bool, str]) -> None
Set whether the visual is fixed along certain axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixed
|
bool or str
|
Use True to fix all x, y, z dimensions, or |
required |
get_count
¶
get_count() -> int
Get the number of elements in the visual.
Returns:
Type | Description |
---|---|
int
|
The number of elements. |
set_color
¶
set_color(array: ndarray, offset: int = 0) -> None
Set the color of points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The color array. |
required |
offset
|
int
|
The offset at which to start setting the color, by default 0. |
0
|
set_count
¶
set_count(count: int) -> None
Set the number of elements in the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements. |
required |
set_data
¶
set_data(
depth_test: bool = None, cull: str = None, **kwargs
) -> None
Set data for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
**kwargs
|
Additional data to set. |
{}
|
set_position
¶
set_position(array: ndarray, offset: int = 0) -> None
Set the position of points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The position array. |
required |
offset
|
int
|
The offset at which to start setting the position, by default 0. |
0
|
set_prop_class
¶
set_prop_class(prop_name: str, prop_cls: type) -> None
Set the class for a property.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prop_name
|
str
|
The name of the property. |
required |
prop_cls
|
type
|
The class of the property. |
required |
set_size
¶
set_size(array: ndarray, offset: int = 0) -> None
Set the size of points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The size array, in pixels. |
required |
offset
|
int
|
The offset at which to start setting the size, by default 0. |
0
|
show
¶
show(is_visible: bool = True) -> None
Show or hide the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_visible
|
bool
|
Whether to show the visual, by default True. |
True
|
datoviz.visuals.Marker
¶
Marker(c_visual: DvzVisual, visual_name: str = None)
Bases: Visual
A visual for rendering markers.
Initialize a Visual instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_visual
|
DvzVisual
|
The underlying C visual object. |
required |
visual_name
|
str
|
The name of the visual, by default None. |
None
|
allocate
¶
allocate(count: int) -> None
Allocate memory for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements to allocate. |
required |
clip
¶
clip(clip: str) -> None
Set the clipping mode for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clip
|
str
|
The clipping mode:
- |
required |
fixed
¶
fixed(fixed: Union[bool, str]) -> None
Set whether the visual is fixed along certain axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixed
|
bool or str
|
Use True to fix all x, y, z dimensions, or |
required |
get_count
¶
get_count() -> int
Get the number of elements in the visual.
Returns:
Type | Description |
---|---|
int
|
The number of elements. |
set_angle
¶
set_angle(array: ndarray, offset: int = 0) -> None
Set the angle of the markers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The angle array. |
required |
offset
|
int
|
The offset at which to start setting the angle, by default 0. |
0
|
set_aspect
¶
set_aspect(value: str) -> None
Set the rendering style of the marker.
This controls how the marker uses color, edgecolor, and linewidth.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
One of: - 'filled': fill only (no border) - 'stroke': border only (transparent interior) - 'outline': fill with border |
required |
set_color
¶
set_color(array: ndarray, offset: int = 0) -> None
Set the color of the markers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The color array. |
required |
offset
|
int
|
The offset at which to start setting the color, by default 0. |
0
|
set_count
¶
set_count(count: int) -> None
Set the number of elements in the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements. |
required |
set_data
¶
set_data(
depth_test: bool = None, cull: str = None, **kwargs
) -> None
Set data for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
**kwargs
|
Additional data to set. |
{}
|
set_edgecolor
¶
set_edgecolor(value: tuple) -> None
Set the common edge color of the markers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
tuple
|
The edge color value. |
required |
set_linewidth
¶
set_linewidth(value: float) -> None
Set the common linewidth of the markers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The linewidth value. |
required |
set_mode
¶
set_mode(value: str) -> None
Set the marker mode.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
The mode value:
- |
required |
set_position
¶
set_position(array: ndarray, offset: int = 0) -> None
Set the position of the markers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The position array. |
required |
offset
|
int
|
The offset at which to start setting the position, by default 0. |
0
|
set_prop_class
¶
set_prop_class(prop_name: str, prop_cls: type) -> None
Set the class for a property.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prop_name
|
str
|
The name of the property. |
required |
prop_cls
|
type
|
The class of the property. |
required |
set_shape
¶
set_shape(value: str) -> None
Set the shape of the visual's elements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
The shape value, one of:
- |
required |
set_size
¶
set_size(array: ndarray, offset: int = 0) -> None
Set the size of the markers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The size array. |
required |
offset
|
int
|
The offset at which to start setting the size, by default 0. |
0
|
set_tex_scale
¶
set_tex_scale(value: float) -> None
Set the common texture scale.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The texture scale value. |
required |
set_texture
¶
set_texture(texture: Texture) -> None
Set the texture with the bitmap, SDF, or MSDF data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
texture
|
Texture
|
The texture object. |
required |
show
¶
show(is_visible: bool = True) -> None
Show or hide the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_visible
|
bool
|
Whether to show the visual, by default True. |
True
|
datoviz.visuals.Segment
¶
Segment(c_visual: DvzVisual, visual_name: str = None)
Bases: Visual
A visual for rendering line segments.
Initialize a Visual instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_visual
|
DvzVisual
|
The underlying C visual object. |
required |
visual_name
|
str
|
The name of the visual, by default None. |
None
|
allocate
¶
allocate(count: int) -> None
Allocate memory for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements to allocate. |
required |
clip
¶
clip(clip: str) -> None
Set the clipping mode for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clip
|
str
|
The clipping mode:
- |
required |
fixed
¶
fixed(fixed: Union[bool, str]) -> None
Set whether the visual is fixed along certain axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixed
|
bool or str
|
Use True to fix all x, y, z dimensions, or |
required |
get_count
¶
get_count() -> int
Get the number of elements in the visual.
Returns:
Type | Description |
---|---|
int
|
The number of elements. |
set_cap
¶
set_cap(initial: str, terminal: str = None) -> None
Set the cap of line segments:
round
triangle_in
triangle_out
square
butt
Parameters:
Name | Type | Description | Default |
---|---|---|---|
initial
|
str
|
The initial cap. |
required |
terminal
|
str
|
The terminal cap. |
None
|
set_color
¶
set_color(array: ndarray, offset: int = 0) -> None
Set the color of line segments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The color array. |
required |
offset
|
int
|
The offset at which to start setting the color, by default 0. |
0
|
set_count
¶
set_count(count: int) -> None
Set the number of elements in the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements. |
required |
set_data
¶
set_data(
depth_test: bool = None, cull: str = None, **kwargs
) -> None
Set data for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
**kwargs
|
Additional data to set. |
{}
|
set_linewidth
¶
set_linewidth(array: ndarray, offset: int = 0) -> None
Set the linewidth of line segments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The linewidth array. |
required |
offset
|
int
|
The offset at which to start setting the linewidth, by default 0. |
0
|
set_position
¶
set_position(
initial: ndarray,
terminal: ndarray = None,
offset: int = 0,
) -> None
Set the position of the line segments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
initial
|
ndarray
|
The initial positions. |
required |
terminal
|
ndarray
|
The terminal positions. |
None
|
offset
|
int
|
The offset at which to start setting the position, by default 0. |
0
|
set_prop_class
¶
set_prop_class(prop_name: str, prop_cls: type) -> None
Set the class for a property.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prop_name
|
str
|
The name of the property. |
required |
prop_cls
|
type
|
The class of the property. |
required |
set_shift
¶
set_shift(array: ndarray, offset: int = 0) -> None
Set the pixel shift of line segments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The shift array. |
required |
offset
|
int
|
The offset at which to start setting the shift, by default 0. |
0
|
show
¶
show(is_visible: bool = True) -> None
Show or hide the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_visible
|
bool
|
Whether to show the visual, by default True. |
True
|
datoviz.visuals.Path
¶
Path(c_visual: DvzVisual, visual_name: str = None)
Bases: Visual
A visual for rendering paths.
Initialize a Visual instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_visual
|
DvzVisual
|
The underlying C visual object. |
required |
visual_name
|
str
|
The name of the visual, by default None. |
None
|
allocate
¶
allocate(count: int) -> None
Allocate memory for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements to allocate. |
required |
clip
¶
clip(clip: str) -> None
Set the clipping mode for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clip
|
str
|
The clipping mode:
- |
required |
fixed
¶
fixed(fixed: Union[bool, str]) -> None
Set whether the visual is fixed along certain axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixed
|
bool or str
|
Use True to fix all x, y, z dimensions, or |
required |
get_count
¶
get_count() -> int
Get the number of elements in the visual.
Returns:
Type | Description |
---|---|
int
|
The number of elements. |
set_cap
¶
set_cap(value: str) -> None
Set the common cap style of all paths, one of the following:
round
triangle_in
triangle_out
square
butt
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
The cap style. |
required |
set_color
¶
set_color(array: ndarray, offset: int = 0) -> None
Set the color of the individual points in each path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The color array. |
required |
offset
|
int
|
The offset at which to start setting the color, by default 0. |
0
|
set_count
¶
set_count(count: int) -> None
Set the number of elements in the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements. |
required |
set_data
¶
set_data(
depth_test: bool = None, cull: str = None, **kwargs
) -> None
Set data for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
**kwargs
|
Additional data to set. |
{}
|
set_join
¶
set_join(value: str) -> None
Set the common join style of all paths, one of the following:
square
round
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
The join style. |
required |
set_linewidth
¶
set_linewidth(array: ndarray, offset: int = 0) -> None
Set the linewidth of the individual points in each path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The linewidth array. |
required |
offset
|
int
|
The offset at which to start setting the linewidth, by default 0. |
0
|
set_position
¶
set_position(
position: Union[ndarray, List[ndarray]],
groups: Union[int, ndarray] = 0,
offset: int = 0,
) -> None
Set the position of the paths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position
|
ndarray, or list of ndarray
|
A list of arrays representing the positions of the paths. |
required |
groups
|
int or ndarray
|
The number of uniformly-sized groups, by default 0, or the sizes of each group. |
0
|
offset
|
int
|
The offset at which to start setting the position, by default 0. |
0
|
set_prop_class
¶
set_prop_class(prop_name: str, prop_cls: type) -> None
Set the class for a property.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prop_name
|
str
|
The name of the property. |
required |
prop_cls
|
type
|
The class of the property. |
required |
show
¶
show(is_visible: bool = True) -> None
Show or hide the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_visible
|
bool
|
Whether to show the visual, by default True. |
True
|
datoviz.visuals.Glyph
¶
Glyph(*args, font_size: int = None, **kwargs)
Bases: Visual
A visual for rendering glyphs.
Initialize a Glyph visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args
|
tuple
|
Positional arguments for the parent class |
()
|
font_size
|
int
|
The font size, by default None. |
None
|
kwargs
|
dict
|
Keyword arguments for the parent class |
{}
|
allocate
¶
allocate(count: int) -> None
Allocate memory for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements to allocate. |
required |
clip
¶
clip(clip: str) -> None
Set the clipping mode for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clip
|
str
|
The clipping mode:
- |
required |
fixed
¶
fixed(fixed: Union[bool, str]) -> None
Set whether the visual is fixed along certain axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixed
|
bool or str
|
Use True to fix all x, y, z dimensions, or |
required |
get_count
¶
get_count() -> int
Get the number of elements in the visual.
Returns:
Type | Description |
---|---|
int
|
The number of elements. |
set_anchor
¶
set_anchor(array: ndarray, offset: int = 0) -> None
Set the anchor of each glyph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The anchor array. |
required |
offset
|
int
|
The offset at which to start setting the anchor, by default 0. |
0
|
set_angle
¶
set_angle(array: ndarray, offset: int = 0) -> None
Set the angle of each glyph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The angle array. |
required |
offset
|
int
|
The offset at which to start setting the angle, by default 0. |
0
|
set_axis
¶
set_axis(array: ndarray, offset: int = 0) -> None
Set the 3D rotation axis of the glyphs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The axis array. |
required |
offset
|
int
|
The offset at which to start setting the axis, by default 0. |
0
|
Warnings:
This is not implemented yet.
set_bgcolor
¶
set_bgcolor(value: tuple) -> None
Set the common background color for all glyphs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
tuple
|
The background color value. |
required |
set_color
¶
set_color(array: ndarray, offset: int = 0) -> None
Set the color of each glyph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The color array. |
required |
offset
|
int
|
The offset at which to start setting the color, by default 0. |
0
|
set_count
¶
set_count(count: int) -> None
Set the number of elements in the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements. |
required |
set_data
¶
set_data(
depth_test: bool = None, cull: str = None, **kwargs
) -> None
Set data for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
**kwargs
|
Additional data to set. |
{}
|
set_group_size
¶
set_group_size(array: ndarray, offset: int = 0) -> None
Set the string size of each glyph (the value should be the same across all glyphs of each string).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The group size array. |
required |
offset
|
int
|
The offset at which to start setting the group size, by default 0. |
0
|
set_position
¶
set_position(array: ndarray, offset: int = 0) -> None
Set the position of each glyph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The position array. |
required |
offset
|
int
|
The offset at which to start setting the position, by default 0. |
0
|
set_prop_class
¶
set_prop_class(prop_name: str, prop_cls: type) -> None
Set the class for a property.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prop_name
|
str
|
The name of the property. |
required |
prop_cls
|
type
|
The class of the property. |
required |
set_scale
¶
set_scale(array: ndarray, offset: int = 0) -> None
Set the scale of each glyph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The scale array. |
required |
offset
|
int
|
The offset at which to start setting the scale, by default 0. |
0
|
set_shift
¶
set_shift(array: ndarray, offset: int = 0) -> None
Set the pixel shift of each glyph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The shift array. |
required |
offset
|
int
|
The offset at which to start setting the shift, by default 0. |
0
|
set_size
¶
set_size(array: ndarray, offset: int = 0) -> None
Set the size of each glyph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The size array. |
required |
offset
|
int
|
The offset at which to start setting the size, by default 0. |
0
|
set_strings
¶
set_strings(
strings: List[str],
string_pos: ndarray = None,
scales: ndarray = None,
color: tuple = cst.DEFAULT_GLYPH_COLOR,
anchor: tuple = (0, 0),
offset: tuple = (0, 0),
) -> None
Set the strings to render as glyphs.
This is a helper function to set several strings at different locations and scales but with the same color, anchor, and offset. To use different values for each string, use the other methods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
strings
|
list of str
|
The list of strings to render. |
required |
string_pos
|
ndarray
|
The positions of each string, by default None. |
None
|
scales
|
ndarray
|
The scales of each string, by default None. |
None
|
color
|
tuple
|
The common color of all glyphs, by default cst.DEFAULT_GLYPH_COLOR. |
DEFAULT_GLYPH_COLOR
|
anchor
|
tuple
|
The common anchor point of all strings, by default (0, 0). |
(0, 0)
|
offset
|
tuple
|
The common offset of all strings, by default (0, 0). |
(0, 0)
|
set_texcoords
¶
set_texcoords(array: ndarray, offset: int = 0) -> None
Set the texture coordinates of each glyph (relative to the font atlas texture).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The texture coordinates array. |
required |
offset
|
int
|
The offset at which to start setting the texture coordinates, by default 0. |
0
|
set_texture
¶
set_texture(texture: Texture) -> None
Set the texture with the font atlas.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
texture
|
Texture
|
The texture object. |
required |
show
¶
show(is_visible: bool = True) -> None
Show or hide the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_visible
|
bool
|
Whether to show the visual, by default True. |
True
|
datoviz.visuals.Image
¶
Image(c_visual: DvzVisual, visual_name: str = None)
Bases: Visual
A visual for displaying images.
Initialize a Visual instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_visual
|
DvzVisual
|
The underlying C visual object. |
required |
visual_name
|
str
|
The name of the visual, by default None. |
None
|
allocate
¶
allocate(count: int) -> None
Allocate memory for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements to allocate. |
required |
clip
¶
clip(clip: str) -> None
Set the clipping mode for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clip
|
str
|
The clipping mode:
- |
required |
fixed
¶
fixed(fixed: Union[bool, str]) -> None
Set whether the visual is fixed along certain axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixed
|
bool or str
|
Use True to fix all x, y, z dimensions, or |
required |
get_count
¶
get_count() -> int
Get the number of elements in the visual.
Returns:
Type | Description |
---|---|
int
|
The number of elements. |
set_anchor
¶
set_anchor(array: ndarray, offset: int = 0) -> None
Set the anchor of each image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The anchor array. |
required |
offset
|
int
|
The offset at which to start setting the anchor, by default 0. |
0
|
set_colormap
¶
set_colormap(value: str) -> None
Set the colormap of the image when using the colormap
image mode.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
The colormap value. |
required |
set_count
¶
set_count(count: int) -> None
Set the number of elements in the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements. |
required |
set_data
¶
set_data(
depth_test: bool = None, cull: str = None, **kwargs
) -> None
Set data for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
**kwargs
|
Additional data to set. |
{}
|
set_edgecolor
¶
set_edgecolor(value: tuple) -> None
Set the common edge color of all images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
tuple
|
The edge color value. |
required |
set_facecolor
¶
set_facecolor(array: ndarray, offset: int = 0) -> None
Set the face color of the image (when using a fill mode instead of texture mode).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The face color array. |
required |
offset
|
int
|
The offset at which to start setting the face color, by default 0. |
0
|
set_linewidth
¶
set_linewidth(value: float) -> None
Set the common linewidth of all images when using an image border.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The linewidth value. |
required |
set_permutation
¶
set_permutation(value: tuple) -> None
Set the permutation axes of the image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
tuple
|
The permutation value. |
required |
set_position
¶
set_position(array: ndarray, offset: int = 0) -> None
Set the position of each image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The position array. |
required |
offset
|
int
|
The offset at which to start setting the position, by default 0. |
0
|
set_prop_class
¶
set_prop_class(prop_name: str, prop_cls: type) -> None
Set the class for a property.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prop_name
|
str
|
The name of the property. |
required |
prop_cls
|
type
|
The class of the property. |
required |
set_radius
¶
set_radius(value: float) -> None
Set the common border radius of all images when using an image border.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The radius value. |
required |
set_size
¶
set_size(array: ndarray, offset: int = 0) -> None
Set the pixel size of each image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The size array. |
required |
offset
|
int
|
The offset at which to start setting the size, by default 0. |
0
|
set_texcoords
¶
set_texcoords(array: ndarray, offset: int = 0) -> None
Set the texture coordinates of each image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The texture coordinates array. |
required |
offset
|
int
|
The offset at which to start setting the texture coordinates, by default 0. |
0
|
set_texture
¶
set_texture(texture: Texture) -> None
Set the image texture.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
texture
|
Texture
|
The texture object. |
required |
show
¶
show(is_visible: bool = True) -> None
Show or hide the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_visible
|
bool
|
Whether to show the visual, by default True. |
True
|
datoviz.visuals.Mesh
¶
Mesh(c_visual: DvzVisual, visual_name: str = None)
Bases: Visual
A visual for rendering meshes.
Initialize a Visual instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_visual
|
DvzVisual
|
The underlying C visual object. |
required |
visual_name
|
str
|
The name of the visual, by default None. |
None
|
allocate
¶
allocate(count: int, index_count: int = None) -> None
Allocate memory for the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of vertices to allocate. |
required |
index_count
|
int
|
The number of indices to allocate, by default None. |
None
|
clip
¶
clip(clip: str) -> None
Set the clipping mode for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clip
|
str
|
The clipping mode:
- |
required |
fixed
¶
fixed(fixed: Union[bool, str]) -> None
Set whether the visual is fixed along certain axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixed
|
bool or str
|
Use True to fix all x, y, z dimensions, or |
required |
get_count
¶
get_count() -> int
Get the number of elements in the visual.
Returns:
Type | Description |
---|---|
int
|
The number of elements. |
get_index_count
¶
get_index_count() -> int
Get the number of indices in the mesh.
Returns:
Type | Description |
---|---|
int
|
The number of indices. |
set_color
¶
set_color(array: ndarray, offset: int = 0) -> None
Set the color of the mesh vertices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The color array. |
required |
offset
|
int
|
The offset at which to start setting the color, by default 0. |
0
|
set_count
¶
set_count(count: int, index_count: int = None) -> None
Set the number of vertices and indices in the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of vertices. |
required |
index_count
|
int
|
The number of indices, by default None. |
None
|
set_data
¶
set_data(
vertex_count: int = None,
index_count: int = None,
compute_normals: bool = None,
**kwargs
) -> None
Set data for the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vertex_count
|
int
|
The number of vertices, by default None. |
None
|
index_count
|
int
|
The number of indices, by default None. |
None
|
compute_normals
|
bool
|
Whether to compute normals, by default None. |
None
|
**kwargs
|
Additional data to set. |
{}
|
set_density
¶
set_density(value: int) -> None
Set the density of the isolines, if showing isolines.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
int
|
The density value. |
required |
set_edgecolor
¶
set_edgecolor(value: tuple) -> None
Set the edge color of the contour, if showing a contour.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
tuple
|
The edge color value. |
required |
set_emit
¶
set_emit(value: float) -> None
Set the surface emission level.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The emit value. |
required |
set_index
¶
set_index(array: ndarray, offset: int = 0) -> None
Set the indices of the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The indices array. |
required |
offset
|
int
|
The offset at which to start setting the indices, by default 0. |
0
|
set_isoline
¶
set_isoline(array: ndarray, offset: int = 0) -> None
Set the isolines of the mesh vertices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The isolines array. |
required |
offset
|
int
|
The offset at which to start setting the isolines, by default 0. |
0
|
set_light_color
¶
set_light_color(value: tuple, idx: int = 0) -> None
Set the color of the light.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
tuple
|
The light color value. |
required |
idx
|
int
|
The index of the light, by default 0. |
0
|
set_light_pos
¶
set_light_pos(value: tuple, idx: int = 0) -> None
Set the direction of the light.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
tuple
|
The light direction value. |
required |
idx
|
int
|
The index of the light, by default 0. |
0
|
set_linewidth
¶
set_linewidth(value: float) -> None
Set the line width of the contour, if showing a contour.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The linewidth value. |
required |
set_material_params
¶
set_material_params(value: tuple, idx: int = 0) -> None
Set the parameters of the material.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
tuple
|
The material light parameters (r, g, b). |
required |
idx
|
int
|
The index of the material, by default 0. (0 ambient, 1 diffuse, 2 specular, 3 emission) |
0
|
set_normal
¶
set_normal(array: ndarray, offset: int = 0) -> None
Set the normals of the mesh vertices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The normals array. |
required |
offset
|
int
|
The offset at which to start setting the normals, by default 0. |
0
|
set_position
¶
set_position(array: ndarray, offset: int = 0) -> None
Set the position of the mesh vertices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The position array. |
required |
offset
|
int
|
The offset at which to start setting the position, by default 0. |
0
|
set_prop_class
¶
set_prop_class(prop_name: str, prop_cls: type) -> None
Set the class for a property.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prop_name
|
str
|
The name of the property. |
required |
prop_cls
|
type
|
The class of the property. |
required |
set_shine
¶
set_shine(value: float) -> None
Set the surface shininess.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The shine value. |
required |
set_texcoords
¶
set_texcoords(array: ndarray, offset: int = 0) -> None
Set the texture coordinates of the mesh vertices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The texture coordinates array. |
required |
offset
|
int
|
The offset at which to start setting the texture coordinates, by default 0. |
0
|
set_texture
¶
set_texture(texture: Texture) -> None
Set the mesh texture.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
texture
|
Texture
|
The texture object. |
required |
show
¶
show(is_visible: bool = True) -> None
Show or hide the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_visible
|
bool
|
Whether to show the visual, by default True. |
True
|
datoviz.visuals.Sphere
¶
Sphere(c_visual: DvzVisual, visual_name: str = None)
Bases: Visual
A visual for rendering spheres.
Initialize a Visual instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_visual
|
DvzVisual
|
The underlying C visual object. |
required |
visual_name
|
str
|
The name of the visual, by default None. |
None
|
allocate
¶
allocate(count: int) -> None
Allocate memory for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements to allocate. |
required |
clip
¶
clip(clip: str) -> None
Set the clipping mode for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clip
|
str
|
The clipping mode:
- |
required |
fixed
¶
fixed(fixed: Union[bool, str]) -> None
Set whether the visual is fixed along certain axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixed
|
bool or str
|
Use True to fix all x, y, z dimensions, or |
required |
get_count
¶
get_count() -> int
Get the number of elements in the visual.
Returns:
Type | Description |
---|---|
int
|
The number of elements. |
set_color
¶
set_color(array: ndarray, offset: int = 0) -> None
Set the color of the spheres.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The color array. |
required |
offset
|
int
|
The offset at which to start setting the color, by default 0. |
0
|
set_count
¶
set_count(count: int) -> None
Set the number of elements in the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements. |
required |
set_data
¶
set_data(
depth_test: bool = None, cull: str = None, **kwargs
) -> None
Set data for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
**kwargs
|
Additional data to set. |
{}
|
set_emit
¶
set_emit(value) -> None
Set the size of the spheres.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The amount of surface light emission. |
required |
set_light_color
¶
set_light_color(value: tuple, idx: int = 0) -> None
Set the color of the light idx.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
tuple
|
The light color value. |
required |
idx
|
int
|
The index of the light, by default 0. |
0
|
set_light_pos
¶
set_light_pos(value: tuple, idx: int = 0) -> None
Set the position of light idx.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
tuple
|
The light position value. |
required |
idx
|
int
|
The index of the light, by default 0. |
0
|
set_position
¶
set_position(array: ndarray, offset: int = 0) -> None
Set the position of the spheres.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The position array. |
required |
offset
|
int
|
The offset at which to start setting the position, by default 0. |
0
|
set_prop_class
¶
set_prop_class(prop_name: str, prop_cls: type) -> None
Set the class for a property.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prop_name
|
str
|
The name of the property. |
required |
prop_cls
|
type
|
The class of the property. |
required |
set_shine
¶
set_shine(value) -> None
Set the size of the spheres.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The amount of surface shininess. |
required |
set_size
¶
set_size(array: ndarray, offset: int = 0) -> None
Set the size of the spheres.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The size array. |
required |
offset
|
int
|
The offset at which to start setting the size, by default 0. |
0
|
show
¶
show(is_visible: bool = True) -> None
Show or hide the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_visible
|
bool
|
Whether to show the visual, by default True. |
True
|
datoviz.visuals.Volume
¶
Volume(c_visual: DvzVisual, visual_name: str = None)
Bases: Visual
A visual for rendering volumetric data.
Initialize a Visual instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_visual
|
DvzVisual
|
The underlying C visual object. |
required |
visual_name
|
str
|
The name of the visual, by default None. |
None
|
allocate
¶
allocate(count: int) -> None
Allocate memory for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements to allocate. |
required |
clip
¶
clip(clip: str) -> None
Set the clipping mode for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clip
|
str
|
The clipping mode:
- |
required |
fixed
¶
fixed(fixed: Union[bool, str]) -> None
Set whether the visual is fixed along certain axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixed
|
bool or str
|
Use True to fix all x, y, z dimensions, or |
required |
get_count
¶
get_count() -> int
Get the number of elements in the visual.
Returns:
Type | Description |
---|---|
int
|
The number of elements. |
set_bounds
¶
set_bounds(
xlim: tuple, ylim: tuple = None, zlim: tuple = None
) -> None
Set the bounds of the volume.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xlim
|
tuple
|
The x-axis bounds. |
required |
ylim
|
tuple
|
The y-axis bounds. |
None
|
zlim
|
tuple
|
The z-axis bounds. |
None
|
set_count
¶
set_count(count: int) -> None
Set the number of elements in the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements. |
required |
set_data
¶
set_data(
depth_test: bool = None, cull: str = None, **kwargs
) -> None
Set data for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
**kwargs
|
Additional data to set. |
{}
|
set_permutation
¶
set_permutation(value: tuple) -> None
Set the axis permutation of the volume 3D array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
tuple
|
The permutation of the axes, by default (0, 1, 2) (corresponding to u, v, w). |
required |
set_prop_class
¶
set_prop_class(prop_name: str, prop_cls: type) -> None
Set the class for a property.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prop_name
|
str
|
The name of the property. |
required |
prop_cls
|
type
|
The class of the property. |
required |
set_slice
¶
set_slice(value: int) -> None
Set the slice index for the volume.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
int
|
The slice index. |
required |
Warnings:
This is not implemented yet.
set_texcoords
¶
set_texcoords(uvw0: tuple, uvw1: tuple) -> None
Set the texture coordinates of the volume.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uvw0
|
tuple
|
The texture coordinates of the point |
required |
uvw1
|
tuple
|
The texture coordinates of the point |
required |
set_texture
¶
set_texture(texture: Texture) -> None
Set the texture for the volume.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
texture
|
Texture
|
The texture object. |
required |
set_transfer
¶
set_transfer(value: tuple) -> None
Set the transfer function for the volume.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
tuple
|
The transfer function parameters. |
required |
show
¶
show(is_visible: bool = True) -> None
Show or hide the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_visible
|
bool
|
Whether to show the visual, by default True. |
True
|
datoviz.visuals.Slice
¶
Slice(c_visual: DvzVisual, visual_name: str = None)
Bases: Visual
A visual for rendering 2D slices of volumetric data.
Initialize a Visual instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
c_visual
|
DvzVisual
|
The underlying C visual object. |
required |
visual_name
|
str
|
The name of the visual, by default None. |
None
|
allocate
¶
allocate(count: int) -> None
Allocate memory for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements to allocate. |
required |
clip
¶
clip(clip: str) -> None
Set the clipping mode for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
clip
|
str
|
The clipping mode:
- |
required |
fixed
¶
fixed(fixed: Union[bool, str]) -> None
Set whether the visual is fixed along certain axes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixed
|
bool or str
|
Use True to fix all x, y, z dimensions, or |
required |
get_count
¶
get_count() -> int
Get the number of elements in the visual.
Returns:
Type | Description |
---|---|
int
|
The number of elements. |
set_alpha
¶
set_alpha(value: float) -> None
Set the alpha transparency of the slice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float
|
The alpha transparency value. |
required |
set_count
¶
set_count(count: int) -> None
Set the number of elements in the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
count
|
int
|
The number of elements. |
required |
set_data
¶
set_data(
depth_test: bool = None, cull: str = None, **kwargs
) -> None
Set data for the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
depth_test
|
bool
|
Whether to enable depth testing. |
None
|
cull
|
str
|
The culling mode, |
None
|
**kwargs
|
Additional data to set. |
{}
|
set_position
¶
set_position(array: ndarray, offset: int = 0) -> None
Set the position of the slice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The position array. |
required |
offset
|
int
|
The offset at which to start setting the position, by default 0. |
0
|
set_prop_class
¶
set_prop_class(prop_name: str, prop_cls: type) -> None
Set the class for a property.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prop_name
|
str
|
The name of the property. |
required |
prop_cls
|
type
|
The class of the property. |
required |
set_texcoords
¶
set_texcoords(array: ndarray, offset: int = 0) -> None
Set the texture coordinates of the slice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
The texture coordinates array. |
required |
offset
|
int
|
The offset at which to start setting the texture coordinates, by default 0. |
0
|
set_texture
¶
set_texture(texture: Texture) -> None
Set the texture for the slice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
texture
|
Texture
|
The texture object. |
required |
show
¶
show(is_visible: bool = True) -> None
Show or hide the visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_visible
|
bool
|
Whether to show the visual, by default True. |
True
|
Utils¶
datoviz.utils
¶
Copyright (c) 2021 Cyrille Rossant and contributors. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for details. SPDX-License-Identifier: MIT
array_pointer
¶
array_pointer(
x: ndarray, dtype: dtype = None
) -> ctypes.POINTER
Convert a NumPy array to a C pointer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
ndarray
|
The NumPy array to convert. |
required |
dtype
|
dtype
|
The desired data type, by default None. |
None
|
Returns:
Type | Description |
---|---|
POINTER
|
A C pointer to the array data. |
button_name
¶
button_name(button: int) -> str
Get the name of a mouse button from its button code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
button
|
int
|
The button code. |
required |
Returns:
Type | Description |
---|---|
str
|
The name of the mouse button. |
char_pointer
¶
char_pointer(s: Union[str, List[str]]) -> ctypes.POINTER
Convert a string or list of strings to a C char pointer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s
|
str or list of str
|
The string or list of strings to convert. |
required |
Returns:
Type | Description |
---|---|
POINTER
|
A C char pointer. |
cmap
¶
cmap(
cm: Union[str, int],
values: ndarray,
vmin: float = 0.0,
vmax: float = 1.0,
) -> np.ndarray
Apply a colormap to an array of values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cm
|
str or int
|
The colormap identifier, either as a string name or an integer. |
required |
values
|
ndarray
|
The array of values to map. |
required |
vmin
|
float
|
The minimum value for normalization, by default 0.0. |
0.0
|
vmax
|
float
|
The maximum value for normalization, by default 1.0. |
1.0
|
Returns:
Type | Description |
---|---|
ndarray
|
An array of RGBA colors. |
dtype_to_format
¶
dtype_to_format(dtype: str, n_channels: int) -> int
Get the format identifier for a given data type and number of channels.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dtype
|
str
|
The data type. |
required |
n_channels
|
int
|
The number of channels. |
required |
Returns:
Type | Description |
---|---|
int
|
The format identifier. |
from_enum
¶
from_enum(
enum_cls: type, value: int, prettify: bool = True
) -> Optional[str]
Convert an enum value to its string representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
enum_cls
|
type
|
The enum class. |
required |
value
|
int
|
The enum value. |
required |
prettify
|
bool
|
Whether to prettify the string representation, by default True. |
True
|
Returns:
Type | Description |
---|---|
str or None
|
The string representation of the enum value, or None if not found. |
get_fixed_params
¶
get_fixed_params(
fixed: Union[bool, str],
) -> Tuple[bool, bool, bool]
Get the fixed parameters for a visual on all three dimensions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fixed
|
bool or str
|
The fixed parameters. |
required |
Returns:
Type | Description |
---|---|
tuple of bool
|
A tuple indicating whether each axis is fixed. |
get_size
¶
get_size(
idx: Union[slice, int],
value: ndarray,
total_size: int = 0,
) -> int
Get the size of a slice or array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
slice or int
|
The slice or index. |
required |
value
|
ndarray
|
The array. |
required |
total_size
|
int
|
The total size of the array, by default 0. |
0
|
Returns:
Type | Description |
---|---|
int
|
The size of the slice or array. |
get_version
¶
get_version() -> Dict[str, str]
Get the version information for the library.
Returns:
Type | Description |
---|---|
dict of str
|
A dictionary containing the version of the ctypes wrapper and the Datoviz library. |
image_flags
¶
image_flags(
unit: str = None,
mode: str = None,
rescale: str = None,
border: bool = None,
) -> int
Compute the image flags for rendering based on the provided options.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unit
|
str
|
Specifies the unit for the image size. Can be:
- |
None
|
mode
|
str
|
Specifies the image mode. Can be:
- |
None
|
rescale
|
str
|
Specifies how the image should be rescaled with transformations. Can be:
- |
None
|
border
|
bool
|
Indicates whether to display a border around the image. Defaults to |
None
|
Returns:
Type | Description |
---|---|
int
|
The computed image flags as an integer bitmask. |
key_name
¶
key_name(key_code: int) -> str
Get the name of a key from its key code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key_code
|
int
|
The key code. |
required |
Returns:
Type | Description |
---|---|
str
|
The name of the key. |
mesh_flags
¶
mesh_flags(
indexed: bool = None,
textured: bool = None,
lighting: bool = None,
contour: bool = None,
isoline: bool = None,
) -> int
Compute the C mesh flags based on the given options.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indexed
|
bool
|
Whether the mesh is indexed. |
None
|
textured
|
bool
|
Whether to use a texture for the mesh. |
None
|
lighting
|
bool
|
Whether lighting is enabled. |
None
|
contour
|
bool
|
Whether contour is enabled. |
None
|
isoline
|
bool
|
Whether to show isolines. |
None
|
Returns:
Type | Description |
---|---|
int
|
The computed mesh flags. |
pointer_array
¶
pointer_array(
pointer: POINTER,
length: int,
n_components: int,
dtype: dtype = np.float32,
) -> np.ndarray
Convert a C pointer to a NumPy array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pointer
|
POINTER
|
The C pointer to convert. |
required |
length
|
int
|
The length of the array. |
required |
n_components
|
int
|
The number of components per element. |
required |
dtype
|
dtype
|
The desired data type, by default np.float32. |
float32
|
Returns:
Type | Description |
---|---|
ndarray
|
The resulting NumPy array. |
pointer_image
¶
pointer_image(
rgb: POINTER,
width: int,
height: int,
n_channels: int = 3,
) -> np.ndarray
Convert a C pointer to an image buffer into a NumPy array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rgb
|
POINTER
|
The C pointer to the image buffer. |
required |
width
|
int
|
The width of the image. |
required |
height
|
int
|
The height of the image. |
required |
n_channels
|
int
|
The number of channels in the image, by default 3. |
3
|
Returns:
Type | Description |
---|---|
ndarray
|
A NumPy array representing the image. |
prepare_data_array
¶
prepare_data_array(
name: str,
dtype: str,
shape: Tuple[int, ...],
value: ndarray,
) -> np.ndarray
Prepare a data array for use in a visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the property. |
required |
dtype
|
str
|
The data type of the array. |
required |
shape
|
tuple of int
|
The expected shape of the array. |
required |
value
|
ndarray
|
The array to prepare. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The prepared array. |
Raises:
Type | Description |
---|---|
ValueError
|
If the array shape is incorrect. |
prepare_data_scalar
¶
prepare_data_scalar(
name: str, dtype: str, size: int, value: float
) -> np.ndarray
Prepare a scalar value for use in a visual.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the property. |
required |
dtype
|
str
|
The data type of the scalar. |
required |
size
|
int
|
The size of the array to create. |
required |
value
|
float
|
The scalar value. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
An array filled with the scalar value. |
Raises:
Type | Description |
---|---|
ValueError
|
If the size is zero. |
sphere_flags
¶
sphere_flags(
textured: bool = None,
lighting: bool = None,
size_pixels: bool = None,
) -> int
Compute the C mesh flags based on the given options.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
textured
|
bool
|
Whether to use a texture for the sphere. |
None
|
lighting
|
bool
|
Whether lighting is enabled. |
None
|
size_pixels
|
bool
|
Whether to specify the sphere size in pixels rather than NDC. |
None
|
Returns:
Type | Description |
---|---|
int
|
The computed sphere flags. |
to_byte
¶
to_byte(
arr: ndarray, vmin: float = None, vmax: float = None
) -> np.ndarray
Normalize an array to the range [0, 255] and convert to uint8.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arr
|
ndarray
|
The array to normalize. |
required |
vmin
|
float
|
The minimum value for normalization, by default None. |
None
|
vmax
|
float
|
The maximum value for normalization, by default None. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
The normalized array as uint8. |
to_enum
¶
to_enum(enumstr: Union[str, int]) -> int
Convert an enum string to its corresponding value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
enumstr
|
str or int
|
The enum string or value (no-op). |
required |
Returns:
Type | Description |
---|---|
int
|
The enum value. |