49 lines
2.4 KiB
C++
49 lines
2.4 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 <vector>
|
|
namespace aethera::render_2d {
|
|
struct Frequency_Trace_Sample {
|
|
Plot_Time_Tick tick{}; /* 时间轴上的单调样本序号。 */
|
|
Plot_Value value{}; /* 该时间点对应的频率值。 */
|
|
bool operator==(const Frequency_Trace_Sample&) const;
|
|
};
|
|
struct Frequency_Trace_Stream_Tag {};
|
|
struct Frequency_Trace : Def<Frequency_Trace, Renderable_2D<Renderable_2D_Cache::enabled>,
|
|
Mpmc_Triple_Buffer<Frequency_Trace_Stream_Tag, Frequency_Trace_Sample>> {
|
|
using Scene_Object = Impl<Render_Scene_2D>;
|
|
using Time_Object = Impl<Time_Axis>;
|
|
using Value_Object = Impl<Numeric_Axis>;
|
|
struct Prop : Prev_Prop {
|
|
Plot_Partition_Count partition_count{1}; /* fixed 模式使用的 Prepare 子图分块数。 */
|
|
Pen pen{Color::yellow()}; /* 频率轨迹折线样式。 */
|
|
Plot_Partition_Mode partition_mode{Plot_Partition_Mode::automatic}; /* Prepare 子图分块策略。 */
|
|
bool operator==(const Prop&) const;
|
|
};
|
|
struct State : Prev_State {
|
|
std::size_t sample_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(Time_Object* time_axis, Value_Object* value_axis);
|
|
[[nodiscard]] std::expected<std::unique_ptr<Object>, Dependency_Graph_Error> build();
|
|
private:
|
|
Time_Object* time_axis{}; /* 不拥有的时间轴。 */
|
|
Value_Object* value_axis{}; /* 不拥有的数值轴。 */
|
|
};
|
|
/* 提交同一使用层刚由绑定 Time_Axis::append_time() 分配的 tick;本图元不推进时间轴。 */
|
|
void append_sample(Plot_Time_Tick tick, Plot_Value value);
|
|
[[nodiscard]] std::size_t sample_count() const;
|
|
[[nodiscard]] std::size_t rendered_point_count() const;
|
|
};
|
|
}
|
|
#include "Frequency_Trace.ipp"
|