实时分块控制
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include <render_2D/axis/Axis.hpp>
|
||||
#include <render_2D/base/Frame_2D.hpp>
|
||||
#include <render_2D/plottable/Constellation_Diagram.hpp>
|
||||
#include <render_2D/plottable/Spectrum.hpp>
|
||||
#include <render_2D/plottable/Waterfall.hpp>
|
||||
#include <render_2D/scene/Render_Scene_2D.hpp>
|
||||
#include <process.h>
|
||||
#include <atomic>
|
||||
@@ -34,13 +36,22 @@ bool contains_color(Image_View view) {
|
||||
int main() {
|
||||
using Frequency = Impl<Frequency_Axis>;
|
||||
using Power = Impl<Numeric_Axis>;
|
||||
using Time = Impl<Time_Axis>;
|
||||
using Spectrum_Object = Impl<Spectrum>;
|
||||
using Constellation_Object = Impl<Constellation_Diagram>;
|
||||
using Waterfall_Object = Impl<Waterfall>;
|
||||
using Scene_Object = Impl<Render_Scene_2D>;
|
||||
|
||||
initialize_runtime({.workers = 4});
|
||||
auto* frequency = build_object<Frequency>();
|
||||
auto* power = build_object<Power>();
|
||||
auto* spectrum = build_object<Spectrum_Object>(frequency, power);
|
||||
auto* spectrum = build_object<Spectrum_Object>(frequency, power, 4u);
|
||||
auto* time = build_object<Time>();
|
||||
auto* waterfall = build_object<Waterfall_Object>(
|
||||
frequency, time, Plot_Partition_Grid{2, 2});
|
||||
auto* q_axis = build_object<Power>();
|
||||
auto* constellation = build_object<Constellation_Object>(
|
||||
power, q_axis, 3u);
|
||||
auto* spectrum_painted = new std::atomic_bool{};
|
||||
auto* topology_valid = new std::atomic_bool{true};
|
||||
spectrum->paint_taskflow().add("test.spectrum.paint.complete", [spectrum_painted] {
|
||||
@@ -58,6 +69,8 @@ int main() {
|
||||
|
||||
typename Scene_Object::Builder scene_builder;
|
||||
scene_builder.add_renderable(spectrum);
|
||||
scene_builder.add_renderable(waterfall);
|
||||
scene_builder.add_renderable(constellation);
|
||||
auto scene_result = scene_builder.build();
|
||||
if (!scene_result) return 2;
|
||||
auto* scene = std::move(scene_result).value().release();
|
||||
@@ -71,32 +84,111 @@ int main() {
|
||||
power->set<&Abs_Axis::Prop::orientation>(Axis_Orientation::vertical);
|
||||
power->set<&Numeric_Axis::Prop::coordinate_range>(
|
||||
Axis_Range{-100.0, 0.0});
|
||||
time->set<&Abs_Axis::Prop::position>(Point_F{20.0, 100.0});
|
||||
time->set<&Abs_Axis::Prop::pixel_length>(-80.0);
|
||||
time->set<&Abs_Axis::Prop::orientation>(Axis_Orientation::vertical);
|
||||
time->set<&Time_Axis::Prop::visible_count>(4);
|
||||
q_axis->set<&Abs_Axis::Prop::position>(Point_F{20.0, 100.0});
|
||||
q_axis->set<&Abs_Axis::Prop::pixel_length>(120.0);
|
||||
q_axis->set<&Numeric_Axis::Prop::coordinate_range>(
|
||||
Axis_Range{-1.0, 1.0});
|
||||
spectrum->set<&Spectrum::Prop::frequency_range>(
|
||||
Axis_Range{0.0, 100.0});
|
||||
spectrum->set<&Spectrum::Prop::partition_mode>(
|
||||
Plot_Partition_Mode::fixed);
|
||||
spectrum->set<&Spectrum::Prop::partition_count>(4);
|
||||
spectrum->pending_buffer<Spectrum_Frame_Tag>() =
|
||||
Spectrum_Frame{std::vector<Spectrum_Power>(512, -50.0)};
|
||||
spectrum->mark_dirty<Prepare_Data_Tag>();
|
||||
waterfall->set<&Waterfall::Prop::frequency_range>(
|
||||
Axis_Range{0.0, 100.0});
|
||||
waterfall->set<&Waterfall::Prop::power_range>(
|
||||
Axis_Range{-100.0, 0.0});
|
||||
const Plot_Time_Tick first_tick = time->append_time({1'000});
|
||||
const Plot_Time_Tick second_tick = time->append_time({2'000});
|
||||
waterfall->submit_stream<Waterfall_Stream_Tag>(
|
||||
std::make_shared<const Waterfall_Row>(Waterfall_Row{
|
||||
first_tick, std::vector<Plot_Value>(64, -70.0)}));
|
||||
waterfall->submit_stream<Waterfall_Stream_Tag>(
|
||||
std::make_shared<const Waterfall_Row>(Waterfall_Row{
|
||||
second_tick, std::vector<Plot_Value>(64, -30.0)}));
|
||||
waterfall->mark_dirty<Prepare_Data_Tag>();
|
||||
constellation->set<&Constellation_Diagram::Prop::i_range>(
|
||||
Axis_Range{-1.0, 1.0});
|
||||
constellation->set<&Constellation_Diagram::Prop::q_range>(
|
||||
Axis_Range{-1.0, 1.0});
|
||||
constellation->submit_stream<Constellation_Stream_Tag>(
|
||||
Constellation_Point{{-50.0, 0.25}, monotonic_milliseconds()});
|
||||
constellation->mark_dirty<Prepare_Data_Tag>();
|
||||
|
||||
scene->set<&Render_Scene_2D::Prop::viewport>(Size{160, 120});
|
||||
scene->activate_view();
|
||||
auto* frame = new Frame_2D(Frame_Identity{1, 0});
|
||||
auto* resized_partition_frame = new Frame_2D(Frame_Identity{2, 0});
|
||||
scene->set_frame_callback(
|
||||
[spectrum, frequency, power, frame,
|
||||
[scene, spectrum, waterfall, constellation, frequency, power, frame,
|
||||
resized_partition_frame, spectrum_painted,
|
||||
topology_valid](Frame_2D* completed) {
|
||||
const auto& state =
|
||||
const auto& spectrum_state =
|
||||
spectrum->read_state<Renderable::Base_Tag>();
|
||||
const auto& waterfall_state =
|
||||
waterfall->read_state<Renderable::Base_Tag>();
|
||||
const auto& constellation_state =
|
||||
constellation->read_state<Renderable::Base_Tag>();
|
||||
const bool valid = completed == frame &&
|
||||
state.prepare_executed && state.paint_executed &&
|
||||
spectrum_state.prepare_executed &&
|
||||
spectrum_state.paint_executed &&
|
||||
spectrum_state.prepare_task_count == 5 &&
|
||||
spectrum_state.paint_task_count == 6 &&
|
||||
waterfall_state.prepare_executed &&
|
||||
waterfall_state.paint_executed &&
|
||||
waterfall_state.prepare_task_count == 5 &&
|
||||
waterfall_state.paint_task_count == 5 &&
|
||||
constellation_state.prepare_executed &&
|
||||
constellation_state.paint_executed &&
|
||||
constellation_state.paint_task_count == 4 &&
|
||||
spectrum->read_state<Spectrum::Base_Tag>().sample_count ==
|
||||
512 &&
|
||||
frequency->read_state<Renderable::Base_Tag>().paint_executed &&
|
||||
power->read_state<Renderable::Base_Tag>().paint_executed &&
|
||||
topology_valid->load(std::memory_order_relaxed) &&
|
||||
contains_color(completed->image());
|
||||
std::_Exit(valid ? 0 : 1);
|
||||
if (!valid) std::_Exit(1);
|
||||
|
||||
spectrum->set<&Spectrum::Prop::partition_count>(2u);
|
||||
waterfall->set<&Waterfall::Prop::partition_grid>(
|
||||
Plot_Partition_Grid{3, 2});
|
||||
constellation->set<
|
||||
&Constellation_Diagram::Prop::partition_count>(2u);
|
||||
spectrum_painted->store(false, std::memory_order_relaxed);
|
||||
scene->set_frame_callback(
|
||||
[spectrum, waterfall, constellation, frequency, power,
|
||||
resized_partition_frame,
|
||||
topology_valid](Frame_2D* next) {
|
||||
const auto& next_spectrum =
|
||||
spectrum->read_state<Renderable::Base_Tag>();
|
||||
const auto& next_waterfall =
|
||||
waterfall->read_state<Renderable::Base_Tag>();
|
||||
const auto& next_constellation =
|
||||
constellation->read_state<Renderable::Base_Tag>();
|
||||
const bool resized_valid =
|
||||
next == resized_partition_frame &&
|
||||
next_spectrum.prepare_graph_rebuilt &&
|
||||
next_spectrum.paint_graph_rebuilt &&
|
||||
next_spectrum.prepare_task_count == 3 &&
|
||||
next_spectrum.paint_task_count == 4 &&
|
||||
next_waterfall.prepare_graph_rebuilt &&
|
||||
next_waterfall.paint_graph_rebuilt &&
|
||||
next_waterfall.prepare_task_count == 7 &&
|
||||
next_waterfall.paint_task_count == 7 &&
|
||||
next_constellation.paint_graph_rebuilt &&
|
||||
next_constellation.paint_task_count == 3 &&
|
||||
frequency->read_state<Renderable::Base_Tag>()
|
||||
.paint_executed &&
|
||||
power->read_state<Renderable::Base_Tag>()
|
||||
.paint_executed &&
|
||||
topology_valid->load(std::memory_order_relaxed) &&
|
||||
contains_color(next->image());
|
||||
std::_Exit(resized_valid ? 0 : 1);
|
||||
});
|
||||
if (!scene->render(resized_partition_frame)) std::_Exit(2);
|
||||
});
|
||||
if (!scene->render(frame)) return 2;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user