MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ done()

SeriesSpec MayaFlux::Portal::Forma::Plot::BarsBuilder::done ( ) const

Definition at line 371 of file SeriesBuilder.cpp.

372{
373 auto x_mappings = m_state.x_mappings();
374 auto y_mappings = m_state.y_mappings();
375 const auto global_palette = m_state.palette();
376
377 return {
378 .fn = [x_mappings, y_mappings, global_palette](
379 const std::shared_ptr<Kakshya::PlotContainer>& container,
380 std::vector<uint8_t>& out,
381 Element&) mutable {
382 if (!container)
383 return;
384
385 container->process_default();
386
387 AxisRange x_range = x_mappings.empty() ? AxisRange {} : merge_axis(x_mappings);
388 out.clear();
389
390 for (auto& y_mapping : y_mappings) {
391 auto y_series = series_for_mapping(*container, y_mapping);
392 if (y_series.empty())
393 continue;
394
395 auto y_range = y_mapping.range;
396 apply_auto_scale(y_range, y_series);
397
398 for (size_t si = 0; si < y_series.size(); ++si) {
399 const auto& series = y_series[si];
400 const size_t n = series.size();
401 if (n == 0)
402 continue;
403
404 const glm::vec3 color = resolve_color(y_mapping, global_palette, si);
405 const float bar_w = (x_range.max - x_range.min) / static_cast<float>(n);
406 const float y_base = y_range.to_ndc(0.F);
407
408 for (size_t i = 0; i < n; ++i) {
409 const float x_left = x_range.to_ndc(x_range.min + static_cast<float>(i) * bar_w);
410 const float x_right = x_range.to_ndc(x_range.min + static_cast<float>(i + 1) * bar_w);
411 const float y_top = y_range.to_ndc(static_cast<float>(series[i]));
412
413 write_vertex(out, { x_left, y_base, 0.F }, color, 0.F);
414 write_vertex(out, { x_right, y_base, 0.F }, color, 0.F);
415 write_vertex(out, { x_left, y_top, 0.F }, color, 0.F);
416 write_vertex(out, { x_right, y_base, 0.F }, color, 0.F);
417 write_vertex(out, { x_right, y_top, 0.F }, color, 0.F);
418 write_vertex(out, { x_left, y_top, 0.F }, color, 0.F);
419 }
420 }
421 } },
423 .capacity_for = [](uint64_t n) { return n * 6 * k_stride; },
424 .background_fn = m_state.has_background()
425 ? std::optional<GeometryFn<float>> { background(m_state.background_bounds(), m_state.background_color()) }
426 : std::nullopt,
427 .plot_bounds = m_state.plot_bounds(),
428 .labels = m_state.labels(),
429 .tick_labels = m_state.resolved_tick_labels(),
430 .legend = m_state.legend_spec(),
431 };
432}
const std::vector< LabelSpec > & labels() const
std::vector< TickLabelsSpec > resolved_tick_labels() const
Resolve pending fluent tick requests into concrete tick label specs.
Kinesis::AABB2D background_bounds() const
const std::vector< AxisMapping > & x_mappings() const
const std::optional< LegendSpec > & legend_spec() const
const std::optional< Kinesis::AABB2D > & plot_bounds() const
const std::vector< glm::vec3 > & palette() const
const std::vector< AxisMapping > & y_mappings() const
Series series()
Begin a Series chain.
Definition Plot.hpp:109
void apply_auto_scale(AxisRange &range, const std::vector< std::span< const double > > &series)
Apply auto-scaling to an AxisRange from a set of series.
Definition PlotSpec.cpp:53
GeometryFn< float > background(Kinesis::AABB2D bounds, glm::vec3 color, const std::shared_ptr< Core::VKImage > &texture)
TRIANGLE_STRIP background quad for a plot area.
Definition PlotSpec.cpp:88

References MayaFlux::Portal::Forma::Plot::apply_auto_scale(), MayaFlux::Portal::Forma::Plot::background(), MayaFlux::Portal::Forma::Plot::Series::background_bounds(), MayaFlux::Portal::Forma::Plot::Series::background_color(), MayaFlux::Portal::Forma::Plot::Series::has_background(), MayaFlux::Portal::Forma::Plot::Series::labels(), MayaFlux::Portal::Forma::Plot::Series::legend_spec(), m_state, MayaFlux::Portal::Forma::Plot::AxisRange::max, MayaFlux::Portal::Forma::Plot::AxisRange::min, MayaFlux::Portal::Forma::Plot::Series::palette(), MayaFlux::Portal::Forma::Plot::Series::plot_bounds(), MayaFlux::Portal::Forma::Plot::Series::resolved_tick_labels(), MayaFlux::Portal::Forma::Plot::series(), MayaFlux::Portal::Forma::Plot::AxisRange::to_ndc(), MayaFlux::Portal::Graphics::TRIANGLE_LIST, MayaFlux::Portal::Forma::Plot::Series::x_mappings(), and MayaFlux::Portal::Forma::Plot::Series::y_mappings().

+ Here is the call graph for this function: