scivianna.panel package

Scivianna Panel Module

The panel module provides the core visualization panel classes that display and interact with simulation data. Panels are the primary user interface for visualizing 1D and 2D data in Scivianna.

Files

File

Description

__init__.py

Package initialization file

visualisation_panel.py

Base class VisualizationPanel for all panel types

panel_1d.py

1D plot panel for line charts and time series

panel_2d.py

2D plot panel for geometry visualization

gui.py

GUI manager for panel controls and sidebars

demo.py

Demonstrator application with example panels

VisualizationPanel Class

The VisualizationPanel is the base class for all visualization panels:

Attributes

Attribute

Type

Description

panel_name

str

Name identifier for the panel

slave

ComputeSlave

Data slave providing geometry and field data

plotter

Plotter2D

2D plotting backend (Bokeh/Matplotlib)

main_frame

pmui.Container

Main display container

extensions

List[Extension]

Attached extension components

figure

Overlay

Figure with overlay controls

current_data

DataContainer

Currently displayed data

update_event

UpdateEvent

Event triggering panel updates

sync_field

bool

Whether to sync fields with other panels

Key Methods

Method

Purpose

recompute()

Refresh the panel display

get_slave()

Return the data slave

duplicate()

Create a copy of the panel

set_field(field_name)

Change displayed field

set_colormap(colormap)

Change color map

outline_color(color)

Set border color

provide_on_clic_callback(fn)

Register click handler

provide_on_mouse_move_callback(fn)

Register mouse move handler

recompute_at(position, cell_id)

Trigger recompute at location

Panel Types

Panel1D

Displays one-dimensional data:

  • Line charts

  • Time series plots

Panel2D

Displays two-dimensional geometries:

  • Mesh visualizations

  • Field color maps

  • Polygon-based displays

GUI Integration

Each panel includes a GUI manager (gui.py) that handles:

  • Extension buttons and sidebars

  • Drawer navigation

  • Active extension tracking

  • Button visibility management

Usage Example

from scivianna.panel.panel_2d import Panel2D
from scivianna.slave import ComputeSlave
from scivianna.interface.med_interface import MEDInterface

# Create slave with interface
slave = ComputeSlave(MEDInterface)
slave.read_file("result.med")

# Create panel with extensions
panel = VisualizationPanel(
    slave=slave,
    name="Temperature View",
    extensions=[FieldSelector, LayoutExtension]
)

# Display the panel
panel.show()

Event Handling

Panels respond to user interactions:

  • Mouse click: Trigger on_mouse_clic callbacks

  • Mouse hover: Trigger on_mouse_move callbacks

  • Field change: Update all synced panels

Serialization

Panels can be serialized for save/load:

# Save panel state
state = panel.to_json()

# Restore panel
restored_panel = Panel2D.from_json(state, data_container)

Submodules

scivianna.panel.demo module

scivianna.panel.gui module

class scivianna.panel.gui.GUI(extensions: List[Extension])

Bases: object

Class defining the panels sidebar and managing the extensions

add_extension(extension: Extension)

Adds an Extension instance to the GUI

Parameters:

extension (Extension) – Extension to add to the GUI

change_drawer(_, extension: Tuple[IconButton, Column])

Open the drawer and set the active extension

Parameters:
  • _ (_type_) – Bokeh event

  • extension (Tuple[pmui.IconButton, pn.Column]) – Extension to set active

make_panel() Row

Builds the panel viewable of the GUI

Returns:

GUI panel object

Return type:

pn.Row

open_close_drawer(_)

Toggle drawer open

Parameters:

_ (Any) – Bokeh even

register_new_extension(button: IconButton, col: Column)

Register a button and its associated column to the GUI

Parameters:
  • button (pmui.IconButton) – Extension button

  • col (pn.Column) – Extension toolbar column

update_colors()

Update the GUI extension buttons colors: if the sidebar is open, color the active extension in purple.

scivianna.panel.panel_1d module

class scivianna.panel.panel_1d.Panel1D(slave: ~scivianna.slave.ComputeSlave, name: str = '', extensions: ~typing.List[~scivianna.extension.extension.Extension] = [<class 'scivianna.extension.line_selector.LineSelector'>])

Bases: VisualizationPanel

Visualisation panel associated to a code.

async_update_data()

Update the figures and buttons based on what was added in self.__new_data. This function is called between two servers ticks to prevent multi-users collisions.

cell_id: str = None

cell ID where request the plot

duplicate(keep_name: bool = False) Panel1D

Get a copy of the panel. A panel of the same type is generated, the current display too, but a new slave process is created.

Parameters:

keep_name (bool) – New panel name is the same as the current, if not, a number iterates at the end of the name

Returns:

Copy of the visualisation panel

Return type:

VisualizationPanel

field_change_callback: Callable

Function to call when the field is changed

classmethod from_json(info_dict: Dict, slave: ComputeSlave, extensions: List[Extension] | List[Tuple[Type[Extension], dict]] = []) Panel1D

Restores the visualization panel from its information dict

Parameters:
  • info_dict (Dict) – Dictionnary containing all required information to restore the panel

  • slave (ComputeSlave) – Panel associated slave

  • extensions (Union[List[Extension], List[Tuple[Type[Extension], dict]]]) – GUI extensions, can be extension classes or tuples of (class, state_dict)

Returns:

Restored panel

Return type:

Panel1D

get_slave()

Returns the current panel code slave

Returns:

Panel slave

Return type:

ComputeSlave

name = 'Panel1D'
plotter: Plotter1D

1D plotter displaying and updating the graph

position: Tuple[float, float, float] = None

Position where request the plot

provide_field_change_callback(callback: Callable)

Stores a function to call everytime the displayed field is changed. the functions takes a string as argument.

Parameters:

callback (Callable) – Function to call.

provide_on_clic_callback(callback: Callable)

Stores a function to call everytime the user clics on the plot. Functions arguments are location, cell_id.

Parameters:

callback (Callable) – Function to call.

provide_on_mouse_move_callback(callback: Callable)

Stores a function to call everytime the user moves the mouse on the plot. Functions arguments are location, cell_id.

Parameters:

callback (Callable) – Function to call.

recompute(*args, **kwargs)

Recomputes the figure based on the new bounds and parameters.

Parameters:

event (Any) – Event to make the function linkable to a button

recompute_at(position: Tuple[float, float, float], cell_id: str)

Triggers a panel recomputation at the provided location. Called by layout update event.

Parameters:
  • position (Tuple[float, float, float]) – Location to provide to the slave

  • cell_id (str) – cell id to provide to the slave

set_colormap(colormap)

Sets the current color map, not used in the case of a Panel1D

Parameters:

colormap (str) – Color map name

set_field(field_names: List[str])

Updates the plotted fields

Parameters:
  • field_name (List[str]) – Fields to display

  • allow_wrong_name (bool) – Accept a wrong field (nothing happens)

to_json() Dict

Returns a dictionnary with the information required to rebuild the visualization panel

Returns:

Information dict

Return type:

Dict

update_event: UpdateEvent | List[UpdateEvent] = 0

On what event does the panel recompute itself

scivianna.panel.panel_2d module

class scivianna.panel.panel_2d.Panel2D(slave: ~scivianna.slave.ComputeSlave, name='', display_polygons: bool = True, extensions: ~typing.List[~scivianna.extension.extension.Extension] = [<class 'scivianna.extension.file_loader.FileLoader'>, <class 'scivianna.extension.field_selector.FieldSelector'>, <class 'scivianna.extension.axes.Axes'>], data: ~scivianna.data.data2d.Data2D = None, displayed_field: str = 'Mesh', colormap: str = 'BuRd', u: ~typing.Tuple[float, float, float] = (1.0, 0.0, 0.0), v: ~typing.Tuple[float, float, float] = (0.0, 1.0, 0.0), u_range: ~typing.Tuple[float, float] = (0.0, 1.0), v_range: ~typing.Tuple[float, float] = (0.0, 1.0), w_value: float = 0.5)

Bases: VisualizationPanel

2D Visualisation panel associated to a code.

async_update_data()

Update the figures and buttons based on what was added in self.__new_data. This function is called between two servers ticks to prevent multi-users collisions.

colormap = ''
compute_fn(u: Tuple[float, float, float], v: Tuple[float, float, float], x0: float, y0: float, x1: float, y1: float, z: float) Data2D

Request the slave to compute a new frame, and updates the data to display

Parameters:
  • u (Tuple[float, float, float]) – Direction vector along the horizontal axis

  • v (Tuple[float, float, float]) – Direction vector along the vertical axis

  • x0 (float) – Lower bound value along the u axis

  • y0 (float) – Lower bound value along the v axis

  • x1 (float) – Upper bound value along the u axis

  • y1 (float) – Upper bound value along the v axis

  • z (float) – Value along the u ^ v axis

Returns:

Geometry data.

Return type:

Data2D

current_data: Data2D

Displayed data and their properties.

duplicate(keep_name: bool = False) VisualizationPanel

Get a copy of the panel. A panel of the same type is generated, the current display too, but a new slave process is created.

Parameters:

keep_name (bool) – New panel name is the same as the current, if not, a number iterates at the end of the name

Returns:

Copy of the visualisation panel

Return type:

VisualizationPanel

field_change_callback: Callable

Function to call when the field is changed

classmethod from_json(info_dict: Dict, slave: ComputeSlave, data: Data2D, extensions: List[Extension] | List[Tuple[Type[Extension], dict]] = []) Panel2D

Restores the visualization panel from its information dict

Parameters:
  • info_dict (Dict) – Dictionnary containing all required information to restore the panel

  • slave (ComputeSlave) – Panel associated slave

  • data (Data2D) – Initial state Data2D

  • extensions (Union[List[Extension], List[Tuple[Type[Extension], dict]]]) – GUI extensions, can be extension classes or tuples of (class, state_dict)

Returns:

Restored panel

Return type:

Panel2D

get_slave() ComputeSlave

Returns the current panel code slave

Returns:

Panel slave

Return type:

ComputeSlave

get_uv() Tuple[ndarray, ndarray]

Gets the normal direction vectors from the FloatInput objects.

Returns:

Vectors U, V

Return type:

Tuple[np.ndarray, np.ndarray]

name = 'Panel2D'
plotter: Plotter2D

2D plotter displaying and updating the graph

provide_field_change_callback(callback: Callable)

Stores a function to call everytime the displayed field is changed. the functions takes a string as argument.

Parameters:

callback (Callable) – Function to call.

provide_on_clic_callback(callback: Callable)

Stores a function to call everytime the user clics on the plot. Functions arguments are location, cell_id.

Parameters:

callback (Callable) – Function to call.

provide_on_mouse_move_callback(callback: Callable)

Stores a function to call everytime the user moves the mouse on the plot. Functions arguments are location, cell_id.

Parameters:

callback (Callable) – Function to call.

ranges_callback(x0: float, x1: float, y0: float, y1: float)

Updates the bounds FloatInput based on the current frame zoom.

Parameters:
  • x0 (float) – Horizontal axis minimum value

  • x1 (float) – Horizontal axis maximum value

  • y0 (float) – Vertical axis minimum value

  • y1 (float) – Vertical axis maximum value

recompute(*args, **kwargs)

Recomputes the figure based on the new bounds and parameters.

recompute_at(position: Tuple[float, float, float], cell_id: str)

Triggers a panel recomputation at the provided location. Called by layout update event.

Parameters:
  • position (Tuple[float, float, float]) – Location to provide to the slave

  • cell_id (str) – cell id to provide to the slave

set_colormap(colormap: str)

Sets the current color map

Parameters:

colormap (str) – Color map name

set_coordinates(u: Tuple[float, float, float] = None, v: Tuple[float, float, float] = None, u_min: float = None, u_max: float = None, v_min: float = None, v_max: float = None, w: float = None)

Updates the plot coordinates

Parameters:
  • u (Tuple[float, float, float], optional) – Horizontal axis direction vector, by default None

  • v (Tuple[float, float, float], optional) – Vertical axis direction vector, by default None

  • u_min (float, optional) – Horizontal axis minimum coordinate, by default None

  • u_max (float, optional) – Horizontal axis maximum coordinate, by default None

  • v_min (float, optional) – Vertical axis minimum coordinate, by default None

  • v_max (float, optional) – Vertical axis maximum coordinate, by default None

  • w (float, optional) – Normal axis location, by default None

set_field(field_name: str)

Updates the plotted field

Parameters:

field_name (str) – New field to display

to_json() Dict

Returns a dictionnary with the information required to rebuild the visualization panel

Returns:

Information dict

Return type:

Dict

update_polygons

Need to update the data at the next async call

scivianna.panel.visualisation_panel module

class scivianna.panel.visualisation_panel.VisualizationPanel(slave: ComputeSlave, name='', extensions: List[Extension] | List[Tuple[Type[Extension], dict]] = [])

Bases: Viewer

Visualisation panel associated to a code.

current_data: DataContainer

Displayed data and their properties.

duplicate(keep_name: bool = False) VisualizationPanel

Get a copy of the panel. A panel of the same type is generated, the current display too, but a new slave process is created.

Parameters:

keep_name (bool) – New panel name is the same as the current, if not, a number iterates at the end of the name

Returns:

Copy of the visualisation panel

Return type:

VisualizationPanel

extensions: List[Extension]

List of extensions attached to the panel

field_change_callback: Callable

Function to call when the field is changed

figure: Overlay

Figure in its overlay

classmethod from_json(info_dict: Dict, data: DataContainer) VisualizationPanel

Restores the visualization panel from its information dict

Parameters:

info_dict (Dict) – Dictionnary containing all required information to restore the panel

Returns:

Dict defined visualization panel

Return type:

VisualizationPanel

get_new_name() str

Returns an new name iterating on the current one

Returns:

Name different from current name

Return type:

str

get_slave() ComputeSlave

Returns the current panel code slave

Returns:

Panel slave

Return type:

ComputeSlave

main_frame: Container

Main frame displaying the geometry.

marked_to_recompute

Recompute requested by a coordinates/field change on API side

name = 'VisualizationPanel'
outline_color(color: str = 'lightgray')

Sets the color of the outlined plot

Parameters:

color (str) – HTML color

panel_coupling_extension: Extension
panel_name: str

Panel name

periodic_recompute_added

Coupling periodic update

plotter: Plotter2D

2D plotter displaying and updating the graph

provide_field_change_callback(callback: Callable)

Stores a function to call everytime the displayed field is changed. the functions takes a string as argument.

Parameters:

callback (Callable) – Function to call.

provide_on_clic_callback(callback: Callable)

Stores a function to call everytime the user clics on the plot. Functions arguments are location, cell_id.

Parameters:

callback (Callable) – Function to call.

provide_on_mouse_move_callback(callback: Callable)

Stores a function to call everytime the user moves the mouse on the plot. Functions arguments are location, cell_id.

Parameters:

callback (Callable) – Function to call.

recompute(*args, **kwargs)

Recomputes the figure based on the new bounds and parameters.

recompute_at(position: Tuple[float, float, float], cell_id: str)

Triggers a panel recomputation at the provided location. Called by layout update event.

Parameters:
  • position (Tuple[float, float, float]) – Location to provide to the slave

  • cell_id (str) – cell id to provide to the slave

rename(name: str)

Rename current panel

Parameters:

name (str) – New name

set_colormap(colormap: str)

Sets the current color map

Parameters:

colormap (str) – Color map name

set_field(field_name: str)

Updates the plotted field

Parameters:

field_name (str) – New field to display

slave: ComputeSlave

Slave to which request the plots

sync_field: bool = False

The panel updates its field if another panel did

to_json() Dict

Returns a dictionnary with the information required to rebuild the visualization panel

Returns:

Information dict

Return type:

Dict

trigger_on_file_load(file_path: str, file_label: str)
update_event: UpdateEvent | List[UpdateEvent] = 0

On what event does the panel recompute itself

update_polygons

Need to update the data at the next async call

Module contents