[Interest] QPainterPathStroker's curve threshold

Ch'Gans chgans at gna.org
Thu Dec 8 01:02:41 CET 2016


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) ?

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



More information about the Interest mailing list