Skip to content

Commit 480c860

Browse files
committed
Add option to set min/max values to stdDev in singleband gray and multiband color widgets
1 parent 86c4b6a commit 480c860

File tree

4 files changed

+124
-12
lines changed

4 files changed

+124
-12
lines changed

src/gui/raster/qgsmultibandcolorrendererwidget.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,13 @@ void QgsMultiBandColorRendererWidget::loadMinMaxValueForBand( int band, QLineEdi
237237
minVal = minMax[0];
238238
maxVal = minMax[1];
239239
}
240+
else if ( mUseStdDevRadioButton->isChecked() )
241+
{
242+
QgsRasterBandStats rasterBandStats = mRasterLayer->bandStatistics( band );
243+
double diff = mStdDevSpinBox->value() * rasterBandStats.stdDev;
244+
minVal = rasterBandStats.mean - diff;
245+
maxVal = rasterBandStats.mean + diff;
246+
}
240247

241248
minEdit->setText( QString::number( minVal ) );
242249
maxEdit->setText( QString::number( maxVal ) );

src/gui/raster/qgssinglebandgrayrendererwidget.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ void QgsSingleBandGrayRendererWidget::on_mLoadPushButton_clicked()
113113
minVal = minMax[0];
114114
maxVal = minMax[1];
115115
}
116+
else if ( mUseStdDevRadioButton->isChecked() )
117+
{
118+
QgsRasterBandStats rasterBandStats = mRasterLayer->bandStatistics( band );
119+
double diff = mStdDevSpinBox->value() * rasterBandStats.stdDev;
120+
minVal = rasterBandStats.mean - diff;
121+
maxVal = rasterBandStats.mean + diff;
122+
}
116123
else
117124
{
118125
return;

src/ui/qgsmultibandcolorrendererwidgetbase.ui

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>320</width>
10-
<height>452</height>
10+
<height>529</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -355,7 +355,7 @@
355355
</property>
356356
</widget>
357357
</item>
358-
<item row="2" column="1">
358+
<item row="2" column="1" colspan="2">
359359
<spacer name="horizontalSpacer">
360360
<property name="orientation">
361361
<enum>Qt::Horizontal</enum>
@@ -368,13 +368,65 @@
368368
</property>
369369
</spacer>
370370
</item>
371-
<item row="2" column="2">
371+
<item row="3" column="0">
372+
<widget class="QRadioButton" name="mUseStdDevRadioButton">
373+
<property name="text">
374+
<string>Use standard deviation</string>
375+
</property>
376+
</widget>
377+
</item>
378+
<item row="3" column="1">
379+
<widget class="QDoubleSpinBox" name="mStdDevSpinBox">
380+
<property name="sizePolicy">
381+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
382+
<horstretch>0</horstretch>
383+
<verstretch>0</verstretch>
384+
</sizepolicy>
385+
</property>
386+
<property name="value">
387+
<double>1.000000000000000</double>
388+
</property>
389+
</widget>
390+
</item>
391+
<item row="3" column="2">
392+
<spacer name="horizontalSpacer_4">
393+
<property name="orientation">
394+
<enum>Qt::Horizontal</enum>
395+
</property>
396+
<property name="sizeHint" stdset="0">
397+
<size>
398+
<width>40</width>
399+
<height>20</height>
400+
</size>
401+
</property>
402+
</spacer>
403+
</item>
404+
<item row="4" column="0">
372405
<widget class="QPushButton" name="mLoadPushButton">
406+
<property name="sizePolicy">
407+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
408+
<horstretch>0</horstretch>
409+
<verstretch>0</verstretch>
410+
</sizepolicy>
411+
</property>
373412
<property name="text">
374413
<string>Load</string>
375414
</property>
376415
</widget>
377416
</item>
417+
<item row="4" column="1" colspan="2">
418+
<spacer name="horizontalSpacer_5">
419+
<property name="orientation">
420+
<enum>Qt::Horizontal</enum>
421+
</property>
422+
<property name="sizeHint" stdset="0">
423+
<size>
424+
<width>251</width>
425+
<height>20</height>
426+
</size>
427+
</property>
428+
</spacer>
429+
</item>
378430
</layout>
379431
</widget>
380432
</item>

src/ui/qgssinglebandgrayrendererwidgetbase.ui

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>400</width>
10-
<height>300</height>
9+
<width>388</width>
10+
<height>292</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -68,7 +68,7 @@
6868
<string>Load min-/max values</string>
6969
</property>
7070
<layout class="QGridLayout" name="gridLayout_2">
71-
<item row="0" column="0">
71+
<item row="0" column="0" colspan="2">
7272
<widget class="QRadioButton" name="mEstimateRadioButton">
7373
<property name="text">
7474
<string>Estimate (faster)</string>
@@ -78,7 +78,7 @@
7878
</property>
7979
</widget>
8080
</item>
81-
<item row="0" column="1" colspan="2">
81+
<item row="0" column="2" colspan="3">
8282
<spacer name="horizontalSpacer_3">
8383
<property name="orientation">
8484
<enum>Qt::Horizontal</enum>
@@ -91,14 +91,14 @@
9191
</property>
9292
</spacer>
9393
</item>
94-
<item row="1" column="0">
94+
<item row="1" column="0" colspan="2">
9595
<widget class="QRadioButton" name="mActualRadioButton">
9696
<property name="text">
9797
<string>Actual (slower)</string>
9898
</property>
9999
</widget>
100100
</item>
101-
<item row="1" column="1" colspan="2">
101+
<item row="1" column="2" colspan="3">
102102
<spacer name="horizontalSpacer_2">
103103
<property name="orientation">
104104
<enum>Qt::Horizontal</enum>
@@ -111,14 +111,14 @@
111111
</property>
112112
</spacer>
113113
</item>
114-
<item row="2" column="0">
114+
<item row="2" column="0" colspan="2">
115115
<widget class="QRadioButton" name="mCurrentExtentRadioButton">
116116
<property name="text">
117117
<string>CurrentExtent</string>
118118
</property>
119119
</widget>
120120
</item>
121-
<item row="2" column="1">
121+
<item row="2" column="2" colspan="3">
122122
<spacer name="horizontalSpacer">
123123
<property name="orientation">
124124
<enum>Qt::Horizontal</enum>
@@ -131,13 +131,59 @@
131131
</property>
132132
</spacer>
133133
</item>
134-
<item row="2" column="2">
134+
<item row="3" column="0" colspan="3">
135+
<widget class="QRadioButton" name="mUseStdDevRadioButton">
136+
<property name="text">
137+
<string>Use standard deviation</string>
138+
</property>
139+
</widget>
140+
</item>
141+
<item row="3" column="3">
142+
<widget class="QDoubleSpinBox" name="mStdDevSpinBox">
143+
<property name="sizePolicy">
144+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
145+
<horstretch>0</horstretch>
146+
<verstretch>0</verstretch>
147+
</sizepolicy>
148+
</property>
149+
<property name="value">
150+
<double>1.000000000000000</double>
151+
</property>
152+
</widget>
153+
</item>
154+
<item row="3" column="4">
155+
<spacer name="horizontalSpacer_4">
156+
<property name="orientation">
157+
<enum>Qt::Horizontal</enum>
158+
</property>
159+
<property name="sizeHint" stdset="0">
160+
<size>
161+
<width>148</width>
162+
<height>20</height>
163+
</size>
164+
</property>
165+
</spacer>
166+
</item>
167+
<item row="4" column="0">
135168
<widget class="QPushButton" name="mLoadPushButton">
136169
<property name="text">
137170
<string>Load</string>
138171
</property>
139172
</widget>
140173
</item>
174+
<item row="4" column="1" colspan="4">
175+
<spacer name="horizontalSpacer_5">
176+
<property name="orientation">
177+
<enum>Qt::Horizontal</enum>
178+
</property>
179+
<property name="sizeHint" stdset="0">
180+
<size>
181+
<width>303</width>
182+
<height>20</height>
183+
</size>
184+
</property>
185+
</spacer>
186+
</item>
141187
</layout>
142188
</widget>
143189
</item>

0 commit comments

Comments
 (0)