Skip to main content

CorePlotting::Interaction::LineInteractionController

CorePlotting::Interaction::LineInteractionController

Controller for interactive line creation and modification. More…

#include <LineInteractionController.hpp>

Inherits from CorePlotting::Interaction::IGlyphInteractionController

Public Functions

Name
LineInteractionController() =default
Construct with default configuration.
LineInteractionController(LineInteractionConfig config)
Construct with custom configuration.
void setConfig(LineInteractionConfig config)
Set configuration.
LineInteractionConfig const & getConfig() const
Get current configuration.
void startEndpointDrag(float canvas_x, float canvas_y, std::string series_key, EntityId entity_id, LineEndpoint endpoint, glm::vec2 original_start, glm::vec2 original_end)
Start endpoint drag mode for modifying an existing line.
virtual void start(float canvas_x, float canvas_y, std::string series_key, std::optional< EntityId > existing_entity_id =std::nullopt) override
Begin a new interaction.
virtual void update(float canvas_x, float canvas_y) override
Update the interaction with new cursor position.
virtual void complete() override
Complete the interaction successfully.
virtual void cancel() override
Cancel the interaction without applying changes.
virtual bool isActive() const override
Check if an interaction is currently in progress.
virtual GlyphPreview getPreview() const override
Get the current preview geometry.
virtual std::string const & getSeriesKey() const override
Get the target series key.
virtual std::optional< EntityId > getEntityId() const override
Get the EntityId if modifying an existing element.
LineEndpoint getDraggedEndpoint() const
Get the endpoint being dragged (if in endpoint drag mode).
bool isEndpointDrag() const
Check if this is an endpoint drag (modification) vs creation.
glm::vec2 getStartPoint() const
Get current line start point in canvas coordinates.
glm::vec2 getEndPoint() const
Get current line end point in canvas coordinates.
float getLength() const
Get current line length in canvas pixels.
std::optional< std::pair< glm::vec2, glm::vec2 > > getOriginalLine() const
Get original line points (for modification mode).

Additional inherited members

Public Functions inherited from CorePlotting::Interaction::IGlyphInteractionController

Name
virtual ~IGlyphInteractionController() =default
bool isModification() const
Check if this interaction is modifying an existing element.

Detailed Description

class CorePlotting::Interaction::LineInteractionController;

Controller for interactive line creation and modification.

See: IGlyphInteractionController for the interface contract

Creation Mode (via [start()](/api_generated/Classes/classCorePlotting_1_1Interaction_1_1LineInteractionController.md#function-start)):

  • User clicks to set start point
  • Drags to set end point
  • Line preview updates during drag
  • Complete on mouse release

Modification Mode (via [startEndpointDrag()](/api_generated/Classes/classCorePlotting_1_1Interaction_1_1LineInteractionController.md#function-startendpointdrag)):

  • Used when user clicks near an endpoint of an existing line
  • Only the specified endpoint moves during drag
  • Shows ghost of original line

Axis Snapping:

  • If snap_to_axis is enabled, the line will snap to horizontal/vertical when within snap_angle_threshold degrees of the axis

Public Functions Documentation

function LineInteractionController

LineInteractionController() =default

Construct with default configuration.

function LineInteractionController

inline explicit LineInteractionController(
    LineInteractionConfig config
)

Construct with custom configuration.

function setConfig

inline void setConfig(
    LineInteractionConfig config
)

Set configuration.

function getConfig

inline LineInteractionConfig const & getConfig() const

Get current configuration.

function startEndpointDrag

void startEndpointDrag(
    float canvas_x,
    float canvas_y,
    std::string series_key,
    EntityId entity_id,
    LineEndpoint endpoint,
    glm::vec2 original_start,
    glm::vec2 original_end
)

Start endpoint drag mode for modifying an existing line.

Parameters:

  • canvas_x Starting X coordinate in canvas pixels
  • canvas_y Starting Y coordinate in canvas pixels
  • series_key Identifier of the series containing the line
  • entity_id EntityId of the line being modified
  • endpoint Which endpoint is being dragged
  • original_start Original start point in canvas coords
  • original_end Original end point in canvas coords

function start

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

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

Reimplements: CorePlotting::Interaction::IGlyphInteractionController::start

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

function update

virtual void update(
    float canvas_x,
    float canvas_y
) override

Update the interaction with new cursor position.

Parameters:

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

Reimplements: CorePlotting::Interaction::IGlyphInteractionController::update

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

function complete

virtual void complete() override

Complete the interaction successfully.

Reimplements: CorePlotting::Interaction::IGlyphInteractionController::complete

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

function cancel

virtual void cancel() override

Cancel the interaction without applying changes.

Reimplements: CorePlotting::Interaction::IGlyphInteractionController::cancel

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

function isActive

inline virtual bool isActive() const override

Check if an interaction is currently in progress.

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

Reimplements: CorePlotting::Interaction::IGlyphInteractionController::isActive

function getPreview

virtual GlyphPreview getPreview() const override

Get the current preview geometry.

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

Reimplements: CorePlotting::Interaction::IGlyphInteractionController::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

inline virtual std::string const & getSeriesKey() const override

Get the target series key.

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

Reimplements: CorePlotting::Interaction::IGlyphInteractionController::getSeriesKey

function getEntityId

inline virtual std::optional< EntityId > getEntityId() const override

Get the EntityId if modifying an existing element.

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

Reimplements: CorePlotting::Interaction::IGlyphInteractionController::getEntityId

function getDraggedEndpoint

inline LineEndpoint getDraggedEndpoint() const

Get the endpoint being dragged (if in endpoint drag mode).

function isEndpointDrag

inline bool isEndpointDrag() const

Check if this is an endpoint drag (modification) vs creation.

function getStartPoint

inline glm::vec2 getStartPoint() const

Get current line start point in canvas coordinates.

function getEndPoint

inline glm::vec2 getEndPoint() const

Get current line end point in canvas coordinates.

function getLength

inline float getLength() const

Get current line length in canvas pixels.

function getOriginalLine

inline std::optional< std::pair< glm::vec2, glm::vec2 > > getOriginalLine() const

Get original line points (for modification mode).


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