#pragma once #include "../base/Color.h" #include "../base/Geometry.h" #include "global.h" namespace renderive { /// @brief 星座图调制类型。 /// @brief PSK constellation phase-state count. enum class Constellation_Diagram_Type : std::uint8_t { /// @brief 8PSK 星座图。 /// @brief 4PSK constellation, commonly also called QPSK. Psk4 = 4, /// @brief 8PSK constellation. Psk8 = 8, /// @brief 16PSK constellation. Psk16 = 16 }; struct Constellation_Diagram_Private; class Grid; /// @brief I/Q 星座图元。 class LIB_DECL Constellation_Diagram : public Renderable { public: /// @brief 创建 I/Q 星座图元。 Constellation_Diagram(); /// @brief 写入一个 I/Q 点。 void append_point(PointF pos); /// @brief 绑定 I 轴。 PROP(std::shared_ptr, i_axis) /// @brief 绑定 Q 轴。 PROP(std::shared_ptr, q_axis) /// @brief I 轴星座范围。 PROP(Range, i_range) /// @brief Q 轴星座范围。 PROP(Range, q_range) /// @brief 输入点颜色。 PROP(Color, point_color) /// @brief 锚点颜色。 PROP(Color, anchor_color) /// @brief 输入点保留时间。 PROP(int, point_lifetime_ms) /// @brief 星座调制类型。 PROP(Constellation_Diagram_Type, type) /// @brief PSK constellation phase offset in radians. PROP(double, phase_offset_radians) /// @brief 设置坐标轴到星座图中心范围。 void fit_square_to_axes(); struct Builder; private: Constellation_Diagram_Private* d(); Render_Object_Owner create_render_data() override; Render_Object_Owner create_render_state() override; Render_Object_Owner create_input_data() override; }; struct Constellation_Diagram_Prop { std::weak_ptr i_axis{}; std::weak_ptr q_axis{}; Range i_range{0, 100}; Range q_range{0, 100}; Color point_color = Color::red(); Color anchor_color = Color::yellow(); int point_lifetime_ms = 1000; Constellation_Diagram_Type type = Constellation_Diagram_Type::Psk8; double phase_offset_radians = 0.0; }; /// @brief 星座图构造器。 struct LIB_DECL Constellation_Diagram::Builder : Constellation_Diagram_Prop { PROP_B(std::shared_ptr, parent) PROP_B(std::shared_ptr, i_axis) PROP_B(std::shared_ptr, q_axis) PROP_B(Range, i_range) PROP_B(Range, q_range) PROP_B(Color, point_color) PROP_B(Color, anchor_color) PROP_B(int, point_lifetime_ms) PROP_B(Constellation_Diagram_Type, type) PROP_B(double, phase_offset_radians) /// 创建星座图构造器。 Builder(std::shared_ptr parent, std::shared_ptr i_axis, std::shared_ptr q_axis); /// 构建并返回星座图对象。 std::shared_ptr build(); std::shared_ptr parent{}; }; } // namespace renderive