28QgsPointCloudAttributeByRampRendererWidget::QgsPointCloudAttributeByRampRendererWidget(
QgsPointCloudLayer *layer,
QgsStyle *style )
33 mAttributeComboBox->setAllowEmptyAttributeName(
false );
36 mMinSpin->setShowClearButton(
false );
37 mMaxSpin->setShowClearButton(
false );
41 mAttributeComboBox->setLayer( layer );
43 setFromRenderer( layer->
renderer() );
47 this, &QgsPointCloudAttributeByRampRendererWidget::attributeChanged );
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;
119 if ( !mBlockSetMinMaxFromLayer )
120 setMinMaxFromLayer();
122 mScalarRecalculateMinMaxButton->setEnabled( !std::isnan( mProviderMin ) && !std::isnan( mProviderMax ) );
126void QgsPointCloudAttributeByRampRendererWidget::setMinMaxFromLayer()
128 if ( std::isnan( mProviderMin ) || std::isnan( mProviderMax ) )
131 mBlockMinMaxChanged =
true;
132 mMinSpin->setValue( mProviderMin );
133 mMaxSpin->setValue( mProviderMax );
134 mBlockMinMaxChanged =
false;
141 mBlockChangedSignal =
true;
146 mBlockSetMinMaxFromLayer =
true;
150 mMinSpin->setValue( mbcr->
minimum() );
151 mMaxSpin->setValue( mbcr->
maximum() );
158 if ( mAttributeComboBox->findText( QStringLiteral(
"Intensity" ) ) > -1 )
160 mAttributeComboBox->setAttribute( QStringLiteral(
"Intensity" ) );
164 mAttributeComboBox->setCurrentIndex( mAttributeComboBox->count() > 1 ? 1 : 0 );
168 mBlockChangedSignal =
false;
169 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.