Address reviews

This commit is contained in:
NEDJIMAbelgacem 2020-12-01 22:40:07 +01:00 committed by Martin Dobias
parent d6a6d9ba64
commit 955eaff38f
11 changed files with 38 additions and 82 deletions

View File

@ -23,4 +23,3 @@
%Include auto_generated/symbols/qgspolygon3dsymbol.sip
%Include auto_generated/symbols/qgspointcloud3dsymbol.sip
%Include auto_generated/qgs3dmapexportsettings.sip
%Include auto_generated/qgscolorramptexture.sip

View File

@ -37,7 +37,7 @@ class QgsPointCloud3DSymbol : QgsAbstract3DSymbol /Abstract/
//! Render the point cloud with a color ramp
ColorRamp,
//! Render the RGB colors of the point cloud
RGBRendering
RgbRendering
};
QgsPointCloud3DSymbol( QgsPointCloud3DSymbol::RenderingStyle style );
@ -207,7 +207,7 @@ Sets the minimum and maximum values used when classifying colors in the color ra
};
class QgsRGBPointCloud3DSymbol : QgsPointCloud3DSymbol
class QgsRgbPointCloud3DSymbol : QgsPointCloud3DSymbol
{
%Docstring
3D symbol that draws point cloud geometries as 3D objects using RGB colors in the dataset
@ -224,9 +224,9 @@ class QgsRGBPointCloud3DSymbol : QgsPointCloud3DSymbol
#include "qgspointcloud3dsymbol.h"
%End
public:
QgsRGBPointCloud3DSymbol();
QgsRgbPointCloud3DSymbol();
%Docstring
Constructor for QgsRGBPointCloud3DSymbol
Constructor for :py:class:`QgsRGBPointCloud3DSymbol`
%End
virtual QgsAbstract3DSymbol *clone() const /Factory/;

View File

@ -35,7 +35,8 @@
#include "qgsmeshlayer.h"
#include "qgsmeshlayerutils.h"
#include "qgstriangularmesh.h"
#ifndef SIP_RUN
#define SIP_NO_FILE
class QgsColorRampTextureGenerator: public Qt3DRender::QTextureImageDataGenerator
{
@ -69,8 +70,6 @@ class QgsColorRampTexture: public Qt3DRender::QAbstractTextureImage
double mVerticalScale = 1;
};
#endif
/// @endcond
#endif // QGSCOLORRAMPTEXTURE_H

View File

@ -142,8 +142,8 @@ void QgsPointCloudLayer3DRenderer::readXml( const QDomElement &elem, const QgsRe
case QgsPointCloud3DSymbol::RenderingStyle::ColorRamp:
mSymbol.reset( new QgsColorRampPointCloud3DSymbol );
break;
case QgsPointCloud3DSymbol::RenderingStyle::RGBRendering:
mSymbol.reset( new QgsRGBPointCloud3DSymbol );
case QgsPointCloud3DSymbol::RenderingStyle::RgbRendering:
mSymbol.reset( new QgsRgbPointCloud3DSymbol );
break;
}
if ( mSymbol )

View File

@ -39,16 +39,11 @@ class QgsPointCloudLayer;
*
* \since QGIS 3.18
*/
class CORE_EXPORT QgsPointCloud3DRenderContext : public Qgs3DRenderContext
class _3D_NO_EXPORT QgsPointCloud3DRenderContext : public Qgs3DRenderContext
{
public:
/**
* Constructor for QgsPointCloud3DRenderContext.
*
* The \a scale and \a offset arguments specify the scale and offset of the layer's int32 coordinates
* compared to CRS coordinates respectively.
*/
//! Constructor for QgsPointCloud3DRenderContext.
QgsPointCloud3DRenderContext( const Qgs3DMapSettings &map, QgsPointCloud3DSymbol *symbol );
//! QgsPointCloudRenderContext cannot be copied.
@ -80,7 +75,7 @@ class CORE_EXPORT QgsPointCloud3DRenderContext : public Qgs3DRenderContext
/**
* Sets the \a symbol used for rendering the point cloud
*
* Takes ownership over the passed symbol
* \see symbol()
*/
void setSymbol( QgsPointCloud3DSymbol *symbol );

View File

@ -62,15 +62,15 @@ QgsPointCloudLayerChunkLoader::QgsPointCloudLayerChunkLoader( const QgsPointClou
QgsDebugMsgLevel( QStringLiteral( "loading entity %1" ).arg( node->tileId().text() ), 2 );
switch ( symbol->renderingStyle() )
{
case QgsPointCloud3DSymbol::NoRendering:
case QgsPointCloud3DSymbol::RenderingStyle::NoRendering:
break;
case QgsPointCloud3DSymbol::SingleColor:
case QgsPointCloud3DSymbol::RenderingStyle::SingleColor:
mHandler.reset( new QgsSingleColorPointCloud3DSymbolHandler() );
break;
case QgsPointCloud3DSymbol::ColorRamp:
case QgsPointCloud3DSymbol::RenderingStyle::ColorRamp:
mHandler.reset( new QgsColorRampPointCloud3DSymbolHandler() );
break;
case QgsPointCloud3DSymbol::RGBRendering:
case QgsPointCloud3DSymbol::RenderingStyle::RgbRendering:
mHandler.reset( new QgsRGBPointCloud3DSymbolHandler() );
break;
}

View File

@ -8,37 +8,13 @@ out vec4 color;
// Sets the redering style, 0: unique color, 1: color ramp shader of terrain, 2: color ramp shader of 2D rendering
uniform int u_renderingStyle;
// Sets the unique mesh color
uniform vec3 u_singleColor; //
uniform vec3 u_singleColor;
// Sets the color ramp type, 0: linear, 1: discrete, 2: exact
uniform int u_colorRampType; //
uniform int u_colorRampType;
// Sets the texture that stores the color ramp
uniform sampler1D u_colorRampTexture; //
// Sets the color ramp value count, used to check the if not void
uniform int u_colorRampCount; //
//vec4 clsidBasedRendering()
//{
// vec4 color;
// if ( abs(clsid-2) < 0.1 ) // ground
// color = vec4(1,1,0,1);
// else if ( abs( clsid - 3 ) < 0.1 ) // low vegetation
// color = vec4(0,0.4,0,1);
// else if ( abs( clsid - 4 ) < 0.1 ) // medium vegetation
// color = vec4(0,0.6,0,1);
// else if ( abs( clsid - 5 ) < 0.1 ) // high vegetation
// color = vec4(0,1,0,1);
// else if ( abs( clsid - 12 ) < 0.1 ) // overlaps
// {
// color = vec4(1,0,0,1);
// discard; // skip overlaps
// }
// else
// {
// color = vec4(0,1,1,1);
// //discard;
// }
// return color;
//}
uniform int u_colorRampCount;
vec3 linearColorRamp()
{
@ -75,7 +51,6 @@ vec3 linearColorRamp()
//last color if no value is found
vec4 colorRampLine=texelFetch(u_colorRampTexture,colorRampSize-1,0);
return colorRampLine.yzw;
return vec3(0.5,0.5,0.5);
}
vec3 discreteColorRamp()

View File

@ -16,6 +16,7 @@
#include "qgspointcloud3dsymbol.h"
#include "qgscolorramptexture.h"
#include "qgssymbollayerutils.h"
#include <Qt3DRender/QMaterial>
#include <Qt3DRender/QParameter>
@ -59,9 +60,7 @@ void QgsSingleColorPointCloud3DSymbol::writeXml( QDomElement &elem, const QgsRea
elem.setAttribute( QStringLiteral( "point-size" ), mPointSize );
elem.setAttribute( QStringLiteral( "rendering-style" ), mRenderingStyle );
elem.setAttribute( QStringLiteral( "single-color-red" ), mSingleColor.redF() );
elem.setAttribute( QStringLiteral( "single-color-green" ), mSingleColor.greenF() );
elem.setAttribute( QStringLiteral( "single-color-blue" ), mSingleColor.blueF() );
elem.setAttribute( QStringLiteral( "single-color" ), QgsSymbolLayerUtils::encodeColor( mSingleColor ) );
}
void QgsSingleColorPointCloud3DSymbol::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
@ -69,10 +68,8 @@ void QgsSingleColorPointCloud3DSymbol::readXml( const QDomElement &elem, const Q
Q_UNUSED( context )
mPointSize = elem.attribute( "point-size", QStringLiteral( "2.0" ) ).toFloat();
mRenderingStyle = static_cast< QgsPointCloud3DSymbol::RenderingStyle >( elem.attribute( "rendering-style", QStringLiteral( "1" ) ).toInt() );
mSingleColor.setRedF( elem.attribute( "single-color-red", QStringLiteral( "0.0" ) ).toFloat() );
mSingleColor.setGreenF( elem.attribute( "single-color-green", QStringLiteral( "0.0" ) ).toFloat() );
mSingleColor.setBlueF( elem.attribute( "single-color-blue", QStringLiteral( "1.0" ) ).toFloat() );
mRenderingStyle = static_cast< QgsPointCloud3DSymbol::RenderingStyle >( elem.attribute( QStringLiteral( "rendering-style" ), QStringLiteral( "1" ) ).toInt() );
mSingleColor = QgsSymbolLayerUtils::decodeColor( elem.attribute( QStringLiteral( "single-color" ), QStringLiteral( "0,0,0" ) ) );
}
void QgsSingleColorPointCloud3DSymbol::setSingleColor( QColor color )
@ -188,37 +185,37 @@ void QgsColorRampPointCloud3DSymbol::fillMaterial( Qt3DRender::QMaterial *mat )
mat->addParameter( colorRampTypeParameter );
}
// QgsRGBPointCloud3DSymbol
// QgsRgbPointCloud3DSymbol
QgsRGBPointCloud3DSymbol::QgsRGBPointCloud3DSymbol()
: QgsPointCloud3DSymbol( QgsPointCloud3DSymbol::RenderingStyle::RGBRendering )
QgsRgbPointCloud3DSymbol::QgsRgbPointCloud3DSymbol()
: QgsPointCloud3DSymbol( QgsPointCloud3DSymbol::RenderingStyle::RgbRendering )
{
}
QgsAbstract3DSymbol *QgsRGBPointCloud3DSymbol::clone() const
QgsAbstract3DSymbol *QgsRgbPointCloud3DSymbol::clone() const
{
QgsRGBPointCloud3DSymbol *result = new QgsRGBPointCloud3DSymbol;
QgsRgbPointCloud3DSymbol *result = new QgsRgbPointCloud3DSymbol;
result->mPointSize = mPointSize;
copyBaseSettings( result );
return result;
}
void QgsRGBPointCloud3DSymbol::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const
void QgsRgbPointCloud3DSymbol::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const
{
Q_UNUSED( context )
elem.setAttribute( QStringLiteral( "rendering-style" ), mRenderingStyle );
elem.setAttribute( QStringLiteral( "point-size" ), mPointSize );
}
void QgsRGBPointCloud3DSymbol::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
void QgsRgbPointCloud3DSymbol::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
{
Q_UNUSED( context )
mRenderingStyle = static_cast< QgsPointCloud3DSymbol::RenderingStyle >( elem.attribute( "rendering-style", QStringLiteral( "3" ) ).toInt() );
mPointSize = elem.attribute( "point-size", QStringLiteral( "2.0" ) ).toFloat();
}
void QgsRGBPointCloud3DSymbol::fillMaterial( Qt3DRender::QMaterial *mat )
void QgsRgbPointCloud3DSymbol::fillMaterial( Qt3DRender::QMaterial *mat )
{
Qt3DRender::QParameter *renderingStyle = new Qt3DRender::QParameter( "u_renderingStyle", mRenderingStyle );
mat->addParameter( renderingStyle );

View File

@ -49,7 +49,7 @@ class _3D_EXPORT QgsPointCloud3DSymbol : public QgsAbstract3DSymbol SIP_ABSTRACT
//! Render the point cloud with a color ramp
ColorRamp,
//! Render the RGB colors of the point cloud
RGBRendering
RgbRendering
};
//! Constructor for QgsPointCloud3DSymbol
@ -205,11 +205,11 @@ class _3D_EXPORT QgsColorRampPointCloud3DSymbol : public QgsPointCloud3DSymbol
*
* \since QGIS 3.18
*/
class _3D_EXPORT QgsRGBPointCloud3DSymbol : public QgsPointCloud3DSymbol
class _3D_EXPORT QgsRgbPointCloud3DSymbol : public QgsPointCloud3DSymbol
{
public:
//! Constructor for QgsRGBPointCloud3DSymbol
QgsRGBPointCloud3DSymbol();
QgsRgbPointCloud3DSymbol();
QgsAbstract3DSymbol *clone() const override SIP_FACTORY;

View File

@ -62,20 +62,11 @@ class QgsPointCloud3DSymbolHandler // : public QgsFeature3DHandler
float mZMin = std::numeric_limits<float>::max();
float mZMax = std::numeric_limits<float>::lowest();
//static void addSceneEntities( const Qgs3DMapSettings &map, const QVector<QVector3D> &positions, const QgsPoint3DSymbol *symbol, Qt3DCore::QEntity *parent );
//static void addMeshEntities( const Qgs3DMapSettings &map, const QVector<QVector3D> &positions, const QgsPoint3DSymbol *symbol, Qt3DCore::QEntity *parent, bool are_selected );
//static Qt3DCore::QTransform *transform( QVector3D position, const QgsPoint3DSymbol *symbol );
void makeEntity( Qt3DCore::QEntity *parent, const QgsPointCloud3DRenderContext &context, PointData &out, bool selected );
virtual Qt3DRender::QGeometry *makeGeometry( Qt3DCore::QNode *parent, const QgsPointCloud3DSymbolHandler::PointData &data, unsigned int byteStride ) = 0;
// input specific for this class
//std::unique_ptr< QgsPoint3DSymbol > mSymbol;
// inputs - generic
//QgsFeatureIds mSelectedIds;
// outputs
PointData outNormal; //!< Features that are not selected
// PointData outSelected; //!< Features that are selected
};
class QgsSingleColorPointCloud3DSymbolHandler : public QgsPointCloud3DSymbolHandler

View File

@ -64,9 +64,9 @@ void QgsPointCloud3DSymbolWidget::setSymbol( QgsPointCloud3DSymbol *symbol )
mColorRampShaderWidget->setFromShader( symb->colorRampShader() );
break;
}
case QgsPointCloud3DSymbol::RenderingStyle::RGBRendering:
case QgsPointCloud3DSymbol::RenderingStyle::RgbRendering:
{
QgsRGBPointCloud3DSymbol *symb = dynamic_cast<QgsRGBPointCloud3DSymbol *>( symbol );
QgsRgbPointCloud3DSymbol *symb = dynamic_cast<QgsRgbPointCloud3DSymbol *>( symbol );
mPointSizeSpinBox->setValue( symb->pointSize() );
break;
}
@ -106,9 +106,9 @@ QgsPointCloud3DSymbol *QgsPointCloud3DSymbolWidget::symbol() const
retSymb = symb;
break;
}
case QgsPointCloud3DSymbol::RenderingStyle::RGBRendering:
case QgsPointCloud3DSymbol::RenderingStyle::RgbRendering:
{
QgsRGBPointCloud3DSymbol *symb = new QgsRGBPointCloud3DSymbol;
QgsRgbPointCloud3DSymbol *symb = new QgsRgbPointCloud3DSymbol;
symb->setPointSize( mPointSizeSpinBox->value() );
retSymb = symb;
break;
@ -151,7 +151,7 @@ void QgsPointCloud3DSymbolWidget::onRenderingStyleChanged( int current )
mSingleColorFrame->setVisible( false );
mPointSizeFrame->setVisible( true );
break;
case QgsPointCloud3DSymbol::RenderingStyle::RGBRendering:
case QgsPointCloud3DSymbol::RenderingStyle::RgbRendering:
mColorRampFrame->setVisible( false );
mSingleColorFrame->setVisible( false );
mPointSizeFrame->setVisible( true );