28 QgsPointCloudAttributeByRampRendererWidget::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, qgis::overload<double>::of( &QDoubleSpinBox::valueChanged ), 
this, &QgsPointCloudAttributeByRampRendererWidget::minMaxChanged );
 
   49   connect( mMaxSpin, qgis::overload<double>::of( &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 = qgis::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();
 
   78 void QgsPointCloudAttributeByRampRendererWidget::emitWidgetChanged()
 
   80   if ( !mBlockChangedSignal )
 
   84 void QgsPointCloudAttributeByRampRendererWidget::minMaxChanged()
 
   86   if ( mBlockMinMaxChanged )
 
   89   mScalarColorRampShaderWidget->setMinimumMaximumAndClassify( mMinSpin->value(), mMaxSpin->value() );
 
   92 void QgsPointCloudAttributeByRampRendererWidget::attributeChanged()
 
   94   if ( mLayer && mLayer->dataProvider() )
 
   96     const QVariant min = mLayer->dataProvider()->metadataStatistic( mAttributeComboBox->currentAttribute(), 
QgsStatisticalSummary::Min );
 
   97     const QVariant max = mLayer->dataProvider()->metadataStatistic( mAttributeComboBox->currentAttribute(), 
QgsStatisticalSummary::Max );
 
   98     if ( min.isValid() && max.isValid() )
 
  100       mProviderMin = min.toDouble();
 
  101       mProviderMax = max.toDouble();
 
  105       mProviderMin = std::numeric_limits< double >::quiet_NaN();
 
  106       mProviderMax = std::numeric_limits< double >::quiet_NaN();
 
  109     if ( mAttributeComboBox->currentAttribute().compare( QLatin1String( 
"z" ), Qt::CaseInsensitive ) == 0 )
 
  113       mProviderMin = mProviderMin * zScale + zOffset;
 
  114       mProviderMax = mProviderMax * zScale + zOffset;
 
  118   if ( !mBlockSetMinMaxFromLayer )
 
  119     setMinMaxFromLayer();
 
  121   mScalarRecalculateMinMaxButton->setEnabled( !std::isnan( mProviderMin ) && !std::isnan( mProviderMax ) );
 
  125 void 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.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.