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 <cmath>
7
8
9/////////////////////// Qt includes
10#include <QDebug>
11
12
13/////////////////////// Local includes
15
16
17namespace pappso
18{
19
21{
22 // qDebug() << "Constructing" << this;
23}
24
25IntegrationScopeRect::IntegrationScopeRect(const QPointF &point, double width, double height)
26 : IntegrationScope(point, width), m_height(height)
27{
28 // qDebug() << "Constructing" << this << "point:" << point << "width:" << width
29 // << "height:" << height;
30}
31
32
34 double width,
35 Enums::DataKind data_kind_x,
36 double height,
37 Enums::DataKind data_kind_y)
38 : IntegrationScope(point, width, data_kind_x), m_height(height), m_dataKindY(data_kind_y)
39{
40 // qDebug() << "Constructing" << this << "point:" << point << "width:" << width
41 // << "height:" << height
42 // << "data_kind_x:" << static_cast<int>(data_kind_x)
43 // << "data_kind_y:" << static_cast<int>(data_kind_y);
44}
45
47 : IntegrationScope(other.m_point, other.m_width, other.m_dataKindX),
48 m_height(other.m_height),
50{
51 //qDebug() << "Copy constructing" << this << "point:" << m_point << "width:" << m_width
52 //<< "height:" << m_height << "data_kind_x:" << static_cast<int>(m_dataKindX)
53 //<< "data_kind_y:" << static_cast<int>(m_dataKindY);
54}
55
57{
58 // qDebug() << "Destructing" << this;
59}
60
63{
64 return new IntegrationScopeRect(*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
89
96
97void
99{
100 m_height = height;
101}
102
105{
106 height = m_height;
108}
109
110bool
111IntegrationScopeRect::range(Enums::Axis axis, double &start, double &end) const
112{
113 if(axis == Enums::Axis::x)
114 {
115 start = m_point.x();
116 end = start + m_width;
117
118 return true;
119 }
120 else if(axis == Enums::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 Enums::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
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)").arg(m_point.x(), 0, 'f', 3).arg(m_point.y(), 0, 'f', 3));
231
232 text.append("->");
233
234 text.append(QString("(%1, %2)")
235 .arg(m_point.x() + m_width, 0, 'f', 3)
236 .arg(m_point.y() + m_height, 0, 'f', 3));
237
238 text.append("]");
239
240 return text;
241}
242
243void
250
251} // namespace pappso
virtual IntegrationScopeFeatures getBottomMostPoint(QPointF &point) const override
virtual void update(const QPointF &point, double width, double height)
virtual IntegrationScopeRect & operator=(const IntegrationScopeRect &other)
virtual bool isRectangle() const override
virtual IntegrationScopeFeatures getHeight(double &height) const override
virtual QString toString() const override
virtual void setDataKindY(Enums::DataKind data_kind) override
virtual void setDataKindX(Enums::DataKind data_kind) override
virtual bool getDataKindX(Enums::DataKind &data_kind) override
virtual IntegrationScopeRect * clone() const
virtual bool range(Enums::Axis axis, double &start, double &end) const override
virtual IntegrationScopeFeatures getTopMostPoint(QPointF &point) const override
virtual bool getDataKindY(Enums::DataKind &data_kind) override
virtual void setHeight(double height)
virtual bool contains(const QPointF &point) const override
virtual bool isRhomboid() const override
WRITE setPoint() NOTIFY pointChanged() FINAL) Q_PROPERTY(double width READ getWidth() WRITE setWidth() NOTIFY widthChanged() FINAL) public IntegrationScope(const QPointF &point, double width)
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