OpenMS
PlotWidget.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 //OpenMS
15 #include <OpenMS/CONCEPT/Types.h>
19 
20 class QCloseEvent;
21 class QGridLayout;
22 class QMimeData;
23 class QScrollBar;
24 
25 namespace OpenMS
26 {
27 
28  class AxisWidget;
29 
54  class OPENMS_GUI_DLLAPI PlotWidget :
55  public QWidget,
57  {
58  Q_OBJECT
59 
60 public:
61  static const char RT_AXIS_TITLE[];
62  static const char MZ_AXIS_TITLE[];
63  static const char INTENSITY_AXIS_TITLE[];
64  static const char IM_MS_AXIS_TITLE[];
65  static const char IM_ONEKZERO_AXIS_TITLE[];
66 
69 
77 
79  PlotWidget(const Param & preferences, QWidget * parent = nullptr);
81  ~PlotWidget() override;
82 
91  virtual PlotCanvas* canvas() const = 0;
92 
94  virtual inline AxisWidget * xAxis()
95  {
96  return x_axis_;
97  }
98 
100  virtual inline AxisWidget * yAxis()
101  {
102  return y_axis_;
103  }
104 
107 
109  virtual bool isLegendShown() const;
110 
112  virtual void showLegend(bool show);
113 
116 
118  virtual void hideAxes();
119 
121  virtual void saveAsImage();
122 
123 signals:
125  void sendStatusMessage(std::string, OpenMS::UInt);
127  void sendCursorStatus(const String& x_value, const String& y_value);
129  void aboutToBeDestroyed(int window_id);
133  void dropReceived(const QMimeData* data, QWidget* source, int id);
134 
135 public slots:
141  void showMetaDistribution(const String& name, const Math::Histogram<>& dist);
143  void updateAxes();
152  void updateHScrollbar(float min, float disp_min, float disp_max, float max);
161  void updateVScrollbar(float min, float disp_min, float disp_max, float max);
163  virtual void showGoToDialog() = 0;
166 
171  virtual void setMapper(const DimMapper<2>& mapper) = 0;
172 
173 protected:
175 
176  void closeEvent(QCloseEvent * e) override;
178 
185  void setCanvas_(PlotCanvas * canvas, UInt row = 0, UInt col = 2);
187  virtual void intensityModeChange_();
189  virtual void recalculateAxes_() = 0;
190 
192 
193  void dragEnterEvent(QDragEnterEvent * event) override;
194  void dragMoveEvent(QDragMoveEvent * event) override;
195  void dropEvent(QDropEvent * event) override;
197  void paintEvent(QPaintEvent * /*event*/) override;
199 
203  QGridLayout* grid_;
209  QScrollBar* x_scrollbar_;
211  QScrollBar* y_scrollbar_;
212  };
213 }
214 
Widget that represents an axis of a graph.
Definition: AxisWidget.h:39
Widgets that are placed into an EnhancedTabBar must implement this interface.
Definition: EnhancedTabBarWidgetInterface.h:59
A container for features.
Definition: FeatureMap.h:80
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
Representation of a histogram.
Definition: Histogram.h:38
Management and storage of parameters / INI files.
Definition: Param.h:44
Base class for visualization canvas classes.
Definition: PlotCanvas.h:120
IntensityModes
Display modes of intensity.
Definition: PlotCanvas.h:177
Base class for spectrum widgets.
Definition: PlotWidget.h:57
void showStatistics()
Shows statistics about the data (count, min, max, avg of intensity, charge, quality and meta data)
QScrollBar * y_scrollbar_
Vertical scrollbar.
Definition: PlotWidget.h:211
virtual bool isLegendShown() const
Returns if the axis labels are shown.
void paintEvent(QPaintEvent *) override
make our subclassed QWidget listen to things like stylesheet changes
void updateVScrollbar(float min, float disp_min, float disp_max, float max)
Updates the vertical scrollbar.
void dropReceived(const QMimeData *data, QWidget *source, int id)
Signal that is emitted, when a drag-and-drop action ends on this widget.
AxisWidget * x_axis_
Horizontal axis.
Definition: PlotWidget.h:207
AxisWidget * y_axis_
Vertical axis.
Definition: PlotWidget.h:205
void closeEvent(QCloseEvent *e) override
virtual void showLegend(bool show)
Shows/hides axis labels.
Int getActionMode() const
Get the mouse action mode.
void showMetaDistribution(const String &name, const Math::Histogram<> &dist)
Shows the meta data distribution of value name of the current layer.
PlotWidget(const Param &preferences, QWidget *parent=nullptr)
Default constructor.
virtual void hideAxes()
Hides x-axis and y-axis.
void sendCursorStatus(const String &x_value, const String &y_value)
Emitted when the cursor position changes (for displaying e.g. in status bar)
void dragMoveEvent(QDragMoveEvent *event) override
ExperimentType::SpectrumType SpectrumType
Spectrum type.
Definition: PlotWidget.h:75
void openPreferences()
Shows the main preferences dialog.
virtual void setMapper(const DimMapper< 2 > &mapper)=0
Set a new mapper for the canvas and axis. Internally, all dependent components are updated (e....
PlotCanvas * canvas_
Pointer to the canvas widget.
Definition: PlotWidget.h:201
virtual AxisWidget * xAxis()
Returns a pointer to the x-axis axis widget.
Definition: PlotWidget.h:94
void dragEnterEvent(QDragEnterEvent *event) override
virtual void saveAsImage()
Saves the widget's content as image file.
LayerDataBase::FeatureMapType FeatureMapType
Main data type (features)
Definition: PlotWidget.h:73
void sendStatusMessage(std::string, OpenMS::UInt)
Emits a status message that should be displayed for time ms. If time is 0 the message should be displ...
void updateHScrollbar(float min, float disp_min, float disp_max, float max)
Updates the horizontal scrollbar.
QScrollBar * x_scrollbar_
Horizontal scrollbar.
Definition: PlotWidget.h:209
virtual void intensityModeChange_()
Switch between different intensity modes.
virtual AxisWidget * yAxis()
Returns a pointer to the y-axis axis widget.
Definition: PlotWidget.h:100
void setCanvas_(PlotCanvas *canvas, UInt row=0, UInt col=2)
Adds the canvas, axes and scrollbars to the layout.
void showIntensityDistribution(const Math::Histogram<> &dist)
Shows the intensity distribution of the current layer.
~PlotWidget() override
Destructor.
void setIntensityMode(PlotCanvas::IntensityModes mode)
Sets the intensity mode of the PlotCanvas.
void dropEvent(QDropEvent *event) override
void aboutToBeDestroyed(int window_id)
Message about the destruction of this widget.
void changeLegendVisibility()
Toggles the axis legend visibility.
virtual void recalculateAxes_()=0
recalculates the Axis ticks
void updateAxes()
Updates the axes by setting the right labels and calling recalculateAxes_();.
QGridLayout * grid_
Main layout.
Definition: PlotWidget.h:203
virtual void showGoToDialog()=0
Shows a goto dialog.
virtual PlotCanvas * canvas() const =0
Returns a pointer to canvas object.
LayerDataBase::ExperimentType ExperimentType
Main data type (experiment)
Definition: PlotWidget.h:71
A more convenient string class.
Definition: String.h:34
int Int
Signed integer type.
Definition: Types.h:72
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19