OpenMS
Annotation1DDistanceItem Class Reference

An annotation item which represents a measured distance between two peaks. More...

#include <OpenMS/VISUAL/ANNOTATION/Annotation1DDistanceItem.h>

Inheritance diagram for Annotation1DDistanceItem:
[legend]
Collaboration diagram for Annotation1DDistanceItem:
[legend]

Public Member Functions

 Annotation1DDistanceItem (const QString &text, const PointXYType &start_point, const PointXYType &end_point, const bool swap_ends_if_negative=true)
 
 Annotation1DDistanceItem (const Annotation1DDistanceItem &rhs)=default
 Copy constructor. More...
 
 ~Annotation1DDistanceItem () override=default
 Destructor. More...
 
void ensureWithinDataRange (Plot1DCanvas *const canvas, const int layer_index) override
 Ensures that the item has coordinates within the visible area of the canvas. More...
 
void draw (Plot1DCanvas *const canvas, QPainter &painter, bool flipped=false) override
 Draws the item on painter. More...
 
void move (const PointXYType delta, const Gravitator &gr, const DimMapper< 2 > &dim_mapper) override
 Moves the item on the drawing canvas; behavior depends on item type and is implemented in the subclasses. More...
 
const PointXYTypegetStartPoint () const
 Returns the start point. More...
 
const PointXYTypegetEndPoint () const
 Returns the end point. More...
 
double getDistance () const
 Compute the (negative) euclidean distance between start and endpoint. More...
 
void setTicks (const std::vector< PointXYType > &ticks)
 Set tick lines for the distance item in unit XY coordinates (the gravity dimension is ignored) More...
 
Annotation1DItemclone () const override
 Creates a copy of the item on the heap and returns a pointer. More...
 
- Public Member Functions inherited from Annotation1DItem
virtual ~Annotation1DItem ()
 Destructor. More...
 
const QRectF & boundingBox () const
 Returns the current bounding box of this item on the canvas where it has last been drawn. More...
 
bool isSelected () const
 Returns true if this item is currently selected on the canvas, else false. More...
 
void setSelected (bool selected)
 Sets whether this item is currently selected on the canvas or not. More...
 
void setText (const QString &text)
 Sets the text of the item. More...
 
const QString & getText () const
 Returns the text of the item. More...
 
bool editText ()
 

Protected Attributes

PointXYType start_point_
 The start point of the measured distance line (in XY data coordinates) More...
 
PointXYType end_point_
 The end point of the measured distance line (in XY data coordinates) More...
 
std::vector< PointXYTypeticks_
 Additional tick lines for the distance item (the gravity dimension is ignored) More...
 
- Protected Attributes inherited from Annotation1DItem
QRectF bounding_box_
 The current bounding box of this item on the canvas where it has last been drawn. More...
 
bool selected_
 Determines whether this item is currently selected on the canvas. More...
 
QString text_
 The displayed text. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Annotation1DItem
 Annotation1DItem (const QString &text)
 Constructor. More...
 
 Annotation1DItem (const Annotation1DItem &rhs)
 Copy constructor. More...
 
void drawBoundingBox_ (QPainter &painter)
 Draws the bounding_box_. More...
 

Detailed Description

An annotation item which represents a measured distance between two peaks.

See also
Annotation1DItem

Constructor & Destructor Documentation

◆ Annotation1DDistanceItem() [1/2]

Annotation1DDistanceItem ( const QString &  text,
const PointXYType start_point,
const PointXYType end_point,
const bool  swap_ends_if_negative = true 
)
Parameters
textThe text to display between the two points
start_pointStart point in XY unit coordinates
end_pointEnd point in XY unit coordinates
swap_ends_if_negativeMake sure the distance is positive when creating the distance item?

Referenced by Annotation1DDistanceItem::clone().

◆ Annotation1DDistanceItem() [2/2]

Copy constructor.

◆ ~Annotation1DDistanceItem()

~Annotation1DDistanceItem ( )
overridedefault

Destructor.

Member Function Documentation

◆ clone()

Annotation1DItem* clone ( ) const
inlineoverridevirtual

Creates a copy of the item on the heap and returns a pointer.

Implements Annotation1DItem.

References Annotation1DDistanceItem::Annotation1DDistanceItem().

◆ draw()

void draw ( Plot1DCanvas *const  canvas,
QPainter &  painter,
bool  flipped = false 
)
overridevirtual

Draws the item on painter.

Implements Annotation1DItem.

◆ ensureWithinDataRange()

void ensureWithinDataRange ( Plot1DCanvas *const  canvas,
const int  layer_index 
)
overridevirtual

Ensures that the item has coordinates within the visible area of the canvas.

Implements Annotation1DItem.

◆ getDistance()

double getDistance ( ) const

Compute the (negative) euclidean distance between start and endpoint.

If the startpoint is closer to (0,0) than the endpoint, the distance will be positive; otherwise negative.

Returns
sign * sqrt(deltaX^2 + deltaY^2), where deltaX/Y is the difference between start and endpoint in dimension X/Y

◆ getEndPoint()

const PointXYType& getEndPoint ( ) const
inline

Returns the end point.

References Annotation1DDistanceItem::end_point_.

◆ getStartPoint()

const PointXYType& getStartPoint ( ) const
inline

Returns the start point.

References Annotation1DDistanceItem::start_point_.

◆ move()

void move ( const PointXYType  delta,
const Gravitator gr,
const DimMapper< 2 > &  dim_mapper 
)
overridevirtual

Moves the item on the drawing canvas; behavior depends on item type and is implemented in the subclasses.

Implements Annotation1DItem.

◆ setTicks()

void setTicks ( const std::vector< PointXYType > &  ticks)

Set tick lines for the distance item in unit XY coordinates (the gravity dimension is ignored)

Member Data Documentation

◆ end_point_

PointXYType end_point_
protected

The end point of the measured distance line (in XY data coordinates)

Referenced by Annotation1DDistanceItem::getEndPoint().

◆ start_point_

PointXYType start_point_
protected

The start point of the measured distance line (in XY data coordinates)

Referenced by Annotation1DDistanceItem::getStartPoint().

◆ ticks_

std::vector<PointXYType> ticks_
protected

Additional tick lines for the distance item (the gravity dimension is ignored)