OpenMS
Annotation1DVerticalLineItem Class Reference

An annotation item which represents a vertical line (or more precisely a line along the gravity axis, i.e. it could also be horizontal) and text label on top. More...

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

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

Public Member Functions

 Annotation1DVerticalLineItem (const PointXYType &center_pos, const QColor &color=QColor("as_before"), const QString &text="")
 
 Annotation1DVerticalLineItem (const PointXYType &center_pos, const float width, const int alpha255=128, const bool dashed_line=false, const QColor &color=QColor("as_before"), const QString &text="")
 
 Annotation1DVerticalLineItem (const Annotation1DVerticalLineItem &rhs)=default
 Copy constructor. More...
 
 ~Annotation1DVerticalLineItem () 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...
 
void setPosition (const PointXYType &pos)
 Sets the center position of the line (the widths will extend from there) More...
 
const PointXYTypegetPosition () const
 Returns the position on the non-gravity-axis. More...
 
QRectF getTextRect () const
 size of the painted text (width and height of the rectangle) More...
 
void setTextOffset (int offset)
 offset the text by this much downwards in y-direction (to avoid overlaps etc) 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 pos_
 The position of the line (gravity axis is ignored) More...
 
int text_offset_ {0}
 offset (in pixel coordinates of gravity axis) in for the text (to avoid overlaps) More...
 
float width_ = 0
 width of the item in unit coordinates (allowing to show a 'band'; use =0 to make a thin line and not a band) More...
 
int alpha255_ = 128
 transparency 0...255 of the band/line More...
 
bool dashed_ {false}
 is the band/line dashed? More...
 
QColor color_ = Qt::black
 The color of the line; if invalid, the current painter color will be used. 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 vertical line (or more precisely a line along the gravity axis, i.e. it could also be horizontal) and text label on top.

See also
Annotation1DItem

Constructor & Destructor Documentation

◆ Annotation1DVerticalLineItem() [1/3]

Annotation1DVerticalLineItem ( const PointXYType center_pos,
const QColor &  color = QColor("as_before"),
const QString &  text = "" 
)

Constructor for a single vertical line of 1px width.

Parameters
center_posCenter of the line in unit coordinates (only the non-gravity component will be used)
colorOptional color. If invalid (=default), the current painter color will be used when this is painted
textOptional text displayed next to the line. Can contain '
' which will force multiple lines.

Referenced by Annotation1DVerticalLineItem::clone().

◆ Annotation1DVerticalLineItem() [2/3]

Annotation1DVerticalLineItem ( const PointXYType center_pos,
const float  width,
const int  alpha255 = 128,
const bool  dashed_line = false,
const QColor &  color = QColor("as_before"),
const QString &  text = "" 
)

Constructor for a single vertical line of 1px width or a broader line (band) with the given width

Parameters
center_posCenter of the line in unit coordinates (only the non-gravity component will be used)
widthFull width of the band in unit coordinates; use =0 to make a thin line and not a band;
alpha255A transparency value from 0 (not visible), to 255 (fully opaque)
dashed_lineShould the line/band be dashed
colorOptional color. If invalid (=default), the current painter color will be used when this is painted
textOptional text displayed next to the line/band. Can contain '
' which will force multiple lines. Text will be plotted at the very top (modify using setTextYOffset())

◆ Annotation1DVerticalLineItem() [3/3]

Copy constructor.

◆ ~Annotation1DVerticalLineItem()

~Annotation1DVerticalLineItem ( )
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 Annotation1DVerticalLineItem::Annotation1DVerticalLineItem().

◆ 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.

◆ getPosition()

const PointXYType& getPosition ( ) const

Returns the position on the non-gravity-axis.

◆ getTextRect()

QRectF getTextRect ( ) const

size of the painted text (width and height of the rectangle)

◆ 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.

◆ setPosition()

void setPosition ( const PointXYType pos)

Sets the center position of the line (the widths will extend from there)

◆ setTextOffset()

void setTextOffset ( int  offset)

offset the text by this much downwards in y-direction (to avoid overlaps etc)

Member Data Documentation

◆ alpha255_

int alpha255_ = 128
protected

transparency 0...255 of the band/line

◆ color_

QColor color_ = Qt::black
protected

The color of the line; if invalid, the current painter color will be used.

◆ dashed_

bool dashed_ {false}
protected

is the band/line dashed?

◆ pos_

PointXYType pos_
protected

The position of the line (gravity axis is ignored)

◆ text_offset_

int text_offset_ {0}
protected

offset (in pixel coordinates of gravity axis) in for the text (to avoid overlaps)

◆ width_

float width_ = 0
protected

width of the item in unit coordinates (allowing to show a 'band'; use =0 to make a thin line and not a band)