pyampp.gxbox.box_view3d

Classes

MagFieldViewer

A class to visualize the magnetic field of a box using PyVista. It inherits from the BackgroundPlotter class.

Functions

minval(min_val)

Rounds the minimum value to the nearest hundredth.

maxval(max_val)

Rounds the maximum value to the nearest hundredth.

generate_streamlines_from_line_seeds(box, b3dtype, ...)

Module Contents

pyampp.gxbox.box_view3d.minval(min_val)[source]

Rounds the minimum value to the nearest hundredth.

Parameters:

min_val – float The minimum value to round.

Returns:

float The rounded minimum value.

pyampp.gxbox.box_view3d.maxval(max_val)[source]

Rounds the maximum value to the nearest hundredth.

Parameters:

max_val – float The maximum value to round.

Returns:

float The rounded maximum value.

pyampp.gxbox.box_view3d.generate_streamlines_from_line_seeds(box, b3dtype, line_seeds)[source]
class pyampp.gxbox.box_view3d.MagFieldViewer(box, parent=None, box_norm_direction=None, box_view_up=None, time=None, b3dtype='nlfff', model_path=None, session_mode=None, *args, **kwargs)[source]

Bases: pyvistaqt.BackgroundPlotter

A class to visualize the magnetic field of a box using PyVista. It inherits from the BackgroundPlotter class.

Parameters:
  • box – object The box containing magnetic field data.

  • parent – object, optional The parent object (default is None).

source_model_path[source]
box[source]
parent = None[source]
model_path = None[source]
session_mode = 'embedded'[source]
box_norm_direction = None[source]
box_view_up = None[source]
updating_flag = False[source]
spheres[source]
current_sphere_id = None[source]
next_sphere_id = 1[source]
current_sphere = None[source]
sphere_actor = None[source]
sphere = None[source]
axes_widget = None[source]
plane_actor = None[source]
bottom_slice_actor = None[source]
base_map_actor = None[source]
model_box_actor = None[source]
fov_box_actor = None[source]
streamlines_actor = None[source]
streamlines = None[source]
sphere_visible = True[source]
slice_visible = True[source]
base_map_visible = False[source]
model_box_visible = True[source]
fov_box_visible = True[source]
plane_visible = True[source]
use_interp = True[source]
scalar = 'bz'[source]
previous_params[source]
previous_valid_values[source]
scalar_selector = None[source]
slice_checkbox = None[source]
slice_axis_selector = None[source]
slice_coord_label = None[source]
scalar_selector_items = [][source]
base_map_selector = None[source]
model_box_checkbox = None[source]
fov_box_checkbox = None[source]
base_map_checkbox = None[source]
base_map_items = [][source]
center_x_input = None[source]
center_y_input = None[source]
center_z_input = None[source]
radius_input = None[source]
n_points_input = None[source]
slice_z_input = None[source]
vmin_input = None[source]
vmax_input = None[source]
slice_z_min = 0.0[source]
slice_z_max = 0.0[source]
scalar_min = 0.0[source]
scalar_max = 0.0[source]
base_scalar_min = 0.0[source]
base_scalar_max = 0.0[source]
update_button = None[source]
send_button = None[source]
save_model_button = None[source]
save_close_button = None[source]
cancel_button = None[source]
save_as_button = None[source]
parallel_proj_button = None[source]
field_lines_control_group = None[source]
sphere_control_group = None[source]
base_vmin_input = None[source]
base_vmax_input = None[source]
timestr[source]
grid_x[source]
grid_y[source]
grid_z[source]
grid_zbase[source]
slice_axis = 'z'[source]
slice_axis_positions[source]
slice_coord_min[source]
slice_coord_max[source]
default_sph_cen_x[source]
default_sph_cen_y[source]
default_sph_cen_z[source]
print_camera_position(caller, event)[source]

Prints the camera position whenever the camera is moved.

set_camera_to_LOS_direction()[source]

Set the camera to the observer line-of-sight.

The authoritative orientation comes only from the observer WCS and the box frame. The optional FOV box is used only to choose the framing target (center/zoom), never to define the camera basis itself.

schedule_startup_los_view() None[source]
ensure_window_visible() None[source]
add_parallel_projection_button()[source]

Adds a toggle button for parallel projection to the toolbar.

toggle_parallel_projection(state)[source]

Toggles the parallel projection mode of the camera.

add_observer_cam_button()[source]

Adds a button to the toolbar to set the camera to the normal direction.

add_menu_options()[source]
save_state(default_filename='box_view3d_state.pkl')[source]

Saves the current state of spheres to a file. Prompts the user to select a directory and input a filename.

Parameters:

default_filename – str The default name of the file to save the state data.

load_state(filename=None)[source]

Loads the state of spheres from a file. Prompts the user to select a file.

add_widgets_to_window()[source]

Adds the input widgets to the window.

select_sphere(sphere_id)[source]
deselect_sphere()[source]

Handles the deselection of a sphere. Clears the inputs and hides the current sphere and its streamlines.

delete_sphere_from_tb(sphere_id)[source]
validate_input(widget, min_val, max_val, original_value, to_int=False, paired_widget=None, paired_type=None)[source]

Validates the input of a QLineEdit widget and returns the value if it is valid. If the input is invalid, a warning message is displayed and the original value is restored.

Parameters:
  • widget – QLineEdit The widget to validate.

  • min_val – float The minimum valid value.

  • max_val – float The maximum valid value.

  • original_value – float The original value of the widget.

  • to_int – bool Whether to convert the value to an integer.

  • paired_widget – QLineEdit, optional The paired widget to compare the value with.

  • paired_type – str, optional The type of comparison to perform with the paired widget.

Returns:

float The valid value.

init_grid()[source]
init_plot()[source]

Initializes and displays the plot with the magnetic field data.

update_plot(init=False)[source]

Updates the plot based on the current input parameters.

update_slice(slice_axis, slice_z, scalar, vmin, vmax, use_interp=True, slice_visible=True)[source]

Updates the slice plot based on the given parameters.

Parameters:
  • slice_axis – str The axis normal to the slice plane.

  • slice_z – float The slice coordinate along the selected axis.

  • scalar – str The scalar field to use for the slice.

  • vmin – float The minimum value for the color scale.

  • vmax – float The maximum value for the color scale.

update_base_map(base_map, vmin, vmax, base_map_visible=True)[source]

Render a fixed bottom-plane base map independently of the moving z-slice.

update_model_box(visible=True, do_render=True)[source]
update_fov_box(visible=True, do_render=True)[source]
create_streamlines(center_x, center_y, center_z, radius, n_points)[source]
update_streamlines(center_x, center_y, center_z, radius, n_points)[source]

Updates the streamline plot based on the given parameters.

Parameters:
  • center_x – float The X coordinate of the center of the sphere.

  • center_y – float The Y coordinate of the center of the sphere.

  • center_z – float The Z coordinate of the center of the sphere.

  • radius – float The radius of the sphere.

  • n_points – int The number of seed points for the streamlines.

update_sphere()[source]

Updates the sphere widget based on the current input parameters.

on_lock_z_changed(state)[source]
update_sphere_visibility(sphere_visible)[source]

Updates the visibility of the sphere widget.

Parameters:

sphere_visible – bool Whether the sphere widget is visible.

toggle_sphere_visibility(state)[source]

Toggles the visibility of the sphere widget.

Parameters:

state – int The state of the checkbox (checked or unchecked).

update_plane()[source]

Updates the plane widget based on the current input parameters.

update_plane_visibility(plane_visible)[source]

Updates the visibility of the plane widget.

Parameters:

plane_visible – bool Whether the plane widget is visible.

toggle_plane_visibility(state)[source]

Toggles the visibility of the plane widget.

Parameters:

state – int The state of the checkbox (checked or unchecked).

toggle_slice_visibility(state)[source]

Toggles the visibility of the z-slice actor while preserving the selected scalar.

Parameters:

state – int The state of the checkbox (checked or unchecked).

toggle_base_map_visibility(state)[source]
toggle_model_box_visibility(state)[source]
toggle_fov_box_visibility(state)[source]
send_streamlines()[source]

Sends the streamline data of all spheres to the parent object (if any).

save_current_model()[source]
accept_and_close()[source]
cancel_and_close()[source]
undo_and_restore()[source]
save_box()[source]
load_box()[source]