Files
Renderive/render_2D/plottable/Afterglow.h
T
2026-08-12 00:06:44 +08:00

40 lines
1.4 KiB
C++

#pragma once
#include "Plottable.h"
#include "../axis/Axis.h"
#include <memory_resource>
#include <span>
namespace renderive {
struct Afterglow_Properties {
Range frequency_range{0.0, 10.0};
Range power_range{0.0, 10.0};
Nonnegative_Count frequency_point_size;
Nonnegative_Count power_point_size;
bool interpolate = true;
Unit_Interval attenuation_rate{0.2};
Color_Map color_map;
};
namespace detail {
class LIB_DECL Afterglow_Control : public Plottable_State<Afterglow_Properties> {
public:
Afterglow_Control(Plot_Core& plot, const Afterglow_Properties& properties, std::shared_ptr<Frequency_Axis> frequency_axis, std::shared_ptr<Axis> power_axis);
~Afterglow_Control() override;
[[nodiscard]] std::size_t history_count() const;
[[nodiscard]] std::size_t latest_spectrum_point_count() const;
[[nodiscard]] std::size_t rendered_cell_count() const;
void append_spectrum(std::span<const double> values);
void append_spectrum(std::pmr::vector<double>&& values);
template <class Values>
void append_spectrum(const Values& values) {
append_spectrum(std::span<const double>(values.data(), values.size()));
}
protected:
void paint(Painter& painter, const Render_State_View& state) override;
private:
struct Impl;
std::unique_ptr<Impl> impl_;
void publish() override;
};
}
using Afterglow = detail::Attach_Plottable<detail::Afterglow_Control, Afterglow_Properties>;
}