195 if(fileName.contains(
".svg", Qt::CaseInsensitive)) {
197 QSvgGenerator svgGen;
198 svgGen.setFileName(fileName);
199 svgGen.setSize(this->size());
200 svgGen.setViewBox(this->rect());
202 this->render(&svgGen);
205 if(fileName.contains(
".png", Qt::CaseInsensitive)) {
206 QImage image(this->size(), QImage::Format_ARGB32);
207 image.fill(Qt::transparent);
209 QPainter painter(&image);
210 this->render(&painter);
211 image.save(fileName);
326 void ButterflyView::paintEvent(QPaintEvent *event)
329 QPainter painter(
this);
333 painter.drawRect(QRect(-1,-1,this->width()+2,this->height()+2));
336 painter.setRenderHint(QPainter::Antialiasing,
true);
347 painter.setPen(QPen(Qt::red, 1, Qt::DashLine));
348 painter.setBrush(Qt::red);
349 painter.setOpacity(0.1);
352 qDebug() <<
"Unable to get data. Returning early.";
356 float fDx = (float)(this->width()) / ((float)
m_pEvokedSetModel->getNumSamples());
359 float posX = fDx*(fromSamp);
361 float width = fDx*(toSamp-fromSamp);
363 QRect rect(posX,0,width,this->height());
365 painter.drawRect(rect);
373 painter.setPen(QPen(Qt::red, 1, Qt::DashLine));
375 float fDx = (float)(this->width()) / ((float)
m_pEvokedSetModel->getNumSamples());
377 painter.drawLine(posX, 1, posX, this->height());
379 painter.drawText(QPointF(posX+5,this->rect().bottomRight().y()-5), QString(
"0ms / Stimulus"));
388 QColor colorTimeSpacer = Qt::black;
389 colorTimeSpacer.setAlphaF(0.5);
390 painter.setPen(QPen(colorTimeSpacer, 1, Qt::DashLine));
392 float yStart = this->rect().topLeft().y();
393 float yEnd = this->rect().bottomRight().y();
402 float timeDistanceMSec = 50.0;
403 float timeDistanceSamples = (timeDistanceMSec/1000.0)*
m_pEvokedSetModel->getSamplingFrequency();
406 while(sampleCounter-timeDistanceSamples>0) {
407 sampleCounter-=timeDistanceSamples;
408 float x = fDx*sampleCounter;
409 painter.drawLine(x, yStart, x, yEnd);
410 painter.drawText(QPointF(x+5,yEnd-5), QString(
"-%1ms").arg(timeDistanceMSec*counter));
417 while(sampleCounter+timeDistanceSamples<m_pEvokedSetModel->getNumSamples()) {
418 sampleCounter+=timeDistanceSamples;
419 float x = fDx*sampleCounter;
420 painter.drawLine(x, yStart, x, yEnd);
421 painter.drawText(QPointF(x+5,yEnd-5), QString(
"%1ms").arg(timeDistanceMSec*counter));
431 painter.setPen(QPen(Qt::black, 1, Qt::DashLine));
433 painter.drawLine(0, this->height()/2, this->width(), this->height()/2);
438 painter.translate(0,this->height()/2);
495#if !defined(NO_QOPENGLWIDGET)
496 return QOpenGLWidget::paintGL();
498 return QWidget::paintEvent(event);
512 painter.setOpacity(0.20);
514 painter.setOpacity(0.75);
518 float fScaleY = this->height()/(2*fMaxValue);
521 float fWinMaxVal = ((float)this->height()-2)/2.0f;
527 QPointF qSamplePosition;
529 float fDx = (float)(this->width()-2) / ((float)
m_pEvokedSetModel->getNumSamples()-1.0f);
531 QList<DISPLIB::AvrTypeRowVector> rowVec =
m_pEvokedSetModel->data(row,1).value<QList<DISPLIB::AvrTypeRowVector> >();
534 for(
int j = 0; j < rowVec.size(); ++j) {
535 QString sAvrComment = rowVec.at(j).first;
540 freezeColor.setAlphaF(0.5);
541 painter.setPen(QPen(freezeColor, 1));
549 rowVec.at(j).second.cols() / this->width() < 1 ? dsFactor = 1 : dsFactor = rowVec.at(j).second.cols() / this->width();
554 QPainterPath path(QPointF(1,0));
555 float y_base = path.currentPosition().y();
558 if(rowVec.at(j).second.cols() > 0)
560 float val = rowVec.at(j).second[0];
561 fValue = (val)*fScaleY;
563 float newY = y_base+fValue;
565 qSamplePosition.setY(-newY);
566 qSamplePosition.setX(path.currentPosition().x());
568 path.moveTo(qSamplePosition);
573 for(i = 1; i < rowVec.at(j).second.cols() && path.elementCount() <= this->width(); i += dsFactor) {
574 float val = rowVec.at(j).second[i];
575 fValue = val*fScaleY;
578 fValue = fValue > fWinMaxVal ? fWinMaxVal : fValue < -fWinMaxVal ? -fWinMaxVal : fValue;
580 float newY = y_base+fValue;
582 qSamplePosition.setY(-newY);
584 qSamplePosition.setX(path.currentPosition().x()+fDx);
586 path.lineTo(qSamplePosition);
606 painter.drawPath(path);