~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qpolygon.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/gui/painting/qpolygon.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QPolygon Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QPolygon Class Reference</h1>
 
21
<p>The QPolygon class provides a vector of points. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QPolygon&gt;</pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
 
23
<p>Inherits <a href="qvector.html">QVector&lt;QPoint&gt;</a>.</p>
 
24
<p>Inherited by <a href="q3pointarray.html">Q3PointArray</a>.</p>
 
25
<p><b>Note:</b> All the functions in this class are <a href="threads.html#reentrant">reentrant</a>.</p>
 
26
<ul>
 
27
<li><a href="qpolygon-members.html">List of all members, including inherited members</a></li>
 
28
</ul>
 
29
<a name="public-functions"></a>
 
30
<h3>Public Functions</h3>
 
31
<ul>
 
32
<li><div class="fn"/><b><a href="qpolygon.html#QPolygon">QPolygon</a></b> ()</li>
 
33
<li><div class="fn"/><b><a href="qpolygon.html#QPolygon-2">QPolygon</a></b> ( int <i>size</i> )</li>
 
34
<li><div class="fn"/><b><a href="qpolygon.html#QPolygon-3">QPolygon</a></b> ( const QPolygon &amp; <i>a</i> )</li>
 
35
<li><div class="fn"/><b><a href="qpolygon.html#QPolygon-4">QPolygon</a></b> ( const QVector&lt;QPoint&gt; &amp; <i>pts</i> )</li>
 
36
<li><div class="fn"/><b><a href="qpolygon.html#QPolygon-5">QPolygon</a></b> ( const QRect &amp; <i>r</i>, bool <i>closed</i> = false )</li>
 
37
<li><div class="fn"/><b><a href="qpolygon.html#dtor.QPolygon">~QPolygon</a></b> ()</li>
 
38
<li><div class="fn"/>QRect <b><a href="qpolygon.html#boundingRect">boundingRect</a></b> () const</li>
 
39
<li><div class="fn"/>void <b><a href="qpolygon.html#point">point</a></b> ( int <i>index</i>, int * <i>x</i>, int * <i>y</i> ) const</li>
 
40
<li><div class="fn"/>QPoint <b><a href="qpolygon.html#point-2">point</a></b> ( int <i>index</i> ) const</li>
 
41
<li><div class="fn"/>void <b><a href="qpolygon.html#putPoints">putPoints</a></b> ( int <i>index</i>, int <i>nPoints</i>, int <i>firstx</i>, int <i>firsty</i>, ... )</li>
 
42
<li><div class="fn"/>void <b><a href="qpolygon.html#putPoints-3">putPoints</a></b> ( int <i>index</i>, int <i>nPoints</i>, const QPolygon &amp; <i>from</i>, int <i>fromIndex</i> = 0 )</li>
 
43
<li><div class="fn"/>void <b><a href="qpolygon.html#setPoint">setPoint</a></b> ( int <i>index</i>, int <i>x</i>, int <i>y</i> )</li>
 
44
<li><div class="fn"/>void <b><a href="qpolygon.html#setPoint-2">setPoint</a></b> ( int <i>i</i>, const QPoint &amp; <i>p</i> )</li>
 
45
<li><div class="fn"/>void <b><a href="qpolygon.html#setPoints">setPoints</a></b> ( int <i>nPoints</i>, const int * <i>points</i> )</li>
 
46
<li><div class="fn"/>void <b><a href="qpolygon.html#setPoints-2">setPoints</a></b> ( int <i>nPoints</i>, int <i>firstx</i>, int <i>firsty</i>, ... )</li>
 
47
<li><div class="fn"/>void <b><a href="qpolygon.html#translate">translate</a></b> ( int <i>dx</i>, int <i>dy</i> )</li>
 
48
<li><div class="fn"/>void <b><a href="qpolygon.html#translate-2">translate</a></b> ( const QPoint &amp; <i>offset</i> )</li>
 
49
<li><div class="fn"/><b><a href="qpolygon.html#operator-QVariant">operator QVariant</a></b> () const</li>
 
50
</ul>
 
51
<ul>
 
52
<li><div class="fn"/>62 public functions inherited from <a href="qvector.html#public-functions">QVector</a></li>
 
53
</ul>
 
54
<h3>Additional Inherited Members</h3>
 
55
<ul>
 
56
<li><div class="fn"/>2 static public members inherited from <a href="qvector.html#static-public-members">QVector</a></li>
 
57
</ul>
 
58
<a name="details"></a>
 
59
<hr />
 
60
<h2>Detailed Description</h2>
 
61
<p>The QPolygon class provides a vector of points.</p>
 
62
<p>A QPolygon is a <a href="qvector.html">QVector</a>&lt;<a href="qpoint.html">QPoint</a>&gt;. It is <a href="shclass.html#implicitly-shared">implicitly shared</a>. In addition to the functions provided by <a href="qvector.html">QVector</a>, QPolygon provides some point-specific functions.</p>
 
63
<p>The easiest way to add points to a QPolygon is to use <a href="qvector.html">QVector</a>'s streaming operators, as illustrated below:</p>
 
64
<pre>&nbsp;           QPolygon polygon;
 
65
            polygon &lt;&lt; QPoint(10, 20) &lt;&lt; QPoint(20, 30);</pre>
 
66
<p>All other forms of manipulating a vector are available too, along with some compatibilty functions from Qt 3.</p>
 
67
<p>For geometry operations use <a href="qpolygon.html#boundingRect">boundingRect</a>() and <a href="qpolygon.html#translate">translate</a>(). There is also the <a href="qmatrix.html#map">QMatrix::map</a>() function for more general transformations of QPolygons.</p>
 
68
<p>Among others, QPolygon is used by <a href="qpainter-qt3.html#drawLineSegments">QPainter::drawLineSegments</a>(), <a href="qpainter.html#drawPolyline">QPainter::drawPolyline</a>(), <a href="qpainter.html#drawPolygon">QPainter::drawPolygon</a>() and <a href="qpainter-qt3.html#drawCubicBezier">QPainter::drawCubicBezier</a>().</p>
 
69
<p>See also <a href="qpainter.html">QPainter</a>, <a href="qmatrix.html">QMatrix</a>, <a href="qvector.html">QVector</a>, and <a href="qpolygonf.html">QPolygonF</a>.</p>
 
70
<hr />
 
71
<h2>Member Function Documentation</h2>
 
72
<h3 class="fn"><a name="QPolygon"></a>QPolygon::QPolygon ()</h3>
 
73
<p>Constructs an empty point array.</p>
 
74
<p>See also <a href="qvector.html#isEmpty">QVector::isEmpty</a>().</p>
 
75
<h3 class="fn"><a name="QPolygon-2"></a>QPolygon::QPolygon ( int <i>size</i> )</h3>
 
76
<p>Constructs a point array with room for <i>size</i> points. Makes an empty array if <i>size</i> == 0.</p>
 
77
<p>See also <a href="qvector.html#isEmpty">QVector::isEmpty</a>().</p>
 
78
<h3 class="fn"><a name="QPolygon-3"></a>QPolygon::QPolygon ( const QPolygon &amp; <i>a</i> )</h3>
 
79
<p>Constructs a copy of the point array <i>a</i>.</p>
 
80
<h3 class="fn"><a name="QPolygon-4"></a>QPolygon::QPolygon ( const <a href="qvector.html">QVector</a>&lt;<a href="qpoint.html">QPoint</a>&gt; &amp; <i>pts</i> )</h3>
 
81
<p>Constructs a pointarray containing a copy of the points specified in <i>pts</i>.</p>
 
82
<h3 class="fn"><a name="QPolygon-5"></a>QPolygon::QPolygon ( const <a href="qrect.html">QRect</a> &amp; <i>r</i>, bool <i>closed</i> = false )</h3>
 
83
<p>Constructs a point array from the rectangle <i>r</i>.</p>
 
84
<p>If <i>closed</i> is false, then the point array just contains the following four points of the rectangle ordered clockwise. The bottom-right point is located at (r.x() + r.width(), r.y() + r.height()).</p>
 
85
<p>If <i>closed</i> is true, then a fifth point is set to r.topLeft().</p>
 
86
<h3 class="fn"><a name="dtor.QPolygon"></a>QPolygon::~QPolygon ()</h3>
 
87
<p>Destroys the point array.</p>
 
88
<h3 class="fn"><a name="boundingRect"></a><a href="qrect.html">QRect</a> QPolygon::boundingRect () const</h3>
 
89
<p>Returns the bounding rectangle of the points in the array, or <a href="qrect.html">QRect</a>(0, 0, 0, 0) if the array is empty.</p>
 
90
<h3 class="fn"><a name="point"></a>void QPolygon::point ( int <i>index</i>, int * <i>x</i>, int * <i>y</i> ) const</h3>
 
91
<p>Reads the coordinates of the point at position <i>index</i> within the array and writes them into <tt>*</tt><i>x</i> and <tt>*</tt><i>y</i> if they are valid pointers.</p>
 
92
<h3 class="fn"><a name="point-2"></a><a href="qpoint.html">QPoint</a> QPolygon::point ( int <i>index</i> ) const</h3>
 
93
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
94
<p>Returns the point at position <i>index</i> within the array.</p>
 
95
<h3 class="fn"><a name="putPoints"></a>void QPolygon::putPoints ( int <i>index</i>, int <i>nPoints</i>, int <i>firstx</i>, int <i>firsty</i>, ... )</h3>
 
96
<p>Copies <i>nPoints</i> points from the variable argument list into this point array from position <i>index</i>, and resizes the point array if <tt>index+nPoints</tt> exceeds the size of the array.</p>
 
97
<p>The example code creates an array with three points (4,5), (6,7) and (8,9), by expanding the array from 1 to 3 points:</p>
 
98
<pre>&nbsp;           QPolygon polygon(1);
 
99
            polygon[0] = QPoint(4, 5);
 
100
            polygon.putPoints(1, 2, 6,7, 8,9); // index == 1, points == 2</pre>
 
101
<p>This has the same result, but here putPoints overwrites rather than extends:</p>
 
102
<pre>&nbsp;           QPolygon polygon(3);
 
103
            polygon.putPoints(0, 3, 4,5, 0,0, 8,9);
 
104
            polygon.putPoints(1, 1, 6,7);</pre>
 
105
<p>The points are given as a sequence of integers, starting with <i>firstx</i> then <i>firsty</i>, and so on.</p>
 
106
<p>See also <a href="qpolygon.html#setPoints">setPoints</a>().</p>
 
107
<h3 class="fn"><a name="putPoints-3"></a>void QPolygon::putPoints ( int <i>index</i>, int <i>nPoints</i>, const QPolygon &amp; <i>from</i>, int <i>fromIndex</i> = 0 )</h3>
 
108
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
109
<p>This version of the function copies <i>nPoints</i> from <i>from</i> into this array, starting at <i>index</i> in this array and <i>fromIndex</i> in <i>from</i>. <i>fromIndex</i> is 0 by default.</p>
 
110
<pre>&nbsp;           QPolygon polygon1;
 
111
            polygon1.putPoints(0, 3, 1,2, 0,0, 5,6);
 
112
            // polygon1 is now the three-point array (1,2, 0,0, 5,6);</pre>
 
113
<p>See also <a href="qpolygon.html#setPoints">setPoints</a>().</p>
 
114
<h3 class="fn"><a name="setPoint"></a>void QPolygon::setPoint ( int <i>index</i>, int <i>x</i>, int <i>y</i> )</h3>
 
115
<p>Sets the point at position <i>index</i> in the array to (<i>x</i>, <i>y</i>).</p>
 
116
<p>See also <a href="qpolygon.html#putPoints">putPoints</a>() and <a href="qpolygon.html#setPoints">setPoints</a>().</p>
 
117
<h3 class="fn"><a name="setPoint-2"></a>void QPolygon::setPoint ( int <i>i</i>, const <a href="qpoint.html">QPoint</a> &amp; <i>p</i> )</h3>
 
118
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
119
<p>Sets the point at array index <i>i</i> to <i>p</i>.</p>
 
120
<p>See also <a href="qpolygon.html#putPoints">putPoints</a>() and <a href="qpolygon.html#setPoints">setPoints</a>().</p>
 
121
<h3 class="fn"><a name="setPoints"></a>void QPolygon::setPoints ( int <i>nPoints</i>, const int * <i>points</i> )</h3>
 
122
<p>Resizes the array to <i>nPoints</i> and sets the points in the array to the values taken from <i>points</i>.</p>
 
123
<p>The example code creates an array with two points (10, 20) and (30, 40):</p>
 
124
<pre>&nbsp;           static const int points[] = { 10, 20, 30, 40 };
 
125
            QPolygon polygon;
 
126
            polygon.setPoints(2, points);</pre>
 
127
<p>See also <a href="qvector.html#resize">resize</a>(), <a href="qpolygon.html#setPoint">setPoint</a>(), and <a href="qpolygon.html#putPoints">putPoints</a>().</p>
 
128
<h3 class="fn"><a name="setPoints-2"></a>void QPolygon::setPoints ( int <i>nPoints</i>, int <i>firstx</i>, int <i>firsty</i>, ... )</h3>
 
129
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
130
<p>Resizes the array to <i>nPoints</i> and sets the points in the array to the values taken from the variable argument list.</p>
 
131
<p>The example code creates an array with two points (10, 20) and (30, 40):</p>
 
132
<pre>&nbsp;           QPolygon polygon;
 
133
            polygon.setPoints(2, 10, 20, 30, 40);</pre>
 
134
<p>The points are given as a sequence of integers, starting with <i>firstx</i> then <i>firsty</i>, and so on.</p>
 
135
<p>See also <a href="qvector.html#resize">resize</a>(), <a href="qpolygon.html#putPoints">putPoints</a>(), and <a href="qpolygon.html#setPoint">setPoint</a>().</p>
 
136
<h3 class="fn"><a name="translate"></a>void QPolygon::translate ( int <i>dx</i>, int <i>dy</i> )</h3>
 
137
<p>Translate all points in the array by (<i>dx</i>, <i>dy</i>).</p>
 
138
<h3 class="fn"><a name="translate-2"></a>void QPolygon::translate ( const <a href="qpoint.html">QPoint</a> &amp; <i>offset</i> )</h3>
 
139
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
140
<p>Translate all points in the array by <i>offset</i>.</p>
 
141
<h3 class="fn"><a name="operator-QVariant"></a>QPolygon::operator QVariant () const</h3>
 
142
<p>Returns the polygon as a <a href="qvariant.html">QVariant</a></p>
 
143
<p /><address><hr /><div align="center">
 
144
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
145
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
146
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
147
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
148
</tr></table></div></address></body>
 
149
</html>