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.Memory_View(screen_width, screen_height, xmin, xmax, ymin, ymax)[source]
Memory view
- class wolfhece.PyDraw.Memory_View_encoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]
Bases:
json.JSONEncoder
Memory view encoder
- class wolfhece.PyDraw.Memory_View_decoder(*args, **kwargs)[source]
Bases:
json.JSONDecoder
Memory view decoder
- class wolfhece.PyDraw.Memory_Views[source]
Memory views
- add_view(name: str, screen_width: int, screen_height: int, xmin: float, xmax: float, ymin: float, ymax: float)[source]
Add a new view to the memory views
- zoom_on(name: str, mapviewer: WolfMapViewer)[source]
Zoom on a view
- class wolfhece.PyDraw.Memory_Views_GUI(parent, title, memory_views: Memory_Views, mapviewer: WolfMapViewer)[source]
Bases:
wx.Frame
Memory views GUI
- class wolfhece.PyDraw.draw_type[source]
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- class wolfhece.PyDraw.DragdropFileTarget(window: WolfMapViewer)[source]
Bases:
wx.FileDropTarget
- class wolfhece.PyDraw.Sim_Explorer(parent, title, mapviewer: WolfMapViewer, sim: wolfhece.wolfresults_2D.Wolfresults_2D)[source]
Bases:
wx.Frame
- 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)[source]
Bases:
wx.Frame
Fenêtre de visualisation de données WOLF grâce aux WxWidgets
- property palette_for_copy: wolfhece.PyPalette.wolfpalette[source]
Return the palette for copy from configs
- mybc: list[wolfhece.mesh2d.bc_manager.BcManager][source]
- myvectors: list[wolfhece.PyVertexvectors.Zones][source]
- mytri: list[wolfhece.PyVertexvectors.Triangulation][source]
- myviews: list[wolfhece.wolfresults_2D.views_2D][source]
- mytiles: list[wolfhece.wolf_tiles.Tiles][source]
- mypartsystems: list[wolfhece.lagrangian.particle_system_ui.Particle_system_to_draw][source]
- myviewers3d: list[wolfhece.opengl.py3d.Wolf_Viewer3D][source]
- active_vector: wolfhece.PyVertexvectors.vector[source]
- active_zone: wolfhece.PyVertexvectors.zone[source]
- active_zones: wolfhece.PyVertexvectors.Zones[source]
- active_array: wolfhece.wolf_array.WolfArray[source]
- active_view: wolfhece.pyviews.WolfViews[source]
- active_tri: wolfhece.PyVertexvectors.Triangulation[source]
- active_tile: wolfhece.wolf_tiles.Tiles[source]
- active_particle_system: wolfhece.lagrangian.particle_system_ui.Particle_system_to_draw[source]
- active_viewer3d: wolfhece.opengl.py3d.Wolf_Viewer3D[source]
Menu for triangulations
Menu for cloud points
- get_choices_arrays()[source]
Boîte de dialogue permettant de choisir une ou plusieurs matrices parmi celles chargées
Menu for tiles
Menu for LAZ Data
- get_canvas_bounds(gridsize: float = None)[source]
Retourne les limites de la zone d’affichage
- Returns:
[xmin, ymin, xmax, ymax]
- _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]
Action to perform when the timer is triggered
Menu for 2D simulations
Menu for 2D GPU simulations
Action to perform when menu 2D GPU entry is selected
Action to perform when menu 2D entry is selected
- get_configuration() OpenGL.GLUT.Union[wolfhece.PyConfig.WolfConfiguration, None] [source]
Get global configuration parameters
- 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
- copy_canvasogl(mpl: bool = True, ds: float = 0.0, figsizes=[10.0, 10.0], palette: wolfhece.PyPalette.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
- display_canvasogl(mpl=True, ds=0.0, fig: wolfhece.PyVertexvectors.Figure = None, ax: wolfhece.PyVertexvectors.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.PyVertexvectors.Figure, wolfhece.PyVertexvectors.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
- save_canvasogl(fn: str = '', mpl: bool = True, ds: float = 0.0, dpi: int = 300, add_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êtrte 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: 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…
- 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
- _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
- OnMenubar(event: wx.MenuEvent)[source]
Gestion des clicks sur le menu quel que soit le niveau
- Idée générale :
récupérer le label du menu sur base de l’id de l’event WX passé en argument –> itemlabel
tester le label du menu sur base de la chaîne traduite
a priori appeler une autre routine spécifique au traitement choisi
éviter autant que possible de coder des fonctions directement dans cette routine ce qui la rendrait complexe à lire
- AUTRE POSSIBILITE:
mettre en place un dictionnaire avec key==label, value==action qui se contenterait de tester la présence du label dans les clés et d’appeler l’action
dans ce dernier cas, il faudrait que les routines possèdent idéalement une interface unique
- pop_boundary_manager(which: wolfhece.mesh2d.bc_manager.BcManager)[source]
Pop a boundary condition manager after Destroying
- get_boundary_manager(which: wolfhece.wolf_array.WolfArray)[source]
Get a boundary manager
- 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)
- 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_object(which: Literal[array, array_lidar_first, array_lidar_second, array_xyz, array_tiles, bridges, weirs, wolfhece.PyVertexvectors.vector, tiles, tilescompcloud, triangulation, cross_sections, other, views, res2d, res2d_gpu, particlesystem, wmsback, wmsfore] = 'array', filename='', newobj=None, ToCheck=True, id='')[source]
Add object to current Frame/Drawing area
- get_obj_from_id(id: str, drawtype: draw_type)[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_keys(drawing_type: draw_type, checked_state: bool = True)[source]
Create a list of keys of type draw_type
- get_list_objects(drawing_type: draw_type, checked_state: bool = True)[source]
Create a list of objects of type draw_type
- Parameters:
drawing_type – type of object to search
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: draw_type, checked_state: bool = True)[source]
Create iterator over objects of type draw_type
- 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).
- OnRightDown(e: wx.MouseEvent)[source]
Event when the right button of the mouse is pressed.
We use this event to manage “action” set by others objects.
- _update_mytooltip()[source]
Update the tooltip with the values of the active arrays and results at position x,y
- Autoscale(update_backfore=True)[source]
Redimensionnement de la fenêtre pour afficher tous les objets
- _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.KeyEvent)[source]
Gestion des touches clavier – see print_shortcuts for more details
- 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
- 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
- class wolfhece.PyDraw.Comp_Type[source]
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- 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