mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Move altitude binding/clamping enums to Qgs3DTypes + add culling mode in Python
This commit is contained in:
parent
88cb8313c8
commit
8814e40635
@ -1,5 +1,5 @@
|
||||
// Include auto-generated SIP files
|
||||
%Include auto_generated/qgs3dutils.sip
|
||||
%Include auto_generated/qgs3dtypes.sip
|
||||
%Include auto_generated/qgsphongmaterialsettings.sip
|
||||
%Include auto_generated/qgsvectorlayer3drenderer.sip
|
||||
%Include auto_generated/symbols/qgsabstract3dsymbol.sip
|
||||
|
@ -1,37 +1,51 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/3d/qgs3dutils.h *
|
||||
* src/3d/qgs3dtypes.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enum AltitudeClamping
|
||||
class Qgs3DTypes
|
||||
{
|
||||
AltClampAbsolute,
|
||||
AltClampRelative,
|
||||
AltClampTerrain,
|
||||
%Docstring
|
||||
Defines enumerations and other auxilliary types for QGIS 3D
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgs3dtypes.h"
|
||||
%End
|
||||
public:
|
||||
enum AltitudeClamping
|
||||
{
|
||||
AltClampAbsolute,
|
||||
AltClampRelative,
|
||||
AltClampTerrain,
|
||||
};
|
||||
|
||||
enum AltitudeBinding
|
||||
{
|
||||
AltBindVertex,
|
||||
AltBindCentroid,
|
||||
};
|
||||
|
||||
enum CullingMode
|
||||
{
|
||||
NoCulling,
|
||||
Front,
|
||||
Back,
|
||||
FrontAndBack
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
enum AltitudeBinding
|
||||
{
|
||||
AltBindVertex,
|
||||
AltBindCentroid,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/3d/qgs3dutils.h *
|
||||
* src/3d/qgs3dtypes.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -36,20 +36,20 @@ Constructor for QgsLine3DSymbol
|
||||
virtual void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
|
||||
|
||||
|
||||
AltitudeClamping altitudeClamping() const;
|
||||
Qgs3DTypes::AltitudeClamping altitudeClamping() const;
|
||||
%Docstring
|
||||
Returns method that determines altitude (whether to clamp to feature to terrain)
|
||||
%End
|
||||
void setAltitudeClamping( AltitudeClamping altClamping );
|
||||
void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping );
|
||||
%Docstring
|
||||
Sets method that determines altitude (whether to clamp to feature to terrain)
|
||||
%End
|
||||
|
||||
AltitudeBinding altitudeBinding() const;
|
||||
Qgs3DTypes::AltitudeBinding altitudeBinding() const;
|
||||
%Docstring
|
||||
Returns method that determines how altitude is bound to individual vertices
|
||||
%End
|
||||
void setAltitudeBinding( AltitudeBinding altBinding );
|
||||
void setAltitudeBinding( Qgs3DTypes::AltitudeBinding altBinding );
|
||||
%Docstring
|
||||
Sets method that determines how altitude is bound to individual vertices
|
||||
%End
|
||||
|
@ -36,11 +36,11 @@ Constructor for QgsPoint3DSymbol.
|
||||
virtual void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
|
||||
|
||||
|
||||
AltitudeClamping altitudeClamping() const;
|
||||
Qgs3DTypes::AltitudeClamping altitudeClamping() const;
|
||||
%Docstring
|
||||
Returns method that determines altitude (whether to clamp to feature to terrain)
|
||||
%End
|
||||
void setAltitudeClamping( AltitudeClamping altClamping );
|
||||
void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping );
|
||||
%Docstring
|
||||
Sets method that determines altitude (whether to clamp to feature to terrain)
|
||||
%End
|
||||
|
@ -36,20 +36,20 @@ Constructor for QgsPolygon3DSymbol
|
||||
virtual void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
|
||||
|
||||
|
||||
AltitudeClamping altitudeClamping() const;
|
||||
Qgs3DTypes::AltitudeClamping altitudeClamping() const;
|
||||
%Docstring
|
||||
Returns method that determines altitude (whether to clamp to feature to terrain)
|
||||
%End
|
||||
void setAltitudeClamping( AltitudeClamping altClamping );
|
||||
void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping );
|
||||
%Docstring
|
||||
Sets method that determines altitude (whether to clamp to feature to terrain)
|
||||
%End
|
||||
|
||||
AltitudeBinding altitudeBinding() const;
|
||||
Qgs3DTypes::AltitudeBinding altitudeBinding() const;
|
||||
%Docstring
|
||||
Returns method that determines how altitude is bound to individual vertices
|
||||
%End
|
||||
void setAltitudeBinding( AltitudeBinding altBinding );
|
||||
void setAltitudeBinding( Qgs3DTypes::AltitudeBinding altBinding );
|
||||
%Docstring
|
||||
Sets method that determines how altitude is bound to individual vertices
|
||||
%End
|
||||
@ -81,6 +81,14 @@ Returns material used for shading of the symbol
|
||||
Sets material used for shading of the symbol
|
||||
%End
|
||||
|
||||
Qgs3DTypes::CullingMode cullingMode() const;
|
||||
%Docstring
|
||||
Returns front/back culling mode
|
||||
%End
|
||||
void setCullingMode( Qgs3DTypes::CullingMode mode );
|
||||
%Docstring
|
||||
Sets front/back culling mode
|
||||
%End
|
||||
|
||||
bool invertNormals() const;
|
||||
%Docstring
|
||||
|
@ -112,13 +112,13 @@ SIPIFYDIFF=sipify.$REV.diff
|
||||
true > "$SIPIFYDIFF"
|
||||
for f in $MODIFIED; do
|
||||
# if cpp header
|
||||
if [[ $f =~ ^src\/(core|gui|analysis|server)\/.*\.h$ ]]; then
|
||||
if [[ $f =~ ^src\/(core|gui|analysis|server|3d)\/.*\.h$ ]]; then
|
||||
# look if corresponding SIP file
|
||||
sip_file=$(${GP}sed -r 's@^src/(core|gui|analysis|server)/@@; s@\.h$@.sip@' <<<"$f" )
|
||||
sip_file=$(${GP}sed -r 's@^src/(core|gui|analysis|server|3d)/@@; s@\.h$@.sip@' <<<"$f" )
|
||||
pyfile=$(${GP}sed -E 's@([^\/]+\/)*([^\/]+)\.sip@\2.py@;' <<< "$sip_file")
|
||||
module=$(${GP}sed -r 's@src/(core|gui|analysis|server)/.*$@\1@' <<<"$f" )
|
||||
module=$(${GP}sed -r 's@src/(core|gui|analysis|server|3d)/.*$@\1@' <<<"$f" )
|
||||
if grep -Fq "$sip_file" "${TOPLEVEL}"/python/"${module}"/"${module}"_auto.sip; then
|
||||
sip_file=$(${GP}sed -r 's@^src/(core|gui|analysis|server)@\1/auto_generated@; s@\.h$@.sip.in@' <<<"$f" )
|
||||
sip_file=$(${GP}sed -r 's@^src/(core|gui|analysis|server|3d)@\1/auto_generated@; s@\.h$@.sip.in@' <<<"$f" )
|
||||
m=python/$sip_file.$REV.prepare
|
||||
touch python/"$sip_file"
|
||||
cp python/"$sip_file" "$m"
|
||||
|
@ -83,6 +83,7 @@ SET(QGIS_3D_HDRS
|
||||
qgsabstract3dengine.h
|
||||
qgs3dmapscene.h
|
||||
qgs3dmapsettings.h
|
||||
qgs3dtypes.h
|
||||
qgs3dutils.h
|
||||
qgscameracontroller.h
|
||||
qgscamerapose.h
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "qgs3dmapsettings.h"
|
||||
|
||||
#include "qgs3dutils.h"
|
||||
#include "qgsflatterraingenerator.h"
|
||||
#include "qgsdemterraingenerator.h"
|
||||
//#include "quantizedmeshterraingenerator.h"
|
||||
|
54
src/3d/qgs3dtypes.h
Normal file
54
src/3d/qgs3dtypes.h
Normal file
@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
qgs3dtypes.h
|
||||
--------------------------------------
|
||||
Date : October 2018
|
||||
Copyright : (C) 2018 by Martin Dobias
|
||||
Email : wonder dot sk at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGS3DTYPES_H
|
||||
#define QGS3DTYPES_H
|
||||
|
||||
#include "qgis_3d.h"
|
||||
|
||||
/**
|
||||
* \ingroup 3d
|
||||
* Defines enumerations and other auxilliary types for QGIS 3D
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
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
|
||||
{
|
||||
NoCulling, //!< Will render both front and back faces of triangles
|
||||
Front, //!< Will render only back faces of triangles
|
||||
Back, //!< Will render only front faces of triangles (recommended when input data are consistent)
|
||||
FrontAndBack //!< Will not render anything
|
||||
};
|
||||
};
|
||||
|
||||
#endif // QGS3DTYPES_H
|
@ -83,96 +83,96 @@ 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( AltitudeClamping altClamp )
|
||||
QString Qgs3DUtils::altClampingToString( Qgs3DTypes::AltitudeClamping altClamp )
|
||||
{
|
||||
switch ( altClamp )
|
||||
{
|
||||
case AltClampAbsolute: return QStringLiteral( "absolute" );
|
||||
case AltClampRelative: return QStringLiteral( "relative" );
|
||||
case AltClampTerrain: return QStringLiteral( "terrain" );
|
||||
case Qgs3DTypes::AltClampAbsolute: return QStringLiteral( "absolute" );
|
||||
case Qgs3DTypes::AltClampRelative: return QStringLiteral( "relative" );
|
||||
case Qgs3DTypes::AltClampTerrain: return QStringLiteral( "terrain" );
|
||||
default: Q_ASSERT( false ); return QString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AltitudeClamping Qgs3DUtils::altClampingFromString( const QString &str )
|
||||
Qgs3DTypes::AltitudeClamping Qgs3DUtils::altClampingFromString( const QString &str )
|
||||
{
|
||||
if ( str == "absolute" )
|
||||
return AltClampAbsolute;
|
||||
return Qgs3DTypes::AltClampAbsolute;
|
||||
else if ( str == "terrain" )
|
||||
return AltClampTerrain;
|
||||
return Qgs3DTypes::AltClampTerrain;
|
||||
else // "relative" (default)
|
||||
return AltClampRelative;
|
||||
return Qgs3DTypes::AltClampRelative;
|
||||
}
|
||||
|
||||
|
||||
QString Qgs3DUtils::altBindingToString( AltitudeBinding altBind )
|
||||
QString Qgs3DUtils::altBindingToString( Qgs3DTypes::AltitudeBinding altBind )
|
||||
{
|
||||
switch ( altBind )
|
||||
{
|
||||
case AltBindVertex: return QStringLiteral( "vertex" );
|
||||
case AltBindCentroid: return QStringLiteral( "centroid" );
|
||||
case Qgs3DTypes::AltBindVertex: return QStringLiteral( "vertex" );
|
||||
case Qgs3DTypes::AltBindCentroid: return QStringLiteral( "centroid" );
|
||||
default: Q_ASSERT( false ); return QString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AltitudeBinding Qgs3DUtils::altBindingFromString( const QString &str )
|
||||
Qgs3DTypes::AltitudeBinding Qgs3DUtils::altBindingFromString( const QString &str )
|
||||
{
|
||||
if ( str == "vertex" )
|
||||
return AltBindVertex;
|
||||
return Qgs3DTypes::AltBindVertex;
|
||||
else // "centroid" (default)
|
||||
return AltBindCentroid;
|
||||
return Qgs3DTypes::AltBindCentroid;
|
||||
}
|
||||
|
||||
QString Qgs3DUtils::cullingModeToString( Qt3DRender::QCullFace::CullingMode mode )
|
||||
QString Qgs3DUtils::cullingModeToString( Qgs3DTypes::CullingMode mode )
|
||||
{
|
||||
switch ( mode )
|
||||
{
|
||||
case Qt3DRender::QCullFace::NoCulling: return QStringLiteral( "no-culling" );
|
||||
case Qt3DRender::QCullFace::Front: return QStringLiteral( "front" );
|
||||
case Qt3DRender::QCullFace::Back: return QStringLiteral( "back" );
|
||||
case Qt3DRender::QCullFace::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();
|
||||
}
|
||||
|
||||
Qt3DRender::QCullFace::CullingMode Qgs3DUtils::cullingModeFromString( const QString &str )
|
||||
Qgs3DTypes::CullingMode Qgs3DUtils::cullingModeFromString( const QString &str )
|
||||
{
|
||||
if ( str == QStringLiteral( "front" ) )
|
||||
return Qt3DRender::QCullFace::Front;
|
||||
return Qgs3DTypes::Front;
|
||||
else if ( str == QStringLiteral( "back" ) )
|
||||
return Qt3DRender::QCullFace::Back;
|
||||
return Qgs3DTypes::Back;
|
||||
else if ( str == QStringLiteral( "front-and-back" ) )
|
||||
return Qt3DRender::QCullFace::FrontAndBack;
|
||||
return Qgs3DTypes::FrontAndBack;
|
||||
else
|
||||
return Qt3DRender::QCullFace::NoCulling;
|
||||
return Qgs3DTypes::NoCulling;
|
||||
}
|
||||
|
||||
float Qgs3DUtils::clampAltitude( const QgsPoint &p, AltitudeClamping altClamp, AltitudeBinding altBind, float height, const QgsPoint ¢roid, const Qgs3DMapSettings &map )
|
||||
float Qgs3DUtils::clampAltitude( const QgsPoint &p, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, float height, const QgsPoint ¢roid, const Qgs3DMapSettings &map )
|
||||
{
|
||||
float terrainZ = 0;
|
||||
if ( altClamp == AltClampRelative || altClamp == AltClampTerrain )
|
||||
if ( altClamp == Qgs3DTypes::AltClampRelative || altClamp == Qgs3DTypes::AltClampTerrain )
|
||||
{
|
||||
QgsPointXY pt = altBind == AltBindVertex ? p : centroid;
|
||||
QgsPointXY pt = altBind == Qgs3DTypes::AltBindVertex ? p : centroid;
|
||||
terrainZ = map.terrainGenerator()->heightAt( pt.x(), pt.y(), map );
|
||||
}
|
||||
|
||||
float geomZ = altClamp == AltClampAbsolute || altClamp == AltClampRelative ? p.z() : 0;
|
||||
float geomZ = altClamp == Qgs3DTypes::AltClampAbsolute || altClamp == Qgs3DTypes::AltClampRelative ? p.z() : 0;
|
||||
|
||||
float z = ( terrainZ + geomZ ) * map.terrainVerticalScale() + height;
|
||||
return z;
|
||||
}
|
||||
|
||||
void Qgs3DUtils::clampAltitudes( QgsLineString *lineString, AltitudeClamping altClamp, AltitudeBinding altBind, const QgsPoint ¢roid, float height, const Qgs3DMapSettings &map )
|
||||
void Qgs3DUtils::clampAltitudes( QgsLineString *lineString, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, const QgsPoint ¢roid, float height, const Qgs3DMapSettings &map )
|
||||
{
|
||||
for ( int i = 0; i < lineString->nCoordinates(); ++i )
|
||||
{
|
||||
float terrainZ = 0;
|
||||
if ( altClamp == AltClampRelative || altClamp == AltClampTerrain )
|
||||
if ( altClamp == Qgs3DTypes::AltClampRelative || altClamp == Qgs3DTypes::AltClampTerrain )
|
||||
{
|
||||
QgsPointXY pt;
|
||||
if ( altBind == AltBindVertex )
|
||||
if ( altBind == Qgs3DTypes::AltBindVertex )
|
||||
{
|
||||
pt.setX( lineString->xAt( i ) );
|
||||
pt.setY( lineString->yAt( i ) );
|
||||
@ -185,7 +185,7 @@ void Qgs3DUtils::clampAltitudes( QgsLineString *lineString, AltitudeClamping alt
|
||||
}
|
||||
|
||||
float geomZ = 0;
|
||||
if ( altClamp == AltClampAbsolute || altClamp == AltClampRelative )
|
||||
if ( altClamp == Qgs3DTypes::AltClampAbsolute || altClamp == Qgs3DTypes::AltClampRelative )
|
||||
geomZ = lineString->zAt( i );
|
||||
|
||||
float z = ( terrainZ + geomZ ) * map.terrainVerticalScale() + height;
|
||||
@ -194,13 +194,13 @@ void Qgs3DUtils::clampAltitudes( QgsLineString *lineString, AltitudeClamping alt
|
||||
}
|
||||
|
||||
|
||||
bool Qgs3DUtils::clampAltitudes( QgsPolygon *polygon, AltitudeClamping altClamp, AltitudeBinding altBind, float height, const Qgs3DMapSettings &map )
|
||||
bool Qgs3DUtils::clampAltitudes( QgsPolygon *polygon, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, float height, const Qgs3DMapSettings &map )
|
||||
{
|
||||
if ( !polygon->is3D() )
|
||||
polygon->addZValue( 0 );
|
||||
|
||||
QgsPoint centroid;
|
||||
if ( altBind == AltBindCentroid )
|
||||
if ( altBind == Qgs3DTypes::AltBindCentroid )
|
||||
centroid = polygon->centroid();
|
||||
|
||||
QgsCurve *curve = const_cast<QgsCurve *>( polygon->exteriorRing() );
|
||||
@ -242,7 +242,7 @@ QMatrix4x4 Qgs3DUtils::stringToMatrix4x4( const QString &str )
|
||||
return m;
|
||||
}
|
||||
|
||||
QList<QVector3D> Qgs3DUtils::positions( const Qgs3DMapSettings &map, QgsVectorLayer *layer, const QgsFeatureRequest &request, AltitudeClamping altClamp )
|
||||
QList<QVector3D> Qgs3DUtils::positions( const Qgs3DMapSettings &map, QgsVectorLayer *layer, const QgsFeatureRequest &request, Qgs3DTypes::AltitudeClamping altClamp )
|
||||
{
|
||||
QList<QVector3D> positions;
|
||||
QgsFeature f;
|
||||
@ -265,14 +265,14 @@ QList<QVector3D> Qgs3DUtils::positions( const Qgs3DMapSettings &map, QgsVectorLa
|
||||
float h;
|
||||
switch ( altClamp )
|
||||
{
|
||||
case AltClampAbsolute:
|
||||
case Qgs3DTypes::AltClampAbsolute:
|
||||
default:
|
||||
h = geomZ;
|
||||
break;
|
||||
case AltClampTerrain:
|
||||
case Qgs3DTypes::AltClampTerrain:
|
||||
h = terrainZ;
|
||||
break;
|
||||
case AltClampRelative:
|
||||
case Qgs3DTypes::AltClampRelative:
|
||||
h = terrainZ + geomZ;
|
||||
break;
|
||||
}
|
||||
|
@ -25,26 +25,9 @@ class QgsAbstract3DEngine;
|
||||
class Qgs3DMapScene;
|
||||
|
||||
#include "qgs3dmapsettings.h"
|
||||
#include "qgs3dtypes.h"
|
||||
#include "qgsaabb.h"
|
||||
|
||||
#include <Qt3DRender/QCullFace>
|
||||
|
||||
//! 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
|
||||
};
|
||||
|
||||
|
||||
#ifndef SIP_RUN
|
||||
|
||||
@ -71,26 +54,26 @@ 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( AltitudeClamping altClamp );
|
||||
static QString altClampingToString( Qgs3DTypes::AltitudeClamping altClamp );
|
||||
//! Converts a string to a value from AltitudeClamping enum
|
||||
static AltitudeClamping altClampingFromString( const QString &str );
|
||||
static Qgs3DTypes::AltitudeClamping altClampingFromString( const QString &str );
|
||||
|
||||
//! Converts a value from AltitudeBinding enum to a string
|
||||
static QString altBindingToString( AltitudeBinding altBind );
|
||||
static QString altBindingToString( Qgs3DTypes::AltitudeBinding altBind );
|
||||
//! Converts a string to a value from AltitudeBinding enum
|
||||
static AltitudeBinding altBindingFromString( const QString &str );
|
||||
static Qgs3DTypes::AltitudeBinding altBindingFromString( const QString &str );
|
||||
|
||||
//! Converts a value from CullingMode enum to a string
|
||||
static QString cullingModeToString( Qt3DRender::QCullFace::CullingMode mode );
|
||||
static QString cullingModeToString( Qgs3DTypes::CullingMode mode );
|
||||
//! Converts a string to a value from CullingMode enum
|
||||
static Qt3DRender::QCullFace::CullingMode cullingModeFromString( const QString &str );
|
||||
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, AltitudeClamping altClamp, AltitudeBinding altBind, float height, const QgsPoint ¢roid, const Qgs3DMapSettings &map );
|
||||
static float clampAltitude( const QgsPoint &p, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::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, AltitudeClamping altClamp, AltitudeBinding altBind, const QgsPoint ¢roid, float height, const Qgs3DMapSettings &map );
|
||||
static void clampAltitudes( QgsLineString *lineString, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::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, AltitudeClamping altClamp, AltitudeBinding altBind, float height, const Qgs3DMapSettings &map );
|
||||
static bool clampAltitudes( QgsPolygon *polygon, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, float height, const Qgs3DMapSettings &map );
|
||||
|
||||
//! Converts a 4x4 transform matrix to a string
|
||||
static QString matrix4x4toString( const QMatrix4x4 &m );
|
||||
@ -100,7 +83,7 @@ class _3D_EXPORT Qgs3DUtils
|
||||
/**
|
||||
* Calculates (x,y,z) positions of a (multi)point in the Point vector layers
|
||||
*/
|
||||
static QList<QVector3D> positions( const Qgs3DMapSettings &map, QgsVectorLayer *layer, const QgsFeatureRequest &req, AltitudeClamping altClamp );
|
||||
static QList<QVector3D> positions( const Qgs3DMapSettings &map, QgsVectorLayer *layer, const QgsFeatureRequest &req, Qgs3DTypes::AltitudeClamping altClamp );
|
||||
|
||||
/**
|
||||
Returns true if bbox is completely outside the current viewing volume.
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "qgsabstract3dsymbol.h"
|
||||
|
||||
#include "qgsphongmaterialsettings.h"
|
||||
#include "qgs3dutils.h"
|
||||
|
||||
#include "qgsmaplayerref.h"
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
#include "qgsline3dsymbol.h"
|
||||
|
||||
#include "qgs3dutils.h"
|
||||
|
||||
QgsAbstract3DSymbol *QgsLine3DSymbol::clone() const
|
||||
{
|
||||
return new QgsLine3DSymbol( *this );
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "qgsabstract3dsymbol.h"
|
||||
#include "qgsphongmaterialsettings.h"
|
||||
#include "qgs3dutils.h"
|
||||
#include "qgs3dtypes.h"
|
||||
|
||||
|
||||
/**
|
||||
@ -41,14 +41,14 @@ class _3D_EXPORT QgsLine3DSymbol : public QgsAbstract3DSymbol
|
||||
void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
|
||||
|
||||
//! Returns method that determines altitude (whether to clamp to feature to terrain)
|
||||
AltitudeClamping altitudeClamping() const { return mAltClamping; }
|
||||
Qgs3DTypes::AltitudeClamping altitudeClamping() const { return mAltClamping; }
|
||||
//! Sets method that determines altitude (whether to clamp to feature to terrain)
|
||||
void setAltitudeClamping( AltitudeClamping altClamping ) { mAltClamping = altClamping; }
|
||||
void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping ) { mAltClamping = altClamping; }
|
||||
|
||||
//! Returns method that determines how altitude is bound to individual vertices
|
||||
AltitudeBinding altitudeBinding() const { return mAltBinding; }
|
||||
Qgs3DTypes::AltitudeBinding altitudeBinding() const { return mAltBinding; }
|
||||
//! Sets method that determines how altitude is bound to individual vertices
|
||||
void setAltitudeBinding( AltitudeBinding altBinding ) { mAltBinding = altBinding; }
|
||||
void setAltitudeBinding( Qgs3DTypes::AltitudeBinding altBinding ) { mAltBinding = altBinding; }
|
||||
|
||||
//! Returns width of the line symbol (in map units)
|
||||
float width() const { return mWidth; }
|
||||
@ -77,9 +77,9 @@ class _3D_EXPORT QgsLine3DSymbol : public QgsAbstract3DSymbol
|
||||
|
||||
private:
|
||||
//! how to handle altitude of vector features
|
||||
AltitudeClamping mAltClamping = AltClampRelative;
|
||||
Qgs3DTypes::AltitudeClamping mAltClamping = Qgs3DTypes::AltClampRelative;
|
||||
//! how to handle clamping of vertices of individual features
|
||||
AltitudeBinding mAltBinding = AltBindCentroid;
|
||||
Qgs3DTypes::AltitudeBinding mAltBinding = Qgs3DTypes::AltBindCentroid;
|
||||
|
||||
float mWidth = 2.0f; //!< Line width (horizontally)
|
||||
float mHeight = 0.0f; //!< Base height of polygons
|
||||
|
@ -174,7 +174,7 @@ Qt3DRender::QGeometryRenderer *QgsLine3DSymbolEntityNode::rendererSimple( const
|
||||
if ( f.geometry().isNull() )
|
||||
continue;
|
||||
|
||||
if ( symbol.altitudeBinding() == AltBindCentroid )
|
||||
if ( symbol.altitudeBinding() == Qgs3DTypes::AltBindCentroid )
|
||||
centroid = QgsPoint( f.geometry().centroid().asPoint() );
|
||||
|
||||
QgsGeometry geom = f.geometry();
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "qgspoint3dsymbol.h"
|
||||
|
||||
#include "qgs3dutils.h"
|
||||
#include "qgsreadwritecontext.h"
|
||||
#include "qgsxmlutils.h"
|
||||
|
||||
|
@ -20,8 +20,9 @@
|
||||
|
||||
#include "qgsabstract3dsymbol.h"
|
||||
#include "qgsphongmaterialsettings.h"
|
||||
#include "qgs3dutils.h"
|
||||
#include "qgs3dtypes.h"
|
||||
|
||||
#include <QMatrix4x4>
|
||||
|
||||
/**
|
||||
* \ingroup 3d
|
||||
@ -42,9 +43,9 @@ class _3D_EXPORT QgsPoint3DSymbol : public QgsAbstract3DSymbol
|
||||
void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
|
||||
|
||||
//! Returns method that determines altitude (whether to clamp to feature to terrain)
|
||||
AltitudeClamping altitudeClamping() const { return mAltClamping; }
|
||||
Qgs3DTypes::AltitudeClamping altitudeClamping() const { return mAltClamping; }
|
||||
//! Sets method that determines altitude (whether to clamp to feature to terrain)
|
||||
void setAltitudeClamping( AltitudeClamping altClamping ) { mAltClamping = altClamping; }
|
||||
void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping ) { mAltClamping = altClamping; }
|
||||
|
||||
//! Returns material used for shading of the symbol
|
||||
QgsPhongMaterialSettings material() const { return mMaterial; }
|
||||
@ -86,7 +87,7 @@ class _3D_EXPORT QgsPoint3DSymbol : public QgsAbstract3DSymbol
|
||||
|
||||
private:
|
||||
//! how to handle altitude of vector features
|
||||
AltitudeClamping mAltClamping = AltClampRelative;
|
||||
Qgs3DTypes::AltitudeClamping mAltClamping = Qgs3DTypes::AltClampRelative;
|
||||
|
||||
QgsPhongMaterialSettings mMaterial; //!< Defines appearance of objects
|
||||
Shape mShape = Cylinder; //!< What kind of shape to use
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
#include "qgspolygon3dsymbol.h"
|
||||
|
||||
#include "qgs3dutils.h"
|
||||
|
||||
QgsAbstract3DSymbol *QgsPolygon3DSymbol::clone() const
|
||||
{
|
||||
return new QgsPolygon3DSymbol( *this );
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "qgsabstract3dsymbol.h"
|
||||
#include "qgsphongmaterialsettings.h"
|
||||
#include "qgs3dutils.h"
|
||||
#include "qgs3dtypes.h"
|
||||
|
||||
#include <Qt3DRender/QCullFace>
|
||||
|
||||
@ -42,14 +42,14 @@ class _3D_EXPORT QgsPolygon3DSymbol : public QgsAbstract3DSymbol
|
||||
void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
|
||||
|
||||
//! Returns method that determines altitude (whether to clamp to feature to terrain)
|
||||
AltitudeClamping altitudeClamping() const { return mAltClamping; }
|
||||
Qgs3DTypes::AltitudeClamping altitudeClamping() const { return mAltClamping; }
|
||||
//! Sets method that determines altitude (whether to clamp to feature to terrain)
|
||||
void setAltitudeClamping( AltitudeClamping altClamping ) { mAltClamping = altClamping; }
|
||||
void setAltitudeClamping( Qgs3DTypes::AltitudeClamping altClamping ) { mAltClamping = altClamping; }
|
||||
|
||||
//! Returns method that determines how altitude is bound to individual vertices
|
||||
AltitudeBinding altitudeBinding() const { return mAltBinding; }
|
||||
Qgs3DTypes::AltitudeBinding altitudeBinding() const { return mAltBinding; }
|
||||
//! Sets method that determines how altitude is bound to individual vertices
|
||||
void setAltitudeBinding( AltitudeBinding altBinding ) { mAltBinding = altBinding; }
|
||||
void setAltitudeBinding( Qgs3DTypes::AltitudeBinding altBinding ) { mAltBinding = altBinding; }
|
||||
|
||||
//! Returns height (altitude) of the symbol (in map units)
|
||||
float height() const { return mHeight; }
|
||||
@ -67,9 +67,9 @@ class _3D_EXPORT QgsPolygon3DSymbol : public QgsAbstract3DSymbol
|
||||
void setMaterial( const QgsPhongMaterialSettings &material ) { mMaterial = material; }
|
||||
|
||||
//! Returns front/back culling mode
|
||||
Qt3DRender::QCullFace::CullingMode cullingMode() const { return mCullingMode; } SIP_SKIP
|
||||
Qgs3DTypes::CullingMode cullingMode() const { return mCullingMode; }
|
||||
//! Sets front/back culling mode
|
||||
void setCullingMode( Qt3DRender::QCullFace::CullingMode mode ) { mCullingMode = mode; } SIP_SKIP
|
||||
void setCullingMode( Qgs3DTypes::CullingMode mode ) { mCullingMode = mode; }
|
||||
|
||||
//! Returns whether the normals of triangles will be inverted (useful for fixing clockwise / counter-clockwise face vertex orders)
|
||||
bool invertNormals() const { return mInvertNormals; }
|
||||
@ -90,14 +90,14 @@ class _3D_EXPORT QgsPolygon3DSymbol : public QgsAbstract3DSymbol
|
||||
|
||||
private:
|
||||
//! how to handle altitude of vector features
|
||||
AltitudeClamping mAltClamping = AltClampRelative;
|
||||
Qgs3DTypes::AltitudeClamping mAltClamping = Qgs3DTypes::AltClampRelative;
|
||||
//! how to handle clamping of vertices of individual features
|
||||
AltitudeBinding mAltBinding = AltBindCentroid;
|
||||
Qgs3DTypes::AltitudeBinding mAltBinding = Qgs3DTypes::AltBindCentroid;
|
||||
|
||||
float mHeight = 0.0f; //!< Base height of polygons
|
||||
float mExtrusionHeight = 0.0f; //!< How much to extrude (0 means no walls)
|
||||
QgsPhongMaterialSettings mMaterial; //!< Defines appearance of objects
|
||||
Qt3DRender::QCullFace::CullingMode mCullingMode = Qt3DRender::QCullFace::NoCulling; //!< Front/back culling mode
|
||||
Qgs3DTypes::CullingMode mCullingMode = Qgs3DTypes::NoCulling; //!< Front/back culling mode
|
||||
bool mInvertNormals = false;
|
||||
bool mAddBackFaces = false;
|
||||
};
|
||||
|
@ -107,6 +107,17 @@ void QgsPolygon3DSymbolEntity::addEntityForNotSelectedPolygons( const Qgs3DMapSe
|
||||
entity->setParent( this );
|
||||
}
|
||||
|
||||
static Qt3DRender::QCullFace::CullingMode _qt3DcullingMode( Qgs3DTypes::CullingMode mode )
|
||||
{
|
||||
switch ( mode )
|
||||
{
|
||||
case Qgs3DTypes::NoCulling: return Qt3DRender::QCullFace::NoCulling;
|
||||
case Qgs3DTypes::Front: return Qt3DRender::QCullFace::Front;
|
||||
case Qgs3DTypes::Back: return Qt3DRender::QCullFace::Back;
|
||||
case Qgs3DTypes::FrontAndBack: return Qt3DRender::QCullFace::FrontAndBack;
|
||||
}
|
||||
return Qt3DRender::QCullFace::NoCulling;
|
||||
}
|
||||
|
||||
Qt3DExtras::QPhongMaterial *QgsPolygon3DSymbolEntity::material( const QgsPolygon3DSymbol &symbol ) const
|
||||
{
|
||||
@ -120,7 +131,7 @@ Qt3DExtras::QPhongMaterial *QgsPolygon3DSymbolEntity::material( const QgsPolygon
|
||||
for ( auto rpit = renderPasses.begin(); rpit != renderPasses.end(); ++rpit )
|
||||
{
|
||||
Qt3DRender::QCullFace *cullFace = new Qt3DRender::QCullFace;
|
||||
cullFace->setMode( symbol.cullingMode() );
|
||||
cullFace->setMode( _qt3DcullingMode( symbol.cullingMode() ) );
|
||||
( *rpit )->addRenderState( cullFace );
|
||||
}
|
||||
}
|
||||
|
@ -44,8 +44,8 @@ void QgsLine3DSymbolWidget::setSymbol( const QgsLine3DSymbol &symbol )
|
||||
spinWidth->setValue( symbol.width() );
|
||||
spinHeight->setValue( symbol.height() );
|
||||
spinExtrusion->setValue( symbol.extrusionHeight() );
|
||||
cboAltClamping->setCurrentIndex( ( int ) symbol.altitudeClamping() );
|
||||
cboAltBinding->setCurrentIndex( ( int ) symbol.altitudeBinding() );
|
||||
cboAltClamping->setCurrentIndex( static_cast<int>( symbol.altitudeClamping() ) );
|
||||
cboAltBinding->setCurrentIndex( static_cast<int>( symbol.altitudeBinding() ) );
|
||||
chkSimpleLines->setChecked( symbol.renderAsSimpleLines() );
|
||||
widgetMaterial->setMaterial( symbol.material() );
|
||||
updateGuiState();
|
||||
@ -57,8 +57,8 @@ QgsLine3DSymbol QgsLine3DSymbolWidget::symbol() const
|
||||
sym.setWidth( spinWidth->value() );
|
||||
sym.setHeight( spinHeight->value() );
|
||||
sym.setExtrusionHeight( spinExtrusion->value() );
|
||||
sym.setAltitudeClamping( ( AltitudeClamping ) cboAltClamping->currentIndex() );
|
||||
sym.setAltitudeBinding( ( AltitudeBinding ) cboAltBinding->currentIndex() );
|
||||
sym.setAltitudeClamping( static_cast<Qgs3DTypes::AltitudeClamping>( cboAltClamping->currentIndex() ) );
|
||||
sym.setAltitudeBinding( static_cast<Qgs3DTypes::AltitudeBinding>( cboAltBinding->currentIndex() ) );
|
||||
sym.setRenderAsSimpleLines( chkSimpleLines->isChecked() );
|
||||
sym.setMaterial( widgetMaterial->material() );
|
||||
return sym;
|
||||
|
@ -97,7 +97,7 @@ void QgsPoint3DSymbolWidget::onOverwriteMaterialChecked( int state )
|
||||
|
||||
void QgsPoint3DSymbolWidget::setSymbol( const QgsPoint3DSymbol &symbol )
|
||||
{
|
||||
cboAltClamping->setCurrentIndex( ( int ) symbol.altitudeClamping() );
|
||||
cboAltClamping->setCurrentIndex( static_cast<int>( symbol.altitudeClamping() ) );
|
||||
|
||||
QVariantMap vm = symbol.shapeProperties();
|
||||
int index = cboShape->findData( symbol.shape() );
|
||||
@ -209,8 +209,8 @@ QgsPoint3DSymbol QgsPoint3DSymbolWidget::symbol() const
|
||||
tr.rotate( rot );
|
||||
|
||||
QgsPoint3DSymbol sym;
|
||||
sym.setAltitudeClamping( ( AltitudeClamping ) cboAltClamping->currentIndex() );
|
||||
sym.setShape( ( QgsPoint3DSymbol::Shape ) cboShape->itemData( cboShape->currentIndex() ).toInt() );
|
||||
sym.setAltitudeClamping( static_cast<Qgs3DTypes::AltitudeClamping>( cboAltClamping->currentIndex() ) );
|
||||
sym.setShape( static_cast<QgsPoint3DSymbol::Shape>( cboShape->itemData( cboShape->currentIndex() ).toInt() ) );
|
||||
sym.setShapeProperties( vm );
|
||||
sym.setMaterial( widgetMaterial->material() );
|
||||
sym.setTransform( tr );
|
||||
|
@ -39,39 +39,13 @@ QgsPolygon3DSymbolWidget::QgsPolygon3DSymbolWidget( QWidget *parent )
|
||||
connect( btnExtrusionDD, &QgsPropertyOverrideButton::changed, this, &QgsPolygon3DSymbolWidget::changed );
|
||||
}
|
||||
|
||||
|
||||
static int _cullingModeToIndex( Qt3DRender::QCullFace::CullingMode mode )
|
||||
{
|
||||
switch ( mode )
|
||||
{
|
||||
case Qt3DRender::QCullFace::NoCulling: return 0;
|
||||
case Qt3DRender::QCullFace::Front: return 1;
|
||||
case Qt3DRender::QCullFace::Back: return 2;
|
||||
case Qt3DRender::QCullFace::FrontAndBack: return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Qt3DRender::QCullFace::CullingMode _cullingModeFromIndex( int index )
|
||||
{
|
||||
switch ( index )
|
||||
{
|
||||
case 0: return Qt3DRender::QCullFace::NoCulling;
|
||||
case 1: return Qt3DRender::QCullFace::Front;
|
||||
case 2: return Qt3DRender::QCullFace::Back;
|
||||
case 3: return Qt3DRender::QCullFace::FrontAndBack;
|
||||
}
|
||||
return Qt3DRender::QCullFace::NoCulling;
|
||||
}
|
||||
|
||||
|
||||
void QgsPolygon3DSymbolWidget::setSymbol( const QgsPolygon3DSymbol &symbol, QgsVectorLayer *layer )
|
||||
{
|
||||
spinHeight->setValue( symbol.height() );
|
||||
spinExtrusion->setValue( symbol.extrusionHeight() );
|
||||
cboAltClamping->setCurrentIndex( ( int ) symbol.altitudeClamping() );
|
||||
cboAltBinding->setCurrentIndex( ( int ) symbol.altitudeBinding() );
|
||||
cboCullingMode->setCurrentIndex( _cullingModeToIndex( symbol.cullingMode() ) );
|
||||
cboAltClamping->setCurrentIndex( static_cast<int>( symbol.altitudeClamping() ) );
|
||||
cboAltBinding->setCurrentIndex( static_cast<int>( symbol.altitudeBinding() ) );
|
||||
cboCullingMode->setCurrentIndex( static_cast<int>( symbol.cullingMode() ) );
|
||||
chkAddBackFaces->setChecked( symbol.addBackFaces() );
|
||||
chkInvertNormals->setChecked( symbol.invertNormals() );
|
||||
widgetMaterial->setMaterial( symbol.material() );
|
||||
@ -85,9 +59,9 @@ QgsPolygon3DSymbol QgsPolygon3DSymbolWidget::symbol() const
|
||||
QgsPolygon3DSymbol sym;
|
||||
sym.setHeight( spinHeight->value() );
|
||||
sym.setExtrusionHeight( spinExtrusion->value() );
|
||||
sym.setAltitudeClamping( ( AltitudeClamping ) cboAltClamping->currentIndex() );
|
||||
sym.setAltitudeBinding( ( AltitudeBinding ) cboAltBinding->currentIndex() );
|
||||
sym.setCullingMode( _cullingModeFromIndex( cboCullingMode->currentIndex() ) );
|
||||
sym.setAltitudeClamping( static_cast<Qgs3DTypes::AltitudeClamping>( cboAltClamping->currentIndex() ) );
|
||||
sym.setAltitudeBinding( static_cast<Qgs3DTypes::AltitudeBinding>( cboAltBinding->currentIndex() ) );
|
||||
sym.setCullingMode( static_cast<Qgs3DTypes::CullingMode>( cboCullingMode->currentIndex() ) );
|
||||
sym.setAddBackFaces( chkAddBackFaces->isChecked() );
|
||||
sym.setInvertNormals( chkInvertNormals->isChecked() );
|
||||
sym.setMaterial( widgetMaterial->material() );
|
||||
|
Loading…
x
Reference in New Issue
Block a user