wolfhece.pyvertexvectors._vector ================================ .. py:module:: wolfhece.pyvertexvectors._vector .. autoapi-nested-parse:: GUI-enabled vector class with OpenGL, matplotlib, and wx integration. Module Contents --------------- .. py:data:: _FONTNAMES .. py:class:: vector(lines: list = [], is2D=True, name='NoName', parentzone: wolfhece.pyvertexvectors._zone.zone = None, fromshapely=None, fromnumpy: numpy.ndarray = None, fromlist: list = None) Bases: :py:obj:`wolfhece.pyvertexvectors._models.vectorModel` .. autoapi-inheritance-diagram:: wolfhece.pyvertexvectors._vector.vector :parts: 1 :private-bases: Objet de gestion d'informations vectorielles (GUI). Hérite de :class:`vectorModel` pour les données/géométrie et ajoute OpenGL, wx et matplotlib. .. py:attribute:: mytree :type: TreeListCtrl .. py:attribute:: myitem :type: wx.core.TreeItemId .. py:attribute:: textimage :type: wolfhece.wolf_texture.Text_Image_Texture :value: None .. py:attribute:: _vbo_cache :type: numpy.ndarray | None :value: None .. py:attribute:: _vbo_vertex_count :type: int :value: 0 .. py:attribute:: _fill_vbo_cache :type: numpy.ndarray | None :value: None .. py:attribute:: _fill_vbo_vertex_count :type: int :value: 0 .. py:method:: _make_properties(*args, **kwargs) -> wolfhece.pyvertexvectors._vectorproperties.vectorproperties Factory: create GUI-enabled vector properties. .. py:method:: _make_vector(**kwargs) -> vector Factory: create a new GUI-enabled vector. .. py:method:: _make_zone(**kwargs) -> wolfhece.pyvertexvectors._zone.zone Factory: create a new GUI-enabled zone. .. py:method:: intersects_view_bounds(xmin: float = None, ymin: float = None, xmax: float = None, ymax: float = None) -> bool 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. .. py:method:: legend_anchor_in_view_bounds(xmin: float = None, ymin: float = None, xmax: float = None, ymax: float = None) -> bool Return whether the legend anchor should be rendered in the current view. .. py:method:: text_along_in_view_bounds(xmin: float = None, ymin: float = None, xmax: float = None, ymax: float = None) -> bool Return whether text-along should be rendered in the current view. .. py:method:: make_from_shapely(shapelyobj, **kwargs) -> vector :classmethod: Factory method to create a vector from a Shapely geometry. .. py:method:: make_from_numpy(array: numpy.ndarray, **kwargs) -> vector :classmethod: Factory method to create a vector from a NumPy array of shape (N, 2) or (N, 3). .. py:method:: make_from_list(lst: list, **kwargs) -> vector :classmethod: Factory method to create a vector from a list of coordinate tuples. .. py:method:: find_nearest_vertex(x, y) -> wolfhece.PyVertex.wolfvertex | None Return the nearest vertex. The returned object is an existing vertex from this GUI vector. .. py:method:: show_properties() Show the properties .. py:method:: hide_properties() Hide the properties .. py:method:: use() Mark the vector as used and check it in the tree. .. py:method:: unuse() L'objet n'est plus à utiliser .. py:method:: _on_vertices_changed() Invalidate cached geometries and the parent zone's OpenGL display list. .. py:method:: add2tree(tree: TreeListCtrl, root) Add the vector to a wx TreeListCtrl. :param tree: Target tree control. :param root: Parent tree item. .. py:method:: fillgrid(gridto: wolfhece.CpGrid.CpGrid) Fill a wx CpGrid with vertex data. :param gridto: Target grid control. .. py:method:: _fillgrid_only_i(gridto: wolfhece.CpGrid.CpGrid) Fill only the in-use column of a wx CpGrid. :param gridto: Target grid control. .. py:method:: updatefromgrid(gridfrom: wolfhece.CpGrid.CpGrid) Update vertices from a wx CpGrid. :param gridfrom: Source grid control. .. py:method:: _plot_square_at_vertices(size=5) Plot small squares at each vertex using OpenGL. :param size: Point size in pixels. .. py:method:: _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) Plot OpenGL :param idx: index of the vertex to plot :param xy: coordinates (x,y) of the vertex to plot :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 .. py:method:: _plot_all_indices(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None) 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 .. py:method:: _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) Plot OpenGL :param idx: index of the vertex to plot :param xy: coordinates (x,y) of the vertex to plot :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 .. py:method:: _plot_all_lengths2D(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None) Plot 2-D curvilinear lengths at each vertex 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 .. py:method:: _ensure_vbo_cache() Rebuild the VBO data cache if invalidated. .. py:method:: build_fill_shader_vbo_data() -> tuple[numpy.ndarray, int] 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. .. py:method:: _ensure_fill_vbo_cache() Rebuild the fill VBO cache if invalidated. .. py:method:: _resolve_fill_anim_geometry() -> tuple[tuple[float, float], float] Return the fill-animation centre and its max radius in world space. .. py:method:: _should_plot_fill_anim_center_preview(mapviewer=None) -> bool Return whether the transient fill-animation centre preview should be shown. .. py:method:: _plot_fill_anim_center_preview(size: float = 9.0) Draw a transient OpenGL marker at the fill-animation centre. .. py:method:: plot_shader(mvp: numpy.ndarray, viewport: tuple[int, int], anim_phase: float = 0.0) Plot the vector using the modern shader pipeline. :param mvp: 4×4 projection matrix (column-major float32). :param viewport: ``(width_px, height_px)`` of the viewport. :param anim_phase: Animation phase ``[0, 1]`` for effects. .. py:method:: plot_list(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None) Plot the vector using legacy OpenGL immediate mode / display lists. :param sx: Scale factor along X. :param sy: Scale factor along Y. :param xmin: Minimum X of the viewport. :param ymin: Minimum Y of the viewport. :param xmax: Maximum X of the viewport. :param ymax: Maximum Y of the viewport. :param size: Reference size for rendering. .. py:method:: 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) Plot the vector using OpenGL (dispatcher). When *rendering_machine* is ``VectorOGLRenderer.SHADER``, delegates to :meth:`plot_shader`. Otherwise falls back to the legacy :meth:`plot_list` path. :param rendering_machine: :class:`VectorOGLRenderer` enum value. :param mvp: 4×4 projection matrix (only for shader mode). :param viewport: ``(width_px, height_px)`` (only for shader mode). :param anim_phase: Animation phase ``[0, 1]`` (only for shader mode). .. py:method:: 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) Plot the legend as an OpenGL image texture or via the SDF atlas shader. :param sx: Scale factor along X. :param sy: Scale factor along Y. :param xmin: Minimum X of the viewport. :param ymin: Minimum Y of the viewport. :param xmax: Maximum X of the viewport. :param ymax: Maximum Y of the viewport. :param size: Reference size for rendering. :param rendering_machine: ``VectorOGLRenderer.SHADER`` for atlas path. :param mvp: 4×4 MVP matrix (required for shader path). :param viewport: ``(width, height)`` in pixels (required for shader path). :param anim_phase: Animation phase ``[0, 1]`` for shader path. .. py:method:: plot_legend_shader(mvp: numpy.ndarray, viewport: tuple[int, int], anim_phase: float = 0.0) Render the legend using the SDF glyph atlas shader. :param mvp: 4×4 MVP matrix (column-major float32). :param viewport: ``(width_px, height_px)``. :param anim_phase: Animation cycling phase ``[0, 1]``. .. py:method:: plot_text_along_polyline(mvp: numpy.ndarray, viewport: tuple[int, int], anim_phase: float = 0.0) 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. :param mvp: 4×4 MVP matrix (column-major float32). :param viewport: ``(width_px, height_px)``. :param anim_phase: Animation cycling phase ``[0, 1]``. .. py:method:: plot_tracking_label(mvp: numpy.ndarray, viewport: tuple[int, int], mouse_x: float, mouse_y: float, format_func=None) 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. :param mvp: 4×4 MVP matrix (column-major float32). :param viewport: ``(width_px, height_px)``. :param mouse_x: Mouse X in world coordinates. :param mouse_y: Mouse Y in world coordinates. :param format_func: ``(curvi_dist, total_length) -> str``. .. py:method:: plot_image(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None) Plot attached images as OpenGL textures. :param sx: Scale factor along X. :param sy: Scale factor along Y. :param xmin: Minimum X of the viewport. :param ymin: Minimum Y of the viewport. :param xmax: Maximum X of the viewport. :param ymax: Maximum Y of the viewport. :param size: Reference size for rendering. .. py:method:: plot_legend_mpl(ax: matplotlib.pyplot.Axes, xlim: tuple[float] | None = None, ylim: tuple[float] | None = None) Plot the legend on a Matplotlib Axes. :param ax: Target Matplotlib Axes. :param xlim: Optional ``(xmin, xmax)`` bounds to skip off-screen legends. :param ylim: Optional ``(ymin, ymax)`` bounds to skip off-screen legends. .. py:method:: plot_matplotlib(ax: matplotlib.pyplot.Axes | tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] = None, xlim: tuple[float] | None = None, ylim: tuple[float] | None = None) Plot the vector using Matplotlib (XY coordinates only). :param ax: Matplotlib Axes, ``(fig, ax)`` tuple, or None to create one. :param xlim: Optional ``(xmin, xmax)`` bounds for legend clipping. :param ylim: Optional ``(ymin, ymax)`` bounds for legend clipping. :return: ``(fig, ax)`` tuple. .. py:method:: plot_matplotlib_sz(ax: matplotlib.pyplot.Axes | tuple[matplotlib.figure.Figure, matplotlib.axes.Axes] = None) Plot Matplotlib - SZ coordinates ONLY. S is the curvilinear abscissa, Z is the elevation. :param 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. .. py:method:: plot_linked(fig, ax, linked_arrays: dict) Plot linked array values on a Matplotlib figure using a vector as a trace. :param fig: Matplotlib Figure to plot on :param ax: Matplotlib Axes to plot on :param 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. .. py:method:: plot_linked_difference(fig, ax, linked_arrays: dict) 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``. :param fig: Matplotlib Figure. :param ax: Matplotlib Axes. :param linked_arrays: ``{label: array}`` dictionary. .. py:method:: plot_linked_wx(fig: wolfhece.matplotlib_fig.Matplotlib_Figure, linked_arrays: dict) Plot linked array values using wxPython Matplotlib figure. :param fig: wxPython Matplotlib figure wrapper. :param linked_arrays: ``{label: array}`` dictionary. .. py:method:: update_linked_wx(fig: wolfhece.matplotlib_fig.Matplotlib_Figure, linked_arrays: dict) Update an existing wxPython Matplotlib figure with new linked array values. :param fig: wxPython Matplotlib figure wrapper. :param linked_arrays: ``{label: array}`` dictionary. .. py:method:: plot_mpl(show=False, forceaspect=True, fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, labels: dict = {}, clear_ax: bool = True) Plot the vector in Matplotlib (SZ coordinates only). .. deprecated:: Use :meth:`plot_matplotlib_sz` instead. :param show: Whether to call ``fig.show()``. :param forceaspect: Whether to force the aspect ratio. :param fig: Existing Figure, or None to create one. :param ax: Existing Axes, or None to create one. :param labels: Dict with optional *title*, *xlabel*, *ylabel*. :param clear_ax: Whether to clear the axes before plotting. :return: ``(fig, ax)`` tuple. .. py:method:: _get_textfont() Retunr a 'Text_Infos' instance for the legend .. py:method:: _get_textfont_idx() Retunr a 'Text_Infos' instance for the legend