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

◆ done()

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

Definition at line 319 of file SeriesBuilder.cpp.

320{
321 auto x_mappings = m_state.x_mappings();
322 auto y_mappings = m_state.y_mappings();
323 auto z_mappings = m_state.z_mappings();
324 const auto global_palette = m_state.palette();
325 const float point_size = m_point_size;
326
327 return fitted(SeriesSpec {
328 .fn = [x_mappings, y_mappings, z_mappings, global_palette, point_size](
329 const std::shared_ptr<Kakshya::PlotContainer>& container,
330 std::vector<uint8_t>& out,
331 Element&) mutable {
332 if (!container)
333 return;
334
335 container->process_default();
336
337 std::vector<std::span<const double>> all_x, all_z;
338 for (auto& m : x_mappings) {
339 auto s = series_for_mapping(*container, m);
340 all_x.insert(all_x.end(), s.begin(), s.end());
341 }
342 for (auto& m : z_mappings) {
343 auto s = series_for_mapping(*container, m);
344 all_z.insert(all_z.end(), s.begin(), s.end());
345 }
346
347 AxisRange x_range = merge_axis(x_mappings);
348 AxisRange z_range = z_mappings.empty() ? AxisRange {} : merge_axis(z_mappings);
349 apply_auto_scale(x_range, all_x);
350 apply_auto_scale(z_range, all_z);
351
352 out.clear();
353
354 size_t global_idx = 0;
355 for (auto& y_mapping : y_mappings) {
356 auto y_series = series_for_mapping(*container, y_mapping);
357 auto y_range = y_mapping.range;
358 apply_auto_scale(y_range, y_series);
359
360 for (size_t si = 0; si < y_series.size(); ++si, ++global_idx) {
361 const auto& ys = y_series[si];
362 const size_t n = ys.size();
363 if (n == 0)
364 continue;
365
366 const glm::vec3 color = resolve_color(y_mapping, global_palette, si);
367 const size_t x_idx = std::min(global_idx, all_x.empty() ? size_t(0) : all_x.size() - 1);
368 const bool has_x = !all_x.empty() && all_x[x_idx].size() == n;
369 const bool has_z = global_idx < all_z.size() && all_z[global_idx].size() == n;
370
371 for (size_t i = 0; i < n; ++i) {
372 const float px = has_x
373 ? x_range.to_ndc(static_cast<float>(all_x[x_idx][i]))
374 : x_range.to_ndc(x_range.min
375 + static_cast<float>(i) / static_cast<float>(std::max<size_t>(n - 1, 1))
376 * (x_range.max - x_range.min));
377
378 write_vertex(out,
379 { px,
380 y_range.to_ndc(static_cast<float>(ys[i])),
381 has_z ? z_range.to_ndc(static_cast<float>(all_z[global_idx][i])) : 0.F },
382 color,
383 point_size);
384 }
385 }
386 } },
388 .capacity_for = [](uint64_t n) { return n * k_stride; },
389 .background_fn = m_state.has_background()
390 ? std::optional<GeometryFn<float>> { background(m_state.background_bounds(), m_state.background_color()) }
391 : std::nullopt,
392 .plot_bounds = m_state.plot_bounds(),
393 .labels = m_state.labels(),
394 .tick_labels = m_state.resolved_tick_labels(),
395 .legend = m_state.legend_spec(),
396 });
397}
glm::vec3 color
Definition Decoder.cpp:97
bool size
std::vector< float > * out
uint32_t px
ScatterBuilder & point_size(float s)
Point size in pixels.
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 > & z_mappings() 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
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_point_size, 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::Graphics::POINT_LIST, point_size(), px, MayaFlux::Portal::Forma::Plot::Series::resolved_tick_labels(), MayaFlux::Portal::Forma::Plot::AxisRange::to_ndc(), MayaFlux::Portal::Forma::Plot::Series::x_mappings(), MayaFlux::Portal::Forma::Plot::Series::y_mappings(), and MayaFlux::Portal::Forma::Plot::Series::z_mappings().

+ Here is the call graph for this function: