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
Details
- Reviewers
aacid - Group Reviewers
Okular - Commits
- R223:6a2ed4f3144b: [Okular] Bug 387282: Highlighting of search results lost when rotating page
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.
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 )
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.
So you mean that the rects in m_page->m_rects are not being rotated correctly either?
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.
I used Okular::buildRotationMatrix to rotate the highlights, the rotation angle is specified in the rotateAt function
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.
I will investigate more to find out why m_rects and m_highlights need different transformation matrices.