OpenMS
Annotation1DTextItem.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: Johannes Junker, Timo Sachsenberg $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
13 
14 namespace OpenMS
15 {
20  public Annotation1DItem
21  {
22 public:
23 
25  Annotation1DTextItem(const PointXYType& position, const QString& text, const int flags = Qt::AlignCenter)
26  : Annotation1DItem(text), position_(position), flags_(flags)
27  {
28  }
31 
33  ~Annotation1DTextItem() override = default;
34 
35  // Docu in base class
36  void ensureWithinDataRange(Plot1DCanvas* const canvas, const int layer_index) override;
37 
38  // Docu in base class
39  void draw(Plot1DCanvas* const canvas, QPainter& painter, bool flipped = false) override;
40 
41  // Docu in base class
42  void move(const PointXYType delta, const Gravitator& gr, const DimMapper<2>& dim_mapper) override;
43 
45  void setPosition(const PointXYType& position)
46  {
47  position_ = position;
48  }
49 
51  const PointXYType& getPosition() const
52  {
53  return position_;
54  }
55 
57  void setFlags(int flags)
58  {
59  flags_ = flags;
60  }
61 
63  int getFlags() const
64  {
65  return flags_;
66  }
67 
68  // Docu in base class
69  Annotation1DItem* clone() const override
70  {
71  return new Annotation1DTextItem(*this);
72  }
73 
74  protected:
77 
78  int flags_;
79  };
80 } // namespace OpenMS
81 
An abstract class acting as an interface for the different 1D annotation items.
Definition: Annotation1DItem.h:36
An annotation item which represents an arbitrary text on the canvas.
Definition: Annotation1DTextItem.h:21
Annotation1DItem * clone() const override
Creates a copy of the item on the heap and returns a pointer.
Definition: Annotation1DTextItem.h:69
void setFlags(int flags)
Set Qt flags (default: Qt::AlignCenter)
Definition: Annotation1DTextItem.h:57
Annotation1DTextItem(const Annotation1DTextItem &rhs)=default
Copy constructor.
int flags_
Definition: Annotation1DTextItem.h:78
void draw(Plot1DCanvas *const canvas, QPainter &painter, bool flipped=false) override
Draws the item on painter.
void ensureWithinDataRange(Plot1DCanvas *const canvas, const int layer_index) override
Ensures that the item has coordinates within the visible area of the canvas.
int getFlags() const
Get Qt flags.
Definition: Annotation1DTextItem.h:63
PointXYType position_
The position of the item as a datatype, e.g. Peak1D.
Definition: Annotation1DTextItem.h:76
const PointXYType & getPosition() const
Returns the position of the item (in X-Y coordinates)
Definition: Annotation1DTextItem.h:51
~Annotation1DTextItem() override=default
Destructor.
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...
void setPosition(const PointXYType &position)
Sets the position of the item (in X-Y coordinates)
Definition: Annotation1DTextItem.h:45
Annotation1DTextItem(const PointXYType &position, const QString &text, const int flags=Qt::AlignCenter)
Constructor.
Definition: Annotation1DTextItem.h:25
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