Пример #1
0
void QGLView::prepareTextTexture(const QStaticText &staticText, QFont font)
{
    if (m_textTextList.contains(staticText))
    {
        return;
    }

    if (m_textTextureList.size() > 100) // maximum of 100 rendered texts TODO: make parameter
    {
        clearTextTextures();
    }

    QPixmap pixmap(QSize(qCeil(staticText.size().width()), qCeil(staticText.size().height())));
    pixmap.fill(QColor(Qt::transparent));

    QPainter painter(&pixmap);
    painter.setPen(Qt::white);
    painter.setFont(font);
    painter.drawStaticText(0, 0, staticText);

    QOpenGLTexture *texture = new QOpenGLTexture(QOpenGLTexture::Target2D);
    float aspectRatio = staticText.size().width()/staticText.size().height();

    m_textTextList.append(staticText);
    m_textTextureList.append(texture);
    m_textAspectRatioList.append(aspectRatio);
    m_textImageList.append(pixmap.toImage());
}
Пример #2
0
void AverageSceneItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);

    //set posistion
    this->setPos(75*m_qpChannelPosition.x(), -75*m_qpChannelPosition.y());

    painter->setRenderHint(QPainter::Antialiasing, true);

//    //Plot bounding rect / drawing region of this item
//    painter->drawRect(this->boundingRect());

    //Plot stim time
    painter->save();
    paintStimLine(painter);
    painter->restore();

    //Plot average data
    painter->save();
    paintAveragePath(painter);
    painter->restore();

    // Plot channel name
    QStaticText staticElectrodeName = QStaticText(m_sChannelName);
    QSizeF sizeText = staticElectrodeName.size();
    painter->save();
    QPen pen;
    pen.setColor(Qt::yellow);
    pen.setWidthF(5);
    painter->setPen(pen);
    painter->drawStaticText(boundingRect().x(), boundingRect().y(), staticElectrodeName);
    painter->restore();
}
Пример #3
0
void TFPlotSceneItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);

    this->setPos(10*m_qpChannelPosition.x(), -10*m_qpChannelPosition.y());

    if(m_tfImage->isNull())
    {
        // Plot shadow
        painter->setPen(Qt::NoPen);
        painter->setBrush(Qt::darkGray);
        painter->drawEllipse(-12, -12, 30, 30);
        //Plot red if bad
        if(m_bIsBadChannel) {
            painter->setBrush(Qt::red);
            painter->drawEllipse(-15, -15, 30, 30);
        }
        else {
            painter->setBrush(m_cChannelColor);
            painter->drawEllipse(-15, -15, 30, 30);
        }

        //Plot selected item
        if(this->isSelected()){
            //painter->setPen(QPen(QColor(255,84,22), 5));
            painter->setPen(QPen(Qt::red, 5));
            painter->drawEllipse(-15, -15, 30, 30);
        }

        // Plot electrode name
        painter->setPen(QPen(Qt::black, 1));
        QStaticText staticElectrodeName = QStaticText(m_sChannelName);
        QSizeF sizeText = staticElectrodeName.size();
        painter->drawStaticText(-15+((30-sizeText.width())/2), -32, staticElectrodeName);
    }
    else
    {
        painter->drawImage(QRectF(-30, -15, 60, 30), *m_tfImage);
        // Plot electrode name
        painter->setPen(QPen(Qt::black, 1));
        QStaticText staticElectrodeName = QStaticText(m_sChannelName);
        QSizeF sizeText = staticElectrodeName.size();
        painter->drawStaticText(-30+((60-sizeText.width())/2), -32, staticElectrodeName);
    }
}