#pragma once
#include "Plottable.h"
#include "../axis/Axis.h"
#include <memory_resource>
#include <span>
namespace renderive {
struct Sweep_Spectrum_Properties {
    Range frequency_range{};
    Nonnegative_Count bins_per_block;
    Positive_Count block_count;
    Pen pen{Color::yellow()};
    Pen current_frequency_pen{Color::red(), 2.0};
    bool visible_range_only{true};
    Line_Interpolation_Mode interpolation_mode = Line_Interpolation_Mode::Linear_Value;
};
namespace detail {
class LIB_DECL Sweep_Spectrum_Control : public Plottable_State<Sweep_Spectrum_Properties> {
public:
    Sweep_Spectrum_Control(const Sweep_Spectrum_Properties& properties, renderive_Owner<Axis> frequency_axis, renderive_Owner<Axis> power_axis);
    ~Sweep_Spectrum_Control() override;
    void append_block(std::span<const double> values);
    void append_block(std::pmr::vector<double>&& values);
    template <class Values>
    void append_block(const Values& values) {
        append_block(std::span<const double>(values.data(), values.size()));
    }
    [[nodiscard]] std::size_t stored_block_count() const;
    [[nodiscard]] std::size_t stored_point_count() const;
    [[nodiscard]] std::size_t rendered_point_count() const;
protected:
    void prepare_frame(const Prepare_Render_Context& context) override;
    void paint(Painter& painter, const Paint_Render_Context& context) override;
private:
    struct Impl;
    void publish() override;
};
}
using Sweep_Spectrum = detail::Attach_Plottable<detail::Sweep_Spectrum_Control, Sweep_Spectrum_Properties>;
}
