Moved SimpleViewer and GraphicsWindow into their own osgViewer library, updated simpleviewer examples to reflect this change

This commit is contained in:
Robert Osfield
2006-11-02 12:27:15 +00:00
parent f9fb99dc43
commit e0f395fd07
35 changed files with 470 additions and 117 deletions

72
include/osgViewer/Export Normal file
View File

@@ -0,0 +1,72 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
// The following symbol has a underscore suffix for compatibility.
#ifndef OSGVIEWER_EXPORT_
#define OSGVIEWER_EXPORT_ 1
#if defined(WIN32) && !(defined(__CYGWIN__) || defined(__MINGW32__))
#pragma warning( disable : 4244 )
#pragma warning( disable : 4251 )
#pragma warning( disable : 4267 )
#pragma warning( disable : 4275 )
#pragma warning( disable : 4290 )
#pragma warning( disable : 4786 )
#pragma warning( disable : 4305 )
#pragma warning( disable : 4996 )
#endif
#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__)
# if defined( OSG_LIBRARY_STATIC )
# define OSGVIEWER_EXPORT
# elif defined( OSGVIEWER_LIBRARY )
# define OSGVIEWER_EXPORT __declspec(dllexport)
# else
# define OSGVIEWER_EXPORT __declspec(dllimport)
#endif
#else
#define OSGVIEWER_EXPORT
#endif
#endif
/**
\namespace osgViewer
The 'GA' in osgViewer stands for 'GUI Abstraction'; the osgViewer namespace provides facilities to
help developers write the glue to allow the osg to work with varying window systems.
As a cross-platform, window system-agnostic class library, the OpenSceneGraph
has no direct ties to any given windowing environment. Viewers, however, must at
some level interact with a window system - where Window system may refer to a windowing
API, e.g. GLUT, Qt, FLTK, MFC, ...
There is much commonality in the implementation of Viewers for varying windowing
environments. E.g. most Viewers will update a Camera position in response to a mouse
event, and may request that a timer be started as a result of a model being 'spun'.
The purpose of the osgViewer namespace is to centralise the common areas of this
functionality. The viewer writer needs then only write a GUIEventAdapter, a
GUIActionAdapter, and assemble a collection of GUIEventHandlers
as appropriate for the viewer.
Events from the windowing environment are adpated, and then fed into the GUIEventHandlers.
The GUIEventHandlers analyse and take action, and make requests of the windowing
environemnt via the GUIActionAdapter. The viewer writer should then honour these
requests, translating them into calls to the windowing API.
*/

View File

@@ -11,15 +11,17 @@
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_GRAPHICWINDOW
#define OSG_GRAPHICWINDOW 1
#ifndef OSGVIEWER_GRAPHICWINDOW
#define OSGVIEWER_GRAPHICWINDOW 1
#include <osg/GraphicsContext>
#include <osg/Notify>
#include <osgGA/EventQueue>
namespace osgGA {
#include <osgViewer/Export>
namespace osgViewer {
/** Base class for providing Windowing API agnostic access to creating and managing graphisc window and events.
* Note, the GraphicsWindow is subclassed from osg::GraphicsContext, and to provide an implemention you'll need to implement its
@@ -27,7 +29,7 @@ namespace osgGA {
* GraphicsWindow adds the event queue ontop of the GraphicsContext, thereby adding a mechnism for adapting Windowing events
* as well as basics graphics context work, you should wire up custom GraphicsWindowImplementation to push their events through
* into the EventQueue. */
class OSGGA_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgGA::GUIActionAdapter
class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgGA::GUIActionAdapter
{
public:

View File

@@ -11,21 +11,22 @@
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGGA_SimpleViewer
#define OSGGA_SimpleViewer 1
#ifndef OSGVIEWER_SimpleViewer
#define OSGVIEWER_SimpleViewer 1
#include <osgGA/EventVisitor>
#include <osgGA/MatrixManipulator>
#include <osgGA/GraphicsWindow>
#include <osgViewer/GraphicsWindow>
#include <osgDB/DatabasePager>
#include <list>
namespace osgGA{
namespace osgViewer{
/** SimpleViewer provide a simple interface for setting up rendering of an scene graph, using a single camera view within a single window.*/
class OSGGA_EXPORT SimpleViewer : public virtual osgGA::GraphicsWindow
class OSGVIEWER_EXPORT SimpleViewer : public virtual osgViewer::GraphicsWindow
{
public:
@@ -39,14 +40,14 @@ class OSGGA_EXPORT SimpleViewer : public virtual osgGA::GraphicsWindow
osg::CameraNode* getCamera();
const osg::CameraNode* getCamera() const;
void setCameraManipulator(MatrixManipulator* manipulator);
MatrixManipulator* getCameraManipulator() { return _cameraManipulator.get(); }
const MatrixManipulator* getCameraManipulator() const { return _cameraManipulator.get(); }
void setCameraManipulator(osgGA::MatrixManipulator* manipulator);
osgGA::MatrixManipulator* getCameraManipulator() { return _cameraManipulator.get(); }
const osgGA::MatrixManipulator* getCameraManipulator() const { return _cameraManipulator.get(); }
typedef std::list< osg::ref_ptr<GUIEventHandler> > EventHandlers;
typedef std::list< osg::ref_ptr<osgGA::GUIEventHandler> > EventHandlers;
void addEventHandler(GUIEventHandler* eventHandler);
void addEventHandler(osgGA::GUIEventHandler* eventHandler);
EventHandlers& getEventHandlers() { return _eventHandlers; }
const EventHandlers& getEventHandlers() const { return _eventHandlers; }

48
include/osgViewer/Version Normal file
View File

@@ -0,0 +1,48 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGVIEWER_VERSION
#define OSGVIEWER_VERSION 1
#include <osgViewer/Export>
extern "C" {
/**
* osgViewerGetVersion() returns the library version number.
* Numbering convention : OpenSceneGraph-1.0 will return 1.0 from osgViewerGetVersion.
*
* This C function can be also used to check for the existence of the OpenSceneGraph
* library using autoconf and its m4 macro AC_CHECK_LIB.
*
* Here is the code to add to your configure.in:
\verbatim
#
# Check for the OpenSceneGraph (OSG) utility library
#
AC_CHECK_LIB(osg, osgViewerGetVersion, ,
[AC_MSG_ERROR(OpenSceneGraph utility library not found. See http://www.openscenegraph.org)],)
\endverbatim
*/
extern OSGVIEWER_EXPORT const char* osgViewerGetVersion();
/**
* getLibraryName_osgViewer() returns the library name in human friendly form.
*/
extern OSGVIEWER_EXPORT const char* osgViewerGetLibraryName();
}
#endif