Skip to content

Commit 1e0e9c2

Browse files
nirvnnyalldawson
authored andcommitted
[pseudocolor renderer] fix invert check box in continous mode
(fixes #15209)
1 parent bc32b1f commit 1e0e9c2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,23 @@ void QgsSingleBandPseudoColorRendererWidget::on_mClassifyButton_clicked()
369369
{
370370
for ( int i = 0; i < numberOfEntries; ++i )
371371
{
372-
double value = colorRamp->value( i );
373-
entryValues.push_back( min + value * ( max - min ) );
372+
if ( mInvertCheckBox->isChecked() )
373+
{
374+
double value = 1.0 - colorRamp->value( numberOfEntries - i - 1 );
375+
entryValues.push_back( min + value * ( max - min ) );
376+
}
377+
else
378+
{
379+
double value = colorRamp->value( i );
380+
entryValues.push_back( min + value * ( max - min ) );
381+
}
374382
}
375383
}
376384
// for continuous mode take original color map colors
377385
for ( int i = 0; i < numberOfEntries; ++i )
378386
{
379-
entryColors.push_back( colorRamp->color( colorRamp->value( i ) ) );
387+
int idx = mInvertCheckBox->isChecked() ? numberOfEntries - i - 1 : i;
388+
entryColors.push_back( colorRamp->color( colorRamp->value( idx ) ) );
380389
}
381390
}
382391
}

0 commit comments

Comments
 (0)