fibomat.beam_simulation.fibcanvas module#

class fibomat.beam_simulation.fibcanvas.FIBCanvas(dwell_points: ndarray, length_unit: str, on_timer_callback: Callable)[source]#

Bases: Canvas

__init__(dwell_points: ndarray, length_unit: str, on_timer_callback: Callable)[source]#
on_resize(event)[source]#
on_draw(event)[source]#
on_timer(event)[source]#
start_animation()[source]#
stop_animation()[source]#
reset_animation()[source]#
set_speed(speed)[source]#
set_tail_length(length)[source]#
set_alpha(alpha)[source]#
property number_of_points: int#
property app#

The vispy Application instance on which this Canvas is based.

close()#

Close the canvas

Notes#

This will usually destroy the GL context. For Qt, the context (and widget) will be destroyed only if the widget is top-level. To avoid having the widget destroyed (more like standard Qt behavior), consider making the widget a sub-widget.

connect(fun)#

Connect a function to an event

The name of the function should be on_X, with X the name of the event (e.g. ‘on_draw’).

This method is typically used as a decorator on a function definition for an event handler.

Parameters#

funcallable

The function.

property context#

The OpenGL context of the native widget

It gives access to OpenGL functions to call on this canvas object, and to the shared context namespace.

create_native()#

Create the native widget if not already done so. If the widget is already created, this function does nothing.

property dpi#

The physical resolution of the canvas in dots per inch.

property fps#

The fps of canvas/window, as the rate that events.draw is emitted.

property fullscreen#
measure_fps(window=1, callback='%1.1f FPS')#

Measure the current FPS

Sets the update window, connects the draw event to update_fps and sets the callback function.

Parameters#

windowfloat

The time-window (in seconds) to calculate FPS. Default 1.0.

callbackfunction | str

The function to call with the float FPS value, or the string to be formatted with the fps value and then printed. The default is '%1.1f FPS'. If callback evaluates to False, the FPS measurement is stopped.

property native#

The native widget object on which this Canvas is based.

property physical_size#

The physical size of the canvas/window, which may differ from the size property on backends that expose HiDPI.

property pixel_scale#

The ratio between the number of logical pixels, or ‘points’, and the physical pixels on the device. In most cases this will be 1.0, but on certain backends this will be greater than 1. This should be used as a scaling factor when writing your own visualisations with gloo (make a copy and multiply all your logical pixel values by it). When writing Visuals or SceneGraph visualisations, this value is exposed as TransformSystem.px_scale.

property position#

The position of canvas/window relative to screen.

render(alpha=True)#

Render the canvas to an offscreen buffer and return the image array.

Parameters#

alphabool

If True (default) produce an RGBA array (M, N, 4). If False, remove the Alpha channel and return the RGB array (M, N, 3). This may be useful if blending of various elements requires a solid background to produce the expected visualization.

Returns#

imagearray

Numpy array of type ubyte and shape (h, w, 4). Index [0, 0] is the upper-left corner of the rendered region. If alpha is False, then only 3 channels will be returned (RGB).

set_current(event=None)#

Make this the active GL canvas

Parameters#

eventNone

Not used.

show(visible=True, run=False)#

Show or hide the canvas

Parameters#

visiblebool

Make the canvas visible.

runbool

Run the backend event loop.

property size#

The size of canvas/window.

swap_buffers(event=None)#

Swap GL buffers such that the offscreen buffer becomes visible

Parameters#

eventNone

Not used.

property title#

The title of canvas/window.

update(event=None)#

Inform the backend that the Canvas needs to be redrawn

Parameters#

eventNone

Not used.

property current_point_index: int#