libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
xicwidget.cpp
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/widget/xicwidget/xicwidget.h
3
* \date 12/1/2018
4
* \author Olivier Langella
5
* \brief plot a XIC
6
*/
7
8
9
/*******************************************************************************
10
* Copyright (c) 2018 Olivier Langella <Olivier.Langella@u-psud.fr>.
11
*
12
* This file is part of the PAPPSOms++ library.
13
*
14
* PAPPSOms++ is free software: you can redistribute it and/or modify
15
* it under the terms of the GNU General Public License as published by
16
* the Free Software Foundation, either version 3 of the License, or
17
* (at your option) any later version.
18
*
19
* PAPPSOms++ is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU General Public License for more details.
23
*
24
* You should have received a copy of the GNU General Public License
25
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
26
*
27
* Contributors:
28
* Olivier Langella <Olivier.Langella@u-psud.fr> - initial API and
29
*implementation
30
******************************************************************************/
31
32
33
#include "
xicwidget.h
"
34
#include <QDebug>
35
#include <QHBoxLayout>
36
#include "
qcpxic.h
"
37
#include "
pappsomspp/core/exception/exceptionnotfound.h
"
38
39
using namespace
pappso
;
40
41
XicWidget::XicWidget
(QWidget *parent) :
GraphicDeviceWidget
(parent)
42
{
43
qDebug() <<
"XicWidget::XicWidget begin"
;
44
45
46
this->setLayout(
new
QHBoxLayout(
this
));
47
48
setMinimumSize(200, 160);
49
this->layout()->setContentsMargins(0, 0, 0, 0);
50
51
_qcp_xic
=
new
QCPXic
(
this
);
52
this->layout()->addWidget(
_qcp_xic
);
53
qDebug() <<
"XicWidget::XicWidget end"
;
54
}
55
XicWidget::~XicWidget
()
56
{
57
}
58
59
void
60
XicWidget::addMsMsEvent
(
const
Xic
*xic_p,
pappso::pappso_double
rt)
61
{
62
XicCstSPtr
xic_sp =
getXicCstSPtr
(xic_p);
63
_qcp_xic
->addMsMsEvent(xic_p, rt);
64
_map_xic_msms_event
[xic_p] = rt;
65
}
66
QCPGraph *
67
XicWidget::addXicSp
(
XicCstSPtr
xic_sp)
68
{
69
_xic_sp_list
.push_back(xic_sp);
70
return
_qcp_xic
->addXicP(xic_sp.get());
71
}
72
73
const
QString &
74
XicWidget::getName
(
const
Xic
*xic_p)
const
75
{
76
XicCstSPtr
xic_sp =
getXicCstSPtr
(xic_p);
77
return
_map_xic_name
.at(xic_p);
78
}
79
80
void
81
XicWidget::setName
(
const
Xic
*xic_p,
const
QString &name)
82
{
83
XicCstSPtr
xic_sp =
getXicCstSPtr
(xic_p);
84
_qcp_xic
->legend->setVisible(
true
);
85
_qcp_xic
->setName(xic_p, name);
86
_map_xic_name
[xic_p] = name;
87
}
88
89
void
90
XicWidget::plot
()
91
{
92
_qcp_xic
->replot();
93
}
94
void
95
XicWidget::rescale
()
96
{
97
_qcp_xic
->xAxis->rescale(
true
);
98
_qcp_xic
->yAxis->rescale(
true
);
99
_qcp_xic
->rescale();
100
}
101
102
QCPAxis *
103
XicWidget::getRtAxisP
()
104
{
105
return
_qcp_xic
->xAxis;
106
}
107
108
QCPAxis *
109
XicWidget::getIntensityAxisP
()
110
{
111
return
_qcp_xic
->yAxis;
112
}
113
114
void
115
XicWidget::rescaleOneRange
(QString axis_name, QCPRange new_range)
116
{
117
if
(axis_name ==
"xAxis"
)
118
{
119
_qcp_xic
->xAxis->setRange(new_range);
120
}
121
else
// axis_name == "yAxis"
122
{
123
_qcp_xic
->yAxis->setRange(new_range);
124
}
125
_qcp_xic
->replot();
126
}
127
128
void
129
XicWidget::clear
()
130
{
131
_map_xic_name
.clear();
132
_xic_sp_list
.clear();
133
_xic_peak_sp_list
.clear();
134
_qcp_xic
->clear();
135
_map_xic_msms_event
.clear();
136
}
137
138
XicCstSPtr
139
XicWidget::getXicCstSPtr
(
const
Xic
*xic_p)
const
140
{
141
std::vector<XicCstSPtr>::const_iterator it =
142
std::find_if(
_xic_sp_list
.begin(),
_xic_sp_list
.end(), [xic_p](
XicCstSPtr
xic_sp) {
143
return xic_sp.get() == xic_p;
144
});
145
if
(it ==
_xic_sp_list
.end())
146
{
147
throw
pappso::ExceptionNotFound
(tr(
"ERROR : xic pointer not found"
));
148
}
149
return
*it;
150
}
151
152
void
153
XicWidget::addXicPeakList
(
const
Xic
*xic_p,
154
const
std::vector<pappso::TracePeakCstSPtr> &xic_peak_list)
155
{
156
XicCstSPtr
xic_sp =
getXicCstSPtr
(xic_p);
157
_qcp_xic
->addXicPeakList(xic_p, xic_peak_list);
158
for
(
const
pappso::TracePeakCstSPtr
&xic_peak : xic_peak_list)
159
{
160
_xic_peak_sp_list
.push_back(std::pair<XicCstSPtr, TracePeakCstSPtr>(xic_sp, xic_peak));
161
}
162
}
163
void
164
XicWidget::rtChangeEvent
(
pappso::pappso_double
rt)
const
165
{
166
emit
rtChanged
(rt);
167
168
std::vector<std::pair<XicCstSPtr, TracePeakCstSPtr>> over_xic_peak_list;
169
for
(std::pair<XicCstSPtr, TracePeakCstSPtr> pair_xic_peak :
_xic_peak_sp_list
)
170
{
171
if
(pair_xic_peak.second.get()->containsRt(rt))
172
{
173
over_xic_peak_list.push_back(pair_xic_peak);
174
}
175
}
176
177
// if (over_xic_peak_list.size() > 0) {
178
emit
xicPeakListChanged
(over_xic_peak_list);
179
//}
180
}
181
182
void
183
XicWidget::toQPaintDevice
(QPaintDevice *device,
const
QSize &size)
184
{
185
186
if
(
_qcp_xic
!=
nullptr
)
187
{
188
QCPPainter painter;
189
painter.begin(device);
190
_qcp_xic
->toPainter(&painter, size.width(), size.height());
191
painter.end();
192
}
193
}
194
195
196
void
197
XicWidget::setRetentionTimeInSeconds
()
198
{
199
_rt_in_seconds
=
true
;
200
_qcp_xic
->xAxis->setLabel(
"retention time (sec)"
);
201
replotAll
();
202
}
203
void
204
XicWidget::setRetentionTimeInMinutes
()
205
{
206
_rt_in_seconds
=
false
;
207
_qcp_xic
->xAxis->setLabel(
"retention time (min)"
);
208
replotAll
();
209
}
210
211
void
212
XicWidget::replotAll
()
213
{
214
_qcp_xic
->clear();
215
216
for
(
XicCstSPtr
xic_sp :
_xic_sp_list
)
217
{
218
_qcp_xic
->addXicP(xic_sp.get());
219
220
std::vector<TracePeakCstSPtr> xic_peak_list;
221
for
(
auto
xic_map_peak_list :
_xic_peak_sp_list
)
222
{
223
if
(xic_map_peak_list.first.get() == xic_sp.get())
224
xic_peak_list.push_back(xic_map_peak_list.second);
225
}
226
_qcp_xic
->addXicPeakList(xic_sp.get(), xic_peak_list);
227
}
228
for
(
auto
xic_name :
_map_xic_name
)
229
{
230
setName
(xic_name.first, xic_name.second);
231
}
232
for
(
auto
xic_msms :
_map_xic_msms_event
)
233
{
234
_qcp_xic
->addMsMsEvent(xic_msms.first, xic_msms.second);
235
}
236
237
rescale
();
238
_qcp_xic
->replot();
239
}
240
241
void
242
XicWidget::xicClickEvent
(
pappso::pappso_double
rt,
pappso::pappso_double
intensity)
const
243
{
244
emit
clicked
(rt, intensity);
245
}
246
247
248
void
249
XicWidget::drawXicPeakBorders
(
pappso::TracePeakCstSPtr
xic_peak)
250
{
251
XicCstSPtr
xic_sp;
252
for
(std::pair<XicCstSPtr, TracePeakCstSPtr> pair_xic_peak :
_xic_peak_sp_list
)
253
{
254
if
(pair_xic_peak.second.get() == xic_peak.get())
255
{
256
xic_sp = pair_xic_peak.first;
257
break
;
258
}
259
}
260
261
if
(xic_sp.get() !=
nullptr
)
262
{
263
264
unsigned
int
i = 0;
265
for
(
XicCstSPtr
xic_in_list :
_xic_sp_list
)
266
{
267
if
(xic_in_list.get() == xic_sp.get())
268
{
269
break
;
270
}
271
i++;
272
}
273
_qcp_xic
->drawXicPeakBorders(i, xic_sp.get(), xic_peak.get());
274
}
275
}
276
277
278
void
279
XicWidget::clearXicPeakBorders
()
280
{
281
_qcp_xic
->clearXicPeakBorders();
282
}
GraphicDeviceWidget::GraphicDeviceWidget
GraphicDeviceWidget(QWidget *parent)
Definition
graphicdevicewidget.cpp:35
pappso::ExceptionNotFound
Definition
exceptionnotfound.h:32
pappso::XicWidget::QCPXic
friend class QCPXic
Definition
xicwidget.h:89
pappso::XicWidget::rescale
void rescale()
Definition
xicwidget.cpp:95
pappso::XicWidget::toQPaintDevice
void toQPaintDevice(QPaintDevice *device, const QSize &size) override
Definition
xicwidget.cpp:183
pappso::XicWidget::addXicPeakList
void addXicPeakList(const Xic *xic_p, const std::vector< pappso::TracePeakCstSPtr > &xic_peak_list)
Definition
xicwidget.cpp:153
pappso::XicWidget::rtChanged
void rtChanged(double rt) const
announce the current retention time (under mouse) in seconds
pappso::XicWidget::getIntensityAxisP
QCPAxis * getIntensityAxisP()
Definition
xicwidget.cpp:109
pappso::XicWidget::_xic_sp_list
std::vector< XicCstSPtr > _xic_sp_list
Definition
xicwidget.h:102
pappso::XicWidget::clearXicPeakBorders
void clearXicPeakBorders()
Definition
xicwidget.cpp:279
pappso::XicWidget::~XicWidget
~XicWidget()
Definition
xicwidget.cpp:55
pappso::XicWidget::getXicCstSPtr
XicCstSPtr getXicCstSPtr(const Xic *xic_p) const
Definition
xicwidget.cpp:139
pappso::XicWidget::plot
void plot()
Definition
xicwidget.cpp:90
pappso::XicWidget::_xic_peak_sp_list
XicXicPeakPairList _xic_peak_sp_list
Definition
xicwidget.h:103
pappso::XicWidget::_map_xic_name
std::map< const Xic *, QString > _map_xic_name
Definition
xicwidget.h:100
pappso::XicWidget::replotAll
void replotAll()
Definition
xicwidget.cpp:212
pappso::XicWidget::XicWidget
XicWidget(QWidget *parent=0)
Definition
xicwidget.cpp:41
pappso::XicWidget::setRetentionTimeInMinutes
void setRetentionTimeInMinutes()
Definition
xicwidget.cpp:204
pappso::XicWidget::getName
const QString & getName(const Xic *xic_p) const
Definition
xicwidget.cpp:74
pappso::XicWidget::rtChangeEvent
void rtChangeEvent(pappso::pappso_double rt) const
Definition
xicwidget.cpp:164
pappso::XicWidget::addXicSp
QCPGraph * addXicSp(XicCstSPtr xic_sp)
Definition
xicwidget.cpp:67
pappso::XicWidget::_rt_in_seconds
bool _rt_in_seconds
Definition
xicwidget.h:97
pappso::XicWidget::_map_xic_msms_event
std::map< const Xic *, pappso::pappso_double > _map_xic_msms_event
Definition
xicwidget.h:101
pappso::XicWidget::getRtAxisP
QCPAxis * getRtAxisP()
get the plots axis and rescale one axis with the given range
Definition
xicwidget.cpp:103
pappso::XicWidget::xicPeakListChanged
void xicPeakListChanged(pappso::XicXicPeakPairList xic_peak_list) const
pappso::XicWidget::addMsMsEvent
void addMsMsEvent(const Xic *xic_p, pappso::pappso_double rt)
Definition
xicwidget.cpp:60
pappso::XicWidget::setName
void setName(const Xic *xic_p, const QString &name)
Definition
xicwidget.cpp:81
pappso::XicWidget::clicked
void clicked(double rt, double intensity) const
announce mouse position on click (rt in seconds, intensity)
pappso::XicWidget::rescaleOneRange
void rescaleOneRange(QString axis_name, QCPRange new_range)
Definition
xicwidget.cpp:115
pappso::XicWidget::drawXicPeakBorders
void drawXicPeakBorders(pappso::TracePeakCstSPtr xic_peak)
Definition
xicwidget.cpp:249
pappso::XicWidget::xicClickEvent
void xicClickEvent(pappso::pappso_double rt, pappso::pappso_double intensity) const
Definition
xicwidget.cpp:242
pappso::XicWidget::clear
void clear()
Definition
xicwidget.cpp:129
pappso::XicWidget::_qcp_xic
QCPXic * _qcp_xic
Definition
xicwidget.h:104
pappso::XicWidget::setRetentionTimeInSeconds
void setRetentionTimeInSeconds()
Definition
xicwidget.cpp:197
pappso::Xic
Definition
xic.h:44
exceptionnotfound.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::XicCstSPtr
std::shared_ptr< const Xic > XicCstSPtr
Definition
xic.h:38
pappso::pappso_double
double pappso_double
A type definition for doubles.
Definition
types.h:60
pappso::TracePeakCstSPtr
std::shared_ptr< const TracePeak > TracePeakCstSPtr
Definition
tracepeak.h:35
qcpxic.h
xicwidget.h
pappsomspp
gui
xicwidget
xicwidget.cpp
Generated on
for libpappsomspp by
1.17.0