builder 和 运行时修改隔离开
This commit is contained in:
@@ -50,13 +50,13 @@ double gaussian(double x, double center, double width) {
|
||||
} // namespace
|
||||
struct Web_Plot_Session::Impl {
|
||||
Scene2D plot;
|
||||
std::shared_ptr<Frequency_Axis> spectrum_frequency_axis;
|
||||
std::shared_ptr<Axis> spectrum_power_axis;
|
||||
std::shared_ptr<Frequency_Axis> waterfall_frequency_axis;
|
||||
std::shared_ptr<Time_Axis> waterfall_time_axis;
|
||||
std::shared_ptr<Spectrum> spectrum;
|
||||
std::shared_ptr<Waterfall> waterfall;
|
||||
std::shared_ptr<Selection_Rectangle_Overlay> selection;
|
||||
renderive_Owner<Frequency_Axis> spectrum_frequency_axis;
|
||||
renderive_Owner<Axis> spectrum_power_axis;
|
||||
renderive_Owner<Frequency_Axis> waterfall_frequency_axis;
|
||||
renderive_Owner<Time_Axis> waterfall_time_axis;
|
||||
renderive_Owner<Spectrum> spectrum;
|
||||
renderive_Owner<Waterfall> waterfall;
|
||||
renderive_Owner<Selection_Rectangle_Overlay> selection;
|
||||
Demo_Mode mode = Demo_Mode::Fm;
|
||||
double gain_db = 8.0;
|
||||
std::uint64_t frame_index{};
|
||||
@@ -67,14 +67,24 @@ struct Web_Plot_Session::Impl {
|
||||
plot.set_max_render_fps(30.0);
|
||||
plot.set_viewport_size({960, 600});
|
||||
const auto root = plot.root_renderable();
|
||||
const auto data = plot.create_renderable_node(root, "Web_Data");
|
||||
const auto axes = plot.create_renderable_node(root, "Web_Axes");
|
||||
const auto overlay = plot.create_renderable_node(root, "Web_Overlay");
|
||||
axes->set_cache_mode(Renderable_Cache_Mode::Local_Pixel);
|
||||
constexpr Color axis_color{93, 116, 151, 255};
|
||||
const Range initial_frequency{101'300'000.0, 103'700'000.0};
|
||||
spectrum_frequency_axis =
|
||||
Frequency_Axis::Builder(axes, Orientation::Horizontal)
|
||||
{
|
||||
auto attach = plot.attach_builder();
|
||||
const auto make_group = [&](std::string name) {
|
||||
auto group = detail::make_renderable_group(true);
|
||||
group->set_object_name(std::move(name));
|
||||
attach.attach(group);
|
||||
attach.add_parent(::Scene_Base::Relationship::display, group, root);
|
||||
attach.add_parent(::Scene_Base::Relationship::dependency, group, root);
|
||||
return group;
|
||||
};
|
||||
const auto data = make_group("Web_Data");
|
||||
const auto axes = make_group("Web_Axes");
|
||||
const auto overlay = make_group("Web_Overlay");
|
||||
axes->set_cache_mode(Renderable_Cache_Mode::Local_Pixel);
|
||||
spectrum_frequency_axis =
|
||||
Frequency_Axis::Builder(axes, Orientation::Horizontal, &attach)
|
||||
.set_coord_range(initial_frequency)
|
||||
.set_label_precision(2)
|
||||
.set_tick_length(8)
|
||||
@@ -84,7 +94,7 @@ struct Web_Plot_Session::Impl {
|
||||
.set_use_drag(true)
|
||||
.build();
|
||||
spectrum_power_axis =
|
||||
Axis::Builder(axes, Orientation::Vertical)
|
||||
Axis::Builder(axes, Orientation::Vertical, &attach)
|
||||
.set_coord_range({-20.0, -120.0})
|
||||
.set_label_precision(0)
|
||||
.set_tick_length(-8)
|
||||
@@ -93,7 +103,7 @@ struct Web_Plot_Session::Impl {
|
||||
.set_unit_text("dBm")
|
||||
.build();
|
||||
waterfall_frequency_axis =
|
||||
Frequency_Axis::Builder(axes, Orientation::Horizontal)
|
||||
Frequency_Axis::Builder(axes, Orientation::Horizontal, &attach)
|
||||
.set_coord_range(initial_frequency)
|
||||
.set_label_precision(2)
|
||||
.set_tick_length(8)
|
||||
@@ -103,7 +113,7 @@ struct Web_Plot_Session::Impl {
|
||||
.set_use_drag(true)
|
||||
.build();
|
||||
waterfall_time_axis =
|
||||
Time_Axis::Builder(axes, Orientation::Vertical)
|
||||
Time_Axis::Builder(axes, Orientation::Vertical, &attach)
|
||||
.set_visible_time_point_count(72)
|
||||
.set_tick_label_spacing_px(34)
|
||||
.set_time_format("mm:ss")
|
||||
@@ -111,7 +121,7 @@ struct Web_Plot_Session::Impl {
|
||||
.set_sub_tick_length(-4)
|
||||
.set_color(axis_color)
|
||||
.build();
|
||||
spectrum = Spectrum::Builder{}
|
||||
spectrum = Spectrum::Builder{&attach}
|
||||
.set<&Spectrum::Properties::frequency_range>(initial_frequency)
|
||||
.set<&Spectrum::Properties::frequency_point_size>(768)
|
||||
.set<&Spectrum::Properties::center_frequency>(102'500'000.0)
|
||||
@@ -130,17 +140,18 @@ struct Web_Plot_Session::Impl {
|
||||
Color{56, 189, 248, 220}, 1.0,
|
||||
Line_Style::Dash
|
||||
});
|
||||
waterfall = Waterfall::Builder{}
|
||||
waterfall = Waterfall::Builder{&attach}
|
||||
.set<&Waterfall::Properties::frequency_range>(initial_frequency)
|
||||
.set<&Waterfall::Properties::power_range>(Range{-120.0, -20.0})
|
||||
.set<&Waterfall::Properties::frequency_bin_count>(768)
|
||||
.set<&Waterfall::Properties::interpolation_mode>(Image_Interpolation_Mode::Bilinear)
|
||||
.set<&Waterfall::Properties::color_map>(radio_color_map())
|
||||
.build(data, waterfall_frequency_axis, waterfall_time_axis);
|
||||
selection = Selection_Rectangle_Overlay::Builder{}
|
||||
selection = Selection_Rectangle_Overlay::Builder{&attach}
|
||||
.set<&Selection_Rectangle_Overlay::Properties::selection_brush>(Brush{Color{56, 189, 248, 36}, Brush_Style::Solid})
|
||||
.set<&Selection_Rectangle_Overlay::Properties::selection_border_pen>(Pen{Color{125, 211, 252, 230}, 1.0, Line_Style::Dash})
|
||||
.build(overlay, spectrum_frequency_axis, spectrum_power_axis);
|
||||
}
|
||||
apply_layout(plot.viewport_size());
|
||||
plot.activate_view();
|
||||
update_model();
|
||||
|
||||
Reference in New Issue
Block a user