OpenMS  3.0.0
Annotation1DVerticalLineItem.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2022.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Jihyung Kim, Timo Sachsenberg $
32 // $Authors: Jihyung Kim, Timo Sachsenberg $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
39 
40 #include <QtGui/QColor>
41 
42 namespace OpenMS
43 {
48  public Annotation1DItem
49  {
50  public:
58  Annotation1DVerticalLineItem(const double x_pos, const QColor& color = QColor("as_before"), const QString& text = "");
69  Annotation1DVerticalLineItem(const double x_center_pos, const double width, const int alpha255 = 128, const bool dashed_line = false, const QColor& color = QColor("as_before"), const QString& text = "");
73  ~Annotation1DVerticalLineItem() override = default;
74  // Docu in base class
75  void ensureWithinDataRange(Plot1DCanvas* const canvas) override;
76  // Docu in base class
77  void draw(Plot1DCanvas* const canvas, QPainter& painter, bool flipped = false) override;
78  // Docu in base class
79  void move(const PointType& delta) override;
81  void setPosition(const double& x);
83  const double& getPosition() const;
84 
86  QRectF getTextRect() const;
87 
89  void setTextYOffset(int y_offset);
90 
91  protected:
93  double x_ = -1;
96 
98  float width_ = 1;
100  float alpha255_ = 128;
102  bool dashed_{false};
103 
105  QColor color_ = Qt::black;
106  };
107 } // namespace OpenMS
OpenMS::Plot1DCanvas
Canvas for visualization of one or several spectra.
Definition: Plot1DCanvas.h:70
DPosition.h
OpenMS::Annotation1DVerticalLineItem::ensureWithinDataRange
void ensureWithinDataRange(Plot1DCanvas *const canvas) override
Ensures that the item has coordinates within the visible area of the canvas.
Annotation1DItem.h
OpenMS::Annotation1DVerticalLineItem::draw
void draw(Plot1DCanvas *const canvas, QPainter &painter, bool flipped=false) override
Draws the item on painter.
OpenMS::Annotation1DVerticalLineItem::width_
float width_
width of the item (allowing to show a 'band' if > 1)
Definition: Annotation1DVerticalLineItem.h:98
OpenMS::Annotation1DVerticalLineItem
An annotation item which represents a vertical line and text label on top.
Definition: Annotation1DVerticalLineItem.h:47
OpenMS::Annotation1DVerticalLineItem::setPosition
void setPosition(const double &x)
Sets the uppermost position of the line.
OpenMS::Annotation1DVerticalLineItem::dashed_
bool dashed_
is the band/line dashed?
Definition: Annotation1DVerticalLineItem.h:102
OpenMS::Annotation1DVerticalLineItem::move
void move(const PointType &delta) override
Moves the item; behaviour depends on item type and is implemented in the subclasses.
OpenMS::Annotation1DVerticalLineItem::x_
double x_
The position of the vertical line.
Definition: Annotation1DVerticalLineItem.h:93
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::Annotation1DVerticalLineItem::getTextRect
QRectF getTextRect() const
size of the painted text (width and height of the rectangle)
OpenMS::Annotation1DVerticalLineItem::getPosition
const double & getPosition() const
Returns the position.
OpenMS::Annotation1DVerticalLineItem::color_
QColor color_
The color of the line; if invalid, the current painter color will be used.
Definition: Annotation1DVerticalLineItem.h:105
OpenMS::Annotation1DItem
An abstract class acting as an interface for the different 1D annotation items.
Definition: Annotation1DItem.h:59
OpenMS::Annotation1DVerticalLineItem::alpha255_
float alpha255_
transparency 0...255 of the band/line
Definition: Annotation1DVerticalLineItem.h:100
OpenMS::Annotation1DVerticalLineItem::Annotation1DVerticalLineItem
Annotation1DVerticalLineItem(const double x_pos, const QColor &color=QColor("as_before"), const QString &text="")
OpenMS::DPosition< 2 >
OpenMS::Annotation1DVerticalLineItem::y_text_offset_
int y_text_offset_
offset in y for the text (to avoid overlaps)
Definition: Annotation1DVerticalLineItem.h:95
OpenMS::Annotation1DVerticalLineItem::~Annotation1DVerticalLineItem
~Annotation1DVerticalLineItem() override=default
Destructor.
OpenMS::Annotation1DVerticalLineItem::setTextYOffset
void setTextYOffset(int y_offset)
offset the text by this much downwards in y-direction (to avoid overlaps etc)