void PushButton::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { if (!styleSheet().isNull() || Theme::defaultTheme()->useNativeWidgetStyle()) { QGraphicsProxyWidget::paint(painter, option, widget); return; } QPixmap bufferPixmap; //Normal button, pressed or not if (isEnabled()) { if (nativeWidget()->isDown() || nativeWidget()->isChecked()) { d->background->setElementPrefix("pressed"); } else { d->background->setElementPrefix("normal"); } //flat or disabled } else if (!isEnabled() || nativeWidget()->isFlat()) { bufferPixmap = QPixmap(rect().size().toSize()); bufferPixmap.fill(Qt::transparent); QPainter buffPainter(&bufferPixmap); d->background->paintFrame(&buffPainter); buffPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); buffPainter.fillRect(bufferPixmap.rect(), QColor(0, 0, 0, 128)); painter->drawPixmap(0, 0, bufferPixmap); } //if is under mouse draw the animated glow overlay if (!nativeWidget()->isDown() && !nativeWidget()->isChecked() && isEnabled() && acceptHoverEvents() && d->background->hasElementPrefix("active")) { if (d->hoverAnimation->state() == QAbstractAnimation::Running && !isUnderMouse() && !nativeWidget()->isDefault()) { d->background->setElementPrefix("active"); d->background->paintFrame(painter, d->activeRect.topLeft()); } else { painter->drawPixmap( d->activeRect.topLeft(), d->hoverAnimation->property("currentPixmap").value<QPixmap>()); } } else if (isEnabled()) { d->background->paintFrame(painter); } painter->setPen(Plasma::Theme::defaultTheme()->color(Theme::ButtonTextColor)); if (nativeWidget()->isDown()) { painter->translate(QPoint(1, 1)); } QRectF rect = contentsRect(); if (!nativeWidget()->icon().isNull()) { const qreal iconSize = qMin(rect.width(), rect.height()); QPixmap iconPix = nativeWidget()->icon().pixmap(iconSize); if (!isEnabled()) { KIconEffect *effect = KIconLoader::global()->iconEffect(); iconPix = effect->apply(iconPix, KIconLoader::Toolbar, KIconLoader::DisabledState); } QRect pixmapRect; if (nativeWidget()->text().isEmpty()) { pixmapRect = nativeWidget()->style()->alignedRect(option->direction, Qt::AlignCenter, iconPix.size(), rect.toRect()); } else { pixmapRect = nativeWidget()->style()->alignedRect(option->direction, Qt::AlignLeft|Qt::AlignVCenter, iconPix.size(), rect.toRect()); } painter->drawPixmap(pixmapRect.topLeft(), iconPix); if (option->direction == Qt::LeftToRight) { rect.adjust(rect.height(), 0, 0, 0); } else { rect.adjust(0, 0, -rect.height(), 0); } } QFontMetricsF fm(font()); // If the height is too small increase the Height of the button to shall the whole text #192988 if (rect.height() < fm.height()) { rect.setHeight(fm.height()); rect.moveTop(boundingRect().center().y() - rect.height() / 2); } // If there is not enough room for the text make it to fade out if (rect.width() < fm.width(nativeWidget()->text())) { if (bufferPixmap.isNull()) { bufferPixmap = QPixmap(rect.size().toSize()); } bufferPixmap.fill(Qt::transparent); QPainter p(&bufferPixmap); p.setPen(painter->pen()); p.setFont(font()); // Create the alpha gradient for the fade out effect QLinearGradient alphaGradient(0, 0, 1, 0); alphaGradient.setCoordinateMode(QGradient::ObjectBoundingMode); if (option->direction == Qt::LeftToRight) { alphaGradient.setColorAt(0, QColor(0, 0, 0, 255)); alphaGradient.setColorAt(1, QColor(0, 0, 0, 0)); p.drawText(bufferPixmap.rect(), Qt::AlignLeft|Qt::AlignVCenter|Qt::TextShowMnemonic, nativeWidget()->text()); } else { alphaGradient.setColorAt(0, QColor(0, 0, 0, 0)); alphaGradient.setColorAt(1, QColor(0, 0, 0, 255)); p.drawText(bufferPixmap.rect(), Qt::AlignRight|Qt::AlignVCenter|Qt::TextShowMnemonic, nativeWidget()->text()); } p.setCompositionMode(QPainter::CompositionMode_DestinationIn); p.fillRect(bufferPixmap.rect(), alphaGradient); painter->drawPixmap(rect.topLeft(), bufferPixmap); } else { painter->setFont(font()); painter->drawText(rect, Qt::AlignCenter|Qt::TextShowMnemonic, nativeWidget()->text()); } }
//protected void MapGraphicsView::doTileLayout() { //Calculate the center point and polygon of the viewport in QGraphicsScene coordinates const QPointF centerPointQGS = _childView->mapToScene(_childView->width()/2.0, _childView->height()/2.0); QPolygon viewportPolygonQGV; viewportPolygonQGV << QPoint(0,0) << QPoint(0,_childView->height()) << QPoint(_childView->width(),_childView->height()) << QPoint(_childView->width(),0); const QPolygonF viewportPolygonQGS = _childView->mapToScene(viewportPolygonQGV); const QRectF boundingRect = viewportPolygonQGS.boundingRect(); //We exaggerate the bounding rect for some purposes! QRectF exaggeratedBoundingRect = boundingRect; exaggeratedBoundingRect.setSize(boundingRect.size()*2.0); exaggeratedBoundingRect.moveCenter(boundingRect.center()); //We'll mark tiles that aren't being displayed as free so we can use them QQueue<MapTileGraphicsObject *> freeTiles; QSet<QPointF> placesWhereTilesAre; foreach(MapTileGraphicsObject * tileObject, _tileObjects) { if (!tileObject->isVisible() || !exaggeratedBoundingRect.contains(tileObject->pos())) { freeTiles.enqueue(tileObject); tileObject->setVisible(false); } else placesWhereTilesAre.insert(tileObject->pos()); } const quint16 tileSize = _tileSource->tileSize(); const quint32 tilesPerRow = sqrt((long double)_tileSource->tilesOnZoomLevel(this->zoomLevel())); const quint32 tilesPerCol = tilesPerRow; const qint32 perSide = qMax(boundingRect.width()/tileSize, boundingRect.height()/tileSize) + 3; const qint32 xc = qMax((qint32)0, (qint32)(centerPointQGS.x() / tileSize) - perSide/2); const qint32 yc = qMax((qint32)0, (qint32)(centerPointQGS.y() / tileSize) - perSide/2); const qint32 xMax = qMin((qint32)tilesPerRow, xc + perSide); const qint32 yMax = qMin(yc + perSide, (qint32)tilesPerCol); for (qint32 x = xc; x < xMax; x++) { for (qint32 y = yc; y < yMax; y++) { const QPointF scenePos(x*tileSize + tileSize/2, y*tileSize + tileSize/2); bool tileIsThere = false; if (placesWhereTilesAre.contains(scenePos)) tileIsThere = true; if (tileIsThere) continue; //Just in case we're running low on free tiles, add one if (freeTiles.isEmpty()) { MapTileGraphicsObject * tileObject = new MapTileGraphicsObject(tileSize); tileObject->setTileSource(_tileSource); _tileObjects.insert(tileObject); _childScene->addItem(tileObject); freeTiles.enqueue(tileObject); } //Get the first free tile and make it do its thing MapTileGraphicsObject * tileObject = freeTiles.dequeue(); if (tileObject->pos() != scenePos) tileObject->setPos(scenePos); if (tileObject->isVisible() != true) tileObject->setVisible(true); tileObject->setTile(x,y,this->zoomLevel()); } } //If we've got a lot of free tiles left over, delete some of them while (freeTiles.size() > 2) { MapTileGraphicsObject * tileObject = freeTiles.dequeue(); _tileObjects.remove(tileObject); _childScene->removeItem(tileObject); delete tileObject; } }
scroll_widget::scroll_widget(const QRectF &a_rect, widget *parent) : widget(parent), o_scroll_widget(new Private) { o_scroll_widget->m_viewport = 0; QScroller::grabGesture(this, QScroller::LeftMouseButtonGesture); o_scroll_widget->m_size = a_rect.size(); }
void TileLayerItem::syncWithTileLayer() { const QRectF boundingRect = mRenderer->boundingRect(mLayer->bounds()); setPosition(boundingRect.topLeft()); setSize(boundingRect.size()); }
void QDeclarativeGraphicsGeoMap::geometryChanged(const QRectF &newGeometry, const QRectF & /*oldGeometry*/) { setSize(newGeometry.size()); }
/*! \brief Draw the raster data \param painter Painter \param xMap X-Scale Map \param yMap Y-Scale Map \param canvasRect Contents rect of the plot canvas */ void QwtPlotRasterItem::draw( QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect ) const { if ( canvasRect.isEmpty() || d_data->alpha == 0 ) return; const bool doCache = useCache( d_data->cache.policy, painter ); const QwtInterval xInterval = interval( Qt::XAxis ); const QwtInterval yInterval = interval( Qt::YAxis ); /* Scaling a rastered image always results in a loss of precision/quality. So we always render the image in paint device resolution. */ QwtScaleMap xxMap, yyMap; transformMaps( painter->transform(), xMap, yMap, xxMap, yyMap ); QRectF paintRect = painter->transform().mapRect( canvasRect ); QRectF area = QwtScaleMap::invTransform( xxMap, yyMap, paintRect ); const QRectF br = boundingRect(); if ( br.isValid() && !br.contains( area ) ) { area &= br; if ( !area.isValid() ) return; paintRect = QwtScaleMap::transform( xxMap, yyMap, area ); } QRectF imageRect; QImage image; QRectF pixelRect = pixelHint(area); if ( !pixelRect.isEmpty() ) { const QRectF r = QwtScaleMap::invTransform( xxMap, yyMap, QRectF(0, 0, 1, 1) ).normalized(); if ( r.width() > pixelRect.width() && r.height() > pixelRect.height() ) { /* When the resolution of the data pixels is higher than the resolution of the target device we render in target device resolution. */ pixelRect = QRectF(); } } if ( pixelRect.isEmpty() ) { if ( QwtPainter::roundingAlignment( painter ) ) { // we want to have maps, where the boundaries of // the aligned paint rectangle exactly match the area paintRect = qwtAlignRect(paintRect); adjustMaps(xxMap, yyMap, area, paintRect); } // When we have no information about position and size of // data pixels we render in resolution of the paint device. image = compose(xxMap, yyMap, area, paintRect, paintRect.size().toSize(), doCache); if ( image.isNull() ) return; // Remove pixels at the boundaries, when explicitly // excluded in the intervals imageRect = qwtStripRect(paintRect, area, xxMap, yyMap, xInterval, yInterval); if ( imageRect != paintRect ) { const QRect r( qRound( imageRect.x() - paintRect.x()), qRound( imageRect.y() - paintRect.y() ), qRound( imageRect.width() ), qRound( imageRect.height() ) ); image = image.copy(r); } } else { if ( QwtPainter::roundingAlignment( painter ) ) paintRect = qwtAlignRect(paintRect); // align the area to the data pixels QRectF imageArea = expandToPixels(area, pixelRect); if ( imageArea.right() == xInterval.maxValue() && !( xInterval.borderFlags() & QwtInterval::ExcludeMaximum ) ) { imageArea.adjust(0, 0, pixelRect.width(), 0); } if ( imageArea.bottom() == yInterval.maxValue() && !( yInterval.borderFlags() & QwtInterval::ExcludeMaximum ) ) { imageArea.adjust(0, 0, 0, pixelRect.height() ); } QSize imageSize; imageSize.setWidth( qRound( imageArea.width() / pixelRect.width() ) ); imageSize.setHeight( qRound( imageArea.height() / pixelRect.height() ) ); image = compose(xxMap, yyMap, imageArea, paintRect, imageSize, doCache ); if ( image.isNull() ) return; imageRect = qwtStripRect(paintRect, area, xxMap, yyMap, xInterval, yInterval); if ( ( image.width() > 1 || image.height() > 1 ) && testPaintAttribute( PaintInDeviceResolution ) ) { // Because of rounding errors the pixels // need to be expanded manually to rectangles of // different sizes image = qwtExpandImage(image, xxMap, yyMap, imageArea, area, paintRect, xInterval, yInterval ); } } painter->save(); painter->setWorldTransform( QTransform() ); QwtPainter::drawImage( painter, imageRect, image ); painter->restore(); }
void ORPrintRender::renderPage(ORODocument * pDocument, int pageNb, QPainter *painter, qreal xDpi, qreal yDpi, QSize margins, int printResolution) { OROPage * p = pDocument->page(pageNb); if(((!p->backgroundImage().isNull()) && (p->backgroundOpacity() != 0)) || ((!p->watermarkText().isEmpty()) && (p->watermarkOpacity() != 0))) { // Do some simple processing used by both Background and Watermark const int resolution = 100; bool doBgWm = false; int printMarginWidth = margins.width(); int printMarginHeight = margins.height(); QString pageSize = pDocument->pageOptions().getPageSize(); int pageWidth = 0; int pageHeight = 0; if(pageSize == "Custom") { // if this is custom sized sheet of paper we will just use those values pageWidth = (int)(pDocument->pageOptions().getCustomWidth() * resolution); pageHeight = (int)(pDocument->pageOptions().getCustomHeight() * resolution); } else { // lookup the correct size information for the specified size paper PageSizeInfo pi = PageSizeInfo::getByName(pageSize); if(!pi.isNull()) { pageWidth = (int)((pi.width() / 100.0) * resolution); pageHeight = (int)((pi.height() / 100.0) * resolution); } } if(!pDocument->pageOptions().isPortrait()) { int tmp = pageWidth; pageWidth = pageHeight; pageHeight = tmp; } if(pageWidth < 1 || pageHeight < 1) { // whoops we couldn't find it.... we will use the values from the painter // and add in the margins of the printer to get what should be the correct // size of the sheet of paper we are printing to. pageWidth = (int)(((painter->viewport().width() + printMarginWidth + printMarginWidth) / xDpi) * resolution); pageHeight = (int)(((painter->viewport().height() + printMarginHeight + printMarginHeight) / yDpi) * resolution); } QImage image = QImage(pageWidth, pageHeight, QImage::Format_RGB32); QPainter gPainter; if(gPainter.begin(&image)) gPainter.fillRect(gPainter.viewport(), QColor(Qt::white)); // Render Background if((!p->backgroundImage().isNull()) && (p->backgroundOpacity() != 0)) { doBgWm = true; QPointF ps = p->backgroundPosition(); QSizeF sz = p->backgroundSize(); QRectF rc = QRectF(ps.x() * resolution, ps.y() * resolution, sz.width() * resolution, sz.height() * resolution); renderBackground(image, p->backgroundImage(), rc.toRect(), p->backgroundScale(), p->backgroundScaleMode(), p->backgroundAlign(), p->backgroundOpacity()); } // Render Watermark if((!p->watermarkText().isEmpty()) && (p->watermarkOpacity() != 0)) { doBgWm = true; renderWatermark(image, p->watermarkText(), p->watermarkFont(), p->watermarkOpacity(), ((pDocument->pageOptions().getMarginLeft() + pDocument->pageOptions().getMarginRight()) * resolution), ((pDocument->pageOptions().getMarginTop() + pDocument->pageOptions().getMarginBottom()) * resolution), pDocument->pageOptions().getMarginLeft() * resolution, pDocument->pageOptions().getMarginTop() * resolution); } if(doBgWm) { QRectF target(-printMarginWidth, -printMarginHeight, (painter->viewport().width() + printMarginWidth + printMarginWidth), (painter->viewport().height() + printMarginHeight + printMarginHeight)); QRectF source(0, 0, image.width(), image.height()); painter->drawImage(target, image, source); } } // Render Page Objects for(int i = 0; i < p->primitives(); i++) { OROPrimitive * prim = p->primitive(i); QPen pen(prim->pen()); painter->save(); painter->setPen(pen); painter->setBrush(prim->brush()); if(prim->type() == OROTextBox::TextBox) { OROTextBox * tb = (OROTextBox*)prim; QPointF ps = tb->position(); QSizeF sz = tb->size(); QRectF rc = QRectF(ps.x() * xDpi, ps.y() * yDpi, sz.width() * xDpi, sz.height() * yDpi); painter->setFont(tb->font()); painter->drawText(rc, tb->flags(), tb->text()); } else if(prim->type() == OROLine::Line) { OROLine * ln = (OROLine*)prim; QPointF s = ln->startPoint(); QPointF e = ln->endPoint(); pen.setWidthF((ln->weight() / 100) * printResolution); painter->setPen(pen); painter->drawLine(QLineF(s.x() * xDpi, s.y() * yDpi, e.x() * xDpi, e.y() * yDpi)); } else if(prim->type() == OROImage::Image) { OROImage * im = (OROImage*)prim; QPointF ps = im->position(); QSizeF sz = im->size(); QRectF rc = QRectF(ps.x() * xDpi, ps.y() * yDpi, sz.width() * xDpi, sz.height() * yDpi); QImage img = im->image(); if(im->scaled()) img = img.scaled(rc.size().toSize(), (Qt::AspectRatioMode)im->aspectRatioMode(), (Qt::TransformationMode)im->transformationMode()); QRectF sr = QRectF(QPointF(0.0, 0.0), rc.size().boundedTo(img.size())); painter->drawImage(rc.topLeft(), img, sr); } else if(prim->type() == ORORect::Rect) { ORORect * re = (ORORect*)prim; QPointF ps = re->position(); QSizeF sz = re->size(); QRectF rc = QRectF(ps.x() * xDpi, ps.y() * yDpi, sz.width() * xDpi, sz.height() * yDpi); pen.setWidthF((re->weight() / 100) * printResolution); painter->setPen(pen); painter->drawRect(rc); } else { qDebug("unrecognized primitive type"); } painter->restore(); } }
void ORPrintRender::renderPage(ORODocument * pDocument, int pageNb, QPainter *painter, qreal xDpi, qreal yDpi, QSize margins, int printResolution) { OROPage * p = pDocument->page(pageNb); if(((!p->backgroundImage().isNull()) && (p->backgroundOpacity() != 0)) || ((!p->watermarkText().isEmpty()) && (p->watermarkOpacity() != 0))) { // Do some simple processing used by both Background and Watermark const int resolution = 100; bool doBgWm = false; int printMarginWidth = margins.width() < 0 ? 0 : margins.width(); int printMarginHeight = margins.height() < 0 ? 0 : margins.height(); QString pageSize = pDocument->pageOptions().getPageSize(); int pageWidth = 0; int pageHeight = 0; if(pageSize == "Custom") { // if this is custom sized sheet of paper we will just use those values pageWidth = (int)(pDocument->pageOptions().getCustomWidth() * resolution); pageHeight = (int)(pDocument->pageOptions().getCustomHeight() * resolution); } else { // lookup the correct size information for the specified size paper PageSizeInfo pi = PageSizeInfo::getByName(pageSize); if(!pi.isNull()) { pageWidth = (int)((pi.width() / 100.0) * resolution); pageHeight = (int)((pi.height() / 100.0) * resolution); } } if(!pDocument->pageOptions().isPortrait()) { int tmp = pageWidth; pageWidth = pageHeight; pageHeight = tmp; } if(pageWidth < 1 || pageHeight < 1) { // whoops we couldn't find it.... we will use the values from the painter // and add in the margins of the printer to get what should be the correct // size of the sheet of paper we are printing to. pageWidth = (int)(((painter->viewport().width() + printMarginWidth + printMarginWidth) / xDpi) * resolution); pageHeight = (int)(((painter->viewport().height() + printMarginHeight + printMarginHeight) / yDpi) * resolution); } QImage image = QImage(pageWidth, pageHeight, QImage::Format_RGB32); QPainter gPainter; if(gPainter.begin(&image)) gPainter.fillRect(gPainter.viewport(), QColor(Qt::white)); // Render Background if((!p->backgroundImage().isNull()) && (p->backgroundOpacity() != 0)) { doBgWm = true; QPointF ps = p->backgroundPosition(); QSizeF sz = p->backgroundSize(); QRectF rc = QRectF(ps.x() * resolution, ps.y() * resolution, sz.width() * resolution, sz.height() * resolution); renderBackground(image, p->backgroundImage(), rc.toRect(), p->backgroundScale(), p->backgroundScaleMode(), p->backgroundAlign(), p->backgroundOpacity()); } // Render Watermark if((!p->watermarkText().isEmpty()) && (p->watermarkOpacity() != 0)) { doBgWm = true; renderWatermark(image, p->watermarkText(), p->watermarkFont(), p->watermarkOpacity(), pDocument->pageOptions().getMarginLeft() * resolution, pDocument->pageOptions().getMarginRight() * resolution, pDocument->pageOptions().getMarginTop() * resolution, pDocument->pageOptions().getMarginBottom() * resolution); } if(doBgWm) { QRectF target(0, 0, pageWidth, pageHeight); painter->save(); painter->scale(xDpi / resolution, yDpi / resolution); QRectF source(0, 0, image.width(), image.height()); painter->drawImage(target, image, source); painter->restore(); } } // Render Page Objects for(int i = 0; i < p->primitives(); i++) { OROPrimitive * prim = p->primitive(i); QPen pen(prim->pen()); painter->save(); painter->setPen(pen); painter->setBrush(prim->brush()); QPointF ps = prim->position(); if(prim->rotationAxis().isNull()) { painter->translate(ps.x() * xDpi, ps.y() * yDpi); painter->rotate(prim->rotation()); // rotation around the origin of the primitive (not the center) } else { // rotation around the defined axis qreal xRot = prim->rotationAxis().x(); qreal yRot = prim->rotationAxis().y(); painter->translate(xRot * xDpi, yRot * yDpi); painter->rotate(prim->rotation()); painter->translate((ps.x() - xRot) * xDpi, (ps.y() - yRot) * yDpi); } if(prim->type() == OROTextBox::TextBox) { OROTextBox * tb = (OROTextBox*)prim; QSizeF sz = tb->size(); QRectF rc = QRectF(0, 0, sz.width() * xDpi, sz.height() * yDpi); prim->drawRect(rc, painter, printResolution); painter->setFont(tb->font()); QString text = tb->text(); QString url; if(tb->text().startsWith("<http")) { int endOfUrl = tb->text().indexOf('>'); if(endOfUrl > 0) { url = tb->text().mid(1, endOfUrl-1); text = tb->text().mid(endOfUrl+1); if(text.isEmpty()) text = url; } } bool toPdf = painter->paintEngine()->type() == QPaintEngine::Pdf; if(toPdf && !url.isEmpty()) { QTextDocument doc; QTextCursor cursor(&doc); QTextCharFormat format; format.setFont(tb->font()); format.setFontPointSize(tb->font().pointSizeF()*printResolution/100.0); format.setAnchor(true); format.setAnchorHref(url); cursor.insertText(text, format); doc.drawContents(painter); } else { painter->drawText(rc, tb->flags(), text); } } else if(prim->type() == OROBarcode::Barcode) { OROBarcode * bc = (OROBarcode*)prim; QSizeF sz = bc->size(); QRectF rc = QRectF(0, 0, sz.width() * xDpi, sz.height() * yDpi); if(painter->paintEngine()->type() == QPaintEngine::User) { // label paint engine: the barcode parameters are encoded in a text item QString encodedData = ReportPrinter::barcodePrefix() + QString("%1;%2;%3;%4").arg(bc->format()).arg(sz.height()).arg(bc->narrowBarWidth()).arg(bc->data()); painter->drawText(rc, 0, encodedData); } else { if(bc->format() == "3of9") render3of9(painter, xDpi, rc, bc->data(), bc); else if(bc->format() == "3of9+") renderExtended3of9(painter, xDpi, rc, bc->data(), bc); else if(bc->format() == "128") renderCode128(painter, xDpi, rc, bc->data(), bc); else if(bc->format() == "i2of5") renderI2of5(painter, xDpi, rc, bc->data(), bc); else if(bc->format() == "ean13") renderCodeEAN13(painter, xDpi, rc, bc->data(), bc); else if(bc->format() == "ean8") renderCodeEAN8(painter, xDpi, rc, bc->data(), bc); else if(bc->format() == "upc-a") renderCodeUPCA(painter, xDpi, rc, bc->data(), bc); else if(bc->format() == "upc-e") renderCodeUPCE(painter, xDpi, rc, bc->data(), bc); else if(bc->format().contains("datamatrix")) renderCodeDatamatrix(painter, rc, bc->data(), bc); else if(bc->format().contains("PDF417")) renderPDF417(painter, xDpi, rc, bc->data(), bc); else if(bc->format().contains("QR")) renderQR(painter, xDpi, rc, bc->data(), bc); else { painter->drawText(rc, 0, "ERR: [" + bc->format() + "]" + bc->data()); } } } else if(prim->type() == OROLine::Line) { OROLine * ln = (OROLine*)prim; QPointF s = ln->startPoint(); QPointF e = ln->endPoint(); pen.setWidthF((pen.widthF() / 100.0) * printResolution); painter->setPen(pen); painter->drawLine(QLineF(0, 0, (e.x()-s.x()) * xDpi, (e.y()-s.y()) * yDpi)); } else if(prim->type() == OROImage::Image) { OROImage * im = (OROImage*)prim; QSizeF sz = im->size(); QRectF rc = QRectF(0, 0, sz.width() * xDpi, sz.height() * yDpi); prim->drawRect(rc, painter, printResolution); QImage img = im->image(); if(im->scaled()) img = img.scaled(rc.size().toSize(), (Qt::AspectRatioMode)im->aspectRatioMode(), (Qt::TransformationMode)im->transformationMode()); else img = img.scaled(QSize(img.width()*(int)xDpi/150, img.height()*(int)yDpi/150), Qt::KeepAspectRatio); QRectF sr = QRectF(QPointF(0.0, 0.0), rc.size().boundedTo(img.size())); painter->drawImage(rc.topLeft(), img, sr); } else if(prim->type() == ORORect::Rect) { QSizeF sz = ((OROTextBox*)prim)->size(); QRectF rc = QRectF(0, 0, sz.width() * xDpi, sz.height() * yDpi); prim->drawRect(rc, painter, printResolution); } else { qDebug("unrecognized primitive type"); } painter->restore(); } }