@@ -55,12 +55,20 @@ QgsPointCloudRgbRendererWidget::QgsPointCloudRgbRendererWidget( QgsPointCloudLay
55
55
}
56
56
57
57
connect ( mRedAttributeComboBox , &QgsPointCloudAttributeComboBox::attributeChanged,
58
- this , &QgsPointCloudRgbRendererWidget::emitWidgetChanged );
58
+ this , &QgsPointCloudRgbRendererWidget::redAttributeChanged );
59
59
connect ( mGreenAttributeComboBox , &QgsPointCloudAttributeComboBox::attributeChanged,
60
- this , &QgsPointCloudRgbRendererWidget::emitWidgetChanged );
60
+ this , &QgsPointCloudRgbRendererWidget::greenAttributeChanged );
61
61
connect ( mBlueAttributeComboBox , &QgsPointCloudAttributeComboBox::attributeChanged,
62
- this , &QgsPointCloudRgbRendererWidget::emitWidgetChanged );
62
+ this , &QgsPointCloudRgbRendererWidget::blueAttributeChanged );
63
63
connect ( mContrastEnhancementAlgorithmComboBox , static_cast <void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this , &QgsPointCloudRgbRendererWidget::emitWidgetChanged );
64
+
65
+ if ( layer )
66
+ {
67
+ // set nice initial values
68
+ redAttributeChanged ();
69
+ greenAttributeChanged ();
70
+ blueAttributeChanged ();
71
+ }
64
72
}
65
73
66
74
QgsPointCloudRendererWidget *QgsPointCloudRgbRendererWidget::create ( QgsPointCloudLayer *layer, QgsStyle *style, QgsPointCloudRenderer * )
@@ -200,6 +208,66 @@ void QgsPointCloudRgbRendererWidget::emitWidgetChanged()
200
208
emit widgetChanged ();
201
209
}
202
210
211
+ void QgsPointCloudRgbRendererWidget::redAttributeChanged ()
212
+ {
213
+ if ( mLayer && mLayer ->dataProvider () )
214
+ {
215
+ const QVariant max = mLayer ->dataProvider ()->metadataStatistic ( mRedAttributeComboBox ->currentAttribute (), QgsStatisticalSummary::Max );
216
+ if ( max.isValid () )
217
+ {
218
+ const int maxValue = max.toInt ();
219
+ mDisableMinMaxWidgetRefresh ++;
220
+ mRedMinLineEdit ->setText ( QLocale ().toString ( 0 ) );
221
+
222
+ // try and guess suitable range from input max values -- we don't just take the provider max value directly here, but rather see if it's
223
+ // likely to be 8 bit or 16 bit color values
224
+ mRedMaxLineEdit ->setText ( QLocale ().toString ( maxValue > 255 ? 65024 : 255 ) );
225
+ mDisableMinMaxWidgetRefresh --;
226
+ emitWidgetChanged ();
227
+ }
228
+ }
229
+ }
230
+
231
+ void QgsPointCloudRgbRendererWidget::greenAttributeChanged ()
232
+ {
233
+ if ( mLayer && mLayer ->dataProvider () )
234
+ {
235
+ const QVariant max = mLayer ->dataProvider ()->metadataStatistic ( mGreenAttributeComboBox ->currentAttribute (), QgsStatisticalSummary::Max );
236
+ if ( max.isValid () )
237
+ {
238
+ const int maxValue = max.toInt ();
239
+ mDisableMinMaxWidgetRefresh ++;
240
+ mGreenMinLineEdit ->setText ( QLocale ().toString ( 0 ) );
241
+
242
+ // try and guess suitable range from input max values -- we don't just take the provider max value directly here, but rather see if it's
243
+ // likely to be 8 bit or 16 bit color values
244
+ mGreenMaxLineEdit ->setText ( QLocale ().toString ( maxValue > 255 ? 65024 : 255 ) );
245
+ mDisableMinMaxWidgetRefresh --;
246
+ emitWidgetChanged ();
247
+ }
248
+ }
249
+ }
250
+
251
+ void QgsPointCloudRgbRendererWidget::blueAttributeChanged ()
252
+ {
253
+ if ( mLayer && mLayer ->dataProvider () )
254
+ {
255
+ const QVariant max = mLayer ->dataProvider ()->metadataStatistic ( mBlueAttributeComboBox ->currentAttribute (), QgsStatisticalSummary::Max );
256
+ if ( max.isValid () )
257
+ {
258
+ const int maxValue = max.toInt ();
259
+ mDisableMinMaxWidgetRefresh ++;
260
+ mBlueMinLineEdit ->setText ( QLocale ().toString ( 0 ) );
261
+
262
+ // try and guess suitable range from input max values -- we don't just take the provider max value directly here, but rather see if it's
263
+ // likely to be 8 bit or 16 bit color values
264
+ mBlueMaxLineEdit ->setText ( QLocale ().toString ( maxValue > 255 ? 65024 : 255 ) );
265
+ mDisableMinMaxWidgetRefresh --;
266
+ emitWidgetChanged ();
267
+ }
268
+ }
269
+ }
270
+
203
271
void QgsPointCloudRgbRendererWidget::minMaxModified ()
204
272
{
205
273
if ( !mDisableMinMaxWidgetRefresh )
@@ -246,11 +314,11 @@ void QgsPointCloudRgbRendererWidget::setFromRenderer( const QgsPointCloudRendere
246
314
mGreenAttributeComboBox ->setAttribute ( mbcr->greenAttribute () );
247
315
mBlueAttributeComboBox ->setAttribute ( mbcr->blueAttribute () );
248
316
249
- mDisableMinMaxWidgetRefresh = true ;
317
+ mDisableMinMaxWidgetRefresh ++ ;
250
318
setMinMaxValue ( mbcr->redContrastEnhancement (), mRedMinLineEdit , mRedMaxLineEdit );
251
319
setMinMaxValue ( mbcr->greenContrastEnhancement (), mGreenMinLineEdit , mGreenMaxLineEdit );
252
320
setMinMaxValue ( mbcr->blueContrastEnhancement (), mBlueMinLineEdit , mBlueMaxLineEdit );
253
- mDisableMinMaxWidgetRefresh = false ;
321
+ mDisableMinMaxWidgetRefresh -- ;
254
322
}
255
323
else
256
324
{
0 commit comments