网页升级

This commit is contained in:
2026-08-11 06:21:51 +08:00
parent f50e9f7c1e
commit feb7c72e94
40 changed files with 6490 additions and 98 deletions
+12 -13
View File
@@ -26,11 +26,8 @@ Color blend(Color first, Color second, double amount) {
Color_Map radio_color_map() {
constexpr Color stops[] = {
{3, 7, 18, 255},
{16, 52, 105, 255},
{23, 163, 184, 255},
{238, 210, 91, 255},
{239, 68, 68, 255}
{3, 7, 18, 255}, {16, 52, 105, 255}, {23, 163, 184, 255},
{238, 210, 91, 255}, {239, 68, 68, 255}
};
std::vector<Pixel> colors;
colors.reserve(256);
@@ -180,7 +177,6 @@ struct Web_Plot_Session::Impl {
spectrum_power_axis->set_x(left);
spectrum_power_axis->set_y(top);
spectrum_power_axis->set_pixel_length(static_cast<std::size_t>(spectrum_height));
waterfall_frequency_axis->set_x(left);
waterfall_frequency_axis->set_y(waterfall_y + waterfall_height);
waterfall_frequency_axis->set_pixel_length(static_cast<std::size_t>(content_width));
@@ -220,7 +216,8 @@ struct Web_Plot_Session::Impl {
28.0 * gaussian(x, 0.32, 0.025);
break;
}
samples[index] = std::clamp(-110.0 + noise * 4.5 + signal + gain_db, -120.0, -20.0);
samples[index] = std::clamp(-110.0 + noise * 4.5 + signal + gain_db,
-120.0, -20.0);
}
spectrum->update_samples(samples);
if ((frame_index & 1U) == 0U)
@@ -237,7 +234,7 @@ struct Web_Plot_Session::Impl {
spectrum->set_frequency_range(range);
spectrum->set_center_frequency(center);
spectrum->set_sweep_frequency_range({center - bandwidth * 0.125,
center + bandwidth * 0.125});
center + bandwidth * 0.125});
waterfall->set_frequency_range(range);
}
@@ -249,7 +246,7 @@ struct Web_Plot_Session::Impl {
waterfall_frequency_axis->set_coord_range(range);
spectrum->set_frequency_range(range);
spectrum->set_sweep_frequency_range({center - bandwidth * 0.125,
center + bandwidth * 0.125});
center + bandwidth * 0.125});
waterfall->set_frequency_range(range);
}
@@ -267,13 +264,15 @@ struct Web_Plot_Session::Impl {
return pixels.empty() ? std::nullopt : std::optional<std::string>(std::move(pixels));
}
std::optional<std::string> handle(const Web_Event& event) {
std::optional<Web_Response> handle(const Web_Event& event) {
std::lock_guard lock(mutex);
return std::visit(
[this](const auto& value) -> std::optional<std::string> {
[this](const auto& value) -> std::optional<Web_Response> {
using T = std::decay_t<decltype(value)>;
if constexpr (std::is_same_v<T, Frame_Request>) {
return render_pixels();
auto pixels = render_pixels();
if (pixels)
return Web_Response{Web_Response_Type::Pixels, std::move(*pixels)};
} else if constexpr (std::is_same_v<T, Viewport_Resize>) {
const Size previous = plot.viewport_size();
plot.set_viewport_size(value.size);
@@ -321,7 +320,7 @@ struct Web_Plot_Session::Impl {
Web_Plot_Session::Web_Plot_Session() : impl_(std::make_unique<Impl>()) {}
Web_Plot_Session::~Web_Plot_Session() = default;
std::optional<std::string> Web_Plot_Session::handle(const Web_Event& event) {
std::optional<Web_Response> Web_Plot_Session::handle(const Web_Event& event) {
return impl_->handle(event);
}