180 const QImage frame = grabFramebuffer();
182 if (fileName.contains(
".svg", Qt::CaseInsensitive)) {
183 QSvgGenerator svgGen;
184 svgGen.setFileName(fileName);
185 svgGen.setSize(this->size());
186 svgGen.setViewBox(this->rect());
188 QPainter painter(&svgGen);
189 painter.drawImage(this->rect(), frame);
192 if (fileName.contains(
".png", Qt::CaseInsensitive)) {
193 frame.save(fileName);
307 QPainter painter(
this);
311 painter.drawRect(QRect(-1, -1, this->width() + 2, this->height() + 2));
314 painter.setRenderHint(QPainter::Antialiasing,
true);
324 painter.setPen(QPen(Qt::red, 1, Qt::DashLine));
325 painter.setBrush(Qt::red);
326 painter.setOpacity(0.1);
329 qDebug() <<
"Unable to get data. Returning early.";
333 float fDx = (float)(this->width()) / ((float)
m_pEvokedSetModel->getNumSamples());
336 float posX = fDx * (fromSamp);
338 float width = fDx * (toSamp - fromSamp);
340 QRect rect(posX, 0, width, this->height());
342 painter.drawRect(rect);
350 painter.setPen(QPen(Qt::red, 1, Qt::DashLine));
352 float fDx = (float)(this->width()) / ((float)
m_pEvokedSetModel->getNumSamples());
354 painter.drawLine(posX, 1, posX, this->height());
356 painter.drawText(QPointF(posX + 5, this->rect().bottomRight().y() - 5), QString(
"0ms / Stimulus"));
364 QColor colorTimeSpacer = Qt::black;
365 colorTimeSpacer.setAlphaF(0.5);
366 painter.setPen(QPen(colorTimeSpacer, 1, Qt::DashLine));
368 float yStart = this->rect().topLeft().y();
369 float yEnd = this->rect().bottomRight().y();
378 float timeDistanceMSec = 50.0;
379 float timeDistanceSamples = (timeDistanceMSec / 1000.0) *
m_pEvokedSetModel->getSamplingFrequency();
382 while (sampleCounter - timeDistanceSamples > 0) {
383 sampleCounter -= timeDistanceSamples;
384 float x = fDx * sampleCounter;
385 painter.drawLine(x, yStart, x, yEnd);
386 painter.drawText(QPointF(x + 5, yEnd - 5), QString(
"-%1ms").arg(timeDistanceMSec * counter));
393 while (sampleCounter + timeDistanceSamples < m_pEvokedSetModel->getNumSamples()) {
394 sampleCounter += timeDistanceSamples;
395 float x = fDx * sampleCounter;
396 painter.drawLine(x, yStart, x, yEnd);
397 painter.drawText(QPointF(x + 5, yEnd - 5), QString(
"%1ms").arg(timeDistanceMSec * counter));
407 painter.setPen(QPen(Qt::black, 1, Qt::DashLine));
409 painter.drawLine(0, this->height() / 2, this->width(), this->height() / 2);
414 painter.translate(0, this->height() / 2);
469 return QRhiWidget::paintEvent(event);
482 painter.setOpacity(0.20);
484 painter.setOpacity(0.75);
488 float fScaleY = this->height() / (2 * fMaxValue);
491 float fWinMaxVal = ((float)this->height() - 2) / 2.0f;
497 QPointF qSamplePosition;
499 float fDx = (float)(this->width() - 2) / ((float)
m_pEvokedSetModel->getNumSamples() - 1.0f);
501 QList<DISPLIB::AvrTypeRowVector> rowVec =
m_pEvokedSetModel->data(row, 1).value<QList<DISPLIB::AvrTypeRowVector>>();
504 for (
int j = 0; j < rowVec.size(); ++j) {
505 QString sAvrComment = rowVec.at(j).first;
510 freezeColor.setAlphaF(0.5);
511 painter.setPen(QPen(freezeColor, 1));
519 rowVec.at(j).second.cols() / this->width() < 1 ? dsFactor = 1 : dsFactor = rowVec.at(j).second.cols() / this->width();
524 QPainterPath path(QPointF(1, 0));
525 float y_base = path.currentPosition().y();
528 if (rowVec.at(j).second.cols() > 0) {
529 float val = rowVec.at(j).second[0];
530 fValue = (val ) * fScaleY;
532 float newY = y_base + fValue;
534 qSamplePosition.setY(-newY);
535 qSamplePosition.setX(path.currentPosition().x());
537 path.moveTo(qSamplePosition);
542 for (i = 1; i < rowVec.at(j).second.cols() && path.elementCount() <= this->width(); i += dsFactor) {
543 float val = rowVec.at(j).second[i];
544 fValue = val * fScaleY;
547 fValue = fValue > fWinMaxVal ? fWinMaxVal : fValue < -fWinMaxVal ? -fWinMaxVal
550 float newY = y_base + fValue;
552 qSamplePosition.setY(-newY);
554 qSamplePosition.setX(1.0 + fDx * i);
556 path.lineTo(qSamplePosition);
576 painter.drawPath(path);