OpenMS
Annotation1DVerticalLineItem.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Jihyung Kim, Timo Sachsenberg $
6 // $Authors: Jihyung Kim, Timo Sachsenberg $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
12 
13 #include <QtGui/QColor>
14 
15 namespace OpenMS
16 {
21  public Annotation1DItem
22  {
23  public:
31  Annotation1DVerticalLineItem(const PointXYType& center_pos, const QColor& color = QColor("as_before"), const QString& text = "");
42  Annotation1DVerticalLineItem(const PointXYType& center_pos, const float width, const int alpha255 = 128, const bool dashed_line = false, const QColor& color = QColor("as_before"),
43  const QString& text = "");
44 
47 
49  ~Annotation1DVerticalLineItem() override = default;
50 
51  // Docu in base class
52  void ensureWithinDataRange(Plot1DCanvas* const canvas, const int layer_index) override;
53 
54  // Docu in base class
55  void draw(Plot1DCanvas* const canvas, QPainter& painter, bool flipped = false) override;
56 
57  // Docu in base class
58  void move(const PointXYType delta, const Gravitator& gr, const DimMapper<2>& dim_mapper) override;
59 
61  void setPosition(const PointXYType& pos);
62 
64  const PointXYType& getPosition() const;
65 
67  QRectF getTextRect() const;
68 
70  void setTextOffset(int offset);
71 
72  // Docu in base class
73  Annotation1DItem* clone() const override
74  {
75  return new Annotation1DVerticalLineItem(*this);
76  }
77  protected:
81  int text_offset_ {0};
83  float width_ = 0;
85  int alpha255_ = 128;
87  bool dashed_{false};
89  QColor color_ = Qt::black;
90  };
91 } // namespace OpenMS
An abstract class acting as an interface for the different 1D annotation items.
Definition: Annotation1DItem.h:36
An annotation item which represents a vertical line (or more precisely a line along the gravity axis,...
Definition: Annotation1DVerticalLineItem.h:22
PointXYType pos_
The position of the line (gravity axis is ignored)
Definition: Annotation1DVerticalLineItem.h:79
Annotation1DItem * clone() const override
Creates a copy of the item on the heap and returns a pointer.
Definition: Annotation1DVerticalLineItem.h:73
bool dashed_
is the band/line dashed?
Definition: Annotation1DVerticalLineItem.h:87
Annotation1DVerticalLineItem(const PointXYType &center_pos, const QColor &color=QColor("as_before"), const QString &text="")
void draw(Plot1DCanvas *const canvas, QPainter &painter, bool flipped=false) override
Draws the item on painter.
QColor color_
The color of the line; if invalid, the current painter color will be used.
Definition: Annotation1DVerticalLineItem.h:89
QRectF getTextRect() const
size of the painted text (width and height of the rectangle)
void ensureWithinDataRange(Plot1DCanvas *const canvas, const int layer_index) override
Ensures that the item has coordinates within the visible area of the canvas.
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.
int text_offset_
offset (in pixel coordinates of gravity axis) in for the text (to avoid overlaps)
Definition: Annotation1DVerticalLineItem.h:81
const PointXYType & getPosition() const
Returns the position on the non-gravity-axis.
void setTextOffset(int offset)
offset the text by this much downwards in y-direction (to avoid overlaps etc)
int alpha255_
transparency 0...255 of the band/line
Definition: Annotation1DVerticalLineItem.h:85
float width_
width of the item in unit coordinates (allowing to show a 'band'; use =0 to make a thin line and not ...
Definition: Annotation1DVerticalLineItem.h:83
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 subclas...
void setPosition(const PointXYType &pos)
Sets the center position of the line (the widths will extend from there)
~Annotation1DVerticalLineItem() override=default
Destructor.
Manipulates X or Y component of points in the X-Y plane, by assuming one axis (either X or Y axis) ha...
Definition: Plot1DCanvas.h:42
Canvas for visualization of one or several spectra.
Definition: Plot1DCanvas.h:295
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19