OpenMS  3.0.0
Annotation1DCaret.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: Chris Bielow $
32 // $Authors: Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
38 
39 #include <QtGui/QColor>
40 #include <QStaticText>
41 #include <QTextDocument>
42 
43 #include <vector>
44 
45 namespace OpenMS
46 {
55  public Annotation1DItem
56  {
57 public:
58 
60  typedef std::vector<PointType> PositionsType;
61 
63  Annotation1DCaret(const PositionsType& poly_positions, const QString& text, const QColor& colour, const QColor& connection_line_color);
64 
67 
69  ~Annotation1DCaret() override;
70 
71  // Docu in base class
72  void ensureWithinDataRange(Plot1DCanvas* const canvas) override;
73 
74  // Docu in base class
75  void draw(Plot1DCanvas* const canvas, QPainter& painter, bool flipped = false) override;
76 
77  // Docu in base class
78  void move(const PointType& delta) override;
79 
81  const PositionsType& getCaretPositions() const;
82 
84  void setPosition(const PointType& position);
85 
87  const PointType& getPosition() const;
88 
90  void setColor(const QColor& color);
91 
93  const QColor& getColor() const;
94 
97  void setRichText(const QString& text);
98 
99 protected:
100 
104 
107 
109  QColor color_;
110 
113 
115  QStaticText st_;
116 
117  };
118 } // namespace OpenMS
119 
OpenMS::Annotation1DCaret::getPosition
const PointType & getPosition() const
Returns the position of the annotated peak (in MZ / intensity coordinates)
OpenMS::Annotation1DCaret::getCaretPositions
const PositionsType & getCaretPositions() const
Returns the positions of the lines (in MZ / intensity coordinates)
OpenMS::Plot1DCanvas
Canvas for visualization of one or several spectra.
Definition: Plot1DCanvas.h:70
OpenMS::Annotation1DCaret::move
void move(const PointType &delta) override
Moves the item; behaviour depends on item type and is implemented in the subclasses.
Annotation1DItem.h
OpenMS::Annotation1DCaret::connection_line_color_
QColor connection_line_color_
The colour of the (optional) dashed line connecting peak and label.
Definition: Annotation1DCaret.h:112
OpenMS::Annotation1DCaret::~Annotation1DCaret
~Annotation1DCaret() override
Destructor.
OpenMS::Annotation1DCaret::caret_positions_
PositionsType caret_positions_
Definition: Annotation1DCaret.h:103
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::Annotation1DCaret::PointType
Annotation1DItem::PointType PointType
Definition: Annotation1DCaret.h:59
OpenMS::Annotation1DCaret
An annotation item which paints a set of carets on the canvas.
Definition: Annotation1DCaret.h:54
OpenMS::Annotation1DCaret::getColor
const QColor & getColor() const
Returns the colour of the carets.
OpenMS::Annotation1DCaret::setPosition
void setPosition(const PointType &position)
Sets the position of the label (in MZ / intensity coordinates)
OpenMS::Annotation1DCaret::color_
QColor color_
The colour of the label.
Definition: Annotation1DCaret.h:109
OpenMS::Annotation1DCaret::setRichText
void setRichText(const QString &text)
OpenMS::Annotation1DItem
An abstract class acting as an interface for the different 1D annotation items.
Definition: Annotation1DItem.h:59
OpenMS::Annotation1DCaret::st_
QStaticText st_
Holds the (rich) text.
Definition: Annotation1DCaret.h:115
OpenMS::Annotation1DCaret::Annotation1DCaret
Annotation1DCaret(const PositionsType &poly_positions, const QString &text, const QColor &colour, const QColor &connection_line_color)
Constructor.
OpenMS::Annotation1DCaret::position_
PointType position_
The position of the label (in MZ/intensity coordinates)
Definition: Annotation1DCaret.h:106
OpenMS::Annotation1DCaret::PositionsType
std::vector< PointType > PositionsType
Definition: Annotation1DCaret.h:60
OpenMS::DPosition< 2 >
OpenMS::Annotation1DCaret::setColor
void setColor(const QColor &color)
Set the colour of the carets (colour of text must be set using html)
OpenMS::Annotation1DCaret::draw
void draw(Plot1DCanvas *const canvas, QPainter &painter, bool flipped=false) override
Draws the item on painter.
OpenMS::Annotation1DCaret::ensureWithinDataRange
void ensureWithinDataRange(Plot1DCanvas *const canvas) override
Ensures that the item has coordinates within the visible area of the canvas.