162 const QImage frame = grab().toImage();
164 if (fileName.contains(
".svg", Qt::CaseInsensitive)) {
165 QSvgGenerator svgGen;
166 svgGen.setFileName(fileName);
167 svgGen.setSize(this->size());
168 svgGen.setViewBox(this->rect());
170 QPainter painter(&svgGen);
171 painter.drawImage(this->rect(), frame);
174 if (fileName.contains(
".png", Qt::CaseInsensitive)) {
175 frame.save(fileName);
289 QPainter painter(
this);
293 painter.drawRect(QRect(-1, -1, this->width() + 2, this->height() + 2));
296 painter.setRenderHint(QPainter::Antialiasing,
true);
306 painter.setPen(QPen(Qt::red, 1, Qt::DashLine));
307 painter.setBrush(Qt::red);
308 painter.setOpacity(0.1);
311 qDebug() <<
"Unable to get data. Returning early.";
315 float fDx =
static_cast<float>(this->width()) / (
static_cast<float>(
m_pEvokedSetModel->getNumSamples()));
318 float posX = fDx * (fromSamp);
320 float width = fDx * (toSamp - fromSamp);
322 QRect rect(posX, 0, width, this->height());
324 painter.drawRect(rect);
332 painter.setPen(QPen(Qt::red, 1, Qt::DashLine));
334 float fDx =
static_cast<float>(this->width()) / (
static_cast<float>(
m_pEvokedSetModel->getNumSamples()));
335 float posX = fDx * (
static_cast<float>(
m_pEvokedSetModel->getNumPreStimSamples()));
336 painter.drawLine(posX, 1, posX, this->height());
338 painter.drawText(QPointF(posX + 5, this->rect().bottomRight().y() - 5), QString(
"0ms / Stimulus"));
346 QColor colorTimeSpacer = Qt::black;
347 colorTimeSpacer.setAlphaF(0.5);
348 painter.setPen(QPen(colorTimeSpacer, 1, Qt::DashLine));
350 float yStart = this->rect().topLeft().y();
351 float yEnd = this->rect().bottomRight().y();
355 fDx =
static_cast<float>(this->width()) / (
static_cast<float>(
m_pEvokedSetModel->getNumSamples()));
360 float timeDistanceMSec = 50.0;
361 float timeDistanceSamples = (timeDistanceMSec / 1000.0) *
m_pEvokedSetModel->getSamplingFrequency();
364 while (sampleCounter - timeDistanceSamples > 0) {
365 sampleCounter -= timeDistanceSamples;
366 float x = fDx * sampleCounter;
367 painter.drawLine(x, yStart, x, yEnd);
368 painter.drawText(QPointF(x + 5, yEnd - 5), QString(
"-%1ms").arg(timeDistanceMSec * counter));
375 while (sampleCounter + timeDistanceSamples < m_pEvokedSetModel->getNumSamples()) {
376 sampleCounter += timeDistanceSamples;
377 float x = fDx * sampleCounter;
378 painter.drawLine(x, yStart, x, yEnd);
379 painter.drawText(QPointF(x + 5, yEnd - 5), QString(
"%1ms").arg(timeDistanceMSec * counter));
389 painter.setPen(QPen(Qt::black, 1, Qt::DashLine));
391 painter.drawLine(0, this->height() / 2, this->width(), this->height() / 2);
396 painter.translate(0, this->height() / 2);
462 painter.setOpacity(0.20);
464 painter.setOpacity(0.75);
468 float fScaleY = this->height() / (2 * fMaxValue);
471 float fWinMaxVal = (
static_cast<float>(this->height()) - 2) / 2.0f;
477 QPointF qSamplePosition;
479 float fDx =
static_cast<float>(this->width() - 2) / (
static_cast<float>(
m_pEvokedSetModel->getNumSamples()) - 1.0f);
481 QList<DISPLIB::AvrTypeRowVector> rowVec =
m_pEvokedSetModel->data(row, 1).value<QList<DISPLIB::AvrTypeRowVector>>();
484 for (
int j = 0; j < rowVec.size(); ++j) {
485 QString sAvrComment = rowVec.at(j).first;
490 freezeColor.setAlphaF(0.5);
491 painter.setPen(QPen(freezeColor, 1));
499 rowVec.at(j).second.cols() / this->width() < 1 ? dsFactor = 1 : dsFactor = rowVec.at(j).second.cols() / this->width();
504 QPainterPath path(QPointF(1, 0));
505 float y_base = path.currentPosition().y();
508 if (rowVec.at(j).second.cols() > 0) {
509 float val = rowVec.at(j).second[0];
510 fValue = (val ) * fScaleY;
512 float newY = y_base + fValue;
514 qSamplePosition.setY(-newY);
515 qSamplePosition.setX(path.currentPosition().x());
517 path.moveTo(qSamplePosition);
522 for (i = 1; i < rowVec.at(j).second.cols() && path.elementCount() <= this->width(); i += dsFactor) {
523 float val = rowVec.at(j).second[i];
524 fValue = val * fScaleY;
527 fValue = fValue > fWinMaxVal ? fWinMaxVal : fValue < -fWinMaxVal ? -fWinMaxVal
530 float newY = y_base + fValue;
532 qSamplePosition.setY(-newY);
534 qSamplePosition.setX(1.0 + fDx * i);
536 path.lineTo(qSamplePosition);
556 painter.drawPath(path);