25#include "moc_qgspointcloudrgbrendererwidget.cpp"
33 connect( mRedMinLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mRedMinLineEdit_textChanged );
34 connect( mRedMaxLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mRedMaxLineEdit_textChanged );
35 connect( mGreenMinLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mGreenMinLineEdit_textChanged );
36 connect( mGreenMaxLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mGreenMaxLineEdit_textChanged );
37 connect( mBlueMinLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mBlueMinLineEdit_textChanged );
38 connect( mBlueMaxLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mBlueMaxLineEdit_textChanged );
41 mRedAttributeComboBox->setAllowEmptyAttributeName(
true );
42 mGreenAttributeComboBox->setAllowEmptyAttributeName(
true );
43 mBlueAttributeComboBox->setAllowEmptyAttributeName(
true );
53 mRedAttributeComboBox->setLayer( layer );
54 mGreenAttributeComboBox->setLayer( layer );
55 mBlueAttributeComboBox->setLayer( layer );
57 setFromRenderer( layer->
renderer() );
63 connect( mContrastEnhancementAlgorithmComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointCloudRgbRendererWidget::emitWidgetChanged );
68 mBlockChangedSignal =
true;
69 redAttributeChanged();
70 greenAttributeChanged();
71 blueAttributeChanged();
72 mBlockChangedSignal =
false;
79 return new QgsPointCloudRgbRendererWidget( layer, style );
89 auto renderer = std::make_unique<QgsPointCloudRgbRenderer>();
90 renderer->setRedAttribute( mRedAttributeComboBox->currentAttribute() );
91 renderer->setGreenAttribute( mGreenAttributeComboBox->currentAttribute() );
92 renderer->setBlueAttribute( mBlueAttributeComboBox->currentAttribute() );
94 setCustomMinMaxValues( renderer.get() );
95 return renderer.release();
98void QgsPointCloudRgbRendererWidget::createValidators()
127 bool redMinOk, redMaxOk;
130 if ( redMinOk && redMaxOk && !mRedAttributeComboBox->currentAttribute().isEmpty() )
137 bool greenMinOk, greenMaxOk;
140 if ( greenMinOk && greenMaxOk && !mGreenAttributeComboBox->currentAttribute().isEmpty() )
147 bool blueMinOk, blueMaxOk;
150 if ( blueMinOk && blueMaxOk && !mBlueAttributeComboBox->currentAttribute().isEmpty() )
157 if ( redEnhancement )
160 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() )
163 if ( greenEnhancement )
166 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() )
169 if ( blueEnhancement )
172 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() )
180void QgsPointCloudRgbRendererWidget::mRedMinLineEdit_textChanged(
const QString & )
185void QgsPointCloudRgbRendererWidget::mRedMaxLineEdit_textChanged(
const QString & )
190void QgsPointCloudRgbRendererWidget::mGreenMinLineEdit_textChanged(
const QString & )
195void QgsPointCloudRgbRendererWidget::mGreenMaxLineEdit_textChanged(
const QString & )
200void QgsPointCloudRgbRendererWidget::mBlueMinLineEdit_textChanged(
const QString & )
205void QgsPointCloudRgbRendererWidget::mBlueMaxLineEdit_textChanged(
const QString & )
210void QgsPointCloudRgbRendererWidget::emitWidgetChanged()
212 if ( !mBlockChangedSignal )
213 emit widgetChanged();
216void QgsPointCloudRgbRendererWidget::redAttributeChanged()
218 if ( mLayer && mLayer->dataProvider() )
221 const double max = stats.
maximum( mRedAttributeComboBox->currentAttribute() );
222 if ( !std::isnan( max ) )
224 mDisableMinMaxWidgetRefresh++;
225 mRedMinLineEdit->setText( QLocale().toString( 0 ) );
229 mRedMaxLineEdit->setText( QLocale().toString( max > 255 ? 65535 : 255 ) );
230 mDisableMinMaxWidgetRefresh--;
236void QgsPointCloudRgbRendererWidget::greenAttributeChanged()
238 if ( mLayer && mLayer->dataProvider() )
241 const double max = stats.
maximum( mGreenAttributeComboBox->currentAttribute() );
242 if ( !std::isnan( max ) )
244 mDisableMinMaxWidgetRefresh++;
245 mGreenMinLineEdit->setText( QLocale().toString( 0 ) );
249 mGreenMaxLineEdit->setText( QLocale().toString( max > 255 ? 65535 : 255 ) );
250 mDisableMinMaxWidgetRefresh--;
256void QgsPointCloudRgbRendererWidget::blueAttributeChanged()
258 if ( mLayer && mLayer->dataProvider() )
261 const double max = stats.
maximum( mBlueAttributeComboBox->currentAttribute() );
262 if ( !std::isnan( max ) )
264 mDisableMinMaxWidgetRefresh++;
265 mBlueMinLineEdit->setText( QLocale().toString( 0 ) );
269 mBlueMaxLineEdit->setText( QLocale().toString( max > 255 ? 65535 : 255 ) );
270 mDisableMinMaxWidgetRefresh--;
276void QgsPointCloudRgbRendererWidget::minMaxModified()
278 if ( !mDisableMinMaxWidgetRefresh )
282 mContrastEnhancementAlgorithmComboBox->setCurrentIndex(
290void QgsPointCloudRgbRendererWidget::setMinMaxValue(
const QgsContrastEnhancement *ce, QLineEdit *minEdit, QLineEdit *maxEdit )
292 if ( !minEdit || !maxEdit )
304 minEdit->setText( QLocale().toString( ce->
minimumValue() ) );
305 maxEdit->setText( QLocale().toString( ce->
maximumValue() ) );
309 mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
316 mBlockChangedSignal =
true;
320 mRedAttributeComboBox->setAttribute( mbcr->
redAttribute() );
322 mBlueAttributeComboBox->setAttribute( mbcr->
blueAttribute() );
324 mDisableMinMaxWidgetRefresh++;
328 mDisableMinMaxWidgetRefresh--;
332 if ( mRedAttributeComboBox->findText( QStringLiteral(
"Red" ) ) > -1 && mRedAttributeComboBox->findText( QStringLiteral(
"Green" ) ) > -1 && mRedAttributeComboBox->findText( QStringLiteral(
"Blue" ) ) > -1 )
334 mRedAttributeComboBox->setAttribute( QStringLiteral(
"Red" ) );
335 mGreenAttributeComboBox->setAttribute( QStringLiteral(
"Green" ) );
336 mBlueAttributeComboBox->setAttribute( QStringLiteral(
"Blue" ) );
340 mRedAttributeComboBox->setCurrentIndex( mRedAttributeComboBox->count() > 1 ? 1 : 0 );
341 mGreenAttributeComboBox->setCurrentIndex( mGreenAttributeComboBox->count() > 2 ? 2 : 0 );
342 mBlueAttributeComboBox->setCurrentIndex( mBlueAttributeComboBox->count() > 3 ? 3 : 0 );
345 mBlockChangedSignal =
false;
@ UnknownDataType
Unknown or unspecified type.
Handles contrast enhancement and clipping.
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.
A custom validator which allows entry of doubles in a locale-tolerant way.
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.
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 ...
A database of saved style entities, including symbols, color ramps, text formats and others.