Skip to content

Class QAccelPlot::SpatialGrid

ClassList > QAccelPlot > SpatialGrid

Uniform-grid spatial index with bounded per-rectangle storage. More...

  • #include <SpatialGrid.hpp>

Public Functions

Type Name
void build (const double * data, int itemCount, int valuesPerItem=4)
Rebuilds the spatial index from data containing__itemCount axis-aligned rectangles.
void buildF (const float * data, int itemCount, int valuesPerItem=4)
Rebuilds the spatial index from single-precision data , likebuild() .
int query (double x, double y) const
Returns the index of the topmost rectangle that contains point ( x _,_y ), or -1 if none.
int queryTopmost (double minX, double minY, double maxX, double maxY, const std::function< bool(int)> & accept) const
Returns the highest index among rectangles overlapping the box for which accept returns true, or -1.

Public Static Functions

Type Name
int scanTopmost (const double * data, int itemCount, double minX, double minY, double maxX, double maxY, const std::function< bool(int)> & accept, int valuesPerItem=4)
Returns what queryTopmost() returns on a grid built from the same rectangles, without building one.
int scanTopmostF (const float * data, int itemCount, double minX, double minY, double maxX, double maxY, const std::function< bool(int)> & accept, int valuesPerItem=4)
Scans single-precision data , likescanTopmost() .

Detailed Description

Each item is stored as four consecutive doubles (x1, y1, x2, y2) in a flat array with a configurable valuesPerItem stride. Intended for use by RectangleSeries and similar shape types. Rectangles spanning more than 64 cells are stored once and checked separately during queries. An infinite edge leaves a rectangle unbounded in that direction; a rectangle with a NaN edge is never hit.

Public Functions Documentation

function build

Rebuilds the spatial index from data containing__itemCount axis-aligned rectangles.

void QAccelPlot::SpatialGrid::build (
    const double * data,
    int itemCount,
    int valuesPerItem=4
) 

Parameters:

  • data Pointer to the flat double array (x1, y1, x2, y2 per item, with valuesPerItem stride).
  • itemCount Number of rectangles in data.
  • valuesPerItem Number of doubles per rectangle entry (default 4).

function buildF

Rebuilds the spatial index from single-precision data , likebuild() .

void QAccelPlot::SpatialGrid::buildF (
    const float * data,
    int itemCount,
    int valuesPerItem=4
) 


function query

Returns the index of the topmost rectangle that contains point ( x _,_y ), or -1 if none.

int QAccelPlot::SpatialGrid::query (
    double x,
    double y
) const


function queryTopmost

Returns the highest index among rectangles overlapping the box for which accept returns true, or -1.

int QAccelPlot::SpatialGrid::queryTopmost (
    double minX,
    double minY,
    double maxX,
    double maxY,
    const std::function< bool(int)> & accept
) const

Lets callers apply a precise hit test, e.g. in pixel space, to the few candidates near a point.


Public Static Functions Documentation

function scanTopmost

Returns what queryTopmost() returns on a grid built from the same rectangles, without building one.

static int QAccelPlot::SpatialGrid::scanTopmost (
    const double * data,
    int itemCount,
    double minX,
    double minY,
    double maxX,
    double maxY,
    const std::function< bool(int)> & accept,
    int valuesPerItem=4
) 

Tests rectangles from the last to the first, so a call costs up to one pass over data. That is cheaper than a rebuild while the data is replaced after only a few queries.


function scanTopmostF

Scans single-precision data , likescanTopmost() .

static int QAccelPlot::SpatialGrid::scanTopmostF (
    const float * data,
    int itemCount,
    double minX,
    double minY,
    double maxX,
    double maxY,
    const std::function< bool(int)> & accept,
    int valuesPerItem=4
) 



The documentation for this class was generated from the following file QAccelPlot/src/QAccelPlot/series/SpatialGrid.hpp