source: trunk/src/opengl/gl2paintengineex/qtriangulator_p.h@ 944

Last change on this file since 944 was 846, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 5.2 KB
Line 
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 QtOpenGL module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
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
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QTRIANGULATOR_P_H
43#define QTRIANGULATOR_P_H
44
45//
46// W A R N I N G
47// -------------
48//
49// This file is not part of the Qt API. It exists purely as an
50// implementation detail. This header file may change from version to
51// version without notice, or even be removed.
52//
53// We mean it.
54//
55
56#include <QtCore/qvector.h>
57#include <QtGui/private/qvectorpath_p.h>
58
59QT_BEGIN_NAMESPACE
60
61class QVertexIndexVector
62{
63public:
64 enum Type {
65 UnsignedInt,
66 UnsignedShort
67 };
68
69 inline Type type() const { return t; }
70
71 inline void setDataUint(const QVector<quint32> &data)
72 {
73 t = UnsignedInt;
74 indices32 = data;
75 }
76
77 inline void setDataUshort(const QVector<quint16> &data)
78 {
79 t = UnsignedShort;
80 indices16 = data;
81 }
82
83 inline const void* data() const
84 {
85 if (t == UnsignedInt)
86 return indices32.data();
87 return indices16.data();
88 }
89
90 inline int size() const
91 {
92 if (t == UnsignedInt)
93 return indices32.size();
94 return indices16.size();
95 }
96
97 inline QVertexIndexVector &operator = (const QVertexIndexVector &other)
98 {
99 if (t == UnsignedInt)
100 indices32 = other.indices32;
101 else
102 indices16 = other.indices16;
103
104 return *this;
105 }
106
107private:
108
109 Type t;
110 QVector<quint32> indices32;
111 QVector<quint16> indices16;
112};
113
114struct QTriangleSet
115{
116 inline QTriangleSet() { }
117 inline QTriangleSet(const QTriangleSet &other) : vertices(other.vertices), indices(other.indices) { }
118 QTriangleSet &operator = (const QTriangleSet &other) {vertices = other.vertices; indices = other.indices; return *this;}
119
120 // The vertices of a triangle are given by: (x[i[n]], y[i[n]]), (x[j[n]], y[j[n]]), (x[k[n]], y[k[n]]), n = 0, 1, ...
121 QVector<qreal> vertices; // [x[0], y[0], x[1], y[1], x[2], ...]
122 QVertexIndexVector indices; // [i[0], j[0], k[0], i[1], j[1], k[1], i[2], ...]
123};
124
125struct QPolylineSet
126{
127 inline QPolylineSet() { }
128 inline QPolylineSet(const QPolylineSet &other) : vertices(other.vertices), indices(other.indices) { }
129 QPolylineSet &operator = (const QPolylineSet &other) {vertices = other.vertices; indices = other.indices; return *this;}
130
131 QVector<qreal> vertices; // [x[0], y[0], x[1], y[1], x[2], ...]
132 QVertexIndexVector indices;
133};
134
135// The vertex coordinates of the returned triangle set will be rounded to a grid with a mesh size
136// of 1/32. The polygon is first transformed, then scaled by 32, the coordinates are rounded to
137// integers, the polygon is triangulated, and then scaled back by 1/32.
138// 'hint' should be a combination of QVectorPath::Hints.
139// 'lod' is the level of detail. Default is 1. Curves are split into more lines when 'lod' is higher.
140QTriangleSet qTriangulate(const qreal *polygon, int count, uint hint = QVectorPath::PolygonHint | QVectorPath::OddEvenFill, const QTransform &matrix = QTransform());
141QTriangleSet qTriangulate(const QVectorPath &path, const QTransform &matrix = QTransform(), qreal lod = 1);
142QTriangleSet qTriangulate(const QPainterPath &path, const QTransform &matrix = QTransform(), qreal lod = 1);
143QPolylineSet qPolyline(const QVectorPath &path, const QTransform &matrix = QTransform(), qreal lod = 1);
144QPolylineSet qPolyline(const QPainterPath &path, const QTransform &matrix = QTransform(), qreal lod = 1);
145
146QT_END_NAMESPACE
147
148#endif
Note: See TracBrowser for help on using the repository browser.