Skip to content

Commit 3ded44a

Browse files
mbernasocchipka
authored andcommitted
Added disabling of irrelevant options to settings dialog
1 parent 4694931 commit 3ded44a

File tree

3 files changed

+138
-57
lines changed

3 files changed

+138
-57
lines changed

src/plugins/globe/globe_plugin_dialog.cpp

Lines changed: 67 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Id$
2+
* $Id$
33
*/
44
/***************************************************************************
55
globe_plugin_dialog.cpp - settings dialog for the globe plugin
@@ -41,6 +41,7 @@ QgsGlobePluginDialog::QgsGlobePluginDialog( QWidget* parent, Qt::WFlags fl )
4141
setupUi( this );
4242
loadStereoConfig(); //values from settings, default values from OSG
4343
setStereoConfig(); //overwrite with values from QSettings
44+
updateStereoDialog(); //update the dialog gui
4445
}
4546

4647
//destructor
@@ -49,7 +50,7 @@ QgsGlobePluginDialog::~QgsGlobePluginDialog()
4950
}
5051

5152
QString QgsGlobePluginDialog::openFile()
52-
{
53+
{
5354
QString path = QFileDialog::getOpenFileName( this,
5455
tr( "Open earth file" ),
5556
earthFile,
@@ -69,12 +70,58 @@ bool QgsGlobePluginDialog::globeRunning()
6970
return true;
7071
}
7172

73+
void QgsGlobePluginDialog::updateStereoDialog()
74+
{
75+
QString stereoMode = comboStereoMode->currentText() ;
76+
screenDistance->setEnabled( true );
77+
screenHeight->setEnabled( true );
78+
screenWidth->setEnabled( true );
79+
eyeSeparation->setEnabled( true );
80+
splitStereoHorizontalSeparation->setEnabled( false );
81+
splitStereoVerticalSeparation->setEnabled( false );
82+
splitStereoHorizontalEyeMapping->setEnabled( false );
83+
splitStereoVerticalEyeMapping->setEnabled( false );
84+
85+
if("OFF" == stereoMode)
86+
{
87+
screenDistance->setEnabled( false );
88+
screenHeight->setEnabled( false );
89+
screenWidth->setEnabled( false );
90+
eyeSeparation->setEnabled( false );
91+
}
92+
else if("ANAGLYPHIC" == stereoMode)
93+
{
94+
//nothing to do
95+
}
96+
else if("VERTICAL_SPLIT" == stereoMode)
97+
{
98+
splitStereoVerticalSeparation->setEnabled( true );
99+
splitStereoVerticalEyeMapping->setEnabled( true );
100+
}
101+
else if("HORIZONTAL_SPLIT" == stereoMode)
102+
{
103+
splitStereoHorizontalSeparation->setEnabled( true );
104+
splitStereoHorizontalEyeMapping->setEnabled( true );
105+
}
106+
else if("QUAD_BUFFER" == stereoMode)
107+
{
108+
//nothing to do
109+
}
110+
else
111+
{
112+
//should never get here
113+
QMessageBox msgBox;
114+
msgBox.setText("This stereo mode has not been implemented yet.");
115+
msgBox.exec();
116+
}
117+
}
118+
72119
void QgsGlobePluginDialog::on_buttonBox_accepted()
73120
{
74121
setStereoConfig();
75122
saveStereoConfig();
76123
/*
77-
*
124+
*
78125
// Validate input settings
79126
QString srcUrl( inputSrcDataset->text() );
80127
QString srcLayer( comboSrcLayer->currentText() );
@@ -156,11 +203,11 @@ void QgsGlobePluginDialog::on_buttonBox_accepted()
156203
157204
// Close dialog box
158205
*/
159-
206+
160207
if ( globeRunning() )
161208
{
162209
restartGlobe();
163-
}
210+
}
164211
accept();
165212
}
166213

@@ -188,6 +235,7 @@ void QgsGlobePluginDialog::on_resetDefaults_clicked()
188235
void QgsGlobePluginDialog::on_comboStereoMode_currentIndexChanged(QString value)
189236
{
190237
setStereoMode();
238+
updateStereoDialog();
191239
}
192240

193241
void QgsGlobePluginDialog::on_eyeSeparation_valueChanged(double value)
@@ -222,13 +270,13 @@ void QgsGlobePluginDialog::on_splitStereoVerticalSeparation_valueChanged(int val
222270

223271
void QgsGlobePluginDialog::on_splitStereoHorizontalEyeMapping_currentIndexChanged(int value)
224272
{
225-
osg::DisplaySettings::instance()->setSplitStereoHorizontalEyeMapping(
273+
osg::DisplaySettings::instance()->setSplitStereoHorizontalEyeMapping(
226274
(osg::DisplaySettings::SplitStereoHorizontalEyeMapping) value );
227275
}
228276

229277
void QgsGlobePluginDialog::on_splitStereoVerticalEyeMapping_currentIndexChanged(int value)
230278
{
231-
osg::DisplaySettings::instance()->setSplitStereoVerticalEyeMapping(
279+
osg::DisplaySettings::instance()->setSplitStereoVerticalEyeMapping(
232280
(osg::DisplaySettings::SplitStereoVerticalEyeMapping) value );
233281
}
234282

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

242290
void QgsGlobePluginDialog::loadStereoConfig()
243291
{
244-
//TODO: is it ok to default to OFF? or should we implement all of the STEREO_MODES
245-
//and a enable stereo switch?
246-
comboStereoMode->setCurrentIndex( comboStereoMode->findText( settings.value( "/Plugin-Globe/stereoMode",
292+
comboStereoMode->setCurrentIndex( comboStereoMode->findText( settings.value( "/Plugin-Globe/stereoMode",
247293
"OFF" ).toString() ) );
248-
screenDistance->setValue( settings.value( "/Plugin-Globe/screenDistance",
294+
screenDistance->setValue( settings.value( "/Plugin-Globe/screenDistance",
249295
osg::DisplaySettings::instance()->getScreenDistance() ).toDouble() );
250-
screenWidth->setValue( settings.value( "/Plugin-Globe/screenWidth",
296+
screenWidth->setValue( settings.value( "/Plugin-Globe/screenWidth",
251297
osg::DisplaySettings::instance()->getScreenWidth() ).toDouble() );
252-
screenHeight->setValue( settings.value( "/Plugin-Globe/screenHeight",
298+
screenHeight->setValue( settings.value( "/Plugin-Globe/screenHeight",
253299
osg::DisplaySettings::instance()->getScreenHeight() ).toDouble() );
254-
eyeSeparation->setValue( settings.value( "/Plugin-Globe/eyeSeparation",
300+
eyeSeparation->setValue( settings.value( "/Plugin-Globe/eyeSeparation",
255301
osg::DisplaySettings::instance()->getEyeSeparation() ).toDouble() );
256-
splitStereoHorizontalSeparation->setValue( settings.value( "/Plugin-Globe/splitStereoHorizontalSeparation",
302+
splitStereoHorizontalSeparation->setValue( settings.value( "/Plugin-Globe/splitStereoHorizontalSeparation",
257303
osg::DisplaySettings::instance()->getSplitStereoHorizontalSeparation() ).toInt() );
258-
splitStereoVerticalSeparation->setValue( settings.value( "/Plugin-Globe/splitStereoVerticalSeparation",
304+
splitStereoVerticalSeparation->setValue( settings.value( "/Plugin-Globe/splitStereoVerticalSeparation",
259305
osg::DisplaySettings::instance()->getSplitStereoVerticalSeparation() ).toInt() );
260-
splitStereoHorizontalEyeMapping->setCurrentIndex( settings.value( "/Plugin-Globe/splitStereoHorizontalEyeMapping",
306+
splitStereoHorizontalEyeMapping->setCurrentIndex( settings.value( "/Plugin-Globe/splitStereoHorizontalEyeMapping",
261307
osg::DisplaySettings::instance()->getSplitStereoHorizontalEyeMapping() ).toInt() );
262-
splitStereoVerticalEyeMapping->setCurrentIndex( settings.value( "/Plugin-Globe/splitStereoVerticalEyeMapping",
308+
splitStereoVerticalEyeMapping->setCurrentIndex( settings.value( "/Plugin-Globe/splitStereoVerticalEyeMapping",
263309
osg::DisplaySettings::instance()->getSplitStereoVerticalEyeMapping() ).toInt() );
264310
}
265311

@@ -313,11 +359,11 @@ void QgsGlobePluginDialog::setStereoConfig()
313359
osg::DisplaySettings::instance()->setEyeSeparation( eyeSeparation->value() );
314360
osg::DisplaySettings::instance()->setSplitStereoHorizontalSeparation( splitStereoHorizontalSeparation->value() );
315361
osg::DisplaySettings::instance()->setSplitStereoVerticalSeparation( splitStereoVerticalSeparation->value() );
316-
osg::DisplaySettings::instance()->setSplitStereoHorizontalEyeMapping(
362+
osg::DisplaySettings::instance()->setSplitStereoHorizontalEyeMapping(
317363
(osg::DisplaySettings::SplitStereoHorizontalEyeMapping) splitStereoHorizontalEyeMapping->currentIndex() );
318-
osg::DisplaySettings::instance()->setSplitStereoVerticalEyeMapping(
364+
osg::DisplaySettings::instance()->setSplitStereoVerticalEyeMapping(
319365
(osg::DisplaySettings::SplitStereoVerticalEyeMapping) splitStereoVerticalEyeMapping->currentIndex() );
320-
366+
321367
}
322368

323369
void QgsGlobePluginDialog::saveStereoConfig()

src/plugins/globe/globe_plugin_dialog.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Id$
2+
* $Id$
33
*/
44
/***************************************************************************
55
globe_plugin_dialog.h - settings dialog for the globe plugin
@@ -25,16 +25,17 @@
2525

2626
class QgsGlobePluginDialog:public QDialog, private Ui::QgsGlobePluginDialogGuiBase
2727
{
28-
Q_OBJECT
29-
28+
Q_OBJECT
29+
3030
public:
3131
QgsGlobePluginDialog( QWidget * parent = 0, Qt::WFlags fl = 0 );
3232
~QgsGlobePluginDialog();
33-
33+
3434
private:
3535
QString earthFile;
3636
QString openFile();
3737
QSettings settings;
38+
void updateStereoDialog();
3839
void restartGlobe();
3940
bool globeRunning();
4041
void showMessageBox( QString text);
@@ -50,7 +51,7 @@ class QgsGlobePluginDialog:public QDialog, private Ui::QgsGlobePluginDialogGuiBa
5051
private slots:
5152
void on_buttonBox_accepted();
5253
void on_buttonBox_rejected();
53-
54+
5455
void on_comboStereoMode_currentIndexChanged(QString value);
5556
void on_eyeSeparation_valueChanged(double value);
5657
void on_screenDistance_valueChanged(double value);

0 commit comments

Comments
 (0)