padne.ui¶
Attributes¶
Classes¶
A dictionary-like object that can hold futures for values, |
|
Spatial index for fast vertex value lookups within a layer. |
|
Spatial index for fast face value lookups within a layer. |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
A QLabel that turns into a QLineEdit on double-click for in-place value editing. |
|
Widget that displays a color scale with delta and absolute range. |
|
Functions¶
|
Configure OpenGL settings for the application. |
|
Main entry point for the UI application. |
Module Contents¶
- padne.ui.VERTEX_SHADER_MESH = Multiline-String[source]¶
Show Value
""" #version 330 core layout(location = 0) in vec2 position; layout(location = 1) in float color; out float frag_value; uniform mat4 mvp; void main() { gl_Position = mvp * vec4(position, 0.0, 1.0); frag_value = color; } """
- padne.ui.FRAGMENT_SHADER_MESH = Multiline-String[source]¶
Show Value
""" #version 330 core in float frag_value; out vec4 out_color; #define COLOR_COUNT 256 uniform float v_max = 1.0; uniform float v_min = 0.0; uniform vec3 color_map[COLOR_COUNT]; void main() { float t = (frag_value - v_min) / (v_max - v_min); float rescaled = t * COLOR_COUNT; int idx = clamp(int(rescaled), 0, COLOR_COUNT - 1); out_color = vec4(color_map[idx], 1.0); } """
- padne.ui.VERTEX_SHADER_DISCONNECTED = Multiline-String[source]¶
Show Value
""" #version 330 core layout(location = 0) in vec2 position; layout(location = 1) in float color; // We still have the color attribute but ignore it uniform mat4 mvp; void main() { gl_Position = mvp * vec4(position, 0.0, 1.0); } """
- padne.ui.FRAGMENT_SHADER_DISCONNECTED = Multiline-String[source]¶
Show Value
""" #version 330 core out vec4 out_color; void main() { // Render disconnected copper in a subdued gray out_color = vec4(0.1, 0.1, 0.1, 1.0); } """
- padne.ui.VERTEX_SHADER_EDGES = Multiline-String[source]¶
Show Value
""" #version 330 core layout(location = 0) in vec2 position; layout(location = 1) in vec3 color; out vec3 frag_color; uniform mat4 mvp; void main() { gl_Position = mvp * vec4(position, 0.0, 1.0); frag_color = color; } """
- padne.ui.FRAGMENT_SHADER_EDGES = Multiline-String[source]¶
Show Value
""" #version 330 core in vec3 frag_color; out vec4 out_color; void main() { out_color = vec4(frag_color, 1.0); } """
- padne.ui.VERTEX_SHADER_POINTS = Multiline-String[source]¶
Show Value
""" #version 330 core layout(location = 0) in vec2 position; layout(location = 1) in vec3 vertex_color; out vec3 frag_color; uniform mat4 mvp; uniform float point_size = 5.0; void main() { gl_Position = mvp * vec4(position, 0.0, 1.0); gl_PointSize = point_size; frag_color = vertex_color; // Pass color to fragment shader } """
- padne.ui.FRAGMENT_SHADER_POINTS = Multiline-String[source]¶
Show Value
""" #version 330 core in vec3 frag_color; // Input color from vertex shader out vec4 out_color; void main() { out_color = vec4(frag_color, 1.0); } """
- class padne.ui.DeferedDict[K, V][source]¶
A dictionary-like object that can hold futures for values, unwrapping them when accessed.
- set_future(key: K, future: concurrent.futures.Future[V])[source]¶
- class padne.ui.BaseSpatialIndex[source]¶
- tree: scipy.spatial.cKDTree | None[source]¶
- classmethod from_layer_data(layer: padne.solver.problem.Layer, layer_solution: padne.solver.LayerSolution) BaseSpatialIndex[source]¶
- class padne.ui.VertexSpatialIndex[source]¶
Bases:
BaseSpatialIndexSpatial index for fast vertex value lookups within a layer.
- class padne.ui.FaceSpatialIndex[source]¶
Bases:
BaseSpatialIndexSpatial index for fast face value lookups within a layer.
- class padne.ui.BaseTool(mesh_viewer: MeshViewer, tool_manager: ToolManager)[source]¶
Bases:
abc.ABCHelper class that provides a standard way to create an ABC using inheritance.
- property shortcut: tuple[PySide6.QtCore.Qt.Key, PySide6.QtCore.Qt.KeyboardModifier] | None[source]¶
- on_shortcut_press(world_point: padne.mesh.Point)[source]¶
Handles a shortcut press event.
- on_mesh_click(world_point: padne.mesh.Point, event: PySide6.QtGui.QMouseEvent)[source]¶
Handles a click event on the mesh.
- on_screen_drag(dx: float, dy: float, event: PySide6.QtGui.QMouseEvent)[source]¶
Handles a screen drag event.
- class padne.ui.PanTool(mesh_viewer: MeshViewer, tool_manager: ToolManager)[source]¶
Bases:
BaseToolHelper class that provides a standard way to create an ABC using inheritance.
- on_screen_drag(dx: float, dy: float, event: PySide6.QtGui.QMouseEvent)[source]¶
Handles a screen drag event.
- class padne.ui.SetMinValueTool(mesh_viewer: MeshViewer, tool_manager: ToolManager)[source]¶
Bases:
PanToolHelper class that provides a standard way to create an ABC using inheritance.
- on_mesh_click(world_point: padne.mesh.Point, event: PySide6.QtGui.QMouseEvent)[source]¶
Handles a click event on the mesh.
- on_shortcut_press(world_point: padne.mesh.Point)[source]¶
Handles a shortcut press event.
- class padne.ui.SetMaxValueTool(mesh_viewer: MeshViewer, tool_manager: ToolManager)[source]¶
Bases:
PanToolHelper class that provides a standard way to create an ABC using inheritance.
- on_mesh_click(world_point: padne.mesh.Point, event: PySide6.QtGui.QMouseEvent)[source]¶
Handles a click event on the mesh.
- on_shortcut_press(world_point: padne.mesh.Point)[source]¶
Handles a shortcut press event.
- class padne.ui.ToolManager(mesh_viewer: MeshViewer, parent=None)[source]¶
Bases:
PySide6.QtCore.QObject- handle_mesh_click(world_point: padne.mesh.Point, event: PySide6.QtGui.QMouseEvent)[source]¶
- handle_screen_drag(dx: float, dy: float, event: PySide6.QtGui.QMouseEvent)[source]¶
- handle_key_press_in_mesh(world_point: padne.mesh.Point, key: PySide6.QtCore.Qt.Key, modifiers: PySide6.QtCore.Qt.KeyboardModifiers)[source]¶
- class padne.ui.AppToolBar(tool_manager: ToolManager, mesh_viewer: MeshViewer, parent=None)[source]¶
Bases:
PySide6.QtWidgets.QToolBar
- class padne.ui.ShaderProgram[source]¶
- shader_program: PySide6.QtOpenGL.QOpenGLShaderProgram[source]¶
- class padne.ui.RenderedMesh[source]¶
-
- class PreparedData[source]¶
- triangle_vertices: numpy.ndarray[numpy.float32][source]¶
- triangle_colors: numpy.ndarray[numpy.float32][source]¶
- edge_vertices: numpy.ndarray[numpy.float32][source]¶
- edge_colors: numpy.ndarray[numpy.float32][source]¶
- boundary_vertices: numpy.ndarray[numpy.float32][source]¶
- boundary_colors: numpy.ndarray[numpy.float32][source]¶
- classmethod from_prepared_data(data: RenderedMesh) RenderedMesh[source]¶
- classmethod prepare_zero_form(msh: padne.mesh.Mesh, values: padne.mesh.ZeroForm) RenderedMesh[source]¶
- classmethod prepare_two_form(msh: padne.mesh.Mesh, values: padne.mesh.TwoForm) RenderedMesh[source]¶
- classmethod prepare_mesh(msh: padne.mesh.Mesh) RenderedMesh[source]¶
Create a RenderedMesh from a mesh with zero values. Used for disconnected copper regions that will be rendered in gray.
- class padne.ui.RenderedPoints[source]¶
- class padne.ui.MeshViewer(parent=None)[source]¶
Bases:
PySide6.QtOpenGLWidgets.QOpenGLWidget- class BaseRenderingMode[source]¶
-
- color_map: padne.colormaps.UniformColorMap[source]¶
- solution: padne.solver.Solution | None = None[source]¶
- spatial_indices: dict[str, BaseSpatialIndex][source]¶
- autoscale_values(solution: padne.solver.Solution)[source]¶
Autoscale values for the rendering mode.
- abstractmethod set_solution(solution: padne.solver.Solution)[source]¶
Initialize this mode with solution data (build indices + meshes).
- pick_nearest_value(layer_name: str, world_x: float, world_y: float) float | None[source]¶
Pick value at coordinates using spatial index.
- get_rendered_meshes_for_layer(layer_name: str) list[RenderedMesh][source]¶
Get pre-built rendered meshes for a layer.
- get_disconnected_rendered_meshes_for_layer(layer_name: str) list[RenderedMesh][source]¶
Get pre-built disconnected rendered meshes for a layer.
- class VoltageRenderingMode[source]¶
Bases:
BaseRenderingMode- color_map: padne.colormaps.UniformColorMap[source]¶
- class PowerDensityRenderingMode[source]¶
Bases:
BaseRenderingMode- color_map: padne.colormaps.UniformColorMap[source]¶
- solution: None | padne.solver.Solution = None[source]¶
- rendered_connection_points: dict[str, RenderedPoints][source]¶
- last_mouse_screen_pos: PySide6.QtCore.QPointF | None = None[source]¶
- property current_rendering_mode: BaseRenderingMode[source]¶
Get the currently active rendering mode.
- autoscaleValue() None[source]¶
Automatically adjust the min/max values for color scaling using the current rendering mode.
- autoscaleXY() None[source]¶
Automatically adjust the offset and scale to fit all meshes in the view. Sets the view to display all meshes with a small margin around them.
- setSolution(solution: padne.solver.Solution)[source]¶
Set the solution for the mesh viewer.
- mousePressEvent(event: PySide6.QtGui.QMouseEvent) None[source]¶
Handle mouse press events.
- mouseMoveEvent(event: PySide6.QtGui.QMouseEvent) None[source]¶
Handle mouse movement.
- mouseReleaseEvent(event: PySide6.QtGui.QMouseEvent) None[source]¶
Handle mouse release events.
- panViewByScreenDelta(dx_screen: float, dy_screen: float) None[source]¶
Pans the view based on a screen delta.
- Args:
dx_screen: Change in x screen coordinate. dy_screen: Change in y screen coordinate.
- setMinValue(value: float) None[source]¶
Sets the minimum of the color scale; clamps max upward if needed.
- setMaxValue(value: float) None[source]¶
Sets the maximum of the color scale; clamps min downward if needed.
- setMinValueFromWorldPoint(world_point: padne.mesh.Point) None[source]¶
Sets the minimum value of the color scale from a world point. If the selected value is greater than the current maximum, both min and max are set to the selected value.
- Args:
world_point: The point in world coordinates.
- setMaxValueFromWorldPoint(world_point: padne.mesh.Point) None[source]¶
Sets the maximum value of the color scale from a world point. If the selected value is less than the current minimum, both min and max are set to the selected value.
- Args:
world_point: The point in world coordinates.
- wheelEvent(event: PySide6.QtGui.QWheelEvent) None[source]¶
Handle mouse wheel for zooming towards cursor position.
- keyPressEvent(event: PySide6.QtGui.QKeyEvent) None[source]¶
Handle keyboard events.
- class padne.ui.EditableValueLabel(parent=None)[source]¶
Bases:
PySide6.QtWidgets.QLabelA QLabel that turns into a QLineEdit on double-click for in-place value editing.
- mouseDoubleClickEvent(event: PySide6.QtGui.QMouseEvent) None[source]¶
- class padne.ui.ColorScaleWidget(parent=None)[source]¶
Bases:
PySide6.QtWidgets.QWidgetWidget that displays a color scale with delta and absolute range.
- delta_label: PySide6.QtWidgets.QLabel | None = None[source]¶
- max_label: EditableValueLabel | None = None[source]¶
- min_label: EditableValueLabel | None = None[source]¶
- paintEvent(event: PySide6.QtGui.QPaintEvent) None[source]¶
Paint the color gradient scale.
- class padne.ui.MainWindow(solution: padne.solver.Solution, warnings_list: list[warnings.WarningMessage] | None = None)[source]¶
Bases:
PySide6.QtWidgets.QMainWindow- updateCurrentLayer(layer_name: str) None[source]¶
Update the window title to show the current layer.
- updateMousePosition(world_point: padne.mesh.Point, value)[source]¶
Update status bar with mouse position and value.
- showEvent(event: PySide6.QtGui.QShowEvent) None[source]¶
Override showEvent to display warnings after window is visible.