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

◆ done()

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

Definition at line 403 of file SeriesBuilder.cpp.

404{
405 auto x_mappings = m_state.x_mappings();
406 auto y_mappings = m_state.y_mappings();
407 const auto global_palette = m_state.palette();
408
409 return fitted(SeriesSpec {
410 .fn = [x_mappings, y_mappings, global_palette](
411 const std::shared_ptr<Kakshya::PlotContainer>& container,
412 std::vector<uint8_t>& out,
413 Element&) mutable {
414 if (!container)
415 return;
416
417 container->process_default();
418
419 AxisRange x_range = x_mappings.empty() ? AxisRange {} : merge_axis(x_mappings);
420 out.clear();
421
422 for (auto& y_mapping : y_mappings) {
423 auto y_series = series_for_mapping(*container, y_mapping);
424 if (y_series.empty())
425 continue;
426
427 auto y_range = y_mapping.range;
428 apply_auto_scale(y_range, y_series);
429
430 for (size_t si = 0; si < y_series.size(); ++si) {
431 const auto& series = y_series[si];
432 const size_t n = series.size();
433 if (n == 0)
434 continue;
435
436 const glm::vec3 color = resolve_color(y_mapping, global_palette, si);
437 const float bar_w = (x_range.max - x_range.min) / static_cast<float>(n);
438 const float y_base = y_range.to_ndc(0.F);
439
440 for (size_t i = 0; i < n; ++i) {
441 const float x_left = x_range.to_ndc(x_range.min + static_cast<float>(i) * bar_w);
442 const float x_right = x_range.to_ndc(x_range.min + static_cast<float>(i + 1) * bar_w);
443 const float y_top = y_range.to_ndc(static_cast<float>(series[i]));
444
445 write_vertex(out, { x_left, y_base, 0.F }, color, 0.F);
446 write_vertex(out, { x_right, y_base, 0.F }, color, 0.F);
447 write_vertex(out, { x_left, y_top, 0.F }, color, 0.F);
448 write_vertex(out, { x_right, y_base, 0.F }, color, 0.F);
449 write_vertex(out, { x_right, y_top, 0.F }, color, 0.F);
450 write_vertex(out, { x_left, y_top, 0.F }, color, 0.F);
451 }
452 }
453 } },
455 .capacity_for = [](uint64_t n) { return n * 6 * k_stride; },
456 .background_fn = m_state.has_background()
457 ? std::optional<GeometryFn<float>> { background(m_state.background_bounds(), m_state.background_color()) }
458 : std::nullopt,
459 .plot_bounds = m_state.plot_bounds(),
460 .labels = m_state.labels(),
461 .tick_labels = m_state.resolved_tick_labels(),
462 .legend = m_state.legend_spec(),
463 });
464}
glm::vec3 color
Definition Decoder.cpp:97
std::vector< float > * out
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:108
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(), color, MayaFlux::Portal::Forma::Plot::SeriesSpec::fn, 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, out, 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: