55 lines
3.1 KiB
C++
55 lines
3.1 KiB
C++
#pragma once
|
|
#include "../axis/Axis.hpp"
|
|
#include "../render/Blend2D_Cache.hpp"
|
|
#include "../scene/Render_Scene_2D.hpp"
|
|
#include "Plot_Types.hpp"
|
|
#include <expected>
|
|
#include <memory>
|
|
#include <memory_resource>
|
|
#include <span>
|
|
#include <vector>
|
|
namespace aethera::render_2d {
|
|
struct Sweep_Spectrum : Def<Sweep_Spectrum, Renderable, Tagged_Buffer<Color_Cache, Blend2D_Cache>> {
|
|
using Scene_Object = Impl<Render_Scene_2D>;
|
|
using Frequency_Object = Impl<Frequency_Axis>;
|
|
using Power_Object = Impl<Numeric_Axis>;
|
|
struct Prop : Prev_Prop {
|
|
Axis_Range frequency_range{}; /* 全部扫描块覆盖的频率范围。 */
|
|
std::size_t bins_per_block{}; /* 每个扫描块期望的功率点数;零值接受首块尺寸。 */
|
|
std::size_t block_count{1}; /* 最多保留的扫描块数;零值按 1 处理。 */
|
|
Plot_Partition_Mode partition_mode{Plot_Partition_Mode::automatic}; /* Prepare 子图分块策略。 */
|
|
Plot_Partition_Count partition_count{1}; /* fixed 模式分块数。 */
|
|
Pen pen{Color::yellow()}; /* 扫频折线样式。 */
|
|
Pen current_frequency_pen{Color::red_color(), 2.0}; /* 当前扫频位置垂线样式。 */
|
|
bool visible_range_only{true}; /* 是否裁掉频率轴可见范围外的线段。 */
|
|
Line_Interpolation_Mode interpolation_mode{Line_Interpolation_Mode::linear_value}; /* 相邻功率点插值方式。 */
|
|
std::vector<std::vector<Plot_Value>> blocks{}; /* 已提交扫描块的唯一权威集合。 */
|
|
bool operator==(const Prop&) const;
|
|
};
|
|
struct State : Prev_State {
|
|
std::size_t stored_block_count{}; /* 当前发布的扫描块数。 */
|
|
std::size_t stored_point_count{}; /* 当前发布的扫描点总数。 */
|
|
std::size_t rendered_point_count{}; /* 最近一次 Prepare 生成的曲线点数。 */
|
|
bool operator==(const State&) const;
|
|
};
|
|
struct Private;
|
|
template <typename Object>
|
|
struct Builder : Prev_Builder<Object> {
|
|
using Base = Prev_Builder<Object>;
|
|
Builder(Scene_Object* scene, Frequency_Object* frequency_axis, Power_Object* power_axis);
|
|
[[nodiscard]] std::expected<std::unique_ptr<Object>, Dependency_Graph_Error> build();
|
|
private:
|
|
Scene_Object* scene{}; /* 不拥有的所属 Scene。 */
|
|
Frequency_Object* frequency_axis{}; /* 不拥有的频率轴。 */
|
|
Power_Object* power_axis{}; /* 不拥有的功率轴。 */
|
|
};
|
|
void append_block(std::span<const Plot_Value> values);
|
|
void append_block(std::pmr::vector<Plot_Value>&& values);
|
|
template <typename Values> void append_block(const Values& values);
|
|
[[nodiscard]] std::size_t stored_block_count() const;
|
|
[[nodiscard]] std::size_t stored_point_count() const;
|
|
[[nodiscard]] std::size_t rendered_point_count() const;
|
|
};
|
|
}
|
|
#include "Sweep_Spectrum.ipp"
|