名称优化

This commit is contained in:
2026-08-02 03:43:39 +08:00
parent d8e023cea7
commit 3d027967b9
109 changed files with 1699 additions and 3979 deletions
+120
View File
@@ -0,0 +1,120 @@
#include <utility>
#include <algorithm>
#include "../Axis/Abs_Axis_p.h"
#include "../base/Memory.h"
#include "Constellation_Diagram_p.h"
namespace renderive {
RENDERIVE_DEFINE_RENDERABLE_BINDING(Constellation_Diagram, Constellation_Diagram_Private, Planisphere_Render_State, Planisphere_Input_Data, "Planisphere")
std::shared_ptr<Axis> Constellation_Diagram::i_axis() {
return d()->edit_state_value(&Planisphere_Render_State::i_axis).lock();
}
void Constellation_Diagram::set_i_axis(std::shared_ptr<Axis> value) {
d()->set_state_value(&Planisphere_Render_State::i_axis, std::weak_ptr<Axis>(value));
}
std::shared_ptr<Axis> Constellation_Diagram::q_axis() {
return d()->edit_state_value(&Planisphere_Render_State::q_axis).lock();
}
void Constellation_Diagram::set_q_axis(std::shared_ptr<Axis> value) {
d()->set_state_value(&Planisphere_Render_State::q_axis, std::weak_ptr<Axis>(value));
}
Range Constellation_Diagram::i_range() {
return d()->edit_state_value(&Planisphere_Render_State::i_range);
}
void Constellation_Diagram::set_i_range(Range value) {
if (value.length() == 0.0)
return;
d()->set_state_value(&Planisphere_Render_State::i_range, std::move(value));
}
Range Constellation_Diagram::q_range() {
return d()->edit_state_value(&Planisphere_Render_State::q_range);
}
void Constellation_Diagram::set_q_range(Range value) {
if (value.length() == 0.0)
return;
d()->set_state_value(&Planisphere_Render_State::q_range, std::move(value));
}
Color Constellation_Diagram::point_color() {
return d()->edit_state_value(&Planisphere_Render_State::point_color);
}
void Constellation_Diagram::set_point_color(Color value) {
d()->set_state_value(&Planisphere_Render_State::point_color, std::move(value));
}
Color Constellation_Diagram::anchor_color() {
return d()->edit_state_value(&Planisphere_Render_State::anchor_color);
}
void Constellation_Diagram::set_anchor_color(Color value) {
d()->set_state_value(&Planisphere_Render_State::anchor_color, std::move(value));
}
int Constellation_Diagram::point_lifetime_ms() {
return d()->edit_state_value(&Planisphere_Render_State::point_lifetime_ms);
}
void Constellation_Diagram::set_point_lifetime_ms(int value) {
d()->set_state_value(&Planisphere_Render_State::point_lifetime_ms, std::max(1, value));
}
Constellation_Diagram_Type Constellation_Diagram::type() {
return d()->edit_state_value(&Planisphere_Render_State::type);
}
void Constellation_Diagram::set_type(Constellation_Diagram_Type value) {
d()->set_state_value(&Planisphere_Render_State::type, value);
}
double Constellation_Diagram::phase_offset_radians() {
return d()->edit_state_value(&Planisphere_Render_State::phase_offset_radians);
}
void Constellation_Diagram::set_phase_offset_radians(double value) {
d()->set_state_value(&Planisphere_Render_State::phase_offset_radians, value);
}
void Constellation_Diagram::append_point(PointF pos) {
if (!ok())
return;
Render_Input_Lease<Constellation_Diagram_Private, Planisphere_Input_Data> input(d());
input->push(pos);
}
Constellation_Diagram::Builder::Builder(std::shared_ptr<Renderable> parent, std::shared_ptr<Axis> i_axis, std::shared_ptr<Axis> q_axis) {
ASSERT(parent, "Planisphere build error! parent == nullptr");
ASSERT(i_axis && q_axis, "Planisphere build error! axis == nullptr");
ASSERT(i_axis->attached_to_plot(), "Planisphere build error! i_axis->plot == nullptr");
ASSERT(i_axis->shares_plot_with(*q_axis), "Planisphere build error! i_axis->plot != q_axis->plot");
ASSERT(parent->shares_plot_with(*i_axis), "Planisphere build error! parent->plot != axis->plot");
ASSERT(i_axis->orientation() != q_axis->orientation(), "Planisphere build error! axes must be orthogonal");
this->parent = parent;
this->i_axis = i_axis;
this->q_axis = q_axis;
}
std::shared_ptr<Constellation_Diagram> Constellation_Diagram::Builder::build() {
auto ret = renderive::make_shared<Constellation_Diagram>();
ret->init(parent);
Constellation_Diagram_Private* pd = ret->d();
Planisphere_Render_State* sc = reinterpret_cast<Planisphere_Render_State*>(pd->state(State_Edit));
PROP_R(std::weak_ptr<Axis>, i_axis)
PROP_R(std::weak_ptr<Axis>, q_axis)
PROP_R(Range, i_range)
PROP_R(Range, q_range)
PROP_R(Color, point_color)
PROP_R(Color, anchor_color)
PROP_R(int, point_lifetime_ms)
PROP_R(Planisphere_Type, type)
PROP_R(double, phase_offset_radians)
if (sc->i_range.length() == 0.0)
sc->i_range = {0.0, 1.0};
if (sc->q_range.length() == 0.0)
sc->q_range = {0.0, 1.0};
sc->point_lifetime_ms = std::max(1, sc->point_lifetime_ms);
return ret;
}
void Constellation_Diagram::fit_square_to_axes() {
Planisphere_Render_State* s = reinterpret_cast<Planisphere_Render_State*>(d()->state(State_Edit));
auto i_axis = s->i_axis.lock();
auto q_axis = s->q_axis.lock();
if (!i_axis || !q_axis)
return;
double w = i_axis->pixel_length(), h = q_axis->pixel_length();
if (w <= 0.0 || h <= 0.0)
return;
double l = w < h ? w : h;
double i_l = i_axis->coord_range().size() / w * l / 2;
double q_l = q_axis->coord_range().size() / h * l / 2;
double im = i_axis->coord_range().center(), qm = q_axis->coord_range().center();
set_i_range({im - i_l, im + i_l});
set_q_range({qm - q_l, qm + q_l});
}
} // namespace renderive