19#include "moc_qgspointcloudattributebyramprendererwidget.cpp"
29QgsPointCloudAttributeByRampRendererWidget::QgsPointCloudAttributeByRampRendererWidget(
QgsPointCloudLayer *layer,
QgsStyle *style )
34 mAttributeComboBox->setAllowEmptyAttributeName(
false );
37 mMinSpin->setShowClearButton(
false );
38 mMaxSpin->setShowClearButton(
false );
42 mAttributeComboBox->setLayer( layer );
44 setFromRenderer( layer->
renderer() );
48 connect( mMinSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsPointCloudAttributeByRampRendererWidget::minMaxChanged );
49 connect( mMaxSpin, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, &QgsPointCloudAttributeByRampRendererWidget::minMaxChanged );
52 connect( mScalarRecalculateMinMaxButton, &QPushButton::clicked,
this, &QgsPointCloudAttributeByRampRendererWidget::setMinMaxFromLayer );
57 return new QgsPointCloudAttributeByRampRendererWidget( layer, style );
67 std::unique_ptr<QgsPointCloudAttributeByRampRenderer> renderer = std::make_unique<QgsPointCloudAttributeByRampRenderer>();
68 renderer->setAttribute( mAttributeComboBox->currentAttribute() );
70 renderer->setMinimum( mMinSpin->value() );
71 renderer->setMaximum( mMaxSpin->value() );
73 renderer->setColorRampShader( mScalarColorRampShaderWidget->shader() );
75 return renderer.release();
78void QgsPointCloudAttributeByRampRendererWidget::emitWidgetChanged()
80 if ( !mBlockChangedSignal )
84void QgsPointCloudAttributeByRampRendererWidget::minMaxChanged()
86 if ( mBlockMinMaxChanged )
89 mScalarColorRampShaderWidget->setMinimumMaximumAndClassify( mMinSpin->value(), mMaxSpin->value() );
92void QgsPointCloudAttributeByRampRendererWidget::attributeChanged()
94 if ( mLayer && mLayer->dataProvider() )
97 const double min = stats.
minimum( mAttributeComboBox->currentAttribute() );
98 const double max = stats.
maximum( mAttributeComboBox->currentAttribute() );
99 if ( !std::isnan( min ) && !std::isnan( max ) )
106 mProviderMin = std::numeric_limits<double>::quiet_NaN();
107 mProviderMax = std::numeric_limits<double>::quiet_NaN();
110 if ( mAttributeComboBox->currentAttribute().compare( QLatin1String(
"z" ), Qt::CaseInsensitive ) == 0 )
114 mProviderMin = mProviderMin * zScale + zOffset;
115 mProviderMax = mProviderMax * zScale + zOffset;
118 if ( !mBlockSetMinMaxFromLayer )
119 setMinMaxFromLayer();
121 mScalarRecalculateMinMaxButton->setEnabled( !std::isnan( mProviderMin ) && !std::isnan( mProviderMax ) );
125void QgsPointCloudAttributeByRampRendererWidget::setMinMaxFromLayer()
127 if ( std::isnan( mProviderMin ) || std::isnan( mProviderMax ) )
130 mBlockMinMaxChanged =
true;
131 mMinSpin->setValue( mProviderMin );
132 mMaxSpin->setValue( mProviderMax );
133 mBlockMinMaxChanged =
false;
140 mBlockChangedSignal =
true;
145 mBlockSetMinMaxFromLayer =
true;
149 mMinSpin->setValue( mbcr->
minimum() );
150 mMaxSpin->setValue( mbcr->
maximum() );
157 if ( mAttributeComboBox->findText( QStringLiteral(
"Intensity" ) ) > -1 )
159 mAttributeComboBox->setAttribute( QStringLiteral(
"Intensity" ) );
163 mAttributeComboBox->setCurrentIndex( mAttributeComboBox->count() > 1 ? 1 : 0 );
167 mBlockChangedSignal =
false;
168 mBlockSetMinMaxFromLayer =
false;
An RGB renderer for 2d visualisation of point clouds using embedded red, green and blue attributes.
double maximum() const
Returns the maximum value for attributes which will be used by the color ramp shader.
QgsColorRampShader colorRampShader() const
Returns the color ramp shader function used to visualize the attribute.
double minimum() const
Returns the minimum value for attributes which will be used by the color ramp shader.
QString attribute() const
Returns the attribute to use for the renderer.
void setAttribute(const QString &attribute)
Sets the attribute to use for the renderer.
void attributeChanged(const QString &name)
Emitted when the currently selected attribute changes.
@ AllTypes
All attribute types.
Point cloud layer specific subclass of QgsMapLayerElevationProperties.
Represents a map layer supporting display of point clouds.
QgsPointCloudRenderer * renderer()
Returns the 2D renderer for the point cloud.
Abstract base class for 2d point cloud renderers.
Class used to store statistics of a point cloud dataset.
double maximum(const QString &attribute) const
Returns the maximum value for the attribute attribute If no matching statistic is available then NaN ...
double minimum(const QString &attribute) const
Returns the minimum value for the attribute attribute If no matching statistic is available then NaN ...
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.