Skip to content

Commit 93cbb54

Browse files
committedJul 29, 2012
raster cumulative cut optional limits
1 parent e8bbc2d commit 93cbb54

File tree

5 files changed

+301
-111
lines changed

5 files changed

+301
-111
lines changed
 

‎src/app/qgsoptions.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
394394
spnThreeBandStdDev->setValue( settings.value( "/Raster/defaultStandardDeviation", 2.0 ).toDouble() );
395395
toggleStandardDeviation( chkUseStandardDeviation->checkState() );
396396

397+
mRasterCumulativeCutLowerDoubleSpinBox->setValue( 100.0 * settings.value( "/Raster/cumulativeCutLower", QString::number( QgsRasterLayer::CUMULATIVE_CUT_LOWER ) ).toDouble() );
398+
mRasterCumulativeCutUpperDoubleSpinBox->setValue( 100.0 * settings.value( "/Raster/cumulativeCutUpper", QString::number( QgsRasterLayer::CUMULATIVE_CUT_UPPER ) ).toDouble() );
399+
397400
//set the color for selections
398401
int myRed = settings.value( "/qgis/default_selection_color_red", 255 ).toInt();
399402
int myGreen = settings.value( "/qgis/default_selection_color_green", 255 ).toInt();
@@ -885,6 +888,9 @@ void QgsOptions::saveOptions()
885888
settings.setValue( "/Raster/useStandardDeviation", chkUseStandardDeviation->isChecked() );
886889
settings.setValue( "/Raster/defaultStandardDeviation", spnThreeBandStdDev->value() );
887890

891+
settings.setValue( "/Raster/cumulativeCutLower", mRasterCumulativeCutLowerDoubleSpinBox->value() / 100.0 );
892+
settings.setValue( "/Raster/cumulativeCutUpper", mRasterCumulativeCutUpperDoubleSpinBox->value() / 100.0 );
893+
888894
settings.setValue( "/Map/updateThreshold", spinBoxUpdateThreshold->value() );
889895
//check behaviour so default projection when new layer is added with no
890896
//projection defined...

‎src/core/qgsrasterdataprovider.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ void QgsRasterDataProvider::cumulativeCut( int theBandNo,
912912
int myMaxCount = ( int ) qRound( theUpperCount * myHistogram.nonNullCount );
913913
bool myLowerFound = false;
914914
QgsDebugMsg( QString( "binCount = %1 minimum = %2 maximum = %3 myBinXStep = %4" ).arg( myHistogram.binCount ).arg( myHistogram.minimum ).arg( myHistogram.maximum ).arg( myBinXStep ) );
915+
QgsDebugMsg( QString( "myMinCount = %1 myMaxCount = %2" ).arg( myMinCount ).arg( myMaxCount ) );
915916

916917
for ( int myBin = 0; myBin < myHistogram.histogramVector.size(); myBin++ )
917918
{

‎src/gui/raster/qgsrasterminmaxwidget.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* *
1616
***************************************************************************/
1717

18+
#include <QSettings>
19+
1820
#include "qgsrasterlayer.h"
1921
#include "qgsrasterminmaxwidget.h"
2022

@@ -24,6 +26,12 @@ QgsRasterMinMaxWidget::QgsRasterMinMaxWidget( QgsRasterLayer* theLayer, QWidget
2426
{
2527
QgsDebugMsg( "Entered." );
2628
setupUi( this );
29+
30+
QSettings mySettings;
31+
double myLower = 100.0 * mySettings.value( "/Raster/cumulativeCutLower", QString::number( QgsRasterLayer::CUMULATIVE_CUT_LOWER ) ).toDouble();
32+
double myUpper = 100.0 * mySettings.value( "/Raster/cumulativeCutUpper", QString::number( QgsRasterLayer::CUMULATIVE_CUT_UPPER ) ).toDouble();
33+
mCumulativeCutLowerDoubleSpinBox->setValue( myLower );
34+
mCumulativeCutUpperDoubleSpinBox->setValue( myUpper );
2735
}
2836

2937
QgsRasterMinMaxWidget::~QgsRasterMinMaxWidget()
@@ -59,7 +67,9 @@ void QgsRasterMinMaxWidget::on_mLoadPushButton_clicked()
5967

6068
if ( mCumulativeCutRadioButton->isChecked() )
6169
{
62-
mLayer->dataProvider()->cumulativeCut( myBand, 0.02, 0.98, myMin, myMax, myExtent, mySampleSize );
70+
double myLower = mCumulativeCutLowerDoubleSpinBox->value() / 100.0;
71+
double myUpper = mCumulativeCutUpperDoubleSpinBox->value() / 100.0;
72+
mLayer->dataProvider()->cumulativeCut( myBand, myLower, myUpper, myMin, myMax, myExtent, mySampleSize );
6373
}
6474
else if ( mMinMaxRadioButton->isChecked() )
6575
{

‎src/ui/qgsoptionsbase.ui

Lines changed: 230 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<item row="2" column="0">
3434
<widget class="QTabWidget" name="tabWidget">
3535
<property name="currentIndex">
36-
<number>1</number>
36+
<number>0</number>
3737
</property>
3838
<property name="iconSize">
3939
<size>
@@ -66,8 +66,8 @@
6666
<rect>
6767
<x>0</x>
6868
<y>0</y>
69-
<width>760</width>
70-
<height>1041</height>
69+
<width>766</width>
70+
<height>938</height>
7171
</rect>
7272
</property>
7373
<layout class="QGridLayout" name="gridLayout">
@@ -941,9 +941,9 @@
941941
<property name="geometry">
942942
<rect>
943943
<x>0</x>
944-
<y>0</y>
945-
<width>760</width>
946-
<height>625</height>
944+
<y>-169</y>
945+
<width>766</width>
946+
<height>621</height>
947947
</rect>
948948
</property>
949949
<layout class="QGridLayout" name="gridLayout_8">
@@ -1039,6 +1039,218 @@
10391039
</layout>
10401040
</widget>
10411041
</item>
1042+
<item row="3" column="0">
1043+
<widget class="QGroupBox" name="groupBox_14">
1044+
<property name="title">
1045+
<string>Rasters</string>
1046+
</property>
1047+
<layout class="QVBoxLayout" name="verticalLayout_4">
1048+
<item>
1049+
<widget class="QWidget" name="widget" native="true">
1050+
<layout class="QHBoxLayout" name="horizontalLayout_19">
1051+
<property name="margin">
1052+
<number>0</number>
1053+
</property>
1054+
<item>
1055+
<widget class="QLabel" name="label_21">
1056+
<property name="text">
1057+
<string>RGB band selection</string>
1058+
</property>
1059+
</widget>
1060+
</item>
1061+
<item>
1062+
<spacer name="horizontalSpacer_19">
1063+
<property name="orientation">
1064+
<enum>Qt::Horizontal</enum>
1065+
</property>
1066+
<property name="sizeType">
1067+
<enum>QSizePolicy::Maximum</enum>
1068+
</property>
1069+
<property name="sizeHint" stdset="0">
1070+
<size>
1071+
<width>15</width>
1072+
<height>20</height>
1073+
</size>
1074+
</property>
1075+
</spacer>
1076+
</item>
1077+
<item>
1078+
<widget class="QLabel" name="label_22">
1079+
<property name="text">
1080+
<string>Red band</string>
1081+
</property>
1082+
</widget>
1083+
</item>
1084+
<item>
1085+
<widget class="QSpinBox" name="spnRed"/>
1086+
</item>
1087+
<item>
1088+
<widget class="QLabel" name="label_23">
1089+
<property name="text">
1090+
<string>Green band</string>
1091+
</property>
1092+
</widget>
1093+
</item>
1094+
<item>
1095+
<widget class="QSpinBox" name="spnGreen"/>
1096+
</item>
1097+
<item>
1098+
<widget class="QLabel" name="label_24">
1099+
<property name="text">
1100+
<string>Blue band</string>
1101+
</property>
1102+
</widget>
1103+
</item>
1104+
<item>
1105+
<widget class="QSpinBox" name="spnBlue"/>
1106+
</item>
1107+
<item>
1108+
<spacer name="horizontalSpacer_20">
1109+
<property name="orientation">
1110+
<enum>Qt::Horizontal</enum>
1111+
</property>
1112+
<property name="sizeHint" stdset="0">
1113+
<size>
1114+
<width>40</width>
1115+
<height>20</height>
1116+
</size>
1117+
</property>
1118+
</spacer>
1119+
</item>
1120+
</layout>
1121+
</widget>
1122+
</item>
1123+
<item>
1124+
<widget class="QWidget" name="widget_2" native="true">
1125+
<layout class="QHBoxLayout" name="horizontalLayout_20">
1126+
<property name="margin">
1127+
<number>0</number>
1128+
</property>
1129+
<item>
1130+
<widget class="QCheckBox" name="chkUseStandardDeviation">
1131+
<property name="text">
1132+
<string>Use standard deviation</string>
1133+
</property>
1134+
</widget>
1135+
</item>
1136+
<item>
1137+
<widget class="QDoubleSpinBox" name="spnThreeBandStdDev">
1138+
<property name="maximum">
1139+
<double>10.000000000000000</double>
1140+
</property>
1141+
<property name="singleStep">
1142+
<double>0.100000000000000</double>
1143+
</property>
1144+
</widget>
1145+
</item>
1146+
<item>
1147+
<spacer name="horizontalSpacer_21">
1148+
<property name="orientation">
1149+
<enum>Qt::Horizontal</enum>
1150+
</property>
1151+
<property name="sizeHint" stdset="0">
1152+
<size>
1153+
<width>258</width>
1154+
<height>20</height>
1155+
</size>
1156+
</property>
1157+
</spacer>
1158+
</item>
1159+
</layout>
1160+
</widget>
1161+
</item>
1162+
<item>
1163+
<widget class="QWidget" name="widget_3" native="true">
1164+
<layout class="QHBoxLayout" name="horizontalLayout_22">
1165+
<property name="margin">
1166+
<number>0</number>
1167+
</property>
1168+
<item>
1169+
<widget class="QLabel" name="label_37">
1170+
<property name="text">
1171+
<string>Contrast enhancement</string>
1172+
</property>
1173+
</widget>
1174+
</item>
1175+
<item>
1176+
<widget class="QComboBox" name="cboxContrastEnhancementAlgorithm"/>
1177+
</item>
1178+
<item>
1179+
<spacer name="horizontalSpacer_23">
1180+
<property name="orientation">
1181+
<enum>Qt::Horizontal</enum>
1182+
</property>
1183+
<property name="sizeHint" stdset="0">
1184+
<size>
1185+
<width>208</width>
1186+
<height>20</height>
1187+
</size>
1188+
</property>
1189+
</spacer>
1190+
</item>
1191+
</layout>
1192+
</widget>
1193+
</item>
1194+
<item>
1195+
<widget class="QWidget" name="widget_4" native="true">
1196+
<layout class="QHBoxLayout" name="horizontalLayout_18">
1197+
<property name="margin">
1198+
<number>0</number>
1199+
</property>
1200+
<item>
1201+
<widget class="QLabel" name="label_36">
1202+
<property name="text">
1203+
<string>Cumulative pixel count cut limits</string>
1204+
</property>
1205+
</widget>
1206+
</item>
1207+
<item>
1208+
<widget class="QDoubleSpinBox" name="mRasterCumulativeCutLowerDoubleSpinBox">
1209+
<property name="decimals">
1210+
<number>1</number>
1211+
</property>
1212+
</widget>
1213+
</item>
1214+
<item>
1215+
<widget class="QLabel" name="label_34">
1216+
<property name="text">
1217+
<string>-</string>
1218+
</property>
1219+
</widget>
1220+
</item>
1221+
<item>
1222+
<widget class="QDoubleSpinBox" name="mRasterCumulativeCutUpperDoubleSpinBox">
1223+
<property name="decimals">
1224+
<number>1</number>
1225+
</property>
1226+
</widget>
1227+
</item>
1228+
<item>
1229+
<widget class="QLabel" name="label_35">
1230+
<property name="text">
1231+
<string>%</string>
1232+
</property>
1233+
</widget>
1234+
</item>
1235+
<item>
1236+
<spacer name="horizontalSpacer_18">
1237+
<property name="orientation">
1238+
<enum>Qt::Horizontal</enum>
1239+
</property>
1240+
<property name="sizeHint" stdset="0">
1241+
<size>
1242+
<width>123</width>
1243+
<height>20</height>
1244+
</size>
1245+
</property>
1246+
</spacer>
1247+
</item>
1248+
</layout>
1249+
</widget>
1250+
</item>
1251+
</layout>
1252+
</widget>
1253+
</item>
10421254
<item row="4" column="0">
10431255
<widget class="QGroupBox" name="groupBox_2">
10441256
<property name="title">
@@ -1085,79 +1297,6 @@
10851297
</layout>
10861298
</widget>
10871299
</item>
1088-
<item row="3" column="0">
1089-
<widget class="QGroupBox" name="groupBox_14">
1090-
<property name="title">
1091-
<string>Rasters</string>
1092-
</property>
1093-
<layout class="QGridLayout" name="gridLayout_12">
1094-
<item row="0" column="0">
1095-
<widget class="QLabel" name="label_21">
1096-
<property name="text">
1097-
<string>RGB band selection</string>
1098-
</property>
1099-
</widget>
1100-
</item>
1101-
<item row="0" column="3">
1102-
<widget class="QLabel" name="label_22">
1103-
<property name="text">
1104-
<string>Red band</string>
1105-
</property>
1106-
</widget>
1107-
</item>
1108-
<item row="0" column="4">
1109-
<widget class="QSpinBox" name="spnRed"/>
1110-
</item>
1111-
<item row="0" column="5">
1112-
<widget class="QLabel" name="label_23">
1113-
<property name="text">
1114-
<string>Green band</string>
1115-
</property>
1116-
</widget>
1117-
</item>
1118-
<item row="0" column="6">
1119-
<widget class="QSpinBox" name="spnGreen"/>
1120-
</item>
1121-
<item row="0" column="7">
1122-
<widget class="QLabel" name="label_24">
1123-
<property name="text">
1124-
<string>Blue band</string>
1125-
</property>
1126-
</widget>
1127-
</item>
1128-
<item row="0" column="8">
1129-
<widget class="QSpinBox" name="spnBlue"/>
1130-
</item>
1131-
<item row="1" column="0" colspan="3">
1132-
<widget class="QCheckBox" name="chkUseStandardDeviation">
1133-
<property name="text">
1134-
<string>Use standard deviation</string>
1135-
</property>
1136-
</widget>
1137-
</item>
1138-
<item row="2" column="0" colspan="2">
1139-
<widget class="QLabel" name="label_25">
1140-
<property name="text">
1141-
<string>Contrast enhancement</string>
1142-
</property>
1143-
</widget>
1144-
</item>
1145-
<item row="1" column="6" colspan="3">
1146-
<widget class="QDoubleSpinBox" name="spnThreeBandStdDev">
1147-
<property name="maximum">
1148-
<double>10.000000000000000</double>
1149-
</property>
1150-
<property name="singleStep">
1151-
<double>0.100000000000000</double>
1152-
</property>
1153-
</widget>
1154-
</item>
1155-
<item row="2" column="6" colspan="3">
1156-
<widget class="QComboBox" name="cboxContrastEnhancementAlgorithm"/>
1157-
</item>
1158-
</layout>
1159-
</widget>
1160-
</item>
11611300
</layout>
11621301
</widget>
11631302
</widget>
@@ -1189,8 +1328,8 @@
11891328
<rect>
11901329
<x>0</x>
11911330
<y>0</y>
1192-
<width>760</width>
1193-
<height>780</height>
1331+
<width>766</width>
1332+
<height>718</height>
11941333
</rect>
11951334
</property>
11961335
<layout class="QGridLayout" name="gridLayout_4">
@@ -1559,8 +1698,8 @@
15591698
<rect>
15601699
<x>0</x>
15611700
<y>0</y>
1562-
<width>778</width>
1563-
<height>436</height>
1701+
<width>784</width>
1702+
<height>452</height>
15641703
</rect>
15651704
</property>
15661705
<layout class="QGridLayout" name="gridLayout_10">
@@ -1640,8 +1779,8 @@
16401779
<rect>
16411780
<x>0</x>
16421781
<y>0</y>
1643-
<width>760</width>
1644-
<height>627</height>
1782+
<width>766</width>
1783+
<height>572</height>
16451784
</rect>
16461785
</property>
16471786
<layout class="QGridLayout" name="gridLayout_13">
@@ -2016,8 +2155,8 @@
20162155
<rect>
20172156
<x>0</x>
20182157
<y>0</y>
2019-
<width>778</width>
2020-
<height>436</height>
2158+
<width>784</width>
2159+
<height>452</height>
20212160
</rect>
20222161
</property>
20232162
<layout class="QGridLayout" name="gridLayout_15">
@@ -2203,8 +2342,8 @@
22032342
<rect>
22042343
<x>0</x>
22052344
<y>0</y>
2206-
<width>760</width>
2207-
<height>551</height>
2345+
<width>766</width>
2346+
<height>536</height>
22082347
</rect>
22092348
</property>
22102349
<layout class="QGridLayout" name="gridLayout_17">
@@ -2300,8 +2439,8 @@
23002439
<rect>
23012440
<x>0</x>
23022441
<y>0</y>
2303-
<width>760</width>
2304-
<height>554</height>
2442+
<width>766</width>
2443+
<height>491</height>
23052444
</rect>
23062445
</property>
23072446
<layout class="QGridLayout" name="gridLayout_20">

‎src/ui/qgsrasterminmaxwidgetbase.ui

Lines changed: 53 additions & 19 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>416</width>
10-
<height>275</height>
9+
<width>433</width>
10+
<height>293</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -22,29 +22,63 @@
2222
<layout class="QVBoxLayout" name="verticalLayout">
2323
<item>
2424
<widget class="QWidget" name="widget" native="true">
25-
<layout class="QGridLayout" name="gridLayout_4">
26-
<item row="0" column="0" colspan="3">
25+
<layout class="QGridLayout" name="gridLayout">
26+
<item row="0" column="0" colspan="2">
2727
<widget class="QRadioButton" name="mCumulativeCutRadioButton">
2828
<property name="text">
29-
<string>2 - 98% cumulative pixel count cut</string>
29+
<string>Cumulative pixel count cut</string>
3030
</property>
3131
<property name="checked">
3232
<bool>true</bool>
3333
</property>
3434
</widget>
3535
</item>
36-
<item row="0" column="3" colspan="2">
37-
<spacer name="horizontalSpacer_6">
38-
<property name="orientation">
39-
<enum>Qt::Horizontal</enum>
40-
</property>
41-
<property name="sizeHint" stdset="0">
42-
<size>
43-
<width>123</width>
44-
<height>20</height>
45-
</size>
46-
</property>
47-
</spacer>
36+
<item row="0" column="2" colspan="3">
37+
<widget class="QWidget" name="widget_4" native="true">
38+
<layout class="QHBoxLayout" name="horizontalLayout_3">
39+
<item>
40+
<widget class="QDoubleSpinBox" name="mCumulativeCutLowerDoubleSpinBox">
41+
<property name="decimals">
42+
<number>1</number>
43+
</property>
44+
</widget>
45+
</item>
46+
<item>
47+
<widget class="QLabel" name="label">
48+
<property name="text">
49+
<string>-</string>
50+
</property>
51+
</widget>
52+
</item>
53+
<item>
54+
<widget class="QDoubleSpinBox" name="mCumulativeCutUpperDoubleSpinBox">
55+
<property name="decimals">
56+
<number>1</number>
57+
</property>
58+
</widget>
59+
</item>
60+
<item>
61+
<widget class="QLabel" name="label_2">
62+
<property name="text">
63+
<string>%</string>
64+
</property>
65+
</widget>
66+
</item>
67+
<item>
68+
<spacer name="horizontalSpacer_6">
69+
<property name="orientation">
70+
<enum>Qt::Horizontal</enum>
71+
</property>
72+
<property name="sizeHint" stdset="0">
73+
<size>
74+
<width>123</width>
75+
<height>20</height>
76+
</size>
77+
</property>
78+
</spacer>
79+
</item>
80+
</layout>
81+
</widget>
4882
</item>
4983
<item row="1" column="0">
5084
<widget class="QRadioButton" name="mMinMaxRadioButton">
@@ -66,14 +100,14 @@
66100
</property>
67101
</spacer>
68102
</item>
69-
<item row="2" column="0" colspan="2">
103+
<item row="2" column="0" colspan="3">
70104
<widget class="QRadioButton" name="mStdDevRadioButton">
71105
<property name="text">
72106
<string>Mean +/- standard deviation ×</string>
73107
</property>
74108
</widget>
75109
</item>
76-
<item row="2" column="2" colspan="2">
110+
<item row="2" column="3">
77111
<widget class="QDoubleSpinBox" name="mStdDevSpinBox">
78112
<property name="sizePolicy">
79113
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">

0 commit comments

Comments
 (0)
Please sign in to comment.