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

◆ done()

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

Definition at line 287 of file SeriesBuilder.cpp.

288{
289 auto x_mappings = m_state.x_mappings();
290 auto y_mappings = m_state.y_mappings();
291 auto z_mappings = m_state.z_mappings();
292 const auto global_palette = m_state.palette();
293 const float point_size = m_point_size;
294
295 return {
296 .fn = [x_mappings, y_mappings, z_mappings, global_palette, point_size](
297 const std::shared_ptr<Kakshya::PlotContainer>& container,
298 std::vector<uint8_t>& out,
299 Element&) mutable {
300 if (!container)
301 return;
302
303 container->process_default();
304
305 std::vector<std::span<const double>> all_x, all_z;
306 for (auto& m : x_mappings) {
307 auto s = series_for_mapping(*container, m);
308 all_x.insert(all_x.end(), s.begin(), s.end());
309 }
310 for (auto& m : z_mappings) {
311 auto s = series_for_mapping(*container, m);
312 all_z.insert(all_z.end(), s.begin(), s.end());
313 }
314
315 AxisRange x_range = merge_axis(x_mappings);
316 AxisRange z_range = z_mappings.empty() ? AxisRange {} : merge_axis(z_mappings);
317 apply_auto_scale(x_range, all_x);
318 apply_auto_scale(z_range, all_z);
319
320 out.clear();
321
322 size_t global_idx = 0;
323 for (auto& y_mapping : y_mappings) {
324 auto y_series = series_for_mapping(*container, y_mapping);
325 auto y_range = y_mapping.range;
326 apply_auto_scale(y_range, y_series);
327
328 for (size_t si = 0; si < y_series.size(); ++si, ++global_idx) {
329 const auto& ys = y_series[si];
330 const size_t n = ys.size();
331 if (n == 0)
332 continue;
333
334 const glm::vec3 color = resolve_color(y_mapping, global_palette, si);
335 const size_t x_idx = std::min(global_idx, all_x.empty() ? size_t(0) : all_x.size() - 1);
336 const bool has_x = !all_x.empty() && all_x[x_idx].size() == n;
337 const bool has_z = global_idx < all_z.size() && all_z[global_idx].size() == n;
338
339 for (size_t i = 0; i < n; ++i) {
340 const float px = has_x
341 ? x_range.to_ndc(static_cast<float>(all_x[x_idx][i]))
342 : x_range.to_ndc(x_range.min
343 + static_cast<float>(i) / static_cast<float>(std::max<size_t>(n - 1, 1))
344 * (x_range.max - x_range.min));
345
346 write_vertex(out,
347 { px,
348 y_range.to_ndc(static_cast<float>(ys[i])),
349 has_z ? z_range.to_ndc(static_cast<float>(all_z[global_idx][i])) : 0.F },
350 color,
351 point_size);
352 }
353 }
354 } },
356 .capacity_for = [](uint64_t n) { return n * k_stride; },
357 .background_fn = m_state.has_background()
358 ? std::optional<GeometryFn<float>> { background(m_state.background_bounds(), m_state.background_color()) }
359 : std::nullopt,
360 .plot_bounds = m_state.plot_bounds(),
361 .labels = m_state.labels(),
362 .tick_labels = m_state.resolved_tick_labels(),
363 .legend = m_state.legend_spec(),
364 };
365}
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(), 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, MayaFlux::Portal::Forma::Plot::Series::palette(), MayaFlux::Portal::Forma::Plot::Series::plot_bounds(), MayaFlux::Portal::Graphics::POINT_LIST, point_size(), 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: