Commit aa8155f8 authored by Pino Toscano's avatar Pino Toscano

decouple the transformation applying and resetting methods, and reset the...

decouple the transformation applying and resetting methods, and reset the transformation when setting a new bonding rect or translating

svn path=/trunk/KDE/kdegraphics/okular/; revision=691056
parent 857d423c
......@@ -630,12 +630,11 @@ void Annotation::setBoundingRectangle( const NormalizedRect &rectangle )
{
Q_D( Annotation );
d->m_boundary = rectangle;
d->resetTransformation();
if ( d->m_page )
{
d->transform( d->m_page->rotationMatrix() );
}
else
d->m_transformedBoundary = d->m_boundary;
}
NormalizedRect Annotation::boundingRectangle() const
......@@ -654,12 +653,11 @@ void Annotation::translate( const NormalizedPoint &coord )
{
Q_D( Annotation );
d->translate( coord );
d->resetTransformation();
if ( d->m_page )
{
d->transform( d->m_page->rotationMatrix() );
}
else
d->m_transformedBoundary = d->m_boundary;
}
Annotation::SubType Annotation::subType() const
......@@ -804,12 +802,22 @@ void Annotation::store( QDomNode & annNode, QDomDocument & document ) const
}
}
void AnnotationPrivate::annotationTransform( const QMatrix &matrix )
{
resetTransformation();
transform( matrix );
}
void AnnotationPrivate::transform( const QMatrix &matrix )
{
m_transformedBoundary = m_boundary;
m_transformedBoundary.transform( matrix );
}
void AnnotationPrivate::resetTransformation()
{
m_transformedBoundary = m_boundary;
}
void AnnotationPrivate::translate( const NormalizedPoint &coord )
{
m_boundary.left = m_boundary.left + coord.x;
......@@ -834,6 +842,7 @@ class Okular::TextAnnotationPrivate : public Okular::AnnotationPrivate
}
virtual void transform( const QMatrix &matrix );
virtual void resetTransformation();
virtual void translate( const NormalizedPoint &coord );
TextAnnotation::TextType m_textType;
......@@ -1067,11 +1076,19 @@ void TextAnnotationPrivate::transform( const QMatrix &matrix )
AnnotationPrivate::transform( matrix );
for ( int i = 0; i < 3; ++i ) {
m_transformedInplaceCallout[i] = m_inplaceCallout[i];
m_transformedInplaceCallout[i].transform( matrix );
}
}
void TextAnnotationPrivate::resetTransformation()
{
AnnotationPrivate::resetTransformation();
for ( int i = 0; i < 3; ++i ) {
m_transformedInplaceCallout[i] = m_inplaceCallout[i];
}
}
void TextAnnotationPrivate::translate( const NormalizedPoint &coord )
{
AnnotationPrivate::translate( coord );
......@@ -1101,6 +1118,7 @@ class Okular::LineAnnotationPrivate : public Okular::AnnotationPrivate
}
virtual void transform( const QMatrix &matrix );
virtual void resetTransformation();
virtual void translate( const NormalizedPoint &coord );
QLinkedList<NormalizedPoint> m_linePoints;
......@@ -1346,13 +1364,18 @@ void LineAnnotationPrivate::transform( const QMatrix &matrix )
{
AnnotationPrivate::transform( matrix );
m_transformedLinePoints = m_linePoints;
QMutableLinkedListIterator<NormalizedPoint> it( m_transformedLinePoints );
while ( it.hasNext() )
it.next().transform( matrix );
}
void LineAnnotationPrivate::resetTransformation()
{
AnnotationPrivate::resetTransformation();
m_transformedLinePoints = m_linePoints;
}
void LineAnnotationPrivate::translate( const NormalizedPoint &coord )
{
AnnotationPrivate::translate( coord );
......@@ -1804,6 +1827,7 @@ class Okular::InkAnnotationPrivate : public Okular::AnnotationPrivate
}
virtual void transform( const QMatrix &matrix );
virtual void resetTransformation();
virtual void translate( const NormalizedPoint &coord );
QList< QLinkedList<NormalizedPoint> > m_inkPaths;
......@@ -1930,8 +1954,6 @@ void InkAnnotationPrivate::transform( const QMatrix &matrix )
{
AnnotationPrivate::transform( matrix );
m_transformedInkPaths = m_inkPaths;
for ( int i = 0; i < m_transformedInkPaths.count(); ++i )
{
QMutableLinkedListIterator<NormalizedPoint> it( m_transformedInkPaths[ i ] );
......@@ -1940,6 +1962,13 @@ void InkAnnotationPrivate::transform( const QMatrix &matrix )
}
}
void InkAnnotationPrivate::resetTransformation()
{
AnnotationPrivate::resetTransformation();
m_transformedInkPaths = m_inkPaths;
}
void InkAnnotationPrivate::translate( const NormalizedPoint &coord )
{
AnnotationPrivate::translate( coord );
......
......@@ -35,7 +35,10 @@ class AnnotationPrivate
* Transforms the annotation coordinates with the transformation
* defined by @p matrix.
*/
void annotationTransform( const QMatrix &matrix );
virtual void transform( const QMatrix &matrix );
virtual void resetTransformation();
virtual void translate( const NormalizedPoint &coord );
PagePrivate * m_page;
......
......@@ -320,7 +320,7 @@ AnnotationObjectRect::~AnnotationObjectRect()
void AnnotationObjectRect::transform( const QMatrix &matrix )
{
m_annotation->d_func()->transform( matrix );
m_annotation->d_func()->annotationTransform( matrix );
}
/** class SourceRefObjectRect **/
......
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