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

◆ plot()

MAYAFLUX_API std::pair< Mapped< std::shared_ptr< Kakshya::PlotContainer > >, Surface > MayaFlux::Portal::Forma::plot ( std::string  title,
uint32_t  width,
uint32_t  height,
std::shared_ptr< Kakshya::PlotContainer >  container,
Plot::SeriesSpec  spec 
)

Create a live plot in a new window.

Creates the window, shows it, constructs the Surface, and places the plot in a slice of one batch. Background, legend swatches and labels use slices of that batch; a plot with labels selects the glyph-capable plot shader. Returns the Mapped<shared_ptr<PlotContainer>> from Plot::place, plus the Surface owning the window and layer.

Parameters
titleWindow title.
widthWindow width in pixels.
heightWindow height in pixels.
containerReady PlotContainer from Plot::source().build().
specSeriesSpec from Plot::series()...done().
Returns
Pair of { Mapped<shared_ptr<PlotContainer>>, Surface } for the created plot.

Definition at line 113 of file Forma.cpp.

119{
120 auto& atelier = internal::atelier();
121
122 auto window = atelier.create_window(
123 Core::WindowCreateInfo { .title = std::move(title), .width = width, .height = height });
124
125 auto surface = atelier.create_surface(SurfaceConfig {
126 .window = window,
127 .name = window->get_create_info().title,
128 });
129
130 const bool has_labels = !spec.labels.empty() || !spec.tick_labels.empty()
131 || (spec.legend && !spec.legend->entries.empty());
132 Graphics::RenderConfig render = surface.render_config();
133 if (has_labels) {
134 render.fragment_shader = "forma_plot.frag.spv";
135 render.additional_textures.emplace_back("text", nullptr);
136 }
137 const auto batch = atelier.create_buffer(std::move(render));
138
139 std::optional<uint32_t> background_id;
140 if (spec.background_fn) {
141 auto bg = atelier.create_element<float>(
142 surface,
143 FormaTarget::slice_of(batch, Graphics::PrimitiveTopology::TRIANGLE_STRIP),
144 *spec.background_fn, 0.F);
145 background_id = bg.element.id;
146 }
147
148 auto mapped = Plot::place(
149 surface, FormaTarget::slice_of(batch, spec.topology), spec, std::move(container));
150
151 if (background_id) {
152 surface.layer().relate(mapped.element.id, *background_id);
153 surface.layer().send_to_back(*background_id);
154 }
155
156 internal::atelier().place_adornments(surface, spec, mapped.element.id, batch);
157
158 return { std::move(mapped), std::move(surface) };
159}
std::weak_ptr< Core::Window > window
Definition Picker.cpp:23
uint32_t width
uint32_t height
Surface create_surface(SurfaceConfig config)
Build a Surface from a SurfaceConfig, creating Layer and Context when config.layer/config....
Definition Atelier.cpp:160
std::shared_ptr< Core::Window > create_window(const Core::WindowCreateInfo &info)
Create a window through the stored WindowManager and show it.
Definition Atelier.cpp:104
Mapped< T > create_element(Surface &surface, GeometryFn< T > geom, T initial, Graphics::PrimitiveTopology topology=Graphics::PrimitiveTopology::TRIANGLE_STRIP, std::function< float(T)> project={})
create_element on a buffer of its own, as a slice of topology, followed by one sync so bounds_hint an...
Definition Atelier.hpp:165
std::shared_ptr< Buffers::FormaBuffer > create_buffer(Graphics::RenderConfig render)
The single buffer construction path.
Definition Atelier.cpp:117
std::string title
Window title/identifier.
Configuration for creating a single window instance.
std::optional< LegendSpec > legend
Optional legend to materialize when the plot is placed.
std::optional< GeometryFn< float > > background_fn
std::vector< TickLabelsSpec > tick_labels
Concrete tick label generation specs resolved at done() time.
std::vector< LabelSpec > labels
Explicit text labels to materialize when the plot is placed.

References MayaFlux::Portal::Graphics::RenderConfig::additional_textures, MayaFlux::Portal::Forma::internal::atelier(), MayaFlux::Portal::Forma::Plot::SeriesSpec::background_fn, MayaFlux::Portal::Forma::internal::Atelier::create_buffer(), MayaFlux::Portal::Forma::internal::Atelier::create_element(), MayaFlux::Portal::Forma::internal::Atelier::create_surface(), MayaFlux::Portal::Forma::internal::Atelier::create_window(), MayaFlux::Portal::Graphics::RenderConfig::fragment_shader, height, MayaFlux::Portal::Forma::Plot::SeriesSpec::labels, MayaFlux::Portal::Forma::Plot::SeriesSpec::legend, MayaFlux::Portal::Forma::Plot::place(), MayaFlux::Portal::Forma::internal::Atelier::place_adornments(), MayaFlux::Portal::Forma::FormaTarget::slice_of(), MayaFlux::Portal::Forma::Plot::SeriesSpec::tick_labels, MayaFlux::Core::WindowCreateInfo::title, MayaFlux::Portal::Forma::Plot::SeriesSpec::topology, MayaFlux::Portal::Graphics::TRIANGLE_STRIP, width, window, and MayaFlux::Portal::Forma::SurfaceConfig::window.

+ Here is the call graph for this function: