|
Harmony
HARMONic stabilitY assessment of PE-penetrated power systems
|
Implementation of Interactive ImGui/ImPlot visualization for solver results. More...
#include "Constants.h"#include "Visualization.h"#include "ui/harmony_banner_gui.h"#include "stb_image_write.h"
Macros | |
| #define | STB_IMAGE_WRITE_IMPLEMENTATION |
Functions | |
| static void | glfw_error_callback (int error, const char *desc) |
| static void | init_gui () |
| static void | draw_plot_tabs (const char *tabBarId) |
| static void | gui_loop () |
| static void | ensure_running () |
| static void | add_tab (const std::string &title, std::function< void()> fn) |
| void | visualization_set_embedded_mode (const bool enabled) |
| Use the host ImGui/GLFW context (HarmonyUI) instead of a background window. | |
| void | visualization_stop () |
| Closes the visualization window and stops the GUI thread. | |
| bool | visualization_is_running () |
| Returns whether the visualization window is currently open. | |
| bool | visualization_has_tabs () |
| Returns whether plot tabs are registered. | |
| void | visualization_clear_tabs () |
| Remove all registered plot tabs (e.g. | |
| void | visualization_draw_embedded (const char *tabBarId) |
| Draw plot tabs inside the current ImGui window (embedded / HarmonyUI mode). | |
| void | visualization_process_pending_save (GLFWwindow *window) |
Capture a pending PNG save after ImGui::Render() on window. | |
| void | visualization_wait () |
| Block until the window is closed by the user. | |
| void | visualization_save_tab (const std::string &tab_title, const std::filesystem::path &output_dir) |
| Schedule a PNG capture of the named tab on the next rendered frame. | |
| std::vector< std::string > | visualization_tab_titles () |
| Titles of tabs currently registered in the visualization window. | |
| void | add_plot_tab (const std::string &title, std::function< void()> fn) |
| Public interface used by external modules (e.g. viz_opf). | |
| void | bode_plot_implot (const std::vector< double > &freq, const std::vector< std::vector< double > > &mag_dB, const std::vector< std::vector< double > > &phase_deg, const std::vector< std::string > &labels, const std::string &title) |
| Opens a Bode magnitude/phase plot in the visualization window. | |
| void | nyquist_plot_implot (const std::vector< std::vector< std::complex< double > > > &H_data, const std::vector< std::string > &labels, const std::string &title) |
| Opens a Nyquist plot in the visualization window. | |
| void | plot_eigenvalues_implot (const std::vector< std::complex< double > > &eigvals, const std::string &title) |
| Plots eigenvalues in the complex plane. | |
| void | plot_participation_factors_implot (const std::vector< std::vector< double > > &P, const std::vector< std::string > &state_labels, const std::vector< std::string > &mode_labels, const std::string &title) |
| Plots participation factor heatmap (states vs modes). | |
| void | plot_abc_waveforms_implot (const std::vector< double > &t, const Eigen::MatrixXd &Xabc, const std::string &title) |
| Plots three-phase abc waveforms over time. | |
| void | plot_abc_groups_implot (const std::vector< double > &t, const std::vector< Eigen::MatrixXd > &Xabc_groups, const std::string &title) |
| Plots multiple abc waveform groups on shared axes. | |
| void | viz_opf (const OPFVisualData &d) |
| Registers an "AC/DC OPF" network diagram tab in the visualization window. | |
Implementation of Interactive ImGui/ImPlot visualization for solver results.
| #define STB_IMAGE_WRITE_IMPLEMENTATION |
| void add_plot_tab | ( | const std::string & | title, |
| std::function< void()> | fn | ||
| ) |
Public interface used by external modules (e.g. viz_opf).
Registers a custom ImGui/ImPlot draw callback as a new tab.
References add_tab().
|
static |
| void bode_plot_implot | ( | const std::vector< double > & | freq, |
| const std::vector< std::vector< double > > & | mag_dB, | ||
| const std::vector< std::vector< double > > & | phase_deg, | ||
| const std::vector< std::string > & | labels, | ||
| const std::string & | title | ||
| ) |
Opens a Bode magnitude/phase plot in the visualization window.
| freq | Frequency axis (Hz). |
| mag_dB | Magnitude in dB, one vector per trace. |
| phase_deg | Phase in degrees, one vector per trace. |
| labels | Trace legend labels. |
| title | Plot window title. |
References add_tab(), j, and kHarmonyPlotPanelHeightPx.
Referenced by StabilityEstimate::bodeplotTF(), and Element::plotYParameters().
|
static |
Referenced by gui_loop(), and visualization_draw_embedded().
|
static |
References gui_loop().
Referenced by add_tab().
|
static |
Referenced by init_gui().
|
static |
References draw_plot_tabs(), and init_gui().
Referenced by ensure_running().
|
static |
References glfw_error_callback(), and harmonyConfigurePlotUi().
Referenced by gui_loop().
| void nyquist_plot_implot | ( | const std::vector< std::vector< std::complex< double > > > & | H_data, |
| const std::vector< std::string > & | labels, | ||
| const std::string & | title | ||
| ) |
Opens a Nyquist plot in the visualization window.
| H_data | Complex frequency response, one vector per trace. |
| labels | Trace legend labels. |
| title | Plot window title. |
Referenced by StabilityEstimate::nyquistplotTF().
| void plot_abc_groups_implot | ( | const std::vector< double > & | t, |
| const std::vector< Eigen::MatrixXd > & | Xabc_groups, | ||
| const std::string & | title | ||
| ) |
Plots multiple abc waveform groups on shared axes.
| t | Time axis (s). |
| Xabc_groups | One 3N matrix per signal group. |
| title | Plot window title. |
References add_tab(), and kHarmonyPlotWaveformHeightPx.
Referenced by example_DQsym_DSSS2(), example_DQsym_RLC(), and DQsym::plot().
| void plot_abc_waveforms_implot | ( | const std::vector< double > & | t, |
| const Eigen::MatrixXd & | Xabc, | ||
| const std::string & | title | ||
| ) |
Plots three-phase abc waveforms over time.
| t | Time axis (s). |
| Xabc | Waveform matrix (3 rows N samples). |
| title | Plot window title. |
References add_tab().
Referenced by example_DQsym_math_operations().
| void plot_eigenvalues_implot | ( | const std::vector< std::complex< double > > & | eigvals, |
| const std::string & | title | ||
| ) |
Plots eigenvalues in the complex plane.
| eigvals | List of eigenvalues. |
| title | Plot window title. |
References add_tab(), and kHarmonyPlotEigenHeightPx.
Referenced by Converter::plotEigenvalues().
| void plot_participation_factors_implot | ( | const std::vector< std::vector< double > > & | P, |
| const std::vector< std::string > & | state_labels, | ||
| const std::vector< std::string > & | mode_labels, | ||
| const std::string & | title | ||
| ) |
Plots participation factor heatmap (states vs modes).
| P | Participation factor matrix [state][mode]. |
| state_labels | Row labels (state names). |
| mode_labels | Column labels (mode indices/names). |
| title | Plot window title. |
Referenced by Converter::plotParticipationFactors().
| void visualization_clear_tabs | ( | ) |
Remove all registered plot tabs (e.g.
before a new run).
| void visualization_draw_embedded | ( | const char * | tabBarId | ) |
Draw plot tabs inside the current ImGui window (embedded / HarmonyUI mode).
References draw_plot_tabs().
| bool visualization_has_tabs | ( | ) |
Returns whether plot tabs are registered.
| bool visualization_is_running | ( | ) |
Returns whether the visualization window is currently open.
Referenced by runJsonSimulation().
| void visualization_process_pending_save | ( | GLFWwindow * | window | ) |
Capture a pending PNG save after ImGui::Render() on window.
Referenced by runHarmonyLauncher().
| void visualization_save_tab | ( | const std::string & | tab_title, |
| const std::filesystem::path & | output_dir | ||
| ) |
Schedule a PNG capture of the named tab on the next rendered frame.
Schedules a PNG capture of the named tab on the next rendered frame.
The file is written as "<tab_title>.png" in the working directory. Thread-safe: can be called from any thread.
| void visualization_set_embedded_mode | ( | bool | enabled | ) |
Use the host ImGui/GLFW context (HarmonyUI) instead of a background window.
Call before any simulation runs. Prevents a second GLFW/ImGui context that can crash with ImGui focus-scope errors.
Referenced by runHarmonyLauncher().
| void visualization_stop | ( | ) |
Closes the visualization window and stops the GUI thread.
Referenced by runHarmonyLauncher().
| std::vector< std::string > visualization_tab_titles | ( | ) |
Titles of tabs currently registered in the visualization window.
| void visualization_wait | ( | ) |
Block until the window is closed by the user.
Blocks until the user closes the visualization window.
Referenced by runJsonSimulation().
| void viz_opf | ( | const OPFVisualData & | data | ) |
Registers an "AC/DC OPF" network diagram tab in the visualization window.
Opens an interactive AC/DC OPF network diagram.
Returns immediately; the window stays open until the user closes it or visualization_stop() / visualization_wait() is called.
| data | OPF topology and solved bus/branch quantities. |
References add_tab(), OPFVisualData::baseMVA_ac, OPFVisualData::baseMW_dc, OPFVisualData::branch_dc, OPFVisualData::branch_entire_ac, OPFVisualData::bus_dc, OPFVisualData::bus_entire_ac, OPFVisualData::conv_dc, OPFVisualData::gen_entire_ac, j, OPFVisualData::nbuses_ac, OPFVisualData::nconvs_dc, OPFVisualData::ngens_ac, OPFVisualData::ngrids, OPFVisualData::pgen_ac_k, OPFVisualData::pij_ac_k, OPFVisualData::pij_dc_k, OPFVisualData::pol_dc, OPFVisualData::ps_dc_k, OPFVisualData::qgen_ac_k, OPFVisualData::qij_ac_k, OPFVisualData::qs_dc_k, OPFVisualData::vn2_ac_k, and OPFVisualData::vn2_dc_k.
Referenced by PowerFlow::solve_opf().