Skip to main content

CorePlotting::RenderableScene

CorePlotting::RenderableScene

The complete description of a scene to be rendered. More…

#include <RenderablePrimitives.hpp>

Public Functions

Name
bool isSelected(EntityId id) const
Check if an entity is selected.
std::unordered_set< EntityId > const & getSelectedEntities() const
Get the selection set.
glm::vec2 canvasToWorld(float canvas_x, float canvas_y, int viewport_width, int viewport_height) const
Convert canvas pixel coordinates to world coordinates.
Interaction::DataCoordinates previewToDataCoords(Interaction::GlyphPreview const & preview, int viewport_width, int viewport_height, LayoutTransform const & y_transform, std::string const & series_key, std::optional< EntityId > entity_id =std::nullopt) const
Convert a GlyphPreview to DataCoordinates for committing to DataManager.
Interaction::DataCoordinates::IntervalCoords previewToIntervalCoords(Interaction::GlyphPreview const & rect_preview, int viewport_width, int viewport_height) const
Convert rectangle preview to interval coordinates.
Interaction::DataCoordinates::LineCoords previewToLineCoords(Interaction::GlyphPreview const & line_preview, int viewport_width, int viewport_height, LayoutTransform const & y_transform) const
Convert line preview to line coordinates.
Interaction::DataCoordinates::PointCoords previewToPointCoords(Interaction::GlyphPreview const & point_preview, int viewport_width, int viewport_height, LayoutTransform const & y_transform) const
Convert point preview to point coordinates.

Public Attributes

Name
std::vector< RenderablePolyLineBatch > poly_line_batches
std::vector< RenderableRectangleBatch > rectangle_batches
std::vector< RenderableGlyphBatch > glyph_batches
glm::mat4 view_matrix
glm::mat4 projection_matrix
ClockTicks time_axis_origin_master_absolute
Master-clock absolute time at the left edge of the visible window.
std::unique_ptr< QuadTree< EntityId > > spatial_index
std::unordered_map< EntityId, std::string > entity_to_series_key
std::unordered_set< EntityId > selected_entities
std::optional< Interaction::GlyphPreview > active_preview

Detailed Description

struct CorePlotting::RenderableScene;

The complete description of a scene to be rendered.

This struct contains all the primitives and global state required to draw a frame. It is produced by the CorePlotting layout engine and consumed by the Renderer.

ARCHITECTURE:

  • Each batch has its own Model matrix (per-series positioning)
  • View and Projection matrices are shared (global camera state)
  • QuadTree lives here for synchronization (same layout as batches)

See DESIGN.md for the complete architecture discussion.

Public Functions Documentation

function isSelected

inline bool isSelected(
    EntityId id
) const

Check if an entity is selected.

Parameters:

Return: true if the entity is in the selection set

function getSelectedEntities

inline std::unordered_set< EntityId > const & getSelectedEntities() const

Get the selection set.

Return: Const reference to the selected entity set

function canvasToWorld

glm::vec2 canvasToWorld(
    float canvas_x,
    float canvas_y,
    int viewport_width,
    int viewport_height
) const

Convert canvas pixel coordinates to world coordinates.

Parameters:

  • canvas_x X coordinate in pixels (0 = left edge)
  • canvas_y Y coordinate in pixels (0 = top edge, Y increases downward)
  • viewport_width Viewport width in pixels
  • viewport_height Viewport height in pixels

Return: World-space coordinates (X = time, Y = normalized plot position)

Uses the scene’s stored view and projection matrices to unproject from canvas space to world space.

function previewToDataCoords

Interaction::DataCoordinates previewToDataCoords(
    Interaction::GlyphPreview const & preview,
    int viewport_width,
    int viewport_height,
    LayoutTransform const & y_transform,
    std::string const & series_key,
    std::optional< EntityId > entity_id =std::nullopt
) const

Convert a GlyphPreview to DataCoordinates for committing to DataManager.

Parameters:

  • preview The preview geometry in canvas coordinates
  • viewport_width Current viewport width in pixels
  • viewport_height Current viewport height in pixels
  • y_transform The Y-axis LayoutTransform for the target series. This is obtained from the LayoutResponse for the series.
  • series_key Key of the target series in DataManager
  • entity_id Optional EntityId if modifying an existing element

Return: DataCoordinates ready for committing to DataManager

This is the main conversion method for interactive operations. It takes the preview geometry (in canvas coordinates) and converts it to data coordinates suitable for updating a data series.

Usage Example:

// After interaction completes:
auto preview = controller.getPreview();
auto y_transform = layout_response.getSeriesTransform(series_key);
auto data_coords = scene.previewToDataCoords(
    preview, width(), height(), y_transform, series_key, entity_id);
commitToDataManager(data_coords);

function previewToIntervalCoords

Interaction::DataCoordinates::IntervalCoords previewToIntervalCoords(
    Interaction::GlyphPreview const & rect_preview,
    int viewport_width,
    int viewport_height
) const

Convert rectangle preview to interval coordinates.

Parameters:

  • rect_preview A GlyphPreview of Type::Rectangle
  • viewport_width Viewport width in pixels
  • viewport_height Viewport height in pixels

Return: IntervalCoords with start and end time indices

Specialized conversion for interval creation/modification. Only uses the X coordinates (time), ignoring Y (height spans full range).

function previewToLineCoords

Interaction::DataCoordinates::LineCoords previewToLineCoords(
    Interaction::GlyphPreview const & line_preview,
    int viewport_width,
    int viewport_height,
    LayoutTransform const & y_transform
) const

Convert line preview to line coordinates.

Parameters:

  • line_preview A GlyphPreview of Type::Line
  • viewport_width Viewport width in pixels
  • viewport_height Viewport height in pixels
  • y_transform Y-axis transform (use identity for raw world coords)

Return: LineCoords with start and end points in data space

Converts both endpoints from canvas to world coordinates. Y values are optionally transformed using the provided layout transform.

function previewToPointCoords

Interaction::DataCoordinates::PointCoords previewToPointCoords(
    Interaction::GlyphPreview const & point_preview,
    int viewport_width,
    int viewport_height,
    LayoutTransform const & y_transform
) const

Convert point preview to point coordinates.

Parameters:

  • point_preview A GlyphPreview of Type::Point
  • viewport_width Viewport width in pixels
  • viewport_height Viewport height in pixels
  • y_transform Y-axis transform

Return: PointCoords in data space

Public Attributes Documentation

variable poly_line_batches

std::vector< RenderablePolyLineBatch > poly_line_batches;

variable rectangle_batches

std::vector< RenderableRectangleBatch > rectangle_batches;

variable glyph_batches

std::vector< RenderableGlyphBatch > glyph_batches;

variable view_matrix

glm::mat4 view_matrix {1.0f};

Note: Renderers (including [PlottingSVG::SVGSceneRenderer](/api_generated/Classes/classPlottingSVG_1_1SVGSceneRenderer.md)) compute [projection_matrix](/api_generated/Classes/structCorePlotting_1_1RenderableScene.md#variable-projection-matrix) * [view_matrix](/api_generated/Classes/structCorePlotting_1_1RenderableScene.md#variable-view-matrix) * batch.model_matrix per batch. Identity defaults produce a 1:1 world→NDC mapping that is almost never the correct camera for a plot widget. Callers that build a scene via [SceneBuilder](/api_generated/Classes/classCorePlotting_1_1SceneBuilder.md) should copy the widget’s view/projection matrices onto the scene before rendering or exporting.

Shared view matrix (camera pan/zoom). Default is identity.

variable projection_matrix

glm::mat4 projection_matrix {1.0f};

Shared projection matrix (world → NDC mapping). Default is identity. See [view_matrix](/api_generated/Classes/structCorePlotting_1_1RenderableScene.md#variable-view-matrix) note on identity defaults.

variable time_axis_origin_master_absolute

ClockTicks time_axis_origin_master_absolute {0};

Master-clock absolute time at the left edge of the visible window.

When non-zero (or always set by DataViewer), polyline/glyph/interval batch X coordinates are expressed as ``(master_time - this_origin) for float precision. Hit testing and interval metadata must add this value back to recover absolute time.

variable spatial_index

std::unique_ptr< QuadTree< EntityId > > spatial_index;

variable entity_to_series_key

std::unordered_map< EntityId, std::string > entity_to_series_key;

variable selected_entities

std::unordered_set< EntityId > selected_entities;

variable active_preview

std::optional< Interaction::GlyphPreview > active_preview;

Updated on 2026-11-13 at 20:25:42 +0000