Beispiel #1
0
void widgetLandmark::SetLineItemAsConnection()
{
    QLineF line = QLineF(_currentConnection->GetLandmarks().first->GetPos(),_currentConnection->GetLandmarks().second->GetPos());
    QPen pen = QPen(Qt::blue,2);
    pen.setCosmetic(true);
    QGraphicsLineItem* lineItem = _gview->GetScene()->addLine(line,pen);
    lineItem->setTransform(QTransform::fromTranslate(_gview->GetTranslationX(),_gview->GetTranslationY()), true);
    _currentConnection->SetLineItem(lineItem);
    _currentConnection=nullptr;
}
void PSV_CircularIndicatorItem::drawMark(int zValue)
{
    double colorCircleRadius = m_colorCircleRadiusRatio * m_outerRadius;
    double value= m_min;
    double dValue = (m_max - m_min) / m_numTicks;
    QString strValue;
    for(int i=0;i<=m_numTicks;i++)
    {
        QPointF topPot;
        QPointF bottomPot;

        if(i%10==0)
        {
            strValue=QObject::tr("%1").arg(value);
            bottomPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius);
            topPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius*1.05);
            value+=10 * dValue;
            QGraphicsTextItem* item = new QGraphicsTextItem(strValue, this);
            item->setDefaultTextColor(QColor(Qt::white));
            item->setFont(m_markFont);
            item->setZValue(zValue);
            QRectF rectF = item->boundingRect();
            QPointF movePointF = QPointF(m_rect.center().x() - 0.5 * rectF.width()
                                         , m_rect.center().y() - colorCircleRadius*1.05 - rectF.height());
            item->moveBy(movePointF.x(), movePointF.y());
            item->setTransform(QTransform().translate(m_rect.center().x() - movePointF.x(), m_rect.center().y() - movePointF.y()).rotate(270 * i / 100-135).translate(-(m_rect.center().x() - movePointF.x()), -(m_rect.center().y() - movePointF.y())));
        }
        else if(i%5==0)
        {
            bottomPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius);
            topPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius*1.03);
        }
        else
        {
            bottomPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius);
            topPot = QPointF(m_rect.center().x(), m_rect.center().y() - colorCircleRadius*1.01);
        }
        QGraphicsLineItem* item = new QGraphicsLineItem(QLineF(topPot, bottomPot), this);
        item->setPen(QPen(Qt::white));
        item->setZValue(zValue);
        item->setTransform(QTransform().translate(m_rect.center().x(), m_rect.center().y()).rotate(270.0 * i / 100-135).translate(-m_rect.center().x(), -m_rect.center().y()));
    }
}