[Interest] QPainterPathStroker's curve threshold

Elvis Stansvik elvstone at gmail.com
Thu Dec 8 08:40:47 CET 2016


Den 8 dec. 2016 1:02 fm skrev "Ch'Gans" <chgans at gna.org>:
>
> Hi,
>
> The documentation of QPainterPathStroker's curve threshold says:
> ----------------------------------------------------------------
> Specifies the curve flattening threshold, controlling the granularity
> with which the generated outlines' curve is drawn.
>
> The default threshold is a well adjusted value (0.25), and normally
> you should not need to modify it. However, you can make the curve's
> appearance smoother by decreasing its value.
> ----------------------------------------------------------------
>
> However i have noticed that when used in a graphics scene with objects
> of small size, the default threshold value is obviously too big, eg a
> circle becomes a square!
>
> As the doc states that "normally you should not need to modify it", i
> was reluctant to change it, but then I realised that maybe this
> default value is actually well adjusted in the context of QWidget,
> where the unit of measure is "pixel". In a QGraphicsScene the unit is
> arbitrary.
> If I'm right, there could be potentially a problem as well if the
> scene object is too big, eg, a circle will be rendered as a regular
> polygon with thousands of edges. So it all boil down to find the
> correct threshold so that both small and big (in scene coordinates)
> will be rendered in the view (pixel coordinates), using say 26 edges
> polygon (icosikaihexagon [1][2] ;))
>
> Could anyone shed a bit of light on what "well adjusted" mean and how
> to actually adjust it to s specific use case? Is this threshold
> actually expressed in a pixel-related unit of measure? Is it a ratio
> of something (0.0 to 1.0) ?

I've been wondering the same actually, though it was a long time ago.

The QPainterPathStroker has no information about which scale you intend to
paint the path, so I guess like you say, it must make some assumption based
on pixel units and a regular screen size.

For details of how it adjusts this value I think you'll have to look at the
code. But maybe the docs should be extended a bit.

Elvis

>
> Thanks,
> Chris
>
> [1] https://www.voltage.com/math-2/approximating-a-circle-with-a-polygon/
> [2] http://mathforum.org/dr.math/faq/faq.polygon.names.html
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161208/eb614d72/attachment.html>


More information about the Interest mailing list