CorePlotting::HitTestResult
CorePlotting::HitTestResult
Result of a hit test query. More…
#include <HitTestResult.hpp>
Public Functions
| Name | |
|---|---|
| HitTestResult() =default Default constructor creates a “no hit” result. |
|
| bool | hasHit() const Check if anything was hit. |
| bool | hasEntityId() const Check if the hit target has an EntityId. |
| bool | isIntervalHit() const Check if this is an interval hit (body or edge). |
| bool | isIntervalEdge() const Check if this is an interval edge hit. |
| bool | isDiscrete() const Check if this is a discrete/clickable element (event, interval, point). |
| bool | isCloserThan(HitTestResult const & other) const Compare hit results by distance (for finding closest hit). |
| HitTestResult | noHit() Create a “no hit” result. |
| HitTestResult | eventHit(std::string key, EntityId id, float dist, float x, float y) Create a digital event hit result. |
| HitTestResult | intervalBodyHit(std::string key, EntityId id, int64_t start, int64_t end, float dist) Create an interval body hit result. |
| HitTestResult | intervalEdgeHit(std::string key, EntityId id, bool is_left_edge, int64_t start, int64_t end, float edge_time, float dist) Create an interval edge hit result. |
| HitTestResult | analogSeriesHit(std::string key, float x, float y, float dist =0.0f) Create an analog series region hit result. |
| HitTestResult | pointHit(std::string key, EntityId id, float x, float y, float dist) Create a point hit result. |
Public Attributes
| Name | |
|---|---|
| HitType | hit_type Type of element that was hit. |
| std::string | series_key Series key (empty if no hit). |
| std::optional< EntityId > | entity_id EntityId if the hit target has one (events, intervals, points). |
| float | distance |
| float | world_x World X coordinate of the hit target (for events: time, for intervals: edge position). |
| float | world_y World Y coordinate of the hit target. |
| std::optional< int64_t > | interval_start For intervals: the start time of the interval. |
| std::optional< int64_t > | interval_end For intervals: the end time of the interval. |
Detailed Description
struct CorePlotting::HitTestResult;Result of a hit test query.
See: SceneHitTester for the query interface
Contains all information about what (if anything) was hit at a given screen/world position. This struct is returned by SceneHitTester and used by widgets to determine appropriate responses to mouse events.
Design philosophy:
[entity_id](/api_generated/Classes/structCorePlotting_1_1HitTestResult.md#variable-entity-id)is present for discrete data (events, intervals, points)[entity_id](/api_generated/Classes/structCorePlotting_1_1HitTestResult.md#variable-entity-id)is absent for continuous data (analog series regions)[series_key](/api_generated/Classes/structCorePlotting_1_1HitTestResult.md#variable-series-key)identifies which series was hit (always present if hit_type != None)[distance](/api_generated/Classes/structCorePlotting_1_1HitTestResult.md#variable-distance)allows selecting the closest hit when multiple candidates exist
Public Functions Documentation
function HitTestResult
HitTestResult() =defaultDefault constructor creates a “no hit” result.
function hasHit
inline bool hasHit() constCheck if anything was hit.
Return: true if hit_type is not None
function hasEntityId
inline bool hasEntityId() constCheck if the hit target has an EntityId.
Return: true if entity_id contains a value
function isIntervalHit
inline bool isIntervalHit() constCheck if this is an interval hit (body or edge).
Return: true if hit_type is IntervalBody, IntervalEdgeLeft, or IntervalEdgeRight
function isIntervalEdge
inline bool isIntervalEdge() constCheck if this is an interval edge hit.
Return: true if hit_type is IntervalEdgeLeft or IntervalEdgeRight
function isDiscrete
inline bool isDiscrete() constCheck if this is a discrete/clickable element (event, interval, point).
Return: true if the hit type represents a discrete element
function isCloserThan
inline bool isCloserThan(
HitTestResult const & other
) constCompare hit results by distance (for finding closest hit).
function noHit
static inline HitTestResult noHit()Create a “no hit” result.
function eventHit
static inline HitTestResult eventHit(
std::string key,
EntityId id,
float dist,
float x,
float y
)Create a digital event hit result.
Parameters:
- key Series key
- id Entity ID of the event
- dist Distance from query point
- x World X coordinate (time) of the event
- y World Y coordinate of the event
function intervalBodyHit
static inline HitTestResult intervalBodyHit(
std::string key,
EntityId id,
int64_t start,
int64_t end,
float dist
)Create an interval body hit result.
Parameters:
function intervalEdgeHit
static inline HitTestResult intervalEdgeHit(
std::string key,
EntityId id,
bool is_left_edge,
int64_t start,
int64_t end,
float edge_time,
float dist
)Create an interval edge hit result.
Parameters:
function analogSeriesHit
static inline HitTestResult analogSeriesHit(
std::string key,
float x,
float y,
float dist =0.0f
)Create an analog series region hit result.
Parameters:
- key Series key
- x World X coordinate
- y World Y coordinate
- dist Distance from series center (or 0 if within bounds)
function pointHit
static inline HitTestResult pointHit(
std::string key,
EntityId id,
float x,
float y,
float dist
)Create a point hit result.
Parameters:
- key Series key
- id Entity ID of the point
- x World X coordinate
- y World Y coordinate
- dist Distance from query point
Public Attributes Documentation
variable hit_type
HitType hit_type {HitType::None};Type of element that was hit.
variable series_key
std::string series_key;Series key (empty if no hit).
variable entity_id
std::optional< EntityId > entity_id;EntityId if the hit target has one (events, intervals, points).
variable distance
float distance {std::numeric_limits<float>::max()};World-space distance from query point to hit target Lower values indicate more precise hits
variable world_x
float world_x {0.0f};World X coordinate of the hit target (for events: time, for intervals: edge position).
variable world_y
float world_y {0.0f};World Y coordinate of the hit target.
variable interval_start
std::optional< int64_t > interval_start;For intervals: the start time of the interval.
variable interval_end
std::optional< int64_t > interval_end;For intervals: the end time of the interval.
Updated on 2026-11-13 at 20:25:42 +0000