Skip to content

Commit

Permalink
Added disabling of irrelevant options to settings dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
mbernasocchi authored and pka committed Jul 5, 2011
1 parent 4694931 commit 3ded44a
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 57 deletions.
88 changes: 67 additions & 21 deletions src/plugins/globe/globe_plugin_dialog.cpp
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id$
*/
/***************************************************************************
globe_plugin_dialog.cpp - settings dialog for the globe plugin
Expand Down Expand Up @@ -41,6 +41,7 @@ QgsGlobePluginDialog::QgsGlobePluginDialog( QWidget* parent, Qt::WFlags fl )
setupUi( this );
loadStereoConfig(); //values from settings, default values from OSG
setStereoConfig(); //overwrite with values from QSettings
updateStereoDialog(); //update the dialog gui
}

//destructor
Expand All @@ -49,7 +50,7 @@ QgsGlobePluginDialog::~QgsGlobePluginDialog()
}

QString QgsGlobePluginDialog::openFile()
{
{
QString path = QFileDialog::getOpenFileName( this,
tr( "Open earth file" ),
earthFile,
Expand All @@ -69,12 +70,58 @@ bool QgsGlobePluginDialog::globeRunning()
return true;
}

void QgsGlobePluginDialog::updateStereoDialog()
{
QString stereoMode = comboStereoMode->currentText() ;
screenDistance->setEnabled( true );
screenHeight->setEnabled( true );
screenWidth->setEnabled( true );
eyeSeparation->setEnabled( true );
splitStereoHorizontalSeparation->setEnabled( false );
splitStereoVerticalSeparation->setEnabled( false );
splitStereoHorizontalEyeMapping->setEnabled( false );
splitStereoVerticalEyeMapping->setEnabled( false );

if("OFF" == stereoMode)
{
screenDistance->setEnabled( false );
screenHeight->setEnabled( false );
screenWidth->setEnabled( false );
eyeSeparation->setEnabled( false );
}
else if("ANAGLYPHIC" == stereoMode)
{
//nothing to do
}
else if("VERTICAL_SPLIT" == stereoMode)
{
splitStereoVerticalSeparation->setEnabled( true );
splitStereoVerticalEyeMapping->setEnabled( true );
}
else if("HORIZONTAL_SPLIT" == stereoMode)
{
splitStereoHorizontalSeparation->setEnabled( true );
splitStereoHorizontalEyeMapping->setEnabled( true );
}
else if("QUAD_BUFFER" == stereoMode)
{
//nothing to do
}
else
{
//should never get here
QMessageBox msgBox;
msgBox.setText("This stereo mode has not been implemented yet.");
msgBox.exec();
}
}

void QgsGlobePluginDialog::on_buttonBox_accepted()
{
setStereoConfig();
saveStereoConfig();
/*
*
*
// Validate input settings
QString srcUrl( inputSrcDataset->text() );
QString srcLayer( comboSrcLayer->currentText() );
Expand Down Expand Up @@ -156,11 +203,11 @@ void QgsGlobePluginDialog::on_buttonBox_accepted()
// Close dialog box
*/

if ( globeRunning() )
{
restartGlobe();
}
}
accept();
}

Expand Down Expand Up @@ -188,6 +235,7 @@ void QgsGlobePluginDialog::on_resetDefaults_clicked()
void QgsGlobePluginDialog::on_comboStereoMode_currentIndexChanged(QString value)
{
setStereoMode();
updateStereoDialog();
}

void QgsGlobePluginDialog::on_eyeSeparation_valueChanged(double value)
Expand Down Expand Up @@ -222,13 +270,13 @@ void QgsGlobePluginDialog::on_splitStereoVerticalSeparation_valueChanged(int val

void QgsGlobePluginDialog::on_splitStereoHorizontalEyeMapping_currentIndexChanged(int value)
{
osg::DisplaySettings::instance()->setSplitStereoHorizontalEyeMapping(
osg::DisplaySettings::instance()->setSplitStereoHorizontalEyeMapping(
(osg::DisplaySettings::SplitStereoHorizontalEyeMapping) value );
}

void QgsGlobePluginDialog::on_splitStereoVerticalEyeMapping_currentIndexChanged(int value)
{
osg::DisplaySettings::instance()->setSplitStereoVerticalEyeMapping(
osg::DisplaySettings::instance()->setSplitStereoVerticalEyeMapping(
(osg::DisplaySettings::SplitStereoVerticalEyeMapping) value );
}

Expand All @@ -241,25 +289,23 @@ void QgsGlobePluginDialog::showMessageBox( QString text )

void QgsGlobePluginDialog::loadStereoConfig()
{
//TODO: is it ok to default to OFF? or should we implement all of the STEREO_MODES
//and a enable stereo switch?
comboStereoMode->setCurrentIndex( comboStereoMode->findText( settings.value( "/Plugin-Globe/stereoMode",
comboStereoMode->setCurrentIndex( comboStereoMode->findText( settings.value( "/Plugin-Globe/stereoMode",
"OFF" ).toString() ) );
screenDistance->setValue( settings.value( "/Plugin-Globe/screenDistance",
screenDistance->setValue( settings.value( "/Plugin-Globe/screenDistance",
osg::DisplaySettings::instance()->getScreenDistance() ).toDouble() );
screenWidth->setValue( settings.value( "/Plugin-Globe/screenWidth",
screenWidth->setValue( settings.value( "/Plugin-Globe/screenWidth",
osg::DisplaySettings::instance()->getScreenWidth() ).toDouble() );
screenHeight->setValue( settings.value( "/Plugin-Globe/screenHeight",
screenHeight->setValue( settings.value( "/Plugin-Globe/screenHeight",
osg::DisplaySettings::instance()->getScreenHeight() ).toDouble() );
eyeSeparation->setValue( settings.value( "/Plugin-Globe/eyeSeparation",
eyeSeparation->setValue( settings.value( "/Plugin-Globe/eyeSeparation",
osg::DisplaySettings::instance()->getEyeSeparation() ).toDouble() );
splitStereoHorizontalSeparation->setValue( settings.value( "/Plugin-Globe/splitStereoHorizontalSeparation",
splitStereoHorizontalSeparation->setValue( settings.value( "/Plugin-Globe/splitStereoHorizontalSeparation",
osg::DisplaySettings::instance()->getSplitStereoHorizontalSeparation() ).toInt() );
splitStereoVerticalSeparation->setValue( settings.value( "/Plugin-Globe/splitStereoVerticalSeparation",
splitStereoVerticalSeparation->setValue( settings.value( "/Plugin-Globe/splitStereoVerticalSeparation",
osg::DisplaySettings::instance()->getSplitStereoVerticalSeparation() ).toInt() );
splitStereoHorizontalEyeMapping->setCurrentIndex( settings.value( "/Plugin-Globe/splitStereoHorizontalEyeMapping",
splitStereoHorizontalEyeMapping->setCurrentIndex( settings.value( "/Plugin-Globe/splitStereoHorizontalEyeMapping",
osg::DisplaySettings::instance()->getSplitStereoHorizontalEyeMapping() ).toInt() );
splitStereoVerticalEyeMapping->setCurrentIndex( settings.value( "/Plugin-Globe/splitStereoVerticalEyeMapping",
splitStereoVerticalEyeMapping->setCurrentIndex( settings.value( "/Plugin-Globe/splitStereoVerticalEyeMapping",
osg::DisplaySettings::instance()->getSplitStereoVerticalEyeMapping() ).toInt() );
}

Expand Down Expand Up @@ -313,11 +359,11 @@ void QgsGlobePluginDialog::setStereoConfig()
osg::DisplaySettings::instance()->setEyeSeparation( eyeSeparation->value() );
osg::DisplaySettings::instance()->setSplitStereoHorizontalSeparation( splitStereoHorizontalSeparation->value() );
osg::DisplaySettings::instance()->setSplitStereoVerticalSeparation( splitStereoVerticalSeparation->value() );
osg::DisplaySettings::instance()->setSplitStereoHorizontalEyeMapping(
osg::DisplaySettings::instance()->setSplitStereoHorizontalEyeMapping(
(osg::DisplaySettings::SplitStereoHorizontalEyeMapping) splitStereoHorizontalEyeMapping->currentIndex() );
osg::DisplaySettings::instance()->setSplitStereoVerticalEyeMapping(
osg::DisplaySettings::instance()->setSplitStereoVerticalEyeMapping(
(osg::DisplaySettings::SplitStereoVerticalEyeMapping) splitStereoVerticalEyeMapping->currentIndex() );

}

void QgsGlobePluginDialog::saveStereoConfig()
Expand Down
11 changes: 6 additions & 5 deletions src/plugins/globe/globe_plugin_dialog.h
@@ -1,5 +1,5 @@
/*
* $Id$
* $Id$
*/
/***************************************************************************
globe_plugin_dialog.h - settings dialog for the globe plugin
Expand All @@ -25,16 +25,17 @@

class QgsGlobePluginDialog:public QDialog, private Ui::QgsGlobePluginDialogGuiBase
{
Q_OBJECT
Q_OBJECT

public:
QgsGlobePluginDialog( QWidget * parent = 0, Qt::WFlags fl = 0 );
~QgsGlobePluginDialog();

private:
QString earthFile;
QString openFile();
QSettings settings;
void updateStereoDialog();
void restartGlobe();
bool globeRunning();
void showMessageBox( QString text);
Expand All @@ -50,7 +51,7 @@ class QgsGlobePluginDialog:public QDialog, private Ui::QgsGlobePluginDialogGuiBa
private slots:
void on_buttonBox_accepted();
void on_buttonBox_rejected();

void on_comboStereoMode_currentIndexChanged(QString value);
void on_eyeSeparation_valueChanged(double value);
void on_screenDistance_valueChanged(double value);
Expand Down

0 comments on commit 3ded44a

Please sign in to comment.