19#include "moc_qgspointcloudrgbrendererwidget.cpp"
31 connect( mRedMinLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mRedMinLineEdit_textChanged );
32 connect( mRedMaxLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mRedMaxLineEdit_textChanged );
33 connect( mGreenMinLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mGreenMinLineEdit_textChanged );
34 connect( mGreenMaxLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mGreenMaxLineEdit_textChanged );
35 connect( mBlueMinLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mBlueMinLineEdit_textChanged );
36 connect( mBlueMaxLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mBlueMaxLineEdit_textChanged );
39 mRedAttributeComboBox->setAllowEmptyAttributeName(
true );
40 mGreenAttributeComboBox->setAllowEmptyAttributeName(
true );
41 mBlueAttributeComboBox->setAllowEmptyAttributeName(
true );
51 mRedAttributeComboBox->setLayer( layer );
52 mGreenAttributeComboBox->setLayer( layer );
53 mBlueAttributeComboBox->setLayer( layer );
55 setFromRenderer( layer->
renderer() );
59 this, &QgsPointCloudRgbRendererWidget::redAttributeChanged );
61 this, &QgsPointCloudRgbRendererWidget::greenAttributeChanged );
63 this, &QgsPointCloudRgbRendererWidget::blueAttributeChanged );
64 connect( mContrastEnhancementAlgorithmComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointCloudRgbRendererWidget::emitWidgetChanged );
69 mBlockChangedSignal =
true;
70 redAttributeChanged();
71 greenAttributeChanged();
72 blueAttributeChanged();
73 mBlockChangedSignal =
false;
80 return new QgsPointCloudRgbRendererWidget( layer, style );
90 std::unique_ptr< QgsPointCloudRgbRenderer > renderer = std::make_unique< QgsPointCloudRgbRenderer >();
91 renderer->setRedAttribute( mRedAttributeComboBox->currentAttribute() );
92 renderer->setGreenAttribute( mGreenAttributeComboBox->currentAttribute() );
93 renderer->setBlueAttribute( mBlueAttributeComboBox->currentAttribute() );
95 setCustomMinMaxValues( renderer.get() );
96 return renderer.release();
99void QgsPointCloudRgbRendererWidget::createValidators()
116 if ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ==
129 bool redMinOk, redMaxOk;
132 if ( redMinOk && redMaxOk && !mRedAttributeComboBox->currentAttribute().isEmpty() )
139 bool greenMinOk, greenMaxOk;
142 if ( greenMinOk && greenMaxOk && !mGreenAttributeComboBox->currentAttribute().isEmpty() )
149 bool blueMinOk, blueMaxOk;
152 if ( blueMinOk && blueMaxOk && !mBlueAttributeComboBox->currentAttribute().isEmpty() )
159 if ( redEnhancement )
162 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) ) );
164 if ( greenEnhancement )
167 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) ) );
169 if ( blueEnhancement )
172 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() ) ) );
179void QgsPointCloudRgbRendererWidget::mRedMinLineEdit_textChanged(
const QString & )
184void QgsPointCloudRgbRendererWidget::mRedMaxLineEdit_textChanged(
const QString & )
189void QgsPointCloudRgbRendererWidget::mGreenMinLineEdit_textChanged(
const QString & )
194void QgsPointCloudRgbRendererWidget::mGreenMaxLineEdit_textChanged(
const QString & )
199void QgsPointCloudRgbRendererWidget::mBlueMinLineEdit_textChanged(
const QString & )
204void QgsPointCloudRgbRendererWidget::mBlueMaxLineEdit_textChanged(
const QString & )
209void QgsPointCloudRgbRendererWidget::emitWidgetChanged()
211 if ( !mBlockChangedSignal )
212 emit widgetChanged();
215void QgsPointCloudRgbRendererWidget::redAttributeChanged()
217 if ( mLayer && mLayer->dataProvider() )
220 const double max = stats.
maximum( mRedAttributeComboBox->currentAttribute() );
221 if ( !std::isnan( max ) )
223 mDisableMinMaxWidgetRefresh++;
224 mRedMinLineEdit->setText( QLocale().toString( 0 ) );
228 mRedMaxLineEdit->setText( QLocale().toString( max > 255 ? 65535 : 255 ) );
229 mDisableMinMaxWidgetRefresh--;
235void QgsPointCloudRgbRendererWidget::greenAttributeChanged()
237 if ( mLayer && mLayer->dataProvider() )
240 const double max = stats.
maximum( mGreenAttributeComboBox->currentAttribute() );
241 if ( !std::isnan( max ) )
243 mDisableMinMaxWidgetRefresh++;
244 mGreenMinLineEdit->setText( QLocale().toString( 0 ) );
248 mGreenMaxLineEdit->setText( QLocale().toString( max > 255 ? 65535 : 255 ) );
249 mDisableMinMaxWidgetRefresh--;
255void QgsPointCloudRgbRendererWidget::blueAttributeChanged()
257 if ( mLayer && mLayer->dataProvider() )
260 const double max = stats.
maximum( mBlueAttributeComboBox->currentAttribute() );
261 if ( !std::isnan( max ) )
263 mDisableMinMaxWidgetRefresh++;
264 mBlueMinLineEdit->setText( QLocale().toString( 0 ) );
268 mBlueMaxLineEdit->setText( QLocale().toString( max > 255 ? 65535 : 255 ) );
269 mDisableMinMaxWidgetRefresh--;
275void QgsPointCloudRgbRendererWidget::minMaxModified()
277 if ( !mDisableMinMaxWidgetRefresh )
281 mContrastEnhancementAlgorithmComboBox->setCurrentIndex(
288void QgsPointCloudRgbRendererWidget::setMinMaxValue(
const QgsContrastEnhancement *ce, QLineEdit *minEdit, QLineEdit *maxEdit )
290 if ( !minEdit || !maxEdit )
302 minEdit->setText( QLocale().toString( ce->
minimumValue() ) );
303 maxEdit->setText( QLocale().toString( ce->
maximumValue() ) );
307 mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
313 mBlockChangedSignal =
true;
317 mRedAttributeComboBox->setAttribute( mbcr->
redAttribute() );
319 mBlueAttributeComboBox->setAttribute( mbcr->
blueAttribute() );
321 mDisableMinMaxWidgetRefresh++;
325 mDisableMinMaxWidgetRefresh--;
329 if ( mRedAttributeComboBox->findText( QStringLiteral(
"Red" ) ) > -1 && mRedAttributeComboBox->findText( QStringLiteral(
"Green" ) ) > -1 &&
330 mRedAttributeComboBox->findText( QStringLiteral(
"Blue" ) ) > -1 )
332 mRedAttributeComboBox->setAttribute( QStringLiteral(
"Red" ) );
333 mGreenAttributeComboBox->setAttribute( QStringLiteral(
"Green" ) );
334 mBlueAttributeComboBox->setAttribute( QStringLiteral(
"Blue" ) );
338 mRedAttributeComboBox->setCurrentIndex( mRedAttributeComboBox->count() > 1 ? 1 : 0 );
339 mGreenAttributeComboBox->setCurrentIndex( mGreenAttributeComboBox->count() > 2 ? 2 : 0 );
340 mBlueAttributeComboBox->setCurrentIndex( mBlueAttributeComboBox->count() > 3 ? 3 : 0 );
343 mBlockChangedSignal =
false;
@ UnknownDataType
Unknown or unspecified type.
Manipulates raster or point cloud pixel values so that they enhanceContrast or clip into a specified ...
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used.
@ StretchToMinimumMaximum
Linear histogram.
@ StretchAndClipToMinimumMaximum
@ NoEnhancement
Default color scaling algorithm, no scaling is applied.
void setMinimumValue(double value, bool generateTable=true)
Sets the minimum value for the contrast enhancement range.
void setContrastEnhancementAlgorithm(ContrastEnhancementAlgorithm algorithm, bool generateTable=true)
Sets the contrast enhancement algorithm.
double minimumValue() const
Returns the minimum value for the contrast enhancement range.
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const
void setMaximumValue(double value, bool generateTable=true)
Sets the maximum value for the contrast enhancement range.
double maximumValue() const
Returns the maximum value for the contrast enhancement range.
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
void attributeChanged(const QString &name)
Emitted when the currently selected attribute changes.
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.
An RGB renderer for 2d visualisation of point clouds using embedded red, green and blue attributes.
void setRedContrastEnhancement(QgsContrastEnhancement *enhancement)
Sets the contrast enhancement to use for the red channel.
QString redAttribute() const
Returns the attribute to use for the red channel.
QString greenAttribute() const
Returns the attribute to use for the green channel.
void setBlueContrastEnhancement(QgsContrastEnhancement *enhancement)
Sets the contrast enhancement to use for the blue channel.
const QgsContrastEnhancement * greenContrastEnhancement() const
Returns the contrast enhancement to use for the green channel.
QString blueAttribute() const
Returns the attribute to use for the blue channel.
void setGreenContrastEnhancement(QgsContrastEnhancement *enhancement)
Sets the contrast enhancement to use for the green channel.
const QgsContrastEnhancement * blueContrastEnhancement() const
Returns the contrast enhancement to use for the blue channel.
const QgsContrastEnhancement * redContrastEnhancement() const
Returns the contrast enhancement to use for the red channel.
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 ...