@@ -139,8 +139,9 @@ void GlobePlugin::run()
139
139
mRootNode ->addChild ( mControlCanvas );
140
140
setupControls ();
141
141
142
- // add our fly-to handler
142
+ // add our handlers
143
143
viewer.addEventHandler (new FlyToExtentHandler ( manip, mQGisIface ));
144
+ viewer.addEventHandler (new KeyboardControlHandler ( manip, mQGisIface ));
144
145
145
146
// add some stock OSG handlers:
146
147
viewer.addEventHandler (new osgViewer::StatsHandler ());
@@ -550,8 +551,6 @@ void GlobePlugin::copyFolder(QString sourceFolder, QString destFolder)
550
551
}
551
552
}
552
553
553
- // ----------
554
-
555
554
bool FlyToExtentHandler::handle ( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
556
555
{
557
556
if ( ea.getEventType () == ea.KEYDOWN && ea.getKey () == ' 1' )
@@ -563,10 +562,7 @@ bool FlyToExtentHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIAct
563
562
return false ;
564
563
}
565
564
566
- // ----------
567
-
568
- bool
569
- NavigationControl::handle ( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, ControlContext& cx )
565
+ bool NavigationControl::handle ( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, ControlContext& cx )
570
566
{
571
567
switch ( ea.getEventType () )
572
568
{
@@ -595,7 +591,113 @@ NavigationControl::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAda
595
591
return Control::handle ( ea, aa, cx );
596
592
}
597
593
598
- // ----------
594
+ bool KeyboardControlHandler::handle ( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
595
+ {
596
+ float deg = 3.14159 / 180 ;
597
+ /*
598
+ osgEarthUtil::EarthManipulator::Settings* _manipSettings = _manip->getSettings();
599
+ _manipSettings->bindKey(osgEarthUtil::EarthManipulator::ACTION_ZOOM_IN, osgGA::GUIEventAdapter::KEY_Space);
600
+ //install default action bindings:
601
+ osgEarthUtil::EarthManipulator::ActionOptions options;
602
+
603
+ _manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_HOME, osgGA::GUIEventAdapter::KEY_Space );
604
+
605
+ _manipSettings->bindMouse( osgEarthUtil::EarthManipulator::ACTION_PAN, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON );
606
+
607
+ // zoom as you hold the right button:
608
+ options.clear();
609
+ options.add( osgEarthUtil::EarthManipulator::OPTION_CONTINUOUS, true );
610
+ _manipSettings->bindMouse( osgEarthUtil::EarthManipulator::ACTION_ROTATE, osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON, 0L, options );
611
+
612
+ // zoom with the scroll wheel:
613
+ _manipSettings->bindScroll( osgEarthUtil::EarthManipulator::ACTION_ZOOM_IN, osgGA::GUIEventAdapter::SCROLL_DOWN );
614
+ _manipSettings->bindScroll( osgEarthUtil::EarthManipulator::ACTION_ZOOM_OUT, osgGA::GUIEventAdapter::SCROLL_UP );
615
+
616
+ // pan around with arrow keys:
617
+ _manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_LEFT, osgGA::GUIEventAdapter::KEY_Left );
618
+ _manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_RIGHT, osgGA::GUIEventAdapter::KEY_Right );
619
+ _manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_UP, osgGA::GUIEventAdapter::KEY_Up );
620
+ _manipSettings->bindKey( osgEarthUtil::EarthManipulator::ACTION_PAN_DOWN, osgGA::GUIEventAdapter::KEY_Down );
621
+
622
+ // double click the left button to zoom in on a point:
623
+ options.clear();
624
+ options.add( osgEarthUtil::EarthManipulator::OPTION_GOTO_RANGE_FACTOR, 0.4 );
625
+ _manipSettings->bindMouseDoubleClick( osgEarthUtil::EarthManipulator::ACTION_GOTO, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON, 0L, options );
626
+
627
+ // double click the right button (or CTRL-left button) to zoom out to a point
628
+ options.clear();
629
+ options.add( osgEarthUtil::EarthManipulator::OPTION_GOTO_RANGE_FACTOR, 2.5 );
630
+ _manipSettings->bindMouseDoubleClick( osgEarthUtil::EarthManipulator::ACTION_GOTO, osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON, 0L, options );
631
+ _manipSettings->bindMouseDoubleClick( osgEarthUtil::EarthManipulator::ACTION_GOTO, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON, osgGA::GUIEventAdapter::MODKEY_CTRL, options );
632
+
633
+ _manipSettings->setThrowingEnabled( false );
634
+ _manipSettings->setLockAzimuthWhilePanning( true );
635
+
636
+ _manip->applySettings(_manipSettings);
637
+
638
+ */
639
+
640
+ switch (ea.getEventType ())
641
+ {
642
+ case (osgGA::GUIEventAdapter::KEYDOWN):
643
+ {
644
+ // move map
645
+ if (ea.getKey () == ' 4' )
646
+ {
647
+ _manip->pan ( -0.1 , 0 );
648
+ }
649
+ if (ea.getKey () == ' 6' )
650
+ {
651
+ _manip->pan ( 0.1 , 0 );
652
+ }
653
+ if (ea.getKey () == ' 2' )
654
+ {
655
+ _manip->pan ( 0 , 0.1 );
656
+ }
657
+ if (ea.getKey () == ' 8' )
658
+ {
659
+ _manip->pan ( 0 , -0.1 );
660
+ }
661
+ // rotate
662
+ if (ea.getKey () == ' /' )
663
+ {
664
+ _manip->rotate ( 1 *deg, 0 );
665
+ }
666
+ if (ea.getKey () == ' *' )
667
+ {
668
+ _manip->rotate ( -1 *deg, 0 );
669
+ }
670
+ // tilt
671
+ if ( ea.getKey () == ' 9' )
672
+ {
673
+ _manip->rotate ( 0 , 1 *deg );
674
+ }
675
+ if (ea.getKey () == ' 3' )
676
+ {
677
+ _manip->rotate ( 0 , -1 *deg );
678
+ }
679
+ // zoom
680
+ if (ea.getKey () == ' -' )
681
+ {
682
+ _manip->zoom ( 0 , 0.1 );
683
+ }
684
+ if (ea.getKey () == ' +' )
685
+ {
686
+ _manip->zoom ( 0 , -0.1 );
687
+ }
688
+ // reset
689
+ if (ea.getKey () == ' 5' )
690
+ {
691
+ // _manip->zoom( 0, 1 );
692
+ }
693
+ break ;
694
+ }
695
+
696
+ default :
697
+ break ;
698
+ }
699
+ return false ;
700
+ }
599
701
600
702
/* *
601
703
* Required extern functions needed for every plugin
0 commit comments