pyampp.gxbox.box_view3d
Classes
A class to visualize the magnetic field of a box using PyVista. It inherits from the BackgroundPlotter class. |
Functions
|
Rounds the minimum value to the nearest hundredth. |
|
Rounds the maximum value to the nearest hundredth. |
|
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.
- 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.BackgroundPlotterA 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).
- 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.
- add_parallel_projection_button()[source]
Adds a toggle button for parallel projection to the toolbar.
- add_observer_cam_button()[source]
Adds a button to the toolbar to set the camera to the normal direction.
- 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.
- deselect_sphere()[source]
Handles the deselection of a sphere. Clears the inputs and hides the current sphere and its streamlines.
- 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.
- 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_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_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_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).