wolfhece.pyvertexvectors._vector

GUI-enabled vector class with OpenGL, matplotlib, and wx integration.

Module Contents

wolfhece.pyvertexvectors._vector._FONTNAMES[source]
class wolfhece.pyvertexvectors._vector.vector(lines: list = [], is2D=True, name='NoName', parentzone: wolfhece.pyvertexvectors._zone.zone = None, fromshapely=None, fromnumpy: numpy.ndarray = None, fromlist: list = None)[source]

Bases: wolfhece.pyvertexvectors._models.vectorModel

Inheritance diagram of wolfhece.pyvertexvectors._vector.vector

Objet de gestion d’informations vectorielles (GUI).

Hérite de vectorModel pour les données/géométrie et ajoute OpenGL, wx et matplotlib.

mytree: TreeListCtrl[source]
myitem: wx.core.TreeItemId[source]
textimage: wolfhece.wolf_texture.Text_Image_Texture = None[source]
_vbo_cache: numpy.ndarray | None = None[source]
_vbo_vertex_count: int = 0[source]
_fill_vbo_cache: numpy.ndarray | None = None[source]
_fill_vbo_vertex_count: int = 0[source]
_make_properties(*args, **kwargs) wolfhece.pyvertexvectors._vectorproperties.vectorproperties[source]

Factory: create GUI-enabled vector properties.

_make_vector(**kwargs) vector[source]

Factory: create a new GUI-enabled vector.

_make_zone(**kwargs) wolfhece.pyvertexvectors._zone.zone[source]

Factory: create a new GUI-enabled zone.

intersects_view_bounds(xmin: float = None, ymin: float = None, xmax: float = None, ymax: float = None) bool[source]

Return whether the vector should be considered visible in the current view.

This is a rendering-oriented wrapper around the model’s generic bbox intersection predicate.

legend_anchor_in_view_bounds(xmin: float = None, ymin: float = None, xmax: float = None, ymax: float = None) bool[source]

Return whether the legend anchor should be rendered in the current view.

text_along_in_view_bounds(xmin: float = None, ymin: float = None, xmax: float = None, ymax: float = None) bool[source]

Return whether text-along should be rendered in the current view.

classmethod make_from_shapely(shapelyobj, **kwargs) vector[source]

Factory method to create a vector from a Shapely geometry.

classmethod make_from_numpy(array: numpy.ndarray, **kwargs) vector[source]

Factory method to create a vector from a NumPy array of shape (N, 2) or (N, 3).

classmethod make_from_list(lst: list, **kwargs) vector[source]

Factory method to create a vector from a list of coordinate tuples.

find_nearest_vertex(x, y) wolfhece.PyVertex.wolfvertex | None[source]

Return the nearest vertex.

The returned object is an existing vertex from this GUI vector.

show_properties()[source]

Show the properties

hide_properties()[source]

Hide the properties

use()[source]

Mark the vector as used and check it in the tree.

unuse()[source]

L’objet n’est plus à utiliser

_on_vertices_changed()[source]

Invalidate cached geometries and the parent zone’s OpenGL display list.

add2tree(tree: TreeListCtrl, root)[source]

Add the vector to a wx TreeListCtrl.

Parameters:
  • tree – Target tree control.

  • root – Parent tree item.

fillgrid(gridto: wolfhece.CpGrid.CpGrid)[source]

Fill a wx CpGrid with vertex data.

Parameters:

gridto – Target grid control.

_fillgrid_only_i(gridto: wolfhece.CpGrid.CpGrid)[source]

Fill only the in-use column of a wx CpGrid.

Parameters:

gridto – Target grid control.

updatefromgrid(gridfrom: wolfhece.CpGrid.CpGrid)[source]

Update vertices from a wx CpGrid.

Parameters:

gridfrom – Source grid control.

_plot_square_at_vertices(size=5)[source]

Plot small squares at each vertex using OpenGL.

Parameters:

size – Point size in pixels.

_plot_index_vertex(idx: int = None, xy: tuple[float, float] = None, sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None)[source]

Plot OpenGL

Parameters:
  • idx – index of the vertex to plot

  • xy – coordinates (x,y) of the vertex to plot

  • sx – scale x

  • sy – scale y

  • xmin – minimum x

  • ymin – minimum y

  • xmax – maximum x

  • ymax – maximum y

  • size – size of the text

_plot_all_indices(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None)[source]

Plot all indices of the vertices using OpenGL :param sx: scale x :param sy: scale y :param xmin: minimum x :param ymin: minimum y :param xmax: maximum x :param ymax: maximum y :param size: size of the text

_plot_length2D_vertex(idx: int = None, xy: tuple[float, float] = None, sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None)[source]

Plot OpenGL

Parameters:
  • idx – index of the vertex to plot

  • xy – coordinates (x,y) of the vertex to plot

  • sx – scale x

  • sy – scale y

  • xmin – minimum x

  • ymin – minimum y

  • xmax – maximum x

  • ymax – maximum y

  • size – size of the text

_plot_all_lengths2D(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None)[source]

Plot 2-D curvilinear lengths at each vertex using OpenGL.

Parameters:
  • sx – scale x

  • sy – scale y

  • xmin – minimum x

  • ymin – minimum y

  • xmax – maximum x

  • ymax – maximum y

  • size – size of the text

_ensure_vbo_cache()[source]

Rebuild the VBO data cache if invalidated.

build_fill_shader_vbo_data() tuple[numpy.ndarray, int][source]

Build contiguous float32 triangle vertices for filled polygon shader.

Each vertex is (x, y, edgeDist) where edgeDist is the normalised distance from the vertex to the nearest polygon boundary (0 = on the edge, 1 = at the deepest interior point). This attribute drives the cushion/pillow normal effect.

_ensure_fill_vbo_cache()[source]

Rebuild the fill VBO cache if invalidated.

_resolve_fill_anim_geometry() tuple[tuple[float, float], float][source]

Return the fill-animation centre and its max radius in world space.

_should_plot_fill_anim_center_preview(mapviewer=None) bool[source]

Return whether the transient fill-animation centre preview should be shown.

_plot_fill_anim_center_preview(size: float = 9.0)[source]

Draw a transient OpenGL marker at the fill-animation centre.

plot_shader(mvp: numpy.ndarray, viewport: tuple[int, int], anim_phase: float = 0.0)[source]

Plot the vector using the modern shader pipeline.

Parameters:
  • mvp – 4×4 projection matrix (column-major float32).

  • viewport(width_px, height_px) of the viewport.

  • anim_phase – Animation phase [0, 1] for effects.

plot_list(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None)[source]

Plot the vector using legacy OpenGL immediate mode / display lists.

Parameters:
  • sx – Scale factor along X.

  • sy – Scale factor along Y.

  • xmin – Minimum X of the viewport.

  • ymin – Minimum Y of the viewport.

  • xmax – Maximum X of the viewport.

  • ymax – Maximum Y of the viewport.

  • size – Reference size for rendering.

plot(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None, rendering_machine=None, mvp=None, viewport=None, anim_phase=0.0)[source]

Plot the vector using OpenGL (dispatcher).

When rendering_machine is VectorOGLRenderer.SHADER, delegates to plot_shader(). Otherwise falls back to the legacy plot_list() path.

Parameters:
  • rendering_machineVectorOGLRenderer enum value.

  • mvp – 4×4 projection matrix (only for shader mode).

  • viewport(width_px, height_px) (only for shader mode).

  • anim_phase – Animation phase [0, 1] (only for shader mode).

plot_legend(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None, rendering_machine=None, mvp=None, viewport=None, anim_phase=0.0)[source]

Plot the legend as an OpenGL image texture or via the SDF atlas shader.

Parameters:
  • sx – Scale factor along X.

  • sy – Scale factor along Y.

  • xmin – Minimum X of the viewport.

  • ymin – Minimum Y of the viewport.

  • xmax – Maximum X of the viewport.

  • ymax – Maximum Y of the viewport.

  • size – Reference size for rendering.

  • rendering_machineVectorOGLRenderer.SHADER for atlas path.

  • mvp – 4×4 MVP matrix (required for shader path).

  • viewport(width, height) in pixels (required for shader path).

  • anim_phase – Animation phase [0, 1] for shader path.

plot_legend_shader(mvp: numpy.ndarray, viewport: tuple[int, int], anim_phase: float = 0.0)[source]

Render the legend using the SDF glyph atlas shader.

Parameters:
  • mvp – 4×4 MVP matrix (column-major float32).

  • viewport(width_px, height_px).

  • anim_phase – Animation cycling phase [0, 1].

plot_text_along_polyline(mvp: numpy.ndarray, viewport: tuple[int, int], anim_phase: float = 0.0)[source]

Render text that follows the polyline path using the SDF atlas.

Each character is oriented along the local tangent of the polyline. Controlled by myprop.text_along_* properties.

Parameters:
  • mvp – 4×4 MVP matrix (column-major float32).

  • viewport(width_px, height_px).

  • anim_phase – Animation cycling phase [0, 1].

plot_tracking_label(mvp: numpy.ndarray, viewport: tuple[int, int], mouse_x: float, mouse_y: float, format_func=None)[source]

Render a dynamic label snapped to the polyline at mouse position.

The label content (by default the curvilinear distance) follows the mouse cursor projected onto the polyline. A small marker is drawn at the snap point on the polyline.

Parameters:
  • mvp – 4×4 MVP matrix (column-major float32).

  • viewport(width_px, height_px).

  • mouse_x – Mouse X in world coordinates.

  • mouse_y – Mouse Y in world coordinates.

  • format_func(curvi_dist, total_length) -> str.

plot_image(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None)[source]

Plot attached images as OpenGL textures.

Parameters:
  • sx – Scale factor along X.

  • sy – Scale factor along Y.

  • xmin – Minimum X of the viewport.

  • ymin – Minimum Y of the viewport.

  • xmax – Maximum X of the viewport.

  • ymax – Maximum Y of the viewport.

  • size – Reference size for rendering.

plot_legend_mpl(ax: matplotlib.pyplot.Axes, xlim: tuple[float] | None = None, ylim: tuple[float] | None = None)[source]

Plot the legend on a Matplotlib Axes.

Parameters:
  • ax – Target Matplotlib Axes.

  • xlim – Optional (xmin, xmax) bounds to skip off-screen legends.

  • ylim – Optional (ymin, ymax) bounds to skip off-screen legends.

plot_matplotlib(ax: matplotlib.pyplot.Axes | tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] = None, xlim: tuple[float] | None = None, ylim: tuple[float] | None = None)[source]

Plot the vector using Matplotlib (XY coordinates only).

Parameters:
  • ax – Matplotlib Axes, (fig, ax) tuple, or None to create one.

  • xlim – Optional (xmin, xmax) bounds for legend clipping.

  • ylim – Optional (ymin, ymax) bounds for legend clipping.

Returns:

(fig, ax) tuple.

plot_matplotlib_sz(ax: matplotlib.pyplot.Axes | tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] = None)[source]

Plot Matplotlib - SZ coordinates ONLY.

S is the curvilinear abscissa, Z is the elevation.

Parameters:

ax – Matplotlib Axes to plot on or a tuple (fig, ax) where fig is the figure and ax is the axes.

If ax is None, a new figure and axes will be created.

plot_linked(fig, ax, linked_arrays: dict)[source]

Plot linked array values on a Matplotlib figure using a vector as a trace.

Parameters:
  • fig – Matplotlib Figure to plot on

  • ax – Matplotlib Axes to plot on

  • linked_arrays – Dictionary of linked arrays to plot, with the label as key and the array as value

The linked arrays can be a WolfArray or a Wolfresults_2D, as long as they have the method get_value(x,y) to retrieve the value at coordinates (x,y) and the method get_dxdy_min() to get the minimum grid spacing used for vector subdivision.

If you call this method by script, ensure that plotted=True for the linked arrays you want to plot, otherwise they will not be displayed.

plot_linked_difference(fig, ax, linked_arrays: dict)[source]

Plot differences of linked array values along the vector trace.

The first plotted array is used as reference; subsequent arrays are displayed as value - reference.

Parameters:
  • fig – Matplotlib Figure.

  • ax – Matplotlib Axes.

  • linked_arrays{label: array} dictionary.

plot_linked_wx(fig: wolfhece.matplotlib_fig.Matplotlib_Figure, linked_arrays: dict)[source]

Plot linked array values using wxPython Matplotlib figure.

Parameters:
  • fig – wxPython Matplotlib figure wrapper.

  • linked_arrays{label: array} dictionary.

update_linked_wx(fig: wolfhece.matplotlib_fig.Matplotlib_Figure, linked_arrays: dict)[source]

Update an existing wxPython Matplotlib figure with new linked array values.

Parameters:
  • fig – wxPython Matplotlib figure wrapper.

  • linked_arrays{label: array} dictionary.

plot_mpl(show=False, forceaspect=True, fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, labels: dict = {}, clear_ax: bool = True)[source]

Plot the vector in Matplotlib (SZ coordinates only).

Deprecated since version Use: plot_matplotlib_sz() instead.

Parameters:
  • show – Whether to call fig.show().

  • forceaspect – Whether to force the aspect ratio.

  • fig – Existing Figure, or None to create one.

  • ax – Existing Axes, or None to create one.

  • labels – Dict with optional title, xlabel, ylabel.

  • clear_ax – Whether to clear the axes before plotting.

Returns:

(fig, ax) tuple.

_get_textfont()[source]

Retunr a ‘Text_Infos’ instance for the legend

_get_textfont_idx()[source]

Retunr a ‘Text_Infos’ instance for the legend