OpenMS  3.0.0
Plot1DCanvas.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-2022.
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, Timo Sachsenberg, Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 // OpenMS_GUI config
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
40 // OpenMS
43 
44 // QT
45 #include <QTextDocument>
46 
47 // STL
48 #include <vector>
49 #include <utility>
50 
51 // QT
52 class QAction;
53 
54 namespace OpenMS
55 {
56 
70  class OPENMS_GUI_DLLAPI Plot1DCanvas :
71  public PlotCanvas
72  {
73  Q_OBJECT
74 
75 public:
77  enum LabelMode
78  {
82  LM_XPERCENT_YPERCENT
83  };
84 
86  constexpr static double TOP_MARGIN{1.09};
87 
89  Plot1DCanvas(const Param & preferences, QWidget* parent = nullptr);
91  ~Plot1DCanvas() override;
92 
103  bool addChromLayer(ExperimentSharedPtrType chrom_exp_sptr,
104  ODExperimentSharedPtrType ondisc_sptr,
105  OSWDataSharedPtrType chrom_annotation,
106  const int index,
107  const String& filename,
108  const String& caption,
109  const bool multiple_select);
110 
111 
114  {
116  DM_CONNECTEDLINES
117  };
118 
120  DrawModes getDrawMode() const;
121 
123  void setDrawMode(DrawModes mode);
124 
125  // Docu in base class
126  void showCurrentLayerPreferences() override;
127 
128  // Docu in base class
129  void saveCurrentLayer(bool visible) override;
130 
132  bool flippedLayersExist();
133 
135  void flipLayer(Size index);
136 
138  bool mirrorModeActive() const;
139 
141  void setMirrorModeActive(bool b);
142 
144  void dataToWidget(const PeakType& peak, QPoint& point, bool flipped = false, bool percentage = true);
145 
147  void dataToWidget(double x, double y, QPoint& point, bool flipped = false, bool percentage = false);
148 
150  PointType widgetToData(const QPoint& pos, bool percentage = false);
151 
153  PointType widgetToData(double x, double y, bool percentage = false);
154 
156  void setTextBox(const QString& html);
157 
159 
161  Annotation1DItem* addPeakAnnotation(const PeakIndex& peak_index, const QString& text, const QColor& color);
162 
165  void performAlignment(Size layer_index_1, Size layer_index_2, const Param& param);
166 
168  void resetAlignment();
169 
171  Size getAlignmentSize();
172 
174  double getAlignmentScore() const;
175 
177  std::vector<std::pair<Size, Size> > getAlignedPeaksIndices();
178 
180  void activateSpectrum(Size index, bool repaint = true);
181 
183  void setSwappedAxis(bool swapped);
184 
186  void setCurrentLayerPeakPenStyle(Qt::PenStyle ps);
187 
189  void paint(QPainter* paint_device, QPaintEvent* e);
190 
192  void setDrawInterestingMZs(bool enable);
193 
195  bool isDrawInterestingMZs() const;
196 
197  // Show/hide ion ladder on top right corner (Identification view)
198  void setIonLadderVisible(bool show);
199 
200  // Returns true if ion ladder is visible
201  bool isIonLadderVisible() const;
202 
203 signals:
205  void showCurrentPeaksAs2D();
206 
208  void showCurrentPeaksAs3D();
209 
211  void showCurrentPeaksAsIonMobility();
212 
214  void showCurrentPeaksAsDIA();
215 
216 public slots:
217  // Docu in base class
218  void activateLayer(Size layer_index) override;
219  // Docu in base class
220  void removeLayer(Size layer_index) override;
221  // Docu in base class
222  void updateLayer(Size i) override;
223 
230  void setVisibleArea(DRange<2> range); //Do not change this to AreaType the signal needs QT needs the exact type...
231  // Docu in base class
232  void horizontalScrollBarChange(int value) override;
233 
234 protected slots:
235 
237  void currentLayerParamtersChanged_();
238 
239 protected:
240  // Docu in base class
241  bool finishAdding_() override;
242 
244  void drawCoordinates_(QPainter& painter, const PeakIndex& peak);
246  void drawDeltas_(QPainter& painter, const PeakIndex& start, const PeakIndex& end);
247 
249  void drawAlignment_(QPainter& painter);
250 
256  void changeVisibleArea_(double lo, double hi, bool repaint = true, bool add_to_stack = false);
257 
259  void drawHighlightedPeak_(Size layer_index, const PeakIndex& peak, QPainter& painter, bool draw_elongation = false);
260 
262  void updatePercentageFactor_(Size layer_index);
263 
274  void changeVisibleArea_(const AreaType& new_area, bool repaint = true, bool add_to_stack = false) override;
275  // Docu in base class
276  void recalculateSnapFactor_() override;
277  // Docu in base class
278  void updateScrollbars_() override;
279  // Docu in base class
280  void intensityModeChange_() override;
281 
283  std::vector<DrawModes> draw_modes_;
285  std::vector<Qt::PenStyle> peak_penstyle_;
286 
291 
294 
302  std::vector<std::pair<double, double> > aligned_peaks_mz_delta_;
304  std::vector<std::pair<Size, Size> > aligned_peaks_indices_;
313 
315  PeakIndex findPeakAtPosition_(QPoint);
316 
318  void addUserLabelAnnotation_(const QPoint& screen_position);
320  void addLabelAnnotation_(const QPoint& screen_position, const QString& label_text);
322  void addUserPeakAnnotation_(PeakIndex near_peak);
323 
325  void ensureAnnotationsWithinDataRange_();
326 
327  QTextDocument text_box_content_;
328 
331  void paintEvent(QPaintEvent* e) override;
332  void mousePressEvent(QMouseEvent* e) override;
333  void mouseReleaseEvent(QMouseEvent* e) override;
334  void mouseMoveEvent(QMouseEvent* e) override;
335  void keyPressEvent(QKeyEvent* e) override;
336  void contextMenuEvent(QContextMenuEvent* e) override;
338 
340  void zoomForward_() override;
342  void zoom_(int x, int y, bool zoom_in) override;
343  //docu in base class
344  void translateLeft_(Qt::KeyboardModifiers m) override;
345  //docu in base class
346  void translateRight_(Qt::KeyboardModifiers m) override;
347  //docu in base class
348  void paintGridLines_(QPainter& painter) override;
349 
350  friend class Painter1DPeak;
351 
352  };
353 } // namespace OpenMS
354 
OpenMS::SpectrumLookup::findByRT
Size findByRT(double rt) const
Look up spectrum by retention time (RT).
OpenMS::TOPPBase
Base class for TOPP applications.
Definition: TOPPBase.h:147
AScore.h
Size
OpenMS::Plot1DCanvas
Canvas for visualization of one or several spectra.
Definition: Plot1DCanvas.h:70
OpenMS::Plot1DCanvas::alignment_layer_2_
Size alignment_layer_2_
Layer index of the second alignment layer.
Definition: Plot1DCanvas.h:300
OpenMS::AScore::compute
PeptideHit compute(const PeptideHit &hit, PeakSpectrum &real_spectrum)
Computes the AScore and returns all computed phospho-sites. The saved sequences contain only phospho ...
OpenMS::MSExperiment::getSpectrum
MSSpectrum & getSpectrum(Size id)
returns a single spectrum
OpenMS::IdXMLFile::store
void store(const String &filename, const std::vector< ProteinIdentification > &protein_ids, const std::vector< PeptideIdentification > &peptide_ids, const String &document_id="")
Stores the data in an idXML file.
OpenMS::MSSpectrum::findNearest
Size findNearest(CoordinateType mz) const
Binary search for the peak nearest to a specific m/z.
OpenMS::PeptideHit::getSequence
const AASequence & getSequence() const
returns the peptide sequence without trailing or following spaces
OpenMS::MSExperiment::sortSpectra
void sortSpectra(bool sort_mz=true)
Sorts the data points by retention time.
OpenMS::Peak1D::setMZ
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:119
OpenMS::Peak2D
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:54
OpenMS::MzMLFile
File adapter for MzML files.
Definition: MzMLFile.h:57
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::DRange< 2 >
MzMLFile.h
Int
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
OpenMS::Plot1DCanvas::peak_penstyle_
std::vector< Qt::PenStyle > peak_penstyle_
Draw style (for each layer)
Definition: Plot1DCanvas.h:285
OpenMS::PeakFileOptions::addMSLevel
void addMSLevel(int level)
adds a desired MS level for peaks to load
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
IdXMLFile.h
OpenMS::AASequence::toString
String toString() const
returns the peptide as string with modifications embedded in brackets
OpenMS::Plot1DCanvas::moving_annotations_
bool moving_annotations_
Indicates whether annotation items are just being moved on the canvas.
Definition: Plot1DCanvas.h:293
SpectrumMetaDataLookup.h
OpenMS::Constants::PROTON_MASS_U
const double PROTON_MASS_U
Definition: Constants.h:116
QWidget
OpenMS::String::hasSubstring
bool hasSubstring(const String &string) const
true if String contains the string, false otherwise
PlotCanvas.h
OpenMS::IdXMLFile::load
void load(const String &filename, std::vector< ProteinIdentification > &protein_ids, std::vector< PeptideIdentification > &peptide_ids)
Loads the identifications of an idXML file without identifier.
OpenMS::AScore
Implementation of the Ascore For a given peptide sequence and its MS/MS spectrum it identifies the mo...
Definition: AScore.h:72
OpenMS::Plot1DCanvas::DrawModes
DrawModes
Enumerate all available paint styles.
Definition: Plot1DCanvas.h:113
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::Plot1DCanvas::show_alignment_
bool show_alignment_
Indicates whether an alignment is currently visualized.
Definition: Plot1DCanvas.h:296
OpenMS::PlotCanvas
Base class for visualization canvas classes.
Definition: PlotCanvas.h:135
OpenMS::PeakIndex
Index of a peak or feature.
Definition: PeakIndex.h:50
OpenMS::Painter1DPeak
Painter1D for spectra.
Definition: Painter1DBase.h:72
OpenMS::MetaInfoInterface::setMetaValue
void setMetaValue(const String &name, const DataValue &value)
Sets the DataValue corresponding to a name.
OpenMS::MzMLFile::load
void load(const String &filename, PeakMap &map)
Loads a map from a MzML file. Spectra and chromatograms are sorted by default (this can be disabled u...
OpenMS::Plot1DCanvas::measurement_start_point_
QPoint measurement_start_point_
start point of "ruler" for measure mode
Definition: Plot1DCanvas.h:288
OpenMS::Plot1DCanvas::draw_interesting_MZs_
bool draw_interesting_MZs_
annotate interesting peaks with m/z's
Definition: Plot1DCanvas.h:312
OpenMS::SpectrumLookup
Helper class for looking up spectra based on different attributes.
Definition: SpectrumLookup.h:67
OpenMS::Plot1DCanvas::draw_modes_
std::vector< DrawModes > draw_modes_
Draw modes (for each layer)
Definition: Plot1DCanvas.h:283
OpenMS::Annotation1DItem
An abstract class acting as an interface for the different 1D annotation items.
Definition: Annotation1DItem.h:59
OpenMS::SpectrumLookup::readSpectra
void readSpectra(const SpectrumContainer &spectra, const String &scan_regexp=default_scan_regexp)
Read and index spectra for later look-up.
Definition: SpectrumLookup.h:103
OpenMS::Peak1D::getMZ
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition: Peak1D.h:113
OpenMS::Plot1DCanvas::ion_ladder_visible_
bool ion_ladder_visible_
whether the ion ladder is displayed on the top right corner in ID view
Definition: Plot1DCanvas.h:310
OPENMS_LOG_DEBUG
#define OPENMS_LOG_DEBUG
Macro for general debugging information.
Definition: LogStream.h:470
OpenMS::Plot1DCanvas::is_swapped_
bool is_swapped_
is this widget showing data with swapped m/z and RT axis? (for drawCoordinates_ only)
Definition: Plot1DCanvas.h:308
OpenMS::MSSpectrum::clear
void clear(bool clear_meta_data)
Clears all data and meta data.
OpenMS::DefaultParamHandler::setParameters
void setParameters(const Param &param)
Sets the parameters.
Painter1DBase.h
OpenMS::DefaultParamHandler::getDefaults
const Param & getDefaults() const
Non-mutable access to the default parameters.
OpenMS::Peak1D
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:53
OpenMS::MSSpectrum::sortByPosition
void sortByPosition()
Lexicographically sorts the peaks by their position.
OpenMS::Plot1DCanvas::alignment_score_
double alignment_score_
Stores the score of the last alignment.
Definition: Plot1DCanvas.h:306
IDMapper.h
main
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:71
MSExperiment.h
OpenMS::Param::update
bool update(const Param &p_outdated, const bool add_unknown=false)
Rescue parameter values from p_outdated to current param.
OpenMS::Plot1DCanvas::mirror_mode_
bool mirror_mode_
Indicates whether this widget is currently in mirror mode.
Definition: Plot1DCanvas.h:290
OpenMS::OpenMS_Log_debug
Logger::LogStream OpenMS_Log_debug
Global static instance of a LogStream to capture messages classified as debug output....
OpenMS::PeptideIdentification
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:63
OpenMS::Plot1DCanvas::LM_XABSOLUTE_YABSOLUTE
Definition: Plot1DCanvas.h:79
OpenMS::MetaInfoInterface::metaValueExists
bool metaValueExists(const String &name) const
Returns whether an entry with the given name exists.
OpenMS::MSExperiment::getSpectra
const std::vector< MSSpectrum > & getSpectra() const
returns the spectrum list
OpenMS::PeptideHit::getScore
double getScore() const
returns the PSM score
OpenMS::Plot1DCanvas::aligned_peaks_indices_
std::vector< std::pair< Size, Size > > aligned_peaks_indices_
Stores the peak indices of pairs of aligned peaks in both spectra.
Definition: Plot1DCanvas.h:304
OpenMS::PeakFileOptions
Options for loading files containing peak data.
Definition: PeakFileOptions.h:47
OpenMS::PeakFileOptions::clearMSLevels
void clearMSLevels()
clears the MS levels
OpenMS::Param
Management and storage of parameters / INI files.
Definition: Param.h:69
OpenMS::Plot1DCanvas::alignment_layer_1_
Size alignment_layer_1_
Layer index of the first alignment layer.
Definition: Plot1DCanvas.h:298
OpenMS::Plot1DCanvas::LM_XPERCENT_YABSOLUTE
Definition: Plot1DCanvas.h:80
OpenMS::Plot1DCanvas::DM_PEAKS
draw data as peak
Definition: Plot1DCanvas.h:115
OpenMS::Constants::C13C12_MASSDIFF_U
const double C13C12_MASSDIFF_U
Definition: Constants.h:121
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
OpenMS::Plot1DCanvas::aligned_peaks_mz_delta_
std::vector< std::pair< double, double > > aligned_peaks_mz_delta_
Stores the alignment as MZ values of pairs of aligned peaks in both spectra.
Definition: Plot1DCanvas.h:302
OpenMS::Plot1DCanvas::text_box_content_
QTextDocument text_box_content_
Definition: Plot1DCanvas.h:327
OpenMS::Plot1DCanvas::LM_XABSOLUTE_YPERCENT
Definition: Plot1DCanvas.h:81
OpenMS::MzMLFile::getOptions
PeakFileOptions & getOptions()
Mutable access to the options for loading/storing.
OpenMS::ProgressLogger::setLogType
void setLogType(LogType type) const
Sets the progress log that should be used. The default type is NONE!
TOPPBase.h
OpenMS::Plot1DCanvas::LabelMode
LabelMode
Label modes (percentage or absolute) of x axis and y axis.
Definition: Plot1DCanvas.h:77
OpenMS::IdXMLFile
Used to load and store idXML files.
Definition: IdXMLFile.h:68
OpenMS::PeptideHit
Representation of a peptide hit.
Definition: PeptideHit.h:55