OpenMS  2.5.0
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-2020.
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(AxisPainter::Alignment alignment, const char * legend = "", QWidget * parent = nullptr);
76 
78  ~AxisWidget() override;
79 
81  void setMargin(UInt size);
82 
84  UInt margin();
85 
87  void showLegend(bool show_legend);
88 
90  bool isLegendShown() const;
91 
93  void setLegend(const String & legend);
94 
96  const String & getLegend();
97 
99  const GridVector & gridLines();
100 
102  void setLogScale(bool is_log);
103 
105  bool isLogScale();
106 
108  void setInverseOrientation(bool inverse_orientation);
109 
111  bool hasInverseOrientation();
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 
Types.h
OpenMS::AxisWidget::max_
double max_
maximum value on the axis
Definition: AxisWidget.h:156
OpenMS::AxisWidget::grid_line_
GridVector grid_line_
Vector that defines the position of the ticks/gridlines and the shown values on axis.
Definition: AxisWidget.h:135
OpenMS::String
A more convenient string class.
Definition: String.h:58
QWidget
OpenMS::AxisWidget::show_legend_
bool show_legend_
display of legend enabled or not
Definition: AxisWidget.h:141
AxisPainter.h
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::AxisWidget::margin_
UInt margin_
margin of axis
Definition: AxisWidget.h:150
MathFunctions.h
OpenMS::AxisWidget::allow_short_numbers_
bool allow_short_numbers_
true if k/M/G units can be used
Definition: AxisWidget.h:165
OpenMS::AxisWidget::is_inverse_orientation_
bool is_inverse_orientation_
true if axis label are displayed in inverse order (left to right or bottom to top)
Definition: AxisWidget.h:147
OpenMS::AxisWidget
Widget that represents an axis of a graph.
Definition: AxisWidget.h:63
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::AxisWidget::alignment_
AxisPainter::Alignment alignment_
Position of the axis (right, left, top, down as defined in ALIGNMENT_ENUM)
Definition: AxisWidget.h:144
String.h
OpenMS::AxisWidget::min_
double min_
minimum value on the axis
Definition: AxisWidget.h:153
OpenMS::AxisWidget::tick_level_
UInt tick_level_
maximum number of tick levels (default=2)
Definition: AxisWidget.h:162
OpenMS::AxisPainter::Alignment
Alignment
Where the axis is placed.
Definition: AxisPainter.h:62
OpenMS::AxisWidget::is_log_
bool is_log_
format of axis scale (linear or logarithmic)
Definition: AxisWidget.h:138
OpenMS::AxisWidget::GridVector
std::vector< std::vector< double > > GridVector
Type definitions.
Definition: AxisWidget.h:72
OpenMS::AxisWidget::legend_
String legend_
text/unit on axis
Definition: AxisWidget.h:159