OpenMS
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-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, Timo Sachsenberg, Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 // OpenMS_GUI config
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
40 // OpenMS
45 
46 // QT
47 #include <QTextDocument>
48 #include <QPoint>
49 
50 // STL
51 #include <vector>
52 #include <utility>
53 
54 // QT
55 class QAction;
56 
57 namespace OpenMS
58 {
59  class Annotation1DItem;
60 
67  class Gravitator
68  {
69  public:
70 
72 
78  {
79  setGravityAxis(axis);
80  }
81 
86  Gravitator(const DimMapper<2>& unit_mapper)
87  {
88  setIntensityAsGravity(unit_mapper);
89  }
90 
96  void setGravityAxis(DIM axis)
97  {
98  if (axis != DIM::X && axis != DIM::Y)
99  {
100  throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Not a valid axis for 1D plotting", String((int)axis));
101  }
102  gravity_axis_ = axis;
103  }
104 
110  void setIntensityAsGravity(const DimMapper<2>& unit_mapper)
111  {
112  if (unit_mapper.getDim(DIM::X).getUnit() == DIM_UNIT::INT)
113  {
115  }
116  if (unit_mapper.getDim(DIM::Y).getUnit() == DIM_UNIT::INT)
117  {
119  }
121  throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
122  }
123 
126  {
127  return gravity_axis_;
128  }
129 
134  Gravitator swap() const
135  {
136  auto r = *this;
137  r.setGravityAxis( (r.getGravityAxis() == DIM::X) ? DIM::Y : DIM::X);
138  return r;
139  }
140 
146  QPoint gravitateMin(QPoint p, const AreaXYType& area) const
147  {
148  if (gravity_axis_ == DIM::X)
149  {
150  p.rx() = area.minX();
151  }
152  else if (gravity_axis_ == DIM::Y)
153  {
154  p.ry() = area.minY();
155  }
156  return p;
157  }
158 
164  QPoint gravitateWith(QPoint p, const QPoint& delta) const
165  {
166  if (gravity_axis_ == DIM::X)
167  {
168  p.rx() += delta.x();
169  }
170  else if (gravity_axis_ == DIM::Y)
171  {
172  p.ry() += delta.y();
173  }
174  return p;
175  }
176 
178  template<UInt D>
180  {
181  p[(int)gravity_axis_] += delta[(int)gravity_axis_];
182  return p;
183  }
184 
190  QPoint gravitateTo(QPoint p, const QPoint& target) const
191  {
192  if (gravity_axis_ == DIM::X)
193  {
194  p.rx() = target.x();
195  }
196  else if (gravity_axis_ == DIM::Y)
197  {
198  p.ry() = target.y();
199  }
200  return p;
201  }
202 
204  template<UInt D>
206  {
207  p[(int)gravity_axis_] = target[(int)gravity_axis_];
208  return p;
209  }
210 
211 
213  QPoint gravitateMax(QPoint p, const AreaXYType& area) const
214  {
215  if (gravity_axis_ == DIM::X)
216  {
217  p.rx() = area.maxX();
218  }
219  else if (gravity_axis_ == DIM::Y)
220  {
221  p.ry() = area.maxY();
222  }
223  return p;
224  }
225 
230  QPoint gravitateZero(QPoint p) const
231  {
232  if (gravity_axis_ == DIM::X)
233  {
234  p.rx() = 0;
235  }
236  else if (gravity_axis_ == DIM::Y)
237  {
238  p.ry() = 0;
239  }
240  return p;
241  }
242 
247  template<UInt D>
249  {
250  p[(int)gravity_axis_] = 0;
251  return p;
252  }
253 
258  template<UInt D>
260  {
261  p[(int)gravity_axis_] = std::numeric_limits<float>::quiet_NaN();
262  return p;
263  }
264 
269  int gravityValue(const QPoint& p) const
270  {
271  if (gravity_axis_ == DIM::X)
272  {
273  return p.x();
274  }
275  else if (gravity_axis_ == DIM::Y)
276  {
277  return p.y();
278  }
279  // never reached, but make compilers happy
280  return 0;
281  }
286  template<UInt D>
287  int gravityValue(const DPosition<D>& p) const
288  {
289  return p[(int)gravity_axis_];
290  }
291 
297  template<UInt D>
298  auto gravityDiff(const DPosition<D>& start, const DPosition<D>& end) const
299  {
300  return end[(int)gravity_axis_] - start[(int)gravity_axis_];
301  }
302 
303  private:
306  };
307 
319  class OPENMS_GUI_DLLAPI Plot1DCanvas :
320  public PlotCanvas
321  {
322  Q_OBJECT
323 
324 public:
327  {
331  LM_XPERCENT_YPERCENT
332  };
333 
335  constexpr static double TOP_MARGIN{1.09};
336 
338  Plot1DCanvas(const Param& preferences, const DIM gravity_axis = DIM::Y, QWidget* parent = nullptr);
340  ~Plot1DCanvas() override;
341 
344  const LayerData1DBase& getLayer(Size index) const;
348 
355 
357  const DimBase& getGravityDim() const;
358 
360  const DimBase& getNonGravityDim() const;
361 
373  ODExperimentSharedPtrType ondisc_sptr,
374  OSWDataSharedPtrType chrom_annotation,
375  const int index,
376  const String& filename,
377  const String& basename,
378  const String& basename_extra);
379 
380 
383  {
385  DM_CONNECTEDLINES
386  };
387 
390 
392  void setDrawMode(DrawModes mode);
393 
394  // Docu in base class
396 
399 
401  void flipLayer(Size index);
402 
404  bool mirrorModeActive() const;
405 
407  void setMirrorModeActive(bool b);
408 
410  void dataToWidget(const DPosition<2>& peak, QPoint& point, bool flipped = false);
412  void dataToWidget(const DPosition<2>& xy_point, DPosition<2>& point, bool flipped);
413 
415  void dataToWidget(double x, double y, QPoint& point, bool flipped = false);
416 
418  PointXYType widgetToData(const QPoint& pos);
419 
421  PointXYType widgetToData(double x, double y);
422 
426  inline void dataToWidgetDistance(double x, double y, QPoint& point)
427  {
428  dataToWidget_(x, y, point);
429  // subtract the 'offset'
430  QPoint zero;
431  dataToWidget_(0, 0, zero);
432  point -= zero;
433  }
434 
438  inline PointXYType widgetToDataDistance(double x, double y)
439  {
440  PointXYType point = Plot1DCanvas::widgetToData(x, y); // call the 1D version, otherwise intensity&mirror modes will not be honored
441  // subtract the 'offset'
442  PointXYType zero = Plot1DCanvas::widgetToData(0, 0); // call the 1D version, otherwise intensity&mirror modes will not be honored
443  point -= zero;
444  return point;
445  }
446 
453  template <class T>
454  void pushIntoDataRange(T& data_point, const int layer_index)
455  { // 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
456  auto xy_unit = unit_mapper_.map(data_point); // datatype to xy
457  pushIntoDataRange(xy_unit, layer_index);
458  unit_mapper_.fromXY(xy_unit, data_point); // xy to datatype
459  }
460 
466  //template<> // specialization does not compile when declared within the class on GCC -- even though it should; but I'm not moving it outside! :)
467  void pushIntoDataRange(PointXYType& xy_unit, const int layer_index)
468  { // 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
469  auto p_range = unit_mapper_.fromXY(xy_unit);
470  const auto all_range = getLayer(layer_index).getRange();
471  p_range.pushInto(all_range);
472  xy_unit = unit_mapper_.mapRange(p_range).minPosition();
473  }
474 
476  void setTextBox(const QString& html);
477 
479 
481  Annotation1DItem* addPeakAnnotation(const PeakIndex& peak_index, const QString& text, const QColor& color);
482 
485  void performAlignment(Size layer_index_1, Size layer_index_2, const Param& param);
486 
489 
492 
494  double getAlignmentScore() const;
495 
497  std::vector<std::pair<Size, Size> > getAlignedPeaksIndices();
498 
500  void activateSpectrum(Size index, bool repaint = true);
501 
503  void setCurrentLayerPeakPenStyle(Qt::PenStyle ps);
504 
506  void paint(QPainter* paint_device, QPaintEvent* e);
507 
509  void setDrawInterestingMZs(bool enable);
510 
512  bool isDrawInterestingMZs() const;
513 
514  // Show/hide ion ladder on top right corner (Identification view)
515  void setIonLadderVisible(bool show);
516 
517  // Returns true if ion ladder is visible
518  bool isIonLadderVisible() const;
519 
524  const Gravitator& getGravitator() const
525  {
526  return gr_;
527  }
528 
529 signals:
532 
535 
538 
540  void showCurrentPeaksAsDIA(const Precursor& pc, const MSExperiment& exp);
541 
542 public slots:
543  // Docu in base class
544  void activateLayer(Size layer_index) override;
545  // Docu in base class
546  void removeLayer(Size layer_index) override;
547  // Docu in base class
548  void updateLayer(Size i) override;
549  // Docu in base class
550  void horizontalScrollBarChange(int value) override;
551 
552 protected slots:
553 
556 
557 protected:
558 
559 
568  void dataToWidget_(double x, double y, QPoint& point)
569  {
570  const auto& xy = visible_area_.getAreaXY();
571  const auto h_px = height();
572  const auto w_px = width();
573 
574  point.setX(int((x - xy.minX()) / xy.width() * w_px));
575 
576  if (intensity_mode_ != PlotCanvas::IM_LOG)
577  {
578  point.setY(int((xy.maxY() - y) / xy.height() * h_px));
579  }
580  else // IM_LOG
581  {
582  point.setY(h_px - int(std::log10((y - xy.minY()) + 1) / std::log10(xy.height() + 1) * h_px));
583  }
584  }
585 
586  void dataToWidget_(const DPosition<2>& xy, QPoint& point)
587  {
588  dataToWidget_(xy.getX(), xy.getY(), point);
589  }
590 
591  QPoint dataToWidget_(const DPosition<2>& xy)
592  {
593  QPoint point;
594  dataToWidget_(xy.getX(), xy.getY(), point);
595  return point;
596  }
597 
598  // Docu in base class
599  bool finishAdding_() override;
600 
602  void drawCoordinates_(QPainter& painter, const PeakIndex& peak);
604  void drawDeltas_(QPainter& painter, const PeakIndex& start, const PeakIndex& end);
605 
607  void drawAlignment_(QPainter& painter);
608 
610  void changeVisibleAreaCommon_(const UnitRange& new_area, bool repaint, bool add_to_stack);
611 
612  // Docu in base class
613  void changeVisibleArea_(VisibleArea new_area, bool repaint = true, bool add_to_stack = false) override;
614 
620  void changeVisibleArea_(const AreaXYType& new_area, bool repaint = true, bool add_to_stack = false);
621 
627  void changeVisibleArea_(const UnitRange& new_area, bool repaint = true, bool add_to_stack = false);
628 
629 
631  void drawHighlightedPeak_(Size layer_index, const PeakIndex& peak, QPainter& painter, bool draw_elongation = false);
632 
633 
641  void resetZoom(bool repaint = true) override
642  {
643  zoomClear_();
644  PlotCanvas::changeVisibleArea_(visible_area_.cloneWith(overall_data_range_1d_), repaint, true);
645  }
646 
649 
656  void recalculateRanges_() override
657  {
658  PlotCanvas::recalculateRanges_(); // for: overall_data_range_
659  // the same thing for: overall_data_range_1d_
660  RangeType& layer_range_1d = overall_data_range_1d_;
661  layer_range_1d.clearRanges();
662 
663  for (Size layer_index = 0; layer_index < getLayerCount(); ++layer_index)
664  {
665  layer_range_1d.extend(getLayer(layer_index).getRange1D());
666  }
667  // add 4% margin (2% left, 2% right) to all dimensions, except the current gravity axes's minimum (usually intensity)
668  layer_range_1d.scaleBy(1.04);
669 
670  // set minimum intensity to 0 (avoid negative intensities and show full height of peaks in case their common minimum is large)
671  auto& gravity_range = getGravityDim().map(layer_range_1d);
672  gravity_range.setMin(0);
673 
674  // make sure that each dimension is not a single point (axis widget won't like that)
675  // (this needs to be the last command to ensure this property holds when leaving the function!)
676  layer_range_1d.minSpanIfSingular(1);
677  }
678 
679  // Docu in base class
680  void updateScrollbars_() override;
681  // Docu in base class
682  void intensityModeChange_() override;
683 
684 
688 
691  void paintEvent(QPaintEvent* e) override;
692  void mousePressEvent(QMouseEvent* e) override;
693  void mouseReleaseEvent(QMouseEvent* e) override;
694  void mouseMoveEvent(QMouseEvent* e) override;
695  void keyPressEvent(QKeyEvent* e) override;
696  void contextMenuEvent(QContextMenuEvent* e) override;
698 
699  // docu in base class
700  void zoomForward_() override;
701  // docu in base class
702  void zoom_(int x, int y, bool zoom_in) override;
703  // docu in base class
704  void translateLeft_(Qt::KeyboardModifiers m) override;
705  // docu in base class
706  void translateRight_(Qt::KeyboardModifiers m) override;
707  // docu in base class
708  void translateForward_() override;
709  // docu in base class
710  void translateBackward_() override;
711 
712  // docu in base class
713  void paintGridLines_(QPainter& painter) override;
714 
717 
719  void addUserLabelAnnotation_(const QPoint& screen_position);
721  void addLabelAnnotation_(const QPoint& screen_position, const QString& label_text);
724 
727 
728  friend class Painter1DChrom;
729  friend class Painter1DPeak;
730  friend class Painter1DIonMobility;
731 
735 
738 
740  std::vector<DrawModes> draw_modes_;
742  std::vector<Qt::PenStyle> peak_penstyle_;
743 
747  bool mirror_mode_ = false;
749  bool moving_annotations_ = false;
751  bool show_alignment_ = false;
757  std::vector<std::pair<double, double> > aligned_peaks_mz_delta_;
759  std::vector<std::pair<Size, Size> > aligned_peaks_indices_;
761  double alignment_score_ = 0.0;
763  bool ion_ladder_visible_ = true;
765  bool draw_interesting_MZs_ = false;
767  QTextDocument text_box_content_;
770  };
771 
772 
773 
774 
775 } // namespace OpenMS
776 
An abstract class acting as an interface for the different 1D annotation items.
Definition: Annotation1DItem.h:62
DRange< N_DIM > AreaXYType
The Area in X,Y,(Z)... dimension (number of dimensions depends on N_DIM)
Definition: DimMapper.h:822
Representation of a coordinate in D-dimensional space.
Definition: DPosition.h:55
CoordinateType getY() const
Name accessor for the second dimension. Only for DPosition<2>, for visualization.
Definition: DPosition.h:175
CoordinateType getX() const
Name accessor for the first dimension. Only for DPosition<2>, for visualization.
Definition: DPosition.h:168
A base class for a dimension which represents a certain unit (e.g. RT or m/z). Derived classes implem...
Definition: DimMapper.h:67
DIM_UNIT getUnit() const
The unit of the dimension.
Definition: DimMapper.h:155
const DimBase & getDim(DIM d) const
obtain unit/name for X/Y/Z dimension.
Definition: DimMapper.h:784
Invalid value exception.
Definition: Exception.h:329
Not implemented exception.
Definition: Exception.h:430
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:68
DIM gravity_axis_
Where are points in the X-Y plane projected onto when drawing lines?
Definition: Plot1DCanvas.h:305
QPoint gravitateWith(QPoint p, const QPoint &delta) const
Definition: Plot1DCanvas.h:164
void setIntensityAsGravity(const DimMapper< 2 > &unit_mapper)
Convenience function, which picks the Intensity dimension from a DimMapper as gravity axis.
Definition: Plot1DCanvas.h:110
QPoint gravitateMin(QPoint p, const AreaXYType &area) const
Definition: Plot1DCanvas.h:146
void setGravityAxis(DIM axis)
Definition: Plot1DCanvas.h:96
DPosition< D > gravitateZero(DPosition< D > p) const
Definition: Plot1DCanvas.h:248
int gravityValue(const QPoint &p) const
Definition: Plot1DCanvas.h:269
QPoint gravitateZero(QPoint p) const
Definition: Plot1DCanvas.h:230
DPosition< D > gravitateWith(DPosition< D > p, const DPosition< D > &delta) const
Same as gravitateWith()
Definition: Plot1DCanvas.h:179
int gravityValue(const DPosition< D > &p) const
Definition: Plot1DCanvas.h:287
QPoint gravitateTo(QPoint p, const QPoint &target) const
Definition: Plot1DCanvas.h:190
QPoint gravitateMax(QPoint p, const AreaXYType &area) const
Opposite of gravitateMin()
Definition: Plot1DCanvas.h:213
DPosition< D > gravitateTo(DPosition< D > p, const DPosition< D > &target) const
Same as gravitateTo()
Definition: Plot1DCanvas.h:205
Gravitator swap() const
Swap gravity axis (from X to Y, or vice versa)
Definition: Plot1DCanvas.h:134
Gravitator(const DimMapper< 2 > &unit_mapper)
Convenience c'tor, which picks the Intensity dimension from a DimMapper as gravity axis.
Definition: Plot1DCanvas.h:86
auto gravityDiff(const DPosition< D > &start, const DPosition< D > &end) const
Definition: Plot1DCanvas.h:298
Gravitator(DIM axis)
C'tor to apply gravity on any axis.
Definition: Plot1DCanvas.h:77
DPosition< D > gravitateNAN(DPosition< D > p) const
Definition: Plot1DCanvas.h:259
DIM getGravityAxis() const
Which axis is affected by gravity?
Definition: Plot1DCanvas.h:125
CoordinateType minX() const
Accessor for min_ coordinate minimum.
Definition: DIntervalBase.h:294
CoordinateType maxX() const
Accessor for min_ coordinate maximum.
Definition: DIntervalBase.h:306
CoordinateType maxY() const
Accessor for max_ coordinate maximum.
Definition: DIntervalBase.h:312
CoordinateType minY() const
Accessor for max_ coordinate minimum.
Definition: DIntervalBase.h:300
Base class for all 1D layers, a special case of LayerData.
Definition: LayerData1DBase.h:54
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:72
The representation of a 1D spectrum.
Definition: MSSpectrum.h:70
Painter1D for chromatograms.
Definition: Painter1DBase.h:97
Painter1D for mobilograms.
Definition: Painter1DBase.h:114
Painter1D for spectra.
Definition: Painter1DBase.h:77
Management and storage of parameters / INI files.
Definition: Param.h:70
Canvas for visualization of one or several spectra.
Definition: Plot1DCanvas.h:321
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 changeVisibleAreaCommon_(const UnitRange &new_area, bool repaint, bool add_to_stack)
internal method, called before calling parent function PlotCanvas::changeVisibleArea_
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:757
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 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:327
@ LM_XPERCENT_YABSOLUTE
Definition: Plot1DCanvas.h:329
@ LM_XABSOLUTE_YPERCENT
Definition: Plot1DCanvas.h:330
@ LM_XABSOLUTE_YABSOLUTE
Definition: Plot1DCanvas.h:328
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:740
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:641
void mouseReleaseEvent(QMouseEvent *e) override
void dataToWidget_(const DPosition< 2 > &xy, QPoint &point)
Definition: Plot1DCanvas.h:586
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 all spectra 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:426
LayerData1DBase & getLayer(Size index)
DrawModes
Enumerate all available paint styles.
Definition: Plot1DCanvas.h:383
@ DM_PEAKS
draw data as peak
Definition: Plot1DCanvas.h:384
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:759
std::vector< Qt::PenStyle > peak_penstyle_
Draw style (for each layer)
Definition: Plot1DCanvas.h:742
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:524
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:745
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:454
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:767
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:568
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:656
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:438
RangeType overall_data_range_1d_
The data range (m/z, RT and intensity) of the current(!) spec/chrom for all layers.
Definition: Plot1DCanvas.h:737
Size alignment_layer_1_
Layer index of the first alignment layer.
Definition: Plot1DCanvas.h:753
QPoint dataToWidget_(const DPosition< 2 > &xy)
Definition: Plot1DCanvas.h:591
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:755
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:467
Gravitator gr_
handles pulling/pushing of points to the edges of the widget
Definition: Plot1DCanvas.h:769
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:146
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:178
@ IM_LOG
Logarithmic version of normal mode.
Definition: PlotCanvas.h:207
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:156
LayerDataBase::ODExperimentSharedPtrType ODExperimentSharedPtrType
Definition: PlotCanvas.h:158
Precursor meta information.
Definition: Precursor.h:61
void scaleBy(const double factor)
calls RangeBase::scale() for each dimension
Definition: RangeManager.h:654
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:669
void clearRanges()
Resets all ranges.
Definition: RangeManager.h:821
void extend(const RangeManager< RangeBasesOther... > &rhs)
Definition: RangeManager.h:645
A more convenient string class.
Definition: String.h:60
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
DIM
Definition: DimMapper.h:627
@ INT
intensity
boost::shared_ptr< OSWData > OSWDataSharedPtrType
SharedPtr on OSWData.
Definition: LayerDataChrom.h:42
Index of a peak or feature.
Definition: PeakIndex.h:51