void KiviatView::KiviatData::redraw() { qDeleteAll(cornerPoints); cornerPoints.clear(); cornerPoints.resize(data.size()); cornerPoints.fill(NULL); QPolygonF polygonF; for(int i=0; i< view->getAxisCount(); i++) { Q_ASSERT(data[i]>=0 && data[i] <=1.0); QPointF curPoint = view->calcPosition(i,data[i]); polygonF << curPoint; int rad=view->cornerPointRadius(); QRectF circleRect(0,0,rad,rad); circleRect.moveCenter(curPoint); cornerPoints[i]= new QGraphicsEllipseItem (circleRect,polygon); cornerPoints[i]->setBrush(QBrush(Qt::black)); } polygon->setPolygon(polygonF); polygon->setBrush(QBrush(polygonColor)); /* //Shadow: polygon.translate(6,6); QGraphicsPolygonItem * shadow = scene.addPolygon(polygon); shadow->setBrush(QBrush(QColor(0,0,0,100))); polygon.translate(-6,-6); */ }
void MulticolorLedWidget::paintEvent(QPaintEvent *paintEvt) { QLOG_TRACE_FN(); QPainter painter(this); // Paint background painter.drawRect(rect()); painter.fillRect(rect(), m_BackgroundColor); // paint led QRect circleRect(0, 0, 18, 18); circleRect.moveCenter(rect().center()); painter.setBrush(QBrush(m_LedColor)); painter.drawEllipse(circleRect); }
void AudioObject::drawObject( QPainter* painter, const QRectF& rect, QTextDocument* doc, int posInDocument, const QTextFormat& format ) { painter->setBrush( Qt::darkGreen ); painter->drawRect( rect ); painter->setBrush( Qt::white ); QRect circleRect(rect.left() + 2.0, rect.top() + 2.0, rect.width() - 4.0, rect.height() - 4.0 ); painter->drawEllipse( circleRect ); painter->setBrush( Qt::green ); const QPointF points[3] = { QPointF( circleRect.left() + 7.0, circleRect.top() + 4.0 ), QPointF( circleRect.right() - 4.0, circleRect.top() + 4.0 + ( ( circleRect.height() - 8.0) / 2.0 ) ), QPointF( circleRect.left() + 7.0, circleRect.bottom() - 4.0 ) }; painter->drawPolygon(points, 3); }
void pathArcTo( QPainterPath& path, const QPointF& circleCenter, qreal circleRadius, qreal angle_o, qreal angle_d, int direction ) { QRectF circleRect( circleCenter - QPointF( circleRadius, circleRadius ), circleCenter + QPointF( circleRadius, circleRadius ) ); if ( direction == 1 ) { if ( angle_o < angle_d ) path.arcTo( circleRect, angle_o / M_PI * 180.0, ( angle_d - angle_o ) / M_PI * 180.0 ); else path.arcTo( circleRect, angle_o / M_PI * 180.0, 360.0 - ( angle_o - angle_d ) / M_PI * 180.0 ); } else { if ( angle_o < angle_d ) path.arcTo( circleRect, angle_o / M_PI * 180.0, - ( 360.0 - ( angle_d - angle_o ) / M_PI * 180.0 ) ); else path.arcTo( circleRect, angle_o / M_PI * 180.0, ( angle_d - angle_o ) / M_PI * 180.0 ); } }
void KiviatView::KiviatData::changeDataPoint(int axisNr, float newValue) { data[axisNr]=newValue; QPointF newPoint = view->calcPosition(axisNr,newValue); //Adjust corner point int rad=view->cornerPointRadius(); QRectF circleRect(0,0,rad,rad); circleRect.moveCenter(newPoint); cornerPoints[axisNr]->setRect(circleRect); //Adjust polygon QPolygonF fPoly = polygon->polygon(); fPoly[axisNr]=newPoint; polygon->setPolygon(fPoly); }