OpenMS
Plot1DCanvas.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg$
6 // $Authors: Marc Sturm, Timo Sachsenberg, Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 // OpenMS_GUI config
12 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
13 
14 // OpenMS
19 
20 // QT
21 #include <QTextDocument>
22 #include <QPoint>
23 
24 // STL
25 #include <vector>
26 #include <utility>
27 
28 // QT
29 class QAction;
30 
31 namespace OpenMS
32 {
33  class Annotation1DItem;
34 
41  class Gravitator
42  {
43  public:
44 
46 
52  {
53  setGravityAxis(axis);
54  }
55 
60  Gravitator(const DimMapper<2>& unit_mapper)
61  {
62  setIntensityAsGravity(unit_mapper);
63  }
64 
70  void setGravityAxis(DIM axis)
71  {
72  if (axis != DIM::X && axis != DIM::Y)
73  {
74  throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Not a valid axis for 1D plotting", String((int)axis));
75  }
76  gravity_axis_ = axis;
77  }
78 
84  void setIntensityAsGravity(const DimMapper<2>& unit_mapper)
85  {
86  if (unit_mapper.getDim(DIM::X).getUnit() == DIM_UNIT::INT)
87  {
89  }
90  if (unit_mapper.getDim(DIM::Y).getUnit() == DIM_UNIT::INT)
91  {
93  }
95  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
96  }
97 
100  {
101  return gravity_axis_;
102  }
103 
108  Gravitator swap() const
109  {
110  auto r = *this;
111  r.setGravityAxis( (r.getGravityAxis() == DIM::X) ? DIM::Y : DIM::X);
112  return r;
113  }
114 
120  QPoint gravitateMin(QPoint p, const AreaXYType& area) const
121  {
122  if (gravity_axis_ == DIM::X)
123  {
124  p.rx() = area.minX();
125  }
126  else if (gravity_axis_ == DIM::Y)
127  {
128  p.ry() = area.minY();
129  }
130  return p;
131  }
132 
138  QPoint gravitateWith(QPoint p, const QPoint& delta) const
139  {
140  if (gravity_axis_ == DIM::X)
141  {
142  p.rx() += delta.x();
143  }
144  else if (gravity_axis_ == DIM::Y)
145  {
146  p.ry() += delta.y();
147  }
148  return p;
149  }
150 
152  template<UInt D>
154  {
155  p[(int)gravity_axis_] += delta[(int)gravity_axis_];
156  return p;
157  }
158 
164  QPoint gravitateTo(QPoint p, const QPoint& target) const
165  {
166  if (gravity_axis_ == DIM::X)
167  {
168  p.rx() = target.x();
169  }
170  else if (gravity_axis_ == DIM::Y)
171  {
172  p.ry() = target.y();
173  }
174  return p;
175  }
176 
178  template<UInt D>
180  {
181  p[(int)gravity_axis_] = target[(int)gravity_axis_];
182  return p;
183  }
184 
185 
187  QPoint gravitateMax(QPoint p, const AreaXYType& area) const
188  {
189  if (gravity_axis_ == DIM::X)
190  {
191  p.rx() = area.maxX();
192  }
193  else if (gravity_axis_ == DIM::Y)
194  {
195  p.ry() = area.maxY();
196  }
197  return p;
198  }
199 
204  QPoint gravitateZero(QPoint p) const
205  {
206  if (gravity_axis_ == DIM::X)
207  {
208  p.rx() = 0;
209  }
210  else if (gravity_axis_ == DIM::Y)
211  {
212  p.ry() = 0;
213  }
214  return p;
215  }
216 
221  template<UInt D>
223  {
224  p[(int)gravity_axis_] = 0;
225  return p;
226  }
227 
232  template<UInt D>
234  {
235  p[(int)gravity_axis_] = std::numeric_limits<float>::quiet_NaN();
236  return p;
237  }
238 
243  int gravityValue(const QPoint& p) const
244  {
245  if (gravity_axis_ == DIM::X)
246  {
247  return p.x();
248  }
249  else if (gravity_axis_ == DIM::Y)
250  {
251  return p.y();
252  }
253  // never reached, but make compilers happy
254  return 0;
255  }
260  template<UInt D>
261  int gravityValue(const DPosition<D>& p) const
262  {
263  return p[(int)gravity_axis_];
264  }
265 
271  template<UInt D>
272  auto gravityDiff(const DPosition<D>& start, const DPosition<D>& end) const
273  {
274  return end[(int)gravity_axis_] - start[(int)gravity_axis_];
275  }
276 
277  private:
280  };
281 
293  class OPENMS_GUI_DLLAPI Plot1DCanvas :
294  public PlotCanvas
295  {
296  Q_OBJECT
297 
298 public:
301  {
305  LM_XPERCENT_YPERCENT
306  };
307 
309  constexpr static double TOP_MARGIN{1.09};
310 
312  Plot1DCanvas(const Param& preferences, const DIM gravity_axis = DIM::Y, QWidget* parent = nullptr);
314  ~Plot1DCanvas() override;
315 
318  const LayerData1DBase& getLayer(Size index) const;
322 
329 
331  const DimBase& getGravityDim() const;
332 
334  const DimBase& getNonGravityDim() const;
335 
347  ODExperimentSharedPtrType ondisc_sptr,
348  OSWDataSharedPtrType chrom_annotation,
349  const int index,
350  const String& filename,
351  const String& basename,
352  const String& basename_extra);
353 
354 
357  {
359  DM_CONNECTEDLINES
360  };
361 
364 
366  void setDrawMode(DrawModes mode);
367 
368  // Docu in base class
370 
373 
375  void flipLayer(Size index);
376 
378  bool mirrorModeActive() const;
379 
381  void setMirrorModeActive(bool b);
382 
384  void dataToWidget(const DPosition<2>& peak, QPoint& point, bool flipped = false);
386  void dataToWidget(const DPosition<2>& xy_point, DPosition<2>& point, bool flipped);
387 
389  void dataToWidget(double x, double y, QPoint& point, bool flipped = false);
390 
392  PointXYType widgetToData(const QPoint& pos);
393 
395  PointXYType widgetToData(double x, double y);
396 
400  inline void dataToWidgetDistance(double x, double y, QPoint& point)
401  {
402  dataToWidget_(x, y, point);
403  // subtract the 'offset'
404  QPoint zero;
405  dataToWidget_(0, 0, zero);
406  point -= zero;
407  }
408 
412  inline PointXYType widgetToDataDistance(double x, double y)
413  {
414  PointXYType point = Plot1DCanvas::widgetToData(x, y); // call the 1D version, otherwise intensity&mirror modes will not be honored
415  // subtract the 'offset'
416  PointXYType zero = Plot1DCanvas::widgetToData(0, 0); // call the 1D version, otherwise intensity&mirror modes will not be honored
417  point -= zero;
418  return point;
419  }
420 
422  virtual const RangeType& getDataRange() const override
423  {
424  return overall_data_range_1d_;
425  }
426 
433  template <class T>
434  void pushIntoDataRange(T& data_point, const int layer_index)
435  { // note: if this is needed for anything other than the 1D Canvas, you need to make sure to call the correct widgetToData/ etc functions --- they work a bit different, depending on Canvas
436  auto xy_unit = unit_mapper_.map(data_point); // datatype to xy
437  pushIntoDataRange(xy_unit, layer_index);
438  unit_mapper_.fromXY(xy_unit, data_point); // xy to datatype
439  }
440 
446  //template<> // specialization does not compile when declared within the class on GCC -- even though it should; but I'm not moving it outside! :)
447  void pushIntoDataRange(PointXYType& xy_unit, const int layer_index)
448  { // note: if this is needed for anything other than the 1D Canvas, you need to make sure to call the correct widgetToData/ etc functions --- they work a bit different, depending on Canvas
449  auto p_range = unit_mapper_.fromXY(xy_unit);
450  const auto all_range = getLayer(layer_index).getRange();
451  p_range.pushInto(all_range);
452  xy_unit = unit_mapper_.mapRange(p_range).minPosition();
453  }
454 
456  void setTextBox(const QString& html);
457 
459 
461  Annotation1DItem* addPeakAnnotation(const PeakIndex& peak_index, const QString& text, const QColor& color);
462 
465  void performAlignment(Size layer_index_1, Size layer_index_2, const Param& param);
466 
469 
472 
474  double getAlignmentScore() const;
475 
477  std::vector<std::pair<Size, Size> > getAlignedPeaksIndices();
478 
480  void activateSpectrum(Size index, bool repaint = true);
481 
483  void setCurrentLayerPeakPenStyle(Qt::PenStyle ps);
484 
486  void paint(QPainter* paint_device, QPaintEvent* e);
487 
489  void setDrawInterestingMZs(bool enable);
490 
492  bool isDrawInterestingMZs() const;
493 
494  // Show/hide ion ladder on top right corner (Identification view)
495  void setIonLadderVisible(bool show);
496 
497  // Returns true if ion ladder is visible
498  bool isIonLadderVisible() const;
499 
504  const Gravitator& getGravitator() const
505  {
506  return gr_;
507  }
508 
509 signals:
512 
515 
518 
520  void showCurrentPeaksAsDIA(const Precursor& pc, const MSExperiment& exp);
521 
522 public slots:
523  // Docu in base class
524  void activateLayer(Size layer_index) override;
525  // Docu in base class
526  void removeLayer(Size layer_index) override;
527  // Docu in base class
528  void updateLayer(Size i) override;
529  // Docu in base class
530  void horizontalScrollBarChange(int value) override;
531 
532 protected slots:
533 
536 
537 protected:
538 
539 
548  void dataToWidget_(double x, double y, QPoint& point)
549  {
550  const auto& xy = visible_area_.getAreaXY();
551  const auto h_px = height();
552  const auto w_px = width();
553 
554  point.setX(int((x - xy.minX()) / xy.width() * w_px));
555 
556  if (intensity_mode_ != PlotCanvas::IM_LOG)
557  {
558  point.setY(int((xy.maxY() - y) / xy.height() * h_px));
559  }
560  else // IM_LOG
561  {
562  point.setY(h_px - int(std::log10((y - xy.minY()) + 1) / std::log10(xy.height() + 1) * h_px));
563  }
564  }
565 
566  void dataToWidget_(const DPosition<2>& xy, QPoint& point)
567  {
568  dataToWidget_(xy.getX(), xy.getY(), point);
569  }
570 
571  QPoint dataToWidget_(const DPosition<2>& xy)
572  {
573  QPoint point;
574  dataToWidget_(xy.getX(), xy.getY(), point);
575  return point;
576  }
577 
578  // Docu in base class
579  bool finishAdding_() override;
580 
582  void drawCoordinates_(QPainter& painter, const PeakIndex& peak);
584  void drawDeltas_(QPainter& painter, const PeakIndex& start, const PeakIndex& end);
585 
587  void drawAlignment_(QPainter& painter);
588 
590  void changeVisibleArea1D_(const UnitRange& new_area, bool repaint, bool add_to_stack);
591 
592  // Docu in base class
593  void changeVisibleArea_(VisibleArea new_area, bool repaint = true, bool add_to_stack = false) override;
594 
600  void changeVisibleArea_(const AreaXYType& new_area, bool repaint = true, bool add_to_stack = false);
601 
607  void changeVisibleArea_(const UnitRange& new_area, bool repaint = true, bool add_to_stack = false);
608 
609 
611  void drawHighlightedPeak_(Size layer_index, const PeakIndex& peak, QPainter& painter, bool draw_elongation = false);
612 
613 
621  void resetZoom(bool repaint = true) override
622  {
623  zoomClear_();
624  PlotCanvas::changeVisibleArea_(visible_area_.cloneWith(overall_data_range_1d_), repaint, true);
625  }
626 
629 
636  void recalculateRanges_() override
637  {
638  PlotCanvas::recalculateRanges_(); // for: overall_data_range_
639  // the same thing for: overall_data_range_1d_
640  RangeType& layer_range_1d = overall_data_range_1d_;
641  layer_range_1d.clearRanges();
642 
643  for (Size layer_index = 0; layer_index < getLayerCount(); ++layer_index)
644  {
645  layer_range_1d.extend(getLayer(layer_index).getRange1D());
646  }
647  // add 4% margin (2% left, 2% right) to all dimensions, except the current gravity axes's minimum (usually intensity)
648  layer_range_1d.scaleBy(1.04);
649 
650  // set minimum intensity to 0 (avoid negative intensities and show full height of peaks in case their common minimum is large)
651  auto& gravity_range = getGravityDim().map(layer_range_1d);
652  gravity_range.setMin(0);
653 
654  // make sure that each dimension is not a single point (axis widget won't like that)
655  // (this needs to be the last command to ensure this property holds when leaving the function!)
656  layer_range_1d.minSpanIfSingular(1);
657  }
658 
659  // Docu in base class
660  void updateScrollbars_() override;
661  // Docu in base class
662  void intensityModeChange_() override;
663 
664 
668 
671  void paintEvent(QPaintEvent* e) override;
672  void mousePressEvent(QMouseEvent* e) override;
673  void mouseReleaseEvent(QMouseEvent* e) override;
674  void mouseMoveEvent(QMouseEvent* e) override;
675  void keyPressEvent(QKeyEvent* e) override;
676  void contextMenuEvent(QContextMenuEvent* e) override;
678 
679  // docu in base class
680  void zoomForward_() override;
681  // docu in base class
682  void zoom_(int x, int y, bool zoom_in) override;
683  // docu in base class
684  void translateLeft_(Qt::KeyboardModifiers m) override;
685  // docu in base class
686  void translateRight_(Qt::KeyboardModifiers m) override;
687  // docu in base class
688  void translateForward_() override;
689  // docu in base class
690  void translateBackward_() override;
691 
692  // docu in base class
693  void paintGridLines_(QPainter& painter) override;
694 
697 
699  void addUserLabelAnnotation_(const QPoint& screen_position);
701  void addLabelAnnotation_(const QPoint& screen_position, const QString& label_text);
704 
707 
708  friend class Painter1DChrom;
709  friend class Painter1DPeak;
710  friend class Painter1DIonMobility;
711 
715 
718 
720  std::vector<DrawModes> draw_modes_;
722  std::vector<Qt::PenStyle> peak_penstyle_;
723 
727  bool mirror_mode_ = false;
729  bool moving_annotations_ = false;
731  bool show_alignment_ = false;
737  std::vector<std::pair<double, double> > aligned_peaks_mz_delta_;
739  std::vector<std::pair<Size, Size> > aligned_peaks_indices_;
741  double alignment_score_ = 0.0;
743  bool ion_ladder_visible_ = true;
745  bool draw_interesting_MZs_ = false;
747  QTextDocument text_box_content_;
750  };
751 
752 
753 
754 
755 } // namespace OpenMS
756 
An abstract class acting as an interface for the different 1D annotation items.
Definition: Annotation1DItem.h:36
DRange< N_DIM > AreaXYType
The Area in X,Y,(Z)... dimension (number of dimensions depends on N_DIM)
Definition: DimMapper.h:805
Representation of a coordinate in D-dimensional space.
Definition: DPosition.h:29
CoordinateType getY() const
Name accessor for the second dimension. Only for DPosition<2>, for visualization.
Definition: DPosition.h:149
CoordinateType getX() const
Name accessor for the first dimension. Only for DPosition<2>, for visualization.
Definition: DPosition.h:142
A base class for a dimension which represents a certain unit (e.g. RT or m/z). Derived classes implem...
Definition: DimMapper.h:41
DIM_UNIT getUnit() const
The unit of the dimension.
Definition: DimMapper.h:129
const DimBase & getDim(DIM d) const
obtain unit/name for X/Y/Z dimension.
Definition: DimMapper.h:758
Invalid value exception.
Definition: Exception.h:305
Not implemented exception.
Definition: Exception.h:399
Manipulates X or Y component of points in the X-Y plane, by assuming one axis (either X or Y axis) ha...
Definition: Plot1DCanvas.h:42
DIM gravity_axis_
Where are points in the X-Y plane projected onto when drawing lines?
Definition: Plot1DCanvas.h:279
QPoint gravitateWith(QPoint p, const QPoint &delta) const
Definition: Plot1DCanvas.h:138
void setIntensityAsGravity(const DimMapper< 2 > &unit_mapper)
Convenience function, which picks the Intensity dimension from a DimMapper as gravity axis.
Definition: Plot1DCanvas.h:84
QPoint gravitateMin(QPoint p, const AreaXYType &area) const
Definition: Plot1DCanvas.h:120
void setGravityAxis(DIM axis)
Definition: Plot1DCanvas.h:70
DPosition< D > gravitateZero(DPosition< D > p) const
Definition: Plot1DCanvas.h:222
int gravityValue(const QPoint &p) const
Definition: Plot1DCanvas.h:243
QPoint gravitateZero(QPoint p) const
Definition: Plot1DCanvas.h:204
DPosition< D > gravitateWith(DPosition< D > p, const DPosition< D > &delta) const
Same as gravitateWith()
Definition: Plot1DCanvas.h:153
int gravityValue(const DPosition< D > &p) const
Definition: Plot1DCanvas.h:261
QPoint gravitateTo(QPoint p, const QPoint &target) const
Definition: Plot1DCanvas.h:164
QPoint gravitateMax(QPoint p, const AreaXYType &area) const
Opposite of gravitateMin()
Definition: Plot1DCanvas.h:187
DPosition< D > gravitateTo(DPosition< D > p, const DPosition< D > &target) const
Same as gravitateTo()
Definition: Plot1DCanvas.h:179
Gravitator swap() const
Swap gravity axis (from X to Y, or vice versa)
Definition: Plot1DCanvas.h:108
Gravitator(const DimMapper< 2 > &unit_mapper)
Convenience c'tor, which picks the Intensity dimension from a DimMapper as gravity axis.
Definition: Plot1DCanvas.h:60
auto gravityDiff(const DPosition< D > &start, const DPosition< D > &end) const
Definition: Plot1DCanvas.h:272
Gravitator(DIM axis)
C'tor to apply gravity on any axis.
Definition: Plot1DCanvas.h:51
DPosition< D > gravitateNAN(DPosition< D > p) const
Definition: Plot1DCanvas.h:233
DIM getGravityAxis() const
Which axis is affected by gravity?
Definition: Plot1DCanvas.h:99
CoordinateType minX() const
Accessor for min_ coordinate minimum.
Definition: DIntervalBase.h:268
CoordinateType maxX() const
Accessor for min_ coordinate maximum.
Definition: DIntervalBase.h:280
CoordinateType maxY() const
Accessor for max_ coordinate maximum.
Definition: DIntervalBase.h:286
CoordinateType minY() const
Accessor for max_ coordinate minimum.
Definition: DIntervalBase.h:274
Base class for all 1D layers, a special case of LayerData.
Definition: LayerData1DBase.h:28
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:45
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
Painter1D for chromatograms.
Definition: Painter1DBase.h:71
Painter1D for mobilograms.
Definition: Painter1DBase.h:88
Painter1D for spectra.
Definition: Painter1DBase.h:51
Management and storage of parameters / INI files.
Definition: Param.h:44
Canvas for visualization of one or several spectra.
Definition: Plot1DCanvas.h:295
void dataToWidget(const DPosition< 2 > &xy_point, DPosition< 2 > &point, bool flipped)
For convenience - calls dataToWidget.
void translateForward_() override
Translation bound to the 'Up' key.
void recalculatePercentageFactor_(Size layer_index)
Recalculates the current scale factor based on the specified layer (= 1.0 if intensity mode !...
const DimBase & getGravityDim() const
Get the dimension on which gravity is currently acting upon (usually it's the Y axis' unit)
PointXYType widgetToData(double x, double y)
Calls PlotCanvas::widgetToData_(), takes mirror mode into account.
RangeAllType correctGravityAxisOfVisibleArea_(UnitRange area)
~Plot1DCanvas() override
Destructor.
std::vector< std::pair< Size, Size > > getAlignedPeaksIndices()
Returns aligned_peaks_indices_.
void drawCoordinates_(QPainter &painter, const PeakIndex &peak)
Draws the coordinates (or coordinate deltas) to the widget's upper left corner.
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:737
void addUserPeakAnnotation_(PeakIndex near_peak)
Shows dialog and calls addPeakAnnotation_.
const DimBase & getNonGravityDim() const
Get the dimension on which gravity is currently not acting upon (the orthogonal axis; usually it's th...
void dataToWidget(const DPosition< 2 > &peak, QPoint &point, bool flipped=false)
For convenience - calls dataToWidget.
void zoomForward_() override
Go forward in zoom history.
bool finishAdding_() override
Method that is called when a new layer has been added.
void dataToWidget(double x, double y, QPoint &point, bool flipped=false)
Calls PlotCanvas::dataToWidget_(), takes mirror mode into account.
void removeLayer(Size layer_index) override
void changeVisibleArea1D_(const UnitRange &new_area, bool repaint, bool add_to_stack)
internal method, called before calling parent function PlotCanvas::changeVisibleArea_
void mousePressEvent(QMouseEvent *e) override
void setDrawInterestingMZs(bool enable)
interesting (e.g., high-intensity) get live annotated with m/s's
DrawModes getDrawMode() const
Returns the draw mode of the current layer.
LabelMode
Label modes (percentage or absolute) of x axis and y axis.
Definition: Plot1DCanvas.h:301
@ LM_XPERCENT_YABSOLUTE
Definition: Plot1DCanvas.h:303
@ LM_XABSOLUTE_YPERCENT
Definition: Plot1DCanvas.h:304
@ LM_XABSOLUTE_YABSOLUTE
Definition: Plot1DCanvas.h:302
void horizontalScrollBarChange(int value) override
void setCurrentLayerPeakPenStyle(Qt::PenStyle ps)
Set's the Qt PenStyle of the active layer.
void mouseMoveEvent(QMouseEvent *e) override
std::vector< DrawModes > draw_modes_
Draw modes (for each layer) - sticks or connected lines.
Definition: Plot1DCanvas.h:720
void setMirrorModeActive(bool b)
Sets whether this widget is currently in mirror mode.
void resetZoom(bool repaint=true) override
Zooms fully out and resets the zoom stack.
Definition: Plot1DCanvas.h:621
void mouseReleaseEvent(QMouseEvent *e) override
void dataToWidget_(const DPosition< 2 > &xy, QPoint &point)
Definition: Plot1DCanvas.h:566
virtual const RangeType & getDataRange() const override
overload to call the 1D version (which has min-intensity of '0')
Definition: Plot1DCanvas.h:422
void currentLayerParamtersChanged_()
Reacts on changed layer parameters.
bool isIonLadderVisible() const
PeakIndex findPeakAtPosition_(QPoint)
Find peak next to the given position.
const LayerData1DBase & getCurrentLayer() const
void changeVisibleArea_(const UnitRange &new_area, bool repaint=true, bool add_to_stack=false)
Changes visible area interval.
void keyPressEvent(QKeyEvent *e) override
void activateSpectrum(Size index, bool repaint=true)
Sets current spectrum index of current layer to index.
void showCurrentPeaksAs2D()
Requests to display all spectra in 2D plot.
void showCurrentPeaksAsIonMobility(const MSSpectrum &spec)
Requests to display this spectrum (=frame) in ion mobility plot.
void updateScrollbars_() override
Updates the scroll bars.
void dataToWidgetDistance(double x, double y, QPoint &point)
converts a distance in axis values to pixel values
Definition: Plot1DCanvas.h:400
LayerData1DBase & getLayer(Size index)
DrawModes
Enumerate all available paint styles.
Definition: Plot1DCanvas.h:357
@ DM_PEAKS
draw data as peak
Definition: Plot1DCanvas.h:358
bool addChromLayer(ExperimentSharedPtrType chrom_exp_sptr, ODExperimentSharedPtrType ondisc_sptr, OSWDataSharedPtrType chrom_annotation, const int index, const String &filename, const String &basename, const String &basename_extra)
void showCurrentLayerPreferences() override
Shows the preferences dialog of the active layer.
void translateLeft_(Qt::KeyboardModifiers m) override
Translation bound to the 'Left' key.
bool mirrorModeActive() const
Returns whether this widget is currently in mirror mode.
void setIonLadderVisible(bool show)
void drawHighlightedPeak_(Size layer_index, const PeakIndex &peak, QPainter &painter, bool draw_elongation=false)
Draws a highlighted peak; if draw_elongation is true, the elongation line is drawn (for measuring)
void setTextBox(const QString &html)
Display a static text box on the top right.
void drawDeltas_(QPainter &painter, const PeakIndex &start, const PeakIndex &end)
Draws the coordinates (or coordinate deltas) to the widget's upper left corner.
const LayerData1DBase & getLayer(Size index) const
void flipLayer(Size index)
Flips the layer with index up/downwards.
void performAlignment(Size layer_index_1, Size layer_index_2, const Param &param)
bool isDrawInterestingMZs() const
Return true if interesting m/s are annotated.
std::vector< std::pair< Size, Size > > aligned_peaks_indices_
Stores the peak indices of pairs of aligned peaks in both spectra.
Definition: Plot1DCanvas.h:739
std::vector< Qt::PenStyle > peak_penstyle_
Draw style (for each layer)
Definition: Plot1DCanvas.h:722
void addLabelAnnotation_(const QPoint &screen_position, const QString &label_text)
Adds an annotation item at the given screen position.
const Gravitator & getGravitator() const
Get gravity manipulation object to apply gravity to points.
Definition: Plot1DCanvas.h:504
void paint(QPainter *paint_device, QPaintEvent *e)
Actual painting takes place here.
void intensityModeChange_() override
This method is called whenever the intensity mode changes. Reimplement if you need to react on such c...
double getAlignmentScore() const
Returns the score of the alignment.
QPoint measurement_start_point_px_
start point of "ruler" in pixel coordinates for measure mode
Definition: Plot1DCanvas.h:725
void activateLayer(Size layer_index) override
void changeVisibleArea_(const AreaXYType &new_area, bool repaint=true, bool add_to_stack=false)
Changes visible area interval.
void translateRight_(Qt::KeyboardModifiers m) override
Translation bound to the 'Right' key.
void showCurrentPeaksAsDIA(const Precursor &pc, const MSExperiment &exp)
Requests to display all spectra as DIA.
void updateLayer(Size i) override
void pushIntoDataRange(T &data_point, const int layer_index)
Pushes a data point back into the valid data range of the current layer area. Useful for annotation i...
Definition: Plot1DCanvas.h:434
void contextMenuEvent(QContextMenuEvent *e) override
void addUserLabelAnnotation_(const QPoint &screen_position)
Shows dialog and calls addLabelAnnotation_.
void setDrawMode(DrawModes mode)
Sets draw mode of the current layer.
Plot1DCanvas(const Param &preferences, const DIM gravity_axis=DIM::Y, QWidget *parent=nullptr)
Default constructor.
QTextDocument text_box_content_
The text box in the upper left corner with the current data coordinates of the cursor.
Definition: Plot1DCanvas.h:747
void showCurrentPeaksAs3D()
Requests to display all spectra in 3D plot.
void drawAlignment_(QPainter &painter)
Draws the alignment on painter.
void zoom_(int x, int y, bool zoom_in) override
Zooms such that screen point x, y would still point to the same data point.
void changeVisibleArea_(VisibleArea new_area, bool repaint=true, bool add_to_stack=false) override
Sets the visible area.
void paintGridLines_(QPainter &painter) override
Helper function to paint grid lines.
void dataToWidget_(double x, double y, QPoint &point)
Convert chart to widget coordinates.
Definition: Plot1DCanvas.h:548
PointXYType widgetToData(const QPoint &pos)
For convenience - calls widgetToData.
void recalculateRanges_() override
Recalculates the overall_data_range_ (by calling PlotCanvas::recalculateRanges_) plus the overall_dat...
Definition: Plot1DCanvas.h:636
void ensureAnnotationsWithinDataRange_()
Ensure that all annotations are within data range.
Annotation1DItem * addPeakAnnotation(const PeakIndex &peak_index, const QString &text, const QColor &color)
--— Annotations
PointXYType widgetToDataDistance(double x, double y)
compute distance in data coordinates (unit axis as shown) when moving x/y pixel in chart/widget coord...
Definition: Plot1DCanvas.h:412
RangeType overall_data_range_1d_
The data range (m/z, RT and intensity) of the current(!) spec/chrom for all layers.
Definition: Plot1DCanvas.h:717
Size alignment_layer_1_
Layer index of the first alignment layer.
Definition: Plot1DCanvas.h:733
QPoint dataToWidget_(const DPosition< 2 > &xy)
Definition: Plot1DCanvas.h:571
void translateBackward_() override
Translation bound to the 'Down' key.
Size getAlignmentSize()
Returns the number of aligned pairs of peaks.
Size alignment_layer_2_
Layer index of the second alignment layer.
Definition: Plot1DCanvas.h:735
void pushIntoDataRange(PointXYType &xy_unit, const int layer_index)
Pushes a data point back into the valid data range of the current layer area. Useful for annotation i...
Definition: Plot1DCanvas.h:447
Gravitator gr_
handles pulling/pushing of points to the edges of the widget
Definition: Plot1DCanvas.h:749
void paintEvent(QPaintEvent *e) override
bool flippedLayersExist()
Returns whether flipped layers exist or not.
LayerData1DBase & getCurrentLayer()
void resetAlignment()
Resets alignment_.
Base class for visualization canvas classes.
Definition: PlotCanvas.h:120
virtual void recalculateRanges_()
Recalculates the overall_data_range_.
Area< 2 >::AreaXYType AreaXYType
The range of data shown on the X and Y axis (unit depends on runtime config)
Definition: PlotCanvas.h:152
@ IM_LOG
Logarithmic version of normal mode.
Definition: PlotCanvas.h:181
virtual void changeVisibleArea_(VisibleArea new_area, bool repaint=true, bool add_to_stack=false)
Sets the visible area.
LayerDataBase::ExperimentSharedPtrType ExperimentSharedPtrType
Main managed data type (experiment)
Definition: PlotCanvas.h:130
LayerDataBase::ODExperimentSharedPtrType ODExperimentSharedPtrType
Definition: PlotCanvas.h:132
Precursor meta information.
Definition: Precursor.h:35
void scaleBy(const double factor)
calls RangeBase::scale() for each dimension
Definition: RangeManager.h:635
void minSpanIfSingular(const double min_span)
If any dimension is a single point, e.g. min==max, then extend this dimension by min_span / 2 on eith...
Definition: RangeManager.h:648
void clearRanges()
Resets all ranges.
Definition: RangeManager.h:794
void extend(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:626
A more convenient string class.
Definition: String.h:34
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
DIM
Definition: DimMapper.h:601
@ INT
intensity
boost::shared_ptr< OSWData > OSWDataSharedPtrType
SharedPtr on OSWData.
Definition: LayerDataChrom.h:16
Index of a peak or feature.
Definition: PeakIndex.h:25