root/OpenSceneGraph/trunk/applications/present3D/deprecated/ShowEventHandler.cpp @ 13720

Revision 13720, 2.0 kB (checked in by robert, 5 days ago)

Fixed comment

  • Property svn:eol-style set to native
Line 
1/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
2 *
3 * This software is open source and may be redistributed and/or modified under 
4 * the terms of the GNU General Public License (GPL) version 2.0.
5 * The full license is in LICENSE.txt file included with this distribution,.
6 *
7 * This software is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 * include LICENSE.txt for more details.
11*/
12
13#include "ShowEventHandler.h"
14
15#include <osgViewer/Viewer>
16#include <osg/Notify>
17
18using namespace p3d;
19
20ShowEventHandler::ShowEventHandler()
21{
22}
23
24bool ShowEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& /*aa*/, osg::Object* object, osg::NodeVisitor* /*nv*/)
25{
26    switch(ea.getEventType())
27    {
28        case(osgGA::GUIEventAdapter::KEYUP):
29        {
30            osg::notify(osg::INFO)<<"ShowEventHandler KEYUP "<<(int)ea.getKey()<<std::endl;
31            if (ea.getKey()>=osgGA::GUIEventAdapter::KEY_F1 &&
32                ea.getKey()<=osgGA::GUIEventAdapter::KEY_F8)
33            {
34                unsigned int child = ea.getKey()-osgGA::GUIEventAdapter::KEY_F1;
35                osg::notify(osg::INFO)<<"   Select "<<child<<std::endl;
36                osg::Switch* showSwitch = dynamic_cast<osg::Switch*>(object);
37                if (showSwitch)
38                {
39                    if (child<showSwitch->getNumChildren())
40                    {
41                        osg::notify(osg::INFO)<<"   Switched "<<child<<std::endl;
42                        showSwitch->setSingleChildOn(child);
43                        return true;
44                    }
45                }
46            }
47            break;
48        }
49        default:
50            break;
51    }
52    return false;
53}
54
55
56void ShowEventHandler::accept(osgGA::GUIEventHandlerVisitor& v)
57{
58    v.visit(*this);
59}
60
61void ShowEventHandler::getUsage(osg::ApplicationUsage& /*usage*/) const
62{
63}
Note: See TracBrowser for help on using the browser.