Doc: improve Mandelbrot example
Change-Id: Iac6c3e681f3d5b195d08513ac5fe4b661c3d0f59 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
parent
621ab8ab59
commit
e04b85b026
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
The heavy computation here is the Mandelbrot set, probably the
|
The heavy computation here is the Mandelbrot set, probably the
|
||||||
world's most famous fractal. These days, while sophisticated
|
world's most famous fractal. These days, while sophisticated
|
||||||
programs such as \l{http://xaos.sourceforge.net/}{XaoS} that provide real-time zooming in the
|
programs such as \l{http://matek.hu/xaos/doku.php}{XaoS} that provide real-time zooming in the
|
||||||
Mandelbrot set, the standard Mandelbrot algorithm is just slow
|
Mandelbrot set, the standard Mandelbrot algorithm is just slow
|
||||||
enough for our purposes.
|
enough for our purposes.
|
||||||
|
|
||||||
@ -201,7 +201,7 @@
|
|||||||
\snippet threads/mandelbrot/renderthread.cpp 9
|
\snippet threads/mandelbrot/renderthread.cpp 9
|
||||||
|
|
||||||
Once we're done with all the iterations, we call
|
Once we're done with all the iterations, we call
|
||||||
QWaitCondition::wait() to put the thread to sleep by calling,
|
QWaitCondition::wait() to put the thread to sleep,
|
||||||
unless \c restart is \c true. There's no use in keeping a worker
|
unless \c restart is \c true. There's no use in keeping a worker
|
||||||
thread looping indefinitely while there's nothing to do.
|
thread looping indefinitely while there's nothing to do.
|
||||||
|
|
||||||
@ -232,7 +232,7 @@
|
|||||||
|
|
||||||
\snippet threads/mandelbrot/mandelbrotwidget.cpp 0
|
\snippet threads/mandelbrot/mandelbrotwidget.cpp 0
|
||||||
|
|
||||||
The implementation starts with a few contants that we'll need
|
The implementation starts with a few constants that we'll need
|
||||||
later on.
|
later on.
|
||||||
|
|
||||||
\snippet threads/mandelbrot/mandelbrotwidget.cpp 1
|
\snippet threads/mandelbrot/mandelbrotwidget.cpp 1
|
||||||
@ -256,15 +256,15 @@
|
|||||||
slot later on. Qt knows how to take of copy of many C++ and Qt
|
slot later on. Qt knows how to take of copy of many C++ and Qt
|
||||||
types, but QImage isn't one of them. We must therefore call the
|
types, but QImage isn't one of them. We must therefore call the
|
||||||
template function qRegisterMetaType() before we can use QImage
|
template function qRegisterMetaType() before we can use QImage
|
||||||
as parameter in queued connections.
|
as a parameter in queued connections.
|
||||||
|
|
||||||
\snippet threads/mandelbrot/mandelbrotwidget.cpp 2
|
\snippet threads/mandelbrot/mandelbrotwidget.cpp 2
|
||||||
\snippet threads/mandelbrot/mandelbrotwidget.cpp 3
|
\snippet threads/mandelbrot/mandelbrotwidget.cpp 3
|
||||||
\snippet threads/mandelbrot/mandelbrotwidget.cpp 4
|
\snippet threads/mandelbrot/mandelbrotwidget.cpp 4
|
||||||
|
|
||||||
In \l{QWidget::paintEvent()}{paintEvent()}, we start by filling
|
In \l{QWidget::paintEvent()}{paintEvent()}, we start by filling
|
||||||
the background with black. If we have nothing yet to paint (\c
|
the background with black. If we have nothing to paint yet (\c
|
||||||
pixmap is null), we print a message on the widget asking the user
|
pixmap is null), we display a message on the widget asking the user
|
||||||
to be patient and return from the function immediately.
|
to be patient and return from the function immediately.
|
||||||
|
|
||||||
\snippet threads/mandelbrot/mandelbrotwidget.cpp 5
|
\snippet threads/mandelbrot/mandelbrotwidget.cpp 5
|
||||||
@ -293,7 +293,7 @@
|
|||||||
|
|
||||||
Notice that we rely on \c resizeEvent() being automatically
|
Notice that we rely on \c resizeEvent() being automatically
|
||||||
called by Qt when the widget is shown the first time to generate
|
called by Qt when the widget is shown the first time to generate
|
||||||
the image the very first time.
|
the initial image.
|
||||||
|
|
||||||
\snippet threads/mandelbrot/mandelbrotwidget.cpp 11
|
\snippet threads/mandelbrot/mandelbrotwidget.cpp 11
|
||||||
|
|
||||||
@ -307,7 +307,7 @@
|
|||||||
control the zoom level. QWheelEvent::delta() returns the angle of
|
control the zoom level. QWheelEvent::delta() returns the angle of
|
||||||
the wheel mouse movement, in eights of a degree. For most mice,
|
the wheel mouse movement, in eights of a degree. For most mice,
|
||||||
one wheel step corresponds to 15 degrees. We find out how many
|
one wheel step corresponds to 15 degrees. We find out how many
|
||||||
mouse steps we have and determine the zoom factor in consequence.
|
mouse steps we have and determine the resulting zoom factor.
|
||||||
For example, if we have two wheel steps in the positive direction
|
For example, if we have two wheel steps in the positive direction
|
||||||
(i.e., +30 degrees), the zoom factor becomes \c ZoomInFactor
|
(i.e., +30 degrees), the zoom factor becomes \c ZoomInFactor
|
||||||
to the second power, i.e. 0.8 * 0.8 = 0.64.
|
to the second power, i.e. 0.8 * 0.8 = 0.64.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user