Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
MiniPlotRenderer.hpp
Go to the documentation of this file.
1// Correlation - Liquid and Amorphous Solid Analysis Tool
2// Copyright © 2013-2026 Isaías Rodríguez (isurwars@gmail.com)
3// SPDX-License-Identifier: AGPL-3.0-only
4// Full license: https://github.com/Isurwars/Correlation/blob/main/LICENSE
5
6#pragma once
7
9#include "math/Precision.hpp"
10
11#include <cstddef>
12#include <cstdint>
13#include <optional>
14#include <span>
15#include <vector>
16
17namespace correlation::render3d {
18
22struct RgbaPixel {
23 uint8_t r{0};
24 uint8_t g{0};
25 uint8_t b{0};
26 uint8_t a{255};
27};
28
33 uint32_t width{0};
34 uint32_t height{0};
35 std::vector<RgbaPixel> pixels;
36};
37
41struct PeakInfo {
42 real_t x{0.0};
43 real_t y{0.0};
44 bool valid{false};
45};
46
51 std::optional<real_t> manual_x_min;
52 std::optional<real_t> manual_x_max;
53 std::optional<real_t> manual_y_min;
54 std::optional<real_t> manual_y_max;
55 bool y_log_scale{false};
56};
57
65public:
67 static constexpr uint32_t K_DEFAULT_WIDTH = 260;
69 static constexpr uint32_t K_DEFAULT_HEIGHT = 130;
70
80 [[nodiscard]] static PlotImageBuffer render(const analysis::MetricCurveData &metric_data,
81 std::optional<std::size_t> frame_idx, uint32_t width,
82 uint32_t height) {
83 return render(metric_data, frame_idx, MiniPlotConfig(), width, height);
84 }
85
95 [[nodiscard]] static PlotImageBuffer render(const analysis::MetricCurveData &metric_data,
96 std::optional<std::size_t> frame_idx = std::nullopt,
97 const MiniPlotConfig &config = MiniPlotConfig(),
98 uint32_t width = K_DEFAULT_WIDTH,
99 uint32_t height = K_DEFAULT_HEIGHT);
100
107 [[nodiscard]] static PeakInfo findPeak(std::span<const real_t> bins,
108 std::span<const real_t> values) noexcept;
109};
110
111} // namespace correlation::render3d
Floating point precision type definitions for Correlation.
High-performance 2D software renderer for distribution mini-charts.
Definition MiniPlotRenderer.hpp:64
static constexpr uint32_t K_DEFAULT_WIDTH
Default canvas width (px).
Definition MiniPlotRenderer.hpp:67
static PeakInfo findPeak(std::span< const real_t > bins, std::span< const real_t > values) noexcept
Finds the primary local maximum peak in a 1D curve.
Definition MiniPlotRenderer.cpp:213
static constexpr uint32_t K_DEFAULT_HEIGHT
Default canvas height (px).
Definition MiniPlotRenderer.hpp:69
static PlotImageBuffer render(const analysis::MetricCurveData &metric_data, std::optional< std::size_t > frame_idx, uint32_t width, uint32_t height)
Renders a 2D mini distribution plot into an RGBA pixel buffer with default configuration.
Definition MiniPlotRenderer.hpp:80
Definition Camera3D.hpp:14
double real_t
Definition Precision.hpp:18
Holds 1D curve data for a specific distribution across an entire trajectory.
Definition PerFrameDistributionStore.hpp:34
Configuration parameters for MiniPlot rendering.
Definition MiniPlotRenderer.hpp:50
bool y_log_scale
Logarithmic (log10) scale on Y.
Definition MiniPlotRenderer.hpp:55
std::optional< real_t > manual_x_min
Optional lower X limit.
Definition MiniPlotRenderer.hpp:51
std::optional< real_t > manual_y_min
Optional lower Y limit.
Definition MiniPlotRenderer.hpp:53
std::optional< real_t > manual_x_max
Optional upper X limit.
Definition MiniPlotRenderer.hpp:52
std::optional< real_t > manual_y_max
Optional upper Y limit.
Definition MiniPlotRenderer.hpp:54
Detected peak position on a 1D distribution profile.
Definition MiniPlotRenderer.hpp:41
real_t y
Amplitude of peak.
Definition MiniPlotRenderer.hpp:43
real_t x
X-axis coordinate of peak.
Definition MiniPlotRenderer.hpp:42
bool valid
True if a valid local maximum was found.
Definition MiniPlotRenderer.hpp:44
Raw RGBA pixel buffer generated by MiniPlotRenderer.
Definition MiniPlotRenderer.hpp:32
std::vector< RgbaPixel > pixels
Pixel array (size = width * height).
Definition MiniPlotRenderer.hpp:35
uint32_t width
Buffer width in pixels.
Definition MiniPlotRenderer.hpp:33
uint32_t height
Buffer height in pixels.
Definition MiniPlotRenderer.hpp:34
Standard 32-bit RGBA pixel representation.
Definition MiniPlotRenderer.hpp:22
uint8_t b
Blue channel (0-255).
Definition MiniPlotRenderer.hpp:25
uint8_t a
Alpha channel (0-255).
Definition MiniPlotRenderer.hpp:26
uint8_t g
Green channel (0-255).
Definition MiniPlotRenderer.hpp:24
uint8_t r
Red channel (0-255).
Definition MiniPlotRenderer.hpp:23