Skip to content

Commit

Permalink
Add option to set min/max values to stdDev in singleband gray and mul…
Browse files Browse the repository at this point in the history
…tiband color widgets
  • Loading branch information
mhugent committed Jun 19, 2012
1 parent 86c4b6a commit 480c860
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 12 deletions.
7 changes: 7 additions & 0 deletions src/gui/raster/qgsmultibandcolorrendererwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ void QgsMultiBandColorRendererWidget::loadMinMaxValueForBand( int band, QLineEdi
minVal = minMax[0];
maxVal = minMax[1];
}
else if ( mUseStdDevRadioButton->isChecked() )
{
QgsRasterBandStats rasterBandStats = mRasterLayer->bandStatistics( band );
double diff = mStdDevSpinBox->value() * rasterBandStats.stdDev;
minVal = rasterBandStats.mean - diff;
maxVal = rasterBandStats.mean + diff;
}

minEdit->setText( QString::number( minVal ) );
maxEdit->setText( QString::number( maxVal ) );
Expand Down
7 changes: 7 additions & 0 deletions src/gui/raster/qgssinglebandgrayrendererwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ void QgsSingleBandGrayRendererWidget::on_mLoadPushButton_clicked()
minVal = minMax[0];
maxVal = minMax[1];
}
else if ( mUseStdDevRadioButton->isChecked() )
{
QgsRasterBandStats rasterBandStats = mRasterLayer->bandStatistics( band );
double diff = mStdDevSpinBox->value() * rasterBandStats.stdDev;
minVal = rasterBandStats.mean - diff;
maxVal = rasterBandStats.mean + diff;
}
else
{
return;
Expand Down
58 changes: 55 additions & 3 deletions src/ui/qgsmultibandcolorrendererwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>320</width>
<height>452</height>
<height>529</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -355,7 +355,7 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="2" column="1" colspan="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -368,13 +368,65 @@
</property>
</spacer>
</item>
<item row="2" column="2">
<item row="3" column="0">
<widget class="QRadioButton" name="mUseStdDevRadioButton">
<property name="text">
<string>Use standard deviation</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="mStdDevSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="mLoadPushButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>251</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
Expand Down
64 changes: 55 additions & 9 deletions src/ui/qgssinglebandgrayrendererwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>388</width>
<height>292</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -68,7 +68,7 @@
<string>Load min-/max values</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<item row="0" column="0" colspan="2">
<widget class="QRadioButton" name="mEstimateRadioButton">
<property name="text">
<string>Estimate (faster)</string>
Expand All @@ -78,7 +78,7 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<item row="0" column="2" colspan="3">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -91,14 +91,14 @@
</property>
</spacer>
</item>
<item row="1" column="0">
<item row="1" column="0" colspan="2">
<widget class="QRadioButton" name="mActualRadioButton">
<property name="text">
<string>Actual (slower)</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<item row="1" column="2" colspan="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -111,14 +111,14 @@
</property>
</spacer>
</item>
<item row="2" column="0">
<item row="2" column="0" colspan="2">
<widget class="QRadioButton" name="mCurrentExtentRadioButton">
<property name="text">
<string>CurrentExtent</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="2" column="2" colspan="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -131,13 +131,59 @@
</property>
</spacer>
</item>
<item row="2" column="2">
<item row="3" column="0" colspan="3">
<widget class="QRadioButton" name="mUseStdDevRadioButton">
<property name="text">
<string>Use standard deviation</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QDoubleSpinBox" name="mStdDevSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="4">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>148</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="mLoadPushButton">
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="4">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>303</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 480c860

Please sign in to comment.