wolfhece.wolf_texture ===================== .. py:module:: wolfhece.wolf_texture .. autoapi-nested-parse:: Author: HECE - University of Liege, Pierre Archambeau Date: 2024 Copyright (c) 2024 University of Liege. All rights reserved. This script and its content are protected by copyright law. Unauthorized copying or distribution of this file, via any medium, is strictly prohibited. Module Contents --------------- .. py:data:: msg .. py:class:: genericImagetexture(which: str, label: str, mapviewer, xmin: float, xmax: float, ymin: float, ymax: float, imageFile: str = '', imageObj=None, transparent_color=None, tolerance: int = 3, replace_color=None, drawing_scale: float = 1.0, offset: list[float, float] = [0.0, 0.0]) Bases: :py:obj:`wolfhece.drawing_obj.Element_To_Draw` .. autoapi-inheritance-diagram:: wolfhece.wolf_texture.genericImagetexture :parts: 1 :private-bases: Affichage d'une image en OpenGL via une texture .. py:attribute:: name :type: str .. py:attribute:: idtexture :type: int .. py:attribute:: width :type: int .. py:attribute:: height :type: int .. py:attribute:: which :type: str .. py:attribute:: myImage :type: PIL.Image .. py:attribute:: time :value: None .. py:attribute:: xmin .. py:attribute:: xmax .. py:attribute:: ymin .. py:attribute:: ymax .. py:attribute:: idx .. py:attribute:: imageFile :value: '' .. py:attribute:: drawing_scale :value: 1.0 .. py:attribute:: offset :value: [0.0, 0.0] .. py:attribute:: oldview .. py:attribute:: newview .. py:attribute:: _loader :value: None .. py:attribute:: _pending_load_request_id :type: str | None :value: None .. py:attribute:: _pending_async_image :type: PIL.Image.Image | None :value: None .. py:attribute:: _async_load_bounds :type: tuple[float, float, float, float] | None :value: None .. py:method:: unload() Unload the texture from memory .. py:method:: load(imageFile='') Load the image texture into OpenGL :param imageFile: Optional file path to load the image from This method first checks if an asynchronous image has been loaded and is ready. If so, it uses that image. Otherwise, it proceeds with synchronous loading. .. py:method:: update_minmax() Update the spatial extent of the texture based on its size .. py:method:: reload(xmin=-99999, xmax=-99999, ymin=-99999, ymax=-99999) Reload the texture with new spatial bounds and trigger async image update if using cache. When spatial bounds change, this method: 1. Updates the bounds 2. Checks if the view has changed significantly 3. If using a cache service, schedules async image loading 4. Immediately updates the texture if using direct service (non-cached) .. py:method:: _schedule_async_image_update() Schedule an asynchronous image update based on current bounds and service. This is called when bounds change and the texture is using a cached service. The image is loaded in the background without blocking the UI. Optimizations: 1. Cancel obsolete requests for this texture (old bounds become irrelevant) 2. Load a degraded image (lower resolution, larger bounds) while waiting for best quality .. py:method:: _load_degraded_image_for_fallback(service) -> bool Load a lower-resolution image at wider bounds for immediate display while best quality loads. This improves perceived responsiveness by showing a degraded image immediately. The wider bounds ensure the degraded image covers the viewport during fast pans/zooms. :param service: WebService enum for the source :return: True if fallback was loaded, False otherwise .. py:method:: _get_current_service() -> wolfhece.PyWMS.WebService | None Determine the current service based on texture type. :return: WebService enum value or None .. py:method:: plot(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None) alias for paint .. py:method:: find_minmax(update=False) Generic function to find min and max spatial extent in data .. py:method:: uv(x: float, y: float) -> tuple[float, float] Convert coordinates to texture coordinates taking into account the texture's spatial extent, the scaleing factor, and the offset. :param x: X coordinate in pixels :param y: Y coordinate in pixels :return: Tuple of (u, v) texture coordinates .. py:method:: paint() Paint the image texture on the OpenGL canvas .. py:class:: imagetexture(which: str, label: str, cat: str, subc: str, mapviewer, xmin: float, xmax: float, ymin: float, ymax: float, width: int = 1000, height: int = 1000, France: bool = False, epsg='31370', Vlaanderen: bool = False, LifeWatch: bool = False, IGN_Belgium: bool = False, IGN_Cartoweb: bool = False, postFlood2021: bool = False, Alaro: bool = False) Bases: :py:obj:`wolfhece.drawing_obj.Element_To_Draw` .. autoapi-inheritance-diagram:: wolfhece.wolf_texture.imagetexture :parts: 1 :private-bases: Affichage d'une image, obtenue depuis un Web service, en OpenGL via une texture .. py:attribute:: name :type: str .. py:attribute:: idtexture :type: int .. py:attribute:: width :type: int .. py:attribute:: height :type: int .. py:attribute:: which :type: str .. py:attribute:: category :type: str .. py:attribute:: subcategory :type: str .. py:attribute:: France :type: bool .. py:attribute:: epsg :type: str .. py:attribute:: _program :value: None .. py:attribute:: _cache :value: None .. py:attribute:: Vlaanderen :value: False .. py:attribute:: LifeWatch :value: False .. py:attribute:: IGN_Belgium :value: False .. py:attribute:: IGN_Cartoweb :value: False .. py:attribute:: postFlood2021 :value: False .. py:attribute:: Alaro :value: False .. py:attribute:: xmin .. py:attribute:: xmax .. py:attribute:: ymin .. py:attribute:: ymax .. py:attribute:: idx .. py:attribute:: time :value: None .. py:attribute:: alpha :value: 1.0 .. py:attribute:: force_alpha :value: False .. py:attribute:: oldview .. py:method:: _init_cache() Initialize the cache for this texture based on its category and subcategory .. py:method:: load() Load the image texture into OpenGL, fetching it from the appropriate web service if necessary and caching it for future use. .. py:method:: _update_texture_from_image(image) Update the OpenGL texture with a new image (used for progressive tile updates). .. py:method:: reload() .. py:method:: plot(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None) alias for paint .. py:method:: find_minmax(update=False) Generic function to find min and max spatial extent in data .. py:method:: init_shader() .. py:method:: paint(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None) .. py:method:: check_plot() Generic function responding to check operation from mapviewer .. py:method:: uncheck_plot(unload=True) Generic function responding to uncheck operation from mapviewer .. py:class:: Text_Image_Texture(text: str, mapviewer, proptext: wolfhece.textpillow.Text_Infos, vector, x: float, y: float) Bases: :py:obj:`genericImagetexture` .. autoapi-inheritance-diagram:: wolfhece.wolf_texture.Text_Image_Texture :parts: 1 :private-bases: Affichage d'une image en OpenGL via une texture .. py:attribute:: x .. py:attribute:: y .. py:attribute:: vector .. py:attribute:: proptext .. py:attribute:: mapviewer .. py:attribute:: oldview .. py:method:: findscale() .. py:method:: load(imageFile='') Load the image texture into OpenGL :param imageFile: Optional file path to load the image from This method first checks if an asynchronous image has been loaded and is ready. If so, it uses that image. Otherwise, it proceeds with synchronous loading. .. py:method:: paint() Paint the image texture on the OpenGL canvas .. py:method:: update_image(newtext: str = '', proptext: wolfhece.textpillow.Text_Infos = None)