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 }
TransparencyLayer(const QPainter& p, int width, int height) { pixmap = new QPixmap(width, height); painter = new QPainter(pixmap); painter->setPen(p.pen()); painter->setBrush(p.brush()); painter->setMatrix(p.matrix()); #if QT_VERSION >= 0x040200 painter->setOpacity(p.opacity()); #endif painter->setFont(p.font()); painter->setCompositionMode(p.compositionMode()); painter->setClipPath(p.clipPath()); }
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 } } }
static void draw(unsigned icam, unsigned ncam, QPainter& painter, bool draw_fast) { if(draw_fast) { const QMatrix& matrix(painter.matrix()); // Determinant is product of eigenvalues const int r = int(floor(sqrt(fabs(matrix.det())))); const int x = int(round(matrix.dx()))-r; const int y = int(round(matrix.dy()))-r; const int d = 2*r; painter.setMatrixEnabled(false); painter.drawEllipse(QRect(x,y,d,d)); painter.setMatrixEnabled(true); } else { painter.drawEllipse(QRectF(-1,-1,2,2)); } }
void BezierCurve::drawPath(QPainter& painter, Object* object, QTransform transformation, bool simplified, bool showThinLines ) { QColor colour = object->getColour(colourNumber).colour; BezierCurve myCurve; if (isPartlySelected()) { myCurve = (transformed(transformation)); } else { myCurve = *this; } if ( variableWidth && !simplified && !invisible) { painter.setPen(QPen(QBrush(colour), 1, Qt::NoPen, Qt::RoundCap,Qt::RoundJoin)); painter.setBrush(colour); painter.drawPath(myCurve.getStrokedPath()); } else { qreal renderedWidth = width; if (simplified) { renderedWidth = 1.0/painter.matrix().m11(); } painter.setBrush(Qt::NoBrush); if ( invisible ) { if (showThinLines) { if (simplified) { // Set simplified lines to black for the fill function to define contours. painter.setPen(QPen(QBrush(Qt::black), renderedWidth, Qt::SolidLine, Qt::RoundCap,Qt::RoundJoin)); } else { painter.setPen(QPen(QBrush(colour), 0, Qt::DotLine, Qt::RoundCap,Qt::RoundJoin)); } } else { painter.setPen(Qt::NoPen); } } else { painter.setPen( QPen( QBrush( colour ), renderedWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) ); //painter.setPen( QPen( Qt::darkYellow , 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) ); } QPainterPath path = myCurve.getSimplePath(); painter.drawPath( path ); } if (!simplified) { // highlight the selected elements colour = QColor(100,100,255); // highlight colour painter.setBrush(Qt::NoBrush); qreal lineWidth = 1.5/painter.matrix().m11(); painter.setPen(QPen(QBrush(colour), lineWidth, Qt::SolidLine, Qt::RoundCap,Qt::RoundJoin)); if (isSelected()) painter.drawPath(myCurve.getSimplePath()); for(int i=-1; i< vertex.size(); i++) { if (isSelected(i)) { //painter.fillRect(myCurve.getVertex(i).x()-0.5*squareWidth, myCurve.getVertex(i).y()-0.5*squareWidth, squareWidth, squareWidth, colour); //painter.fillRect(QRectF(myCurve.getVertex(i).x()-0.5*squareWidth, myCurve.getVertex(i).y()-0.5*squareWidth, squareWidth, squareWidth), colour); /*painter.setFont( QFont("Arial", floor(12.0/painter.matrix().m11()), -1, false) ); //painter.drawText(myCurve.getVertex(i)+QPointF(4.0,0.0), QString::number(i)+"-"+QString::number(myCurve.getVertex(i).x())+","+QString::number(myCurve.getVertex(i).y())); QPointF normale = QPointF(4.0, 0.0); if (i>-1) { normale = (myCurve.getVertex(i)-myCurve.getC2(i)); } else { normale = (myCurve.getC1(i+1)-myCurve.getVertex(i)); } normale = QPointF(-normale.y(), normale.x()); normale = 8.0*normale/eLength(normale)/painter.matrix().m11(); painter.drawLine(myCurve.getVertex(i), myCurve.getVertex(i)+normale); painter.drawText(myCurve.getVertex(i)+2*normale, QString::number(i));*/ } } } }
void BezierCurve::drawPath(QPainter &painter, Object* object, QMatrix transformation, bool simplified, bool showThinLines, qreal opacity) { if(!simplified) painter.setOpacity(opacity); QColor colour = object->getColour(colourNumber).colour; //simplified = true; //if(selected) { painter.setMatrix(transformation); } else { painter.setMatrix(QMatrix()); } //QColor colour = object->getColour(colourNumber).colour; if(!simplified) painter.setOpacity(opacity); BezierCurve myCurve; if(isPartlySelected()) { myCurve = (transformed(transformation)); } else { myCurve = *this; } //if(variableWidth && !simplified && width != 0) { if( variableWidth && !simplified && !invisible) { painter.setPen(QPen(QBrush(colour), 1, Qt::NoPen, Qt::RoundCap,Qt::RoundJoin)); painter.setBrush(colour); painter.drawPath(myCurve.getStrokedPath()); /*QPen pen; pen.setColor(colour); QPointF P1 = origin; QPointF P2 = origin; for(int i=0; i<vertex.size(); i++) { P2 = getVertex(i); QPainterPath path; path.moveTo(P1); path.cubicTo(c1.at(i), c2.at(i), P2); pen.setWidthF( 2.0 * width * getPressure(i) ); pen.setCapStyle( Qt::RoundCap ); painter.setPen( pen ); painter.drawPath( path ); //painter.drawLine( P1, P2 ); P1 = P2; }*/ } else { qreal renderedWidth = width; if(simplified) { renderedWidth = 1.0/painter.matrix().m11(); } painter.setBrush(Qt::NoBrush); //if(width == 0 && !simplified) { if( invisible ) { // invisible && !simplified if(showThinLines) { if(simplified) { painter.setPen(QPen(QBrush(colour), renderedWidth, Qt::SolidLine, Qt::RoundCap,Qt::RoundJoin)); } else { painter.setPen(QPen(QBrush(colour), 0, Qt::DotLine, Qt::RoundCap,Qt::RoundJoin)); } } else { painter.setPen(Qt::NoPen); } } else { painter.setPen(QPen(QBrush(colour), renderedWidth, Qt::SolidLine, Qt::RoundCap,Qt::RoundJoin)); } painter.drawPath(myCurve.getSimplePath()); } if(!simplified) { // highlight the selected elements colour = QColor(100,100,255); // highlight colour painter.setBrush(Qt::NoBrush); qreal lineWidth = 1.5/painter.matrix().m11(); painter.setPen(QPen(QBrush(colour), lineWidth, Qt::SolidLine, Qt::RoundCap,Qt::RoundJoin)); if(isSelected()) painter.drawPath(myCurve.getSimplePath()); //qreal squareWidth = max(6.0, 1.2*myCurve.getWidth()); //squareWidth = squareWidth/painter.matrix().m11(); qreal squareWidth = 5.0/painter.matrix().m11(); for(int i=-1; i< vertex.size(); i++) { if(isSelected(i)) { //painter.fillRect(myCurve.getVertex(i).x()-0.5*squareWidth, myCurve.getVertex(i).y()-0.5*squareWidth, squareWidth, squareWidth, colour); //painter.fillRect(QRectF(myCurve.getVertex(i).x()-0.5*squareWidth, myCurve.getVertex(i).y()-0.5*squareWidth, squareWidth, squareWidth), colour); /*painter.setFont( QFont("Arial", floor(12.0/painter.matrix().m11()), -1, false) ); //painter.drawText(myCurve.getVertex(i)+QPointF(4.0,0.0), QString::number(i)+"-"+QString::number(myCurve.getVertex(i).x())+","+QString::number(myCurve.getVertex(i).y())); QPointF normale = QPointF(4.0, 0.0); if(i>-1) { normale = (myCurve.getVertex(i)-myCurve.getC2(i)); } else { normale = (myCurve.getC1(i+1)-myCurve.getVertex(i)); } normale = QPointF(-normale.y(), normale.x()); normale = 8.0*normale/eLength(normale)/painter.matrix().m11(); painter.drawLine(myCurve.getVertex(i), myCurve.getVertex(i)+normale); painter.drawText(myCurve.getVertex(i)+2*normale, QString::number(i));*/ } } } }
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); } }