diff options
Diffstat (limited to 'core/client.cpp')
| -rw-r--r-- | core/client.cpp | 107 |
1 files changed, 50 insertions, 57 deletions
diff --git a/core/client.cpp b/core/client.cpp index 2ca419a..d541129 100644 --- a/core/client.cpp +++ b/core/client.cpp @@ -1,26 +1,25 @@ -// [SECTION] Includes -// [SECTION] Defines -// [SECTION] Status enum -// [SECTION] String comparator declaration -// [SECTION] Trace declarations -// [SECTION] Plot declarations -// [SECTION] Plots -// [SECTION] Heatmap colormap -// [SECTION] Global variables -// [SECTION] String comparator definition -// [SECTION] Trace (base) definition -// [SECTION] TraceNamed definition -// [SECTION] TraceHeatmap definition -// [SECTION] Plot (base) definition -// [SECTION] PlotLines definition -// [SECTION] PlotStacked definition -// [SECTION] PlotHeatmap definition -// [SECTION] Data functions -// [SECTION] GUI functions -// [SECTION] Main functions +// index +// [section] includes +// [section] macros & enums +// [section] string comparator declaration +// [section] trace declarations +// [section] plot declarations +// [section] plots +// [section] global variables +// [section] string comparator definition +// [section] Trace (base) definition +// [section] TraceNamed definition +// [section] TraceHeatmap definition +// [section] Plot (base) definition +// [section] PlotLines definition +// [section] PlotStacked definition +// [section] PlotHeatmap definition +// [section] data functions +// [section] gui functions +// [section] main functions // ---------------------------------------------------------------------------- -// [SECTION] Includes +// [section] includes // ---------------------------------------------------------------------------- #include <arpa/inet.h> #include <GL/glu.h> @@ -41,7 +40,7 @@ #include "logger.c" // ---------------------------------------------------------------------------- -// [SECTION] Defines +// [section] macros & enums // ---------------------------------------------------------------------------- #define COLOR_BLACK ImVec4(0.f, 0.f, 0.f, 1.f) #define FONT_SIZE 12.f @@ -75,9 +74,6 @@ #define DEFVAL_HM_LEFT 0l #define DEFVAL_HM_PIXEL_COUNT 0x400l // must equal HM_PIXEL_COUNT in server.c -// ---------------------------------------------------------------------------- -// [SECTION] Status enum -// ---------------------------------------------------------------------------- enum Status { STATUS_STOPPED, STATUS_RUNNING, @@ -86,14 +82,14 @@ enum Status { }; // ---------------------------------------------------------------------------- -// [SECTION] String comparator declaration +// [section] string comparator declaration // ---------------------------------------------------------------------------- struct StringComparator { bool operator()(const char *a, const char *b) const; }; // ---------------------------------------------------------------------------- -// [SECTION] Trace declarations +// [section] trace declarations // ---------------------------------------------------------------------------- template <class T> struct Trace : public std::vector<T> { @@ -134,7 +130,7 @@ struct TraceHeatmap : public TraceNamed<T> { }; // ---------------------------------------------------------------------------- -// [SECTION] Plot declarations +// [section] plot declarations // ---------------------------------------------------------------------------- typedef int (*AxisFormatter)(double value, char *buff, int size, void *data); @@ -201,7 +197,7 @@ private: }; // ---------------------------------------------------------------------------- -// [SECTION] Plots +// [section] plots // ---------------------------------------------------------------------------- #include "plots.cpp" @@ -282,23 +278,7 @@ std::array g_core_plots_heatmaps = std::to_array<PlotHeatmap>({ }); // ---------------------------------------------------------------------------- -// [SECTION] Heatmap colormap -// ---------------------------------------------------------------------------- -std::array g_hm_colormap = std::to_array<ImVec4>({ - {0.000f, 0.000f, 0.016f, 1.f}, - {0.106f, 0.047f, 0.255f, 1.f}, - {0.290f, 0.047f, 0.420f, 1.f}, - {0.471f, 0.110f, 0.427f, 1.f}, - {0.647f, 0.173f, 0.376f, 1.f}, - {0.812f, 0.267f, 0.275f, 1.f}, - {0.929f, 0.412f, 0.145f, 1.f}, - {0.984f, 0.608f, 0.024f, 1.f}, - {0.969f, 0.820f, 0.239f, 1.f}, - {0.988f, 1.000f, 0.643f, 1.f}, -}); - -// ---------------------------------------------------------------------------- -// [SECTION] Global variables +// [section] global variables // ---------------------------------------------------------------------------- GLFWwindow *g_window; ImGuiIO *g_imgui_io; @@ -355,17 +335,30 @@ std::vector<Plot *> g_plots; Trace<double> g_x_axis_double; Trace<double> g_zero_trace; +std::array g_hm_colormap = std::to_array<ImVec4>({ + {0.000f, 0.000f, 0.016f, 1.f}, + {0.106f, 0.047f, 0.255f, 1.f}, + {0.290f, 0.047f, 0.420f, 1.f}, + {0.471f, 0.110f, 0.427f, 1.f}, + {0.647f, 0.173f, 0.376f, 1.f}, + {0.812f, 0.267f, 0.275f, 1.f}, + {0.929f, 0.412f, 0.145f, 1.f}, + {0.984f, 0.608f, 0.024f, 1.f}, + {0.969f, 0.820f, 0.239f, 1.f}, + {0.988f, 1.000f, 0.643f, 1.f}, +}); + PFNGLCOPYIMAGESUBDATAPROC glCopyImageSubData; // ---------------------------------------------------------------------------- -// [SECTION] String comparator definition +// [section] string comparator definition // ---------------------------------------------------------------------------- bool StringComparator::operator()(const char *a, const char *b) const { return strcmp(a, b) < 0; } // ---------------------------------------------------------------------------- -// [SECTION] Trace (base) definition +// [section] Trace (base) definition // ---------------------------------------------------------------------------- template <class T> Trace<T>::Trace() : std::vector<T>() {} @@ -430,7 +423,7 @@ void Trace<T>::trim_spec(int64_t multiplier) { } // ---------------------------------------------------------------------------- -// [SECTION] TraceNamed definition +// [section] TraceNamed definition // ---------------------------------------------------------------------------- template <class T> TraceNamed<T>::TraceNamed(const char *name, const char *label) : m_name(name), m_label(label) {} @@ -446,7 +439,7 @@ const char *TraceNamed<T>::get_label() const { } // ---------------------------------------------------------------------------- -// [SECTION] TraceHeatmap definition +// [section] TraceHeatmap definition // ---------------------------------------------------------------------------- template <class T> TraceHeatmap<T>::TraceHeatmap(const char *name, const char *name_fmt) : TraceNamed<T>(name, name_fmt) {} @@ -469,7 +462,7 @@ void TraceHeatmap<T>::validate() const { #endif // ---------------------------------------------------------------------------- -// [SECTION] Plot (base) definition +// [section] Plot (base) definition // ---------------------------------------------------------------------------- Plot::Plot(const char *name, const char *section) : m_visible(true), m_name(name), m_section(section) {} @@ -531,7 +524,7 @@ void Plot::render_post(const ImVec2 &frame_size) { } // ---------------------------------------------------------------------------- -// [SECTION] PlotLines definition +// [section] PlotLines definition // ---------------------------------------------------------------------------- PlotLines::PlotLines(const char *name, const char *section, std::vector<const char *> trace_keys) : Plot(name, section), m_trace_keys(trace_keys) {} @@ -549,7 +542,7 @@ void PlotLines::render_internal(const ImVec2 &frame_size) { } // ---------------------------------------------------------------------------- -// [SECTION] PlotStacked definition +// [section] PlotStacked definition // ---------------------------------------------------------------------------- PlotStacked::PlotStacked(const char *name, const char *section, std::vector<const char *> trace_keys) : Plot(name, section), m_trace_keys(trace_keys), m_trace_states(trace_keys.size(), true), m_trace_totals(), m_trace_normals(trace_keys.size()), m_needs_reset(true) {} @@ -651,7 +644,7 @@ void PlotStacked::render_internal(const ImVec2 &frame_size) { } // ---------------------------------------------------------------------------- -// [SECTION] PlotHeatmap definition +// [section] PlotHeatmap definition // ---------------------------------------------------------------------------- PlotHeatmap::PlotHeatmap(const char *name, const char *section, const char *trace_key) : Plot(name, section), m_trace_key(trace_key), m_tex_scale_pow(-1.f), m_tex_scale_high(0.f), m_tex_rendered_last(0), m_rows_rendered(0), m_tex_id(0), m_tex_render(), m_needs_reset(true) {} @@ -797,7 +790,7 @@ void PlotHeatmap::render_post(const ImVec2 &frame_size) { } // ---------------------------------------------------------------------------- -// [SECTION] Data functions +// [section] data functions // ---------------------------------------------------------------------------- int64_t data_max_hm_pixel_pow(void) { return (int64_t)floor(log2((double)(MVEC_SIZE - g_hm_left) / (double)g_hm_pixel_count)); @@ -987,7 +980,7 @@ void data_stop_fetching(void) { } // ---------------------------------------------------------------------------- -// [SECTION] GUI functions +// [section] gui functions // ---------------------------------------------------------------------------- void gui_render_data_input(const char *label, int64_t *target) { assert(target); @@ -1276,7 +1269,7 @@ void gui_render(void) { } // ---------------------------------------------------------------------------- -// [SECTION] Main functions +// [section] main functions // ---------------------------------------------------------------------------- void app_sig_handler(int signo) { (void)signo; |
