OpenMS
OverlapDetector Class Reference

A heuristic: Given a set of levels (rows), try to add items at to topmost row which does not overlap an already placed item in this row (according to its x-coordinate) More...

#include <OpenMS/VISUAL/MISC/GUIHelpers.h>

Collaboration diagram for OverlapDetector:
[legend]

Public Member Functions

 OverlapDetector (int levels)
 
size_t placeItem (double x_start, double x_end)
 

Private Attributes

std::vector< double > rows_
 store the largest x_end for each row More...
 

Detailed Description

A heuristic: Given a set of levels (rows), try to add items at to topmost row which does not overlap an already placed item in this row (according to its x-coordinate)

If a collision occurs, try the row below. If no row is collision-free, pick the one with the smallest overlap.

Only positions beyond the largest x-coordinate observed so far are considered (i.e. gaps are not filled).

X-coordinates should always be positive (a warning is issued otherwise).

Constructor & Destructor Documentation

◆ OverlapDetector()

OverlapDetector ( int  levels)
explicit

C'tor: number of levels must be >=1

Exceptions
Exception::InvalidSizeif levels <= 0

Member Function Documentation

◆ placeItem()

size_t placeItem ( double  x_start,
double  x_end 
)

try to put an item which spans from x_start to x_end in the topmost row possible

Returns
the smallest row index (starting at 0) which has none (or the least) overlap

Member Data Documentation

◆ rows_

std::vector<double> rows_
private

store the largest x_end for each row