OpenMS
Loading...
Searching...
No Matches
Plot2DWidget.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
17
18class QGroupBox;
19class QLabel;
20class QCheckBox;
21
22namespace OpenMS
23{
24 class Plot1DWidget;
25
37 class OPENMS_GUI_DLLAPI Plot2DWidget :
38 public PlotWidget
39 {
40 Q_OBJECT
41public:
44
46 Plot2DWidget(const Param & preferences, QWidget * parent = nullptr);
48 ~Plot2DWidget() override = default;
49
50 // docu in base class
51 Plot2DCanvas* canvas() const override
52 {
53 return static_cast<Plot2DCanvas*>(canvas_);
54 }
55
60
62 bool projectionsVisible() const;
63
67 void setMapper(const DimMapper<2>& mapper) override
68 {
69 canvas_->setMapper(mapper); // update canvas
70 // ... and projections: the projected Dim becomes intensity
71 projection_onto_X_->setMapper(DimMapper<2>({mapper.getDim(DIM::X).getUnit(), DIM_UNIT::INT}));
72 projection_onto_Y_->setMapper(DimMapper<2>({DIM_UNIT::INT, mapper.getDim(DIM::Y).getUnit()}));
73
74 // decide on default draw mode, depending on main axis unit (e.g. m/z or RT)
75 auto set_style = [&](const DIM_UNIT main_unit_1d, Plot1DCanvas* canvas) {
76 switch (main_unit_1d)
77 { // this may not be optimal for every unit. Feel free to change behavior.
78 case DIM_UNIT::MZ:
79 // to show isotope distributions as sticks
80 canvas->setDrawMode(Plot1DCanvas::DM_PEAKS);
81 canvas->setIntensityMode(PlotCanvas::IM_PERCENTAGE);
82 break;
83 // all other units
84 default:
85 canvas->setDrawMode(Plot1DCanvas::DM_CONNECTEDLINES);
86 canvas->setIntensityMode(PlotCanvas::IM_SNAP);
87 break;
88 }
89 };
90 set_style(mapper.getDim(DIM::X).getUnit(), projection_onto_Y_->canvas());
91 set_style(mapper.getDim(DIM::Y).getUnit(), projection_onto_X_->canvas());
92 }
93
94public slots:
95 // Docu in base class
96 void recalculateAxes_() override;
103 void setProjectionsVisible(bool visible);
104 // Docu in base class
105 void showGoToDialog() override;
106
107signals:
115 void showSpectrumAsNew1D(int index);
116 void showChromatogramsAsNew1D(std::vector<int, std::allocator<int> > indices);
124
125
126protected:
128 void projectionInfo_(int peaks, double intensity, double max);
129
135 QGroupBox * projection_box_;
143 QCheckBox * projections_auto_;
146
147private slots:
149 void showProjections_(const LayerDataBase* source_layer);
154 };
155}
156
A D-dimensional half-open interval.
Definition DRange.h:39
DIM_UNIT getUnit() const
The unit of the dimension.
Definition DimMapper.h:129
Allows dynamical switching (at runtime) between a dimension (RT, m/z, int, IM, etc) and X,...
Definition DimMapper.h:662
const DimBase & getDim(DIM d) const
obtain unit/name for X/Y/Z dimension.
Definition DimMapper.h:801
Class that stores the data for one layer.
Definition LayerDataBase.h:170
The representation of a 1D spectrum.
Definition MSSpectrum.h:44
Management and storage of parameters / INI files.
Definition Param.h:46
Canvas for visualization of one or several spectra.
Definition Plot1DCanvas.h:296
Widget for visualization of several spectra.
Definition Plot1DWidget.h:41
Canvas for 2D-visualization of peak map, feature map and consensus map data.
Definition Plot2DCanvas.h:46
Widget for 2D-visualization of peak map and feature map data.
Definition Plot2DWidget.h:39
void recalculateAxes_() override
Plot2DCanvas * canvas() const override
Returns a pointer to canvas object.
Definition Plot2DWidget.h:51
Plot2DWidget(const Param &preferences, QWidget *parent=nullptr)
Default constructor.
void showSpectrumAsNew1D(int index)
Requests to display the spectrum with index index in 1D.
const Plot1DWidget * getProjectionOntoY() const
const reference to the vertical projection
~Plot2DWidget() override=default
Destructor.
bool projectionsVisible() const
Returns if one of the projections is visible (or both are visible)
void toggleProjections()
Toggles the visibility of the projections (convenience wrapper around setProjectionsVisible())
void projectionInfo_(int peaks, double intensity, double max)
shows projections information
void visibleAreaChanged(DRange< 2 > area)
Signal emitted whenever the visible area changes.
QLabel * projection_sum_
Intensity sum of the projection.
Definition Plot2DWidget.h:139
const Plot1DWidget * getProjectionOntoX() const
const reference to the horizontal projection
void showCurrentPeaksAsIonMobility(const MSSpectrum &spec)
Requests to display this spectrum (=frame) in ion mobility plot.
QTimer * projections_timer_
Timer that triggers auto-update of projections.
Definition Plot2DWidget.h:145
void setMapper(const DimMapper< 2 > &mapper) override
Definition Plot2DWidget.h:67
void setProjectionsVisible(bool visible)
QCheckBox * projections_auto_
Checkbox that indicates that projections should be automatically updated (with a slight delay)
Definition Plot2DWidget.h:143
void showProjections_(const LayerDataBase *source_layer)
extracts the projections from the source_layer and displays them
QLabel * projection_max_
Intensity maximum of the projection.
Definition Plot2DWidget.h:141
void projectionsVisibilityChanged(bool visible)
Plot1DWidget * projection_onto_Y_
Horizontal projection widget.
Definition Plot2DWidget.h:133
void refreshProjections_()
re-extracts the projections for the now-current layer, but only if projections are currently shown
void showChromatogramsAsNew1D(std::vector< int, std::allocator< int > > indices)
Plot1DWidget * projection_onto_X_
Vertical projection widget.
Definition Plot2DWidget.h:131
void showCurrentPeaksAs3D()
Requests to display all spectra as 1D.
QGroupBox * projection_box_
Group box that shows information about the projections.
Definition Plot2DWidget.h:135
void showGoToDialog() override
QLabel * projection_peaks_
Number of peaks of the projection.
Definition Plot2DWidget.h:137
LayerDataBase::ExperimentSharedPtrType ExperimentSharedPtrType
Main managed data type (experiment)
Definition Plot2DWidget.h:43
void autoUpdateProjections_()
slot that monitors the visible area changes and triggers the update of projections
Base class for spectrum widgets.
Definition PlotWidget.h:57
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
DIM_UNIT
Definition CommonEnums.h:20
std::shared_ptr< ExperimentType > ExperimentSharedPtrType
SharedPtr on MSExperiment.
Definition LayerDataBase.h:127