mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Move altitude clamping/binding enums to Qgis namespace, promote to enum
class
This commit is contained in:
parent
2379de4a95
commit
5395d87d7f
@ -23,3 +23,20 @@ __copyright__ = '(C) 2014, Nathan Woodrow'
|
||||
|
||||
from qgis.PyQt import QtCore
|
||||
from qgis._3d import *
|
||||
|
||||
from qgis.core import Qgis
|
||||
# manual monkey patching for old enum values
|
||||
Qgs3DTypes.AltitudeClamping = Qgis.AltitudeClamping
|
||||
Qgs3DTypes.AltClampAbsolute = Qgis.AltitudeClamping.Absolute
|
||||
Qgs3DTypes.AltClampAbsolute.is_monkey_patched = True
|
||||
Qgs3DTypes.AltClampRelative = Qgis.AltitudeClamping.Relative
|
||||
Qgs3DTypes.AltClampRelative.is_monkey_patched = True
|
||||
Qgs3DTypes.AltClampTerrain = Qgis.AltitudeClamping.Terrain
|
||||
Qgs3DTypes.AltClampTerrain.is_monkey_patched = True
|
||||
|
||||
Qgs3DTypes.AltitudeBinding = Qgis.AltitudeBinding
|
||||
Qgs3DTypes.AltBindVertex = Qgis.AltitudeBinding.Vertex
|
||||
Qgs3DTypes.AltBindVertex.is_monkey_patched = True
|
||||
Qgs3DTypes.AltBindCentroid = Qgis.AltitudeBinding.Centroid
|
||||
Qgs3DTypes.AltBindCentroid.is_monkey_patched = True
|
||||
|
||||
|
@ -25,18 +25,6 @@ Defines enumerations and other auxiliary types for QGIS 3D
|
||||
#include "qgs3dtypes.h"
|
||||
%End
|
||||
public:
|
||||
enum AltitudeClamping
|
||||
{
|
||||
AltClampAbsolute,
|
||||
AltClampRelative,
|
||||
AltClampTerrain,
|
||||
};
|
||||
|
||||
enum AltitudeBinding
|
||||
{
|
||||
AltBindVertex,
|
||||
AltBindCentroid,
|
||||
};
|
||||
|
||||
enum CullingMode
|
||||
{
|
||||
|
@ -51,20 +51,20 @@ Caller takes ownership of the returned symbol.
|
||||
virtual QList< QgsWkbTypes::GeometryType > compatibleGeometryTypes() const;
|
||||
|
||||
|
||||
Qgs3DTypes::AltitudeClamping altitudeClamping() const;
|
||||
Qgis::AltitudeClamping altitudeClamping() const;
|
||||
%Docstring
|
||||
Returns method that determines altitude (whether to clamp to feature to terrain)
|
||||
%End
|
||||
void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping );
|
||||
void setAltitudeClamping( Qgis::AltitudeClamping altClamping );
|
||||
%Docstring
|
||||
Sets method that determines altitude (whether to clamp to feature to terrain)
|
||||
%End
|
||||
|
||||
Qgs3DTypes::AltitudeBinding altitudeBinding() const;
|
||||
Qgis::AltitudeBinding altitudeBinding() const;
|
||||
%Docstring
|
||||
Returns method that determines how altitude is bound to individual vertices
|
||||
%End
|
||||
void setAltitudeBinding( Qgs3DTypes::AltitudeBinding altBinding );
|
||||
void setAltitudeBinding( Qgis::AltitudeBinding altBinding );
|
||||
%Docstring
|
||||
Sets method that determines how altitude is bound to individual vertices
|
||||
%End
|
||||
|
@ -58,11 +58,11 @@ Caller takes ownership of the returned symbol.
|
||||
virtual QList< QgsWkbTypes::GeometryType > compatibleGeometryTypes() const;
|
||||
|
||||
|
||||
Qgs3DTypes::AltitudeClamping altitudeClamping() const;
|
||||
Qgis::AltitudeClamping altitudeClamping() const;
|
||||
%Docstring
|
||||
Returns method that determines altitude (whether to clamp to feature to terrain)
|
||||
%End
|
||||
void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping );
|
||||
void setAltitudeClamping( Qgis::AltitudeClamping altClamping );
|
||||
%Docstring
|
||||
Sets method that determines altitude (whether to clamp to feature to terrain)
|
||||
%End
|
||||
|
@ -52,20 +52,20 @@ Creates a new QgsPolygon3DSymbol.
|
||||
Caller takes ownership of the returned symbol.
|
||||
%End
|
||||
|
||||
Qgs3DTypes::AltitudeClamping altitudeClamping() const;
|
||||
Qgis::AltitudeClamping altitudeClamping() const;
|
||||
%Docstring
|
||||
Returns method that determines altitude (whether to clamp to feature to terrain)
|
||||
%End
|
||||
void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping );
|
||||
void setAltitudeClamping( Qgis::AltitudeClamping altClamping );
|
||||
%Docstring
|
||||
Sets method that determines altitude (whether to clamp to feature to terrain)
|
||||
%End
|
||||
|
||||
Qgs3DTypes::AltitudeBinding altitudeBinding() const;
|
||||
Qgis::AltitudeBinding altitudeBinding() const;
|
||||
%Docstring
|
||||
Returns method that determines how altitude is bound to individual vertices
|
||||
%End
|
||||
void setAltitudeBinding( Qgs3DTypes::AltitudeBinding altBinding );
|
||||
void setAltitudeBinding( Qgis::AltitudeBinding altBinding );
|
||||
%Docstring
|
||||
Sets method that determines how altitude is bound to individual vertices
|
||||
%End
|
||||
|
@ -1327,3 +1327,16 @@ Qgis.FieldDomainType.Glob.__doc__ = "Glob string pattern field domain"
|
||||
Qgis.FieldDomainType.__doc__ = 'Types of field domain\n\n.. versionadded:: 3.26\n\n' + '* ``Coded``: ' + Qgis.FieldDomainType.Coded.__doc__ + '\n' + '* ``Range``: ' + Qgis.FieldDomainType.Range.__doc__ + '\n' + '* ``Glob``: ' + Qgis.FieldDomainType.Glob.__doc__
|
||||
# --
|
||||
Qgis.FieldDomainType.baseClass = Qgis
|
||||
# monkey patching scoped based enum
|
||||
Qgis.AltitudeClamping.Absolute.__doc__ = "Elevation is taken directly from feature and is independent of terrain height (final elevation = feature elevation)"
|
||||
Qgis.AltitudeClamping.Relative.__doc__ = "Elevation is relative to terrain height (final elevation = terrain elevation + feature elevation)"
|
||||
Qgis.AltitudeClamping.Terrain.__doc__ = "Elevation is clamped to terrain (final elevation = terrain elevation)"
|
||||
Qgis.AltitudeClamping.__doc__ = 'Altitude clamping.\n\n.. versionadded:: 3.24\n\n' + '* ``Absolute``: ' + Qgis.AltitudeClamping.Absolute.__doc__ + '\n' + '* ``Relative``: ' + Qgis.AltitudeClamping.Relative.__doc__ + '\n' + '* ``Terrain``: ' + Qgis.AltitudeClamping.Terrain.__doc__
|
||||
# --
|
||||
Qgis.AltitudeClamping.baseClass = Qgis
|
||||
# monkey patching scoped based enum
|
||||
Qgis.AltitudeBinding.Vertex.__doc__ = "Clamp every vertex of feature"
|
||||
Qgis.AltitudeBinding.Centroid.__doc__ = "Clamp just centroid of feature"
|
||||
Qgis.AltitudeBinding.__doc__ = 'Altitude binding.\n\n.. versionadded:: 3.24\n\n' + '* ``Vertex``: ' + Qgis.AltitudeBinding.Vertex.__doc__ + '\n' + '* ``Centroid``: ' + Qgis.AltitudeBinding.Centroid.__doc__
|
||||
# --
|
||||
Qgis.AltitudeBinding.baseClass = Qgis
|
||||
|
@ -856,6 +856,19 @@ The development version
|
||||
Glob,
|
||||
};
|
||||
|
||||
enum class AltitudeClamping
|
||||
{
|
||||
Absolute,
|
||||
Relative,
|
||||
Terrain,
|
||||
};
|
||||
|
||||
enum class AltitudeBinding
|
||||
{
|
||||
Vertex,
|
||||
Centroid,
|
||||
};
|
||||
|
||||
static const double DEFAULT_SEARCH_RADIUS_MM;
|
||||
|
||||
static const float DEFAULT_MAPTOPIXEL_THRESHOLD;
|
||||
|
@ -30,20 +30,6 @@
|
||||
class _3D_EXPORT Qgs3DTypes
|
||||
{
|
||||
public:
|
||||
//! how to handle altitude of vector features
|
||||
enum AltitudeClamping
|
||||
{
|
||||
AltClampAbsolute, //!< Z_final = z_geometry
|
||||
AltClampRelative, //!< Z_final = z_terrain + z_geometry
|
||||
AltClampTerrain, //!< Z_final = z_terrain
|
||||
};
|
||||
|
||||
//! how to handle clamping of vertices of individual features
|
||||
enum AltitudeBinding
|
||||
{
|
||||
AltBindVertex, //!< Clamp every vertex of feature
|
||||
AltBindCentroid, //!< Clamp just centroid of feature
|
||||
};
|
||||
|
||||
//! Triangle culling mode
|
||||
enum CullingMode
|
||||
|
@ -230,58 +230,67 @@ int Qgs3DUtils::maxZoomLevel( double tile0width, double tileResolution, double m
|
||||
return round( zoomLevel ); // we could use ceil() here if we wanted to always get to the desired error
|
||||
}
|
||||
|
||||
QString Qgs3DUtils::altClampingToString( Qgs3DTypes::AltitudeClamping altClamp )
|
||||
QString Qgs3DUtils::altClampingToString( Qgis::AltitudeClamping altClamp )
|
||||
{
|
||||
switch ( altClamp )
|
||||
{
|
||||
case Qgs3DTypes::AltClampAbsolute: return QStringLiteral( "absolute" );
|
||||
case Qgs3DTypes::AltClampRelative: return QStringLiteral( "relative" );
|
||||
case Qgs3DTypes::AltClampTerrain: return QStringLiteral( "terrain" );
|
||||
default: Q_ASSERT( false ); return QString();
|
||||
case Qgis::AltitudeClamping::Absolute:
|
||||
return QStringLiteral( "absolute" );
|
||||
case Qgis::AltitudeClamping::Relative:
|
||||
return QStringLiteral( "relative" );
|
||||
case Qgis::AltitudeClamping::Terrain:
|
||||
return QStringLiteral( "terrain" );
|
||||
}
|
||||
BUILTIN_UNREACHABLE
|
||||
}
|
||||
|
||||
|
||||
Qgs3DTypes::AltitudeClamping Qgs3DUtils::altClampingFromString( const QString &str )
|
||||
Qgis::AltitudeClamping Qgs3DUtils::altClampingFromString( const QString &str )
|
||||
{
|
||||
if ( str == QLatin1String( "absolute" ) )
|
||||
return Qgs3DTypes::AltClampAbsolute;
|
||||
return Qgis::AltitudeClamping::Absolute;
|
||||
else if ( str == QLatin1String( "terrain" ) )
|
||||
return Qgs3DTypes::AltClampTerrain;
|
||||
return Qgis::AltitudeClamping::Terrain;
|
||||
else // "relative" (default)
|
||||
return Qgs3DTypes::AltClampRelative;
|
||||
return Qgis::AltitudeClamping::Relative;
|
||||
}
|
||||
|
||||
|
||||
QString Qgs3DUtils::altBindingToString( Qgs3DTypes::AltitudeBinding altBind )
|
||||
QString Qgs3DUtils::altBindingToString( Qgis::AltitudeBinding altBind )
|
||||
{
|
||||
switch ( altBind )
|
||||
{
|
||||
case Qgs3DTypes::AltBindVertex: return QStringLiteral( "vertex" );
|
||||
case Qgs3DTypes::AltBindCentroid: return QStringLiteral( "centroid" );
|
||||
default: Q_ASSERT( false ); return QString();
|
||||
case Qgis::AltitudeBinding::Vertex:
|
||||
return QStringLiteral( "vertex" );
|
||||
case Qgis::AltitudeBinding::Centroid:
|
||||
return QStringLiteral( "centroid" );
|
||||
}
|
||||
BUILTIN_UNREACHABLE
|
||||
}
|
||||
|
||||
|
||||
Qgs3DTypes::AltitudeBinding Qgs3DUtils::altBindingFromString( const QString &str )
|
||||
Qgis::AltitudeBinding Qgs3DUtils::altBindingFromString( const QString &str )
|
||||
{
|
||||
if ( str == QLatin1String( "vertex" ) )
|
||||
return Qgs3DTypes::AltBindVertex;
|
||||
return Qgis::AltitudeBinding::Vertex;
|
||||
else // "centroid" (default)
|
||||
return Qgs3DTypes::AltBindCentroid;
|
||||
return Qgis::AltitudeBinding::Centroid;
|
||||
}
|
||||
|
||||
QString Qgs3DUtils::cullingModeToString( Qgs3DTypes::CullingMode mode )
|
||||
{
|
||||
switch ( mode )
|
||||
{
|
||||
case Qgs3DTypes::NoCulling: return QStringLiteral( "no-culling" );
|
||||
case Qgs3DTypes::Front: return QStringLiteral( "front" );
|
||||
case Qgs3DTypes::Back: return QStringLiteral( "back" );
|
||||
case Qgs3DTypes::FrontAndBack: return QStringLiteral( "front-and-back" );
|
||||
case Qgs3DTypes::NoCulling:
|
||||
return QStringLiteral( "no-culling" );
|
||||
case Qgs3DTypes::Front:
|
||||
return QStringLiteral( "front" );
|
||||
case Qgs3DTypes::Back:
|
||||
return QStringLiteral( "back" );
|
||||
case Qgs3DTypes::FrontAndBack:
|
||||
return QStringLiteral( "front-and-back" );
|
||||
}
|
||||
return QString();
|
||||
BUILTIN_UNREACHABLE
|
||||
}
|
||||
|
||||
Qgs3DTypes::CullingMode Qgs3DUtils::cullingModeFromString( const QString &str )
|
||||
@ -296,47 +305,85 @@ Qgs3DTypes::CullingMode Qgs3DUtils::cullingModeFromString( const QString &str )
|
||||
return Qgs3DTypes::NoCulling;
|
||||
}
|
||||
|
||||
float Qgs3DUtils::clampAltitude( const QgsPoint &p, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, float height, const QgsPoint ¢roid, const Qgs3DMapSettings &map )
|
||||
float Qgs3DUtils::clampAltitude( const QgsPoint &p, Qgis::AltitudeClamping altClamp, Qgis::AltitudeBinding altBind, float height, const QgsPoint ¢roid, const Qgs3DMapSettings &map )
|
||||
{
|
||||
float terrainZ = 0;
|
||||
if ( altClamp == Qgs3DTypes::AltClampRelative || altClamp == Qgs3DTypes::AltClampTerrain )
|
||||
switch ( altClamp )
|
||||
{
|
||||
const QgsPointXY pt = altBind == Qgs3DTypes::AltBindVertex ? p : centroid;
|
||||
terrainZ = map.terrainGenerator() ? map.terrainGenerator()->heightAt( pt.x(), pt.y(), map ) : 0;
|
||||
case Qgis::AltitudeClamping::Relative:
|
||||
case Qgis::AltitudeClamping::Terrain:
|
||||
{
|
||||
const QgsPointXY pt = altBind == Qgis::AltitudeBinding::Vertex ? p : centroid;
|
||||
terrainZ = map.terrainGenerator() ? map.terrainGenerator()->heightAt( pt.x(), pt.y(), map ) : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case Qgis::AltitudeClamping::Absolute:
|
||||
break;
|
||||
}
|
||||
|
||||
float geomZ = 0;
|
||||
if ( p.is3D() && ( altClamp == Qgs3DTypes::AltClampAbsolute || altClamp == Qgs3DTypes::AltClampRelative ) )
|
||||
geomZ = p.z();
|
||||
if ( p.is3D() )
|
||||
{
|
||||
switch ( altClamp )
|
||||
{
|
||||
case Qgis::AltitudeClamping::Absolute:
|
||||
case Qgis::AltitudeClamping::Relative:
|
||||
geomZ = p.z();
|
||||
break;
|
||||
|
||||
case Qgis::AltitudeClamping::Terrain:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const float z = ( terrainZ + geomZ ) * map.terrainVerticalScale() + height;
|
||||
return z;
|
||||
}
|
||||
|
||||
void Qgs3DUtils::clampAltitudes( QgsLineString *lineString, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, const QgsPoint ¢roid, float height, const Qgs3DMapSettings &map )
|
||||
void Qgs3DUtils::clampAltitudes( QgsLineString *lineString, Qgis::AltitudeClamping altClamp, Qgis::AltitudeBinding altBind, const QgsPoint ¢roid, float height, const Qgs3DMapSettings &map )
|
||||
{
|
||||
for ( int i = 0; i < lineString->nCoordinates(); ++i )
|
||||
{
|
||||
float terrainZ = 0;
|
||||
if ( altClamp == Qgs3DTypes::AltClampRelative || altClamp == Qgs3DTypes::AltClampTerrain )
|
||||
switch ( altClamp )
|
||||
{
|
||||
QgsPointXY pt;
|
||||
if ( altBind == Qgs3DTypes::AltBindVertex )
|
||||
case Qgis::AltitudeClamping::Relative:
|
||||
case Qgis::AltitudeClamping::Terrain:
|
||||
{
|
||||
pt.setX( lineString->xAt( i ) );
|
||||
pt.setY( lineString->yAt( i ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
pt.set( centroid.x(), centroid.y() );
|
||||
QgsPointXY pt;
|
||||
switch ( altBind )
|
||||
{
|
||||
case Qgis::AltitudeBinding::Vertex:
|
||||
pt.setX( lineString->xAt( i ) );
|
||||
pt.setY( lineString->yAt( i ) );
|
||||
break;
|
||||
|
||||
case Qgis::AltitudeBinding::Centroid:
|
||||
pt.set( centroid.x(), centroid.y() );
|
||||
break;
|
||||
}
|
||||
|
||||
terrainZ = map.terrainGenerator() ? map.terrainGenerator()->heightAt( pt.x(), pt.y(), map ) : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
terrainZ = map.terrainGenerator() ? map.terrainGenerator()->heightAt( pt.x(), pt.y(), map ) : 0;
|
||||
case Qgis::AltitudeClamping::Absolute:
|
||||
break;
|
||||
}
|
||||
|
||||
float geomZ = 0;
|
||||
if ( altClamp == Qgs3DTypes::AltClampAbsolute || altClamp == Qgs3DTypes::AltClampRelative )
|
||||
geomZ = lineString->zAt( i );
|
||||
|
||||
switch ( altClamp )
|
||||
{
|
||||
case Qgis::AltitudeClamping::Absolute:
|
||||
case Qgis::AltitudeClamping::Relative:
|
||||
geomZ = lineString->zAt( i );
|
||||
break;
|
||||
|
||||
case Qgis::AltitudeClamping::Terrain:
|
||||
break;
|
||||
}
|
||||
|
||||
const float z = ( terrainZ + geomZ ) * map.terrainVerticalScale() + height;
|
||||
lineString->setZAt( i, z );
|
||||
@ -344,14 +391,21 @@ void Qgs3DUtils::clampAltitudes( QgsLineString *lineString, Qgs3DTypes::Altitude
|
||||
}
|
||||
|
||||
|
||||
bool Qgs3DUtils::clampAltitudes( QgsPolygon *polygon, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, float height, const Qgs3DMapSettings &map )
|
||||
bool Qgs3DUtils::clampAltitudes( QgsPolygon *polygon, Qgis::AltitudeClamping altClamp, Qgis::AltitudeBinding altBind, float height, const Qgs3DMapSettings &map )
|
||||
{
|
||||
if ( !polygon->is3D() )
|
||||
polygon->addZValue( 0 );
|
||||
|
||||
QgsPoint centroid;
|
||||
if ( altBind == Qgs3DTypes::AltBindCentroid )
|
||||
centroid = polygon->centroid();
|
||||
switch ( altBind )
|
||||
{
|
||||
case Qgis::AltitudeBinding::Vertex:
|
||||
break;
|
||||
|
||||
case Qgis::AltitudeBinding::Centroid:
|
||||
centroid = polygon->centroid();
|
||||
break;
|
||||
}
|
||||
|
||||
QgsCurve *curve = const_cast<QgsCurve *>( polygon->exteriorRing() );
|
||||
QgsLineString *lineString = qgsgeometry_cast<QgsLineString *>( curve );
|
||||
@ -393,7 +447,7 @@ QMatrix4x4 Qgs3DUtils::stringToMatrix4x4( const QString &str )
|
||||
return m;
|
||||
}
|
||||
|
||||
void Qgs3DUtils::extractPointPositions( const QgsFeature &f, const Qgs3DMapSettings &map, Qgs3DTypes::AltitudeClamping altClamp, QVector<QVector3D> &positions )
|
||||
void Qgs3DUtils::extractPointPositions( const QgsFeature &f, const Qgs3DMapSettings &map, Qgis::AltitudeClamping altClamp, QVector<QVector3D> &positions )
|
||||
{
|
||||
const QgsAbstractGeometry *g = f.geometry().constGet();
|
||||
for ( auto it = g->vertices_begin(); it != g->vertices_end(); ++it )
|
||||
@ -408,14 +462,13 @@ void Qgs3DUtils::extractPointPositions( const QgsFeature &f, const Qgs3DMapSetti
|
||||
float h;
|
||||
switch ( altClamp )
|
||||
{
|
||||
case Qgs3DTypes::AltClampAbsolute:
|
||||
default:
|
||||
case Qgis::AltitudeClamping::Absolute:
|
||||
h = geomZ;
|
||||
break;
|
||||
case Qgs3DTypes::AltClampTerrain:
|
||||
case Qgis::AltitudeClamping::Terrain:
|
||||
h = terrainZ;
|
||||
break;
|
||||
case Qgs3DTypes::AltClampRelative:
|
||||
case Qgis::AltitudeClamping::Relative:
|
||||
h = terrainZ + geomZ;
|
||||
break;
|
||||
}
|
||||
|
@ -105,14 +105,14 @@ class _3D_EXPORT Qgs3DUtils
|
||||
static int maxZoomLevel( double tile0width, double tileResolution, double maxError );
|
||||
|
||||
//! Converts a value from AltitudeClamping enum to a string
|
||||
static QString altClampingToString( Qgs3DTypes::AltitudeClamping altClamp );
|
||||
static QString altClampingToString( Qgis::AltitudeClamping altClamp );
|
||||
//! Converts a string to a value from AltitudeClamping enum
|
||||
static Qgs3DTypes::AltitudeClamping altClampingFromString( const QString &str );
|
||||
static Qgis::AltitudeClamping altClampingFromString( const QString &str );
|
||||
|
||||
//! Converts a value from AltitudeBinding enum to a string
|
||||
static QString altBindingToString( Qgs3DTypes::AltitudeBinding altBind );
|
||||
static QString altBindingToString( Qgis::AltitudeBinding altBind );
|
||||
//! Converts a string to a value from AltitudeBinding enum
|
||||
static Qgs3DTypes::AltitudeBinding altBindingFromString( const QString &str );
|
||||
static Qgis::AltitudeBinding altBindingFromString( const QString &str );
|
||||
|
||||
//! Converts a value from CullingMode enum to a string
|
||||
static QString cullingModeToString( Qgs3DTypes::CullingMode mode );
|
||||
@ -120,11 +120,11 @@ class _3D_EXPORT Qgs3DUtils
|
||||
static Qgs3DTypes::CullingMode cullingModeFromString( const QString &str );
|
||||
|
||||
//! Clamps altitude of a vertex according to the settings, returns Z value
|
||||
static float clampAltitude( const QgsPoint &p, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, float height, const QgsPoint ¢roid, const Qgs3DMapSettings &map );
|
||||
static float clampAltitude( const QgsPoint &p, Qgis::AltitudeClamping altClamp, Qgis::AltitudeBinding altBind, float height, const QgsPoint ¢roid, const Qgs3DMapSettings &map );
|
||||
//! Clamps altitude of vertices of a linestring according to the settings
|
||||
static void clampAltitudes( QgsLineString *lineString, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, const QgsPoint ¢roid, float height, const Qgs3DMapSettings &map );
|
||||
static void clampAltitudes( QgsLineString *lineString, Qgis::AltitudeClamping altClamp, Qgis::AltitudeBinding altBind, const QgsPoint ¢roid, float height, const Qgs3DMapSettings &map );
|
||||
//! Clamps altitude of vertices of a polygon according to the settings
|
||||
static bool clampAltitudes( QgsPolygon *polygon, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, float height, const Qgs3DMapSettings &map );
|
||||
static bool clampAltitudes( QgsPolygon *polygon, Qgis::AltitudeClamping altClamp, Qgis::AltitudeBinding altBind, float height, const Qgs3DMapSettings &map );
|
||||
|
||||
//! Converts a 4x4 transform matrix to a string
|
||||
static QString matrix4x4toString( const QMatrix4x4 &m );
|
||||
@ -132,7 +132,7 @@ class _3D_EXPORT Qgs3DUtils
|
||||
static QMatrix4x4 stringToMatrix4x4( const QString &str );
|
||||
|
||||
//! Calculates (x,y,z) positions of (multi)point from the given feature
|
||||
static void extractPointPositions( const QgsFeature &f, const Qgs3DMapSettings &map, Qgs3DTypes::AltitudeClamping altClamp, QVector<QVector3D> &positions );
|
||||
static void extractPointPositions( const QgsFeature &f, const Qgs3DMapSettings &map, Qgis::AltitudeClamping altClamp, QVector<QVector3D> &positions );
|
||||
|
||||
/**
|
||||
* Returns TRUE if bbox is completely outside the current viewing volume.
|
||||
|
@ -116,7 +116,7 @@ void QgsRubberBand3D::updateGeometry()
|
||||
{
|
||||
QgsLineVertexData lineData;
|
||||
lineData.withAdjacency = true;
|
||||
lineData.init( Qgs3DTypes::AltClampAbsolute, Qgs3DTypes::AltBindVertex, 0, mMapSettings );
|
||||
lineData.init( Qgis::AltitudeClamping::Absolute, Qgis::AltitudeBinding::Vertex, 0, mMapSettings );
|
||||
lineData.addLineString( mLineString );
|
||||
|
||||
mPositionAttribute->buffer()->setData( lineData.createVertexBuffer() );
|
||||
|
@ -54,14 +54,14 @@ class _3D_EXPORT QgsLine3DSymbol : public QgsAbstract3DSymbol SIP_NODEFAULTCTORS
|
||||
QList< QgsWkbTypes::GeometryType > compatibleGeometryTypes() const override;
|
||||
|
||||
//! Returns method that determines altitude (whether to clamp to feature to terrain)
|
||||
Qgs3DTypes::AltitudeClamping altitudeClamping() const { return mAltClamping; }
|
||||
Qgis::AltitudeClamping altitudeClamping() const { return mAltClamping; }
|
||||
//! Sets method that determines altitude (whether to clamp to feature to terrain)
|
||||
void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping ) { mAltClamping = altClamping; }
|
||||
void setAltitudeClamping( Qgis::AltitudeClamping altClamping ) { mAltClamping = altClamping; }
|
||||
|
||||
//! Returns method that determines how altitude is bound to individual vertices
|
||||
Qgs3DTypes::AltitudeBinding altitudeBinding() const { return mAltBinding; }
|
||||
Qgis::AltitudeBinding altitudeBinding() const { return mAltBinding; }
|
||||
//! Sets method that determines how altitude is bound to individual vertices
|
||||
void setAltitudeBinding( Qgs3DTypes::AltitudeBinding altBinding ) { mAltBinding = altBinding; }
|
||||
void setAltitudeBinding( Qgis::AltitudeBinding altBinding ) { mAltBinding = altBinding; }
|
||||
|
||||
//! Returns width of the line symbol (in map units)
|
||||
float width() const { return mWidth; }
|
||||
@ -101,9 +101,9 @@ class _3D_EXPORT QgsLine3DSymbol : public QgsAbstract3DSymbol SIP_NODEFAULTCTORS
|
||||
|
||||
private:
|
||||
//! how to handle altitude of vector features
|
||||
Qgs3DTypes::AltitudeClamping mAltClamping = Qgs3DTypes::AltClampRelative;
|
||||
Qgis::AltitudeClamping mAltClamping = Qgis::AltitudeClamping::Relative;
|
||||
//! how to handle clamping of vertices of individual features
|
||||
Qgs3DTypes::AltitudeBinding mAltBinding = Qgs3DTypes::AltBindCentroid;
|
||||
Qgis::AltitudeBinding mAltBinding = Qgis::AltitudeBinding::Centroid;
|
||||
|
||||
float mWidth = 2.0f; //!< Line width (horizontally)
|
||||
float mHeight = 0.0f; //!< Base height of polygons
|
||||
|
@ -32,7 +32,7 @@ QgsLineVertexData::QgsLineVertexData()
|
||||
vertices << QVector3D();
|
||||
}
|
||||
|
||||
void QgsLineVertexData::init( Qgs3DTypes::AltitudeClamping clamping, Qgs3DTypes::AltitudeBinding binding, float height, const Qgs3DMapSettings *map )
|
||||
void QgsLineVertexData::init( Qgis::AltitudeClamping clamping, Qgis::AltitudeBinding binding, float height, const Qgs3DMapSettings *map )
|
||||
{
|
||||
altClamping = clamping;
|
||||
altBinding = binding;
|
||||
@ -107,8 +107,14 @@ void QgsLineVertexData::addLineString( const QgsLineString &lineString, float ex
|
||||
indexes << vertices.count(); // add the following vertex (for adjacency)
|
||||
|
||||
QgsPoint centroid;
|
||||
if ( altBinding == Qgs3DTypes::AltBindCentroid )
|
||||
centroid = lineString.centroid();
|
||||
switch ( altBinding )
|
||||
{
|
||||
case Qgis::AltitudeBinding::Vertex:
|
||||
break;
|
||||
case Qgis::AltitudeBinding::Centroid:
|
||||
centroid = lineString.centroid();
|
||||
break;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < lineString.vertexCount(); ++i )
|
||||
{
|
||||
@ -128,8 +134,14 @@ void QgsLineVertexData::addLineString( const QgsLineString &lineString, float ex
|
||||
void QgsLineVertexData::addVerticalLines( const QgsLineString &lineString, float verticalLength, float extraHeightOffset )
|
||||
{
|
||||
QgsPoint centroid;
|
||||
if ( altBinding == Qgs3DTypes::AltBindCentroid )
|
||||
centroid = lineString.centroid();
|
||||
switch ( altBinding )
|
||||
{
|
||||
case Qgis::AltitudeBinding::Vertex:
|
||||
break;
|
||||
case Qgis::AltitudeBinding::Centroid:
|
||||
centroid = lineString.centroid();
|
||||
break;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < lineString.vertexCount(); ++i )
|
||||
{
|
||||
|
@ -33,6 +33,7 @@
|
||||
#define SIP_NO_FILE
|
||||
|
||||
#include "qgs3dtypes.h"
|
||||
#include "qgis.h"
|
||||
|
||||
namespace Qt3DCore
|
||||
{
|
||||
@ -68,14 +69,14 @@ struct QgsLineVertexData
|
||||
bool withAdjacency = false; //!< Whether line strip with adjacency primitive will be used
|
||||
|
||||
// extra info to calculate elevation
|
||||
Qgs3DTypes::AltitudeClamping altClamping = Qgs3DTypes::AltClampRelative;
|
||||
Qgs3DTypes::AltitudeBinding altBinding = Qgs3DTypes::AltBindVertex;
|
||||
Qgis::AltitudeClamping altClamping = Qgis::AltitudeClamping::Relative;
|
||||
Qgis::AltitudeBinding altBinding = Qgis::AltitudeBinding::Vertex;
|
||||
float baseHeight = 0;
|
||||
const Qgs3DMapSettings *mapSettings = nullptr;
|
||||
|
||||
QgsLineVertexData();
|
||||
|
||||
void init( Qgs3DTypes::AltitudeClamping clamping, Qgs3DTypes::AltitudeBinding binding, float height, const Qgs3DMapSettings *map );
|
||||
void init( Qgis::AltitudeClamping clamping, Qgis::AltitudeBinding binding, float height, const Qgs3DMapSettings *map );
|
||||
|
||||
QByteArray createVertexBuffer();
|
||||
QByteArray createIndexBuffer();
|
||||
|
@ -97,9 +97,9 @@ class _3D_EXPORT QgsMesh3DSymbol : public QgsAbstract3DSymbol
|
||||
void setEnabled( bool enabled );
|
||||
|
||||
//! Returns method that determines altitude (whether to clamp to feature to terrain)
|
||||
Qgs3DTypes::AltitudeClamping altitudeClamping() const { return mAltClamping; }
|
||||
Qgis::AltitudeClamping altitudeClamping() const { return mAltClamping; }
|
||||
//! Sets method that determines altitude (whether to clamp to feature to terrain)
|
||||
void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping ) { mAltClamping = altClamping; }
|
||||
void setAltitudeClamping( Qgis::AltitudeClamping altClamping ) { mAltClamping = altClamping; }
|
||||
|
||||
//! Returns height (altitude) of the symbol (in map units)
|
||||
float height() const { return mHeight; }
|
||||
@ -345,7 +345,7 @@ class _3D_EXPORT QgsMesh3DSymbol : public QgsAbstract3DSymbol
|
||||
private:
|
||||
|
||||
//! how to handle altitude of vector features
|
||||
Qgs3DTypes::AltitudeClamping mAltClamping = Qgs3DTypes::AltClampRelative;
|
||||
Qgis::AltitudeClamping mAltClamping = Qgis::AltitudeClamping::Relative;
|
||||
float mHeight = 0.0f; //!< Base height of triangles
|
||||
std::unique_ptr< QgsAbstractMaterialSettings > mMaterial; //!< Defines appearance of objects
|
||||
bool mAddBackFaces = false;
|
||||
|
@ -123,7 +123,7 @@ Qt3DRender::QGeometryRenderer *QgsMesh3DSymbolEntityNode::renderer( const Qgs3DM
|
||||
std::unique_ptr< QgsPolygon > polygon = QgsMeshUtils::toPolygon( triangle, vertices );
|
||||
Qgs3DUtils::clampAltitudes( polygon.get(),
|
||||
symbol.altitudeClamping(),
|
||||
Qgs3DTypes::AltitudeBinding::AltBindVertex,
|
||||
Qgis::AltitudeBinding::Vertex,
|
||||
height,
|
||||
map );
|
||||
polygons.append( polygon.release() );
|
||||
|
@ -61,9 +61,9 @@ class _3D_EXPORT QgsPoint3DSymbol : public QgsAbstract3DSymbol SIP_NODEFAULTCTOR
|
||||
QList< QgsWkbTypes::GeometryType > compatibleGeometryTypes() const override;
|
||||
|
||||
//! Returns method that determines altitude (whether to clamp to feature to terrain)
|
||||
Qgs3DTypes::AltitudeClamping altitudeClamping() const { return mAltClamping; }
|
||||
Qgis::AltitudeClamping altitudeClamping() const { return mAltClamping; }
|
||||
//! Sets method that determines altitude (whether to clamp to feature to terrain)
|
||||
void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping ) { mAltClamping = altClamping; }
|
||||
void setAltitudeClamping( Qgis::AltitudeClamping altClamping ) { mAltClamping = altClamping; }
|
||||
|
||||
//! Returns material used for shading of the symbol
|
||||
QgsAbstractMaterialSettings *material() const;
|
||||
@ -124,7 +124,7 @@ class _3D_EXPORT QgsPoint3DSymbol : public QgsAbstract3DSymbol SIP_NODEFAULTCTOR
|
||||
bool exportGeometries( Qgs3DSceneExporter *exporter, Qt3DCore::QEntity *entity, const QString &objectNamePrefix ) const override SIP_SKIP;
|
||||
private:
|
||||
//! how to handle altitude of vector features
|
||||
Qgs3DTypes::AltitudeClamping mAltClamping = Qgs3DTypes::AltClampRelative;
|
||||
Qgis::AltitudeClamping mAltClamping = Qgis::AltitudeClamping::Relative;
|
||||
|
||||
std::unique_ptr< QgsAbstractMaterialSettings> mMaterial; //!< Defines appearance of objects
|
||||
Shape mShape = Cylinder; //!< What kind of shape to use
|
||||
|
@ -56,14 +56,14 @@ class _3D_EXPORT QgsPolygon3DSymbol : public QgsAbstract3DSymbol SIP_NODEFAULTCT
|
||||
static QgsAbstract3DSymbol *create() SIP_FACTORY;
|
||||
|
||||
//! Returns method that determines altitude (whether to clamp to feature to terrain)
|
||||
Qgs3DTypes::AltitudeClamping altitudeClamping() const { return mAltClamping; }
|
||||
Qgis::AltitudeClamping altitudeClamping() const { return mAltClamping; }
|
||||
//! Sets method that determines altitude (whether to clamp to feature to terrain)
|
||||
void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping ) { mAltClamping = altClamping; }
|
||||
void setAltitudeClamping( Qgis::AltitudeClamping altClamping ) { mAltClamping = altClamping; }
|
||||
|
||||
//! Returns method that determines how altitude is bound to individual vertices
|
||||
Qgs3DTypes::AltitudeBinding altitudeBinding() const { return mAltBinding; }
|
||||
Qgis::AltitudeBinding altitudeBinding() const { return mAltBinding; }
|
||||
//! Sets method that determines how altitude is bound to individual vertices
|
||||
void setAltitudeBinding( Qgs3DTypes::AltitudeBinding altBinding ) { mAltBinding = altBinding; }
|
||||
void setAltitudeBinding( Qgis::AltitudeBinding altBinding ) { mAltBinding = altBinding; }
|
||||
|
||||
//! Returns height (altitude) of the symbol (in map units)
|
||||
float height() const { return mHeight; }
|
||||
@ -164,9 +164,9 @@ class _3D_EXPORT QgsPolygon3DSymbol : public QgsAbstract3DSymbol SIP_NODEFAULTCT
|
||||
|
||||
private:
|
||||
//! how to handle altitude of vector features
|
||||
Qgs3DTypes::AltitudeClamping mAltClamping = Qgs3DTypes::AltClampRelative;
|
||||
Qgis::AltitudeClamping mAltClamping = Qgis::AltitudeClamping::Relative;
|
||||
//! how to handle clamping of vertices of individual features
|
||||
Qgs3DTypes::AltitudeBinding mAltBinding = Qgs3DTypes::AltBindCentroid;
|
||||
Qgis::AltitudeBinding mAltBinding = Qgis::AltitudeBinding::Centroid;
|
||||
|
||||
float mHeight = 0.0f; //!< Base height of polygons
|
||||
float mExtrusionHeight = 0.0f; //!< How much to extrude (0 means no walls)
|
||||
|
@ -71,8 +71,8 @@ QgsAbstract3DSymbol *QgsLine3DSymbolWidget::symbol()
|
||||
sym->setWidth( spinWidth->value() );
|
||||
sym->setHeight( spinHeight->value() );
|
||||
sym->setExtrusionHeight( spinExtrusion->value() );
|
||||
sym->setAltitudeClamping( static_cast<Qgs3DTypes::AltitudeClamping>( cboAltClamping->currentIndex() ) );
|
||||
sym->setAltitudeBinding( static_cast<Qgs3DTypes::AltitudeBinding>( cboAltBinding->currentIndex() ) );
|
||||
sym->setAltitudeClamping( static_cast<Qgis::AltitudeClamping>( cboAltClamping->currentIndex() ) );
|
||||
sym->setAltitudeBinding( static_cast<Qgis::AltitudeBinding>( cboAltBinding->currentIndex() ) );
|
||||
sym->setRenderAsSimpleLines( chkSimpleLines->isChecked() );
|
||||
sym->setMaterial( widgetMaterial->settings() );
|
||||
return sym.release();
|
||||
|
@ -227,7 +227,7 @@ QgsAbstract3DSymbol *QgsPoint3DSymbolWidget::symbol()
|
||||
tr.scale( sca );
|
||||
tr.rotate( rot );
|
||||
|
||||
sym->setAltitudeClamping( static_cast<Qgs3DTypes::AltitudeClamping>( cboAltClamping->currentIndex() ) );
|
||||
sym->setAltitudeClamping( static_cast<Qgis::AltitudeClamping>( cboAltClamping->currentIndex() ) );
|
||||
sym->setShape( static_cast<QgsPoint3DSymbol::Shape>( cboShape->itemData( cboShape->currentIndex() ).toInt() ) );
|
||||
sym->setShapeProperties( vm );
|
||||
sym->setMaterial( widgetMaterial->settings() );
|
||||
|
@ -83,8 +83,8 @@ QgsAbstract3DSymbol *QgsPolygon3DSymbolWidget::symbol()
|
||||
std::unique_ptr< QgsPolygon3DSymbol > sym = std::make_unique< QgsPolygon3DSymbol >();
|
||||
sym->setHeight( spinHeight->value() );
|
||||
sym->setExtrusionHeight( spinExtrusion->value() );
|
||||
sym->setAltitudeClamping( static_cast<Qgs3DTypes::AltitudeClamping>( cboAltClamping->currentIndex() ) );
|
||||
sym->setAltitudeBinding( static_cast<Qgs3DTypes::AltitudeBinding>( cboAltBinding->currentIndex() ) );
|
||||
sym->setAltitudeClamping( static_cast<Qgis::AltitudeClamping>( cboAltClamping->currentIndex() ) );
|
||||
sym->setAltitudeBinding( static_cast<Qgis::AltitudeBinding>( cboAltBinding->currentIndex() ) );
|
||||
sym->setCullingMode( static_cast<Qgs3DTypes::CullingMode>( cboCullingMode->currentIndex() ) );
|
||||
sym->setRenderedFacade( cboRenderedFacade->currentIndex() );
|
||||
sym->setAddBackFaces( chkAddBackFaces->isChecked() );
|
||||
|
@ -1410,6 +1410,31 @@ class CORE_EXPORT Qgis
|
||||
};
|
||||
Q_ENUM( FieldDomainType )
|
||||
|
||||
/**
|
||||
* Altitude clamping.
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
enum class AltitudeClamping : int
|
||||
{
|
||||
Absolute, //!< Elevation is taken directly from feature and is independent of terrain height (final elevation = feature elevation)
|
||||
Relative, //!< Elevation is relative to terrain height (final elevation = terrain elevation + feature elevation)
|
||||
Terrain, //!< Elevation is clamped to terrain (final elevation = terrain elevation)
|
||||
};
|
||||
Q_ENUM( AltitudeClamping )
|
||||
|
||||
/**
|
||||
* Altitude binding.
|
||||
*
|
||||
* \since QGIS 3.24
|
||||
*/
|
||||
enum class AltitudeBinding : int
|
||||
{
|
||||
Vertex, //!< Clamp every vertex of feature
|
||||
Centroid, //!< Clamp just centroid of feature
|
||||
};
|
||||
Q_ENUM( AltitudeBinding )
|
||||
|
||||
/**
|
||||
* Identify search radius in mm
|
||||
* \since QGIS 2.3
|
||||
|
Loading…
x
Reference in New Issue
Block a user