void toPieChart::editPrint ( void ) { TOPrinter printer; printer.setMinMax ( 1, 1 ); if ( printer.setup() ) { printer.setCreator ( "TOra" ); QPainter painter ( &printer ); QPaintDeviceMetrics metrics ( &printer ); QRect rect ( 0, 0, metrics.width(), metrics.height() ); paintChart ( &painter, rect ); } }
void CorrelationView::print(QPainter& printPainter,QPaintDeviceMetrics& metrics,bool whiteBackground){ printState = true; //Draw the double buffer (pixmap) by copying it into the printer device throught the painter. QRect viewportOld = QRect(viewport.left(),viewport.top(),viewport.width(),viewport.height()); //If the left margin is not visible (the user zoomed without taking it in his selection), the viewport and the printer //have the same size. QRect r((QRect)window); if(r.left() != 0) viewport = QRect(printPainter.viewport().left(),printPainter.viewport().top(),printPainter.viewport().width(),printPainter.viewport().height()-10); else viewport = QRect(printPainter.viewport().left() + XMARGIN,printPainter.viewport().top(),printPainter.viewport().width() - XMARGIN,printPainter.viewport().height()-10); //Set the window (part of the world I want to show) printPainter.setWindow(r.left(),r.top(),r.width()-1,r.height()-1);//hack because Qt QRect is used differently in this function //Set the viewport (part of the device I want to write on). //By default, the viewport is the same as the device's rectangle (contentsRec), taking a smaller //one will ensure that the legends (cluster ids) will not ovelap a correlogram. printPainter.setViewport(viewport); //Fill the background with the background color and ensure we draw the same portion of the world than on the screen QRect back = QRect(r.left(),r.top(),r.width(),r.height()); float heightRatio = (static_cast<float>(back.height())/static_cast<float>(metrics.height())); back.setBottom(r.top() + r.height() - 1 + static_cast<long>(10 * heightRatio)); float widthRatio = (static_cast<float>(back.width())/static_cast<float>(metrics.width())); if(r.left() == 0) back.setLeft(r.left() - static_cast<long>(XMARGIN * widthRatio)); printRegion = QRegion(back); QColor colorLegendTmp = colorLegend; QColor background= backgroundColor(); if(whiteBackground){ colorLegend = black; setPaletteBackgroundColor(white); } printPainter.fillRect(back,backgroundColor()); printPainter.setClipRegion(printRegion,QPainter::CoordPainter); //Paint all the correlograms in the pairs list (in the double buffer) drawCorrelograms(printPainter,pairs); //reset transformation due to setWindow and setViewport printPainter.resetXForm(); //Draw the cluster Ids along the correlograms. drawClusterIds(printPainter); printPainter.setClipping(false); //Restore the colors. if(whiteBackground){ colorLegend = colorLegendTmp; setPaletteBackgroundColor(background); } //Restore the previous state viewport = QRect(viewportOld.left(),viewportOld.top(),viewportOld.width(),viewportOld.height()); printState = false; }