RectangleInteractionController
RectangleInteractionController
Controller for interactive rectangle creation and modification. More…
#include <RectangleInteractionController.hpp>
Inherits from CorePlotting::Interaction::IGlyphInteractionController
Public Functions
| Name | |
|---|---|
| RectangleInteractionController() =default Construct with default configuration. |
|
| RectangleInteractionController(RectangleInteractionConfig config) Construct with custom configuration. |
|
| void | setConfig(RectangleInteractionConfig config) Set configuration. |
| RectangleInteractionConfig const & | getConfig() const Get current configuration. |
| void | setViewportHeight(float height) Update viewport height (call when widget resizes). |
| void | startEdgeDrag(float canvas_x, float canvas_y, std::string series_key, EntityId entity_id, RectangleEdge edge, glm::vec4 original_bounds) Start edge drag mode for modifying an existing rectangle. |
| 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. |
| RectangleEdge | getDraggedEdge() const Get the edge being dragged (if in edge drag mode). |
| bool | isEdgeDrag() const Check if this is an edge drag (modification) vs creation. |
| glm::vec4 | getCurrentBounds() const Get current rectangle bounds in canvas coordinates. |
| std::optional< glm::vec4 > | getOriginalBounds() const Get original rectangle bounds (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 RectangleInteractionController;Controller for interactive rectangle creation and modification.
See: IGlyphInteractionController for the interface contract
Supports two modes:
Creation Mode (via [start()](/api_generated/Classes/classRectangleInteractionController.md#function-start)):
- User clicks to set first corner
- Drags to set opposite corner
- Rectangle preview updates during drag
- Complete on mouse release
Modification Mode (via [startEdgeDrag()](/api_generated/Classes/classRectangleInteractionController.md#function-startedgedrag)):
- Used when user clicks on an edge of an existing rectangle
- Only the specified edge moves during drag
- Shows ghost of original position
Interval Mode (constrain_to_x_axis = true):
- Rectangle height spans full canvas
- Only X coordinates matter (for DigitalIntervalSeries)
Selection Box Mode (constrain_to_x_axis = false):
- User defines both width and height
- For rectangular selection regions
Public Functions Documentation
function RectangleInteractionController
RectangleInteractionController() =defaultConstruct with default configuration.
function RectangleInteractionController
inline explicit RectangleInteractionController(
RectangleInteractionConfig config
)Construct with custom configuration.
function setConfig
inline void setConfig(
RectangleInteractionConfig config
)Set configuration.
function getConfig
inline RectangleInteractionConfig const & getConfig() constGet current configuration.
function setViewportHeight
inline void setViewportHeight(
float height
)Update viewport height (call when widget resizes).
function startEdgeDrag
void startEdgeDrag(
float canvas_x,
float canvas_y,
std::string series_key,
EntityId entity_id,
RectangleEdge edge,
glm::vec4 original_bounds
)Start edge drag mode for modifying an existing rectangle.
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 rectangle
- entity_id EntityId of the rectangle being modified
- edge Which edge is being dragged
- original_bounds Original rectangle {x, y, width, height} in canvas coords
Called when the user clicks on an edge of an existing rectangle. The widget should pre-process the hit test result and provide:
- Which edge was hit
- The original bounds of the rectangle
- The EntityId of the rectangle being modified
function start
virtual void start(
float canvas_x,
float canvas_y,
std::string series_key,
std::optional< EntityId > existing_entity_id =std::nullopt
) overrideBegin 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
) overrideUpdate 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() overrideComplete 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/classRectangleInteractionController.md#function-isactive) returns false and [getPreview()](/api_generated/Classes/classRectangleInteractionController.md#function-getpreview) contains the final geometry for conversion to data coordinates.
function cancel
virtual void cancel() overrideCancel 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/classRectangleInteractionController.md#function-isactive) returns false.
function isActive
inline virtual bool isActive() const overrideCheck 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 overrideGet 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 overrideGet 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 overrideGet the EntityId if modifying an existing element.
Return: EntityId if modifying, std::nullopt if creating new
Reimplements: CorePlotting::Interaction::IGlyphInteractionController::getEntityId
function getDraggedEdge
inline RectangleEdge getDraggedEdge() constGet the edge being dragged (if in edge drag mode).
function isEdgeDrag
inline bool isEdgeDrag() constCheck if this is an edge drag (modification) vs creation.
function getCurrentBounds
inline glm::vec4 getCurrentBounds() constGet current rectangle bounds in canvas coordinates.
Return: {x, y, width, height} where (x,y) is top-left
function getOriginalBounds
inline std::optional< glm::vec4 > getOriginalBounds() constGet original rectangle bounds (for modification mode).
Updated on 2026-11-13 at 20:25:40 +0000