27#include "moc_qgspointcloudrgbrendererwidget.cpp"
29using namespace Qt::StringLiterals;
37 connect( mRedMinLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mRedMinLineEdit_textChanged );
38 connect( mRedMaxLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mRedMaxLineEdit_textChanged );
39 connect( mGreenMinLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mGreenMinLineEdit_textChanged );
40 connect( mGreenMaxLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mGreenMaxLineEdit_textChanged );
41 connect( mBlueMinLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mBlueMinLineEdit_textChanged );
42 connect( mBlueMaxLineEdit, &QLineEdit::textChanged,
this, &QgsPointCloudRgbRendererWidget::mBlueMaxLineEdit_textChanged );
45 mRedAttributeComboBox->setAllowEmptyAttributeName(
true );
46 mGreenAttributeComboBox->setAllowEmptyAttributeName(
true );
47 mBlueAttributeComboBox->setAllowEmptyAttributeName(
true );
57 mRedAttributeComboBox->setLayer( layer );
58 mGreenAttributeComboBox->setLayer( layer );
59 mBlueAttributeComboBox->setLayer( layer );
61 setFromRenderer( layer->
renderer() );
67 connect( mContrastEnhancementAlgorithmComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsPointCloudRgbRendererWidget::emitWidgetChanged );
72 mBlockChangedSignal =
true;
73 redAttributeChanged();
74 greenAttributeChanged();
75 blueAttributeChanged();
76 mBlockChangedSignal =
false;
83 return new QgsPointCloudRgbRendererWidget( layer, style );
93 auto renderer = std::make_unique<QgsPointCloudRgbRenderer>();
94 renderer->setRedAttribute( mRedAttributeComboBox->currentAttribute() );
95 renderer->setGreenAttribute( mGreenAttributeComboBox->currentAttribute() );
96 renderer->setBlueAttribute( mBlueAttributeComboBox->currentAttribute() );
98 setCustomMinMaxValues( renderer.get() );
99 return renderer.release();
102void QgsPointCloudRgbRendererWidget::createValidators()
131 bool redMinOk, redMaxOk;
134 if ( redMinOk && redMaxOk && !mRedAttributeComboBox->currentAttribute().isEmpty() )
141 bool greenMinOk, greenMaxOk;
144 if ( greenMinOk && greenMaxOk && !mGreenAttributeComboBox->currentAttribute().isEmpty() )
151 bool blueMinOk, blueMaxOk;
154 if ( blueMinOk && blueMaxOk && !mBlueAttributeComboBox->currentAttribute().isEmpty() )
161 if ( redEnhancement )
164 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() )
167 if ( greenEnhancement )
170 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() )
173 if ( blueEnhancement )
176 ( mContrastEnhancementAlgorithmComboBox->currentData().toInt() )
184void QgsPointCloudRgbRendererWidget::mRedMinLineEdit_textChanged(
const QString & )
189void QgsPointCloudRgbRendererWidget::mRedMaxLineEdit_textChanged(
const QString & )
194void QgsPointCloudRgbRendererWidget::mGreenMinLineEdit_textChanged(
const QString & )
199void QgsPointCloudRgbRendererWidget::mGreenMaxLineEdit_textChanged(
const QString & )
204void QgsPointCloudRgbRendererWidget::mBlueMinLineEdit_textChanged(
const QString & )
209void QgsPointCloudRgbRendererWidget::mBlueMaxLineEdit_textChanged(
const QString & )
214void QgsPointCloudRgbRendererWidget::emitWidgetChanged()
216 if ( !mBlockChangedSignal )
217 emit widgetChanged();
220void QgsPointCloudRgbRendererWidget::redAttributeChanged()
222 if ( mLayer && mLayer->dataProvider() )
225 const double max = stats.
maximum( mRedAttributeComboBox->currentAttribute() );
226 if ( !std::isnan( max ) )
228 mDisableMinMaxWidgetRefresh++;
229 mRedMinLineEdit->setText( QLocale().toString( 0 ) );
233 mRedMaxLineEdit->setText( QLocale().toString( max > 255 ? 65535 : 255 ) );
234 mDisableMinMaxWidgetRefresh--;
240void QgsPointCloudRgbRendererWidget::greenAttributeChanged()
242 if ( mLayer && mLayer->dataProvider() )
245 const double max = stats.
maximum( mGreenAttributeComboBox->currentAttribute() );
246 if ( !std::isnan( max ) )
248 mDisableMinMaxWidgetRefresh++;
249 mGreenMinLineEdit->setText( QLocale().toString( 0 ) );
253 mGreenMaxLineEdit->setText( QLocale().toString( max > 255 ? 65535 : 255 ) );
254 mDisableMinMaxWidgetRefresh--;
260void QgsPointCloudRgbRendererWidget::blueAttributeChanged()
262 if ( mLayer && mLayer->dataProvider() )
265 const double max = stats.
maximum( mBlueAttributeComboBox->currentAttribute() );
266 if ( !std::isnan( max ) )
268 mDisableMinMaxWidgetRefresh++;
269 mBlueMinLineEdit->setText( QLocale().toString( 0 ) );
273 mBlueMaxLineEdit->setText( QLocale().toString( max > 255 ? 65535 : 255 ) );
274 mDisableMinMaxWidgetRefresh--;
280void QgsPointCloudRgbRendererWidget::minMaxModified()
282 if ( !mDisableMinMaxWidgetRefresh )
286 mContrastEnhancementAlgorithmComboBox->setCurrentIndex(
294void QgsPointCloudRgbRendererWidget::setMinMaxValue(
const QgsContrastEnhancement *ce, QLineEdit *minEdit, QLineEdit *maxEdit )
296 if ( !minEdit || !maxEdit )
308 minEdit->setText( QLocale().toString( ce->
minimumValue() ) );
309 maxEdit->setText( QLocale().toString( ce->
maximumValue() ) );
313 mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
320 mBlockChangedSignal =
true;
324 mRedAttributeComboBox->setAttribute( mbcr->
redAttribute() );
326 mBlueAttributeComboBox->setAttribute( mbcr->
blueAttribute() );
328 mDisableMinMaxWidgetRefresh++;
332 mDisableMinMaxWidgetRefresh--;
336 if ( mRedAttributeComboBox->findText( u
"Red"_s ) > -1 && mRedAttributeComboBox->findText( u
"Green"_s ) > -1 && mRedAttributeComboBox->findText( u
"Blue"_s ) > -1 )
338 mRedAttributeComboBox->setAttribute( u
"Red"_s );
339 mGreenAttributeComboBox->setAttribute( u
"Green"_s );
340 mBlueAttributeComboBox->setAttribute( u
"Blue"_s );
344 mRedAttributeComboBox->setCurrentIndex( mRedAttributeComboBox->count() > 1 ? 1 : 0 );
345 mGreenAttributeComboBox->setCurrentIndex( mGreenAttributeComboBox->count() > 2 ? 2 : 0 );
346 mBlueAttributeComboBox->setCurrentIndex( mBlueAttributeComboBox->count() > 3 ? 3 : 0 );
349 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.