Skip to content

Commit b740549

Browse files
Marco Bernasocchipka
Marco Bernasocchi
authored andcommitted
added live preview of Stereo Settings
1 parent 0a45bff commit b740549

File tree

5 files changed

+119
-46
lines changed

5 files changed

+119
-46
lines changed

src/plugins/globe/globe_plugin.cpp

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
using namespace osgEarth::Drivers;
5252
using namespace osgEarthUtil::Controls2;
5353

54+
#define MOVE_OFFSET 0.05
5455

5556
//static const char * const sIdent = "$Id: plugin.cpp 9327 2008-09-14 11:18:44Z jef $";
5657
static const QString sName = QObject::tr( "Globe" );
@@ -318,16 +319,15 @@ void GlobePlugin::setupControls()
318319
moveHControls->setPosition( 5, 35 );
319320

320321
osgEarthUtil::EarthManipulator* manip = dynamic_cast<osgEarthUtil::EarthManipulator*>(viewer.getCameraManipulator());
321-
322322
//Move Left
323323
osg::Image* moveLeftImg = osgDB::readImageFile( imgDir + "/move-left.png" );
324324
ImageControl* moveLeft = new NavigationControl( moveLeftImg );
325-
moveLeft->addEventHandler( new PanControlHandler( manip, -0.05, 0 ) );
325+
moveLeft->addEventHandler( new PanControlHandler( manip, -MOVE_OFFSET, 0 ) );
326326

327327
//Move Right
328328
osg::Image* moveRightImg = osgDB::readImageFile( imgDir + "/move-right.png" );
329329
ImageControl* moveRight = new NavigationControl( moveRightImg );
330-
moveRight->addEventHandler( new PanControlHandler( manip, 0.05, 0 ) );
330+
moveRight->addEventHandler( new PanControlHandler( manip, MOVE_OFFSET, 0 ) );
331331

332332
//Move Reset
333333
osg::Image* moveResetImg = osgDB::readImageFile( imgDir + "/move-reset.png" );
@@ -348,12 +348,12 @@ void GlobePlugin::setupControls()
348348
//Move Up
349349
osg::Image* moveUpImg = osgDB::readImageFile( imgDir + "/move-up.png" );
350350
ImageControl* moveUp = new NavigationControl( moveUpImg );
351-
moveUp->addEventHandler( new PanControlHandler( manip, 0, -0.05 ) );
351+
moveUp->addEventHandler( new PanControlHandler( manip, 0, MOVE_OFFSET ) );
352352

353353
//Move Down
354354
osg::Image* moveDownImg = osgDB::readImageFile( imgDir + "/move-down.png" );
355355
ImageControl* moveDown = new NavigationControl( moveDownImg );
356-
moveDown->addEventHandler( new PanControlHandler( manip, 0, 0.05 ) );
356+
moveDown->addEventHandler( new PanControlHandler( manip, 0, -MOVE_OFFSET ) );
357357

358358
//add controls to moveControls group
359359
moveHControls->addControl( moveLeft );
@@ -378,12 +378,12 @@ void GlobePlugin::setupControls()
378378
//Rotate CCW
379379
osg::Image* rotateCCWImg = osgDB::readImageFile( imgDir + "/rotate-ccw.png" );
380380
ImageControl* rotateCCW = new NavigationControl( rotateCCWImg );
381-
rotateCCW->addEventHandler( new RotateControlHandler( manip, 0.05, 0) );
381+
rotateCCW->addEventHandler( new RotateControlHandler( manip, MOVE_OFFSET, 0) );
382382

383383
//Rotate CW
384384
osg::Image* rotateCWImg = osgDB::readImageFile( imgDir + "/rotate-cw.png" );
385385
ImageControl* rotateCW = new NavigationControl( rotateCWImg );
386-
rotateCW->addEventHandler( new RotateControlHandler( manip, -0.05 , 0 ) );
386+
rotateCW->addEventHandler( new RotateControlHandler( manip, -MOVE_OFFSET , 0 ) );
387387

388388
//Rotate Reset
389389
osg::Image* rotateResetImg = osgDB::readImageFile( imgDir + "/rotate-reset.png" );
@@ -411,12 +411,12 @@ void GlobePlugin::setupControls()
411411
//tilt Up
412412
osg::Image* tiltUpImg = osgDB::readImageFile( imgDir + "/tilt-up.png" );
413413
ImageControl* tiltUp = new NavigationControl( tiltUpImg );
414-
tiltUp->addEventHandler( new RotateControlHandler( manip, 0, 0.05 ) );
414+
tiltUp->addEventHandler( new RotateControlHandler( manip, 0, MOVE_OFFSET ) );
415415

416416
//tilt Down
417417
osg::Image* tiltDownImg = osgDB::readImageFile( imgDir + "/tilt-down.png" );
418418
ImageControl* tiltDown = new NavigationControl( tiltDownImg );
419-
tiltDown->addEventHandler( new RotateControlHandler( manip, 0, -0.05 ) );
419+
tiltDown->addEventHandler( new RotateControlHandler( manip, 0, -MOVE_OFFSET ) );
420420

421421
//add controls to tiltControls group
422422
tiltControls->addControl( tiltUp );
@@ -438,12 +438,12 @@ void GlobePlugin::setupControls()
438438
//Zoom In
439439
osg::Image* zoomInImg = osgDB::readImageFile( imgDir + "/zoom-in.png" );
440440
ImageControl* zoomIn = new NavigationControl( zoomInImg );
441-
zoomIn->addEventHandler( new ZoomControlHandler( manip, 0, -0.05 ) );
441+
zoomIn->addEventHandler( new ZoomControlHandler( manip, 0, -MOVE_OFFSET ) );
442442

443443
//Zoom Out
444444
osg::Image* zoomOutImg = osgDB::readImageFile( imgDir + "/zoom-out.png" );
445445
ImageControl* zoomOut = new NavigationControl( zoomOutImg );
446-
zoomOut->addEventHandler( new ZoomControlHandler( manip, 0, 0.05 ) );
446+
zoomOut->addEventHandler( new ZoomControlHandler( manip, 0, MOVE_OFFSET ) );
447447

448448
//Zoom Reset
449449
osg::Image* zoomResetImg = osgDB::readImageFile( imgDir + "/zoom-reset.png" );
@@ -578,6 +578,8 @@ void GlobePlugin::copyFolder(QString sourceFolder, QString destFolder)
578578
}
579579
}
580580

581+
// ----------
582+
581583
bool FlyToExtentHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
582584
{
583585
if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '1' )
@@ -589,7 +591,10 @@ bool FlyToExtentHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIAct
589591
return false;
590592
}
591593

592-
bool NavigationControl::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, ControlContext& cx )
594+
// ----------
595+
596+
bool
597+
NavigationControl::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, ControlContext& cx )
593598
{
594599
switch ( ea.getEventType() )
595600
{
@@ -671,46 +676,46 @@ bool KeyboardControlHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GU
671676
//move map
672677
if (ea.getKey() == '4' )
673678
{
674-
_manip->pan( -0.05, 0 );
679+
_manip->pan( -MOVE_OFFSET, 0 );
675680
}
676681
if (ea.getKey() == '6' )
677682
{
678-
_manip->pan( 0.05, 0 );
683+
_manip->pan( MOVE_OFFSET, 0 );
679684
}
680685
if (ea.getKey() == '2' )
681686
{
682-
_manip->pan( 0, 0.05 );
687+
_manip->pan( 0, MOVE_OFFSET );
683688
}
684689
if (ea.getKey() == '8' )
685690
{
686-
_manip->pan( 0, -0.05 );
691+
_manip->pan( 0, -MOVE_OFFSET );
687692
}
688693
//rotate
689694
if (ea.getKey() == '/' )
690695
{
691-
_manip->rotate( 0.05, 0 );
696+
_manip->rotate( MOVE_OFFSET, 0 );
692697
}
693698
if (ea.getKey() == '*' )
694699
{
695-
_manip->rotate( -0.05, 0 );
700+
_manip->rotate( -MOVE_OFFSET, 0 );
696701
}
697702
//tilt
698703
if ( ea.getKey() == '9' )
699704
{
700-
_manip->rotate( 0, 0.05 );
705+
_manip->rotate( 0, MOVE_OFFSET );
701706
}
702707
if (ea.getKey() == '3' )
703708
{
704-
_manip->rotate( 0, -0.05 );
709+
_manip->rotate( 0, -MOVE_OFFSET );
705710
}
706711
//zoom
707712
if (ea.getKey() == '-' )
708713
{
709-
_manip->zoom( 0, 0.05 );
714+
_manip->zoom( 0, MOVE_OFFSET );
710715
}
711716
if (ea.getKey() == '+' )
712717
{
713-
_manip->zoom( 0, -0.05 );
718+
_manip->zoom( 0, -MOVE_OFFSET );
714719
}
715720
//reset
716721
if (ea.getKey() == '5' )

src/plugins/globe/globe_plugin.h

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -138,26 +138,28 @@ class KeyboardControlHandler : public osgGA::GUIEventHandler
138138
QgisInterface *mQGisIface;
139139
};
140140

141-
namespace osgEarthUtil { namespace Controls2
142-
{
143-
class NavigationControlHandler : public ControlEventHandler
144-
{
145-
public:
146-
virtual void onMouseDown( class Control* control, int mouseButtonMask ) { }
147-
};
148-
149-
class NavigationControl : public ImageControl
150-
{
151-
public:
152-
NavigationControl( osg::Image* image = 0L ) : ImageControl( image ), _mouse_down_event( NULL ) {}
153-
154-
protected:
155-
virtual bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, ControlContext& cx );
156-
157-
private:
158-
osg::ref_ptr<const osgGA::GUIEventAdapter> _mouse_down_event;
159-
};
160-
}
141+
namespace osgEarthUtil
142+
{
143+
namespace Controls2
144+
{
145+
class NavigationControlHandler : public ControlEventHandler
146+
{
147+
public:
148+
virtual void onMouseDown( class Control* control, int mouseButtonMask ) { }
149+
};
150+
151+
class NavigationControl : public ImageControl
152+
{
153+
public:
154+
NavigationControl( osg::Image* image = 0L ) : ImageControl( image ), _mouse_down_event( NULL ) {}
155+
156+
protected:
157+
virtual bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, ControlContext& cx );
158+
159+
private:
160+
osg::ref_ptr<const osgGA::GUIEventAdapter> _mouse_down_event;
161+
};
162+
}
161163
}
162164

163165
#endif // QGS_GLOBE_PLUGIN_H

src/plugins/globe/globe_plugin_dialog.cpp

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ void QgsGlobePluginDialog::on_buttonBox_accepted()
166166

167167
void QgsGlobePluginDialog::on_buttonBox_rejected()
168168
{
169+
loadStereoConfig();
170+
setStereoConfig();
169171
reject();
170172
}
171173

@@ -183,6 +185,53 @@ void QgsGlobePluginDialog::on_resetDefaults_clicked()
183185
splitStereoVerticalEyeMapping->setCurrentIndex( 0 );
184186
}
185187

188+
void QgsGlobePluginDialog::on_comboStereoMode_currentIndexChanged(QString value)
189+
{
190+
setStereoMode();
191+
}
192+
193+
void QgsGlobePluginDialog::on_eyeSeparation_valueChanged(double value)
194+
{
195+
osg::DisplaySettings::instance()->setEyeSeparation( value );
196+
}
197+
198+
void QgsGlobePluginDialog::on_screenDistance_valueChanged(double value)
199+
{
200+
osg::DisplaySettings::instance()->setScreenDistance( value );
201+
}
202+
203+
void QgsGlobePluginDialog::on_screenWidth_valueChanged(double value)
204+
{
205+
osg::DisplaySettings::instance()->setScreenWidth( value );
206+
}
207+
208+
void QgsGlobePluginDialog::on_screenHeight_valueChanged(double value)
209+
{
210+
osg::DisplaySettings::instance()->setScreenHeight( value );
211+
}
212+
213+
void QgsGlobePluginDialog::on_splitStereoHorizontalSeparation_valueChanged(int value)
214+
{
215+
osg::DisplaySettings::instance()->setSplitStereoHorizontalSeparation( value );
216+
}
217+
218+
void QgsGlobePluginDialog::on_splitStereoVerticalSeparation_valueChanged(int value)
219+
{
220+
osg::DisplaySettings::instance()->setSplitStereoVerticalSeparation( value );
221+
}
222+
223+
void QgsGlobePluginDialog::on_splitStereoHorizontalEyeMapping_currentIndexChanged(int value)
224+
{
225+
osg::DisplaySettings::instance()->setSplitStereoHorizontalEyeMapping(
226+
(osg::DisplaySettings::SplitStereoHorizontalEyeMapping) value );
227+
}
228+
229+
void QgsGlobePluginDialog::on_splitStereoVerticalEyeMapping_currentIndexChanged(int value)
230+
{
231+
osg::DisplaySettings::instance()->setSplitStereoVerticalEyeMapping(
232+
(osg::DisplaySettings::SplitStereoVerticalEyeMapping) value );
233+
}
234+
186235
void QgsGlobePluginDialog::showMessageBox( QString text )
187236
{
188237
QMessageBox msgBox;
@@ -214,9 +263,9 @@ void QgsGlobePluginDialog::loadStereoConfig()
214263
osg::DisplaySettings::instance()->getSplitStereoVerticalEyeMapping() ).toInt() );
215264
}
216265

217-
void QgsGlobePluginDialog::setStereoConfig()
266+
void QgsGlobePluginDialog::setStereoMode()
218267
{
219-
//http://www.openscenegraph.org/projects/osg/wiki/Support/UserGuides/StereoSettings
268+
//http://www.openscenegraph.org/projects/osg/wiki/Support/UserGuides/StereoSettings
220269
//http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00181.html
221270

222271
QString stereoMode = comboStereoMode->currentText() ;
@@ -252,8 +301,12 @@ void QgsGlobePluginDialog::setStereoConfig()
252301
msgBox.exec();
253302
}
254303
}
255-
304+
}
305+
306+
void QgsGlobePluginDialog::setStereoConfig()
307+
{
256308
//SETTING THE VALUES IN THE OEGearth instance
309+
setStereoMode();
257310
osg::DisplaySettings::instance()->setScreenDistance( screenDistance->value() );
258311
osg::DisplaySettings::instance()->setScreenWidth( screenWidth->value() );
259312
osg::DisplaySettings::instance()->setScreenHeight( screenHeight->value() );

src/plugins/globe/globe_plugin_dialog.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,23 @@ class QgsGlobePluginDialog:public QDialog, private Ui::QgsGlobePluginDialogGuiBa
4444
void loadStereoConfig();
4545
//! Save settings
4646
void saveStereoConfig();
47+
//! Handle stereoMode
48+
void setStereoMode();
4749

4850
private slots:
4951
void on_buttonBox_accepted();
5052
void on_buttonBox_rejected();
53+
54+
void on_comboStereoMode_currentIndexChanged(QString value);
55+
void on_eyeSeparation_valueChanged(double value);
56+
void on_screenDistance_valueChanged(double value);
57+
void on_screenWidth_valueChanged(double value);
58+
void on_screenHeight_valueChanged(double value);
59+
void on_splitStereoHorizontalSeparation_valueChanged(int value);
60+
void on_splitStereoVerticalSeparation_valueChanged(int value);
61+
void on_splitStereoHorizontalEyeMapping_currentIndexChanged(int value);
62+
void on_splitStereoVerticalEyeMapping_currentIndexChanged(int value);
63+
5164
void on_resetDefaults_clicked();
5265
};
5366

src/plugins/globe/globe_plugin_dialog_guibase.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<item>
3535
<widget class="QTabWidget" name="tabWidget">
3636
<property name="currentIndex">
37-
<number>0</number>
37+
<number>1</number>
3838
</property>
3939
<widget class="QWidget" name="elevation">
4040
<attribute name="title">

0 commit comments

Comments
 (0)