void KoCreateShapeStrategy::paint(QPainter &painter, const KoViewConverter &converter) { if (m_outline.isEmpty()) KoShapeRubberSelectStrategy::paint(painter, converter); else { painter.save(); painter.setRenderHint(QPainter::Antialiasing, false); QColor selectColor(Qt::blue); // TODO make configurable selectColor.setAlphaF(0.5); QBrush sb(selectColor, Qt::SolidPattern); painter.setPen(QPen(sb, 0)); painter.setBrush(sb); QRectF paintRect = converter.documentToView(selectRect()); qreal xscale = paintRect.width() / m_outlineBoundingRect.width(); qreal yscale = paintRect.height() / m_outlineBoundingRect.height(); QMatrix matrix; matrix.translate(-m_outlineBoundingRect.left(), -m_outlineBoundingRect.top()); matrix.scale(xscale, yscale); painter.translate(paintRect.left(), paintRect.top()); if (painter.hasClipping()) paintRect = paintRect.intersect(painter.clipRegion().boundingRect()); painter.setMatrix(matrix, true); painter.drawPath(m_outline); painter.restore(); } }
void MyPlotter::DrawYText(QPainter &painter) { QRect rect_y_text(0,draw_area_.top(),draw_area_.left(),draw_area_.height()); QRect rect_y_virtual(-rect_y_text.top(),rect_y_text.left(),-rect_y_text.height(),rect_y_text.width()); painter.setMatrix(QMatrix(0,-1,1,0,0,0)); //painter.drawRect(rect_y_virtual); painter.drawText(rect_y_virtual,Qt::AlignTop|Qt::AlignHCenter,y_text_); painter.resetMatrix(); }
void KarbonOutlinePaintingStrategy::paint( KoShape * shape, QPainter &painter, const KoViewConverter &converter, bool ) { painter.save(); painter.setMatrix( shape->absoluteTransformation(&converter) * painter.matrix() ); m_border->paintBorder( shape, painter, converter ); painter.restore(); }
void KoShapeManagerPaintingStrategy::paint(KoShape * shape, QPainter &painter, const KoViewConverter &converter, bool forPrint) { painter.save(); painter.setMatrix(shape->absoluteTransformation(&converter) * painter.matrix()); if (d->shapeManager) { d->shapeManager->paintShape(shape, painter, converter, forPrint); } painter.restore(); // for the matrix }
void KoParameterShape::paintHandle(QPainter & painter, const KoViewConverter & converter, int handleId, int handleRadius) { applyConversion(painter, converter); QMatrix worldMatrix = painter.worldMatrix(); painter.setMatrix(QMatrix()); QMatrix matrix; matrix.rotate(45.0); QPolygonF poly(handleRect(QPointF(0, 0), handleRadius)); poly = matrix.map(poly); poly.translate(worldMatrix.map(m_handles[handleId])); painter.drawPolygon(poly); }
void KPrShapeManagerAnimationStrategy::paint( KoShape * shape, QPainter &painter, const KoViewConverter &converter, bool forPrint ) { if ( ! dynamic_cast<KPrPlaceholderShape *>( shape ) ) { if ( m_animationDirector->shapeShown( shape ) ) { //kDebug() << shape; painter.save(); painter.setMatrix( shape->absoluteTransformation( &converter ) * painter.matrix() ); // animate shape QPair<KPrShapeAnimation *, KPrAnimationData *> animation = m_animationDirector->shapeAnimation( shape ); if ( animation.first ) { animation.first->animate( painter, converter, animation.second ); } // paint shape shapeManager()->paintShape( shape, painter, converter, forPrint ); painter.restore(); // for the matrix } } }
void KoParameterShape::paintHandles(QPainter & painter, const KoViewConverter & converter, int handleRadius) { applyConversion(painter, converter); QMatrix worldMatrix = painter.worldMatrix(); painter.setMatrix(QMatrix()); QMatrix matrix; matrix.rotate(45.0); QPolygonF poly(handleRect(QPointF(0, 0), handleRadius)); poly = matrix.map(poly); QList<QPointF>::const_iterator it(m_handles.constBegin()); for (; it != m_handles.constEnd(); ++it) { QPointF moveVector = worldMatrix.map(*it); poly.translate(moveVector.x(), moveVector.y()); painter.drawPolygon(poly); poly.translate(-moveVector.x(), -moveVector.y()); } }
void AccumulateEnergy::DrawAxeUPartText(QPainter &painter) { painter.save(); QPen pen; painter.setFont(QFont(QObject::tr("WenQuanYi"),10)); QRect rect_y_text(0,draw_area_range.top(),draw_area_range.left(),uheight_); QRect rect_y_virtual(-rect_y_text.top(),rect_y_text.left(),-rect_y_text.height(),rect_y_text.width()); QRect rect_y_text2(0,draw_area_range.top() + uheight_,draw_area_range.left(),dheight_); QRect rect_y_virtual2(-rect_y_text2.top(),rect_y_text2.left(),-rect_y_text2.height(),rect_y_text2.width()); painter.setMatrix(QMatrix(0,-1,1,0,0,0)); pen.setColor(Qt::black); painter.setPen(pen); //painter.drawRect(rect_y_virtual); painter.drawText(rect_y_virtual,Qt::AlignTop|Qt::AlignHCenter,STRING_GRAPHIC_ADVANCEMETER); pen.setColor(Qt::black); painter.setPen(pen); painter.drawText(rect_y_virtual2,Qt::AlignTop|Qt::AlignHCenter,STRING_GRAPHIC_EVNET_NUMBERS); painter.resetMatrix(); painter.restore(); }
void GeometryPainter::drawPolygon(QPainter& pt, const OGRPolygon* polygon, const QMatrix& m) { QPen pen = pt.pen(); QBrush brush = pt.brush(); if (polygon->getNumInteriorRings() > 0) { QPainter* lpt = NULL; QImage* image = new QImage(pt.window().size(), QImage::Format_ARGB32); if (image->isNull() == true) { delete image; throw Exception("Internal Error: GeometryPainter::drawPolygon " "Error allocating image."); } image->fill(qRgba(0, 0, 0, 0)); lpt = new QPainter(image); lpt->setMatrix(pt.matrix()); lpt->setPen(pen); lpt->setBrush(brush); const OGRLinearRing* ring = polygon->getExteriorRing(); QPolygonF qp; _convertRingToQPolygon(ring, qp, m); lpt->setPen(Qt::NoPen); lpt->setBrush(brush); lpt->drawPolygon(qp, Qt::WindingFill); lpt->setPen(pen); lpt->setBrush(Qt::NoBrush); lpt->drawPolygon(qp); for (int i = 0; i < polygon->getNumInteriorRings(); i++) { ring = polygon->getInteriorRing(i); // draw the appropriate border around the section we erased. _convertRingToQPolygon(ring, qp, m); // clear out the hole lpt->setPen(Qt::NoPen); lpt->setBrush(QColor(0, 0, 0, 0)); lpt->setCompositionMode(QPainter::CompositionMode_Clear); lpt->drawPolygon(qp, Qt::WindingFill); lpt->setPen(pen); lpt->setBrush(Qt::NoBrush); lpt->setCompositionMode(QPainter::CompositionMode_SourceOver); lpt->drawPolygon(qp, Qt::WindingFill); } lpt->end(); QMatrix m = pt.matrix(); pt.resetMatrix(); pt.drawImage(pt.window(), *image); pt.setMatrix(m); delete lpt; delete image; } else { const OGRLinearRing* ring = polygon->getExteriorRing(); QPolygonF qp; _convertRingToQPolygon(ring, qp, m); pt.setPen(Qt::NoPen); pt.setBrush(brush); pt.drawPolygon(qp, Qt::WindingFill); pt.setPen(pen); pt.setBrush(Qt::NoBrush); pt.drawPolygon(qp); } }
void MyRenderWidget::paintEvent(QPaintEvent * /*event*/ ) { QPainter painter; painter.begin(this); QColor color(0,0,0,255); QMatrix m,n; QString secstr = QString::number(sec); QString minstr = QString::number(min); QString hourstr = QString::number(hour); QFont font("Arial",12); painter.setFont(font); painter.drawText(200,75,hourstr); painter.drawText(250,75,minstr); painter.drawText(300,75,secstr); //Shadow m.reset(); m.translate(90,420); m.rotate(-35); m.shear(1,0.2); m.scale(0.5,0.5); painter.setMatrix(m); painter.setPen(Qt::gray); painter.setBrush(QColor(138, 121, 93,255)); painter.drawEllipse(100,100,300,300); //Background m.reset(); painter.setMatrix(m); painter.setPen(QColor(0,0,0,255)); painter.setBrush(QColor(16,23,33,255)); painter.drawEllipse(100,100,300,300); m.scale(0.8,0.8); painter.setMatrix(m); painter.setBrush(QColor(188,237,241,255)); painter.drawEllipse(165,163,300,300); //Number QPoint rotatedPoint; painter.setMatrix(m); for(int deg = 1; deg < 13; deg++){ m.reset(); m.translate(146,155); m.rotate(deg*30-135); rotatedPoint = QPoint(97,97)* m; n.reset(); n.translate(rotatedPoint.x(), rotatedPoint.y()); painter.setMatrix(n); painter.setPen(QColor(245,146,55,255)); QString hour = QString::number(deg); QFont font("Arial",12); painter.setFont(font); painter.drawText(100,100,hour); } //Second Hand m.reset(); m.translate(250,250); m.rotate(180+6*sec); m.translate(-100,-100); painter.setMatrix(m); painter.setPen(QColor(245,146,55,255)); painter.drawLine(99,100,99,220); //Minute Hand m.reset(); m.translate(250,250); m.rotate(-90+6*min); m.translate(-100,-100); painter.setMatrix(m); painter.setPen(QColor(245,146,55,255)); painter.setBrush(QColor(245,146,55,255)); painter.drawRect(100,100,130,5); //Hour Hand m.reset(); m.translate(250,250); m.rotate(-90+30*hour+0.5*min); m.translate(-100,-100); painter.setMatrix(m); painter.setPen(QColor(245,146,55,255)); painter.setBrush(QColor(245,146,55,255)); painter.drawRect(100,100,100,10); //Center dot m.reset(); painter.setMatrix(m); painter.setPen(QColor(0,0,0,255)); painter.setBrush(QColor(16,23,33,255)); painter.drawEllipse(245,245,20,20); painter.end(); }