Commit b2b74d91 authored by Enrico Ros's avatar Enrico Ros

Adapted to annotations.h changes.

annotations.cpp is all commented out, need to work on that now.

svn path=/branches/kpdf_annotations/kdegraphics/kpdf/; revision=403222
parent eabe001f
This diff is collapsed.
......@@ -319,42 +319,14 @@ void KPDFPage::restoreLocalContents( const QDomNode & pageNode )
QDomElement annotElement = annotationNode.toElement();
annotationNode = annotationNode.nextSibling();
if ( !annotElement.hasAttribute( "type" ) )
continue;
// build annotation of given type
Annotation * annotation = 0;
int typeNumber = annotElement.attribute( "type" ).toInt();
switch ( typeNumber )
{
case Annotation::AWindow:
annotation = new WindowAnnotation( annotElement );
break;
case Annotation::AText:
annotation = new TextAnnotation( annotElement );
break;
case Annotation::ALine:
annotation = new LineAnnotation( annotElement );
break;
case Annotation::AGeom:
annotation = new GeomAnnotation( annotElement );
break;
case Annotation::AHighlight:
annotation = new HighlightAnnotation( annotElement );
break;
case Annotation::AStamp:
annotation = new StampAnnotation( annotElement );
break;
case Annotation::AInk:
annotation = new InkAnnotation( annotElement );
break;
}
// get annotation from the dom element
Annotation * annotation = AnnotationManager::createAnnotation( annotElement );
// append annotation to the list or show warning
if ( annotation )
m_annotations.append( annotation );
else
kdWarning() << "can't restore Annotation of type '" << typeNumber << "from XML." << endl;
kdWarning() << "page (" << m_number << "): can't restore an annotation from XML." << endl;
}
gettimeofday( &te, NULL );
double startTime = (double)ts.tv_sec + ((double)ts.tv_usec) / 1000000.0;
......@@ -406,15 +378,11 @@ void KPDFPage::saveLocalContents( QDomNode & parentNode, QDomDocument & document
// get annotation
const Annotation * a = *aIt;
// only save annotations created by us (not loaded from document)
if ( a->isApplied() )
continue;
// create annotation element and set type
QDomElement annotElement = document.createElement( "annotation" );
annotListElement.appendChild( annotElement );
annotElement.setAttribute( "type", (uint)a->subType() );
// add children and attributes to annotation element
a->store( annotElement, document );
addedAnnotations++;
if ( !a->flags & Annotation::External )
{
AnnotationManager::storeAnnotation( a, annotListElement, document );
addedAnnotations++;
}
}
// add number of children annotations as attribute
......@@ -453,6 +421,11 @@ NormalizedRect::NormalizedRect( const QRect & r, double xScale, double yScale )
: left( (double)r.left() / xScale ), top( (double)r.top() / yScale ),
right( (double)r.right() / xScale ), bottom( (double)r.bottom() / yScale ) {}
bool NormalizedRect::isNull() const
{
return left == 0 && top == 0 && right == 0 && bottom == 0;
}
bool NormalizedRect::contains( double x, double y ) const
{
return x >= left && x <= right && y >= top && y <= bottom;
......
......@@ -124,6 +124,7 @@ class NormalizedRect
NormalizedRect( double l, double t, double r, double b );
NormalizedRect( const QRect & r, double xScale, double yScale );
bool isNull() const;
bool contains( double x, double y ) const;
bool intersects( const NormalizedRect & normRect ) const;
bool intersects( double l, double t, double r, double b ) const;
......
......@@ -103,7 +103,7 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const KPDFPage * p
QValueList< Annotation * >::const_iterator aIt = page->m_annotations.begin(), aEnd = page->m_annotations.end();
for ( ; aIt != aEnd; ++aIt )
{
if ( (*aIt)->r.intersects( nXMin, nYMin, nXMax, nYMax ) )
if ( (*aIt)->boundary.intersects( nXMin, nYMin, nXMax, nYMax ) )
{
paintAnnotations = true;
break;
......@@ -245,7 +245,7 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const KPDFPage * p
for ( ; aIt != aEnd; ++aIt )
{
Annotation * a = *aIt;
QRect annotRect = a->r.geometry( scaledWidth, scaledHeight );
QRect annotRect = a->boundary.geometry( scaledWidth, scaledHeight );
// if annotation doesn't intersect paint region, skip it
if ( !annotRect.isValid() || !annotRect.intersects( limits ) )
......@@ -254,7 +254,7 @@ void PagePainter::paintPageOnPainter( QPainter * destPainter, const KPDFPage * p
// draw extents rectangle
if ( Settings::debugDrawAnnotationRect() )
{
mixedPainter->setPen( a->color );
mixedPainter->setPen( a->style.color );
mixedPainter->drawRect( annotRect );
}
......
......@@ -1879,7 +1879,7 @@ void PageView::slotMoveViewport()
return;
}
// move the viewport smoothly (kmplot: p(x)=x+x*(1-x)*(1-x))
// move the viewport smoothly (kmplot: p(x)=1+0.47*(x-1)^3-0.25*(x-1)^4)
float convergeSpeed = (float)diffTime / 667.0,
x = ((float)visibleWidth() / 2.0) + contentsX(),
y = ((float)visibleHeight() / 2.0) + contentsY(),
......
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