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

◆ place_adornments()

void MayaFlux::Portal::Forma::internal::Atelier::place_adornments ( Surface &  surface,
const Plot::SeriesSpec &  spec,
uint32_t  relate_to,
const std::shared_ptr< Buffers::FormaBuffer > &  batch = {} 
)

Create and place every adornment declared on spec.

Makes a target for each axis label, tick label, legend swatch, and legend label, then hands each to the corresponding Plot placement function. Each adornment is related to relate_to so removal and visibility cascade from the series element.

Lives here rather than in Plot because it constructs buffers, which requires the BufferManager. Plot composes placement from arguments it is given.

Parameters
surfaceSurface to place on.
specSeries spec carrying the adornment declarations.
relate_toElement id the adornments are related to.
batchShared plot buffer for swatches and labels. With labels, it needs a text slot and forma_plot.frag. When empty, one buffer is created for all adornments.

Definition at line 183 of file Atelier.cpp.

188{
189 const bool has_labels = !spec.labels.empty() || !spec.tick_labels.empty()
190 || (spec.legend && !spec.legend->entries.empty());
191 std::shared_ptr<Buffers::FormaBuffer> owned_batch;
192 const auto target_of = [&](Graphics::PrimitiveTopology topology) -> FormaTarget {
193 if (!batch && !owned_batch) {
194 Graphics::RenderConfig render = surface.render_config();
195 if (has_labels) {
196 render.fragment_shader = "forma_plot.frag.spv";
197 render.additional_textures.emplace_back("text", nullptr);
198 }
199 owned_batch = create_buffer(std::move(render));
200 }
201 const auto& target_batch = batch ? batch : owned_batch;
202 return FormaTarget::slice_of(target_batch, topology);
203 };
204
205 const auto legend = spec.legend
206 ? std::optional<Plot::LegendLayout>(Plot::layout_legend(*spec.legend))
207 : std::nullopt;
208 if (legend) {
209 for (const auto& swatch : legend->swatches) {
210 (void)Plot::place_rect(surface,
211 target_of(Graphics::PrimitiveTopology::TRIANGLE_STRIP), swatch, relate_to);
212 }
213 }
214
215 for (const auto& label : spec.labels) {
216 (void)Plot::place_label(surface,
218 }
219
220 for (const auto& ticks : spec.tick_labels) {
221 for (const auto& label : Plot::plot_tick_labels(ticks)) {
222 (void)Plot::place_label(surface,
224 }
225 }
226
227 if (legend) {
228 for (const auto& label : legend->labels) {
229 (void)Plot::place_label(surface,
231 }
232 }
233}
uint32_t label
Definition Contours.cpp:16
PrimitiveTopology topology
static FormaTarget slice_of(const std::shared_ptr< Buffers::FormaBuffer > &buffer, std::optional< Graphics::PrimitiveTopology > topology=std::nullopt)
A new empty slice of buffer, drawn after the others.
Definition Target.cpp:19
std::shared_ptr< Buffers::FormaBuffer > create_buffer(Graphics::RenderConfig render)
The single buffer construction path.
Definition Atelier.cpp:117
uint32_t place_label(Surface &surface, FormaTarget buf, const LabelSpec &spec, uint32_t relate_to)
Place a text label element onto surface using a text-capable target.
Definition Plot.cpp:15
LegendLayout layout_legend(const LegendSpec &spec)
Expand a legend spec into swatch rectangle specs and text label specs.
Definition PlotSpec.cpp:346
std::vector< LabelSpec > plot_tick_labels(const TickLabelsSpec &spec)
Generate construction-free tick label specs.
Definition PlotSpec.cpp:237
uint32_t place_rect(Surface &surface, FormaTarget buf, const RectSpec &spec, uint32_t relate_to)
Place a filled rectangle element onto surface using a target.
Definition Plot.cpp:68
PrimitiveTopology
Vertex assembly primitive topology.

References MayaFlux::Portal::Graphics::RenderConfig::additional_textures, create_buffer(), MayaFlux::Portal::Graphics::RenderConfig::fragment_shader, label, MayaFlux::Portal::Forma::Plot::SeriesSpec::labels, MayaFlux::Portal::Forma::Plot::layout_legend(), MayaFlux::Portal::Forma::Plot::SeriesSpec::legend, MayaFlux::Portal::Forma::Plot::place_label(), MayaFlux::Portal::Forma::Plot::place_rect(), MayaFlux::Portal::Forma::Plot::plot_tick_labels(), MayaFlux::Portal::Forma::Surface::render_config(), MayaFlux::Portal::Forma::FormaTarget::slice_of(), MayaFlux::Portal::Forma::Plot::SeriesSpec::tick_labels, topology, MayaFlux::Portal::Graphics::TRIANGLE_LIST, and MayaFlux::Portal::Graphics::TRIANGLE_STRIP.

Referenced by MayaFlux::Portal::Forma::plot().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: