QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgstextureatlasgenerator.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstextureatlasgenerator.h
3 --------------------------------------
4 Date : September 2025
5 Copyright : (C) 2025 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSTEXTUREATLASGENERATOR_H
17#define QGSTEXTUREATLASGENERATOR_H
18
19#include <vector>
20
21#include "qgis_3d.h"
22
23#include <QImage>
24#include <QRect>
25
27class QgsTextureRect;
29
30
42class _3D_EXPORT QgsTextureAtlas
43{
44 public:
47
50
54 bool isValid() const { return mAtlasSize.isValid(); }
55
60 QSize atlasSize() const { return mAtlasSize; }
61
62#ifndef SIP_RUN
66 QRect rect( int index ) const;
67#else
68
74 QRect rect( int index ) const;
75 //%MethodCode
76 const int count = sipCpp->count();
77 if ( a0 < 0 || a0 >= count )
78 {
79 PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
80 sipIsErr = 1;
81 }
82 else
83 {
84 return sipConvertFromNewType( new QRect( sipCpp->rect( a0 ) ), sipType_QRect, Py_None );
85 }
86 //%End
87#endif
88
94 QImage renderAtlasTexture() const;
95
102 QImage renderDebugTexture() const;
103
107 int count() const;
108
109#ifdef SIP_RUN
110 int __len__() const;
111 % Docstring
112 Returns the number of textures in the atlas.
113 % End
114 //%MethodCode
115 sipRes
116 = sipCpp->count();
117 //% End
118#endif
119
120 private:
121 std::vector< QgsTextureRect >
122 mRects;
123 QSize mAtlasSize;
124
126};
127
139{
140 public:
141
154 static QgsTextureAtlas createFromRects( const QVector< QRect > &rectangles, int maxSide = 1000 );
155
165 static QgsTextureAtlas createFromImages( const QVector< QImage > &images, int maxSide = 1000 );
166
167 private:
168
176 static QgsTextureAtlas generateAtlas( std::vector< QgsTextureRect > rects, int maxSide );
177};
178
179#endif // QGSTEXTUREATLASGENERATOR_H
Generates texture atlases by efficient packing of multiple input rectangles/images.
static QgsTextureAtlas createFromRects(const QVector< QRect > &rectangles, int maxSide=1000)
Creates a texture atlas for a set of rectangles.
static QgsTextureAtlas createFromImages(const QVector< QImage > &images, int maxSide=1000)
Creates a texture atlas for a set of images.
Encapsulates a texture atlas.
QgsTextureAtlas & operator=(const QgsTextureAtlas &other)
bool isValid() const
Returns true if the atlas is valid.
QgsTextureAtlas(const QgsTextureAtlas &other)
QSize atlasSize() const
Returns the total size required for the atlas, i.e.
friend class QgsTextureAtlasGenerator