改造一些
This commit is contained in:
@@ -21,7 +21,7 @@ using Waterfall_Interaction_State = Double_State_Strategy<Waterfall_Interaction_
|
||||
}
|
||||
struct Waterfall_Control::Impl {
|
||||
Impl(Waterfall_Control& owner, std::shared_ptr<Frequency_Axis> frequency, std::shared_ptr<Time_Axis> time)
|
||||
: frequency_axis(std::move(frequency)), time_axis(std::move(time)), rows(observe_real_time_data(owner)) {}
|
||||
: frequency_axis(std::move(frequency)), time_axis(std::move(time)), rows(owner) {}
|
||||
std::shared_ptr<Frequency_Axis> frequency_axis;
|
||||
std::shared_ptr<Time_Axis> time_axis;
|
||||
Waterfall_History rows;
|
||||
@@ -31,7 +31,8 @@ Waterfall_Control::Waterfall_Control(Plot_Core& plot, const Waterfall_Properties
|
||||
: Plottable_State(plot, properties), impl_(std::make_unique<Impl>(*this, std::move(frequency_axis), std::move(time_axis))) {}
|
||||
Waterfall_Control::~Waterfall_Control() = default;
|
||||
void Waterfall_Control::append_row(int tick, std::span<const double> values) {
|
||||
const std::size_t limit = static_cast<std::size_t>(std::max(2, impl_->time_axis->visible_time_point_count()));
|
||||
const std::size_t limit = static_cast<std::size_t>(
|
||||
std::max(2, impl_->time_axis->get<&Time_Axis_Properties::visible_count>()));
|
||||
if(get<&Waterfall_Properties::frequency_bin_count>() <= 0)
|
||||
set<&Waterfall_Properties::frequency_bin_count>(static_cast<int>(values.size()));
|
||||
impl_->rows.update({tick, {values.begin(), values.end()}}, limit);
|
||||
@@ -64,7 +65,11 @@ std::size_t Waterfall_Control::rendered_cell_count() const {
|
||||
const int source_width = std::min(state.frequency_bin_count.get(), static_cast<int>(std::min_element(rows.begin(), rows.end(), [](const auto& left, const auto& right) { return left.values.size() < right.values.size(); })->values.size()));
|
||||
if(source_width <= 0)
|
||||
return 0;
|
||||
const auto columns = frequency_columns(state.frequency_range, impl_->frequency_axis->coord_range(), source_width, state.visible_range_only);
|
||||
const auto columns = frequency_columns(
|
||||
state.frequency_range,
|
||||
impl_->frequency_axis->get<&Axis_Properties::coordinates>(),
|
||||
source_width,
|
||||
state.visible_range_only);
|
||||
return columns ? static_cast<std::size_t>(columns->last - columns->first + 1) * rows.size() : 0;
|
||||
}
|
||||
void Waterfall_Control::handle_event(const Event& event) {
|
||||
@@ -77,17 +82,17 @@ void Waterfall_Control::publish() {
|
||||
publish_properties();
|
||||
impl_->interaction.publish();
|
||||
}
|
||||
void Waterfall_Control::paint(Painter& painter) {
|
||||
const auto state = render_properties();
|
||||
const auto rows = impl_->rows.snapshot();
|
||||
const auto interaction = impl_->interaction.render_use_state();
|
||||
void Waterfall_Control::paint(Painter& painter, const Render_State_View& view) {
|
||||
const auto& state = render_properties(view);
|
||||
const auto& rows = view.get(impl_->rows);
|
||||
const auto& interaction = view.get(impl_->interaction);
|
||||
if(rows.empty())
|
||||
return;
|
||||
const int source_width = std::min(state.frequency_bin_count.get(), static_cast<int>(std::min_element(rows.begin(), rows.end(), [](const auto& left, const auto& right) { return left.values.size() < right.values.size(); })->values.size()));
|
||||
const int height = static_cast<int>(rows.size());
|
||||
if(source_width <= 0 || height <= 0)
|
||||
return;
|
||||
const Axis_Transform horizontal = impl_->frequency_axis->transform();
|
||||
const Axis_Transform horizontal = impl_->frequency_axis->transform(view);
|
||||
const auto columns = frequency_columns(state.frequency_range, horizontal.coordinate_range, source_width, state.visible_range_only);
|
||||
if(!columns)
|
||||
return;
|
||||
@@ -98,11 +103,11 @@ void Waterfall_Control::paint(Painter& painter) {
|
||||
for(int x = 0; x < width; ++x)
|
||||
pixels[static_cast<std::size_t>(y) * width + x] = state.color_map.at_normalized(normalized_value(row[static_cast<std::size_t>(columns->first + x)], state.power_range));
|
||||
}
|
||||
const Axis_Transform vertical = impl_->time_axis->transform();
|
||||
const Axis_Transform vertical = impl_->time_axis->transform(view);
|
||||
const Range time_range{static_cast<double>(rows.front().tick), static_cast<double>(rows.back().tick)};
|
||||
RectF target = mapped_rect(horizontal, vertical, columns->range, time_range);
|
||||
if(target.height < 1.0)
|
||||
target.height = std::max(1.0, static_cast<double>(impl_->time_axis->pixel_length()));
|
||||
target.height = std::max(1.0, impl_->time_axis->transform(view).pixel_length);
|
||||
painter.heatmap(target, width, height, pixels, state.interpolation_mode);
|
||||
if(state.tooltip_enabled && interaction.tooltip.active && target.contains(interaction.tooltip.position)) {
|
||||
const double frequency = horizontal.pixel_to_coord(interaction.tooltip.position.x);
|
||||
|
||||
Reference in New Issue
Block a user