OpenMS
Annotation1DDistanceItem.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: Johannes Veit, Chris Bielow $
6 // $Authors: Johannes Junker, Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
12 #include <vector>
13 
14 namespace OpenMS
15 {
20  public Annotation1DItem
21  {
22 
23 public:
31  Annotation1DDistanceItem(const QString& text, const PointXYType& start_point, const PointXYType& end_point, const bool swap_ends_if_negative = true);
35  ~Annotation1DDistanceItem() override = default;
36 
37  // Docu in base class
38  void ensureWithinDataRange(Plot1DCanvas* const canvas, const int layer_index) override;
39 
40  // Docu in base class
41  void draw(Plot1DCanvas* const canvas, QPainter& painter, bool flipped = false) override;
42 
43  // Docu in base class
44  void move(const PointXYType delta, const Gravitator& gr, const DimMapper<2>& dim_mapper) override;
45 
47  const PointXYType& getStartPoint() const
48  {
49  return start_point_;
50  }
51 
53  const PointXYType& getEndPoint() const
54  {
55  return end_point_;
56  }
57 
65  double getDistance() const;
66 
68  void setTicks(const std::vector<PointXYType>& ticks);
69 
70  // Docu in base class
71  Annotation1DItem* clone() const override
72  {
73  return new Annotation1DDistanceItem(*this);
74  }
75 
76  protected:
82  std::vector<PointXYType> ticks_;
83 
84  };
85 } // namespace OpenMS
86 
An annotation item which represents a measured distance between two peaks.
Definition: Annotation1DDistanceItem.h:21
Annotation1DItem * clone() const override
Creates a copy of the item on the heap and returns a pointer.
Definition: Annotation1DDistanceItem.h:71
PointXYType start_point_
The start point of the measured distance line (in XY data coordinates)
Definition: Annotation1DDistanceItem.h:78
void draw(Plot1DCanvas *const canvas, QPainter &painter, bool flipped=false) override
Draws the item on painter.
const PointXYType & getEndPoint() const
Returns the end point.
Definition: Annotation1DDistanceItem.h:53
std::vector< PointXYType > ticks_
Additional tick lines for the distance item (the gravity dimension is ignored)
Definition: Annotation1DDistanceItem.h:82
void ensureWithinDataRange(Plot1DCanvas *const canvas, const int layer_index) override
Ensures that the item has coordinates within the visible area of the canvas.
void setTicks(const std::vector< PointXYType > &ticks)
Set tick lines for the distance item in unit XY coordinates (the gravity dimension is ignored)
const PointXYType & getStartPoint() const
Returns the start point.
Definition: Annotation1DDistanceItem.h:47
PointXYType end_point_
The end point of the measured distance line (in XY data coordinates)
Definition: Annotation1DDistanceItem.h:80
void move(const PointXYType delta, const Gravitator &gr, const DimMapper< 2 > &dim_mapper) override
Moves the item on the drawing canvas; behavior depends on item type and is implemented in the subclas...
Annotation1DDistanceItem(const Annotation1DDistanceItem &rhs)=default
Copy constructor.
Annotation1DDistanceItem(const QString &text, const PointXYType &start_point, const PointXYType &end_point, const bool swap_ends_if_negative=true)
~Annotation1DDistanceItem() override=default
Destructor.
double getDistance() const
Compute the (negative) euclidean distance between start and endpoint.
An abstract class acting as an interface for the different 1D annotation items.
Definition: Annotation1DItem.h:36
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
Canvas for visualization of one or several spectra.
Definition: Plot1DCanvas.h:295
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19