OpenMS  3.0.0
Painter1DBase.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 <QPainterPath>
40 
41 class QPainter;
42 class QPenStyle;
43 
44 namespace OpenMS
45 {
46  class LayerData1DBase;
47  class LayerData1DChrom;
48  class LayerData1DIonMobility;
49  class LayerData1DPeak;
50  class Plot1DCanvas;
51 
55  class OPENMS_GUI_DLLAPI Painter1DBase
56  {
57  public:
58  virtual ~Painter1DBase() = default;
59 
67  virtual void paint(QPainter* painter, Plot1DCanvas* canvas, int layer_index) = 0;
68 
70  static void drawDashedLine(const QPoint& from, const QPoint& to, QPainter* painter, const QColor color);
71 
73  static void drawCross(const QPoint& position, QPainter* painter, const int size = 8);
74 
76  static void drawCaret(const QPoint& position, QPainter* painter, const int size = 8);
77 
78  static QPainterPath getOpenArrow(int arrow_width)
79  { // arrow definition
80  QPainterPath arrow;
81  arrow.moveTo(QPointF(0, 0));
82  arrow.lineTo(QPointF(-arrow_width, 4));
83  arrow.moveTo(QPointF(0, 0));
84  arrow.lineTo(QPointF(-arrow_width, -4));
85  return arrow;
86  }
87  static QPainterPath getClosedArrow(int arrow_width)
88  { // arrow definition
89  QPainterPath arrow;
90  arrow.moveTo(QPointF(0, 0));
91  arrow.lineTo(QPointF(-arrow_width, 4));
92  arrow.lineTo(QPointF(-arrow_width, -4));
93  arrow.closeSubpath();
94  return arrow;
95  }
96 
107  static QRectF drawLineWithArrows(QPainter* painter, const QPen& pen, const QPoint& start, const QPoint& end,
108  const QPainterPath& arrow_start = QPainterPath(),
109  const QPainterPath& arrow_end = QPainterPath());
110 
111  void drawAnnotations_(const LayerData1DBase* layer, QPainter& painter, Plot1DCanvas* canvas) const;
112  };
113 
118  class OPENMS_GUI_DLLAPI Painter1DPeak : public Painter1DBase
119  {
120  public:
122  Painter1DPeak(const LayerData1DPeak* parent);
123 
125  void paint(QPainter*, Plot1DCanvas* canvas, int layer_index) override;
126 
127  protected:
129  void drawMZAtInterestingPeaks_(QPainter& painter, Plot1DCanvas* canvas, MSSpectrum::ConstIterator v_begin, MSSpectrum::ConstIterator v_end) const;
130 
132  };
133 
138  class OPENMS_GUI_DLLAPI Painter1DChrom : public Painter1DBase
139  {
140  public:
142  Painter1DChrom(const LayerData1DChrom* parent);
143 
145  void paint(QPainter*, Plot1DCanvas* canvas, int layer_index) override;
146 
147  protected:
149  };
150 
155  class OPENMS_GUI_DLLAPI Painter1DIonMobility : public Painter1DBase
156  {
157  public:
160 
162  void paint(QPainter*, Plot1DCanvas* canvas, int layer_index) override;
163 
164  protected:
166  };
167 
168 } // namespace OpenMS
Definition: LayerData1DChrom.h:42
Definition: LayerData1DIonMobility.h:43
const LayerData1DIonMobility * layer_
the data to paint
Definition: Painter1DBase.h:165
Canvas for visualization of one or several spectra.
Definition: Plot1DCanvas.h:319
ContainerType::const_iterator ConstIterator
Non-mutable iterator.
Definition: MSSpectrum.h:134
A base class for painting all items from a data layer (as supported by class derived from here) onto ...
Definition: Painter1DBase.h:55
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
static QPainterPath getOpenArrow(int arrow_width)
Definition: Painter1DBase.h:78
Base class for all 1D layers, a special case of LayerData.
Definition: LayerData1DBase.h:53
static QPainterPath getClosedArrow(int arrow_width)
Definition: Painter1DBase.h:87
const LayerData1DChrom * layer_
the data to paint
Definition: Painter1DBase.h:148
Painter1D for mobilograms.
Definition: Painter1DBase.h:155
const LayerData1DPeak * layer_
the data to paint
Definition: Painter1DBase.h:131
Painter1D for spectra.
Definition: Painter1DBase.h:118
Painter1D for chromatograms.
Definition: Painter1DBase.h:138
Definition: LayerData1DPeak.h:43