OpenMS
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-2023.
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 
117  virtual PlotCanvas* canvas() const = 0;
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 
133 
135  virtual bool isLegendShown() const;
136 
138  virtual void showLegend(bool show);
139 
142 
144  virtual void hideAxes();
145 
147  virtual void saveAsImage();
148 
149 signals:
151  void sendStatusMessage(std::string, OpenMS::UInt);
153  void sendCursorStatus(const String& x_value, const String& y_value);
155  void aboutToBeDestroyed(int window_id);
159  void dropReceived(const QMimeData* data, QWidget* source, int id);
160 
161 public slots:
167  void showMetaDistribution(const String& name, const Math::Histogram<>& dist);
169  void updateAxes();
178  void updateHScrollbar(float min, float disp_min, float disp_max, float max);
187  void updateVScrollbar(float min, float disp_min, float disp_max, float max);
189  virtual void showGoToDialog() = 0;
192 
197  virtual void setMapper(const DimMapper<2>& mapper) = 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_();
215  virtual void recalculateAxes_() = 0;
216 
218 
219  void dragEnterEvent(QDragEnterEvent * event) override;
220  void dragMoveEvent(QDragMoveEvent * event) override;
221  void dropEvent(QDropEvent * event) override;
223  void paintEvent(QPaintEvent * /*event*/) override;
225 
229  QGridLayout* grid_;
235  QScrollBar* x_scrollbar_;
237  QScrollBar* y_scrollbar_;
238  };
239 }
240 
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:106
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:72
The representation of a 1D spectrum.
Definition: MSSpectrum.h:70
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:146
IntensityModes
Display modes of intensity.
Definition: PlotCanvas.h:203
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:237
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:233
AxisWidget * y_axis_
Vertical axis.
Definition: PlotWidget.h:231
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:101
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:227
virtual AxisWidget * xAxis()
Returns a pointer to the x-axis axis widget.
Definition: PlotWidget.h:120
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:99
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:235
virtual void intensityModeChange_()
Switch between different intensity modes.
virtual AxisWidget * yAxis()
Returns a pointer to the y-axis axis widget.
Definition: PlotWidget.h:126
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:229
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:97
A more convenient string class.
Definition: String.h:60
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:48