OpenMS
PainterBase.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-2023.
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 
37 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
38 #include <OpenMS/CONCEPT/Types.h>
39 
40 #include <string_view>
41 
42 #include <QPainterPath>
43 #include <QRgb>
44 
45 class QColor;
46 class QPainter;
47 class QPenStyle;
48 class QPoint;
49 
50 namespace OpenMS
51 {
52  class String;
53  enum class ShapeIcon
54  {
55  DIAMOND,
56  SQUARE,
57  CIRCLE,
58  TRIANGLE
59  };
60 
64  class OPENMS_GUI_DLLAPI PainterBase
65  {
66  public:
69  static ShapeIcon toShapeIcon(const String& icon);
70 
72  static void drawDashedLine(const QPoint& from, const QPoint& to, QPainter* painter, const QColor& color);
73 
75  static void drawCross(const QPoint& position, QPainter* painter, const int size = 8);
76 
78  static void drawCaret(const QPoint& position, QPainter* painter, const int size = 8);
79 
81  static void drawDiamond(const QPoint& position, QPainter* painter, const int size = 8);
82 
84  static void drawIcon(const QPoint& pos, const QRgb& color, const ShapeIcon icon, Size s, QPainter& p);
85 
87  static QPainterPath getOpenArrow(int arrow_width);
89  static QPainterPath getClosedArrow(int arrow_width);
90 
101  static QRectF drawLineWithArrows(QPainter* painter, const QPen& pen, const QPoint& start, const QPoint& end,
102  const QPainterPath& arrow_start = QPainterPath(),
103  const QPainterPath& arrow_end = QPainterPath());
104  };
105 
106 } // namespace OpenMS
An empty base class with some static convenience functions.
Definition: PainterBase.h:65
static void drawCross(const QPoint &position, QPainter *painter, const int size=8)
draw a cross at position, using a certain size (= width = height) of the cross
static QPainterPath getOpenArrow(int arrow_width)
An arrow head which is open, i.e. '>'.
static void drawDiamond(const QPoint &position, QPainter *painter, const int size=8)
draw an unfilled diamond at position, using a certain size (= width = height) of the diamond
static QRectF drawLineWithArrows(QPainter *painter, const QPen &pen, const QPoint &start, const QPoint &end, const QPainterPath &arrow_start=QPainterPath(), const QPainterPath &arrow_end=QPainterPath())
static void drawIcon(const QPoint &pos, const QRgb &color, const ShapeIcon icon, Size s, QPainter &p)
draws squares, circles etc
static ShapeIcon toShapeIcon(const String &icon)
static void drawCaret(const QPoint &position, QPainter *painter, const int size=8)
draw a caret '^' at position, using a certain size (= width) of the caret
static QPainterPath getClosedArrow(int arrow_width)
An arrow head which is closed, i.e. a triangle.
static void drawDashedLine(const QPoint &from, const QPoint &to, QPainter *painter, const QColor &color)
static method to draw a dashed line
A more convenient string class.
Definition: String.h:60
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
ShapeIcon
Definition: PainterBase.h:54