~ubuntu-branches/ubuntu/trusty/openscenegraph/trusty

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/osgViewer/ViewerEventHandlers.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-07-29 04:34:38 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20080729043438-no1h9h0dpsrlzp1y
* Non-maintainer upload.
* No longer try to detect (using /proc/cpuinfo when available) how many
  CPUs are available, fixing the FTBFS (due to -j0) on various platforms
  (Closes: #477353). The right way to do it is to support parallel=n in
  DEB_BUILD_OPTIONS (see Debian Policy §4.9.1), and adequate support has
  been implemented.
* Add patch to fix FTBFS due to the build system now refusing to handle
  whitespaces (Policy CMP0004 say the logs), thanks to Andreas Putzo who
  provided it (Closes: #482239):
   - debian/patches/fix-cmp0004-build-failure.dpatch
* Remove myself from Uploaders, as requested a while ago, done by Luk in
  his 2.2.0-2.1 NMU, which was never acknowledged.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
*/
13
13
 
14
14
#include <stdlib.h>
 
15
#include <float.h>
 
16
#include <limits.h>
15
17
 
16
18
#include <fstream>
 
19
#include <sstream>
 
20
 
17
21
#include <osgViewer/Viewer>
18
22
#include <osgViewer/ViewerEventHandlers>
19
23
 
459
463
            // check for a KeySwitchManipulator, create one if not present, and then add this
460
464
            // to either the newly created one or the existing one. However, the code do that was
461
465
            // EXTREMELY dirty, so I opted for a simpler solution. At a later date, someone may
462
 
            // want to implement the original recomendation (which is in a mailing list reply
 
466
            // want to implement the original recommendation (which is in a mailing list reply
463
467
            // from June 1st by Robert in a thread called "osgviewer Camera Animation (preliminary)".
464
468
            else if (ea.getKey() == _keyEventTogglePlayback)
465
469
            {
483
487
                    _animPathManipulator->home(ea,aa);
484
488
 
485
489
 
486
 
                    // If we succesfully found our _filename file, set it and keep a copy
 
490
                    // If we successfully found our _filename file, set it and keep a copy
487
491
                    // around of the original MatrixManipulator to restore later.
488
492
                    if (_animPathManipulator.valid() && _animPathManipulator->valid())
489
493
                    {
514
518
    return false;
515
519
}
516
520
 
 
521
LODScaleHandler::LODScaleHandler():
 
522
    _keyEventIncreaseLODScale('*'),
 
523
    _keyEventDecreaseLODScale('/')
 
524
{
 
525
}
 
526
 
 
527
bool LODScaleHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
 
528
{
 
529
    osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
 
530
    osg::Camera* camera = view ? view->getCamera() : 0;
 
531
    if (!camera) return false;
 
532
 
 
533
    if (ea.getHandled()) return false;
 
534
 
 
535
    switch(ea.getEventType())
 
536
    {
 
537
        case(osgGA::GUIEventAdapter::KEYUP):
 
538
        {
 
539
            if (ea.getKey() == _keyEventIncreaseLODScale)
 
540
            {
 
541
                camera->setLODScale(camera->getLODScale()*1.1);
 
542
                osg::notify(osg::NOTICE)<<"LODScale = "<<camera->getLODScale()<<std::endl;
 
543
                return true;
 
544
            }
 
545
 
 
546
            else if (ea.getKey() == _keyEventDecreaseLODScale)
 
547
            {
 
548
                camera->setLODScale(camera->getLODScale()/1.1);
 
549
                osg::notify(osg::NOTICE)<<"LODScale = "<<camera->getLODScale()<<std::endl;
 
550
                return true;
 
551
            }        
 
552
 
 
553
            break;
 
554
        }
 
555
    default:
 
556
        break;
 
557
    }
 
558
 
 
559
    return false;
 
560
}
 
561
 
 
562
void LODScaleHandler::getUsage(osg::ApplicationUsage& usage) const
 
563
{
 
564
    {
 
565
        std::ostringstream ostr;
 
566
        ostr<<char(_keyEventIncreaseLODScale);
 
567
        usage.addKeyboardMouseBinding(ostr.str(),"Increase LODScale.");
 
568
    }
 
569
    
 
570
    {
 
571
        std::ostringstream ostr;
 
572
        ostr<<char(_keyEventDecreaseLODScale);
 
573
        usage.addKeyboardMouseBinding(ostr.str(),"Decrease LODScale.");
 
574
    }
 
575
}
 
576
 
 
577
 
517
578
}