wolfhece.PyDraw
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
- class wolfhece.PyDraw.ActiveSlot(expected_type: type[_T] | tuple[type, ...] | None = None)[source]
Bases:
Generic[_T]
Descripteur d’attribut
active_*auto-enregistré.L’objet descripteur est unique au niveau de la classe (attribut de classe), mais la valeur est stockée par instance dans
instance.__dict__sous la clé privée_slot_<name>. Cela garantit une parfaite isolation entre instances et une interface publique indiscernable d’un attribut d’instance classique.À l’affectation de
active_X = ActiveSlot()dans le corps de la classe, Python appelle automatiquement__set_name__qui enregistre le slot dans le registre de classe_active_slots. Ce registre permet les opérations groupées (reset, recherche par identité d’objet).Rétrocompatibilité :
instance.active_X = valetinstance.active_Xfonctionnent exactement comme avant pour tout code interne ou externe.- Gardien de type :
expected_typeest passé au constructeur (type unique ou tuple de types).À l’affectation, un
isinstancevérifie la valeur (horsNone).Les overloads
__get__permettent à Pylance d’inférer_T | Nonedirectement depuis la déclaration de classe, sans analyser tous les sites d’affectation.
- class wolfhece.PyDraw.WolfMapViewer(wxparent=None, title: str = _('Default Wolf Map Viewer'), w: int = 500, h: int = 500, treewidth: int = 200, wolfparent=None, wxlogging=None, enable_async_background_updates: bool = False)[source]
Bases:
wx.dataview.wx.Frame
Fenêtre de visualisation de données WOLF grâce aux WxWidgets
- mybc: list[wolfhece.mesh2d.bc_manager.BcManager][source]
- myviews: list[wolfhece.wolfresults_2D.views_2D][source]
- mytiles: list[wolfhece.wolf_tiles.Tiles][source]
- myimagestiles: list[wolfhece.images_tiles.ImagesTiles][source]
- mypartsystems: list[wolfhece.lagrangian.particle_system_ui.Particle_system_to_draw][source]
- myviewers3d: list[wolfhece.opengl.py3d.Wolf_Viewer3D][source]
- mylazdata: list[wolfhece.lazviewer.laz_viewer.Wolf_LAZ_Data][source]
- mypicturecollections: list[wolfhece.PyPictures.PictureCollection][source]
- myinjectors: list[wolfhece.dike.InjectorWolfDike][source]
- mymplfigs: list[wolfhece._pydraw_utils.MplFigViewer][source]
- mytooltip: wolfhece.PyParams.Wolf_Param[source]
- _active_slots: dict[str, ActiveSlot][source]
- _init_runtime_state(wxparent, title: str, w: int, h: int, treewidth: int, wolfparent, wxlogging, enable_async_background_updates: bool) None[source]
Initialize non-menu runtime state and base frame.
- reset_all_actives() None[source]
Set every active_* slot to None (slots + delegated-manager actives).
- clear_active_if_is(obj) bool[source]
If obj is currently stored in any active_* slot, set that slot to None.
Returns True if at least one slot was cleared, False otherwise. This replaces the long if/elif chain in removeobj_from_id.
Build all top-level menus and wire their handlers.
- _init_canvas_tree_layout(w: int, h: int) None[source]
Create OpenGL canvas, object tree and left layout.
- _init_auxiliary_ui_state() None[source]
Initialize tooltip, notebook placeholders and figure references.
- _init_wintab_context() None[source]
WinTab pressure context initialisation.
DISABLED: WTOpenA/WTEnable in wintab32.dll corrupt the Windows process heap on certain Wacom driver versions, causing STATUS_HEAP_CORRUPTION (0xC0000374) regardless of when the call is made (during init or via wx.CallAfter after MainLoop). The bug is inside the Wacom driver and cannot be worked around by changing call timing.
Pressure is still available via wx.MouseEvent.GetPressure() when the tablet driver operates in Windows Ink mode (Wacom Desktop Center → “Use Windows Ink”). See _sculpt_manager.get_event_pressure().
To re-enable WinTab (e.g. after a Wacom driver update that fixes the heap bug), set WolfMapViewer._WINTAB_ENABLED = True before creating the viewer.
- _do_init_wintab_context() None[source]
Actual WinTab initialisation, called by wx.CallAfter after MainLoop.
- new_fig(caption: str, idx: str = None, layout=PRESET_LAYOUTS.DEFAULT, size=(800, 600), show: bool = True) wolfhece._pydraw_utils.MplFigViewer[source]
Create a new figure
- get_fig(idx: str) wolfhece._pydraw_utils.MplFigViewer[source]
Get a figure by its ID
Menu for triangulations
Menu for cloud points
- _cloud_move_pick_tolerance(pixel_tol: float = 40.0) float[source]
Convert a pixel tolerance to map units for nearest-point picking.
- _overlay_xy_for_mouse(x: float, y: float, altdown: bool) tuple[float, float][source]
Return XY used by OpenGL overlay, with snap when interaction supports it.
- get_choices_arrays()[source]
Boîte de dialogue permettant de choisir une ou plusieurs matrices parmi celles chargées
Menu for tiles
Menu for picture collections
Menu for image tiles
- get_canvas_bounds(gridsize: float = None)[source]
Retourne les limites de la zone d’affichage
- Returns:
[xmin, ymin, xmax, ymax]
- get_bounds(gridsize: float = None) tuple[source]
Retourne les limites de la zone d’affichage, voir aussi get_canvas_bounds
- Returns:
([xmin, xmax], [ymin, ymax])
- get_bounds_as_polygon(gridsize: float = None) wolfhece.PyVertexvectors.vector[source]
Retourne les limites de la zone d’affichage sous forme de polygone :return: vector
- _add_sim_explorer(which: wolfhece.wolfresults_2D.Wolfresults_2D)[source]
Add a step chooser
- _pop_sim_explorer(which: wolfhece.wolfresults_2D.Wolfresults_2D)[source]
Pop a step chooser
- _update_sim_explorer(which: wolfhece.wolfresults_2D.Wolfresults_2D = None)[source]
Menu for 2D simulations
Menu for 2D GPU simulations
- get_configuration() OpenGL.GLUT.Union[wolfhece.PyConfig.WolfConfiguration, None][source]
Get global configuration parameters
- property active_vector_square_size: list[int][source]
Return the active vector square size from configs
- property default_hece_database: pathlib.Path[source]
Return the default HECE database file from configs
- property overlay_xy_font_size: int[source]
Return font size in pixels used by OpenGL XY overlay text.
- property toolbar_tooltip_font_size: int[source]
Return font size in pixels used by toolbar tooltip text.
- property overlay_bg_color: tuple[source]
Return overlay background as an (R, G, B, A) float tuple in [0, 1].
- property snap_grid_round_base: float[source]
Return the coarse base used to align the snap origin [m].
- property palette_for_copy: wolfhece.PyVertexvectors.wolfpalette[source]
Return the palette for copy from configs
- set_interp_cs(obj: wolfhece.PyCrosssections.Interpolators, add_zones: bool = True)[source]
Set the active cross-sections interpolator
- interpolate_cloud()[source]
Interpolation d’un nuage de point sur une matrice
Il est possible d’utiliser une autre valeur que la coordonnées Z des vertices
- interpolate_triangulation(keep: Literal['all', 'above', 'below'] = 'all')[source]
Alias to interpolate on triangulation
- Parameters:
keep – ‘all’ to keep all points, ‘above’ to keep only points above the current array’s value, ‘below’ to keep only points below the current array’s value
- display_canvasogl(mpl=True, ds=0.0, fig: wolfhece.tools_mpl.Figure = None, ax: wolfhece.tools_mpl.Axes = None, clear=True, redraw=True, palette=False, title='')[source]
This method takes a matplotlib figure and axe and, returns a clear screenshot of the information displayed in the wolfpy GUI.
- get_mpl_plot(center=[0.0, 0.0], width=500.0, height=500.0, title='', toshow=True) tuple[wolfhece.tools_mpl.Figure, wolfhece.tools_mpl.Axes][source]
Récupère un graphique matplotlib sur base de la fenêtre OpenGL et de la palette de la matrice/résultat actif.
- create_video(fn: str = '', framerate: int = 0, start_step: int = 0, end_step: int = 0, every: int = 0)[source]
Création d’une vidéo sur base des résultats
- copy_canvasogl(mpl: bool = True, ds: float = 0.0, figsizes=[10.0, 10.0], palette: wolfhece.PyVertexvectors.wolfpalette = None)[source]
Generate image based on UI context and copy to the Clipboard
- Parameters:
mpl (bool, optional) – Using Matplolib as renderer. Defaults to True.
- Parem ds:
Ticks size. Defaults to 0..
- Parem figsizes:
fig size in inches
- save_canvasogl(fn: str = '', mpl: bool = True, ds: float = 0.0, dpi: int = 300, add_title: bool = False, figsizes=[10.0, 10.0], arrayid_as_title: bool = False, resid_as_title: bool = False)[source]
Sauvegarde de la fenêtre d’affichage dans un fichier
- Parameters:
fn – File name (.png or .jpg file)
mpl – Using Matplotlib as renderer
ds – Ticks interval
- setbounds(updatescale=True)[source]
Calcule les limites visibles de la fenêtre graphique sur base des facteurs d’échelle courants
- updatescalefactors()[source]
Mise à jour des facteurs d’échelle This one updates the scale factors based on the relative sizes of the GLCanvas and the footprint that should fit in it.
- add_viewer_and_link()[source]
Ajout d’une nouvelle fenêtre de visualisation et liaison avec la fenêtre courante
- set_compare(ListArrays: list[wolfhece.wolf_array.WolfArray] = None, share_colormap: bool = True)[source]
Comparison of 2 arrays
- Parameters:
ListArrays – List of 2 arrays to compare
share_colormap – Share the colormap between the 2 arrays
- set_compare_all(ListArrays=None, names: WolfMapViewer.set_compare_all.list[str] = None)[source]
Comparison of 2 or 3 arrays
- set_blender_sculpting()[source]
Mise en place de la structure nécessaire pour comparer la donnée de base avec la donnée sculptée sous Blender
La donnée de base est la matrice contenue dans la fenêtre actuelle
- Fenêtres additionnelles :
information sur les volumes de déblai/remblai et bilan
matrice sculptée
différentiel entre scultage - source
gradient
laplacien
masque de modification
- update_blender_sculpting()[source]
Mise à jour des fenêtres de visualisation pour la comparaison avec Blender
- zoomon_activevector(size: float = 500.0, forceupdate: bool = True)[source]
Zoom on active vector
- Parameters:
size – size of the zoomed window
forceupdate – force the update of the window
- zoomon_active_vertex(size: float = 20, forceupdate: bool = True)[source]
Zoom on active vertex.
- Parameters:
size – size of the zoomed window
forceupdate – force the update of the window
- zoom_on_id(id: str, drawtype: wolfhece._pydraw_utils.draw_type = draw_type.ARRAYS, forceupdate=True, canvas_height=1024)[source]
Zoom on id
- Parameters:
id – id of the object to zoom on
drawtype – type of object to zoom on - Different types elements can have the same id
- zoom_on_array(array: wolfhece.wolf_array.WolfArray, forceupdate=True, canvas_height=1024)[source]
Zoom on array
- zoom_on_vector(vector: WolfMapViewer.zoom_on_vector.vector, forceupdate=True, canvas_height=1024)[source]
Zoom on vector
- create_Zones_from_arrays(arrays: list[wolfhece.wolf_array.WolfArray], id: str = None, add_legend: bool = True) wolfhece.PyVertexvectors.Zones[source]
Create a Zones instance from list of WolfArrays
One zone per array.
One vector per zone with the masked contour.
- Parameters:
arrays – list of WolfArrays
id – id of the Zones instance
add_legend – add legend to the vector – centroid of the contour
- zoom_on(zoom_dict=None, width=500, height=500, center=None, xll=None, yll=None, forceupdate=True, canvas_height=1024)[source]
Zoom on a specific area
- It is possible to zoom on a specific area by providing the zoom parameters in :
a dictionnary
width and height of the zoomed window and the lower left corner coordinates
width and height of the zoomed window and the center coordinates
- Parameters:
zoom_dict – dictionnary containing the zoom parameters - possible keys : ‘width’, ‘height’, ‘center’, ‘xmin’, ‘ymin’, ‘xmax’, ‘ymax’
width – width of the zoomed window [m]
height – height of the zoomed window [m]
center – center of the zoomed window [m] - tuple (x,y)
xll – lower left X coordinate of the zoomed window [m]
yll – lower left Y coordinate of the zoomed window [m]
forceupdate – force the update of the window
canvas_height – height of the canvas [pixels]
Examples :
zoom_on(zoom_dict = {‘center’:(500,500), ‘width’:1000, ‘height’:1000})
zoom_on(width = 1000, height = 1000, xll = 500, yll = 500)
zoom_on(width = 1000, height = 1000, center = (500,500))
- zoom_on_active_profile(size: float = 500.0, forceupdate: bool = True)[source]
Zoom on active profile
- read_project(fn)[source]
Projet WOLF GUI
Fichier de paramètres contenant les types et chemins d’accès aux données à ajouter
A compléter…
- help_project()[source]
Help for project file.
Define which elements can be saved in a project file.
- select_active_array_from_laz(array: wolfhece.wolf_array.WolfArray = None, used_codes: list = None, chunk_size: float = 500.0)[source]
select some nodes from laz data
- Parameters:
array – array to fill
used_codes – codes to use
- fill_active_array_from_laz(array: wolfhece.wolf_array.WolfArray = None, used_codes: list = [], operator: int = -1, chunk_size: float = 500.0)[source]
Fill active array with laz data
- Parameters:
array – array to fill
used_codes – codes to use
operator – operator to use
- count_active_array_from_laz(array: wolfhece.wolf_array.WolfArray = None, used_codes: list = [], chunk_size: float = 500.0)[source]
Fill active array with laz data
- Parameters:
array – array to fill
used_codes – codes to use
operator – operator to use
- init_laz_from_lazlasnpz(fn=None)[source]
Read LAZ data stored in one file
- Parameters:
fn – filename (extension .laz, .las, .npz)
- init_laz_from_gridinfos(dirlaz: str = None, classification: Literal['SPW-Geofit 2023', 'SPW 2013-2014', 'SPW 2021-2022'] = 'SPW-Geofit 2023')[source]
- _set_fn_fnpos_gltf()[source]
Définition du nom de fichier GLTF/GLB à lire pour réaliser la comparaison Utilisation d’une fenêtre de dialogue WX
Cette fonction n’est a priori appelée que depuis set_fn_fnpos_gltf
- set_fn_fnpos_gltf()[source]
Définition ou récupération du nom de fichier GLTF/GLB à lire pour réaliser la comparaison
Le nom de fichier est stocké dans la liste des paramètres partagés de façon à ce que l’appel de mise à jour puisse s’effectuer dans n’importe quel frame
- read_one_result(which: int)[source]
Lecture d’un résultat spécific pour les modèles ajoutés et plottés
- Parameters:
which – result index (0-based) – -1 for last result
0 = first result
- _autoscale_if_needed()[source]
Trigger Autoscale when the viewer has exactly 2 total objects (1 new).
- pop_boundary_manager(which: wolfhece.mesh2d.bc_manager.BcManager)[source]
Pop a boundary condition manager after Destroying
- uniquecolormap(loadfromfile=False)[source]
Compute unique colormap from all (arrays, 2D results) and apply it to all
- export_results_as(which: Literal['geotiff', 'shape', 'numpy'] = None, multiband: bool = None)[source]
Export des résultats WOLF2D vers différents formats. Au moins un résultat doit être chargé pour pouvoir être exporté.
- export_shape(outdir: str = '', fn: str = '', myarrays: list[wolfhece.wolf_array.WolfArray] = [], descr: list[str] = [], mask: wolfhece.wolf_array.WolfArray = None)[source]
Export multiple arrays to shapefile
- Parameters:
outdir – output directory
fn – filename – .shp will be added if not present
myarrays – list of Wolfarrays to export
descr – list of descriptions
mask – mask array – export only where mask > 0
- export_geotif(outdir: str = '', fn: str = '', myarrays: list[wolfhece.wolf_array.WolfArray] = [], descr: list[str] = [], multiband: bool = True)[source]
Export multiple arrays to geotiff
- Parameters:
outdir – output directory
fn – filename – .tif will be added if not present
myarrays – list of Wolfarrays to export
descr – list of descriptions – Bands names
- get_linked_arrays(linked: bool = True) dict[source]
Get all arrays in the viewer and linked viewers
- save_linked_canvas(fn: str, mpl: bool = True, ds: float = 0.0, add_title: bool = True) tuple[str, float, str][source]
Save canvas of all linked viewers
- Parameters:
fn – filename without extension – ‘.png’ will be added
mpl – save as matplotlib image
ds – Ticks size for matplotlib image
- Returns:
list of tuple ((filename, ds), viewer_name)
- save_arrays_indep(fn: str, mpl: bool = True, ds: float = 0.0, add_title: bool = True) tuple[str, float, str][source]
Save each array in a separate file
- Parameters:
fn – filename without extension – ‘.png’ will be added
mpl – save as matplotlib image
ds – Ticks size for matplotlib image
- Returns:
list of tuple ((filename, ds), viewer_name)
- assembly_images(all_images, mode: Literal['horizontal', 'vertical', 'square'] = 'square')[source]
Assembly images
Every image has the same size (width, height)
- Parameters:
all_images – list of tuple (filename, viewer_name)
mode – ‘horizontal’, ‘vertical’, ‘square’
- _ADD_FILTER_ARRAY = 'All supported formats|*.bin;*.tif;*.tiff;*.top;*.flt;*.npy;*.npz;*.vrt|bin...[source]
- _ADD_FILTER_VECTOR = 'All supported formats|*.vec;*.vecz;*.dxf;*.shp|vec (*.vec)|*.vec|vecz (*.vecz)|*.vecz|dxf...[source]
- _ADD_FILTER_CLOUD = 'All supported formats|*.xyz;*.laz;*.las;*.json|xyz (*.xyz)|*.xyz|laz (*.laz)|*.laz|las...[source]
- _ADD_FILTER_TRI = "tri (*.tri)|*.tri|text (*.txt)|*.txt|dxf (*.dxf)|*.dxf|gltf (*.gltf)|*.gltf|gltf binary...[source]
- _ADD_FILTER_CS = 'vecz WOLF (*.vecz)|*.vecz|txt 2022 (*.txt)|*.txt|WOLF (*.sxy)|*.sxy|text 2000...[source]
- add_object(which: Literal['array', 'array_lidar_first', 'array_lidar_second', 'array_xyz', 'array_tiles', 'bridges', 'weirs', 'vector', 'tiles', 'tilescomp', 'cloud', 'laz', 'clouds', 'triangulation', 'cross_sections', 'other', 'views', 'res2d', 'res2d_gpu', 'particlesystem', 'wmsback', 'wmsfore', 'drowning', 'imagestiles', 'dike', 'injector', 'picture_collection'] = 'array', filename='', newobj=None, ToCheck=True, id='')[source]
Add object to current Frame/Drawing area.
- _prompt_file_for_type(which: str)[source]
Show a file or directory dialog for which. Returns (filename, curfilter) or None on cancel.
- _resolve_object_id(id: str, filename: str, all_ids: list) str[source]
Prompt for ID when blank; ensure the result is unique across all loaded objects.
- _register_object_in_tree(newobj, curtree, id: str, ToCheck: bool, filename: str) None[source]
Assign idx, insert into treelist, and handle post-registration side-effects.
- add_pie_asset(*args, **kwargs) Zones | PieZonesController[source]
- add_bar_asset(*args, **kwargs) Zones | BarZonesController[source]
- add_curve_asset(*args, **kwargs) Zones | CurveZonesController[source]
- replace_object(id: str, newobj, drawing_type: wolfhece._pydraw_utils.draw_type = None)[source]
Replace an object in the list of objects of type drawing_type
- get_treeitem_from_id(id: str, drawing_type: wolfhece._pydraw_utils.draw_type = None)[source]
Find the tree item associated with id
- get_treeitem_from_obj(obj)[source]
Find the tree item associated with obj.
Alias for “gettreeitem”.
- getobj_from_id(id: str, drawing_type: wolfhece._pydraw_utils.draw_type = None)[source]
Find the object associated with id
- get_obj_from_id(id: str, drawing_type: wolfhece._pydraw_utils.draw_type = None)[source]
Find the object associated with id in a specifid drawtype
If you want to search in all drawtypes, use getobj_from_id instead.
- Parameters:
id – str : id of the object
drawtype – draw_type : type of object to search
- _get_list(drawing_type: wolfhece._pydraw_utils.draw_type = None)[source]
return the list of objects of type drawing_type
- get_list_keys(drawing_type: wolfhece._pydraw_utils.draw_type = None, checked_state: bool = True)[source]
Create a list of keys of type draw_type.
Return a list of keys (idx) in LOWER CASE of objects of type draw_type.
- Parameters:
drawing_type – type of object to search - If None, return all objects
checked_state – if True/False, return only keys of objects that are plotted or not. None return all objects.
- get_list_ids(drawing_type: wolfhece._pydraw_utils.draw_type = None, checked_state: bool = True)[source]
Alias for get_list_keys
- get_list_objects(drawing_type: wolfhece._pydraw_utils.draw_type = None, checked_state: bool = True)[source]
Create a list of objects of type draw_type.
Return a list of keys (idx) in LOWER CASE of objects of type draw_type.
- Parameters:
drawing_type – type of object to search – If None, return all objects.
checked_state – if True/False, return only objects that are plotted or not. None return all objects.
- single_choice_key(draw_type: WolfMapViewer.single_choice_key.draw_type, checked_state: bool = True, message: str = _('Make a choice'), title: str = _('Choice'))[source]
Create wx dialog to choose a key object of type draw_type
- single_choice_object(draw_type: WolfMapViewer.single_choice_object.draw_type, checked_state: bool = True, message: str = _('Make a choice'), title: str = _('Choice'))[source]
Create wx dialog to choose an object of type draw_type
- multiple_choice_key(draw_type: WolfMapViewer.multiple_choice_key.draw_type, checked_state: bool = True, message: str = _('Make a choice'), title: str = _('Choice'))[source]
Create wx dialog to choose multiple keys object of type draw_type
- multiple_choice_object(draw_type: WolfMapViewer.multiple_choice_object.draw_type, checked_state: bool = True, message: str = _('Make a choice'), title: str = _('Choice'))[source]
Create wx dialog to choose multiple objects of type draw_type
- iterator_over_objects(drawing_type: wolfhece._pydraw_utils.draw_type, checked_state: bool = True)[source]
Create iterator over objects of type draw_type
- removeobj_from_id(id: str, draw_type: WolfMapViewer.removeobj_from_id.draw_type = None)[source]
Remove object from id
- _on_tree_motion(e: wx.dataview.wx.MouseEvent)[source]
Detect drag start, update cursor and draw drop indicator.
- _move_obj_to(src_item, src_obj, target_item, before=False)[source]
Move src_item before or after target_item in the tree and lists.
Both items must share the same parent (category).
- OnShowPopup(event)[source]
Deprecated — context menu is now built and shown directly by OntreeRight.
- OnPopupItemSelected(event)[source]
Deprecated — event routing is now handled by direct wx.EVT_MENU bindings in OntreeRight.
- set_active_profile(active_profile: wolfhece.PyCrosssections.profile)[source]
This method sets the active profile in Pydraw (useful for interfaces communication).
- set_active_vector(active_vector: wolfhece.PyVertexvectors.vector)[source]
This method sets the active vector in Pydraw (useful for interfaces communication).
- get_active_profile()[source]
This methods returns the active profile in pydraw (useful for interfaces communication).
- _bridge_gltf_dialog(x: float, y: float) None[source]
wx dialog workflow for BRIDGE_GLTF (called from the mouse handler).
- _ensure_notebookcs() None[source]
Create or show the cross-section notebook (shared by SET_1D_PROFILE and SELECT_NEAREST_PROFILE).
- _set_1d_profile_rdown(x: float, y: float) None[source]
Logic for SET_1D_PROFILE right-click (called from the mouse handler).
- _select_nearest_profile_rdown(x: float, y: float) None[source]
Logic for SELECT_NEAREST_PROFILE right-click (called from the mouse handler).
- _wx_mouse_context(e: wx.dataview.wx.MouseEvent) wolfhece._viewer_plugin_handlers.MouseContext[source]
- _wx_keyboard_snapshot(e: wx.dataview.wx.KeyEvent) wolfhece._viewer_plugin_handlers.KeyboardSnapshot[source]
Build a
KeyboardSnapshotfrom a raw wx.KeyEvent.
- schedule_once(delay_ms: int, fn) None[source]
Run fn() once after delay_ms milliseconds (wx.CallLater wrapper).
- On_Mouse_Right_Down(e: wx.dataview.wx.MouseEvent)[source]
Event when the right button of the mouse is pressed.
We use this event to manage “action” set by others objects.
- _iter_clip_sliders()[source]
Yield all (clip_zone, slider) from checked arrays, 2D results and vectors.
- _get_nearest_clip_slider(world_x: float, world_y: float)[source]
Return the nearest slider label if cursor is close, else ‘’.
- _try_start_clip_slider_drag(world_x: float, world_y: float) bool[source]
If a slider bar is under the cursor, start dragging it.
- Returns:
Trueif a drag was started (caller should skip normal handling).
- _update_clip_slider_drag(world_x: float, world_y: float) bool[source]
Update the active slider position during a drag.
- Returns:
Trueif a drag is in progress.
- _is_heavy_gl_action_active() bool[source]
Return True when an interaction is likely to stress OpenGL drawing.
- _plot_mouse_xy_overlay() None[source]
Draw current world XY near the cursor directly on the OpenGL canvas.
- _plot_distance_overlay() None[source]
Draw cumulative distance near the cursor, stacked below/above the XY overlay.
- _check_active(**slot_messages: str | None) bool[source]
Vérifie que chaque slot actif nommé est non-None.
Log un warning pour chaque slot manquant et retourne False si au moins un slot est absent. Retourne True si tous sont présents.
Passer
Nonecomme message utilise le texte par défaut de_ACTIVE_DEFAULT_MSG.Usage:
# message explicite if not self._check_active( active_array=_('No active array -- Please activate one first'), ): return # message par défaut (None) if not self._check_active(active_array=None, active_vector=None): return
- SetActiveCloud(cloud: wolfhece.PyVertexvectors.cloud_vertices | None)[source]
Set the active cloud of vertices, and update the tooltip if needed
- _update_tooltip()[source]
Update the tooltip with the values of the active arrays and results at position x,y
- _update_tooltip_position() None[source]
Position the tooltip window after each mouse motion.
Called at the end of On_Mouse_Motion once _update_tooltip() has refreshed the tooltip content. Two modes:
CTRL held — tooltip follows the cursor (CTRL-follow mode).
CTRL released — tooltip is placed at its last stored position (or stacked next to the frame when Shift is held or the position has never been set).
- Autoscale(update_backfore=True)[source]
Redimensionnement de la fenêtre pour afficher tous les objets
- msg_action(which: int = 0)[source]
Message to end action
- Parameters:
which – 0 to start action, 1 to end action
- register_action(action_id: str, *, rdown_handler: _MouseHandler | None = None, motion_handler: _MouseHandler | None = None, ldown_handler: _LeftDownHandler | None = None, key_handler: _KeyHandler | None = None, paint_handler: _PaintHandler | None = None, overload: bool = False) None[source]
Register custom event handlers for action_id on this instance only.
The handlers are looked up before the global dispatch tables, so a plugin can shadow or extend any built-in action without modifying core files.
Typical usage from a Jupyter notebook:
from wolfhece._viewer_plugin_handlers import MouseContext, KeyboardSnapshot def my_rdown(viewer, ctx: MouseContext) -> None: print(f"Click at ({ctx.x:.2f}, {ctx.y:.2f})") def my_key(viewer, kb: KeyboardSnapshot) -> bool: if kb.key_code == ord('C') and kb.ctrl: my_data.clear() return True # consume the event return False def my_paint(viewer) -> None: pass # raw OpenGL drawing here viewer.register_action('my action', rdown_handler=my_rdown, key_handler=my_key, paint_handler=my_paint) viewer.start_action('my action', 'Click on the map…')
- Parameters:
action_id – Lowercase string that identifies the action.
rdown_handler –
(viewer, MouseContext) -> None— right mouse-button press.motion_handler –
(viewer, MouseContext) -> None— mouse motion.ldown_handler –
(viewer, MouseContext) -> None— left mouse-button press.key_handler –
(viewer, KeyboardSnapshot) -> bool— key press. ReturnTrueto consume the event (prevents default).paint_handler –
(viewer) -> None— raw OpenGL drawing hook, called after all data layers, before UI overlays.overload – When
True, the current handler for each slot is saved and automatically restored whenunregister_action()is called. A warning is emitted in both cases whenever an existing handler is replaced.
- unregister_action(action_id: str) None[source]
Remove a previously registered custom action from this instance.
If the action was registered with
overload=True, the previously displaced handlers are automatically restored.- Parameters:
action_id – The action id passed to
register_action().
- start_action(action: str | ActionKind, message: str = '')[source]
Message to start action
- Parameters:
action – name of the action (used to manage the end of the action in “end_action” method)
message – message to print in the log (if empty, the action name will be printed)
- end_action(message: str = '')[source]
Message to end action
- Parameters:
message – message to print in the log (if empty, “End of action” will be printed)
- _endactions()[source]
End of actions
Call when the user double click on the right button of the mouse or press return.
Depending on the action, the method will call differnt routines and refresh the figure.
Each action must call self.end_action() to nullify the action and print a message.
- OnHotKey(e: wx.dataview.wx.KeyEvent)[source]
Gestion des touches clavier – see print_shortcuts for more details
- _hotkey_with_modifier(kb: wolfhece._viewer_plugin_handlers.KeyboardSnapshot) None[source]
Key presses with Ctrl or Alt held.
- _hotkey_bare(kb: wolfhece._viewer_plugin_handlers.KeyboardSnapshot) None[source]
Key presses with no modifier (bare key or Shift only).
- paste_values(fromarray: wolfhece.wolf_array.WolfArray)[source]
Paste selected values from a WolfArray to the active array
- paste_selxy(fromarray: wolfhece.wolf_array.WolfArray)[source]
Paste selected nodes from a WolfArray to the active array
- OntreeRight(e: wx.dataview.wx.MouseEvent)[source]
Gestion du menu contextuel sur l’arbre des objets
Append a Clip zone sub-menu with per-item bindings to popup.
- _update_background_async()[source]
Trigger asynchronous background image updates.
This method is called when viewport bounds change (during panning/zooming). It triggers non-blocking image loads in the background via the AsyncImageLoader. The textures are updated as images are loaded, without blocking the UI.
- _plotting(drawing_type: wolfhece._pydraw_utils.draw_type, checked_state: bool = True)[source]
Drawing objets on canvas
- set_tracking_label(zone_id: int, active: bool)[source]
Register or unregister a zone as having active tracking labels.
- Parameters:
zone_id –
id(zone)of the calling zone.active – True to register, False to unregister.
- property has_tracking_labels: bool[source]
Return True if at least one zone has active tracking labels.
- get_MVP_Viewport_matrix()[source]
Read back the current GL modelview, projection and viewport.
Requires an active OpenGL context. The returned projection matrix has the same byte layout as
mvp(C-contiguous, column-major) because PyOpenGL wrapsglGetFloatvthat way.- Returns:
(modelview, projection, viewport)— each a numpy array, or(None, None, None)when no context is available.
- get_ortho_mvp_c_contiguous() numpy.ndarray | None[source]
Build the 2D orthographic MVP purely from Python attributes.
Uses
self.xmin / xmax / ymin / ymaxand the shared :pyattr:`_ORTHO_NEAR` / :pyattr:`_ORTHO_FAR` planes so the result is always consistent with_set_gl_projection_matrix().- Returns:
np.ndarrayshape(4, 4), dtypefloat32, C-contiguous (numpy rows = OpenGL columns), orNonewhen the current view bounds are degenerate.
- _set_gl_projection_matrix()[source]
Set the fixed-function projection from current view bounds.
Uses the same near/far as
get_ortho_mvp_c_contiguous()so the fixed-function pipeline and shader path always agree.
- property mvp: numpy.ndarray[source]
Model-view-projection matrix (C-contiguous, float32).
Preferred path: pure-Python computation via
get_ortho_mvp_c_contiguous()(no GL context needed).Fallback: GL state readback via
get_MVP_Viewport_matrix()wrapped withnp.ascontiguousarray(requires active context).Last resort: identity matrix.
- property sunposition[source]
Sun position as
glm.vec3derived from altitude/azimuth angles.The position is placed on a large sphere centred on the current view so that the resulting directional light is consistent regardless of pan/zoom.
- property hillshade_multidirectional: bool[source]
Whether multi-directional hillshade (8 azimuths) is active.
- property active_hillshade_params: wolfhece.wolf_array.HillshadeRenderParams[source]
Return the material params that the panel/overlay should read/write.
In sync mode → shared params. In per-array mode → active_array.hillshade_params (fallback to shared). When selected_object is a Wolfresults_2D, returns the first block’s current array params so the panel controls them.
- resolve_hillshade_params(wa) wolfhece.wolf_array.HillshadeRenderParams[source]
Return the material params for a specific WolfArray wa.
Called by the shader upload to get per-array or shared params.
- _propagate_hillshade_to_children()[source]
Copy active hillshade params to every child array.
Handles Wolfresults_2D (via iter_current_arrays) and WolfArrayMB (via myblocks).
- _refresh_hillshade_panel_for_active()[source]
Refresh the hillshade panel controls after the active array changed.
- resizeFrame(w: int, h: int)[source]
Resize the frame
- Parameters:
w – width in pixels
h – height in pixels
- Active_zone(zone: WolfMapViewer.Active_zone.zone)[source]
Active une zone et son parent si existant
- uncheck_id(id=str, unload=True, forceresetOGL=True, askquestion=False)[source]
Uncheck an element from its id
- get_current_zoom()[source]
Get the current zoom
- Returns:
dict with keys ‘center’, ‘xmin’, ‘xmax’, ‘ymin’, ‘ymax’, ‘width’, ‘height’
- class wolfhece.PyDraw.Comp_Type(*args, **kwds)[source]
Bases:
enum.Enum
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- class wolfhece.PyDraw.Compare_Arrays_Results(parent: WolfMapViewer = None, share_cmap_array: bool = False, share_cmap_diff: bool = False)[source]
-
- _check_type(file: pathlib.Path)[source]
Check the type of the file/directory
If it is a file and suffix is empty, it is considered as RES2D. If it is a directory and contains a simul_gpu_results, it is considered as RES2D_GPU. If it is a file and suffix is not empty, it is considered as ARRAYS. A check is done to see if it is a multi-block array.
- update_comp(idx=list[int])[source]
Update Arrays from 2D modellings
- Parameters:
idx – indexes of the time step to update –> steps to read
- set_diff()[source]
Set the differential between the elements and the first one, which is the reference
- class wolfhece.PyDraw.InPaint_waterlevel(parent, title: str = _('Inpainting'), size: tuple[int, int] = (400, 400), mapviewer: WolfMapViewer = None, **kwargs)[source]
Bases:
wx.dataview.wx.Dialog
- class wolfhece.PyDraw.InPaint_array(parent, title: str = _('Inpainting'), size: tuple[int, int] = (400, 400), mapviewer: WolfMapViewer = None, **kwargs)[source]
Bases:
wx.dataview.wx.Dialog