OpenMS
HistogramWidget.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, OpenMS Inc. -- 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 #include <QPixmap>
17 class QPaintEvent;
18 class QResizeEvent;
19 class QMouseEvent;
20 
21 //OpenMS
23 
24 namespace OpenMS
25 {
26  class AxisWidget;
27  class String;
28 
39  class OPENMS_GUI_DLLAPI HistogramWidget :
40  public QWidget
41  {
42  Q_OBJECT
43 
44 public:
46  HistogramWidget(const Math::Histogram<> & distribution, QWidget * parent = nullptr);
47 
49  ~HistogramWidget() override;
50 
52  double getLeftSplitter() const;
53 
55  double getRightSplitter() const;
56 
58  void setLegend(const String & legend);
59 
60 public slots:
62  void showSplitters(bool on);
63 
65  void setRightSplitter(double pos);
66 
68  void setLeftSplitter(double pos);
69 
71  void setLogMode(bool log_mode);
72 
73 protected:
76 
79 
82 
85 
88 
91 
94 
96  QPixmap buffer_;
97 
99  bool log_mode_;
100 
102  void invalidate_();
103 
105 
106  void paintEvent(QPaintEvent *) override;
107  void mousePressEvent(QMouseEvent *) override;
108  void mouseReleaseEvent(QMouseEvent *) override;
109  void mouseMoveEvent(QMouseEvent *) override;
110  void resizeEvent(QResizeEvent *) override;
112 
113 protected slots:
114 
116  void showContextMenu(const QPoint & pos);
117  };
118 } // namespace OpenMS
119 
120 
Widget that represents an axis of a graph.
Definition: AxisWidget.h:39
Definition: HistogramWidget.h:41
void invalidate_()
Repaints the contents to the buffer and calls update()
HistogramWidget(const Math::Histogram<> &distribution, QWidget *parent=nullptr)
Constructor.
void paintEvent(QPaintEvent *) override
UInt margin_
Margin around plot.
Definition: HistogramWidget.h:93
void showContextMenu(const QPoint &pos)
Context menu event.
void setLeftSplitter(double pos)
Sets the value of the left splitter.
void mousePressEvent(QMouseEvent *) override
void resizeEvent(QResizeEvent *) override
UInt moving_splitter_
The splitter that is currently dragged (0=none, 1=left, 2=right)
Definition: HistogramWidget.h:87
void setLogMode(bool log_mode)
Enables/disables log mode.
bool log_mode_
Flag that indicates the current mode.
Definition: HistogramWidget.h:99
double getLeftSplitter() const
Returns the value f the lower splitter.
void setLegend(const String &legend)
Set axis legends.
double getRightSplitter() const
Returns the value of the upper splitter.
double left_splitter_
Value of the right splitter.
Definition: HistogramWidget.h:81
void showSplitters(bool on)
Shows the splitters if on is true. Hides them otherwise.
QPixmap buffer_
Internal buffer for the double buffering.
Definition: HistogramWidget.h:96
bool show_splitters_
Flag that indicates if splitters are shown.
Definition: HistogramWidget.h:78
void mouseMoveEvent(QMouseEvent *) override
AxisWidget * bottom_axis_
X axis.
Definition: HistogramWidget.h:90
void mouseReleaseEvent(QMouseEvent *) override
Math::Histogram dist_
The histogram to display.
Definition: HistogramWidget.h:75
~HistogramWidget() override
Destructor.
double right_splitter_
Value of the right splitter.
Definition: HistogramWidget.h:84
void setRightSplitter(double pos)
Sets the value of the right splitter.
Representation of a histogram.
Definition: Histogram.h:38
A more convenient string class.
Definition: String.h:34
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19