31
31
#include < QStringList>
32
32
#include < QVariant>
33
33
34
+ #include < osgViewer/Viewer>
35
+
34
36
// constructor
35
37
QgsGlobePluginDialog::QgsGlobePluginDialog ( QWidget* parent, Qt::WFlags fl )
36
38
: QDialog( parent, fl )
37
39
{
38
40
setupUi ( this );
41
+ stereoMode = settings.value ( " /Plugin-Globe/stereoMode" , " OFF" ).toString ();
42
+ comboStereoMode->setCurrentIndex ( comboStereoMode->findText ( stereoMode ) );
43
+
44
+ earthFile = settings.value ( " /Plugin-Globe/earthFile" , QgsApplication::pkgDataPath () + " /globe/globe.earth" ).toString ();
45
+ inputEarthFile->setText ( earthFile );
39
46
}
40
47
41
48
// destructor
@@ -44,19 +51,64 @@ QgsGlobePluginDialog::~QgsGlobePluginDialog()
44
51
}
45
52
46
53
QString QgsGlobePluginDialog::openFile ()
47
- {
48
- QSettings sets;
54
+ {
49
55
QString path = QFileDialog::getOpenFileName ( this ,
50
- tr ( " Open Earthfile " ),
51
- " /home " ,
52
- tr ( " Earthfiles (*.earth)" ) );
56
+ tr ( " Open earth file " ),
57
+ earthFile ,
58
+ tr ( " Earth files (*.earth)" ) );
53
59
54
60
return path;
55
61
}
56
62
63
+ void QgsGlobePluginDialog::setStereoMode ()
64
+ {
65
+ if (" OFF" == stereoMode)
66
+ {
67
+ osg::DisplaySettings::instance ()->setStereo ( false );
68
+ }
69
+ else if (" ADVANCED" == stereoMode)
70
+ {
71
+ // osg::DisplaySettings::instance()->set
72
+ }
73
+ else
74
+ {
75
+ osg::DisplaySettings::instance ()->setStereo ( true );
76
+
77
+ if (" ANAGLYPHIC" == stereoMode)
78
+ {
79
+ osg::DisplaySettings::instance ()->setStereoMode ( osg::DisplaySettings::ANAGLYPHIC );
80
+ }
81
+ else if (" VERTICAL_SPLIT" == stereoMode)
82
+ {
83
+ osg::DisplaySettings::instance ()->setStereoMode ( osg::DisplaySettings::VERTICAL_SPLIT );
84
+ }
85
+ else
86
+ {
87
+ showMessageBox (" This stereo mode has not been implemented yet. Defaulting to ANAGLYPHIC" );
88
+ }
89
+ }
90
+ }
91
+
92
+ void QgsGlobePluginDialog::setEarthFile ()
93
+ {
94
+ showMessageBox (" TODO: set earth file to " + earthFile);
95
+ }
96
+
97
+ void QgsGlobePluginDialog::restartGlobe ()
98
+ {
99
+ // showMessageBox("TODO: restart globe");
100
+ }
101
+
102
+ bool QgsGlobePluginDialog::globeRunning ()
103
+ {
104
+ // TODO: method that tells if the globe plugin is running
105
+ return true ;
106
+ }
107
+
57
108
void QgsGlobePluginDialog::on_buttonBox_accepted ()
58
109
{
59
110
/*
111
+ *
60
112
// Validate input settings
61
113
QString srcUrl( inputSrcDataset->text() );
62
114
QString srcLayer( comboSrcLayer->currentText() );
@@ -138,6 +190,13 @@ void QgsGlobePluginDialog::on_buttonBox_accepted()
138
190
139
191
// Close dialog box
140
192
*/
193
+ setStereoMode ();
194
+ setEarthFile ();
195
+
196
+ if ( globeRunning () )
197
+ {
198
+ restartGlobe ();
199
+ }
141
200
accept ();
142
201
}
143
202
@@ -146,48 +205,32 @@ void QgsGlobePluginDialog::on_buttonBox_rejected()
146
205
reject ();
147
206
}
148
207
149
- void QgsGlobePluginDialog::on_comboStereo_currentIndexChanged ( int stereoMode )
208
+ void QgsGlobePluginDialog::on_comboStereoMode_currentIndexChanged ( QString mode )
150
209
{
151
- QMessageBox msgBox;
152
- msgBox.setText (" stereo mode changed" );
153
- msgBox.exec ();
154
- // showText("stereo mode changed");
155
- /*
156
- // Select destination data format
157
- QString frmtCode = comboDstFormats->currentText();
158
- mDstFormat = mFrmts.find( frmtCode );
159
-
160
- resetDstUi();
161
- */
210
+ stereoMode = mode;
211
+ settings.setValue ( " /Plugin-Globe/stereoMode" , stereoMode );
162
212
}
163
213
164
- void QgsGlobePluginDialog::on_buttonSelectEarthfile_clicked ()
214
+ void QgsGlobePluginDialog::on_buttonSelectEarthFile_clicked ()
165
215
{
166
- QMessageBox msgBox;
167
- msgBox.setText (" select file" );
168
- msgBox.exec ();
169
- /*
170
- QSettings settings;
171
216
QString src;
172
217
173
218
src = openFile ();
174
219
175
- inputSrcDataset ->setText( src );
220
+ inputEarthFile ->setText ( src );
176
221
177
222
if ( !src.isEmpty () )
178
223
{
179
- QMessageBox msgBox;
180
- msgBox.setText(src);
181
- msgBox.exec();
182
- //showText( src.toString() );
224
+ earthFile = src;
225
+ settings.setValue ( " /Plugin-Globe/earthFile" , earthFile );
183
226
}
184
- */
227
+
185
228
}
186
229
187
- /* void QgsGlobePluginDialog::showText( QString text)
230
+ void QgsGlobePluginDialog::showMessageBox ( QString text )
188
231
{
189
232
QMessageBox msgBox;
190
233
msgBox.setText (text);
191
234
msgBox.exec ();
192
235
}
193
- */
236
+
0 commit comments