CorePlotting::Interaction::GlyphPreview
CorePlotting::Interaction::GlyphPreview
Preview geometry for rendering during interactive glyph creation/modification. More…
#include <GlyphPreview.hpp>
Public Types
| Name | |
|---|---|
| enum class | Type { None, Point, Line, Rectangle, Polygon} Type of primitive being previewed. |
Public Functions
| Name | |
|---|---|
| bool | isValid() const Check if this preview has any geometry. |
| bool | isModification() const Check if this is a modification (has original geometry). |
| void | clear() Clear all geometry and reset to None. |
| GlyphPreview | makePoint(glm::vec2 pos) Create a point preview. |
| GlyphPreview | makeLine(glm::vec2 start, glm::vec2 end) Create a line preview. |
| GlyphPreview | makeRectangle(float x, float y, float width, float height) Create a rectangle preview. |
| GlyphPreview | makeRectangleFromCorners(glm::vec2 corner1, glm::vec2 corner2) Create a rectangle preview from two corner points. |
| GlyphPreview | makePolygon(std::vector< glm::vec2 > vertices) Create a polygon preview. |
Public Attributes
| Name | |
|---|---|
| Type | type Current preview type. |
| glm::vec2 | point Point position (for Type::Point). |
| glm::vec2 | line_start Line start point (for Type::Line). |
| glm::vec2 | line_end Line end point (for Type::Line). |
| glm::vec4 | rectangle |
| std::vector< glm::vec2 > | polygon_vertices Polygon vertices in order (for Type::Polygon). |
| std::optional< glm::vec4 > | original_rectangle Original rectangle bounds before modification (if modifying existing). |
| std::optional< std::pair< glm::vec2, glm::vec2 > > | original_line Original line endpoints before modification (if modifying existing). |
| std::optional< glm::vec2 > | original_point Original point position before modification (if modifying existing). |
| glm::vec4 | fill_color Fill color (RGBA, for rectangles and polygons). |
| glm::vec4 | stroke_color Stroke/outline color (RGBA). |
| float | stroke_width Stroke width in pixels. |
| glm::vec4 | ghost_color Color for the “ghost” of original geometry (when modifying). |
| bool | show_fill Whether to render filled interior (for rectangles/polygons). |
| bool | show_stroke Whether to render stroke/outline. |
| bool | show_ghost Whether to show the original position ghost (when modifying). |
Detailed Description
struct CorePlotting::Interaction::GlyphPreview;Preview geometry for rendering during interactive glyph creation/modification.
See:
- IGlyphInteractionController for the source of preview data
- PlottingOpenGL::PreviewRenderer for rendering
This struct holds the geometric state of an interaction in canvas coordinates (pixels). It is produced by IGlyphInteractionController::getPreview() and consumed by PlottingOpenGL::PreviewRenderer.
Coordinate System: All positions are in canvas pixels with:
- Origin at top-left corner of the viewport
- X increasing rightward
- Y increasing downward
Supported Primitive Types:
- Point: Single position (for placing markers)
- Line: Two endpoints (for line selection/annotation)
- Rectangle: Position + size (for intervals, selection boxes)
- Polygon: Arbitrary vertex list (for freeform regions)
Modification Mode: When modifying an existing element (vs creating new), the “original” fields contain the element’s position before modification, allowing the renderer to show a “ghost” of the original alongside the new position.
Public Types Documentation
enum Type
| Enumerator | Value | Description |
|---|---|---|
| None | No active preview. | |
| Point | Single point (use [point]() field). |
|
| Line | Line segment (use [line_start](), [line_end]() fields). |
|
| Rectangle | Axis-aligned rectangle (use [rectangle]() field). |
|
| Polygon | Arbitrary polygon (use [polygon_vertices]() field). |
Type of primitive being previewed.
Public Functions Documentation
function isValid
inline bool isValid() constCheck if this preview has any geometry.
function isModification
inline bool isModification() constCheck if this is a modification (has original geometry).
function clear
inline void clear()Clear all geometry and reset to None.
function makePoint
static inline GlyphPreview makePoint(
glm::vec2 pos
)Create a point preview.
function makeLine
static inline GlyphPreview makeLine(
glm::vec2 start,
glm::vec2 end
)Create a line preview.
function makeRectangle
static inline GlyphPreview makeRectangle(
float x,
float y,
float width,
float height
)Create a rectangle preview.
Parameters:
- x Left edge (canvas X)
- y Top edge (canvas Y)
- width Width in pixels
- height Height in pixels
function makeRectangleFromCorners
static inline GlyphPreview makeRectangleFromCorners(
glm::vec2 corner1,
glm::vec2 corner2
)Create a rectangle preview from two corner points.
function makePolygon
static inline GlyphPreview makePolygon(
std::vector< glm::vec2 > vertices
)Create a polygon preview.
Public Attributes Documentation
variable type
Type type {Type::None};Current preview type.
variable point
glm::vec2 point {0.0f};Point position (for Type::Point).
variable line_start
glm::vec2 line_start {0.0f};Line start point (for Type::Line).
variable line_end
glm::vec2 line_end {0.0f};Line end point (for Type::Line).
variable rectangle
glm::vec4 rectangle {0.0f};Rectangle as {x, y, width, height} (for Type::Rectangle)
- x, y: Top-left corner in canvas coords
- width, height: Size in pixels (always positive)
variable polygon_vertices
std::vector< glm::vec2 > polygon_vertices;Polygon vertices in order (for Type::Polygon).
variable original_rectangle
std::optional< glm::vec4 > original_rectangle;Original rectangle bounds before modification (if modifying existing).
variable original_line
std::optional< std::pair< glm::vec2, glm::vec2 > > original_line;Original line endpoints before modification (if modifying existing).
variable original_point
std::optional< glm::vec2 > original_point;Original point position before modification (if modifying existing).
variable fill_color
glm::vec4 fill_color {1.0f, 1.0f, 1.0f, 0.3f};Fill color (RGBA, for rectangles and polygons).
variable stroke_color
glm::vec4 stroke_color {1.0f, 1.0f, 1.0f, 1.0f};Stroke/outline color (RGBA).
variable stroke_width
float stroke_width {2.0f};Stroke width in pixels.
variable ghost_color
glm::vec4 ghost_color {0.5f, 0.5f, 0.5f, 0.3f};Color for the “ghost” of original geometry (when modifying).
variable show_fill
bool show_fill {true};Whether to render filled interior (for rectangles/polygons).
variable show_stroke
bool show_stroke {true};Whether to render stroke/outline.
variable show_ghost
bool show_ghost {true};Whether to show the original position ghost (when modifying).
Updated on 2026-11-13 at 20:25:42 +0000