Commit 37abd551 authored by Enrico Ros's avatar Enrico Ros

CVS_SILENT more naming changes

svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=402436
parent 52cf329f
......@@ -22,15 +22,15 @@
#include "core/annotations.h"
#include "conf/settings.h"
void PagePainter::paintPageOnPainter( const KPDFPage * page, int id, int flags,
QPainter * destPainter, int scaledWidth, int scaledHeight, const QRect & limits )
void PagePainter::paintPageOnPainter( QPainter * destPainter, const KPDFPage * page,
int pixID, int flags, int scaledWidth, int scaledHeight, const QRect & limits )
{
/** 1 - RETRIEVE THE 'PAGE+ID' PIXMAP OR A SIMILAR 'PAGE' ONE **/
const QPixmap * pixmap = 0;
// if a pixmap is present for given id, use it
if ( page->m_pixmaps.contains( id ) )
pixmap = page->m_pixmaps[ id ];
if ( page->m_pixmaps.contains( pixID ) )
pixmap = page->m_pixmaps[ pixID ];
// else find the closest match using pixmaps of other IDs (great optim!)
else if ( !page->m_pixmaps.isEmpty() )
......@@ -128,7 +128,7 @@ void PagePainter::paintPageOnPainter( const KPDFPage * page, int id, int flags,
else
{
QImage destImage;
scalePixmapOnImage( pixmap, destImage, scaledWidth, scaledHeight, limits );
scalePixmapOnImage( destImage, pixmap, scaledWidth, scaledHeight, limits );
destPainter->drawPixmap( limits.left(), limits.top(), destImage, 0, 0,
limits.width(),limits.height() );
}
......@@ -144,9 +144,9 @@ void PagePainter::paintPageOnPainter( const KPDFPage * page, int id, int flags,
// 4B.1. draw the page pixmap: normal or scaled
if ( pixmap->width() == scaledWidth && pixmap->height() == scaledHeight )
cropPixmapOnImage( pixmap, backImage, limits );
cropPixmapOnImage( backImage, pixmap, limits );
else
scalePixmapOnImage( pixmap, backImage, scaledWidth, scaledHeight, limits );
scalePixmapOnImage( backImage, pixmap, scaledWidth, scaledHeight, limits );
// 4B.2. modify pixmap following accessibility settings
if ( paintAccessibility )
......@@ -267,7 +267,7 @@ void PagePainter::paintPageOnPainter( const KPDFPage * page, int id, int flags,
{
QPixmap pic = DesktopIcon( "kpdf" );
//QImage destImage;
//scalePixmapOnImage( &pic, destImage, annotRect.width(), annotRect.height(), QRect(0,0,annotRect.width(), annotRect.height()) );
//scalePixmapOnImage( destImage, &pic, annotRect.width(), annotRect.height(), QRect(0,0,annotRect.width(), annotRect.height()) );
//mixedPainter->drawPixmap( annotRect.left(), annotRect.top(), destImage, 0, 0, annotRect.width(), annotRect.height() );
pic = pic.convertToImage().scale( annotRect.width(), annotRect.height() );
mixedPainter->drawPixmap( annotRect.left(), annotRect.top(), pic, 0, 0, annotRect.width(), annotRect.height() );
......@@ -319,7 +319,7 @@ void PagePainter::paintPageOnPainter( const KPDFPage * page, int id, int flags,
/** Private Helpers :: Pixmap conversion **/
void PagePainter::cropPixmapOnImage( const QPixmap * src, QImage & dest, const QRect & r )
void PagePainter::cropPixmapOnImage( QImage & dest, const QPixmap * src, const QRect & r )
{
// handle quickly the case in which the whole pixmap has to be converted
if ( r == QRect( 0, 0, src->width(), src->height() ) )
......@@ -335,7 +335,7 @@ void PagePainter::cropPixmapOnImage( const QPixmap * src, QImage & dest, const Q
}
}
void PagePainter::scalePixmapOnImage ( const QPixmap * src, QImage & dest,
void PagePainter::scalePixmapOnImage ( QImage & dest, const QPixmap * src,
int scaledWidth, int scaledHeight, const QRect & cropRect )
{
// {source, destination, scaling} params
......@@ -370,9 +370,5 @@ void PagePainter::scalePixmapOnImage ( const QPixmap * src, QImage & dest,
}
/** Private Helpers :: Image Drawing **/
void image_draw_line( const QImage & img, bool antiAlias = true )
{
}
//void image_draw_line( const QImage & img, bool antiAlias = true ) {}
......@@ -29,21 +29,19 @@ class PagePainter
// draw (using painter 'p') the 'page' requested by 'id' using features
// in 'flags'. 'limits' is the bounding rect of the paint operation,
// 'scaledWidth' and 'scaledHeight' the expected size of page contents
static void paintPageOnPainter( const KPDFPage * page, int id, int flags,
QPainter * p, int scaledWidth, int scaledHeight, const QRect & pageLimits );
//static void paintPageOnImage( const KPDFPage * page, int id, int flags,
// QPainter * p, int scaledWidth, int scaledHeight, const QRect & pageLimits );
static void paintPageOnPainter( QPainter * p, const KPDFPage * page, int pixID,
int flags, int scaledWidth, int scaledHeight, const QRect & pageLimits );
private:
// create an image taking the 'cropRect' portion of a pixmap. the
// cropRect must be inside the source pixmap
static void cropPixmapOnImage( const QPixmap * src, QImage & dest,
static void cropPixmapOnImage( QImage & dest, const QPixmap * src,
const QRect & cropRect );
// create an image taking the 'cropRect' portion of a pixmap scaled
// to 'scaledWidth' by 'scaledHeight' pixels. cropRect must be inside
// the QRect(0,0, scaledWidth,scaledHeight)
static void scalePixmapOnImage( const QPixmap * src, QImage & dest,
static void scalePixmapOnImage( QImage & dest, const QPixmap * src,
int scaledWidth, int scaledHeight, const QRect & cropRect );
};
......
......@@ -499,9 +499,8 @@ void PageView::viewportPaintEvent( QPaintEvent * pe )
pixmapPainter.translate( -contentsRect.left(), -contentsRect.top() );
// 1) Layer 0: paint items and clear bg on unpainted rects
paintItems( &pixmapPainter, contentsRect );
// 2) Layer 1: pixmap manipulated areas
// 3) Layer 2: paint (blend) transparent selection
drawDocumentOnPainter( contentsRect, &pixmapPainter );
// 2) Layer 1: paint (blend) transparent selection
if ( !selectionRect.isNull() && selectionRect.intersects( contentsRect ) &&
!selectionRectInternal.contains( contentsRect ) )
{
......@@ -524,7 +523,10 @@ void PageView::viewportPaintEvent( QPaintEvent * pe )
pixmapPainter.setPen( selBlendColor );
pixmapPainter.drawRect( selectionRect );
}
// 4) Layer 3: overlays
// 3) Layer 1: give annotator painting control
if ( d->annotator && d->annotator->routePaints( contentsRect ) )
d->annotator->routePaint( &pixmapPainter, contentsRect );
// 4) Layer 2: overlays
if ( Settings::debugDrawBoundaries() )
{
pixmapPainter.setPen( Qt::blue );
......@@ -538,16 +540,18 @@ void PageView::viewportPaintEvent( QPaintEvent * pe )
else
{
// 1) Layer 0: paint items and clear bg on unpainted rects
paintItems( &screenPainter, contentsRect );
// 2) Layer 1: opaque manipulated ares (filled / contours)
// 3) Layer 2: paint opaque selection
drawDocumentOnPainter( contentsRect, &screenPainter );
// 2) Layer 1: paint opaque selection
if ( !selectionRect.isNull() && selectionRect.intersects( contentsRect ) &&
!selectionRectInternal.contains( contentsRect ) )
{
screenPainter.setPen( palette().active().highlight().dark(110) );
screenPainter.drawRect( selectionRect );
}
// 4) Layer 3: overlays
// 3) Layer 1: give annotator painting control
if ( d->annotator && d->annotator->routePaints( contentsRect ) )
d->annotator->routePaint( &screenPainter, contentsRect );
// 4) Layer 2: overlays
if ( Settings::debugDrawBoundaries() )
{
screenPainter.setPen( Qt::red );
......@@ -1094,7 +1098,7 @@ void PageView::contentsMouseReleaseEvent( QMouseEvent * e )
QPixmap copyPix( selectionRect.width(), selectionRect.height() );
QPainter copyPainter( &copyPix );
copyPainter.translate( -selectionRect.left(), -selectionRect.top() );
paintItems( &copyPainter, selectionRect );
drawDocumentOnPainter( selectionRect, &copyPainter );
if ( choice == 3 )
{
......@@ -1249,7 +1253,7 @@ void PageView::dropEvent( QDropEvent * ev )
}
//END widget events
void PageView::paintItems( QPainter * p, const QRect & contentsRect )
void PageView::drawDocumentOnPainter( const QRect & contentsRect, QPainter * p )
{
// when checking if an Item is contained in contentsRect, instead of
// growing PageViewItems rects (for keeping outline into account), we
......@@ -1260,7 +1264,7 @@ void PageView::paintItems( QPainter * p, const QRect & contentsRect )
// create a region from wich we'll subtract painted rects
QRegion remainingArea( contentsRect );
//CHECK: QValueVector< PageViewItem * >::iterator iIt = d->visibleItems.begin(), iEnd = d->visibleItems.end();
// iterate over all items painting the ones intersecting contentsRect
QValueVector< PageViewItem * >::iterator iIt = d->items.begin(), iEnd = d->items.end();
for ( ; iIt != iEnd; ++iIt )
{
......@@ -1268,25 +1272,24 @@ void PageView::paintItems( QPainter * p, const QRect & contentsRect )
if ( !(*iIt)->geometry().intersects( checkRect ) )
continue;
// get item and item's outline geometries
PageViewItem * item = *iIt;
QRect pixmapGeometry = item->geometry();
QRect itemGeometry = item->geometry(),
outlineGeometry = itemGeometry;
outlineGeometry.addCoords( -1, -1, 3, 3 );
// translate the painter so we draw top-left pixmap corner in 0,0
// move the painter to the top-left corner of the page
p->save();
p->translate( pixmapGeometry.left(), pixmapGeometry.top() );
// item pixmap and outline geometry
QRect outlineGeometry = pixmapGeometry;
outlineGeometry.addCoords( -1, -1, 3, 3 );
p->translate( itemGeometry.left(), itemGeometry.top() );
// draw the page outline (little black border and 2px shadow)
if ( !pixmapGeometry.contains( contentsRect ) )
// draw the page outline (black border and 2px bottom-right shadow)
if ( !itemGeometry.contains( contentsRect ) )
{
int pixmapWidth = pixmapGeometry.width(),
pixmapHeight = pixmapGeometry.height();
int itemWidth = itemGeometry.width(),
itemHeight = itemGeometry.height();
// draw simple outline
p->setPen( Qt::black );
p->drawRect( -1, -1, pixmapWidth + 2, pixmapHeight + 2 );
p->drawRect( -1, -1, itemWidth + 2, itemHeight + 2 );
// draw bottom/right gradient
int levels = 2;
int r = Qt::gray.red() / (levels + 2),
......@@ -1295,25 +1298,24 @@ void PageView::paintItems( QPainter * p, const QRect & contentsRect )
for ( int i = 0; i < levels; i++ )
{
p->setPen( QColor( r * (i+2), g * (i+2), b * (i+2) ) );
p->drawLine( i, i + pixmapHeight + 1, i + pixmapWidth + 1, i + pixmapHeight + 1 );
p->drawLine( i + pixmapWidth + 1, i, i + pixmapWidth + 1, i + pixmapHeight );
p->drawLine( i, i + itemHeight + 1, i + itemWidth + 1, i + itemHeight + 1 );
p->drawLine( i + itemWidth + 1, i, i + itemWidth + 1, i + itemHeight );
p->setPen( Qt::gray );
p->drawLine( -1, i + pixmapHeight + 1, i - 1, i + pixmapHeight + 1 );
p->drawLine( i + pixmapWidth + 1, -1, i + pixmapWidth + 1, i - 1 );
p->drawLine( -1, i + itemHeight + 1, i - 1, i + itemHeight + 1 );
p->drawLine( i + itemWidth + 1, -1, i + itemWidth + 1, i - 1 );
}
}
// draw the page using the PagePainter whith all flags active
if ( contentsRect.intersects( pixmapGeometry ) )
if ( contentsRect.intersects( itemGeometry ) )
{
QRect pixmapRect = contentsRect.intersect( pixmapGeometry );
pixmapRect.moveBy( -pixmapGeometry.left(), -pixmapGeometry.top() );
QRect pixmapRect = contentsRect.intersect( itemGeometry );
pixmapRect.moveBy( -itemGeometry.left(), -itemGeometry.top() );
int flags = PagePainter::Accessibility | PagePainter::EnhanceLinks |
PagePainter::EnhanceImages | PagePainter::Highlights |
PagePainter::Annotations;
PagePainter::paintPageOnPainter( item->page(), PAGEVIEW_ID, flags, p,
pixmapGeometry.width(), pixmapGeometry.height(),
pixmapRect );
PagePainter::paintPageOnPainter( p, item->page(), PAGEVIEW_ID, flags,
itemGeometry.width(), itemGeometry.height(), pixmapRect );
}
// remove painted area from 'remainingArea' and restore painter
......@@ -1321,16 +1323,12 @@ void PageView::paintItems( QPainter * p, const QRect & contentsRect )
p->restore();
}
// paint with background color the unpainted area
// fill with background color the unpainted area
QMemArray<QRect> backRects = remainingArea.rects();
uint backRectsNumber = backRects.count();
QColor backColor = /*d->items.isEmpty() ? Qt::lightGray :*/ Qt::gray;
for ( uint jr = 0; jr < backRectsNumber; jr++ )
p->fillRect( backRects[ jr ], backColor );
// paint annotation being created by the annotator
if ( d->annotator && d->annotator->routePaints( contentsRect ) )
d->annotator->routePaint( p, contentsRect );
}
void PageView::updateItemSize( PageViewItem * item, int colWidth, int rowHeight )
......
......@@ -85,8 +85,8 @@ class PageView : public QScrollView, public DocumentObserver
void dropEvent( QDropEvent* );
private:
// draw items on the opened qpainter
void paintItems( QPainter * p, const QRect & clipRect );
// draw background and items on the opened qpainter
void drawDocumentOnPainter( const QRect & pageViewRect, QPainter * p );
// update item width and height using current zoom parameters
void updateItemSize( PageViewItem * item, int columnWidth, int rowHeight );
// return the widget placed on a certain point or 0 if clicking on empty space
......
......@@ -447,8 +447,8 @@ void PresentationWidget::generateContentsPage( int pageNum, QPainter & p )
// draw the page using the shared PagePainter class
int flags = PagePainter::Accessibility;
PagePainter::paintPageOnPainter( frame->page, PRESENTATION_ID, flags,
&p, geom.width(), geom.height(), geom );
PagePainter::paintPageOnPainter( &p, frame->page, PRESENTATION_ID, flags,
geom.width(), geom.height(), geom );
// restore painter
p.translate( -frame->geometry.left(), -frame->geometry.top() );
......
......@@ -510,7 +510,7 @@ void ThumbnailWidget::paintEvent( QPaintEvent * e )
{
int flags = PagePainter::Accessibility | PagePainter::Highlights |
PagePainter::Annotations;
PagePainter::paintPageOnPainter( m_page, THUMBNAILS_ID, flags, &p,
PagePainter::paintPageOnPainter( &p, m_page, THUMBNAILS_ID, flags,
m_pixmapWidth, m_pixmapHeight, clipRect );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment