Skip to content

Commit

Permalink
move some raster settings such as std. dev and band combination to
Browse files Browse the repository at this point in the history
general QGIS settings
  • Loading branch information
alexbruy committed Apr 15, 2012
1 parent f844e2f commit f74f70e
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 4 deletions.
75 changes: 75 additions & 0 deletions src/app/qgsoptions.cpp
Expand Up @@ -64,6 +64,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :

connect( spinFontSize, SIGNAL( valueChanged( const QString& ) ), this, SLOT( fontSizeChanged( const QString& ) ) );

connect( chkUseStandardDeviation, SIGNAL( stateChanged( int ) ), this, SLOT( toggleStandardDeviation( int ) ) );

connect( this, SIGNAL( accepted() ), this, SLOT( saveOptions() ) );

QStringList styles = QStyleFactory::keys();
Expand Down Expand Up @@ -327,6 +329,41 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :

cmbLegendDoubleClickAction->setCurrentIndex( settings.value( "/qgis/legendDoubleClickAction", 0 ).toInt() );

//
// Raster properties
//
spnRed->setValue( settings.value( "/Raster/defaultRedBand", 1 ).toInt() );
spnGreen->setValue( settings.value( "/Raster/defaultGreenBand", 2 ).toInt() );
spnBlue->setValue( settings.value( "/Raster/defaultBlueBand", 3 ).toInt() );

//add items to the color enhanceContrast combo box
cboxContrastEnhancementAlgorithm->addItem( tr( "No Stretch" ) );
cboxContrastEnhancementAlgorithm->addItem( tr( "Stretch To MinMax" ) );
cboxContrastEnhancementAlgorithm->addItem( tr( "Stretch And Clip To MinMax" ) );
cboxContrastEnhancementAlgorithm->addItem( tr( "Clip To MinMax" ) );

QString contrastEnchacement = settings.value( "/Raster/defaultContrastEnhancementAlgorithm", "NoEnhancement" ).toString();
if ( contrastEnchacement == "NoEnhancement" )
{
cboxContrastEnhancementAlgorithm->setCurrentIndex( cboxContrastEnhancementAlgorithm->findText( tr( "No Stretch" ) ) );
}
if ( contrastEnchacement == "StretchToMinimumMaximum" )
{
cboxContrastEnhancementAlgorithm->setCurrentIndex( cboxContrastEnhancementAlgorithm->findText( tr( "Stretch To MinMax" ) ) );
}
else if ( contrastEnchacement == "StretchAndClipToMinimumMaximum" )
{
cboxContrastEnhancementAlgorithm->setCurrentIndex( cboxContrastEnhancementAlgorithm->findText( tr( "Stretch And Clip To MinMax" ) ) );
}
else if ( contrastEnchacement == "ClipToMinimumMaximum" )
{
cboxContrastEnhancementAlgorithm->setCurrentIndex( cboxContrastEnhancementAlgorithm->findText( tr( "Clip To MinMax" ) ) );
}

chkUseStandardDeviation->setChecked( settings.value( "/Raster/useStandardDeviation", false ).toBool() );
spnThreeBandStdDev->setValue( settings.value( "/Raster/defaultStandardDeviation", 2.0 ).toDouble() );
toggleStandardDeviation( chkUseStandardDeviation->checkState() );

//set the color for selections
int myRed = settings.value( "/qgis/default_selection_color_red", 255 ).toInt();
int myGreen = settings.value( "/qgis/default_selection_color_green", 255 ).toInt();
Expand Down Expand Up @@ -559,6 +596,18 @@ void QgsOptions::fontSizeChanged( const QString &fontSize )
QgisApp::instance()->setFontSize( fontSize.toInt() );
}

void QgsOptions::toggleStandardDeviation( int state )
{
if ( Qt::Checked == state )
{
spnThreeBandStdDev->setEnabled( true );
}
else
{
spnThreeBandStdDev->setEnabled( false );
}
}

QString QgsOptions::theme()
{
// returns the current theme (as selected in the cmbTheme combo box)
Expand Down Expand Up @@ -688,6 +737,32 @@ void QgsOptions::saveOptions()
settings.setValue( "/IconSize", cmbIconSize->currentText() );
settings.setValue( "/fontPointSize", spinFontSize->value() );

// rasters settings
settings.setValue( "/Raster/defaultRedBand", spnRed->value() );
settings.setValue( "/Raster/defaultGreenBand", spnGreen->value() );
settings.setValue( "/Raster/defaultBlueBand", spnBlue->value() );

if ( cboxContrastEnhancementAlgorithm->currentText() == tr( "No Stretch" ) )
{
settings.setValue( "/Raster/defaultContrastEnhancementAlgorithm", "NoEnhancement" );
}
else if ( cboxContrastEnhancementAlgorithm->currentText() == tr( "Stretch To MinMax" ) )
{
settings.setValue( "/Raster/defaultContrastEnhancementAlgorithm", "StretchToMinimumMaximum" );
}
else if ( cboxContrastEnhancementAlgorithm->currentText() == tr( "Stretch And Clip To MinMax" ) )
{
settings.setValue( "/Raster/defaultContrastEnhancementAlgorithm", "StretchAndClipToMinimumMaximum" );
}
else if ( cboxContrastEnhancementAlgorithm->currentText() == tr( "Clip To MinMax" ) )
{
settings.setValue( "/Raster/defaultContrastEnhancementAlgorithm", "ClipToMinimumMaximum" );
}

settings.setValue( "/Raster/useStandardDeviation", chkUseStandardDeviation->isChecked() );
settings.setValue( "/Raster/defaultStandardDeviation", spnThreeBandStdDev->value() );


settings.setValue( "/Map/updateThreshold", spinBoxUpdateThreshold->value() );
//check behaviour so default projection when new layer is added with no
//projection defined...
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsoptions.h
Expand Up @@ -63,6 +63,8 @@ class QgsOptions : public QDialog, private Ui::QgsOptionsBase

void fontSizeChanged( const QString &fontSize );

void toggleStandardDeviation( int );

/**
* Return the desired state of newly added layers. If a layer
* is to be drawn when added to the map, this function returns
Expand Down
81 changes: 77 additions & 4 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -67,7 +67,7 @@
<x>0</x>
<y>0</y>
<width>761</width>
<height>819</height>
<height>766</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
Expand Down Expand Up @@ -830,7 +830,7 @@
</layout>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>SVG paths</string>
Expand Down Expand Up @@ -876,6 +876,79 @@
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox_14">
<property name="title">
<string>Rasters</string>
</property>
<layout class="QGridLayout" name="gridLayout_12">
<item row="0" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>RGB band selection</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Red band</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QSpinBox" name="spnRed"/>
</item>
<item row="0" column="5">
<widget class="QLabel" name="label_23">
<property name="text">
<string>Green band</string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QSpinBox" name="spnGreen"/>
</item>
<item row="0" column="7">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Blue band</string>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QSpinBox" name="spnBlue"/>
</item>
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="chkUseStandardDeviation">
<property name="text">
<string>Use standard deviation</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_25">
<property name="text">
<string>Contrast enchacement</string>
</property>
</widget>
</item>
<item row="1" column="6" colspan="3">
<widget class="QDoubleSpinBox" name="spnThreeBandStdDev">
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="2" column="6" colspan="3">
<widget class="QComboBox" name="cboxContrastEnhancementAlgorithm"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
Expand Down Expand Up @@ -1274,8 +1347,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>761</width>
<height>573</height>
<width>781</width>
<height>741</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_13">
Expand Down

0 comments on commit f74f70e

Please sign in to comment.