Bug 370217 - [frameworks] Line width of freehand annotation is resolution dependent
Summary: [frameworks] Line width of freehand annotation is resolution dependent
Status: RESOLVED WORKSFORME
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR minor
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-06 20:56 UTC by Oliver Sander
Modified: 2020-12-12 04:34 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Sander 2016-10-06 20:56:46 UTC
Try drawing a freehand annotation on a pdf document (F6 and then the third icon from the top).  You will see it appear while you draw.  Then as you lift off the pen / release the mouse button, it will disappear very briefly, and then reappear.  The bug is that the line also changes its width at the same moment.

Here is what I think is happening: the line is drawn by two different parts of the code before and after you release the mouse button.  While you draw, the line is drawn by a QPen object constructed in annotationtools.cpp:158.  The pen width is

    const qreal penWidth = m_annotElement.attribute( QStringLiteral("width"), QStringLiteral("1.0") ).toDouble();

from three lines above.  Once the mouse button is released, the line is redrawn by code somewhere else, and I haven't been able to find where.  I don't know how the pen width is computed there.

I played around with my screen resolution and it seems that the problem is that the first drawing code does not take screen resolution into account, while the second one does.  I am interested in debugging this further, but I need some help: where is the code that draws the freehand annotation after the initial drawing is completed?  I suppose that comparing the two will explain why the line widths differ.

Reproducible: Always
Comment 1 Oliver Sander 2016-10-13 08:45:41 UTC
Friendly ping :-)
Comment 2 Christoph Feck 2016-10-14 02:09:03 UTC
On the initial drawing, the tool uses the configured size as a screen pen width in pixels.
When the annotation is added to the document, it is rendered according to the zoom level. To fix it, you would have to take into account the current document zoom in the code you mentioned.
Comment 3 Oliver Sander 2016-10-16 19:10:19 UTC
Thanks for the hint.  I played around with this a little.  It seems that the initial drawing code is buggier than I though.  Simply multiplying the zoom factor to the pen width doesn't cut it.  You can witness the problems without patching okular: go to Options -> set up Okular -> Annotations -> freehand --> edit and set the line width to something large, like 20.  When I do this, the drawing becomes very blocky, the pen width is not constant anymore, and sometimes parts of what I draw are not shown.

Any ideas?  I may look some more into this, but currently I am out of ideas.
Comment 4 Albert Astals Cid 2016-10-29 11:54:29 UTC
is this really frameworks only?
Comment 5 Oliver Sander 2016-10-29 14:52:46 UTC
No, as I learned eventually this happens on master, too.

Actually, on master it is worse, because there, the line-while-you-draw always has width 1, irrespective of what the line width settings say.  Presumably that's because in annotationtools.cpp:153 it simply says

const SmoothPath path( points, QPen(m_engineColor, 1) );

(the '1' is the width).
Comment 6 Justin Zobel 2020-11-09 04:54:17 UTC
(In reply to Oliver Sander from comment #5)
> No, as I learned eventually this happens on master, too.
> 
> Actually, on master it is worse, because there, the line-while-you-draw
> always has width 1, irrespective of what the line width settings say. 
> Presumably that's because in annotationtools.cpp:153 it simply says
> 
> const SmoothPath path( points, QPen(m_engineColor, 1) );
> 
> (the '1' is the width).

Oliver were you able to identify and resolve this issue within the code?

Or can you confirm if this issue is still occurring or if this bug report can be marked as resolved, thanks.
Comment 7 Oliver Sander 2020-11-10 15:24:34 UTC
What I said in comment 5 is still valid.
Comment 8 Justin Zobel 2020-11-12 05:36:03 UTC
(In reply to Oliver Sander from comment #7)
> What I said in comment 5 is still valid.

Sorry I meant have you found a solution to the issue where you could provide a patch (merge request) to fix it.
Comment 9 Oliver Sander 2020-11-12 09:27:14 UTC
Sorry, but I never found the time to try that.
Comment 10 Justin Zobel 2020-11-12 21:08:29 UTC
(In reply to Oliver Sander from comment #9)
> Sorry, but I never found the time to try that.

I'm going to set this bug to needsinfo as you were the only one to report this issue. If you can, please test it, if not please let us know so we can close this bug report.
Comment 11 Bug Janitor Service 2020-11-27 04:34:00 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 12 Bug Janitor Service 2020-12-12 04:34:12 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!