@@ -538,56 +538,114 @@ void GlobePlugin::copyFolder(QString sourceFolder, QString destFolder)
538
538
bool ControlsHandler::handle ( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
539
539
{
540
540
float deg = 3.14159 / 180 ;
541
-
542
- // this should be the way to implement this I think, but it segfaults...
543
- // TODO: put this in the correct place, here is ok for now to test
544
- // _manipSettings.bindKey(osgEarthUtil::EarthManipulator::ACTION_ZOOM_IN, osgGA::GUIEventAdapter::KEY_Page_Up);
545
- // _manip->applySettings( _manipSettings );
546
-
547
-
548
- if ( ea.getEventType () == ea.KEYDOWN && ea.getKey () == ' 1' )
549
-
550
- {
551
- QgsPoint center = mQGisIface ->mapCanvas ()->extent ().center ();
552
- osgEarthUtil::Viewpoint viewpoint ( osg::Vec3d ( center.x (), center.y (), 0.0 ), 0.0 , -90.0 , 1e4 );
553
- _manip->setViewpoint ( viewpoint, 4.0 );
554
- }
555
-
556
-
557
- /* if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '4' )
558
- {
559
- _manip->pan(-1,0);
560
- }
561
- if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '6' )
562
- {
563
- _manip->pan(1,0);
564
- }
565
- if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '8' )
566
- {
567
- _manip->pan(0,1);
568
- }
569
- if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '2' )
570
- {
571
- _manip->pan(0,-1);
572
- }
573
- if ( ea.getEventType() == ea.KEYDOWN && ea.getKey() == '+' )
574
- {
575
- _manip->rotate(0,1*deg);
576
- }
541
+ /*
542
+ osgEarthUtil::EarthManipulator::Settings* _manipSettings = _manip->getSettings();
543
+ _manipSettings->bindKey(osgEarthUtil::EarthManipulator::ACTION_ZOOM_IN, osgGA::GUIEventAdapter::KEY_Space);
544
+ //install default action bindings:
545
+ osgEarthUtil::EarthManipulator::ActionOptions options;
546
+
547
+ _manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_HOME, osgGA::GUIEventAdapter::KEY_Space );
548
+
549
+ _manipSettings->bindMouse( osgEarthUtil::EarthManipulator::ACTION_PAN, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON );
550
+
551
+ // zoom as you hold the right button:
552
+ options.clear();
553
+ options.add( osgEarthUtil::EarthManipulator::OPTION_CONTINUOUS, true );
554
+ _manipSettings->bindMouse( osgEarthUtil::EarthManipulator::ACTION_ROTATE, osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON, 0L, options );
555
+
556
+ // zoom with the scroll wheel:
557
+ _manipSettings->bindScroll( osgEarthUtil::EarthManipulator::ACTION_ZOOM_IN, osgGA::GUIEventAdapter::SCROLL_DOWN );
558
+ _manipSettings->bindScroll( osgEarthUtil::EarthManipulator::ACTION_ZOOM_OUT, osgGA::GUIEventAdapter::SCROLL_UP );
559
+
560
+ // pan around with arrow keys:
561
+ _manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_LEFT, osgGA::GUIEventAdapter::KEY_Left );
562
+ _manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_RIGHT, osgGA::GUIEventAdapter::KEY_Right );
563
+ _manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_UP, osgGA::GUIEventAdapter::KEY_Up );
564
+ _manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_DOWN, osgGA::GUIEventAdapter::KEY_Down );
565
+
566
+ // double click the left button to zoom in on a point:
567
+ options.clear();
568
+ options.add( osgEarthUtil::EarthManipulator::OPTION_GOTO_RANGE_FACTOR, 0.4 );
569
+ _manipSettings->bindMouseDoubleClick( osgEarthUtil::EarthManipulator::ACTION_GOTO, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON, 0L, options );
570
+
571
+ // double click the right button (or CTRL-left button) to zoom out to a point
572
+ options.clear();
573
+ options.add( osgEarthUtil::EarthManipulator::OPTION_GOTO_RANGE_FACTOR, 2.5 );
574
+ _manipSettings->bindMouseDoubleClick( osgEarthUtil::EarthManipulator::ACTION_GOTO, osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON, 0L, options );
575
+ _manipSettings->bindMouseDoubleClick( osgEarthUtil::EarthManipulator::ACTION_GOTO, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON, osgGA::GUIEventAdapter::MODKEY_CTRL, options );
576
+
577
+ _manipSettings->setThrowingEnabled( false );
578
+ _manipSettings->setLockAzimuthWhilePanning( true );
579
+
580
+ _manip->applySettings(_manipSettings);
581
+
577
582
*/
578
- if ( ea.getEventType () == ea.KEYDOWN && ea.getKey () == ' -' )
579
- {
580
- _manip->rotate (0 ,-1 *deg);
581
- }
582
- if ( ea.getEventType () == ea.KEYDOWN && ea.getKey () == ' /' )
583
+
584
+ switch (ea.getEventType ())
583
585
{
584
- _manip->rotate (1 *deg,0 );
586
+ case (osgGA::GUIEventAdapter::KEYDOWN):
587
+ {
588
+ if (ea.getKey () == ' 1' )
589
+ {
590
+ QgsPoint center = mQGisIface ->mapCanvas ()->extent ().center ();
591
+ osgEarthUtil::Viewpoint viewpoint ( osg::Vec3d ( center.x (), center.y (), 0.0 ), 0.0 , -90.0 , 1e4 );
592
+ _manip->setViewpoint ( viewpoint, 4.0 );
593
+ }
594
+ // move map
595
+ if (ea.getKey () == ' 4' )
596
+ {
597
+ _manip->pan ( -0.1 , 0 );
598
+ }
599
+ if (ea.getKey () == ' 6' )
600
+ {
601
+ _manip->pan ( 0.1 , 0 );
602
+ }
603
+ if (ea.getKey () == ' 2' )
604
+ {
605
+ _manip->pan ( 0 , 0.1 );
606
+ }
607
+ if (ea.getKey () == ' 8' )
608
+ {
609
+ _manip->pan ( 0 , -0.1 );
610
+ }
611
+ // rotate
612
+ if (ea.getKey () == ' /' )
613
+ {
614
+ _manip->rotate ( 1 *deg, 0 );
615
+ }
616
+ if (ea.getKey () == ' *' )
617
+ {
618
+ _manip->rotate ( -1 *deg, 0 );
619
+ }
620
+ // tilt
621
+ if ( ea.getKey () == ' 9' )
622
+ {
623
+ _manip->rotate ( 0 , 1 *deg );
624
+ }
625
+ if (ea.getKey () == ' 3' )
626
+ {
627
+ _manip->rotate ( 0 , -1 *deg );
628
+ }
629
+ // zoom
630
+ if (ea.getKey () == ' -' )
631
+ {
632
+ _manip->zoom ( 0 , 0.1 );
633
+ }
634
+ if (ea.getKey () == ' +' )
635
+ {
636
+ _manip->zoom ( 0 , -0.1 );
637
+ }
638
+ // reset
639
+ if (ea.getKey () == ' 5' )
640
+ {
641
+ // _manip->zoom( 0, 1 );
642
+ }
643
+ break ;
644
+ }
645
+
646
+ default :
647
+ break ;
585
648
}
586
- if ( ea.getEventType () == ea.KEYDOWN && ea.getKey () == ' *' )
587
- {
588
- _manip->rotate (-1 *deg,0 );
589
- }
590
-
591
649
return false ;
592
650
}
593
651
0 commit comments