root/OpenSceneGraph/trunk/include/osgGA/GUIActionAdapter @ 13041

Revision 13041, 3.9 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGGA_GUIACTIONADAPTER
15#define OSGGA_GUIACTIONADAPTER 1
16
17#include <osgGA/Export>
18#include <osg/View>
19
20namespace osgGA{
21
22/**
23Abstract base class defining the interface by which GUIEventHandlers may request
24actions of the GUI system in use. These requests for actions should then be honored
25by the GUI toolkit of the user's application.
26
27To provide more detail, when a GUIEventHandler (e.g. a TrackballManipulator)
28handles an incoming event, such as a mouse event, it may wish to make
29a request of the GUI. E.g. if a model is 'thrown', the trackball manipulator
30may wish to start a timer, and be repeatedly called, to continuously refresh the
31camera's position and orientation. However, it has no way of doing this, as it
32knows nothing of the window system in which it's operating. Instead, the
33GUIEventHandler issues it's request via a GUIActionAdapter, and the viewer
34in use should honour the request, using the GUI system in play.
35
36There is more than one way of using the GUIActionAdapter. E.g. it may be inherited
37into a Viewer class, as is done with osgGLUT::Viewer. Alternatively, a simple
38subclass of GUIActionAdapter (e.g. osgQt::QtActionAdapter) may be passed to
39the GUIEventHandler::handle() function; once the function has returned, the viewer
40will then unpack the results and work out what to do to respond to the
41requests.
42
43Also there are several ways to run your app and handle the updating of
44the window.  osgGLUT::Viewer always has a idle callback registered which does a
45redraw all the time.  osgGLUT::Viewer can safely ignore both requestRedraw() and
46requestContinousUpdate() as these are happening all the time anyway.
47
48Other apps will probably want to respond to the requestRedraw() and
49requestContinousUpdate(bool) and again there is more than one way to handle it.
50You can override requestRedraw() and implement to call your own window
51redraw straight away. Or you can implement so that a flag is set and
52then you then respond the flag being set in your own leisure.
53
54*/
55class GUIActionAdapter
56{
57public:
58        virtual ~GUIActionAdapter() {}
59
60        /** Provide a mechanism for getting the osg::View associated with this GUIActionAdapter.
61          * One would use this to case view to osgViewer::View(er) if supported by the subclass.*/
62        virtual osg::View* asView() { return 0; }
63
64        /**
65        requestRedraw() requests a single redraw.
66        */
67        virtual void requestRedraw() = 0;
68
69        /**
70        requestContinousUpdate(bool) is for en/disabling a throw or idle
71        callback to be requested by a GUIEventHandler (typically a MatrixManipulator,
72        though other GUIEventHandler's may also provide functionality).
73        GUI toolkits can respond  to this immediately by registering an idle/timed
74        callback, or can delay setting the callback and update at their own leisure.
75        */
76        virtual void requestContinuousUpdate(bool needed=true) = 0;
77
78        /**
79        requestWarpPointer(int,int) is requesting a repositioning of the mouse pointer
80        to a specified x,y location on the window.  This is used by some camera manipulators
81        to initialise the mouse pointer when mouse position relative to a controls
82        neutral mouse position is required, i.e when mimicking a aircrafts joystick.
83        */
84        virtual void requestWarpPointer(float x,float y) = 0;
85
86};
87
88}
89
90#endif
91
Note: See TracBrowser for help on using the browser.