libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
integrationscoperect.cpp
Go to the documentation of this file.
1// Copyright 2021 Filippo Rusconi
2// GPLv3+
3
4
5/////////////////////// StdLib includes
6#include <limits>
7#include <cmath>
8
9
10/////////////////////// Qt includes
11#include <QDebug>
12
13
14/////////////////////// Local includes
16
17
18namespace pappso
19{
20
22{
23 // qDebug() << "Constructing" << this;
24}
25
27 double width,
28 double height)
29 : IntegrationScope(point, width), m_height(height)
30{
31 // qDebug() << "Constructing" << this << "point:" << point << "width:" << width
32 // << "height:" << height;
33}
34
35
37 double width,
38 DataKind data_kind_x,
39 double height,
40 DataKind data_kind_y)
41 : IntegrationScope(point, width, data_kind_x),
42 m_height(height),
43 m_dataKindY(data_kind_y)
44{
45 // qDebug() << "Constructing" << this << "point:" << point << "width:" << width
46 // << "height:" << height
47 // << "data_kind_x:" << static_cast<int>(data_kind_x)
48 // << "data_kind_y:" << static_cast<int>(data_kind_y);
49}
50
52 : IntegrationScope(other.m_point, other.m_width, other.m_dataKindX),
53 m_height(other.m_height),
54 m_dataKindY(other.m_dataKindY)
55{
56 // qDebug() << "Constructing" << this << "point:" << point << "width:" << width
57 // << "height:" << height
58 // << "data_kind_x:" << static_cast<int>(data_kind_x)
59 // << "data_kind_y:" << static_cast<int>(data_kind_y);
60 }
61
63{
64 // qDebug() << "Destructing" << this;
65}
66
69{
70 if(this == &other)
71 return *this;
72
74
75 m_height = other.m_height;
76
79
80 return *this;
81}
82
85{
86 point = QPointF(m_point.x(), m_point.y() + m_height);
88}
89
92{
93 point = m_point;
95}
96
97void
99{
100 m_height = height;
101}
102
105{
106 height = m_height;
108}
109
110bool
111IntegrationScopeRect::range(Axis axis, double &start, double &end) const
112{
113 if(axis == Axis::x)
114 {
115 start = m_point.x();
116 end = start + m_width;
117
118 return true;
119 }
120 else if(axis == Axis::y)
121 {
122 start = m_point.y();
123 end = start + m_height;
124
125 return true;
126 }
127
128 return false;
129}
130
131void
133{
134 m_dataKindX = data_kind;
135}
136
137void
139{
140 m_dataKindY = data_kind;
141}
142
143bool
145{
146 data_kind = m_dataKindX;
147 return true;
148}
149
150bool
152{
153 data_kind = m_dataKindY;
154 return true;
155}
156
157bool
159{
160 return false;
161}
162
163bool
165{
166 return !is1D();
167}
168
169bool
171{
172 return true;
173}
174
175bool
177{
178 return false;
179}
180
181bool
183{
184 DataKind was_data_kind_y = m_dataKindY;
186 m_dataKindX = was_data_kind_y;
187
188 // qDebug() << "Point before rectangle transposition:" << m_point;
189
190 // Transpose the point.
191 QPointF transposed_point(m_point.y(), m_point.x());
192 m_point = transposed_point;
193
194 //qDebug() << "Point after rectangle transposition:" << m_point;
195
196 // qDebug() << "Before transposition: width is" << m_width << "and height is"
197 // << m_height;
198
199 // Tranpose width <--> height
200 double was_height = m_height;
202 m_width = was_height;
203
204 // qDebug() << "After transposition: width is" << m_width << "and height is"
205 // << m_height;
206
207 return true;
208}
209
210void
211IntegrationScopeRect::update(const QPointF &point, double width, double height)
212{
215 m_height = height;
216}
217
218bool
219IntegrationScopeRect::contains(const QPointF &point) const
220{
221 return (point.x() >= m_point.x() && point.x() <= m_point.x() + m_width &&
222 point.y() >= m_point.y() && point.y() <= m_point.y() + m_height);
223}
224
225QString
227{
228 QString text = "[";
229
230 text.append(QString("(%1, %2)")
231 .arg(m_point.x(), 0, 'f', 3)
232 .arg(m_point.y(), 0, 'f', 3));
233
234 text.append("->");
235
236 text.append(QString("(%1, %2)")
237 .arg(m_point.x() + m_width, 0, 'f', 3)
238 .arg(m_point.y() + m_height, 0, 'f', 3));
239
240 text.append("]");
241
242 return text;
243}
244
245void
252
253} // namespace pappso
virtual IntegrationScopeFeatures getBottomMostPoint(QPointF &point) const override
virtual void setDataKindX(DataKind data_kind) override
virtual void update(const QPointF &point, double width, double height)
virtual IntegrationScopeRect & operator=(const IntegrationScopeRect &other)
virtual bool isRectangle() const override
virtual bool getDataKindX(DataKind &data_kind) override
virtual IntegrationScopeFeatures getHeight(double &height) const override
virtual QString toString() const override
virtual IntegrationScopeFeatures getTopMostPoint(QPointF &point) const override
virtual void setDataKindY(DataKind data_kind) override
virtual void setHeight(double height)
virtual bool contains(const QPointF &point) const override
virtual bool isRhomboid() const override
virtual bool getDataKindY(DataKind &data_kind) override
virtual bool range(Axis axis, double &start, double &end) const override
virtual IntegrationScope & operator=(const IntegrationScope &other)
virtual void reset() override
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
DataKind
Definition types.h:215