OpenMS
AxisWidget.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: Timo Sachsenberg$
32 // $Authors: Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 // OpenMS_GUI config
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
40 // QT
41 #include <QtWidgets>
42 class QPaintEvent;
43 
44 // OpenMS
45 #include <OpenMS/CONCEPT/Types.h>
49 
50 namespace OpenMS
51 {
63  class OPENMS_GUI_DLLAPI AxisWidget :
64  public QWidget
65  {
66  Q_OBJECT
67 
68 public:
70 
71  typedef std::vector<std::vector<double> > GridVector;
73 
75  AxisWidget(const AxisPainter::Alignment alignment, const char * legend = "", QWidget * parent = nullptr);
76 
78  ~AxisWidget() override;
79 
81  void setMargin(UInt size);
82 
84  UInt margin() const;
85 
87  void showLegend(bool show_legend);
88 
90  bool isLegendShown() const;
91 
93  void setLegend(const String & legend);
94 
96  const String & getLegend() const;
97 
99  const GridVector & gridLines() const;
100 
102  void setLogScale(bool is_log);
103 
105  bool isLogScale() const;
106 
108  void setInverseOrientation(bool inverse_orientation);
109 
111  bool hasInverseOrientation() const;
112 
114  void setAllowShortNumbers(bool short_nums);
115 
117  double getAxisMinimum() const;
118 
120  double getAxisMaximum() const;
121 
123  void paint(QPainter * painter, QPaintEvent * e);
124 
125 public slots:
126 
128  void setAxisBounds(double min, double max);
129 
131  void setTickLevel(UInt level);
132 
133 protected:
136 
138  bool is_log_;
139 
142 
145 
148 
151 
153  double min_;
154 
156  double max_;
157 
160 
163 
166 
168  void paintEvent(QPaintEvent *) override;
169  };
170 } // namespace OpenMS
171 
Alignment
Where the axis is placed.
Definition: AxisPainter.h:63
Widget that represents an axis of a graph.
Definition: AxisWidget.h:65
void paintEvent(QPaintEvent *) override
Reimplemented Qt event (calls paint with "this")
std::vector< std::vector< double > > GridVector
Type definitions.
Definition: AxisWidget.h:72
UInt margin_
margin of axis
Definition: AxisWidget.h:150
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:156
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:141
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:162
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:147
bool is_log_
format of axis scale (linear or logarithmic)
Definition: AxisWidget.h:138
bool isLegendShown() const
returns true if legend is shown
double min_
minimum value on the axis
Definition: AxisWidget.h:153
bool allow_short_numbers_
true if k/M/G units can be used
Definition: AxisWidget.h:165
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:135
void showLegend(bool show_legend)
enable the display of the legend (default true)
String legend_
text/unit on axis
Definition: AxisWidget.h:159
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:144
A more convenient string class.
Definition: String.h:60
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48