OpenMS  2.8.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-2021.
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
An abstract class acting as an interface for the different 1D annotation items.
Definition: Annotation1DItem.h:60
An annotation item which represents a vertical line and text label on top.
Definition: Annotation1DVerticalLineItem.h:49
void setPosition(const double &x)
Sets the uppermost position of the line.
bool dashed_
is the band/line dashed?
Definition: Annotation1DVerticalLineItem.h:102
const double & getPosition() const
Returns the position.
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:105
void ensureWithinDataRange(Plot1DCanvas *const canvas) override
Ensures that the item has coordinates within the visible area of the canvas.
QRectF getTextRect() const
size of the painted text (width and height of the rectangle)
void move(const PointType &delta) override
Moves the item; behaviour depends on item type and is implemented in the subclasses.
Annotation1DVerticalLineItem(const Annotation1DVerticalLineItem &rhs)=default
Copy constructor.
float alpha255_
transparency 0...255 of the band/line
Definition: Annotation1DVerticalLineItem.h:100
float width_
width of the item (allowing to show a 'band' if > 1)
Definition: Annotation1DVerticalLineItem.h:98
double x_
The position of the vertical line.
Definition: Annotation1DVerticalLineItem.h:93
Annotation1DVerticalLineItem(const double x_pos, const QColor &color=QColor("as_before"), const QString &text="")
int y_text_offset_
offset in y for the text (to avoid overlaps)
Definition: Annotation1DVerticalLineItem.h:95
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="")
~Annotation1DVerticalLineItem() override=default
Destructor.
void setTextYOffset(int y_offset)
offset the text by this much downwards in y-direction (to avoid overlaps etc)
Canvas for visualization of one or several spectra.
Definition: Plot1DCanvas.h:72
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47