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
18
19class QGroupBox;
20class QLabel;
21class QCheckBox;
22
23namespace OpenMS
24{
36 class OPENMS_GUI_DLLAPI Plot2DWidget :
37 public PlotWidget
38 {
39 Q_OBJECT
40public:
43
45 Plot2DWidget(const Param & preferences, QWidget * parent = nullptr);
47 ~Plot2DWidget() override = default;
48
49 // docu in base class
50 Plot2DCanvas* canvas() const override
51 {
52 return static_cast<Plot2DCanvas*>(canvas_);
53 }
54
59
61 bool projectionsVisible() const;
62
66 void setMapper(const DimMapper<2>& mapper) override
67 {
68 canvas_->setMapper(mapper); // update canvas
69 // ... and projections: the projected Dim becomes intensity
70 projection_onto_X_->setMapper(DimMapper<2>({mapper.getDim(DIM::X).getUnit(), DIM_UNIT::INT}));
71 projection_onto_Y_->setMapper(DimMapper<2>({DIM_UNIT::INT, mapper.getDim(DIM::Y).getUnit()}));
72
73 // decide on default draw mode, depending on main axis unit (e.g. m/z or RT)
74 auto set_style = [&](const DIM_UNIT main_unit_1d, Plot1DCanvas* canvas) {
75 switch (main_unit_1d)
76 { // this may not be optimal for every unit. Feel free to change behavior.
77 case DIM_UNIT::MZ:
78 // to show isotope distributions as sticks
79 canvas->setDrawMode(Plot1DCanvas::DM_PEAKS);
80 canvas->setIntensityMode(PlotCanvas::IM_PERCENTAGE);
81 break;
82 // all other units
83 default:
84 canvas->setDrawMode(Plot1DCanvas::DM_CONNECTEDLINES);
85 canvas->setIntensityMode(PlotCanvas::IM_SNAP);
86 break;
87 }
88 };
89 set_style(mapper.getDim(DIM::X).getUnit(), projection_onto_Y_->canvas());
90 set_style(mapper.getDim(DIM::Y).getUnit(), projection_onto_X_->canvas());
91 }
92
93public slots:
94 // Docu in base class
95 void recalculateAxes_() override;
102 void setProjectionsVisible(bool visible);
103 // Docu in base class
104 void showGoToDialog() override;
105
106signals:
114 void showSpectrumAsNew1D(int index);
115 void showChromatogramsAsNew1D(std::vector<int, std::allocator<int> > indices);
123
124
125protected:
127 void projectionInfo_(int peaks, double intensity, double max);
128
134 QGroupBox * projection_box_;
142 QCheckBox * projections_auto_;
145
146private slots:
148 void showProjections_(const LayerDataBase* source_layer);
153 };
154}
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:38
void recalculateAxes_() override
Plot2DCanvas * canvas() const override
Returns a pointer to canvas object.
Definition Plot2DWidget.h:50
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:138
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:144
void setMapper(const DimMapper< 2 > &mapper) override
Definition Plot2DWidget.h:66
void setProjectionsVisible(bool visible)
QCheckBox * projections_auto_
Checkbox that indicates that projections should be automatically updated (with a slight delay)
Definition Plot2DWidget.h:142
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:140
void projectionsVisibilityChanged(bool visible)
Plot1DWidget * projection_onto_Y_
Horizontal projection widget.
Definition Plot2DWidget.h:132
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:130
void showCurrentPeaksAs3D()
Requests to display all spectra as 1D.
QGroupBox * projection_box_
Group box that shows information about the projections.
Definition Plot2DWidget.h:134
void showGoToDialog() override
QLabel * projection_peaks_
Number of peaks of the projection.
Definition Plot2DWidget.h:136
LayerDataBase::ExperimentSharedPtrType ExperimentSharedPtrType
Main managed data type (experiment)
Definition Plot2DWidget.h:42
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