libpappsomspp
Library for mass spectrometry
pappso::QCPXic Class Reference

#include <qcpxic.h>

Inheritance diagram for pappso::QCPXic:

Protected Member Functions

 QCPXic (XicWidget *parent)
 
 ~QCPXic ()
 
void clear ()
 
void rescale ()
 
QCPGraph * addXicP (const Xic *xic_p)
 
void addMsMsEvent (const Xic *xic_p, pappso::pappso_double rt)
 
void addXicPeakList (const Xic *xic_p, const std::vector< pappso::TracePeakCstSPtr > &xic_peak_list)
 
void setName (const Xic *xic_p, const QString &name)
 
void drawXicPeakBorders (unsigned int i, const Xic *xic_p, const pappso::TracePeak *p_xic_peak)
 
void clearXicPeakBorders ()
 
virtual void mouseMoveEvent (QMouseEvent *event) override
 
virtual void mousePressEvent (QMouseEvent *event) override
 
virtual void mouseReleaseEvent (QMouseEvent *event) override
 
virtual void keyPressEvent (QKeyEvent *event) override
 
virtual void keyReleaseEvent (QKeyEvent *event) override
 

Private Member Functions

Q_SLOT void setRtRangeChanged (QCPRange range)
 
pappso::pappso_double getRetentionTimeFromSecondsToLocal (pappso::pappso_double rt) const
 
pappso::pappso_double xAxisToSeconds (pappso::pappso_double rt) const
 

Private Attributes

XicWidget_parent
 
QCPRange _rt_range
 
QCPRange _intensity_range
 
bool _click = false
 
bool _mouse_move = false
 
bool _control_key = false
 
pappso::pappso_double _old_x
 
pappso::pappso_double _old_y
 
QCPItemTracer * _current_ms2_event = nullptr
 
std::map< const Xic *, QCPGraph * > _map_xic_graph
 
QColor _graph_color
 
std::vector< QColor > _colours
 
std::vector< QCPGraph * > _graph_peak_surface_list
 
std::vector< QCPItemTracer * > _graph_peak_border_list
 

Friends

class XicWidget
 

Detailed Description

Definition at line 40 of file qcpxic.h.

Constructor & Destructor Documentation

◆ QCPXic()

QCPXic::QCPXic ( XicWidget parent)
protected

Definition at line 38 of file qcpxic.cpp.

38  : QCustomPlot(parent)
39 {
40  qDebug() << "QCPXic::QCPXic begin";
41  _parent = parent;
42  setFocusPolicy(Qt::ClickFocus);
43 
45  {
46  xAxis->setLabel("retention time (sec)");
47  }
48  else
49  {
50  xAxis->setLabel("retention time (min)");
51  }
52 
53  yAxis->setLabel("intensity");
54  setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
55  axisRect()->setRangeDrag(Qt::Horizontal);
56  axisRect()->setRangeZoom(Qt::Horizontal);
57 
58  connect(this->xAxis,
59  SIGNAL(rangeChanged(QCPRange)),
60  this,
61  SLOT(setRtRangeChanged(QCPRange)));
62 
63  //
64  // http://tools.medialab.sciences-po.fr/iwanthue/
65  _colours = {QColor(197, 89, 110),
66  QColor(94, 185, 86),
67  QColor(132, 95, 203),
68  QColor(176, 175, 69),
69  QColor(202, 72, 160),
70  QColor(91, 126, 59),
71  QColor(193, 126, 189),
72  QColor(81, 183, 159),
73  QColor(210, 77, 58),
74  QColor(99, 137, 203),
75  QColor(223, 147, 71),
76  QColor(156, 105, 52)};
77 
78  qDebug() << "QCPXic::QCPXic end";
79 }
std::vector< QColor > _colours
Definition: qcpxic.h:88
Q_SLOT void setRtRangeChanged(QCPRange range)
Definition: qcpxic.cpp:258
XicWidget * _parent
Definition: qcpxic.h:77

References _colours, _parent, pappso::XicWidget::_rt_in_seconds, and setRtRangeChanged().

◆ ~QCPXic()

QCPXic::~QCPXic ( )
protected

Definition at line 80 of file qcpxic.cpp.

81 {
82 }

Member Function Documentation

◆ addMsMsEvent()

void QCPXic::addMsMsEvent ( const Xic xic_p,
pappso::pappso_double  rt 
)
protected

Definition at line 275 of file qcpxic.cpp.

276 {
277  _current_ms2_event = new QCPItemTracer(this);
278  // itemDemoPhaseTracer = phaseTracer; // so we can access it later in the
279  // bracketDataSlot for animation
280 
281  _current_ms2_event->setGraph(_map_xic_graph.at(xic_p));
283  _current_ms2_event->setInterpolating(true);
284  _current_ms2_event->setStyle(QCPItemTracer::tsCircle);
285  _current_ms2_event->setPen(QPen(Qt::red));
286  _current_ms2_event->setBrush(Qt::red);
287  _current_ms2_event->setSize(7);
288 
289  // addItem(_current_ms2_event);
290 }
std::map< const Xic *, QCPGraph * > _map_xic_graph
Definition: qcpxic.h:86
pappso::pappso_double getRetentionTimeFromSecondsToLocal(pappso::pappso_double rt) const
Definition: qcpxic.cpp:343
QCPItemTracer * _current_ms2_event
Definition: qcpxic.h:85

References _current_ms2_event, _map_xic_graph, getRetentionTimeFromSecondsToLocal(), and pappso::rt.

Referenced by pappso::XicWidget::addMsMsEvent(), and pappso::XicWidget::replotAll().

◆ addXicP()

QCPGraph * QCPXic::addXicP ( const Xic xic_p)
protected

Definition at line 219 of file qcpxic.cpp.

220 {
221 
222  _graph_color = _colours[(int)(_map_xic_graph.size() % _colours.size())];
223 
224  QCPGraph *graph_xic = addGraph();
225  graph_xic->setPen(QPen(_graph_color));
226  _map_xic_graph.insert(std::pair<const Xic *, QCPGraph *>(xic_p, graph_xic));
227  graph_xic->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 2.0));
228 
229  if(xic_p->size() > 0)
230  {
231  for(const DataPoint &element : *xic_p)
232  {
233  graph_xic->addData(getRetentionTimeFromSecondsToLocal(element.x),
234  element.y);
235  }
236  if(_rt_range.lower > getRetentionTimeFromSecondsToLocal(xic_p->front().x))
237  _rt_range.lower =
238  getRetentionTimeFromSecondsToLocal(xic_p->front().x) - 1;
239  if(_rt_range.upper < getRetentionTimeFromSecondsToLocal(xic_p->back().x))
240  _rt_range.upper =
241  getRetentionTimeFromSecondsToLocal(xic_p->back().x) + 1;
242  _intensity_range.lower = 0;
243  if(_intensity_range.upper < xic_p->maxYDataPoint().y)
244  _intensity_range.upper = xic_p->maxYDataPoint().y;
245  }
246 
247  return graph_xic;
248 }
QCPRange _rt_range
Definition: qcpxic.h:78
QCPRange _intensity_range
Definition: qcpxic.h:79
QColor _graph_color
Definition: qcpxic.h:87

References _colours, _graph_color, _intensity_range, _map_xic_graph, _rt_range, and getRetentionTimeFromSecondsToLocal().

Referenced by pappso::XicWidget::addXicSp(), and pappso::XicWidget::replotAll().

◆ addXicPeakList()

void QCPXic::addXicPeakList ( const Xic xic_p,
const std::vector< pappso::TracePeakCstSPtr > &  xic_peak_list 
)
protected

Definition at line 312 of file qcpxic.cpp.

314 {
315  for(const pappso::TracePeakCstSPtr &peak : xic_peak_list)
316  {
317  _graph_peak_surface_list.push_back(addGraph());
318  for(auto &xic_element : *(xic_p))
319  {
320  if(peak.get()->containsRt(xic_element.x))
321  {
322  _graph_peak_surface_list.back()->addData(
323  getRetentionTimeFromSecondsToLocal(xic_element.x),
324  xic_element.y);
325  }
326  }
327  // graph()->setData(rt_peak, intensity_peak);
328  _graph_peak_surface_list.back()->removeFromLegend();
329  _graph_peak_surface_list.back()->setChannelFillGraph(0);
330  _graph_peak_surface_list.back()->setLineStyle(
331  QCPGraph::LineStyle::lsLine);
332  QColor color = _colours[_graph_peak_surface_list.size() % 12];
333  color.setAlpha(0);
334  // QColor(0, 110, 110, 30)
335  _graph_peak_surface_list.back()->setPen(QPen(color));
336  color.setAlpha(40);
337  //_graph_peak_surface_list.back()->setScatterStyle(QCPScatterStyle::ssDot);
338  _graph_peak_surface_list.back()->setBrush(QBrush(color));
339  }
340 }
std::vector< QCPGraph * > _graph_peak_surface_list
Definition: qcpxic.h:89
std::shared_ptr< const TracePeak > TracePeakCstSPtr
Definition: tracepeak.h:34

References _colours, _graph_peak_surface_list, and getRetentionTimeFromSecondsToLocal().

Referenced by pappso::XicWidget::addXicPeakList(), and pappso::XicWidget::replotAll().

◆ clear()

void QCPXic::clear ( )
protected

Definition at line 301 of file qcpxic.cpp.

302 {
303  legend->clearItems();
304  _map_xic_graph.clear();
305  this->clearGraphs();
306  this->clearItems();
307  this->clearPlottables();
308 }

References _map_xic_graph.

Referenced by pappso::XicWidget::clear(), and pappso::XicWidget::replotAll().

◆ clearXicPeakBorders()

void QCPXic::clearXicPeakBorders ( )
protected

Definition at line 431 of file qcpxic.cpp.

432 {
433  for(QCPItemTracer *p_tracer : _graph_peak_border_list)
434  {
435  removeItem(p_tracer);
436  // delete p_tracer;
437  }
438  _graph_peak_border_list.clear();
439  replot();
440 }
std::vector< QCPItemTracer * > _graph_peak_border_list
Definition: qcpxic.h:90

References _graph_peak_border_list.

Referenced by pappso::XicWidget::clearXicPeakBorders().

◆ drawXicPeakBorders()

void QCPXic::drawXicPeakBorders ( unsigned int  i,
const Xic xic_p,
const pappso::TracePeak p_xic_peak 
)
protected

Definition at line 369 of file qcpxic.cpp.

372 {
373  QCPGraph *p_graph = _map_xic_graph.at(xic_p);
374  QColor color = _colours[i % 12];
375  // color.setAlpha(95);
376 
377  QCPItemTracer *p_peak_border_left = new QCPItemTracer(this);
378  // itemDemoPhaseTracer = phaseTracer; // so we can access it later in the
379  // bracketDataSlot for animation
380  QPen border_pen(color);
381  border_pen.setWidth(3);
382 
383  p_peak_border_left->setGraph(p_graph);
384  p_peak_border_left->setGraphKey(
386  p_peak_border_left->setInterpolating(true);
387  p_peak_border_left->setStyle(QCPItemTracer::tsPlus);
388  p_peak_border_left->setPen(border_pen);
389  p_peak_border_left->setBrush(color);
390  p_peak_border_left->setSize(30);
391 
392  _graph_peak_border_list.push_back(p_peak_border_left);
393 
394  // addItem(p_peak_border_left);
395 
396  QPen apex_pen(color);
397  apex_pen.setWidth(2);
398  p_peak_border_left = new QCPItemTracer(this);
399  p_peak_border_left->setGraph(_map_xic_graph.at(xic_p));
400  p_peak_border_left->setGraphKey(
402  p_peak_border_left->setInterpolating(true);
403  p_peak_border_left->setStyle(QCPItemTracer::tsPlus);
404  p_peak_border_left->setPen(apex_pen);
405  p_peak_border_left->setBrush(color);
406  p_peak_border_left->setSize(8);
407 
408  _graph_peak_border_list.push_back(p_peak_border_left);
409 
410  // addItem(p_peak_border_left);
411 
412 
413  p_peak_border_left = new QCPItemTracer(this);
414  p_peak_border_left->setGraph(_map_xic_graph.at(xic_p));
415  p_peak_border_left->setGraphKey(
417  p_peak_border_left->setInterpolating(true);
418  p_peak_border_left->setStyle(QCPItemTracer::tsPlus);
419  p_peak_border_left->setPen(border_pen);
420  p_peak_border_left->setBrush(color);
421  p_peak_border_left->setSize(30);
422 
423  _graph_peak_border_list.push_back(p_peak_border_left);
424 
425  // addItem(p_peak_border_left);
426 
427  replot();
428 }
DataPoint & getLeftBoundary()
Definition: tracepeak.cpp:93
DataPoint & getMaxXicElement()
Definition: tracepeak.cpp:83
DataPoint & getRightBoundary()
Definition: tracepeak.cpp:104
pappso_double x
Definition: datapoint.h:23

References _colours, _graph_peak_border_list, _map_xic_graph, pappso::TracePeak::getLeftBoundary(), pappso::TracePeak::getMaxXicElement(), getRetentionTimeFromSecondsToLocal(), pappso::TracePeak::getRightBoundary(), and pappso::DataPoint::x.

Referenced by pappso::XicWidget::drawXicPeakBorders().

◆ getRetentionTimeFromSecondsToLocal()

pappso::pappso_double QCPXic::getRetentionTimeFromSecondsToLocal ( pappso::pappso_double  rt) const
private

Definition at line 343 of file qcpxic.cpp.

344 {
346  {
347  return rt;
348  }
349  else
350  {
351  return (rt / (pappso::pappso_double)60);
352  }
353 }
double pappso_double
A type definition for doubles.
Definition: types.h:49
@ rt
Retention time.

References _parent, pappso::XicWidget::_rt_in_seconds, and pappso::rt.

Referenced by addMsMsEvent(), addXicP(), addXicPeakList(), and drawXicPeakBorders().

◆ keyPressEvent()

void QCPXic::keyPressEvent ( QKeyEvent *  event)
overrideprotectedvirtual

Definition at line 84 of file qcpxic.cpp.

85 {
86  if(event->key() == Qt::Key_Control)
87  {
88  _control_key = true;
89  }
90  qDebug() << "QCPXic::keyPressEvent end";
91 }
bool _control_key
Definition: qcpxic.h:82

References _control_key.

◆ keyReleaseEvent()

void QCPXic::keyReleaseEvent ( QKeyEvent *  event)
overrideprotectedvirtual

Definition at line 94 of file qcpxic.cpp.

95 {
96  if(event->key() == Qt::Key_Control)
97  {
98  _control_key = false;
99  }
100  qDebug() << "QCPXic::keyReleaseEvent end";
101 }

References _control_key.

◆ mouseMoveEvent()

void QCPXic::mouseMoveEvent ( QMouseEvent *  event)
overrideprotectedvirtual

Definition at line 152 of file qcpxic.cpp.

153 {
154  _mouse_move = true;
155 
156 #if QT_VERSION < 0x060000
157  pappso::pappso_double x = xAxis->pixelToCoord(event->x());
158 #else
159  pappso::pappso_double x = xAxis->pixelToCoord(event->position().x());
160 #endif
161  if(_click)
162  {
163 
164 #if QT_VERSION < 0x060000
165  qDebug() << "QCPXic::mouseMoveEvent begin "
166  << xAxis->pixelToCoord(event->x()) << " "
167  << yAxis->pixelToCoord(event->y());
168  pappso::pappso_double y = yAxis->pixelToCoord(event->y());
169 #else
170  qDebug() << "QCPXic::mouseMoveEvent begin "
171  << xAxis->pixelToCoord(event->position().x()) << " "
172  << yAxis->pixelToCoord(event->position().y());
173  pappso::pappso_double y = yAxis->pixelToCoord(event->position().y());
174 #endif
175  if(y < 0)
176  {
177  y = 0;
178  }
179  if(_control_key)
180  {
181  if(y > 0)
182  {
183  this->yAxis->scaleRange(_old_y / y, 0);
184  }
185  }
186  else
187  {
188 
189 #if QT_VERSION < 0x060000
190  this->xAxis->moveRange(xAxis->pixelToCoord(_old_x) -
191  xAxis->pixelToCoord(event->x()));
192 #else
193  this->xAxis->moveRange(xAxis->pixelToCoord(_old_x) -
194  xAxis->pixelToCoord(event->position().x()));
195 #endif
196  }
197 
198 #if QT_VERSION < 0x060000
199  _old_x = event->x();
200 #else
201  _old_x = event->position().x();
202 #endif
203  _old_y = y;
204  replot();
205  qDebug() << "QCPXic::mouseMoveEvent end";
206  }
207  else
208  {
209  if(_map_xic_graph.size() > 0)
210  {
211  // pappso::pappso_double mouse_mz_range = xAxis->pixelToCoord(10) -
212  // xAxis->pixelToCoord(5); getNearestPeakBetween(x, mouse_mz_range);
214  }
215  }
216 }
bool _click
Definition: qcpxic.h:80
bool _mouse_move
Definition: qcpxic.h:81
pappso::pappso_double _old_y
Definition: qcpxic.h:84
pappso::pappso_double xAxisToSeconds(pappso::pappso_double rt) const
Definition: qcpxic.cpp:356
pappso::pappso_double _old_x
Definition: qcpxic.h:83
void rtChangeEvent(pappso::pappso_double rt) const
Definition: xicwidget.cpp:165

References _click, _control_key, _map_xic_graph, _mouse_move, _old_x, _old_y, _parent, pappso::XicWidget::rtChangeEvent(), pappso::x, xAxisToSeconds(), and pappso::y.

◆ mousePressEvent()

void QCPXic::mousePressEvent ( QMouseEvent *  event)
overrideprotectedvirtual

Definition at line 104 of file qcpxic.cpp.

105 {
106  qDebug() << " begin ";
107  _mouse_move = false;
108  _click = true;
109 
110 #if QT_VERSION < 0x060000
111  _old_x = event->x();
112  _old_y = yAxis->pixelToCoord(event->y());
113 #else
114  _old_x = event->position().x();
115  _old_y = yAxis->pixelToCoord(event->position().y());
116 #endif
117  if(_old_y < 0)
118  {
119  _old_y = 0;
120  }
121  else
122  {
123  }
124  qDebug() << "QCPXic::mousePressEvent end";
125 }

References _click, _mouse_move, _old_x, and _old_y.

◆ mouseReleaseEvent()

void QCPXic::mouseReleaseEvent ( QMouseEvent *  event)
overrideprotectedvirtual

Definition at line 127 of file qcpxic.cpp.

128 {
129 
130 #if QT_VERSION < 0x060000
131  qDebug() << "QCPXic::mouseReleaseEvent begin "
132  << xAxis->pixelToCoord(event->x()) << " "
133  << yAxis->pixelToCoord(event->y());
134 #else
135  qDebug() << "QCPXic::mouseReleaseEvent begin "
136  << xAxis->pixelToCoord(event->position().x()) << " "
137  << yAxis->pixelToCoord(event->position().y());
138 #endif
139 
140  _click = false;
141  if(_mouse_move)
142  {
143  _mouse_move = false;
144  }
145  else
146  {
148  }
149  qDebug() << "QCPXic::mouseReleaseEvent end";
150 }
void xicClickEvent(pappso::pappso_double rt, pappso::pappso_double intensity) const
Definition: xicwidget.cpp:243

References _click, _mouse_move, _old_x, _old_y, _parent, xAxisToSeconds(), and pappso::XicWidget::xicClickEvent().

◆ rescale()

void QCPXic::rescale ( )
protected

Definition at line 252 of file qcpxic.cpp.

253 {
254 }

Referenced by pappso::XicWidget::rescale().

◆ setName()

void QCPXic::setName ( const Xic xic_p,
const QString &  name 
)
protected

Definition at line 293 of file qcpxic.cpp.

294 {
295  _map_xic_graph.at(xic_p)->addToLegend();
296  _map_xic_graph.at(xic_p)->setName(name);
297 }

References _map_xic_graph.

Referenced by pappso::XicWidget::setName().

◆ setRtRangeChanged()

void QCPXic::setRtRangeChanged ( QCPRange  range)
private

Definition at line 258 of file qcpxic.cpp.

259 {
260  qDebug() << "QCPXic::setMzRangeChanged _rt_range.lower" << _rt_range.lower;
261  if(range.lower < _rt_range.lower)
262  {
263  range.lower = _rt_range.lower;
264  }
265  if(range.upper > _rt_range.upper)
266  {
267  range.upper = _rt_range.upper;
268  }
269 
270  xAxis->setRange(range);
271 }

References _rt_range.

Referenced by QCPXic().

◆ xAxisToSeconds()

pappso::pappso_double QCPXic::xAxisToSeconds ( pappso::pappso_double  rt) const
private

Definition at line 356 of file qcpxic.cpp.

357 {
359  {
360  return rt;
361  }
362  else
363  {
364  return (rt * (pappso::pappso_double)60);
365  }
366 }

References _parent, pappso::XicWidget::_rt_in_seconds, and pappso::rt.

Referenced by mouseMoveEvent(), and mouseReleaseEvent().

Friends And Related Function Documentation

◆ XicWidget

friend class XicWidget
friend

Definition at line 44 of file qcpxic.h.

Member Data Documentation

◆ _click

bool pappso::QCPXic::_click = false
private

Definition at line 80 of file qcpxic.h.

Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

◆ _colours

std::vector<QColor> pappso::QCPXic::_colours
private

Definition at line 88 of file qcpxic.h.

Referenced by QCPXic(), addXicP(), addXicPeakList(), and drawXicPeakBorders().

◆ _control_key

bool pappso::QCPXic::_control_key = false
private

Definition at line 82 of file qcpxic.h.

Referenced by keyPressEvent(), keyReleaseEvent(), and mouseMoveEvent().

◆ _current_ms2_event

QCPItemTracer* pappso::QCPXic::_current_ms2_event = nullptr
private

Definition at line 85 of file qcpxic.h.

Referenced by addMsMsEvent().

◆ _graph_color

QColor pappso::QCPXic::_graph_color
private

Definition at line 87 of file qcpxic.h.

Referenced by addXicP().

◆ _graph_peak_border_list

std::vector<QCPItemTracer *> pappso::QCPXic::_graph_peak_border_list
private

Definition at line 90 of file qcpxic.h.

Referenced by clearXicPeakBorders(), and drawXicPeakBorders().

◆ _graph_peak_surface_list

std::vector<QCPGraph *> pappso::QCPXic::_graph_peak_surface_list
private

Definition at line 89 of file qcpxic.h.

Referenced by addXicPeakList().

◆ _intensity_range

QCPRange pappso::QCPXic::_intensity_range
private

Definition at line 79 of file qcpxic.h.

Referenced by addXicP().

◆ _map_xic_graph

std::map<const Xic *, QCPGraph *> pappso::QCPXic::_map_xic_graph
private

Definition at line 86 of file qcpxic.h.

Referenced by addMsMsEvent(), addXicP(), clear(), drawXicPeakBorders(), mouseMoveEvent(), and setName().

◆ _mouse_move

bool pappso::QCPXic::_mouse_move = false
private

Definition at line 81 of file qcpxic.h.

Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

◆ _old_x

pappso::pappso_double pappso::QCPXic::_old_x
private

Definition at line 83 of file qcpxic.h.

Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

◆ _old_y

pappso::pappso_double pappso::QCPXic::_old_y
private

Definition at line 84 of file qcpxic.h.

Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

◆ _parent

XicWidget* pappso::QCPXic::_parent
private

◆ _rt_range

QCPRange pappso::QCPXic::_rt_range
private

Definition at line 78 of file qcpxic.h.

Referenced by addXicP(), and setRtRangeChanged().


The documentation for this class was generated from the following files: