OpenMS
Annotation1DItem.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, 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 
11 #include <OpenMS/VISUAL/MISC/CommonDefs.h> // for PointXYType
12 
13 #include <QtCore/QRectF>
14 #include <QtCore/QString>
15 
16 class QPainter;
17 
18 namespace OpenMS
19 {
20  template<int D> class DimMapper;
21  class Gravitator;
22  class Plot1DCanvas;
23 
36  {
37  public:
39  virtual ~Annotation1DItem();
40 
42  const QRectF& boundingBox() const;
43 
45  bool isSelected() const;
46 
48  void setSelected(bool selected);
49 
51  void setText(const QString & text);
52 
54  const QString& getText() const;
55 
58  bool editText();
59 
61  virtual void ensureWithinDataRange(Plot1DCanvas* const canvas, const int layer_index) = 0;
62 
64  virtual void draw(Plot1DCanvas* const canvas, QPainter& painter, bool flipped = false) = 0;
65 
67  virtual void move(const PointXYType delta, const Gravitator& gr, const DimMapper<2>& dim_mapper) = 0;
68 
70  virtual Annotation1DItem* clone() const = 0;
71 
72  protected:
74  Annotation1DItem(const QString & text);
75 
78 
80  void drawBoundingBox_(QPainter & painter);
81 
83  QRectF bounding_box_;
84 
86  bool selected_;
87 
89  QString text_;
90  };
91 } // namespace OpenMS
An abstract class acting as an interface for the different 1D annotation items.
Definition: Annotation1DItem.h:36
void setText(const QString &text)
Sets the text of the item.
const QRectF & boundingBox() const
Returns the current bounding box of this item on the canvas where it has last been drawn.
QRectF bounding_box_
The current bounding box of this item on the canvas where it has last been drawn.
Definition: Annotation1DItem.h:83
QString text_
The displayed text.
Definition: Annotation1DItem.h:89
bool isSelected() const
Returns true if this item is currently selected on the canvas, else false.
virtual void move(const PointXYType delta, const Gravitator &gr, const DimMapper< 2 > &dim_mapper)=0
Moves the item on the drawing canvas; behavior depends on item type and is implemented in the subclas...
virtual ~Annotation1DItem()
Destructor.
void drawBoundingBox_(QPainter &painter)
Draws the bounding_box_.
virtual Annotation1DItem * clone() const =0
Creates a copy of the item on the heap and returns a pointer.
virtual void ensureWithinDataRange(Plot1DCanvas *const canvas, const int layer_index)=0
Ensures that the item has coordinates within the visible area of the canvas.
Annotation1DItem(const Annotation1DItem &rhs)
Copy constructor.
Annotation1DItem(const QString &text)
Constructor.
const QString & getText() const
Returns the text of the item.
void setSelected(bool selected)
Sets whether this item is currently selected on the canvas or not.
bool selected_
Determines whether this item is currently selected on the canvas.
Definition: Annotation1DItem.h:86
virtual void draw(Plot1DCanvas *const canvas, QPainter &painter, bool flipped=false)=0
Draws the item on painter.
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: FeatureDeconvolution.h:22