32 if ( maxError <= 0 || tileResolution <= 0 || tile0width <= 0 )
39 double zoomLevel = -log( tileResolution * maxError / tile0width ) / log( 2 );
40 return round( zoomLevel );
50 default: Q_ASSERT(
false );
return QString();
57 if ( str ==
"absolute" )
59 else if ( str ==
"terrain" )
72 default: Q_ASSERT(
false );
return QString();
79 if ( str ==
"vertex" )
89 case Qt3DRender::QCullFace::NoCulling:
return QStringLiteral(
"no-culling" );
90 case Qt3DRender::QCullFace::Front:
return QStringLiteral(
"front" );
91 case Qt3DRender::QCullFace::Back:
return QStringLiteral(
"back" );
92 case Qt3DRender::QCullFace::FrontAndBack:
return QStringLiteral(
"front-and-back" );
99 if ( str == QStringLiteral(
"front" ) )
100 return Qt3DRender::QCullFace::Front;
101 else if ( str == QStringLiteral(
"back" ) )
102 return Qt3DRender::QCullFace::Back;
103 else if ( str == QStringLiteral(
"front-and-back" ) )
104 return Qt3DRender::QCullFace::FrontAndBack;
106 return Qt3DRender::QCullFace::NoCulling;
120 pt.
setX( lineString->
xAt( i ) );
121 pt.
setY( lineString->
yAt( i ) );
125 pt.
set( centroid.
x(), centroid.
y() );
132 geomZ = lineString->
zAt( i );
135 lineString->
setZAt( i, z );
142 if ( !polygon->
is3D() )
154 clampAltitudes( lineString, altClamp, altBind, centroid, height, map );
163 clampAltitudes( lineString, altClamp, altBind, centroid, height, map );
171 const float *d = m.constData();
173 for (
int i = 0; i < 16; ++i )
174 elems << QString::number( d[i] );
175 return elems.join(
' ' );
182 QStringList elems = str.split(
' ' );
183 for (
int i = 0; i < 16; ++i )
184 d[i] = elems[i].toFloat();
218 h = terrainZ + geomZ;
221 positions.append( QVector3D( pt.
x() - map.
origin().
x(), h, -( pt.
y() - map.
origin().
y() ) ) );
234 static inline uint outcode(
const QVector4D &v )
244 if ( v.x() < -v.w() ) code |= 0x01;
245 if ( v.x() > v.w() ) code |= 0x02;
246 if ( v.y() < -v.w() ) code |= 0x04;
247 if ( v.y() > v.w() ) code |= 0x08;
248 if ( v.z() < -v.w() ) code |= 0x10;
249 if ( v.z() > v.w() ) code |= 0x20;
268 for (
int i = 0; i < 8; ++i )
270 QVector4D p( ( ( i >> 0 ) & 1 ) ? bbox.
xMin : bbox.
xMax,
271 ( ( i >> 1 ) & 1 ) ? bbox.
yMin : bbox.
yMax,
272 ( ( i >> 2 ) & 1 ) ? bbox.
zMin : bbox.
zMax, 1 );
273 QVector4D pc = viewProjectionMatrix * p;
277 out = out & outcode( pc );
285 mapCoords.
z() - origin.
z(),
286 -( mapCoords.
y() - origin.
y() ) );
293 -worldCoords.
z() + origin.
y(),
294 worldCoords.
y() + origin.
z() );
308 mapPoint2.
set( pt.
x(), pt.
y(), mapPoint1.
z() );
static QString cullingModeToString(Qt3DRender::QCullFace::CullingMode mode)
Converts a value from CullingMode enum to a string.
Wrapper for iterator of features from vector data provider or vector layer.
3 Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double preci...
3 Axis-aligned bounding box - in world coords.
Z_final = z_terrain + z_geometry.
void set(double x, double y)
Sets the x and y value of the point.
static AltitudeBinding altBindingFromString(const QString &str)
Converts a string to a value from AltitudeBinding enum.
virtual float heightAt(double x, double y, const Qgs3DMapSettings &map) const
Returns height at (x,y) in terrain's CRS.
double zAt(int index) const
Returns the z-coordinate of the specified node in the line string.
bool isNull() const
Returns true if the geometry is null (ie, contains no underlying geometry accessible via geometry() )...
static void clampAltitudes(QgsLineString *lineString, AltitudeClamping altClamp, AltitudeBinding altBind, const QgsPoint ¢roid, float height, const Qgs3DMapSettings &map)
Clamps altitude of vertices of a linestring according to the settings.
A class to represent a 2D point.
const QgsCurve * interiorRing(int i) const
Clamp just centroid of feature.
static Qt3DRender::QCullFace::CullingMode cullingModeFromString(const QString &str)
Converts a string to a value from CullingMode enum.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
static bool isCullable(const QgsAABB &bbox, const QMatrix4x4 &viewProjectionMatrix)
Returns true if bbox is completely outside the current viewing volume.
double y() const
Returns Y coordinate.
3 Definition of the world
void set(double x, double y, double z)
Sets vector coordinates.
QgsVector3D origin() const
Returns coordinates in map CRS at which 3D scene has origin (0,0,0)
virtual QgsPoint centroid() const
Returns the centroid of the geometry.
int numInteriorRings() const
double z() const
Returns Z coordinate.
static QgsVector3D worldToMapCoordinates(const QgsVector3D &worldCoords, const QgsVector3D &origin)
Converts 3D world coordinates to map coordinates (applies offset and turns (x,y,z) into (x...
double yAt(int index) const override
Returns the y-coordinate of the specified node in the line string.
void setY(double y)
Sets the y value of the point.
vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
T qgsgeometry_cast(const QgsAbstractGeometry *geom)
static QgsVector3D mapToWorldCoordinates(const QgsVector3D &mapCoords, const QgsVector3D &origin)
Converts map coordinates to 3D world coordinates (applies offset and turns (x,y,z) into (x...
Abstract base class for curved geometry type.
Abstract base class for all geometries.
Contains information about the context in which a coordinate transform is executed.
QgsGeometry geometry() const
Returns the geometry associated with this feature.
static int maxZoomLevel(double tile0width, double tileResolution, double maxError)
Calculates the highest needed zoom level for tiles in quad-tree given width of the base tile (zoom le...
void setZAt(int index, double z)
Sets the z-coordinate of the specified node in the line string.
Point geometry type, with support for z-dimension and m-values.
AltitudeClamping
how to handle altitude of vector features
static QString altBindingToString(AltitudeBinding altBind)
Converts a value from AltitudeBinding enum to a string.
void setX(double x)
Sets the x value of the point.
static QList< QVector3D > positions(const Qgs3DMapSettings &map, QgsVectorLayer *layer, const QgsFeatureRequest &req, AltitudeClamping altClamp)
Calculates (x,y,z) positions of a (multi)point in the Point vector layers.
Clamp every vertex of feature.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const override
Query the layer for features specified in request.
double terrainVerticalScale() const
Returns vertical scale (exaggeration) of terrain.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
static AltitudeClamping altClampingFromString(const QString &str)
Converts a string to a value from AltitudeClamping enum.
static QMatrix4x4 stringToMatrix4x4(const QString &str)
Convert a string to a 4x4 transform matrix.
Line string geometry type, with support for z-dimension and m-values.
This class represents a coordinate reference system (CRS).
bool addZValue(double zValue=0) override
Adds a z-dimension to the geometry, initialized to a preset value.
double xAt(int index) const override
Returns the x-coordinate of the specified node in the line string.
Custom exception class for Coordinate Reference System related exceptions.
vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
static QgsVector3D transformWorldCoordinates(const QgsVector3D &worldPoint1, const QgsVector3D &origin1, const QgsCoordinateReferenceSystem &crs1, const QgsVector3D &origin2, const QgsCoordinateReferenceSystem &crs2, const QgsCoordinateTransformContext &context)
Transforms a world point from (origin1, crs1) to (origin2, crs2)
bool nextFeature(QgsFeature &f)
const QgsCurve * exteriorRing() const
int nCoordinates() const override
Returns the number of nodes contained in the geometry.
static QString altClampingToString(AltitudeClamping altClamp)
Converts a value from AltitudeClamping enum to a string.
Represents a vector layer which manages a vector based data sets.
static QString matrix4x4toString(const QMatrix4x4 &m)
Converts a 4x4 transform matrix to a string.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
AltitudeBinding
how to handle clamping of vertices of individual features
double x() const
Returns X coordinate.
QgsTerrainGenerator * terrainGenerator() const
Returns terrain generator. It takes care of producing terrain tiles from the input data...