OpenMS  2.4.0
SpectrumWidget.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-2018.
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 //OpenMS
41 #include <OpenMS/CONCEPT/Types.h>
45 
46 class QGridLayout;
47 class QScrollBar;
48 class QCloseEvent;
49 class QMimeData;
50 
51 namespace OpenMS
52 {
53 
54  class AxisWidget;
55 
80  class OPENMS_GUI_DLLAPI SpectrumWidget :
81  public QWidget,
83  {
84  Q_OBJECT
85 
86 public:
89 
97 
99  SpectrumWidget(const Param & preferences, QWidget * parent = nullptr);
101  ~SpectrumWidget() override;
102 
110  {
111  return canvas_;
112  }
113 
115  {
116  return canvas_;
117  }
118 
120  virtual inline AxisWidget * xAxis()
121  {
122  return x_axis_;
123  }
124 
126  virtual inline AxisWidget * yAxis()
127  {
128  return y_axis_;
129  }
130 
132  Int getActionMode() const;
133 
135  virtual bool isLegendShown() const;
136 
138  virtual void showLegend(bool show);
139 
141  void setIntensityMode(SpectrumCanvas::IntensityModes mode);
142 
144  virtual void hideAxes();
145 
147  virtual void saveAsImage();
148 
150  Int getWindowId() override;
151 
153  void setWindowId(Int window_id) override;
154 
155 signals:
157  void sendStatusMessage(std::string, OpenMS::UInt);
159  void sendCursorStatus(double mz = -1.0, double rt = -1.0);
161  void aboutToBeDestroyed(int window_id);
163  void openPreferences();
165  void dropReceived(const QMimeData * data, QWidget * source, int id);
166 
167 public slots:
169  void showStatistics();
171  void showIntensityDistribution();
173  void showMetaDistribution(const String & name);
175  void updateAxes();
184  void updateHScrollbar(float min, float disp_min, float disp_max, float max);
193  void updateVScrollbar(float min, float disp_min, float disp_max, float max);
195  virtual void showGoToDialog() = 0;
197  void changeLegendVisibility();
198 
199 protected:
201 
202  void closeEvent(QCloseEvent * e) override;
204 
211  void setCanvas_(SpectrumCanvas * canvas, UInt row = 0, UInt col = 2);
213  virtual void intensityModeChange_();
215  virtual Math::Histogram<> createIntensityDistribution_() const = 0;
217  virtual Math::Histogram<> createMetaDistribution_(const String & name) const = 0;
219  virtual void recalculateAxes_() = 0;
221  void correctAreaToObeyMinMaxRanges_(SpectrumCanvas::AreaType& area);
222 
224 
225  void dragEnterEvent(QDragEnterEvent * event) override;
226  void dragMoveEvent(QDragMoveEvent * event) override;
227  void dropEvent(QDropEvent * event) override;
229 
233  QGridLayout * grid_;
239  QScrollBar * x_scrollbar_;
241  QScrollBar * y_scrollbar_;
242 
244  };
245 }
246 
SpectrumCanvas * canvas()
Returns a pointer to canvas object.
Definition: SpectrumWidget.h:109
A more convenient string class.
Definition: String.h:57
Widget that represents an axis of a graph.
Definition: AxisWidget.h:63
virtual AxisWidget * yAxis()
Returns a pointer to the y-axis axis widget.
Definition: SpectrumWidget.h:126
A container for features.
Definition: FeatureMap.h:93
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
Base class for visualization canvas classes.
Definition: SpectrumCanvas.h:100
QGridLayout * grid_
Main layout.
Definition: SpectrumWidget.h:233
virtual AxisWidget * xAxis()
Returns a pointer to the x-axis axis widget.
Definition: SpectrumWidget.h:120
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
SpectrumCanvas * canvas() const
Definition: SpectrumWidget.h:114
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
AxisWidget * x_axis_
Horizontal axis.
Definition: SpectrumWidget.h:237
QScrollBar * y_scrollbar_
Vertical scrollbar.
Definition: SpectrumWidget.h:241
Base class for spectrum widgets.
Definition: SpectrumWidget.h:80
Representation of a histogram.
Definition: Histogram.h:63
LayerData::ExperimentType ExperimentType
Main data type (experiment)
Definition: SpectrumWidget.h:91
Int window_id_
Definition: SpectrumWidget.h:243
ExperimentType::SpectrumType SpectrumType
Spectrum type.
Definition: SpectrumWidget.h:95
LayerData::FeatureMapType FeatureMapType
Main data type (features)
Definition: SpectrumWidget.h:93
SpectrumCanvas * canvas_
Pointer to the canvas widget.
Definition: SpectrumWidget.h:231
Management and storage of parameters / INI files.
Definition: Param.h:74
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
Widgets that are placed into an EnhancedTabBar must implement this interface.
Definition: EnhancedTabBarWidgetInterface.h:51
AxisWidget * y_axis_
Vertical axis.
Definition: SpectrumWidget.h:235
IntensityModes
Display modes of intensity.
Definition: SpectrumCanvas.h:149
int Int
Signed integer type.
Definition: Types.h:102
QScrollBar * x_scrollbar_
Horizontal scrollbar.
Definition: SpectrumWidget.h:239