OpenMS
AxisWidget.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg$
6 // $Authors: Marc Sturm $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 // OpenMS_GUI config
12 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
13 
14 // QT
15 #include <QtWidgets>
16 class QPaintEvent;
17 
18 // OpenMS
19 #include <OpenMS/CONCEPT/Types.h>
23 
24 namespace OpenMS
25 {
37  class OPENMS_GUI_DLLAPI AxisWidget :
38  public QWidget
39  {
40  Q_OBJECT
41 
42 public:
44 
45  typedef std::vector<std::vector<double> > GridVector;
47 
49  AxisWidget(const AxisPainter::Alignment alignment, const char * legend = "", QWidget * parent = nullptr);
50 
52  ~AxisWidget() override;
53 
55  void setMargin(UInt size);
56 
58  UInt margin() const;
59 
61  void showLegend(bool show_legend);
62 
64  bool isLegendShown() const;
65 
67  void setLegend(const String & legend);
68 
70  const String & getLegend() const;
71 
73  const GridVector & gridLines() const;
74 
76  void setLogScale(bool is_log);
77 
79  bool isLogScale() const;
80 
82  void setInverseOrientation(bool inverse_orientation);
83 
85  bool hasInverseOrientation() const;
86 
88  void setAllowShortNumbers(bool short_nums);
89 
91  double getAxisMinimum() const;
92 
94  double getAxisMaximum() const;
95 
97  void paint(QPainter * painter, QPaintEvent * e);
98 
99 public slots:
100 
102  void setAxisBounds(double min, double max);
103 
105  void setTickLevel(UInt level);
106 
107 protected:
110 
112  bool is_log_;
113 
116 
119 
122 
125 
127  double min_;
128 
130  double max_;
131 
134 
137 
140 
142  void paintEvent(QPaintEvent *) override;
143  };
144 } // namespace OpenMS
145 
Alignment
Where the axis is placed.
Definition: AxisPainter.h:37
Widget that represents an axis of a graph.
Definition: AxisWidget.h:39
void paintEvent(QPaintEvent *) override
Reimplemented Qt event (calls paint with "this")
std::vector< std::vector< double > > GridVector
Type definitions.
Definition: AxisWidget.h:46
UInt margin_
margin of axis
Definition: AxisWidget.h:124
double getAxisMaximum() const
returns the maximum value displayed on the axis
void setTickLevel(UInt level)
set maximum number of tick levels ('1' or '2', default: '2')
void setMargin(UInt size)
sets the margin on the top/right side (default is 0)
const GridVector & gridLines() const
returns the currently used grid lines
double max_
maximum value on the axis
Definition: AxisWidget.h:130
void setLogScale(bool is_log)
sets the axis to logarithmic scale
~AxisWidget() override
destructor
bool show_legend_
display of legend enabled or not
Definition: AxisWidget.h:115
bool hasInverseOrientation() const
returns if the axis label is displayed in inverse order
const String & getLegend() const
returns the actual legend text
void paint(QPainter *painter, QPaintEvent *e)
Actual painting takes place here.
AxisWidget(const AxisPainter::Alignment alignment, const char *legend="", QWidget *parent=nullptr)
constructor
void setAllowShortNumbers(bool short_nums)
set true to allow for shortened numbers (with k/M/G units) on the axis label
void setAxisBounds(double min, double max)
sets min/max of the axis
UInt tick_level_
maximum number of tick levels (default=2)
Definition: AxisWidget.h:136
void setLegend(const String &legend)
sets the legend text
double getAxisMinimum() const
returns the minimum value displayed on the axis
bool is_inverse_orientation_
true if axis label are displayed in inverse order (left to right or bottom to top)
Definition: AxisWidget.h:121
bool is_log_
format of axis scale (linear or logarithmic)
Definition: AxisWidget.h:112
bool isLegendShown() const
returns true if legend is shown
double min_
minimum value on the axis
Definition: AxisWidget.h:127
bool allow_short_numbers_
true if k/M/G units can be used
Definition: AxisWidget.h:139
bool isLogScale() const
returns true if the axis has logarithmic scale
UInt margin() const
returns the margin
GridVector grid_line_
Vector that defines the position of the ticks/gridlines and the shown values on axis.
Definition: AxisWidget.h:109
void showLegend(bool show_legend)
enable the display of the legend (default true)
String legend_
text/unit on axis
Definition: AxisWidget.h:133
void setInverseOrientation(bool inverse_orientation)
set true to display the axis label in inverse order (left to right or bottom to top)
AxisPainter::Alignment alignment_
Position of the axis (right, left, top, down as defined in ALIGNMENT_ENUM)
Definition: AxisWidget.h:118
A more convenient string class.
Definition: String.h:34
unsigned int UInt
Unsigned integer type.
Definition: Types.h:68
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22