libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
selectionpolygon.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 "
pappsomspp/export-import-config.h
"
17
#include "
../../types.h
"
18
19
namespace
pappso
20
{
21
22
23
enum class
PointSpec
24
{
25
// Starting top left and then clockwise
26
TOP_LEFT_POINT
= 0,
27
TOP_RIGHT_POINT
= 1,
28
BOTTOM_RIGHT_POINT
= 2,
29
BOTTOM_LEFT_POINT
= 3,
30
ENUM_LAST
= 4,
31
};
32
33
34
enum class
DataDimension
35
{
36
NOT_SET
= 0,
37
HORIZONTAL
,
38
VERTICAL
39
};
40
41
42
43
class
PMSPP_LIB_DECL
SelectionPolygon
44
{
45
public
:
46
// Constructor with no arguments
47
SelectionPolygon
();
48
49
SelectionPolygon
(QPointF top_left_point, QPointF top_right_point);
50
51
SelectionPolygon
(QPointF top_left_point,
52
QPointF top_right_point,
53
QPointF bottom_right_point,
54
QPointF bottom_left_point);
55
56
SelectionPolygon
(
const
SelectionPolygon
&other);
57
58
virtual
~SelectionPolygon
();
59
60
61
void
setPoint
(
PointSpec
point_spec,
double
x
,
double
y
);
62
void
setPoint
(
PointSpec
point_spec, QPointF point);
63
void
copyPoint
(
PointSpec
point_spec_src,
PointSpec
point_spec_dest);
64
65
void
set1D
(
double
x_range_start,
double
x_range_end);
66
void
set2D
(QPointF top_left,
67
QPointF top_right,
68
QPointF bottom_right,
69
QPointF bottom_left);
70
void
convertTo1D
();
71
72
const
std::vector<QPointF> &
getPoints
()
const
;
73
74
QPointF
getLeftMostPoint
()
const
;
75
QPointF
getRightMostPoint
()
const
;
76
QPointF
getTopMostPoint
()
const
;
77
QPointF
getBottomMostPoint
()
const
;
78
79
QPointF
getPoint
(
PointSpec
point_spec)
const
;
80
81
bool
computeMinMaxCoordinates
();
82
bool
computeMinMaxCoordinates
(
double
&min_x,
83
double
&max_x,
84
double
&min_y,
85
double
&max_y)
const
;
86
87
double
width
(
bool
&ok)
const
;
88
double
height
(
bool
&ok)
const
;
89
90
bool
rangeX
(
double
&range_start,
double
&range_end)
const
;
91
bool
rangeY
(
double
&range_start,
double
&range_end)
const
;
92
bool
range
(
Enums::Axis
axis,
double
&range_start,
double
&range_end)
const
;
93
94
SelectionPolygon
transpose
()
const
;
95
96
bool
contains
(
const
QPointF &tested_point)
const
;
97
bool
contains
(
const
SelectionPolygon
&selection_polygon)
const
;
98
99
SelectionPolygon
&
operator=
(
const
SelectionPolygon
&other);
100
101
void
resetPoints
();
102
103
bool
is1D
()
const
;
104
bool
is2D
()
const
;
105
bool
isRectangle
()
const
;
106
107
QString
toShort4PointsString
()
const
;
108
QString
toString
()
const
;
109
110
111
static
void
debugAlgorithm
(
const
SelectionPolygon
&selection_polygon,
112
const
QPointF &tested_point);
113
114
protected
:
115
// The PointSpec enum and the setPoint function ensure that there are no more
116
// than four points in the vector.
117
118
// We want to create a largest polygon possible, by settting the first point,
119
// top_left on the lowest_x and highest_y, the top_right on the highest_x and
120
// highest_y, the bottom_right on the highest_x and lowest_y, the bottom_left
121
// at the lowest_x and lowest_y.
122
std::vector<QPointF>
m_points
= {QPointF(std::numeric_limits<double>::min(),
123
std::numeric_limits<double>::max()),
124
QPointF(std::numeric_limits<double>::max(),
125
std::numeric_limits<double>::max()),
126
QPointF(std::numeric_limits<double>::max(),
127
std::numeric_limits<double>::min()),
128
QPointF(std::numeric_limits<double>::min(),
129
std::numeric_limits<double>::min())};
130
131
double
m_minX
= std::numeric_limits<double>::min();
132
double
m_minY
= std::numeric_limits<double>::min();
133
134
double
m_maxX
= std::numeric_limits<double>::max();
135
double
m_maxY
= std::numeric_limits<double>::max();
136
};
137
138
139
struct
PMSPP_LIB_DECL
SelectionPolygonSpec
140
{
141
142
SelectionPolygon
selectionPolygon
;
143
Enums::DataKind
dataKind
=
Enums::DataKind::unset
;
144
145
// NO specification of the axis because it is implicit that MZ is Y and the
146
// checked value is either DT or RT depending on dataKind.
147
148
SelectionPolygonSpec
();
149
150
SelectionPolygonSpec
(
const
SelectionPolygon
&selection_polygon,
151
Enums::DataKind
data_kind)
152
:
selectionPolygon
(selection_polygon),
dataKind
(data_kind)
153
{
154
}
155
156
SelectionPolygonSpec
(
const
SelectionPolygonSpec
&other)
157
:
selectionPolygon
(other.
selectionPolygon
),
dataKind
(other.
dataKind
)
158
{
159
}
160
161
SelectionPolygonSpec
&
162
operator=
(
const
SelectionPolygonSpec
&other)
163
{
164
if
(
this
== &other)
165
return
*
this
;
166
167
selectionPolygon
= other.
selectionPolygon
;
168
dataKind
= other.
dataKind
;
169
170
return
*
this
;
171
}
172
173
174
QString
175
toString
()
const
176
{
177
QString text =
"Selection polygon spec:"
;
178
text +=
selectionPolygon
.toString();
179
180
text +=
" - data kind: "
;
181
182
if
(
dataKind
==
Enums::DataKind::dt
)
183
text +=
"dt."
;
184
else
if
(
dataKind
==
Enums::DataKind::mz
)
185
text +=
"m/z."
;
186
else
if
(
dataKind
==
Enums::DataKind::rt
)
187
text +=
"rt."
;
188
else
189
text +=
"unset."
;
190
191
return
text;
192
}
193
};
194
195
196
}
// namespace pappso
pappso::SelectionPolygon
Definition
selectionpolygon.h:44
pappso::SelectionPolygon::range
bool range(Enums::Axis axis, double &range_start, double &range_end) const
Definition
selectionpolygon.cpp:417
pappso::SelectionPolygon::rangeX
bool rangeX(double &range_start, double &range_end) const
Definition
selectionpolygon.cpp:397
pappso::SelectionPolygon::m_maxY
double m_maxY
Definition
selectionpolygon.h:135
pappso::SelectionPolygon::rangeY
bool rangeY(double &range_start, double &range_end) const
Definition
selectionpolygon.cpp:407
pappso::SelectionPolygon::debugAlgorithm
static void debugAlgorithm(const SelectionPolygon &selection_polygon, const QPointF &tested_point)
Definition
selectionpolygon.cpp:813
pappso::SelectionPolygon::is1D
bool is1D() const
Definition
selectionpolygon.cpp:616
pappso::SelectionPolygon::transpose
SelectionPolygon transpose() const
Definition
selectionpolygon.cpp:442
pappso::SelectionPolygon::toShort4PointsString
QString toShort4PointsString() const
Definition
selectionpolygon.cpp:762
pappso::SelectionPolygon::setPoint
void setPoint(PointSpec point_spec, double x, double y)
Definition
selectionpolygon.cpp:113
pappso::SelectionPolygon::m_minY
double m_minY
Definition
selectionpolygon.h:132
pappso::SelectionPolygon::getTopMostPoint
QPointF getTopMostPoint() const
Definition
selectionpolygon.cpp:259
pappso::SelectionPolygon::getRightMostPoint
QPointF getRightMostPoint() const
Definition
selectionpolygon.cpp:239
pappso::SelectionPolygon::set2D
void set2D(QPointF top_left, QPointF top_right, QPointF bottom_right, QPointF bottom_left)
Definition
selectionpolygon.cpp:174
pappso::SelectionPolygon::computeMinMaxCoordinates
bool computeMinMaxCoordinates()
Definition
selectionpolygon.cpp:313
pappso::SelectionPolygon::m_maxX
double m_maxX
Definition
selectionpolygon.h:134
pappso::SelectionPolygon::getPoints
const std::vector< QPointF > & getPoints() const
Definition
selectionpolygon.cpp:299
pappso::SelectionPolygon::copyPoint
void copyPoint(PointSpec point_spec_src, PointSpec point_spec_dest)
Definition
selectionpolygon.cpp:132
pappso::SelectionPolygon::m_minX
double m_minX
Definition
selectionpolygon.h:131
pappso::SelectionPolygon::is2D
bool is2D() const
Definition
selectionpolygon.cpp:643
pappso::SelectionPolygon::width
double width(bool &ok) const
Definition
selectionpolygon.cpp:367
pappso::SelectionPolygon::getLeftMostPoint
QPointF getLeftMostPoint() const
Definition
selectionpolygon.cpp:219
pappso::SelectionPolygon::operator=
SelectionPolygon & operator=(const SelectionPolygon &other)
Definition
selectionpolygon.cpp:578
pappso::SelectionPolygon::getBottomMostPoint
QPointF getBottomMostPoint() const
Definition
selectionpolygon.cpp:279
pappso::SelectionPolygon::set1D
void set1D(double x_range_start, double x_range_end)
Definition
selectionpolygon.cpp:142
pappso::SelectionPolygon::convertTo1D
void convertTo1D()
Definition
selectionpolygon.cpp:206
pappso::SelectionPolygon::isRectangle
bool isRectangle() const
Definition
selectionpolygon.cpp:668
pappso::SelectionPolygon::resetPoints
void resetPoints()
Definition
selectionpolygon.cpp:603
pappso::SelectionPolygon::getPoint
QPointF getPoint(PointSpec point_spec) const
Definition
selectionpolygon.cpp:306
pappso::SelectionPolygon::height
double height(bool &ok) const
Definition
selectionpolygon.cpp:382
pappso::SelectionPolygon::contains
bool contains(const QPointF &tested_point) const
Definition
selectionpolygon.cpp:476
pappso::SelectionPolygon::SelectionPolygon
SelectionPolygon()
Definition
selectionpolygon.cpp:21
pappso::SelectionPolygon::toString
QString toString() const
Definition
selectionpolygon.cpp:707
pappso::SelectionPolygon::m_points
std::vector< QPointF > m_points
Definition
selectionpolygon.h:122
export-import-config.h
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition
export-import-config.h:14
pappso::Enums::DataKind
DataKind
Definition
types.h:238
pappso::Enums::DataKind::dt
@ dt
Drift time.
Definition
types.h:241
pappso::Enums::DataKind::mz
@ mz
m/z
Definition
types.h:242
pappso::Enums::DataKind::rt
@ rt
Retention time.
Definition
types.h:240
pappso::Enums::DataKind::unset
@ unset
not set
Definition
types.h:239
pappso::Enums::Axis
Axis
Definition
types.h:246
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::PeptideIonCter::y
@ y
Definition
peptide.h:87
pappso::PeptideIonCter::x
@ x
Definition
peptide.h:92
pappso::DataDimension
DataDimension
Definition
selectionpolygon.h:35
pappso::DataDimension::NOT_SET
@ NOT_SET
Definition
selectionpolygon.h:36
pappso::DataDimension::VERTICAL
@ VERTICAL
Definition
selectionpolygon.h:38
pappso::DataDimension::HORIZONTAL
@ HORIZONTAL
Definition
selectionpolygon.h:37
pappso::PointSpec
PointSpec
Definition
selectionpolygon.h:24
pappso::PointSpec::BOTTOM_RIGHT_POINT
@ BOTTOM_RIGHT_POINT
Definition
selectionpolygon.h:28
pappso::PointSpec::TOP_LEFT_POINT
@ TOP_LEFT_POINT
Definition
selectionpolygon.h:26
pappso::PointSpec::BOTTOM_LEFT_POINT
@ BOTTOM_LEFT_POINT
Definition
selectionpolygon.h:29
pappso::PointSpec::ENUM_LAST
@ ENUM_LAST
Definition
selectionpolygon.h:30
pappso::PointSpec::TOP_RIGHT_POINT
@ TOP_RIGHT_POINT
Definition
selectionpolygon.h:27
pappso::SelectionPolygonSpec
Definition
selectionpolygon.h:140
pappso::SelectionPolygonSpec::SelectionPolygonSpec
SelectionPolygonSpec(const SelectionPolygonSpec &other)
Definition
selectionpolygon.h:156
pappso::SelectionPolygonSpec::operator=
SelectionPolygonSpec & operator=(const SelectionPolygonSpec &other)
Definition
selectionpolygon.h:162
pappso::SelectionPolygonSpec::dataKind
Enums::DataKind dataKind
Definition
selectionpolygon.h:143
pappso::SelectionPolygonSpec::SelectionPolygonSpec
SelectionPolygonSpec(const SelectionPolygon &selection_polygon, Enums::DataKind data_kind)
Definition
selectionpolygon.h:150
pappso::SelectionPolygonSpec::selectionPolygon
SelectionPolygon selectionPolygon
Definition
selectionpolygon.h:142
pappso::SelectionPolygonSpec::toString
QString toString() const
Definition
selectionpolygon.h:175
pappso::SelectionPolygonSpec::SelectionPolygonSpec
SelectionPolygonSpec()
types.h
pappsomspp
core
processing
combiners
selectionpolygon.h
Generated on
for libpappsomspp by
1.17.0