libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
integrationscopebase.h
Go to the documentation of this file.
1// Copyright 2021 Filippo Rusconi
2// GPLv3+
3
4#pragma once
5
6/////////////////////// StdLib includes
7#include <vector>
8#include <limits>
9
10/////////////////////// Qt includes
11#include <QString>
12#include <QPointF>
13
14
15/////////////////////// Local includes
16#include "../../exportinmportconfig.h"
17#include "../../types.h"
18
19
20namespace pappso
21{
22
23/*
24 Bitwise stuff (from StackOverflow)
25
26 It is sometimes worth using an enum to name the bits:
27
28 enum ThingFlags = {
29 ThingMask = 0x0000,
30 ThingFlag0 = 1 << 0,
31 ThingFlag1 = 1 << 1,
32 ThingError = 1 << 8,
33 }
34
35 Then use the names later on. I.e. write
36
37 thingstate |= ThingFlag1;
38 thingstate &= ~ThingFlag0;
39 if (thing & ThingError) {...}
40
41 to set, clear and test. This way you hide the magic numbers from the rest of
42 your code.
43 */
44
46{
47 // This one needs to be 0 because of (if!<function>() syntax)
48 FAILURE = 0x0000,
49 // As soon as not 0, success and potentially with more info.
50 SUCCESS = 1 << 1,
55 NOT_PRINTABLE = 1 << 6,
57};
58
59
61{
62 public:
65 virtual ~IntegrationScopeBase();
66
67 virtual bool getPoint(QPointF &point) const;
68 virtual bool getPoints(std::vector<QPointF> &points) const;
69
70 virtual IntegrationScopeFeatures getLeftMostPoint(QPointF &point) const;
72 getLeftMostPoints(std::vector<QPointF> &points) const;
73 virtual IntegrationScopeFeatures getLeftMostTopPoint(QPointF &point) const;
74 virtual IntegrationScopeFeatures getLeftMostBottomPoint(QPointF &point) const;
75
76 virtual IntegrationScopeFeatures getRightMostPoint(QPointF &point) const;
78 getRightMostPoints(std::vector<QPointF> &points) const;
79 virtual IntegrationScopeFeatures getRightMostTopPoint(QPointF &point) const;
81 getRightMostBottomPoint(QPointF &point) const;
82
83 virtual IntegrationScopeFeatures getTopMostPoint(QPointF &point) const;
85 getTopMostPoints(std::vector<QPointF> &points) const;
86 virtual IntegrationScopeFeatures getBottomMostPoint(QPointF &point) const;
88 getBottomMostPoints(std::vector<QPointF> &points) const;
89
90 virtual IntegrationScopeFeatures getRhombHorizontalSize(double &size) const;
91 virtual IntegrationScopeFeatures getRhombVerticalSize(double &size) const;
92
93 virtual IntegrationScopeFeatures getWidth(double &width) const;
94 virtual IntegrationScopeFeatures getHeight(double &height) const;
95
96 virtual bool range(Axis axis, double &start, double &end) const;
97
98 virtual void setDataKindX(DataKind data_kind);
99 virtual bool getDataKindX(DataKind &data_kind);
100
101 virtual void setDataKindY(DataKind data_kind);
102 virtual bool getDataKindY(DataKind &data_kind);
103
104 virtual bool is1D() const;
105 virtual bool is2D() const;
106
107 virtual bool isRectangle() const;
108 virtual bool isRhomboid() const;
109
110 virtual bool transpose();
111
112 virtual bool contains(const QPointF &point) const;
113
114 virtual QString toString() const;
115
116 virtual void reset();
117};
118
119typedef std::shared_ptr<IntegrationScopeBase> IntegrationScopeBaseSPtr;
120typedef std::shared_ptr<const IntegrationScopeBase> IntegrationScopeBaseCstSPtr;
121
123{
124
126 DataKind dataKind = DataKind::unset;
127
128 // NO specification of the axis because it is implicit that MZ is Y and the
129 // checked value is either DT or RT depending on dataKind.
130
132
134 DataKind data_kind)
135 : integrationScopeSPtr(integration_scope_sp), dataKind(data_kind)
136 {
137 }
138
140 : integrationScopeSPtr(other.integrationScopeSPtr), dataKind(other.dataKind)
141 {
142 }
143
146 {
147 if(this == &other)
148 return *this;
149
150 integrationScopeSPtr = other.integrationScopeSPtr;
151 dataKind = other.dataKind;
152
153 return *this;
154 }
155
156 QString
157 toString() const
158 {
159 QString text = "Integration scope spec:";
160 text += integrationScopeSPtr->toString();
161
162 text += " - data kind: ";
163
164 if(dataKind == DataKind::dt)
165 text += "dt.";
166 else if(dataKind == DataKind::mz)
167 text += "m/z.";
168 else if(dataKind == DataKind::rt)
169 text += "rt.";
170 else
171 text += "unset.";
172
173 return text;
174 }
175};
176
177typedef std::shared_ptr<IntegrationScopeSpec> IntegrationScopeSpecSPtr;
178typedef std::shared_ptr<const IntegrationScopeSpec> IntegrationScopeSpecCstSPtr;
179
180} // namespace pappso
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::shared_ptr< const IntegrationScopeSpec > IntegrationScopeSpecCstSPtr
std::shared_ptr< IntegrationScopeBase > IntegrationScopeBaseSPtr
std::shared_ptr< IntegrationScopeSpec > IntegrationScopeSpecSPtr
DataKind
Definition types.h:218
std::shared_ptr< const IntegrationScopeBase > IntegrationScopeBaseCstSPtr
IntegrationScopeSpec & operator=(const IntegrationScopeSpec &other)
IntegrationScopeSpec(const IntegrationScopeSpec &other)
IntegrationScopeBaseSPtr integrationScopeSPtr
IntegrationScopeSpec(IntegrationScopeBaseSPtr integration_scope_sp, DataKind data_kind)