全部迁移完成
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
#include <render_2D/plottable/Plottables.hpp>
|
||||
#include <render_2D/scene/Render_Scene_2D.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
#include <array>
|
||||
|
||||
namespace {
|
||||
using namespace aethera;
|
||||
using namespace aethera::render_2d;
|
||||
|
||||
template <typename Object, typename... Args>
|
||||
std::unique_ptr<Object> build_object(Args&&... args) {
|
||||
typename Object::Builder builder(std::forward<Args>(args)...);
|
||||
auto result = builder.build();
|
||||
if (!result) std::terminate();
|
||||
return std::move(result).value();
|
||||
}
|
||||
|
||||
template <typename Axis>
|
||||
void configure_axis(Axis* axis, Axis_Orientation orientation, Point_F position, Axis_Pixel_Length length, Size canvas) {
|
||||
axis->template update_state<&Abs_Axis::State::orientation>(orientation);
|
||||
axis->template update_state<&Abs_Axis::State::position>(position);
|
||||
axis->template update_state<&Abs_Axis::State::pixel_length>(length);
|
||||
axis->template update_state<&Abs_Axis::State::canvas_size>(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(plottable_migration, curve_plots_share_partitioned_rendering) {
|
||||
using Scene = Impl<Render_Scene_2D>;
|
||||
using Frequency = Impl<Frequency_Axis>;
|
||||
using Numeric = Impl<Numeric_Axis>;
|
||||
using Time = Impl<Time_Axis>;
|
||||
using Trace = Impl<Frequency_Trace>;
|
||||
using Sweep = Impl<Sweep_Spectrum>;
|
||||
initialize_runtime(2);
|
||||
const Size canvas{160, 120};
|
||||
auto scene = build_object<Scene>();
|
||||
auto frequency = build_object<Frequency>();
|
||||
auto power = build_object<Numeric>();
|
||||
auto time = build_object<Time>();
|
||||
auto value = build_object<Numeric>();
|
||||
configure_axis(frequency.get(), Axis_Orientation::horizontal, {20.0, 100.0}, 120.0, canvas);
|
||||
configure_axis(power.get(), Axis_Orientation::vertical, {20.0, 100.0}, -80.0, canvas);
|
||||
configure_axis(time.get(), Axis_Orientation::horizontal, {20.0, 100.0}, 120.0, canvas);
|
||||
configure_axis(value.get(), Axis_Orientation::vertical, {20.0, 100.0}, -80.0, canvas);
|
||||
frequency->update_state<&Numeric_Axis::State::coordinate_range>(Axis_Range{0.0, 100.0});
|
||||
power->update_state<&Numeric_Axis::State::coordinate_range>(Axis_Range{-100.0, 0.0});
|
||||
value->update_state<&Numeric_Axis::State::coordinate_range>(Axis_Range{0.0, 100.0});
|
||||
auto trace = build_object<Trace>(scene.get(), time.get(), value.get());
|
||||
auto sweep = build_object<Sweep>(scene.get(), frequency.get(), power.get());
|
||||
trace->update_state<&Frequency_Trace::State::partition_mode>(Plot_Partition_Mode::fixed);
|
||||
trace->update_state<&Frequency_Trace::State::partition_count>(2u);
|
||||
trace->append_sample(0, 10.0);
|
||||
trace->append_sample(1, 50.0);
|
||||
trace->append_sample(2, 90.0);
|
||||
sweep->update_state<&Sweep_Spectrum::State::frequency_range>(Axis_Range{0.0, 100.0});
|
||||
sweep->update_state<&Sweep_Spectrum::State::partition_mode>(Plot_Partition_Mode::fixed);
|
||||
sweep->update_state<&Sweep_Spectrum::State::partition_count>(2u);
|
||||
const std::array<Plot_Value, 4> block{-90.0, -60.0, -30.0, -10.0};
|
||||
sweep->append_block(block);
|
||||
scene->update_state<&Render_Scene_2D::State::viewport>(canvas);
|
||||
scene->activate_view();
|
||||
EXPECT_EQ(scene->render_frame(), Render_Frame_Status::rendered);
|
||||
EXPECT_EQ(trace->sample_count(), 3u);
|
||||
EXPECT_GT(trace->rendered_point_count(), 0u);
|
||||
EXPECT_EQ(sweep->stored_block_count(), 1u);
|
||||
EXPECT_GT(sweep->rendered_point_count(), 0u);
|
||||
}
|
||||
|
||||
TEST(plottable_migration, raster_plots_share_partitioned_color_blocks) {
|
||||
using Scene = Impl<Render_Scene_2D>;
|
||||
using Frequency = Impl<Frequency_Axis>;
|
||||
using Numeric = Impl<Numeric_Axis>;
|
||||
using Time = Impl<Time_Axis>;
|
||||
using Glow = Impl<Afterglow>;
|
||||
using Fall = Impl<Waterfall>;
|
||||
initialize_runtime(2);
|
||||
const Size canvas{160, 120};
|
||||
auto scene = build_object<Scene>();
|
||||
auto frequency = build_object<Frequency>();
|
||||
auto power = build_object<Numeric>();
|
||||
auto time = build_object<Time>();
|
||||
configure_axis(frequency.get(), Axis_Orientation::horizontal, {20.0, 100.0}, 120.0, canvas);
|
||||
configure_axis(power.get(), Axis_Orientation::vertical, {20.0, 100.0}, -80.0, canvas);
|
||||
configure_axis(time.get(), Axis_Orientation::vertical, {20.0, 100.0}, -80.0, canvas);
|
||||
frequency->update_state<&Numeric_Axis::State::coordinate_range>(Axis_Range{0.0, 100.0});
|
||||
power->update_state<&Numeric_Axis::State::coordinate_range>(Axis_Range{-100.0, 0.0});
|
||||
auto glow = build_object<Glow>(scene.get(), frequency.get(), power.get());
|
||||
auto waterfall = build_object<Fall>(scene.get(), frequency.get(), time.get());
|
||||
glow->update_state<&Afterglow::State::frequency_range>(Axis_Range{0.0, 100.0});
|
||||
glow->update_state<&Afterglow::State::power_range>(Axis_Range{-100.0, 0.0});
|
||||
glow->update_state<&Afterglow::State::power_point_size>(16u);
|
||||
waterfall->update_state<&Waterfall::State::frequency_range>(Axis_Range{0.0, 100.0});
|
||||
waterfall->update_state<&Waterfall::State::power_range>(Axis_Range{-100.0, 0.0});
|
||||
const std::array<Plot_Value, 4> row{-90.0, -60.0, -30.0, -10.0};
|
||||
glow->append_spectrum(row);
|
||||
waterfall->append_row(0, row);
|
||||
waterfall->append_row(1, row);
|
||||
scene->update_state<&Render_Scene_2D::State::viewport>(canvas);
|
||||
scene->activate_view();
|
||||
EXPECT_EQ(scene->render_frame(), Render_Frame_Status::rendered);
|
||||
EXPECT_EQ(glow->history_count(), 1u);
|
||||
EXPECT_GT(glow->rendered_cell_count(), 0u);
|
||||
EXPECT_EQ(waterfall->row_count(), 2u);
|
||||
EXPECT_GT(waterfall->rendered_cell_count(), 0u);
|
||||
}
|
||||
|
||||
TEST(plottable_migration, direct_overlay_and_constellation_build_and_render) {
|
||||
using Scene = Impl<Render_Scene_2D>;
|
||||
using Numeric = Impl<Numeric_Axis>;
|
||||
using Diagram = Impl<Constellation_Diagram>;
|
||||
using Overlay = Impl<Selection_Rectangle_Overlay>;
|
||||
initialize_runtime(2);
|
||||
const Size canvas{160, 120};
|
||||
auto scene = build_object<Scene>();
|
||||
auto horizontal = build_object<Numeric>();
|
||||
auto vertical = build_object<Numeric>();
|
||||
configure_axis(horizontal.get(), Axis_Orientation::horizontal, {20.0, 100.0}, 120.0, canvas);
|
||||
configure_axis(vertical.get(), Axis_Orientation::vertical, {20.0, 100.0}, -80.0, canvas);
|
||||
horizontal->update_state<&Numeric_Axis::State::coordinate_range>(Axis_Range{-1.0, 1.0});
|
||||
vertical->update_state<&Numeric_Axis::State::coordinate_range>(Axis_Range{-1.0, 1.0});
|
||||
auto diagram = build_object<Diagram>(scene.get(), horizontal.get(), vertical.get());
|
||||
auto overlay = build_object<Overlay>(scene.get(), horizontal.get(), vertical.get());
|
||||
diagram->update_state<&Constellation_Diagram::State::i_range>(Axis_Range{-1.0, 1.0});
|
||||
diagram->update_state<&Constellation_Diagram::State::q_range>(Axis_Range{-1.0, 1.0});
|
||||
diagram->append_point({0.25, -0.25});
|
||||
scene->update_state<&Render_Scene_2D::State::viewport>(canvas);
|
||||
scene->activate_view();
|
||||
EXPECT_EQ(scene->render_frame(), Render_Frame_Status::rendered);
|
||||
EXPECT_EQ(diagram->point_count(), 1u);
|
||||
EXPECT_EQ(overlay->read_state<Renderable_State_Tag>().prepare_task_count, 0u);
|
||||
EXPECT_EQ(overlay->read_state<Renderable_State_Tag>().paint_task_count, 1u);
|
||||
}
|
||||
Reference in New Issue
Block a user