MNE-CPP  0.1.9
A Framework for Electrophysiology
rtfiffrawviewdelegate.cpp
Go to the documentation of this file.
1 //=============================================================================================================
38 //=============================================================================================================
39 // INCLUDES
40 //=============================================================================================================
41 
42 #include "rtfiffrawviewdelegate.h"
43 #include "rtfiffrawviewmodel.h"
44 #include "../rtfiffrawview.h"
45 
46 #include "../scalingview.h"
47 
48 //=============================================================================================================
49 // QT INCLUDES
50 //=============================================================================================================
51 
52 #include <QPainter>
53 #include <QDebug>
54 #include <QPainterPath>
55 
56 //=============================================================================================================
57 // EIGEN INCLUDES
58 //=============================================================================================================
59 
60 //=============================================================================================================
61 // USED NAMESPACES
62 //=============================================================================================================
63 
64 using namespace DISPLIB;
65 
66 //=============================================================================================================
67 // DEFINE MEMBER METHODS
68 //=============================================================================================================
69 
71 : QAbstractItemDelegate(parent)
72 , m_pParent(parent)
73 , m_dMaxValue(0.0)
74 , m_dScaleY(0.0)
75 , m_iActiveRow(0)
76 , m_iUpperItemIndex(0)
77 {
78 
79 }
80 
81 //=============================================================================================================
82 
83 void RtFiffRawViewDelegate::initPainterPaths(const QAbstractTableModel *model)
84 {
85  for(int i = 0; i<model->rowCount(); i++)
86  m_painterPaths.append(QPainterPath());
87 
88  // Init pens
89  QColor colorMarker(233,0,43);
90  colorMarker.setAlpha(160);
91 
92  m_penMarker = QPen(colorMarker, 2, Qt::DashLine);
93 
94  m_penGrid = QPen(Qt::black, 1, Qt::DashLine);
95  m_penTimeSpacers = QPen(Qt::black, 1, Qt::DashLine);
96 
97  m_penFreeze = QPen(Qt::darkGray, 1, Qt::SolidLine);
98  m_penFreezeSelected = QPen(Qt::darkRed, 1, Qt::SolidLine);
99 
100  m_penFreezeBad = QPen(Qt::darkGray, 0.1, Qt::SolidLine);
101  m_penFreezeSelectedBad = QPen(Qt::darkRed, 1, Qt::SolidLine);
102 
103  m_penNormal = QPen(Qt::darkBlue, 1, Qt::SolidLine);
104  m_penNormalSelected = QPen(Qt::red, 1, Qt::SolidLine);
105 
106  m_penNormalBad = QPen(Qt::darkBlue, 0.1, Qt::SolidLine);
107  m_penNormalSelectedBad = QPen(Qt::red, 1, Qt::SolidLine);
108 }
109 
110 //=============================================================================================================
111 
112 void createPaths(const QModelIndex &index,
113  const QStyleOptionViewItem &option,
114  QPainterPath &path,
115  QPainterPath &lastPath,
116  QPointF &ellipsePos,
117  QPointF &markerPosition,
118  QString &amplitude,
119  const QVector<float> &data,
120  const QVector<float> &lastData)
121 {
122  const RtFiffRawViewModel* t_pModel = static_cast<const RtFiffRawViewModel*>(index.model());
123 
124  //get maximum range of respective channel type (range value in FiffChInfo does not seem to contain a reasonable value)
125  qint32 kind = t_pModel->getKind(index.row());
126 
127  float fMaxValue = DISPLIB::getScalingValue(t_pModel->getScaling(), kind, t_pModel->getUnit(index.row()));
128 
129  float dValue;
130  float dScaleY = option.rect.height()/(2*fMaxValue);
131 
132  float y_base = path.currentPosition().y();
133  QPointF qSamplePosition;
134 
135  float dDx = ((float)option.rect.width()) / t_pModel->getMaxSamples();
136 
137  //Move to initial starting point
138  if(data.size() > 0)
139  {
140 // float val = data[0];
141  dValue = 0;//(val-data[0])*dScaleY;
142 
143  float newY = y_base-dValue;//Reverse direction -> plot the right way
144 
145  qSamplePosition.setY(newY);
146  qSamplePosition.setX(path.currentPosition().x());
147 
148  path.moveTo(qSamplePosition);
149  }
150 
151  //create lines from one to the next sample
152  qint32 i;
153  for(i = 1; i < data.size(); ++i) {
154  float val = data[i] - data[0]; //remove first sample data[0] as offset
155  dValue = val*dScaleY;
156  //qDebug()<<"val"<<val<<"dScaleY"<<dScaleY<<"dValue"<<dValue;
157 
158  float newY = y_base-dValue;//Reverse direction -> plot the right way
159 
160  qSamplePosition.setY(newY);
161  qSamplePosition.setX(path.currentPosition().x()+dDx);
162 
163  path.lineTo(qSamplePosition);
164 
165  //Create ellipse position
166  if(i == (qint32)(markerPosition.x()/dDx)) {
167  ellipsePos.setX(path.currentPosition().x()+dDx);
168  ellipsePos.setY(newY+(option.rect.height()/2));
169 
170  amplitude = QString::number(data[i]);
171  }
172  }
173 
174  //create lines from one to the next sample for last path
175  qint32 sample_offset = t_pModel->numVLines() + 1;
176  qSamplePosition.setX(qSamplePosition.x() + dDx*sample_offset);
177 
178  //start painting from first sample value
179  float val = lastData[i] - lastData[0]; //remove first sample lastData[0] as offset
180  dValue = val*dScaleY;
181  float newY = y_base-dValue;
182  qSamplePosition.setY(newY);
183 
184  lastPath.moveTo(qSamplePosition);
185 
186  for(i += sample_offset; i < lastData.size(); ++i) {
187  val = lastData[i] - lastData[0]; //remove first sample lastData[0] as offset
188  dValue = val*dScaleY;
189 
190  newY = y_base-dValue;
191 
192  qSamplePosition.setY(newY);
193  qSamplePosition.setX(lastPath.currentPosition().x()+dDx);
194 
195  lastPath.lineTo(qSamplePosition);
196 
197  //Create ellipse position
198  if(i == (qint32)(markerPosition.x()/dDx)) {
199  ellipsePos.setX(lastPath.currentPosition().x()+dDx);
200  ellipsePos.setY(newY+(option.rect.height()/2));
201 
202  amplitude = QString::number(lastData[i]);
203  }
204  }
205 }
206 
207 //=============================================================================================================
208 
209 void RtFiffRawViewDelegate::paint(QPainter *painter,
210  const QStyleOptionViewItem &option,
211  const QModelIndex &index) const
212 {
213  float t_fPlotHeight = option.rect.height();
214  painter->setRenderHint(QPainter::Antialiasing, true);
215 
216  switch(index.column()) {
217  case 0: { //chnames
218  painter->save();
219 
220  painter->rotate(-90);
221  painter->drawText(QRectF(-option.rect.y()-t_fPlotHeight,0,t_fPlotHeight,20),Qt::AlignCenter,index.model()->data(index,Qt::DisplayRole).toString());
222 
223  painter->restore();
224  break;
225  }
226 
227  case 1: { //data plot
228  QBrush backgroundBrush = index.model()->data(index, Qt::BackgroundRole).value<QBrush>();
229  bool bIsBadChannel = index.model()->data(index.model()->index(index.row(), 2), Qt::DisplayRole).toBool();
230 
231  // Plot background based on user chosen color
232  // This is a rather ugly hack in order to cope with QOpenGLWidget's/QtableView's problem when setting a background color
233  if (index.row() == m_iUpperItemIndex) {
234  painter->save();
235  painter->setBrushOrigin(option.rect.topLeft());
236  QRect rect = option.rect;
237  rect.setHeight(2000);
238  painter->fillRect(rect, backgroundBrush);
239  painter->restore();
240  }
241 
242  // Draw special background when channel is marked as bad
243  if(bIsBadChannel) {
244  painter->save();
245  QBrush brush(QColor(254,74,93,40));
246  painter->setBrushOrigin(option.rect.topLeft());
247  painter->fillRect(option.rect, brush);
248  painter->restore();
249  }
250 
251 // //Highlight selected channels
252 // if(option.state & QStyle::State_Selected) {
253 // QPointF oldBO = painter->brushOrigin();
254 // painter->setBrushOrigin(option.rect.topLeft());
255 // painter->fillRect(option.rect, option.palette.highlight());
256 // painter->setBrushOrigin(oldBO);
257 // }
258 
259  //Get data
260  QVariant variant = index.model()->data(index,Qt::DisplayRole);
261  RowVectorPair data = variant.value<RowVectorPair>();
262 
263  const RtFiffRawViewModel* t_pModel = static_cast<const RtFiffRawViewModel*>(index.model());
264 
265  if(data.second > 0) {
266  QPainterPath path(QPointF(option.rect.x(),option.rect.y()));
267 
268 // //Plot hovering marker
269 // createMarkerPath(option, path);
270 
271 // painter->save();
272 // painter->setPen(m_penMarker);
273 // painter->drawPath(path);
274 // painter->restore();
275 
276  //Plot grid
277  createGridPath(index, option, path, data);
278 
279  painter->save();
280  painter->setPen(m_penGrid);
281  painter->drawPath(path);
282  painter->restore();
283 
284  //Plot time spacers
285  createTimeSpacersPath(index, option, path, data);
286 
287  painter->save();
288  painter->setPen(m_penTimeSpacers);
289  painter->drawPath(path);
290  painter->restore();
291 
292  //Plot detected triggers
293  path = QPainterPath(QPointF(option.rect.x(),option.rect.y()));//QPointF(option.rect.x()+t_rtmsaModel->relFiffCursor(),option.rect.y()));
294  painter->save();
295  createTriggerPath(painter, index, option, path, data);
296  painter->restore();
297 
298  //Plot trigger threshold
299  if(index.row() == t_pModel->getCurrentTriggerIndex() &&
300  t_pModel->triggerDetectionActive()) {
301  path = QPainterPath(QPointF(option.rect.x(),option.rect.y()));//QPointF(option.rect.x()+t_rtmsaModel->relFiffCursor(),option.rect.y()));
302  QPointF textPosition;
303  createTriggerThresholdPath(index, option, path, data, textPosition);
304 
305  painter->save();
306  painter->setPen(QPen(Qt::red, 1, Qt::DashLine));
307  painter->drawPath(path);
308  painter->drawText(textPosition, QString("%1 Threshold").arg(t_pModel->getTriggerName()));
309  painter->restore();
310  }
311 
312  path = QPainterPath(QPointF(option.rect.x(),option.rect.y()));//QPointF(option.rect.x()+t_rtmsaModel->relFiffCursor(),option.rect.y()));
313 
314  //Plot data path
315  createPlotPath(index, option, path, data);
316 
317  painter->setRenderHint(QPainter::Antialiasing, true);
318  painter->save();
319  painter->translate(0, t_fPlotHeight/2);
320 
321  if(bIsBadChannel) {
322  if(t_pModel->isFreezed()) {
323  if(option.state & QStyle::State_Selected)
324  painter->setPen(m_penFreezeSelectedBad);
325  else
326  painter->setPen(m_penFreezeBad);
327  } else {
328  if(option.state & QStyle::State_Selected)
329  painter->setPen(m_penNormalSelectedBad);
330  else
331  painter->setPen(m_penNormalBad);
332  }
333  } else {
334  if(t_pModel->isFreezed()) {
335  if(option.state & QStyle::State_Selected)
336  painter->setPen(m_penFreezeSelected);
337  else
338  painter->setPen(m_penFreeze);
339  } else {
340  if(option.state & QStyle::State_Selected)
341  painter->setPen(m_penNormalSelected);
342  else
343  painter->setPen(m_penNormal);
344  }
345  }
346 
347  painter->drawPath(path);
348  painter->restore();
349 
350  //Plot current position marker
351  path = QPainterPath(QPointF(option.rect.x(),option.rect.y()));//QPointF(option.rect.x()+t_rtmsaModel->relFiffCursor(),option.rect.y()));
352  createCurrentPositionMarkerPath(index, option, path);
353 
354  painter->save();
355  painter->setPen(m_penMarker);
356  painter->drawPath(path);
357  painter->restore();
358 
359  path = QPainterPath(QPointF(option.rect.x(),option.rect.y()));//QPointF(option.rect.x()+t_rtmsaModel->relFiffCursor(),option.rect.y()));
360  createMarkerPath(index, option, path);
361 
362  painter->save();
363  painter->setPen(QPen(Qt::green, 1, Qt::SolidLine));
364  painter->drawPath(path);
365  painter->restore();
366  }
367  break;
368  }
369  }
370 }
371 
372 //=============================================================================================================
373 
374 QSize RtFiffRawViewDelegate::sizeHint(const QStyleOptionViewItem &option,
375  const QModelIndex &index) const
376 {
377  QSize size = option.rect.size();
378 
379  switch(index.column()) {
380  case 0:
381  size = QSize(20,option.rect.height());
382  break;
383  case 1:
384  QList< QVector<float> > data = index.model()->data(index).value< QList<QVector<float> > >();
385 // qint32 nsamples = (static_cast<const RtFiffRawViewModel*>(index.model()))->lastSample()-(static_cast<const RtFiffRawViewModel*>(index.model()))->firstSample();
386 // size = QSize(nsamples*m_dDx,m_dPlotHeight);
387  Q_UNUSED(option);
388  break;
389  }
390 
391  return size;
392 }
393 
394 //=============================================================================================================
395 
397  int activeRow)
398 {
399  m_markerPosition = position;
400  m_iActiveRow = activeRow;
401 }
402 
403 //=============================================================================================================
404 
405 void RtFiffRawViewDelegate::setSignalColor(const QColor& signalColor)
406 {
407  m_penNormal.setColor(signalColor);
408  m_penNormalBad.setColor(signalColor);
409 }
410 
411 //=============================================================================================================
412 
414 {
415  return m_penNormal.color();
416 }
417 
418 //=============================================================================================================
419 
421 {
422  m_iUpperItemIndex = iUpperItemIndex;
423 }
424 
425 //=============================================================================================================
426 
427 void RtFiffRawViewDelegate::createPlotPath(const QModelIndex &index,
428  const QStyleOptionViewItem &option,
429  QPainterPath& path,
430  const RowVectorPair &data) const
431 {
432  const RtFiffRawViewModel* t_pModel = static_cast<const RtFiffRawViewModel*>(index.model());
433  int iPlotSizePx = option.rect.width();
434  int iNumSamples = t_pModel->getMaxSamples();
435  double dPixelsPerSample = static_cast<double>(iPlotSizePx) / static_cast<double>(iNumSamples);
436 
437  // locate time-cursor
438  int iTimeCursorSample = t_pModel->getCurrentSampleIndex();
439  double firstValuePreviousPlot = t_pModel->getLastBlockFirstValue(index.row());
440 
441  //get maximum range of respective channel type (range value in FiffChInfo does not seem to contain a reasonable value)
442  double dMaxYValueEstimate = t_pModel->getMaxValueFromRawViewModel(index.row());
443  double dScaleY = option.rect.height()/(2 * dMaxYValueEstimate);
444  double dChannelOffset = path.currentPosition().y();
445 
446 // qDebug() << " - - - - - - - - - - - - - - - - - - - - - ";
447 // qDebug() << " iPlotSizePx = " << iPlotSizePx;
448 // qDebug() << " iNumSamples = " << iNumSamples;
449 // qDebug() << " dPixelsPerSample = " << dPixelsPerSample;
450 // qDebug() << " iTimeCursorSample = " << iTimeCursorSample;
451 // qDebug() << " firstValuePreviousPlot = " << firstValuePreviousPlot;
452 
453 // qDebug() << " dMaxYValueEstimate = " << dMaxYValueEstimate;
454 // qDebug() << " dScaleY = " << dScaleY;
455 // qDebug() << " dChannelOffset = " << dChannelOffset;
456 
457  // Move to initial starting point
458  path.moveTo(calcPoint(path, 0., 0., dChannelOffset, dScaleY));
459  double dY(0);
460 
461  // The plot works as a rolling time-cursor, ploting data on top of previous
462  // runs. You always plot one whole window of data, between first sample and
463  // numSamplesToPlot (or data.second) Even if the only change is a new block
464  // of samples to the left of the time-cursor. At any time, to the left of
465  // the time-cursor you have the most recent data (A part) corresponding to
466  // the current roll. To the right of the time-cursor, you have data
467  // corresponding to the previous roll.
468  for (int j = 0; j < data.second; ++j) {
469  dY = data.first[j];
470  path.lineTo(calcPoint(path, dPixelsPerSample, dY,
471  dChannelOffset, dScaleY));
472  }
473 }
474 
475 //=============================================================================================================
476 
477 void RtFiffRawViewDelegate::createCurrentPositionMarkerPath(const QModelIndex &index, const QStyleOptionViewItem &option, QPainterPath& path) const
478 {
479  const RtFiffRawViewModel* t_pModel = static_cast<const RtFiffRawViewModel*>(index.model());
480 
481  float currentSampleIndex = option.rect.x()+t_pModel->getCurrentSampleIndex();
482  float dDx = ((float)option.rect.width()) / t_pModel->getMaxSamples();
483  currentSampleIndex = currentSampleIndex*dDx;
484 
485  float yStart = option.rect.topLeft().y();
486  float yEnd = option.rect.bottomRight().y();
487 
488  path.moveTo(currentSampleIndex,yStart);
489  path.lineTo(currentSampleIndex,yEnd);
490 }
491 
492 //=============================================================================================================
493 
494 void RtFiffRawViewDelegate::createGridPath(const QModelIndex &index, const QStyleOptionViewItem &option, QPainterPath& path, RowVectorPair &data) const
495 {
496  Q_UNUSED(data)
497 
498  const RtFiffRawViewModel* t_pModel = static_cast<const RtFiffRawViewModel*>(index.model());
499 
500  if(t_pModel->numVLines() > 0)
501  {
502  //vertical lines
503  float distance = float (option.rect.width())/(t_pModel->numVLines()+1);
504 
505  float yStart = option.rect.topLeft().y();
506 
507  float yEnd = option.rect.bottomRight().y();
508 
509  for(qint8 i = 0; i < t_pModel->numVLines(); ++i) {
510  float x = distance*(i+1);
511  path.moveTo(x,yStart);
512  path.lineTo(x,yEnd);
513  }
514  }
515 }
516 
517 //=============================================================================================================
518 
519 void RtFiffRawViewDelegate::createTimeSpacersPath(const QModelIndex &index, const QStyleOptionViewItem &option, QPainterPath& path, RowVectorPair &data) const
520 {
521  Q_UNUSED(data)
522 
523  const RtFiffRawViewModel* t_pModel = static_cast<const RtFiffRawViewModel*>(index.model());
524 
525  if(t_pModel->getNumberOfTimeSpacers() > 0)
526  {
527  //vertical lines
528  float distanceSec = float (option.rect.width())/(t_pModel->numVLines()+1);
529  float distanceSpacers = distanceSec/(t_pModel->getNumberOfTimeSpacers()+1);
530 
531  float yStart = option.rect.topLeft().y();
532 
533  float yEnd = option.rect.bottomRight().y();
534 
535  for(qint8 t = 0; t < t_pModel->numVLines()+1; ++t) {
536  for(qint8 i = 0; i < t_pModel->getNumberOfTimeSpacers(); ++i) {
537  float x = (distanceSec*t)+(distanceSpacers*(i+1));
538  path.moveTo(x,yStart);
539  path.lineTo(x,yEnd);
540  }
541  }
542  }
543 }
544 
545 //=============================================================================================================
546 
547 void RtFiffRawViewDelegate::createTriggerPath(QPainter *painter,
548  const QModelIndex &index,
549  const QStyleOptionViewItem &option,
550  QPainterPath& path,
551  RowVectorPair &data) const
552 {
553  Q_UNUSED(data)
554  Q_UNUSED(path)
555 
556  const RtFiffRawViewModel* t_pModel = static_cast<const RtFiffRawViewModel*>(index.model());
557 
558  QList<QPair<int,double> > detectedTriggers = t_pModel->getDetectedTriggers();
559  QList<QPair<int,double> > detectedTriggersOld = t_pModel->getDetectedTriggersOld();
560  QMap<double, QColor> mapTriggerTypeColors = t_pModel->getTriggerColor();
561 
562  float yStart = option.rect.topLeft().y();
563  float yEnd = option.rect.bottomRight().y();
564  float dDx = ((float)option.rect.width()) / t_pModel->getMaxSamples();
565 
566  int currentSampleIndex = t_pModel->getCurrentSampleIndex();
567 
568  //Newly detected triggers
569  for(int u = 0; u < detectedTriggers.size(); ++u) {
570  QPainterPath path;
571 
572  int triggerPos = detectedTriggers[u].first;
573 
574  painter->save();
575  if(mapTriggerTypeColors.contains(detectedTriggers[u].second)) {
576  painter->setPen(QPen(mapTriggerTypeColors[detectedTriggers[u].second], 1.5, Qt::SolidLine));
577  }
578 
579  if(triggerPos <= currentSampleIndex + t_pModel->getCurrentOverlapAddDelay()) {
580  path.moveTo(triggerPos*dDx,yStart);
581  path.lineTo(triggerPos*dDx,yEnd);
582  }
583 
584  painter->drawPath(path);
585  painter->restore();
586  }
587 
588  //Old detected triggers
589  for(int u = 0; u < detectedTriggersOld.size(); ++u) {
590  QPainterPath path;
591 
592  int triggerPos = detectedTriggersOld[u].first;
593 
594  if(triggerPos >= currentSampleIndex + t_pModel->getCurrentOverlapAddDelay()) {
595  painter->save();
596 
597  if(mapTriggerTypeColors.contains(detectedTriggersOld[u].second)) {
598  painter->setPen(QPen(mapTriggerTypeColors[detectedTriggersOld[u].second], 1.5, Qt::SolidLine));
599  }
600 
601  path.moveTo(triggerPos*dDx,yStart);
602  path.lineTo(triggerPos*dDx,yEnd);
603 
604  painter->drawPath(path);
605  painter->restore();
606  }
607  }
608 }
609 
610 //=============================================================================================================
611 
612 void RtFiffRawViewDelegate::createTriggerThresholdPath(const QModelIndex &index,
613  const QStyleOptionViewItem &option,
614  QPainterPath& path,
615  RowVectorPair &data,
616  QPointF &textPosition) const
617 {
618  Q_UNUSED(data)
619 
620  const RtFiffRawViewModel* t_pModel = static_cast<const RtFiffRawViewModel*>(index.model());
621 
622  //get maximum range of respective channel type (range value in FiffChInfo does not seem to contain a reasonable value)
623  qint32 kind = t_pModel->getKind(index.row());
624  double dMaxValue = 1e-9f;
625 
626  switch(kind) {
627  case FIFFV_STIM_CH: {
628  dMaxValue = 5.0;
629  if(t_pModel->getScaling().contains(FIFFV_STIM_CH))
630  dMaxValue = t_pModel->getScaling()[FIFFV_STIM_CH];
631  break;
632  }
633  }
634 
635  double dScaleY = option.rect.height()/(2*dMaxValue);
636  double triggerThreshold = -1*(t_pModel->getTriggerThreshold());
637 
638  path.moveTo(option.rect.topLeft().x(), option.rect.topLeft().y()+option.rect.height()/2+dScaleY*triggerThreshold);
639  path.lineTo(option.rect.topRight().x(), option.rect.topLeft().y()+option.rect.height()/2+dScaleY*triggerThreshold);
640 
641  textPosition = QPointF(option.rect.topLeft().x()+5, option.rect.topLeft().y()+option.rect.height()/2+dScaleY*triggerThreshold-5);
642 }
643 
644 //=============================================================================================================
645 
646 void RtFiffRawViewDelegate::createMarkerPath(const QModelIndex &index,
647  const QStyleOptionViewItem &option,
648  QPainterPath& path) const
649 {
650  const RtFiffRawViewModel* t_pModel = static_cast<const RtFiffRawViewModel*>(index.model());
651 
652  int iOffset = t_pModel->getFirstSampleOffset();
653  int iTimeCursorSample = t_pModel->getCurrentSampleIndex();
654  int iMaxSample = t_pModel->getMaxSamples();
655 
656  double dDx = static_cast<double>(option.rect.width()) / static_cast<double>(iMaxSample);
657 
658  float yStart = option.rect.topLeft().y();
659  float yEnd = option.rect.bottomRight().y();
660 
661  int iEarliestDrawnSample = iOffset - iMaxSample + iTimeCursorSample;
662  int iLatestDrawnSample = iOffset + iTimeCursorSample;
663 
664  auto events = t_pModel->getEventsToDisplay(iEarliestDrawnSample, iLatestDrawnSample);
665 
666  for(auto& e : *events)
667  {
668  int iEventSample = e.sample;
669  int iLastStartingSample = iOffset - iMaxSample;
670  int iDrawPositionInSamples = (iEventSample - iLastStartingSample) % iMaxSample;
671 
672  float iPositionInPixels = static_cast<float>(iDrawPositionInSamples) * dDx;
673 
674  path.moveTo(iPositionInPixels,yStart);
675  path.lineTo(iPositionInPixels,yEnd);
676  }
677 }
678 
679 //=============================================================================================================
680 
681 QPointF RtFiffRawViewDelegate::calcPoint(QPainterPath& path,
682  const double dx,
683  const double y,
684  const double yBase,
685  const double yScale) const
686 {
687  double x = path.currentPosition().x() + dx;
688  double yScaled = -((yScale * y) - yBase);//- because y pixels grow downwards.
689 
690 // qDebug() << " x = " << x;
691 // qDebug() << " y = " << yScaled;
692 
693  return QPointF(x, yScaled);
694 }
695 
696 //=============================================================================================================
DISPLIB::RtFiffRawViewDelegate::RtFiffRawViewDelegate
RtFiffRawViewDelegate(RtFiffRawView *parent=0)
Definition: rtfiffrawviewdelegate.cpp:70
DISPLIB::RtFiffRawViewModel::getEventsToDisplay
std::unique_ptr< std::vector< EVENTSLIB::Event > > getEventsToDisplay(int iBegin, int iEnd) const
Definition: rtfiffrawviewmodel.cpp:1391
DISPLIB::RtFiffRawView
The RtFiffRawView class provides a real-time channel view display.
Definition: rtfiffrawview.h:97
DISPLIB::RtFiffRawViewModel::getTriggerThreshold
double getTriggerThreshold() const
Definition: rtfiffrawviewmodel.h:798
rtfiffrawviewmodel.h
Declaration of the RtFiffRawViewModel Class.
DISPLIB::RtFiffRawViewDelegate::getSignalColor
QColor getSignalColor()
Definition: rtfiffrawviewdelegate.cpp:413
DISPLIB::RtFiffRawViewModel::getScaling
const QMap< qint32, float > & getScaling() const
Definition: rtfiffrawviewmodel.h:739
DISPLIB::RtFiffRawViewModel::getKind
FIFFLIB::fiff_int_t getKind(qint32 row) const
Definition: rtfiffrawviewmodel.cpp:574
DISPLIB::RtFiffRawViewModel::getDetectedTriggersOld
QList< QPair< int, double > > getDetectedTriggersOld() const
Definition: rtfiffrawviewmodel.h:774
DISPLIB::RtFiffRawViewDelegate::setSignalColor
void setSignalColor(const QColor &signalColor)
Definition: rtfiffrawviewdelegate.cpp:405
DISPLIB::RtFiffRawViewModel::numVLines
qint32 numVLines() const
Definition: rtfiffrawviewmodel.h:725
DISPLIB::RtFiffRawViewModel
The RtFiffRawViewModel class implements the data access model for a real-time multi sample array data...
Definition: rtfiffrawviewmodel.h:101
DISPLIB::RtFiffRawViewDelegate::initPainterPaths
void initPainterPaths(const QAbstractTableModel *model)
Definition: rtfiffrawviewdelegate.cpp:83
DISPLIB::RtFiffRawViewModel::getNumberOfTimeSpacers
int getNumberOfTimeSpacers() const
Definition: rtfiffrawviewmodel.h:790
DISPLIB::RtFiffRawViewModel::getMaxValueFromRawViewModel
double getMaxValueFromRawViewModel(int row) const
Definition: rtfiffrawviewmodel.cpp:1321
DISPLIB::RtFiffRawViewModel::getCurrentOverlapAddDelay
int getCurrentOverlapAddDelay() const
Definition: rtfiffrawviewmodel.h:826
DISPLIB::RtFiffRawViewDelegate::setUpperItemIndex
void setUpperItemIndex(int iUpperItemIndex)
Definition: rtfiffrawviewdelegate.cpp:420
DISPLIB::RtFiffRawViewModel::getUnit
FIFFLIB::fiff_int_t getUnit(qint32 row) const
Definition: rtfiffrawviewmodel.cpp:586
rtfiffrawviewdelegate.h
Declaration of the RtFiffRawViewDelegate Class.
DISPLIB::RtFiffRawViewModel::getDetectedTriggers
QList< QPair< int, double > > getDetectedTriggers() const
Definition: rtfiffrawviewmodel.h:758
DISPLIB::RtFiffRawViewDelegate::sizeHint
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: rtfiffrawviewdelegate.cpp:374
DISPLIB::RtFiffRawViewModel::getCurrentSampleIndex
qint32 getCurrentSampleIndex() const
Definition: rtfiffrawviewmodel.h:690
DISPLIB::RtFiffRawViewDelegate::paint
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: rtfiffrawviewdelegate.cpp:209
DISPLIB::RtFiffRawViewModel::getLastBlockFirstValue
double getLastBlockFirstValue(int row) const
Definition: rtfiffrawviewmodel.h:705
DISPLIB::RtFiffRawViewModel::getMaxSamples
qint32 getMaxSamples() const
Definition: rtfiffrawviewmodel.h:683
DISPLIB::RtFiffRawViewDelegate::markerMoved
void markerMoved(QPoint position, int activeRow)
Definition: rtfiffrawviewdelegate.cpp:396
DISPLIB::RtFiffRawViewModel::getTriggerColor
QMap< double, QColor > getTriggerColor() const
Definition: rtfiffrawviewmodel.h:746
DISPLIB::RtFiffRawViewModel::getFirstSampleOffset
int getFirstSampleOffset() const
Definition: rtfiffrawviewmodel.h:836
DISPLIB::getScalingValue
DISPSHARED_EXPORT float getScalingValue(const QMap< qint32, float > &qMapChScaling, int iChannelKind, int iChannelUnit)
Definition: scalingview.cpp:136