Files
Aethera/render_2D/render_2D/plottable/Constellation_Diagram.hpp
T
2026-08-20 23:04:59 +08:00

43 lines
2.6 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 {
enum class Constellation_Diagram_Type : std::uint8_t { psk4 = 4, psk8 = 8, psk16 = 16 };
struct Constellation_Point { Point_F point{}; Plot_Duration_Milliseconds submitted_at_ms{}; bool operator==(const Constellation_Point&) const; };
struct Constellation_Diagram : Def<Constellation_Diagram, Renderable, Tagged_Buffer<Color_Cache, Blend2D_Cache>> {
using Scene_Object = Impl<Render_Scene_2D>; using Axis_Object = Impl<Numeric_Axis>;
struct Prop : Prev_Prop {
Axis_Range i_range{0.0, 100.0}; /* 同相分量显示范围。 */
Axis_Range q_range{0.0, 100.0}; /* 正交分量显示范围。 */
Color point_color{Color::red_color()}; /* 接收点颜色。 */
Color anchor_color{Color::yellow()}; /* 理想星座锚点颜色。 */
Plot_Duration_Milliseconds point_lifetime_ms{1000}; /* 接收点保留时间,单位为毫秒。 */
Constellation_Diagram_Type type{Constellation_Diagram_Type::psk8}; /* 理想 PSK 锚点数量。 */
Plot_Ratio phase_offset_radians{}; /* 理想锚点相位偏移,单位为弧度。 */
std::vector<Constellation_Point> points{}; /* 已提交且尚未过期的点。 */
bool operator==(const Prop&) const;
};
struct State : Prev_State {
std::size_t point_count{}; /* 当前发布且尚未过期的点数。 */
bool operator==(const State&) const;
};
struct Private;
template <typename Object> struct Builder : Prev_Builder<Object> {
using Base = Prev_Builder<Object>;
Builder(Scene_Object* scene, Axis_Object* i_axis, Axis_Object* q_axis);
[[nodiscard]] std::expected<std::unique_ptr<Object>, Dependency_Graph_Error> build();
private:
Scene_Object* scene{}; /* 不拥有的所属 Scene;生命周期必须覆盖星座图。 */
Axis_Object* i_axis{}; /* 不拥有的同相分量轴;生命周期必须覆盖星座图。 */
Axis_Object* q_axis{}; /* 不拥有的正交分量轴;生命周期必须覆盖星座图。 */
};
void append_point(Point_F point); [[nodiscard]] std::size_t point_count() const; void fit_square_to_axes();
};
}
#include "Constellation_Diagram.ipp"