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() << "Constructing" << this << "point:" << point << "width:" << width
52 // << "height:" << height
53 // << "data_kind_x:" << static_cast<int>(data_kind_x)
54 // << "data_kind_y:" << static_cast<int>(data_kind_y);
55}
56
58{
59 // qDebug() << "Destructing" << this;
60}
61
64{
65 if(this == &other)
66 return *this;
67
69
70 m_height = other.m_height;
71
74
75 return *this;
76}
77
84
91
92void
94{
95 m_height = height;
96}
97
100{
101 height = m_height;
103}
104
105bool
106IntegrationScopeRect::range(Enums::Axis axis, double &start, double &end) const
107{
108 if(axis == Enums::Axis::x)
109 {
110 start = m_point.x();
111 end = start + m_width;
112
113 return true;
114 }
115 else if(axis == Enums::Axis::y)
116 {
117 start = m_point.y();
118 end = start + m_height;
119
120 return true;
121 }
122
123 return false;
124}
125
126void
128{
129 m_dataKindX = data_kind;
130}
131
132void
134{
135 m_dataKindY = data_kind;
136}
137
138bool
140{
141 data_kind = m_dataKindX;
142 return true;
143}
144
145bool
147{
148 data_kind = m_dataKindY;
149 return true;
150}
151
152bool
154{
155 return false;
156}
157
158bool
160{
161 return !is1D();
162}
163
164bool
166{
167 return true;
168}
169
170bool
172{
173 return false;
174}
175
176bool
178{
179 Enums::DataKind was_data_kind_y = m_dataKindY;
181 m_dataKindX = was_data_kind_y;
182
183 // qDebug() << "Point before rectangle transposition:" << m_point;
184
185 // Transpose the point.
186 QPointF transposed_point(m_point.y(), m_point.x());
187 m_point = transposed_point;
188
189 // qDebug() << "Point after rectangle transposition:" << m_point;
190
191 // qDebug() << "Before transposition: width is" << m_width << "and height is"
192 // << m_height;
193
194 // Tranpose width <--> height
195 double was_height = m_height;
197 m_width = was_height;
198
199 // qDebug() << "After transposition: width is" << m_width << "and height is"
200 // << m_height;
201
202 return true;
203}
204
205void
206IntegrationScopeRect::update(const QPointF &point, double width, double height)
207{
210 m_height = height;
211}
212
213bool
215{
216 return (point.x() >= m_point.x() && point.x() <= m_point.x() + m_width &&
217 point.y() >= m_point.y() && point.y() <= m_point.y() + m_height);
218}
219
220QString
222{
223 QString text = "[";
224
225 text.append(QString("(%1, %2)").arg(m_point.x(), 0, 'f', 3).arg(m_point.y(), 0, 'f', 3));
226
227 text.append("->");
228
229 text.append(QString("(%1, %2)")
230 .arg(m_point.x() + m_width, 0, 'f', 3)
231 .arg(m_point.y() + m_height, 0, 'f', 3));
232
233 text.append("]");
234
235 return text;
236}
237
238void
245
246} // 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 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
virtual IntegrationScope & operator=(const IntegrationScope &other)
WRITE setPoint() NOTIFY pointChanged() FINAL) Q_PROPERTY(double width READ getWidth() WRITE setWidth() NOTIFY widthChanged() FINAL) public IntegrationScope(const QPointF &point, double width, QObject *parent_p=nullptr)
virtual void reset() override
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39