OpenMS
Gravitator Class Reference

Manipulates X or Y component of points in the X-Y plane, by assuming one axis (either X or Y axis) has gravity acting upon it. More...

#include <OpenMS/VISUAL/Plot1DCanvas.h>

Collaboration diagram for Gravitator:
[legend]

Public Types

using AreaXYType = PlotCanvas::GenericArea::AreaXYType
 

Public Member Functions

 Gravitator (DIM axis)
 C'tor to apply gravity on any axis. More...
 
 Gravitator (const DimMapper< 2 > &unit_mapper)
 Convenience c'tor, which picks the Intensity dimension from a DimMapper as gravity axis. More...
 
void setGravityAxis (DIM axis)
 
void setIntensityAsGravity (const DimMapper< 2 > &unit_mapper)
 Convenience function, which picks the Intensity dimension from a DimMapper as gravity axis. More...
 
DIM getGravityAxis () const
 Which axis is affected by gravity? More...
 
Gravitator swap () const
 Swap gravity axis (from X to Y, or vice versa) More...
 
QPoint gravitateMin (QPoint p, const AreaXYType &area) const
 
QPoint gravitateWith (QPoint p, const QPoint &delta) const
 
template<UInt D>
DPosition< D > gravitateWith (DPosition< D > p, const DPosition< D > &delta) const
 Same as gravitateWith() More...
 
QPoint gravitateTo (QPoint p, const QPoint &target) const
 
template<UInt D>
DPosition< D > gravitateTo (DPosition< D > p, const DPosition< D > &target) const
 Same as gravitateTo() More...
 
QPoint gravitateMax (QPoint p, const AreaXYType &area) const
 Opposite of gravitateMin() More...
 
QPoint gravitateZero (QPoint p) const
 
template<UInt D>
DPosition< D > gravitateZero (DPosition< D > p) const
 
template<UInt D>
DPosition< D > gravitateNAN (DPosition< D > p) const
 
int gravityValue (const QPoint &p) const
 
template<UInt D>
int gravityValue (const DPosition< D > &p) const
 
template<UInt D>
auto gravityDiff (const DPosition< D > &start, const DPosition< D > &end) const
 

Private Attributes

DIM gravity_axis_
 Where are points in the X-Y plane projected onto when drawing lines? More...
 

Detailed Description

Manipulates X or Y component of points in the X-Y plane, by assuming one axis (either X or Y axis) has gravity acting upon it.

Example: Assume there is a X-Y plane with RT(on X axis) and Intensity(on Y axis). Given a point on the plane, you can make it 'drop down', to a minimum intensity, by applying a gravity on the Y axis. You can also make the point 'fly up'.

Member Typedef Documentation

◆ AreaXYType

Constructor & Destructor Documentation

◆ Gravitator() [1/2]

Gravitator ( DIM  axis)
inline

C'tor to apply gravity on any axis.

Parameters
axisWhich axis

References Gravitator::setGravityAxis().

◆ Gravitator() [2/2]

Gravitator ( const DimMapper< 2 > &  unit_mapper)
inline

Convenience c'tor, which picks the Intensity dimension from a DimMapper as gravity axis.

Parameters
unit_mapperPick the Intensity axis from this mapper (or throw exception). See setGravityAxis().

References Gravitator::setIntensityAsGravity().

Member Function Documentation

◆ getGravityAxis()

DIM getGravityAxis ( ) const
inline

Which axis is affected by gravity?

References Gravitator::gravity_axis_.

◆ gravitateMax()

QPoint gravitateMax ( QPoint  p,
const AreaXYType area 
) const
inline

◆ gravitateMin()

QPoint gravitateMin ( QPoint  p,
const AreaXYType area 
) const
inline

Pull the point p to the current gravity axis, i.e. the lowest point on the Area

Parameters
pA X-Y data point
areaAn area which contains the min/max range of X and Y axis
Returns
A X-Y data point identical to p, but with its gravity-axis value changed to the minimum given in area

References Gravitator::gravity_axis_, DIntervalBase< D >::minX(), DIntervalBase< D >::minY(), OpenMS::X, and OpenMS::Y.

◆ gravitateNAN()

DPosition<D> gravitateNAN ( DPosition< D >  p) const
inline

Pull the point p to NAN on the current gravity axis.

Parameters
pA X-Y data point
Returns
A X-Y data point with its gravity axis set to NAN

References Gravitator::gravity_axis_.

◆ gravitateTo() [1/2]

DPosition<D> gravitateTo ( DPosition< D >  p,
const DPosition< D > &  target 
) const
inline

◆ gravitateTo() [2/2]

QPoint gravitateTo ( QPoint  p,
const QPoint &  target 
) const
inline

Change the value of p's gravity dimension to the value of targets'. Other dimensions remain untouched.

Parameters
pA X-Y data point
targetA target value, of which we only use the gravity dimension's part.
Returns
A X-Y data point identical to p, but with its gravity-axis value changed by target's value.

References Gravitator::gravity_axis_, OpenMS::X, and OpenMS::Y.

◆ gravitateWith() [1/2]

DPosition<D> gravitateWith ( DPosition< D >  p,
const DPosition< D > &  delta 
) const
inline

◆ gravitateWith() [2/2]

QPoint gravitateWith ( QPoint  p,
const QPoint &  delta 
) const
inline

Add value of delta's gravity dimension to the gravity dimension of point p. Other dimensions remain untouched.

Parameters
pA X-Y data point
deltaA distance, of which we only use the gravity dimension's part.
Returns
A X-Y data point identical to p, but with its gravity-axis value changed by adding delta.

References Gravitator::gravity_axis_, OpenMS::X, and OpenMS::Y.

◆ gravitateZero() [1/2]

DPosition<D> gravitateZero ( DPosition< D >  p) const
inline

Pull the point p to zero (0) on the current gravity axis.

Parameters
pA X-Y data point
Returns
A X-Y data point with its gravity axis set to '0'

References Gravitator::gravity_axis_.

◆ gravitateZero() [2/2]

QPoint gravitateZero ( QPoint  p) const
inline

Pull the point p to zero (0) on the current gravity axis.

Parameters
pA X-Y data point
Returns
A X-Y data point with its gravity axis set to '0'

References Gravitator::gravity_axis_, OpenMS::X, and OpenMS::Y.

Referenced by Annotation1DPeakItem< DataPoint >::draw().

◆ gravityDiff()

auto gravityDiff ( const DPosition< D > &  start,
const DPosition< D > &  end 
) const
inline

Get the difference of values in the gravity dimension

Parameters
startThe start point in XY coordinates
endThe end point in XY coordinates
Returns
The difference of (end-start) in the X or Y component, depending on gravity

References Gravitator::gravity_axis_.

◆ gravityValue() [1/2]

int gravityValue ( const DPosition< D > &  p) const
inline

Get the value of the gravity dimension

Parameters
pA X-Y data point
Returns
Either the X or Y component, depending on gravity

References Gravitator::gravity_axis_.

◆ gravityValue() [2/2]

int gravityValue ( const QPoint &  p) const
inline

Get the value of the gravity dimension

Parameters
pA X-Y data point
Returns
Either the X or Y component, depending on gravity

References Gravitator::gravity_axis_, OpenMS::X, and OpenMS::Y.

◆ setGravityAxis()

void setGravityAxis ( DIM  axis)
inline

Which axis is pulling a point downwards (e.g. when plotting sticks) Note that pulling (see gravitateDown()) will only change the value for the gravity axis. E.g. with gravity on Y, a Point(X=10, Y=10), will be pulled to Point(X=10, Y=min)

Parameters
axisEither X, or Y
Exceptions
Exception::InvalidValueif axis is not X or Y

References Gravitator::gravity_axis_, OpenMS::X, and OpenMS::Y.

Referenced by Gravitator::Gravitator(), Gravitator::setIntensityAsGravity(), and Gravitator::swap().

◆ setIntensityAsGravity()

void setIntensityAsGravity ( const DimMapper< 2 > &  unit_mapper)
inline

Convenience function, which picks the Intensity dimension from a DimMapper as gravity axis.

Parameters
unit_mapper
Exceptions
Exception::NotImplementedif unit_mapper does not have an Intensity dimension

if 1D view has no intensity dimension, go think about what dimension should be gravitational...

References DimMapper< N_DIM >::getDim(), DimBase::getUnit(), OpenMS::INT, Gravitator::setGravityAxis(), OpenMS::X, and OpenMS::Y.

Referenced by Gravitator::Gravitator().

◆ swap()

Gravitator swap ( ) const
inline

Swap gravity axis (from X to Y, or vice versa)

Returns
An orthogonal gravity model

References Gravitator::setGravityAxis(), OpenMS::X, and OpenMS::Y.

Referenced by Annotation1DPeakItem< DataPoint >::draw().

Member Data Documentation

◆ gravity_axis_