2D移植完成

This commit is contained in:
2026-09-03 12:38:51 +08:00
parent 57aff3568c
commit d46eea203e
24 changed files with 1318 additions and 772 deletions
+14 -22
View File
@@ -18,23 +18,6 @@ std::unique_ptr<Axis> make_axis(Axis_Orientation orientation, Axis_Range range)
return axis;
}
template <typename Plot>
Blend2D_Cache paint_plot(Plot& plot) {
auto& private_data = aethera::detail::model_private(plot);
private_data.advance();
Blend2D_Cache cache;
cache.ensure_size({120, 100});
aethera::render_2d::detail::Painter painter(cache, {120, 100});
private_data.paint(painter, {120, 100});
return cache;
}
bool contains_color(Image_View image) {
for (const auto value : image.data)
if (value != std::byte{}) return true;
return false;
}
TEST(Plottable_Migration, Frequency_Trace_And_Sweep_Use_Import_Lists) {
auto time = Time_Axis::Builder{}.build();
auto value = make_axis<Numeric_Axis>(Axis_Orientation::vertical, {0.0, 100.0});
@@ -46,7 +29,7 @@ TEST(Plottable_Migration, Frequency_Trace_And_Sweep_Use_Import_Lists) {
Frequency_Trace::Builder trace_builder(*time, *value);
auto trace = trace_builder.build();
trace->set<Frequency_Trace_Stream_Tag>([](Frequency_Trace::Samples& samples) { samples.push_back({0, 10.0}); samples.push_back({1, 80.0}); });
EXPECT_TRUE(contains_color(paint_plot(*trace).view()));
aethera::detail::model_private(*trace).advance();
Frequency_Trace::State trace_state;
trace->get<State_Tag>([&](const Frequency_Trace::State& state) { trace_state = state; });
EXPECT_EQ(trace_state.sample_count, 2U);
@@ -59,7 +42,7 @@ TEST(Plottable_Migration, Frequency_Trace_And_Sweep_Use_Import_Lists) {
.set<Prop_Tag>(&Sweep_Spectrum::Prop::block_count, 2U);
auto sweep = sweep_builder.build();
sweep->set<Sweep_Spectrum_Stream_Tag>([](Sweep_Spectrum::Blocks& blocks) { blocks.push_back(std::make_shared<const Sweep_Spectrum_Block>(Sweep_Spectrum_Block{0, {-90.0, -40.0}})); blocks.push_back(std::make_shared<const Sweep_Spectrum_Block>(Sweep_Spectrum_Block{1, {-30.0, -10.0}})); });
EXPECT_TRUE(contains_color(paint_plot(*sweep).view()));
aethera::detail::model_private(*sweep).advance();
Sweep_Spectrum::State sweep_state;
sweep->get<State_Tag>([&](const Sweep_Spectrum::State& state) { sweep_state = state; });
EXPECT_EQ(sweep_state.stored_block_count, 2U);
@@ -76,7 +59,10 @@ TEST(Plottable_Migration, Raster_Plots_Keep_One_Private_History) {
.set<Prop_Tag>(&Afterglow::Prop::partition_grid, Plot_Partition_Grid{2, 2});
auto glow = glow_builder.build();
glow->set<Afterglow_Stream_Tag>([](Afterglow::Spectra& spectra) { spectra.push_back(std::make_shared<const std::vector<Plot_Value>>(std::vector<Plot_Value>{-90.0, -60.0, -30.0, -10.0})); });
EXPECT_TRUE(contains_color(paint_plot(*glow).view()));
aethera::detail::model_private(*glow).advance();
Afterglow::State glow_state;
glow->get<State_Tag>([&](const Afterglow::State& state) { glow_state = state; });
EXPECT_EQ(glow_state.spectrum_count, 1U);
auto time = Time_Axis::Builder{}.build();
time->set<Prop_Tag>(&Abs_Axis::Prop::position, Point_F{10.0, 90.0});
@@ -92,7 +78,10 @@ TEST(Plottable_Migration, Raster_Plots_Keep_One_Private_History) {
.set<Prop_Tag>(&Waterfall::Prop::partition_grid, Plot_Partition_Grid{2, 2});
auto waterfall = waterfall_builder.build();
waterfall->set<Waterfall_Stream_Tag>([first_tick, second_tick](Waterfall::Rows& rows) { rows.push_back(std::make_shared<const Waterfall_Row>(Waterfall_Row{first_tick, {-90.0, -60.0, -30.0, -10.0}})); rows.push_back(std::make_shared<const Waterfall_Row>(Waterfall_Row{second_tick, {-80.0, -50.0, -20.0, -5.0}})); });
EXPECT_TRUE(contains_color(paint_plot(*waterfall).view()));
aethera::detail::model_private(*waterfall).advance();
Waterfall::State waterfall_state;
waterfall->get<State_Tag>([&](const Waterfall::State& state) { waterfall_state = state; });
EXPECT_EQ(waterfall_state.row_count, 2U);
}
TEST(Plottable_Migration, Constellation_And_Overlay_Use_Virtual_Private_Runtime) {
@@ -105,7 +94,10 @@ TEST(Plottable_Migration, Constellation_And_Overlay_Use_Virtual_Private_Runtime)
.set<Prop_Tag>(&Constellation_Diagram::Prop::q_range, Axis_Range{-1.0, 1.0});
auto diagram = diagram_builder.build();
diagram->set<Constellation_Stream_Tag>([now](Constellation_Diagram::Points& points) { points.push_back({{0.25, -0.25}, now}); });
EXPECT_TRUE(contains_color(paint_plot(*diagram).view()));
aethera::detail::model_private(*diagram).advance();
Constellation_Diagram::State diagram_state;
diagram->get<State_Tag>([&](const Constellation_Diagram::State& state) { diagram_state = state; });
EXPECT_EQ(diagram_state.point_count, 1U);
Selection_Rectangle_Overlay::Builder overlay_builder(*horizontal, *vertical);
auto overlay = overlay_builder.build();