OpenMS  2.7.0
PlotWidget.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-2021.
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 QCloseEvent;
47 class QGridLayout;
48 class QMimeData;
49 class QScrollBar;
50 
51 namespace OpenMS
52 {
53 
54  class AxisWidget;
55 
80  class OPENMS_GUI_DLLAPI PlotWidget :
81  public QWidget,
83  {
84  Q_OBJECT
85 
86 public:
87  static const char RT_AXIS_TITLE[];
88  static const char MZ_AXIS_TITLE[];
89  static const char INTENSITY_AXIS_TITLE[];
90  static const char IM_MS_AXIS_TITLE[];
91  static const char IM_ONEKZERO_AXIS_TITLE[];
92 
95 
103 
105  PlotWidget(const Param & preferences, QWidget * parent = nullptr);
107  ~PlotWidget() override;
108 
116  {
117  return canvas_;
118  }
119 
120  PlotCanvas * canvas() const
121  {
122  return canvas_;
123  }
124 
126  virtual inline AxisWidget * xAxis()
127  {
128  return x_axis_;
129  }
130 
132  virtual inline AxisWidget * yAxis()
133  {
134  return y_axis_;
135  }
136 
139 
141  virtual bool isLegendShown() const;
142 
144  virtual void showLegend(bool show);
145 
148 
150  virtual void hideAxes();
151 
153  virtual void saveAsImage();
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);
165  void dropReceived(const QMimeData * data, QWidget * source, int id);
166 
167 public slots:
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;
198 
199 protected:
201 
202  void closeEvent(QCloseEvent * e) override;
204 
211  void setCanvas_(PlotCanvas * canvas, UInt row = 0, UInt col = 2);
213  virtual void intensityModeChange_();
217  virtual Math::Histogram<> createMetaDistribution_(const String & name) const = 0;
219  virtual void recalculateAxes_() = 0;
222 
224 
225  void dragEnterEvent(QDragEnterEvent * event) override;
226  void dragMoveEvent(QDragMoveEvent * event) override;
227  void dropEvent(QDropEvent * event) override;
229  void paintEvent(QPaintEvent * /*event*/) override;
231 
235  QGridLayout * grid_;
241  QScrollBar * x_scrollbar_;
243  QScrollBar * y_scrollbar_;
244  };
245 }
246 
Widget that represents an axis of a graph.
Definition: AxisWidget.h:65
Widgets that are placed into an EnhancedTabBar must implement this interface.
Definition: EnhancedTabBarWidgetInterface.h:85
A container for features.
Definition: FeatureMap.h:105
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:80
The representation of a 1D spectrum.
Definition: MSSpectrum.h:71
Representation of a histogram.
Definition: Histogram.h:64
Management and storage of parameters / INI files.
Definition: Param.h:70
Base class for visualization canvas classes.
Definition: PlotCanvas.h:136
IntensityModes
Display modes of intensity.
Definition: PlotCanvas.h:184
Base class for spectrum widgets.
Definition: PlotWidget.h:83
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:243
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
LayerData::ExperimentType ExperimentType
Main data type (experiment)
Definition: PlotWidget.h:97
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:239
AxisWidget * y_axis_
Vertical axis.
Definition: PlotWidget.h:237
void closeEvent(QCloseEvent *e) override
virtual void showLegend(bool show)
Shows/hides axis labels.
Int getActionMode() const
Get the mouse action mode.
PlotWidget(const Param &preferences, QWidget *parent=nullptr)
Default constructor.
virtual void hideAxes()
Hides x-axis and y-axis.
virtual Math::Histogram createIntensityDistribution_() const =0
creates the intensity distribution of the current layer
PlotCanvas * canvas()
Returns a pointer to canvas object.
Definition: PlotWidget.h:115
void sendCursorStatus(double mz=-1.0, double rt=-1.0)
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:101
void openPreferences()
Shows the main preferences dialog.
void showIntensityDistribution()
Shows the intensity distribution of the current layer.
PlotCanvas * canvas_
Pointer to the canvas widget.
Definition: PlotWidget.h:233
virtual AxisWidget * xAxis()
Returns a pointer to the x-axis axis widget.
Definition: PlotWidget.h:126
virtual Math::Histogram createMetaDistribution_(const String &name) const =0
creates the meta data distribution of value name of the current layer
void dragEnterEvent(QDragEnterEvent *event) override
PlotCanvas * canvas() const
Definition: PlotWidget.h:120
virtual void saveAsImage()
Saves the widget's content as image file.
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...
LayerData::FeatureMapType FeatureMapType
Main data type (features)
Definition: PlotWidget.h:99
void updateHScrollbar(float min, float disp_min, float disp_max, float max)
Updates the horizontal scrollbar.
QScrollBar * x_scrollbar_
Horizontal scrollbar.
Definition: PlotWidget.h:241
virtual void intensityModeChange_()
Switch between different intensity modes.
virtual AxisWidget * yAxis()
Returns a pointer to the y-axis axis widget.
Definition: PlotWidget.h:132
void setCanvas_(PlotCanvas *canvas, UInt row=0, UInt col=2)
Adds the canvas, axes and scrollbars to the layout.
~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 correctAreaToObeyMinMaxRanges_(PlotCanvas::AreaType &area)
correct given area X/Y-values if the values under-/overflow the min-/max values of the data
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:235
virtual void showGoToDialog()=0
Shows a goto dialog.
void showMetaDistribution(const String &name)
Shows the meta data distribution of value name of the current layer.
A more convenient string class.
Definition: String.h:61
int Int
Signed integer type.
Definition: Types.h:102
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47