OpenMS
LayerData1DBase.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: Chris Bielow $
32 // $Authors: Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
39 
40 class QWidget;
41 
42 namespace OpenMS
43 {
44  class Annotation1DItem;
45 
53  class OPENMS_GUI_DLLAPI LayerData1DBase : public virtual LayerDataBase
54  {
55  public:
56  // rule of 0
57 
62  virtual std::unique_ptr<Painter1DBase> getPainter1D() const = 0;
63 
67  virtual RangeAllType getRange1D() const = 0;
74  virtual RangeAllType getRangeForArea(const RangeAllType partial_range) const = 0;
75 
82  virtual QMenu* getContextMenuAnnotation(Annotation1DItem* annot_item, bool& need_repaint) = 0;
83 
84 
92  virtual Annotation1DItem* addPeakAnnotation(const PeakIndex& peak_index, const QString& text, const QColor& color) = 0;
93 
94 
96  String getDecoratedName() const override;
97 
100  {
101  return annotations_1d_[current_idx_];
102  }
103 
106  {
107  return annotations_1d_[current_idx_];
108  }
109 
111  const Annotations1DContainer& getAnnotations(Size spectrum_index) const
112  {
113  return annotations_1d_[spectrum_index];
114  }
115 
118  {
119  return annotations_1d_[spectrum_index];
120  }
123  {
124  return current_idx_;
125  }
126 
128  void setCurrentIndex(Size index);
129 
131  virtual bool hasIndex(Size index) const = 0;
132 
134  bool flipped = false;
135 
137  std::vector<QColor> peak_colors_1d;
138 
139  protected:
141  Size current_idx_ = 0;
142 
144  std::vector<Annotations1DContainer> annotations_1d_ = std::vector<Annotations1DContainer>(1);
145  };
146 
147 }// namespace OpenMS
148 
An abstract class acting as an interface for the different 1D annotation items.
Definition: Annotation1DItem.h:62
Container for annotations to content of Plot1DCanvas.
Definition: Annotations1DContainer.h:55
Base class for all 1D layers, a special case of LayerData.
Definition: LayerData1DBase.h:54
const Annotations1DContainer & getAnnotations(Size spectrum_index) const
Returns a const reference to the annotations of the spectrum_index's spectrum (1D view)
Definition: LayerData1DBase.h:111
virtual Annotation1DItem * addPeakAnnotation(const PeakIndex &peak_index, const QString &text, const QColor &color)=0
Add a Annotation1DPeakItem to getCurrentAnnotations(). The specific type is determined by the derived...
virtual std::unique_ptr< Painter1DBase > getPainter1D() const =0
Obtain a painter which can draw the layer on a canvas.
virtual bool hasIndex(Size index) const =0
Does the layer have at least index items (e.g. spectra, chroms, etc), so a call to setCurrentIndex() ...
String getDecoratedName() const override
get name augmented with attributes, e.g. '*' if modified
Size getCurrentIndex() const
Get the index of the current spectrum (1D view)
Definition: LayerData1DBase.h:122
virtual RangeAllType getRange1D() const =0
Annotations1DContainer & getCurrentAnnotations()
Returns a mutable reference to the annotations of the current spectrum (1D view)
Definition: LayerData1DBase.h:105
void setCurrentIndex(Size index)
Set the index of the current spectrum (1D view) – and prepares annotations.
const Annotations1DContainer & getCurrentAnnotations() const
Returns a const reference to the annotations of the current spectrum (1D view)
Definition: LayerData1DBase.h:99
virtual RangeAllType getRangeForArea(const RangeAllType partial_range) const =0
Given a partial_range for the current 1D layer (e.g. an m/z range), fill in the other dimensions (usu...
virtual QMenu * getContextMenuAnnotation(Annotation1DItem *annot_item, bool &need_repaint)=0
Get a context menu (with lambda actions included) for this 1D layer, when a Annotation1DItem was righ...
Annotations1DContainer & getAnnotations(Size spectrum_index)
Returns a mutable reference to the annotations of the spectrum_index's spectrum (1D view)
Definition: LayerData1DBase.h:117
std::vector< QColor > peak_colors_1d
Peak colors of the currently shown spectrum.
Definition: LayerData1DBase.h:137
Class that stores the data for one layer.
Definition: LayerDataBase.h:195
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
Index of a peak or feature.
Definition: PeakIndex.h:51