libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
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
14
#include "
integrationscoperect.h
"
15
16
17
namespace
pappso
18
{
19
20
IntegrationScopeRect::IntegrationScopeRect
() :
IntegrationScope
()
21
{
22
// qDebug() << "Constructing" << this;
23
}
24
25
IntegrationScopeRect::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
33
IntegrationScopeRect::IntegrationScopeRect
(
const
QPointF &
point
,
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
46
IntegrationScopeRect::IntegrationScopeRect
(
const
IntegrationScopeRect
&other)
47
:
IntegrationScope
(other.
m_point
, other.
m_width
, other.
m_dataKindX
),
48
m_height
(other.
m_height
),
49
m_dataKindY
(other.
m_dataKindY
)
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
56
IntegrationScopeRect::~IntegrationScopeRect
()
57
{
58
// qDebug() << "Destructing" << this;
59
}
60
61
IntegrationScopeRect
*
62
IntegrationScopeRect::clone
()
const
63
{
64
return
new
IntegrationScopeRect
(*
this
);
65
}
66
67
IntegrationScopeRect
&
68
IntegrationScopeRect::operator=
(
const
IntegrationScopeRect
&other)
69
{
70
if
(
this
== &other)
71
return
*
this
;
72
73
IntegrationScope::operator=
(other);
74
75
m_height
= other.
m_height
;
76
77
m_dataKindX
= other.
m_dataKindX
;
78
m_dataKindY
= other.
m_dataKindY
;
79
80
return
*
this
;
81
}
82
83
IntegrationScopeFeatures
84
IntegrationScopeRect::getTopMostPoint
(QPointF &
point
)
const
85
{
86
point
= QPointF(
m_point
.x(),
m_point
.y() +
m_height
);
87
return
IntegrationScopeFeatures::SUCCESS
;
88
}
89
90
IntegrationScopeFeatures
91
IntegrationScopeRect::getBottomMostPoint
(QPointF &
point
)
const
92
{
93
point
=
m_point
;
94
return
IntegrationScopeFeatures::SUCCESS
;
95
}
96
97
void
98
IntegrationScopeRect::setHeight
(
double
height)
99
{
100
m_height
= height;
101
}
102
103
IntegrationScopeFeatures
104
IntegrationScopeRect::getHeight
(
double
&height)
const
105
{
106
height =
m_height
;
107
return
IntegrationScopeFeatures::SUCCESS
;
108
}
109
110
bool
111
IntegrationScopeRect::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
131
void
132
IntegrationScopeRect::setDataKindX
([[maybe_unused]]
Enums::DataKind
data_kind)
133
{
134
m_dataKindX
= data_kind;
135
}
136
137
void
138
IntegrationScopeRect::setDataKindY
([[maybe_unused]]
Enums::DataKind
data_kind)
139
{
140
m_dataKindY
= data_kind;
141
}
142
143
bool
144
IntegrationScopeRect::getDataKindX
([[maybe_unused]]
Enums::DataKind
&data_kind)
145
{
146
data_kind =
m_dataKindX
;
147
return
true
;
148
}
149
150
bool
151
IntegrationScopeRect::getDataKindY
([[maybe_unused]]
Enums::DataKind
&data_kind)
152
{
153
data_kind =
m_dataKindY
;
154
return
true
;
155
}
156
157
bool
158
IntegrationScopeRect::is1D
()
const
159
{
160
return
false
;
161
}
162
163
bool
164
IntegrationScopeRect::is2D
()
const
165
{
166
return
!
is1D
();
167
}
168
169
bool
170
IntegrationScopeRect::isRectangle
()
const
171
{
172
return
true
;
173
}
174
175
bool
176
IntegrationScopeRect::isRhomboid
()
const
177
{
178
return
false
;
179
}
180
181
bool
182
IntegrationScopeRect::transpose
()
183
{
184
Enums::DataKind
was_data_kind_y =
m_dataKindY
;
185
m_dataKindY
=
m_dataKindX
;
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
;
201
m_height
=
m_width
;
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
210
void
211
IntegrationScopeRect::update
(
const
QPointF &
point
,
double
width,
double
height)
212
{
213
IntegrationScope::m_point
=
point
;
214
IntegrationScope::m_width
= width;
215
m_height
= height;
216
}
217
218
bool
219
IntegrationScopeRect::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
225
QString
226
IntegrationScopeRect::toString
()
const
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
243
void
244
IntegrationScopeRect::reset
()
245
{
246
IntegrationScope::reset
();
247
248
m_height
= 0;
249
}
250
251
}
// namespace pappso
pappso::IntegrationScopeRect
Definition
integrationscoperect.h:45
pappso::IntegrationScopeRect::getBottomMostPoint
virtual IntegrationScopeFeatures getBottomMostPoint(QPointF &point) const override
Definition
integrationscoperect.cpp:91
pappso::IntegrationScopeRect::update
virtual void update(const QPointF &point, double width, double height)
Definition
integrationscoperect.cpp:211
pappso::IntegrationScopeRect::operator=
virtual IntegrationScopeRect & operator=(const IntegrationScopeRect &other)
Definition
integrationscoperect.cpp:68
pappso::IntegrationScopeRect::m_dataKindY
Enums::DataKind m_dataKindY
Definition
integrationscoperect.h:92
pappso::IntegrationScopeRect::m_height
double m_height
Definition
integrationscoperect.h:91
pappso::IntegrationScopeRect::isRectangle
virtual bool isRectangle() const override
Definition
integrationscoperect.cpp:170
pappso::IntegrationScopeRect::IntegrationScopeRect
IntegrationScopeRect()
Definition
integrationscoperect.cpp:20
pappso::IntegrationScopeRect::getHeight
virtual IntegrationScopeFeatures getHeight(double &height) const override
Definition
integrationscoperect.cpp:104
pappso::IntegrationScopeRect::toString
virtual QString toString() const override
Definition
integrationscoperect.cpp:226
pappso::IntegrationScopeRect::transpose
virtual bool transpose() override
Definition
integrationscoperect.cpp:182
pappso::IntegrationScopeRect::setDataKindY
virtual void setDataKindY(Enums::DataKind data_kind) override
Definition
integrationscoperect.cpp:138
pappso::IntegrationScopeRect::setDataKindX
virtual void setDataKindX(Enums::DataKind data_kind) override
Definition
integrationscoperect.cpp:132
pappso::IntegrationScopeRect::getDataKindX
virtual bool getDataKindX(Enums::DataKind &data_kind) override
Definition
integrationscoperect.cpp:144
pappso::IntegrationScopeRect::is2D
bool is2D() const override
Definition
integrationscoperect.cpp:164
pappso::IntegrationScopeRect::clone
virtual IntegrationScopeRect * clone() const
Definition
integrationscoperect.cpp:62
pappso::IntegrationScopeRect::range
virtual bool range(Enums::Axis axis, double &start, double &end) const override
Definition
integrationscoperect.cpp:111
pappso::IntegrationScopeRect::getTopMostPoint
virtual IntegrationScopeFeatures getTopMostPoint(QPointF &point) const override
Definition
integrationscoperect.cpp:84
pappso::IntegrationScopeRect::getDataKindY
virtual bool getDataKindY(Enums::DataKind &data_kind) override
Definition
integrationscoperect.cpp:151
pappso::IntegrationScopeRect::setHeight
virtual void setHeight(double height)
Definition
integrationscoperect.cpp:98
pappso::IntegrationScopeRect::contains
virtual bool contains(const QPointF &point) const override
Definition
integrationscoperect.cpp:219
pappso::IntegrationScopeRect::isRhomboid
virtual bool isRhomboid() const override
Definition
integrationscoperect.cpp:176
pappso::IntegrationScopeRect::is1D
bool is1D() const override
Definition
integrationscoperect.cpp:158
pappso::IntegrationScopeRect::~IntegrationScopeRect
virtual ~IntegrationScopeRect()
Definition
integrationscoperect.cpp:56
pappso::IntegrationScopeRect::reset
virtual void reset() override
Definition
integrationscoperect.cpp:244
pappso::IntegrationScope::m_dataKindX
Enums::DataKind m_dataKindX
Definition
integrationscope.h:94
pappso::IntegrationScope::point
QPointF point
Definition
integrationscope.h:39
pappso::IntegrationScope::IntegrationScope
WRITE setPoint() NOTIFY pointChanged() FINAL) Q_PROPERTY(double width READ getWidth() WRITE setWidth() NOTIFY widthChanged() FINAL) public IntegrationScope(const QPointF &point, double width)
Definition
integrationscope.cpp:26
pappso::IntegrationScope::m_width
double m_width
Definition
integrationscope.h:93
pappso::IntegrationScope::m_point
QPointF m_point
Definition
integrationscope.h:92
pappso::IntegrationScope::operator=
virtual IntegrationScope & operator=(const IntegrationScope &other)
Definition
integrationscope.cpp:65
pappso::IntegrationScope::reset
virtual void reset() override
Definition
integrationscope.cpp:210
integrationscoperect.h
pappso::Enums::DataKind
DataKind
Definition
types.h:238
pappso::Enums::Axis
Axis
Definition
types.h:246
pappso::Enums::Axis::y
@ y
Definition
types.h:249
pappso::Enums::Axis::x
@ x
Definition
types.h:248
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::IntegrationScopeFeatures
IntegrationScopeFeatures
Definition
integrationscopebase.h:47
pappso::SUCCESS
@ SUCCESS
Definition
integrationscopebase.h:51
pappsomspp
core
processing
combiners
integrationscoperect.cpp
Generated on
for libpappsomspp by
1.17.0