KDStateMachineEditor API Documentation 2.1
Loading...
Searching...
No Matches
qopengl2pexvertexarray_p.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Digia. For licensing terms and
14** conditions see http://qt.digia.com/licensing. For further information
15** use the contact form at http://qt.digia.com/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Digia gives you certain additional
26** rights. These rights are described in the Digia Qt LGPL Exception
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28**
29** GNU General Public License Usage
30** Alternatively, this file may be used under the terms of the GNU
31** General Public License version 3.0 as published by the Free Software
32** Foundation and appearing in the file LICENSE.GPL included in the
33** packaging of this file. Please review the following information to
34** ensure the GNU General Public License version 3.0 requirements will be
35** met: https://www.gnu.org/copyleft/gpl.html.
36**
37**
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42//
43// W A R N I N G
44// -------------
45//
46// This file is not part of the Qt API. It exists purely as an
47// implementation detail. This header file may change from version to
48// version without notice, or even be removed.
49//
50// We mean it.
51//
52
53#ifndef QOPENGL2PEXVERTEXARRAY_P_H
54#define QOPENGL2PEXVERTEXARRAY_P_H
55
56#include <QRectF>
57
58#include <private/qdatabuffer_p.h>
59#include <private/qvectorpath_p.h>
60#include <private/qopenglcontext_p.h>
61
62QT_BEGIN_NAMESPACE
63
65{
66public:
67 QOpenGLPoint(GLfloat new_x, GLfloat new_y) :
68 x(new_x), y(new_y) {};
69
70 explicit QOpenGLPoint(QPointF p) :
71 x(p.x()), y(p.y()) {};
72
73 explicit QOpenGLPoint(const QPointF* p) :
74 x(p->x()), y(p->y()) {};
75
76 GLfloat x;
77 GLfloat y;
78
79 operator QPointF() {return QPointF(x,y);}
80 operator QPointF() const {return QPointF(x,y);}
81};
82
84
86{
87 explicit QOpenGLRect(const QRectF &r)
88 : left(r.left()), top(r.top()), right(r.right()), bottom(r.bottom()) {}
89
90 QOpenGLRect(GLfloat l, GLfloat t, GLfloat r, GLfloat b)
91 : left(l), top(t), right(r), bottom(b) {}
92
93 GLfloat left;
94 GLfloat top;
95 GLfloat right;
96 GLfloat bottom;
97
98 operator QRectF() const {return QRectF(left, top, right-left, bottom-top);}
99};
100
102
104{
105public:
107 vertexArray(0), vertexArrayStops(0),
108 maxX(-2e10), maxY(-2e10), minX(2e10), minY(2e10),
109 boundingRectDirty(true)
110 { }
111
112 inline void addRect(const QRectF &rect)
113 {
114 qreal top = rect.top();
115 qreal left = rect.left();
116 qreal bottom = rect.bottom();
117 qreal right = rect.right();
118
119 vertexArray << QOpenGLPoint(left, top)
120 << QOpenGLPoint(right, top)
121 << QOpenGLPoint(right, bottom)
122 << QOpenGLPoint(right, bottom)
123 << QOpenGLPoint(left, bottom)
124 << QOpenGLPoint(left, top);
125 }
126
127 inline void addQuad(const QRectF &rect)
128 {
129 qreal top = rect.top();
130 qreal left = rect.left();
131 qreal bottom = rect.bottom();
132 qreal right = rect.right();
133
134 vertexArray << QOpenGLPoint(left, top)
135 << QOpenGLPoint(right, top)
136 << QOpenGLPoint(left, bottom)
137 << QOpenGLPoint(right, bottom);
138
139 }
140
141 inline void addVertex(const GLfloat x, const GLfloat y)
142 {
143 vertexArray.add(QOpenGLPoint(x, y));
144 }
145
146 void addPath(const QVectorPath &path, GLfloat curveInverseScale, bool outline = true);
147 void clear();
148
149 QOpenGLPoint* data() {return vertexArray.data();}
150 int *stops() const { return vertexArrayStops.data(); }
151 int stopCount() const { return vertexArrayStops.size(); }
153
154 int vertexCount() const { return vertexArray.size(); }
155
156 void lineToArray(QPointF point);
157
158private:
159 QDataBuffer<QOpenGLPoint> vertexArray;
160 QDataBuffer<int> vertexArrayStops;
161
162 GLfloat maxX;
163 GLfloat maxY;
164 GLfloat minX;
165 GLfloat minY;
166 bool boundingRectDirty;
167 void addClosingLine(int index);
168 void addCentroid(const QVectorPath &path, int subPathIndex);
169};
170
171QT_END_NAMESPACE
172
173#endif
void addPath(const QVectorPath &path, GLfloat curveInverseScale, bool outline=true)
void addQuad(const QRectF &rect)
void addRect(const QRectF &rect)
void addVertex(const GLfloat x, const GLfloat y)
QOpenGLPoint(const QPointF *p)
QOpenGLPoint(GLfloat new_x, GLfloat new_y)
Q_DECLARE_TYPEINFO(QOpenGLPoint, Q_PRIMITIVE_TYPE)
QOpenGLRect(GLfloat l, GLfloat t, GLfloat r, GLfloat b)
QOpenGLRect(const QRectF &r)

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDStateMachineEditor
Create Qt State Machine metacode using a graphical user interface
https://github.com/KDAB/KDStateMachineEditor
Generated on Tue Jul 15 2025 15:21:47 for KDStateMachineEditor API Documentation by doxygen 1.9.8