1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:FDL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in a
|
---|
14 | ** written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Free Documentation License
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Free
|
---|
18 | ** Documentation License version 1.3 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file included in the packaging of this
|
---|
20 | ** file.
|
---|
21 | **
|
---|
22 | ** If you have questions regarding the use of this file, please contact
|
---|
23 | ** Nokia at [email protected].
|
---|
24 | ** $QT_END_LICENSE$
|
---|
25 | **
|
---|
26 | ****************************************************************************/
|
---|
27 |
|
---|
28 | /*!
|
---|
29 | \example painting/concentriccircles
|
---|
30 | \title Concentric Circles Example
|
---|
31 |
|
---|
32 | The Concentric Circles example shows the improved rendering
|
---|
33 | quality that can be obtained using floating point precision and
|
---|
34 | anti-aliasing when drawing custom widgets. The example also shows
|
---|
35 | how to do simple animations.
|
---|
36 |
|
---|
37 | The application's main window displays several widgets which are
|
---|
38 | drawn using the various combinations of precision and
|
---|
39 | anti-aliasing.
|
---|
40 |
|
---|
41 | \image concentriccircles-example.png
|
---|
42 |
|
---|
43 | Anti-aliasing is one of QPainter's render hints. The
|
---|
44 | QPainter::RenderHints are used to specify flags to QPainter that
|
---|
45 | may, or may not, be respected by any given
|
---|
46 | engine. QPainter::Antialiasing indicates that the engine should
|
---|
47 | anti-alias the edges of primitives if possible, i.e. put
|
---|
48 | additional pixels around the original ones to smooth the edges.
|
---|
49 |
|
---|
50 | The difference between floating point precision and integer
|
---|
51 | precision is a matter of accuracy, and is visible in the
|
---|
52 | application's main window: Even though the logic that is
|
---|
53 | calculating the circles' geometry is the same, floating points
|
---|
54 | ensure that the white spaces between each circle are of the same
|
---|
55 | size, while integers make two and two circles appear as if they
|
---|
56 | belong together. The reason is that the integer based precision
|
---|
57 | rely on rounding off non-integer calculations.
|
---|
58 |
|
---|
59 | The example consists of two classes:
|
---|
60 |
|
---|
61 | \list
|
---|
62 | \o \c CircleWidget is a custom widget which renders several animated
|
---|
63 | concentric circles.
|
---|
64 | \o \c Window is the application's main window displaying four \c
|
---|
65 | {CircleWidget}s drawn using different combinations of precision
|
---|
66 | and aliasing.
|
---|
67 | \endlist
|
---|
68 |
|
---|
69 | First we will review the CircleWidget class, then we will take a
|
---|
70 | look at the Window class.
|
---|
71 |
|
---|
72 | \section1 CircleWidget Class Definition
|
---|
|
---|