wolfhece._sim_panels ==================== .. py:module:: wolfhece._sim_panels .. autoapi-nested-parse:: Simulation explorer, video-creation, drowning, animation and DEM/DTM dialog classes extracted from PyDraw.py. 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:class:: Sim_Explorer(parent, title, mapviewer: wolfhece.PyDraw.WolfMapViewer, sim: wolfhece.wolfresults_2D.Wolfresults_2D) Bases: :py:obj:`wx.Frame` .. autoapi-inheritance-diagram:: wolfhece._sim_panels.Sim_Explorer :parts: 1 :private-bases: .. py:attribute:: _panel .. py:attribute:: mapviewer .. py:attribute:: active_res2d :type: wolfhece.wolfresults_2D.Wolfresults_2D .. py:attribute:: _all_times_steps .. py:attribute:: _slider_steps .. py:attribute:: _label_idx .. py:attribute:: _step_idx .. py:attribute:: _label_time .. py:attribute:: _starting_date .. py:attribute:: _texttime .. py:attribute:: _step_time .. py:attribute:: _label_steps .. py:attribute:: _step_num .. py:attribute:: _cmd_apply .. py:attribute:: _cmd_update .. py:attribute:: _cmd_plot .. py:attribute:: _cmd_next .. py:attribute:: _cmd_prev .. py:attribute:: _mode .. py:attribute:: _interval .. py:attribute:: MinSize :value: (450, 500) .. py:method:: OnPlot(event) Create a scatter plot of all steps. Major x_axis is time in seconds, Minor X-axis is time by date. Plots: - Computation time step (Dt) - Computation steps (N) - Clock time (s) - Mostly dry mesh (N) .. py:method:: OnInterval(event) Change the interval .. py:method:: _find_next(idx: int) Find the next step based on the mode and interval .. py:method:: _find_prev(idx: int) Find the previous step based on the mode and interval .. py:method:: OnNext(event) Go to the next step .. py:method:: OnPrev(event) Go to the previous step .. py:method:: OnTextTime(event) .. py:method:: OnClose(event) Close the simulation explorer .. py:method:: OnUpdate(event) .. py:method:: OnApply(event) .. py:method:: _set_all(idx: int) .. py:method:: Refresh(idx: int) .. py:method:: OnSliderSteps(event) .. py:method:: OnSelectCurTime(event) .. py:method:: OnSelectNumStep(event) .. py:method:: OnSelectIdxStep(event) .. py:method:: _update() .. py:class:: Sim_VideoCreation(parent, title, mapviewer: wolfhece.PyDraw.WolfMapViewer, sim: wolfhece.wolfresults_2D.Wolfresults_2D) Bases: :py:obj:`wx.Dialog` .. autoapi-inheritance-diagram:: wolfhece._sim_panels.Sim_VideoCreation :parts: 1 :private-bases: .. py:attribute:: mapviewer .. py:attribute:: active_res2d :type: wolfhece.wolfresults_2D.Wolfresults_2D .. py:attribute:: _framerate :value: 25 .. py:attribute:: _start_step :value: 1 .. py:attribute:: _end_step .. py:attribute:: _interval :value: 1 .. py:attribute:: _fn :value: '' .. py:attribute:: _tz_ref .. py:attribute:: _tz_plot .. py:attribute:: _date_ref .. py:attribute:: _fontsize :value: 16 .. py:attribute:: _fontcolor :value: (255, 255, 255, 255) .. py:attribute:: _timeposition :value: 'top-left' .. py:attribute:: tc1 .. py:attribute:: btn_browse .. py:attribute:: tc2 .. py:attribute:: tc3 .. py:attribute:: tc4 .. py:attribute:: tc5 .. py:attribute:: tc7 .. py:attribute:: tc8 .. py:attribute:: tc9 .. py:attribute:: btn1 .. py:attribute:: btn2 .. py:attribute:: check_date .. py:attribute:: calendar .. py:attribute:: timezone_ref .. py:attribute:: timezone_plot .. py:method:: OnBrowse(event) Browse a file name to save the video .. py:method:: get_values() Return the values set in the dialog .. py:method:: OnValidate(event) Validate the text controls to be sure that the values are correct .. py:method:: OnOk(event) Create the video file .. py:method:: OnCancel(event) Cancel the video creation .. py:class:: Drowning_Explorer(parent, title, mapviewer: any, sim: wolfhece.drowning_victims.drowning_class.Drowning_victim_Viewer) Bases: :py:obj:`wx.Frame` .. autoapi-inheritance-diagram:: wolfhece._sim_panels.Drowning_Explorer :parts: 1 :private-bases: .. py:attribute:: _panel .. py:attribute:: mapviewer .. py:attribute:: active_drowning :type: wolfhece.drowning_victims.drowning_class.Drowning_victim_Viewer .. py:attribute:: _all_times_steps .. py:attribute:: _slider_steps .. py:attribute:: _time_drowning .. py:attribute:: _label_time .. py:attribute:: _starting_date .. py:attribute:: _texttime .. py:attribute:: _step_time .. py:attribute:: _step_idx .. py:attribute:: _cmd_apply .. py:attribute:: _cmd_next .. py:attribute:: _cmd_prev .. py:attribute:: MinSize :value: (450, 500) .. py:method:: _find_next(idx: int) Find the next step based on the mode and interval .. py:method:: _find_prev(idx: int) Find the previous step based on the mode and interval .. py:method:: OnNext(event) Go to the next step .. py:method:: OnTextTime(event) .. py:method:: OnPrev(event) Go to the previous step .. py:method:: OnClose(event) Close the simulation explorer .. py:method:: OnUpdate(event) .. py:method:: OnApply(event) .. py:method:: _set_all(idx: int) .. py:method:: Refresh(idx: int) .. py:method:: OnSliderSteps(event) .. py:method:: OnSelectNumStep(event) .. py:method:: OnSelectIdxStep(event) .. py:method:: _update() .. py:class:: Select_Begin_end_interval_step(parent, title, sim: wolfhece.wolfresults_2D.Wolfresults_2D, checkbox: bool = False) Bases: :py:obj:`wx.Dialog` .. autoapi-inheritance-diagram:: wolfhece._sim_panels.Select_Begin_end_interval_step :parts: 1 :private-bases: wx.frame to select the begin and end of the interval to extract .. py:attribute:: _panel .. py:attribute:: begin :value: 1 .. py:attribute:: end .. py:attribute:: step :value: 1 .. py:attribute:: check_all :value: True .. py:attribute:: check_violin :value: False .. py:attribute:: _slider_begin .. py:attribute:: _slider_end .. py:attribute:: _label_range .. py:attribute:: _text_range .. py:attribute:: _slider_step .. py:attribute:: _label_step .. py:attribute:: _text_step .. py:attribute:: _cmd_apply .. py:attribute:: _cmd_ok .. py:attribute:: _cmd_cancel .. py:method:: OnCheckAll(event) .. py:method:: OnCheckViolin(event) .. py:method:: OnSliderBegin(event) .. py:method:: OnSliderEnd(event) .. py:method:: OnSliderStep(event) .. py:method:: OnApply(event) .. py:method:: OnOK(event) .. py:method:: OnCancel(event) .. py:class:: PrecomputedDEM_DTM(*args, **kwds) Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: wolfhece._sim_panels.PrecomputedDEM_DTM :parts: 1 :private-bases: Enum for Precomputed DEM/DTM array .. py:attribute:: DEMDTM_50cm :value: 'AllData.vrt' .. py:attribute:: DEMDTM_1m_average :value: 'Combine_1m_average.vrt' .. py:attribute:: DEMDTM_1m_min :value: 'Combine_1m_minimum.vrt' .. py:attribute:: DEMDTM_1m_max :value: 'Combine_1m_maximum.vrt' .. py:attribute:: DEMDTM_2m_average :value: 'Combine_2m_average.vrt' .. py:attribute:: DEMDTM_2m_min :value: 'Combine_2m_minimum.vrt' .. py:attribute:: DEMDTM_2m_max :value: 'Combine_2m_maximum.vrt' .. py:attribute:: DEMDTM_5m_average :value: 'Combine_5m_average.vrt' .. py:attribute:: DEMDTM_5m_min :value: 'Combine_5m_minimum.vrt' .. py:attribute:: DEMDTM_5m_max :value: 'Combine_5m_maximum.vrt' .. py:attribute:: DEMDTM_10m_average :value: 'Combine_10m_average.vrt' .. py:attribute:: DEMDTM_10m_min :value: 'Combine_10m_minimum.vrt' .. py:attribute:: DEMDTM_10m_max :value: 'Combine_10m_maximum.vrt' .. py:class:: Precomputed_DEM_DTM_Dialog(parent, title, directory: pathlib.Path | str, mapviewer: wolfhece.PyDraw.WolfMapViewer) Bases: :py:obj:`wx.Dialog` .. autoapi-inheritance-diagram:: wolfhece._sim_panels.Precomputed_DEM_DTM_Dialog :parts: 1 :private-bases: wx.Dialog to select Precomputed DEM/DTM array Resolutions are 50cm, 1m, 2m, 5m, 10m Operators are average, min, max .. py:attribute:: _dir .. py:attribute:: _header :value: None .. py:attribute:: _vrt :value: None .. py:attribute:: _mapviewer .. py:attribute:: _panel .. py:attribute:: _res :value: ['50cm', '1m', '2m', '5m', '10m'] .. py:attribute:: _ops :value: ['average', 'minimum', 'maximum'] .. py:attribute:: _resolution .. py:attribute:: _operations .. py:attribute:: _cmd_sameactive .. py:attribute:: _cmd_sameas .. py:attribute:: _cmd_zoom .. py:method:: OnSameAs(event) Set the Precomputed DEM/DTM array to the same bounds as an existing array .. py:method:: OnSameActive(event) Set the Precomputed DEM/DTM array to the same bounds as the active array .. py:method:: OnZoom(event) Set the Precomputed DEM/DTM array to the current zoom .. py:property:: selected_vrt .. py:method:: add_array() Add a new array to the viewer .. py:method:: OnSelectResolution(event) Select the resolution .. py:method:: available_vrt() List all available vrt files in the directory .. py:class:: GlobalAnimationClock(mapviewer: wolfhece.PyDraw.WolfMapViewer) Global animation clock manager for all zones with animations. Replaces per-zone wx.Timer instances with a single centralized timer. This avoids flooding the wxPython event queue with redundant refresh events when dozens of zones are animated simultaneously. Features: - Single ~30 fps timer for the entire WolfMapViewer - Zones register/unregister their animation needs - Adaptive throttling based on total animation load - On each tick, updates a shared time base and requests one redraw - Automatically stops the timer when no animations are active .. py:attribute:: _FPS_STEPS .. py:attribute:: mapviewer .. py:attribute:: timer :type: wx.Timer | None :value: None .. py:attribute:: subscribed_zones :type: dict[int, int] .. py:attribute:: current_time :type: float :value: 0.0 .. py:attribute:: _timer_start_time :type: float | None :value: None .. py:attribute:: _interval_ms :type: int | None :value: None .. py:property:: total_load :type: int Return the total declared animation load across all zones. .. py:method:: subscribe(zone, load: int = 1) Register a zone as animated with its estimated rendering load. Automatically starts the timer if this is the first subscription. .. py:method:: unsubscribe(zone) Unregister a zone from animation. Automatically stops the timer if this was the last subscription. .. py:method:: _get_target_interval_ms() -> int Return the timer interval based on the current animation load. .. py:method:: _ensure_timer_state() Start, stop, or retune the timer according to current load. .. py:method:: _start_timer(interval_ms: int) Start the global animation timer. .. py:method:: _stop_timer() Stop the global animation timer. .. py:method:: _on_timer_tick(event) Handle timer tick: update time and request canvas refresh. .. py:method:: get_phase(anim_speed: float = 1.0) -> float Compute animation phase for a given speed. :param anim_speed: Animation speed multiplier (default 1.0). :return: Phase in range [0, 1), cycling at rate = anim_speed. .. py:method:: destroy() Clean up the timer and disconnect.