[Okular] Bug 387282: Highlighting of search results lost when rotating page
ClosedPublic

Authored by ahmadosama on Apr 3 2018, 10:03 AM.

Details

Summary

The highlights were removed when rotating the page, also the RotaionJob::rotationMatrix function was not rotating the Highlihgts correctly.
I removed the deletion and modified the rotaionMatrix function by making it shorter and adding a translation after the rotatin. I tried different rotations and they are working fine.
BUG: 387282

Diff Detail

Repository
R223 Okular
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ahmadosama created this revision.Apr 3 2018, 10:03 AM
Restricted Application added a project: Okular. · View Herald TranscriptApr 3 2018, 10:03 AM
Restricted Application added a subscriber: Okular. · View Herald Transcript
ahmadosama requested review of this revision.Apr 3 2018, 10:03 AM
ngraham added a subscriber: ngraham.Apr 3 2018, 3:45 PM
aacid added a subscriber: aacid.Apr 3 2018, 10:19 PM

Isn't that translation breaking

RotationJobInternal::run

?

Why would you translate the image there?

Oh yes this may break it, I am thinking of adding another Boolean parameter to the RotationJob::rotationMatrix function with a default value of false to either translate or not
The function can be:
RotationJob::rotationMatrix( Rotation from, Rotation to, bool translate = false )

ahmadosama updated this revision to Diff 31291.Apr 4 2018, 12:26 PM

I added the boolean parameter to either translate or not.

aacid added a comment.Apr 5 2018, 10:46 PM

Oh yes this may break it, I am thinking of adding another Boolean parameter to the RotationJob::rotationMatrix function with a default value of false to either translate or not
The function can be:
RotationJob::rotationMatrix( Rotation from, Rotation to, bool translate = false )

I don't think that's a good idea, also the translations are a bit "random", why are they only 0 or 1?, i guess because you know the HighlightAreaRect are from 0 to 1, but that's knowledge that it's a bit "extra" to the rotationMatrix function.

Can you check if we simply should not be using RotationJob::rotationMatrix? the other objects in the loop above are transformed using a different matrix and those ones seem to work? Maybe you can use that one?

I tried rotating using ( const QTransform matrix = rotationMatrix() ) but it only works when rotating a page from its original orientation, this is why I modified the RotationJob::rotationMatrix in a way similar to Okular::buildRotationMatrix to allow rotating from different orientations.

aacid added a comment.Apr 7 2018, 9:59 AM

I tried rotating using ( const QTransform matrix = rotationMatrix() ) but it only works when rotating a page from its original orientation, this is why I modified the RotationJob::rotationMatrix in a way similar to Okular::buildRotationMatrix to allow rotating from different orientations.

So you mean that the rects in m_page->m_rects are not being rotated correctly either?

This comment was removed by ahmadosama.

As far as I know rotating m_page->m_rects should rotate annotations on the page, the annotations seem to work well when rotating them.

When rotating the highlights I tried to replace:
(*hlIt)->transform( RotationJob::rotationMatrix( oldRotation, m_rotation ) );
with
(*hlIt)->transform( matrix );

but highlights were rotated correctly only from the original orientation.

I am thinking of creating another function to get the rotation matrix for the highlights, or modify the Okular::buildRotationMatrix
as follows Okular::buildRotationMatrix(Rotation oldRotation = Rotation0, Rotation newRotation)

I am still going through the code to find a better way to solve this bug.

ahmadosama updated this revision to Diff 31856.Apr 11 2018, 8:40 AM

I used Okular::buildRotationMatrix to rotate the highlights, the rotation angle is specified in the rotateAt function

aacid accepted this revision.Apr 16 2018, 10:37 PM

Looks like it works, i'll commit in a minute (with a small improvement from my side).

I'd still like to know why m_rects and m_highlights need different transformation matrices.

This revision is now accepted and ready to land.Apr 16 2018, 10:37 PM
This revision was automatically updated to reflect the committed changes.

I will investigate more to find out why m_rects and m_highlights need different transformation matrices.