OpenMS  2.8.0
Public Member Functions | Private Attributes | List of all members
OverlapDetector Class Reference

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)
 C'tor: number of levels must be >=1. More...
 
size_t placeItem (double x_start, double x_end)
 

Private Attributes

std::vector< double > rows_
 

Detailed Description

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.

X coordinates should always be positive.

Constructor & Destructor Documentation

◆ OverlapDetector()

OverlapDetector ( int  levels)
explicit

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

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