Skip to main content

CorePlotting::Interaction::IGlyphInteractionController

CorePlotting::Interaction::IGlyphInteractionController

Abstract interface for interactive glyph creation and modification controllers. More…

#include <IGlyphInteractionController.hpp>

Inherited by CorePlotting::Interaction::LineInteractionController, CorePlotting::Interaction::PolygonInteractionController, CorePlotting::Interaction::RectangleInteractionController

Public Functions

Name
virtual ~IGlyphInteractionController() =default
virtual void start(float canvas_x, float canvas_y, std::string series_key, std::optional< EntityId > existing_entity_id =std::nullopt) =0
Begin a new interaction.
virtual void update(float canvas_x, float canvas_y) =0
Update the interaction with new cursor position.
virtual void complete() =0
Complete the interaction successfully.
virtual void cancel() =0
Cancel the interaction without applying changes.
virtual bool isActive() const =0
Check if an interaction is currently in progress.
virtual GlyphPreview getPreview() const =0
Get the current preview geometry.
virtual std::string const & getSeriesKey() const =0
Get the target series key.
virtual std::optional< EntityId > getEntityId() const =0
Get the EntityId if modifying an existing element.
bool isModification() const
Check if this interaction is modifying an existing element.

Detailed Description

class CorePlotting::Interaction::IGlyphInteractionController;

Abstract interface for interactive glyph creation and modification controllers.

See:

This interface defines the contract for controllers that handle user interactions for creating or modifying visual elements (rectangles, lines, points, polygons).

Coordinate System: All coordinates are in canvas pixels (screen space). The widget is responsible for passing canvas coordinates from mouse events, and the Scene handles conversion to world/data coordinates via inverse transforms.

Lifecycle:

  1. Widget creates appropriate controller based on interaction mode
  2. [start()](/api_generated/Classes/classCorePlotting_1_1Interaction_1_1IGlyphInteractionController.md#function-start) called on mouse press with canvas coordinates
  3. [update()](/api_generated/Classes/classCorePlotting_1_1Interaction_1_1IGlyphInteractionController.md#function-update) called on mouse move to update preview
  4. [complete()](/api_generated/Classes/classCorePlotting_1_1Interaction_1_1IGlyphInteractionController.md#function-complete) called on mouse release to finalize
  5. Widget retrieves preview via [getPreview()](/api_generated/Classes/classCorePlotting_1_1Interaction_1_1IGlyphInteractionController.md#function-getpreview) and converts to data coordinates
  6. Controller can be reused or destroyed

Modification vs Creation:

  • Creating new: [start()](/api_generated/Classes/classCorePlotting_1_1Interaction_1_1IGlyphInteractionController.md#function-start) with existing_entity_id = std::nullopt
  • Modifying existing: [start()](/api_generated/Classes/classCorePlotting_1_1Interaction_1_1IGlyphInteractionController.md#function-start) with the EntityId of the element being modified (e.g., interval edge drag). The controller may need additional info passed via a subclass-specific method (see RectangleInteractionController::startEdgeDrag).

Public Functions Documentation

function ~IGlyphInteractionController

virtual ~IGlyphInteractionController() =default

function start

virtual void start(
    float canvas_x,
    float canvas_y,
    std::string series_key,
    std::optional< EntityId > existing_entity_id =std::nullopt
) =0

Begin a new interaction.

Parameters:

  • canvas_x X coordinate in canvas pixels
  • canvas_y Y coordinate in canvas pixels
  • series_key Identifier of the target series (for data commit)
  • existing_entity_id If modifying an existing element, its EntityId; std::nullopt if creating a new element

Reimplemented by: CorePlotting::Interaction::LineInteractionController::start, CorePlotting::Interaction::PolygonInteractionController::start, CorePlotting::Interaction::RectangleInteractionController::start, RectangleInteractionController::start

Called when the user initiates an interaction (typically on mouse press).

function update

virtual void update(
    float canvas_x,
    float canvas_y
) =0

Update the interaction with new cursor position.

Parameters:

  • canvas_x Current X coordinate in canvas pixels
  • canvas_y Current Y coordinate in canvas pixels

Reimplemented by: CorePlotting::Interaction::LineInteractionController::update, CorePlotting::Interaction::PolygonInteractionController::update, CorePlotting::Interaction::RectangleInteractionController::update, RectangleInteractionController::update

Called during mouse move while the interaction is active. Updates the preview geometry based on the new position.

function complete

virtual void complete() =0

Complete the interaction successfully.

Reimplemented by: CorePlotting::Interaction::LineInteractionController::complete, CorePlotting::Interaction::PolygonInteractionController::complete, CorePlotting::Interaction::RectangleInteractionController::complete, RectangleInteractionController::complete

Called when the user finishes the interaction (typically on mouse release). After this call, [isActive()](/api_generated/Classes/classCorePlotting_1_1Interaction_1_1IGlyphInteractionController.md#function-isactive) returns false and [getPreview()](/api_generated/Classes/classCorePlotting_1_1Interaction_1_1IGlyphInteractionController.md#function-getpreview) contains the final geometry for conversion to data coordinates.

function cancel

virtual void cancel() =0

Cancel the interaction without applying changes.

Reimplemented by: CorePlotting::Interaction::LineInteractionController::cancel, CorePlotting::Interaction::PolygonInteractionController::cancel, CorePlotting::Interaction::RectangleInteractionController::cancel, RectangleInteractionController::cancel

Called when the interaction should be aborted (e.g., Escape key pressed). After this call, [isActive()](/api_generated/Classes/classCorePlotting_1_1Interaction_1_1IGlyphInteractionController.md#function-isactive) returns false.

function isActive

virtual bool isActive() const =0

Check if an interaction is currently in progress.

Return: true if between start() and complete()/cancel()

Reimplemented by: CorePlotting::Interaction::LineInteractionController::isActive, CorePlotting::Interaction::PolygonInteractionController::isActive, CorePlotting::Interaction::RectangleInteractionController::isActive, RectangleInteractionController::isActive

function getPreview

virtual GlyphPreview getPreview() const =0

Get the current preview geometry.

Return: Current preview geometry (valid even after complete())

Reimplemented by: CorePlotting::Interaction::LineInteractionController::getPreview, CorePlotting::Interaction::PolygonInteractionController::getPreview, CorePlotting::Interaction::RectangleInteractionController::getPreview, RectangleInteractionController::getPreview

Returns the preview in canvas coordinates, suitable for rendering via PreviewRenderer. The preview type matches the controller type (e.g., RectangleInteractionController produces Rectangle previews).

function getSeriesKey

virtual std::string const & getSeriesKey() const =0

Get the target series key.

Return: Series key passed to start(), empty string if not active

Reimplemented by: CorePlotting::Interaction::LineInteractionController::getSeriesKey, CorePlotting::Interaction::PolygonInteractionController::getSeriesKey, CorePlotting::Interaction::RectangleInteractionController::getSeriesKey, RectangleInteractionController::getSeriesKey

function getEntityId

virtual std::optional< EntityId > getEntityId() const =0

Get the EntityId if modifying an existing element.

Return: EntityId if modifying, std::nullopt if creating new

Reimplemented by: CorePlotting::Interaction::LineInteractionController::getEntityId, CorePlotting::Interaction::PolygonInteractionController::getEntityId, CorePlotting::Interaction::RectangleInteractionController::getEntityId, RectangleInteractionController::getEntityId

function isModification

inline bool isModification() const

Check if this interaction is modifying an existing element.

Return: true if modifying existing (has EntityId), false if creating new


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