21 #include <Qt3DRender/QMaterial>
22 #include <Qt3DRender/QParameter>
23 #include <Qt3DRender/QTexture>
50 return QStringLiteral(
"single-color" );
57 result->mSingleColor = mSingleColor;
58 copyBaseSettings( result );
66 elem.setAttribute( QStringLiteral(
"point-size" ),
mPointSize );
74 mPointSize = elem.attribute( QStringLiteral(
"point-size" ), QStringLiteral(
"2.0" ) ).toFloat();
86 mat->addParameter( renderingStyle );
87 Qt3DRender::QParameter *pointSizeParameter =
new Qt3DRender::QParameter(
"u_pointSize", QVariant::fromValue(
mPointSize ) );
88 mat->addParameter( pointSizeParameter );
89 Qt3DRender::QParameter *singleColorParameter =
new Qt3DRender::QParameter(
"u_singleColor", QVector3D( mSingleColor.redF(), mSingleColor.greenF(), mSingleColor.blueF() ) );
90 mat->addParameter( singleColorParameter );
105 result->mRenderingParameter = mRenderingParameter;
106 result->mColorRampShader = mColorRampShader;
107 result->mColorRampShaderMin = mColorRampShaderMin;
108 result->mColorRampShaderMax = mColorRampShaderMax;
109 copyBaseSettings( result );
115 return QStringLiteral(
"color-ramp" );
122 elem.setAttribute( QStringLiteral(
"point-size" ),
mPointSize );
123 elem.setAttribute( QStringLiteral(
"rendering-parameter" ), mRenderingParameter );
124 elem.setAttribute( QStringLiteral(
"color-ramp-shader-min" ), mColorRampShaderMin );
125 elem.setAttribute( QStringLiteral(
"color-ramp-shader-max" ), mColorRampShaderMax );
126 QDomDocument doc = elem.ownerDocument();
127 const QDomElement elemColorRampShader = mColorRampShader.
writeXml( doc );
128 elem.appendChild( elemColorRampShader );
135 mPointSize = elem.attribute(
"point-size", QStringLiteral(
"2.0" ) ).toFloat();
136 mRenderingParameter = elem.attribute(
"rendering-parameter", QString() );
137 mColorRampShaderMin = elem.attribute( QStringLiteral(
"color-ramp-shader-min" ), QStringLiteral(
"0.0" ) ).toDouble();
138 mColorRampShaderMax = elem.attribute( QStringLiteral(
"color-ramp-shader-max" ), QStringLiteral(
"1.0" ) ).toDouble();
139 mColorRampShader.
readXml( elem );
144 return mRenderingParameter;
149 mRenderingParameter = parameter;
154 return mColorRampShader;
164 mColorRampShaderMin = min;
165 mColorRampShaderMax = max;
171 mat->addParameter( renderingStyle );
172 Qt3DRender::QParameter *pointSizeParameter =
new Qt3DRender::QParameter(
"u_pointSize", QVariant::fromValue(
mPointSize ) );
173 mat->addParameter( pointSizeParameter );
175 Qt3DRender::QTexture1D *colorRampTexture =
nullptr;
178 colorRampTexture =
new Qt3DRender::QTexture1D( mat );
179 colorRampTexture->addTextureImage(
new QgsColorRampTexture( mColorRampShader, 1 ) );
180 colorRampTexture->setMinificationFilter( Qt3DRender::QTexture1D::Linear );
181 colorRampTexture->setMagnificationFilter( Qt3DRender::QTexture1D::Linear );
185 Qt3DRender::QParameter *colorRampTextureParameter =
new Qt3DRender::QParameter(
"u_colorRampTexture", colorRampTexture );
186 mat->addParameter( colorRampTextureParameter );
187 Qt3DRender::QParameter *colorRampCountParameter =
new Qt3DRender::QParameter(
"u_colorRampCount", mColorRampShader.
colorRampItemList().count() );
188 mat->addParameter( colorRampCountParameter );
190 Qt3DRender::QParameter *colorRampTypeParameter =
new Qt3DRender::QParameter(
"u_colorRampType", colorRampType );
191 mat->addParameter( colorRampTypeParameter );
204 return QStringLiteral(
"rgb" );
211 result->mRedAttribute = mRedAttribute;
212 result->mGreenAttribute = mGreenAttribute;
213 result->mBlueAttribute = mBlueAttribute;
215 if ( mRedContrastEnhancement )
219 if ( mGreenContrastEnhancement )
223 if ( mBlueContrastEnhancement )
227 copyBaseSettings( result );
234 elem.setAttribute( QStringLiteral(
"point-size" ),
mPointSize );
236 elem.setAttribute( QStringLiteral(
"red" ), mRedAttribute );
237 elem.setAttribute( QStringLiteral(
"green" ), mGreenAttribute );
238 elem.setAttribute( QStringLiteral(
"blue" ), mBlueAttribute );
240 QDomDocument doc = elem.ownerDocument();
243 if ( mRedContrastEnhancement )
245 QDomElement redContrastElem = doc.createElement( QStringLiteral(
"redContrastEnhancement" ) );
246 mRedContrastEnhancement->writeXml( doc, redContrastElem );
247 elem.appendChild( redContrastElem );
249 if ( mGreenContrastEnhancement )
251 QDomElement greenContrastElem = doc.createElement( QStringLiteral(
"greenContrastEnhancement" ) );
252 mGreenContrastEnhancement->writeXml( doc, greenContrastElem );
253 elem.appendChild( greenContrastElem );
255 if ( mBlueContrastEnhancement )
257 QDomElement blueContrastElem = doc.createElement( QStringLiteral(
"blueContrastEnhancement" ) );
258 mBlueContrastEnhancement->writeXml( doc, blueContrastElem );
259 elem.appendChild( blueContrastElem );
266 mPointSize = elem.attribute(
"point-size", QStringLiteral(
"2.0" ) ).toFloat();
268 setRedAttribute( elem.attribute( QStringLiteral(
"red" ), QStringLiteral(
"Red" ) ) );
269 setGreenAttribute( elem.attribute( QStringLiteral(
"green" ), QStringLiteral(
"Green" ) ) );
270 setBlueAttribute( elem.attribute( QStringLiteral(
"blue" ), QStringLiteral(
"Blue" ) ) );
274 const QDomElement redContrastElem = elem.firstChildElement( QStringLiteral(
"redContrastEnhancement" ) );
275 if ( !redContrastElem.isNull() )
283 const QDomElement greenContrastElem = elem.firstChildElement( QStringLiteral(
"greenContrastEnhancement" ) );
284 if ( !greenContrastElem.isNull() )
292 const QDomElement blueContrastElem = elem.firstChildElement( QStringLiteral(
"blueContrastEnhancement" ) );
293 if ( !blueContrastElem.isNull() )
304 mat->addParameter( renderingStyle );
305 Qt3DRender::QParameter *pointSizeParameter =
new Qt3DRender::QParameter(
"u_pointSize", QVariant::fromValue(
mPointSize ) );
306 mat->addParameter( pointSizeParameter );
312 return mRedAttribute;
322 return mGreenAttribute;
332 return mBlueAttribute;
342 return mRedContrastEnhancement.get();
347 mRedContrastEnhancement.reset( enhancement );
352 return mGreenContrastEnhancement.get();
357 mGreenContrastEnhancement.reset( enhancement );
362 return mBlueContrastEnhancement.get();
367 mBlueContrastEnhancement.reset( enhancement );
383 result->mRenderingParameter = mRenderingParameter;
384 result->mCategoriesList = mCategoriesList;
385 copyBaseSettings( result );
391 return QStringLiteral(
"classification" );
397 QDomDocument doc = elem.ownerDocument();
399 elem.setAttribute( QStringLiteral(
"point-size" ),
mPointSize );
400 elem.setAttribute( QStringLiteral(
"rendering-parameter" ), mRenderingParameter );
403 QDomElement catsElem = doc.createElement( QStringLiteral(
"categories" ) );
406 QDomElement catElem = doc.createElement( QStringLiteral(
"category" ) );
407 catElem.setAttribute( QStringLiteral(
"value" ), QString::number( category.value() ) );
408 catElem.setAttribute( QStringLiteral(
"label" ), category.label() );
410 catElem.setAttribute( QStringLiteral(
"render" ), category.renderState() ?
"true" :
"false" );
411 catsElem.appendChild( catElem );
413 elem.appendChild( catsElem );
420 mPointSize = elem.attribute(
"point-size", QStringLiteral(
"2.0" ) ).toFloat();
421 mRenderingParameter = elem.attribute(
"rendering-parameter", QString() );
423 const QDomElement catsElem = elem.firstChildElement( QStringLiteral(
"categories" ) );
424 if ( !catsElem.isNull() )
426 mCategoriesList.clear();
427 QDomElement catElem = catsElem.firstChildElement();
428 while ( !catElem.isNull() )
430 if ( catElem.tagName() == QLatin1String(
"category" ) )
432 const int value = catElem.attribute( QStringLiteral(
"value" ) ).toInt();
433 const QString label = catElem.attribute( QStringLiteral(
"label" ) );
434 const bool render = catElem.attribute( QStringLiteral(
"render" ) ) != QLatin1String(
"false" );
438 catElem = catElem.nextSiblingElement();
445 return mRenderingParameter;
455 mCategoriesList = categories;
463 if ( !category.renderState() )
464 filteredOut.push_back( category );
474 QList<QgsColorRampShader::ColorRampItem> colorRampItemList;
477 const QColor color = category.color();
479 colorRampItemList.push_back( item );
482 return colorRampShader;
490 mat->addParameter( renderingStyle );
491 Qt3DRender::QParameter *pointSizeParameter =
new Qt3DRender::QParameter(
"u_pointSize", QVariant::fromValue(
mPointSize ) );
492 mat->addParameter( pointSizeParameter );
494 Qt3DRender::QTexture1D *colorRampTexture =
nullptr;
497 colorRampTexture =
new Qt3DRender::QTexture1D( mat );
498 colorRampTexture->addTextureImage(
new QgsColorRampTexture( mColorRampShader, 1 ) );
499 colorRampTexture->setMinificationFilter( Qt3DRender::QTexture1D::Linear );
500 colorRampTexture->setMagnificationFilter( Qt3DRender::QTexture1D::Linear );
504 Qt3DRender::QParameter *colorRampTextureParameter =
new Qt3DRender::QParameter(
"u_colorRampTexture", colorRampTexture );
505 mat->addParameter( colorRampTextureParameter );
506 Qt3DRender::QParameter *colorRampCountParameter =
new Qt3DRender::QParameter(
"u_colorRampCount", mColorRampShader.
colorRampItemList().count() );
507 mat->addParameter( colorRampCountParameter );
509 Qt3DRender::QParameter *colorRampTypeParameter =
new Qt3DRender::QParameter(
"u_colorRampType", colorRampType );
510 mat->addParameter( colorRampTypeParameter );
@ UnknownDataType
Unknown or unspecified type.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
QgsAbstract3DSymbol * clone() const override SIP_FACTORY
QString attribute() const
Returns the attribute used to select the color of the point cloud.
void fillMaterial(Qt3DRender::QMaterial *material) override SIP_SKIP
Used to fill material object with necessary QParameters (and consequently opengl uniforms)
void setCategoriesList(const QgsPointCloudCategoryList &categories)
Sets the list of categories of the classification.
QgsPointCloudCategoryList getFilteredOutCategories() const
Gets the list of categories of the classification that should not be rendered.
void setAttribute(const QString &attribute)
Sets the attribute used to select the color of the point cloud.
QString symbolType() const override
Returns a unique string identifier of the symbol type.
QgsClassificationPointCloud3DSymbol()
Constructor for QgsClassificationPointCloud3DSymbol.
void fillMaterial(Qt3DRender::QMaterial *material) override SIP_SKIP
Used to fill material object with necessary QParameters (and consequently opengl uniforms)
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
QgsAbstract3DSymbol * clone() const override SIP_FACTORY
void setAttribute(const QString &attribute)
Sets the attribute used to select the color of the point cloud.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
void setColorRampShaderMinMax(double min, double max)
Sets the minimum and maximum values used when classifying colors in the color ramp shader.
QString attribute() const
Returns the attribute used to select the color of the point cloud.
QString symbolType() const override
Returns a unique string identifier of the symbol type.
QgsColorRampShader colorRampShader() const
Returns the color ramp shader used to render the color.
void setColorRampShader(const QgsColorRampShader &colorRampShader)
Sets the color ramp shader used to render the point cloud.
QgsColorRampPointCloud3DSymbol()
Constructor for QgsColorRampPointCloud3DSymbol.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
QList< QgsColorRampShader::ColorRampItem > colorRampItemList() const
Returns the custom colormap.
Type colorRampType() const
Returns the color ramp type.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context=QgsReadWriteContext()) const
Writes configuration to a new DOM element.
void setClassificationMode(ClassificationMode classificationMode)
Sets classification mode.
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &list)
Sets a custom colormap.
void setColorRampType(QgsColorRampShader::Type colorRampType)
Sets the color ramp type.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context=QgsReadWriteContext())
Reads configuration from the given DOM element.
Manipulates raster or point cloud pixel values so that they enhanceContrast or clip into a specified ...
void readXml(const QDomElement &elem)
QgsPointCloud3DSymbol()
Constructor for QgsPointCloud3DSymbol.
void setPointSize(float size)
Sets the point size.
~QgsPointCloud3DSymbol() override
Destructor for QgsPointCloud3DSymbol.
@ SingleColor
Render the point cloud with a single color.
@ ColorRamp
Render the point cloud with a color ramp.
@ RgbRendering
Render the RGB colors of the point cloud.
Represents an individual category (class) from a QgsPointCloudClassifiedRenderer.
The class is used as a container of context for various read/write operations on other objects.
QString blueAttribute() const
Returns the attribute to use for the blue channel.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
void setBlueAttribute(const QString &attribute)
Sets the attribute to use for the blue channel.
void setGreenContrastEnhancement(QgsContrastEnhancement *enhancement SIP_TRANSFER)
Sets the contrast enhancement to use for the green channel.
void fillMaterial(Qt3DRender::QMaterial *material) override SIP_SKIP
Used to fill material object with necessary QParameters (and consequently opengl uniforms)
QgsRgbPointCloud3DSymbol()
Constructor for QgsRGBPointCloud3DSymbol.
QString greenAttribute() const
Returns the attribute to use for the green channel.
QgsContrastEnhancement * blueContrastEnhancement()
Returns the contrast enhancement to use for the blue channel.
void setGreenAttribute(const QString &attribute)
Sets the attribute to use for the green channel.
QString redAttribute() const
Returns the attribute to use for the red channel.
void setBlueContrastEnhancement(QgsContrastEnhancement *enhancement SIP_TRANSFER)
Sets the contrast enhancement to use for the blue channel.
QgsContrastEnhancement * greenContrastEnhancement()
Returns the contrast enhancement to use for the green channel.
QgsContrastEnhancement * redContrastEnhancement()
Returns the contrast enhancement to use for the red channel.
void setRedContrastEnhancement(QgsContrastEnhancement *enhancement SIP_TRANSFER)
Sets the contrast enhancement to use for the red channel.
QgsAbstract3DSymbol * clone() const override SIP_FACTORY
QString symbolType() const override
Returns a unique string identifier of the symbol type.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
void setRedAttribute(const QString &attribute)
Sets the attribute to use for the red channel.
QString symbolType() const override
Returns a unique string identifier of the symbol type.
QgsAbstract3DSymbol * clone() const override SIP_FACTORY
void fillMaterial(Qt3DRender::QMaterial *material) override SIP_SKIP
Used to fill material object with necessary QParameters (and consequently opengl uniforms)
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
QgsSingleColorPointCloud3DSymbol()
Constructor for QgsSingleColorPointCloud3DSymbol.
void setSingleColor(QColor color)
Sets the color used by the renderer when using SingleColor rendering mode.
static QColor decodeColor(const QString &str)
static QString encodeColor(const QColor &color)
QList< QgsPointCloudCategory > QgsPointCloudCategoryList