From e0f395fd071ac4d5c18f0afd64008943b2ee3734 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 2 Nov 2006 12:27:15 +0000 Subject: [PATCH] Moved SimpleViewer and GraphicsWindow into their own osgViewer library, updated simpleviewer examples to reflect this change --- VisualStudio/OpenSceneGraph.dsw | 45 +++++ VisualStudio/osgGA/osgGA.dsp | 8 - VisualStudio/osgViewer/osgViewer.dsp | 191 ++++++++++++++++++ examples/osgkeyboardmouse/GNUmakefile | 2 +- examples/osgkeyboardmouse/GNUmakefile.inst | 2 +- .../osgkeyboardmouse/osgkeyboardmouse.cpp | 80 +++----- examples/osgsimple/GNUmakefile | 2 +- examples/osgsimple/GNUmakefile.inst | 2 +- examples/osgsimple/osgsimple.cpp | 4 +- examples/osgsimpleviewerFLTK/GNUmakefile | 2 +- examples/osgsimpleviewerFLTK/GNUmakefile.inst | 2 +- .../osgsimpleviewerFLTK.cpp | 6 +- examples/osgsimpleviewerGLUT/GNUmakefile | 2 +- examples/osgsimpleviewerGLUT/GNUmakefile.inst | 2 +- .../osgsimpleviewerGLUT.cpp | 6 +- examples/osgsimpleviewerProducer/GNUmakefile | 2 +- .../osgsimpleviewerProducer/GNUmakefile.inst | 2 +- .../osgsimpleviewerProducer.cpp | 8 +- examples/osgsimpleviewerQT3/GNUmakefile | 2 +- examples/osgsimpleviewerQT3/GNUmakefile.inst | 2 +- .../osgsimpleviewerQT3/osgsimpleviewerQT3.cpp | 6 +- examples/osgsimpleviewerQT4/GNUmakefile | 2 +- examples/osgsimpleviewerQT4/GNUmakefile.inst | 2 +- .../osgsimpleviewerQT4/osgsimpleviewerQT4.cpp | 6 +- examples/osgsimpleviewerSDL/GNUmakefile | 2 +- examples/osgsimpleviewerSDL/GNUmakefile.inst | 2 +- .../osgsimpleviewerSDL/osgsimpleviewerSDL.cpp | 4 +- include/osgViewer/Export | 72 +++++++ include/{osgGA => osgViewer}/GraphicsWindow | 10 +- include/{osgGA => osgViewer}/SimpleViewer | 21 +- include/osgViewer/Version | 48 +++++ src/osgGA/GNUmakefile | 3 +- src/osgViewer/GNUmakefile | 16 ++ src/{osgGA => osgViewer}/SimpleViewer.cpp | 9 +- src/osgViewer/Version.cpp | 12 ++ 35 files changed, 470 insertions(+), 117 deletions(-) create mode 100644 VisualStudio/osgViewer/osgViewer.dsp create mode 100644 include/osgViewer/Export rename include/{osgGA => osgViewer}/GraphicsWindow (95%) rename include/{osgGA => osgViewer}/SimpleViewer (84%) create mode 100644 include/osgViewer/Version create mode 100644 src/osgViewer/GNUmakefile rename src/{osgGA => osgViewer}/SimpleViewer.cpp (97%) create mode 100644 src/osgViewer/Version.cpp diff --git a/VisualStudio/OpenSceneGraph.dsw b/VisualStudio/OpenSceneGraph.dsw index a7013619a..8e7a54557 100644 --- a/VisualStudio/OpenSceneGraph.dsw +++ b/VisualStudio/OpenSceneGraph.dsw @@ -183,6 +183,30 @@ Package=<4> ############################################################################### +Project: "Core osgViewer"=.\osgViewer\osgViewer.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name Core osg + End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgUtil + End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgDB + End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgGA + End Project Dependency +}}} + +############################################################################### + Project: "Core osgProducer"=.\osgProducer\osgProducer.dsp - Package Owner=<4> Package=<5> @@ -2042,6 +2066,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name Core osgGA End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgViewer + End Project Dependency }}} ############################################################################### @@ -2066,6 +2093,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name Core osgGA End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgViewer + End Project Dependency }}} ############################################################################### @@ -2090,6 +2120,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name Core osgGA End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgViewer + End Project Dependency }}} ############################################################################### @@ -2114,6 +2147,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name Core osgGA End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgViewer + End Project Dependency }}} ############################################################################### @@ -2138,6 +2174,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name Core osgGA End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgViewer + End Project Dependency }}} ############################################################################### @@ -2162,6 +2201,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name Core osgGA End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgViewer + End Project Dependency }}} ############################################################################### @@ -2186,6 +2228,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name Core osgGA End Project Dependency + Begin Project Dependency + Project_Dep_Name Core osgViewer + End Project Dependency }}} ############################################################################### diff --git a/VisualStudio/osgGA/osgGA.dsp b/VisualStudio/osgGA/osgGA.dsp index 2c5baa4a0..8c4c46db3 100755 --- a/VisualStudio/osgGA/osgGA.dsp +++ b/VisualStudio/osgGA/osgGA.dsp @@ -191,10 +191,6 @@ SOURCE=..\..\src\osgGA\MatrixManipulator.cpp # End Source File # Begin Source File -SOURCE=..\..\src\osgGA\SimpleViewer.cpp -# End Source File -# Begin Source File - SOURCE=..\..\src\osgGA\StateSetManipulator.cpp # End Source File # Begin Source File @@ -267,10 +263,6 @@ SOURCE=..\..\Include\osgGA\MatrixManipulator # End Source File # Begin Source File -SOURCE=..\..\Include\osgGA\SimpleViewer -# End Source File -# Begin Source File - SOURCE=..\..\Include\osgGA\StateSetManipulator # End Source File # Begin Source File diff --git a/VisualStudio/osgViewer/osgViewer.dsp b/VisualStudio/osgViewer/osgViewer.dsp new file mode 100644 index 000000000..2624b5e39 --- /dev/null +++ b/VisualStudio/osgViewer/osgViewer.dsp @@ -0,0 +1,191 @@ +# Microsoft Developer Studio Project File - Name="Core osgViewer" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=Core osgViewer - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "osgViewer.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "osgViewer.mak" CFG="Core osgViewer - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Core osgViewer - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Core osgViewer - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Core osgViewer - Win32 Release Static" (based on "Win32 (x86) Static Library") +!MESSAGE "Core osgViewer - Win32 Debug Static" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Core osgViewer - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "../../lib" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../../bin/$(PlatformName)" +# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +F90=df.exe +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GR /GX /O2 /I "../../include" /I "../../../OpenThreads/include" /I "../../../Producer/include" /I "../../../3rdParty/include" /D "NDEBUG" /D "_MBCS" /D "_USRDLL" /D "OSGVIEWER_LIBRARY" /D "WIN32" /D "_WINDOWS" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /Zm200 /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 OpenThreadsWin32.lib opengl32.lib glu32.lib /nologo /dll /debug /machine:I386 /opt:ref /opt:icf /out:"$(OutDir)/osgViewer.dll" /implib:"../../lib/$(PlatformName)/osgViewer.lib" /libpath:"../../lib/$(PlatformName)" /libpath:"../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../Producer/lib/$(PlatformName)" /libpath:"../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../3rdParty/lib" + +!ELSEIF "$(CFG)" == "Core osgViewer - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../../bin/$(PlatformName)" +# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +F90=df.exe +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /vmg /GR /GX /Zi /Od /I "../../include" /I "../../../OpenThreads/include" /I "../../../Producer/include" /I "../../../3rdParty/include" /D "OSGVIEWER_LIBRARY" /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /GZ /Zm200 /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 OpenThreadsWin32d.lib opengl32.lib glu32.lib /nologo /dll /debug /machine:I386 /out:"$(OutDir)/osgViewerd.dll" /pdbtype:sept /implib:"../../lib/$(PlatformName)/osgViewerd.lib" /libpath:"../../lib/$(PlatformName)" /libpath:"../../../OpenThreads/lib/$(PlatformName)" /libpath:"../../../Producer/lib/$(PlatformName)" /libpath:"../../../3rdParty/lib/$(PlatformName)" /libpath:"../../../3rdParty/lib" +# SUBTRACT LINK32 /pdb:none + +!ELSEIF "$(CFG)" == "Core osgViewer - Win32 Release Static" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "../../lib" +# PROP BASE Intermediate_Dir "Release_Static" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "../../lib/$(PlatformName)" +# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)_Static" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +F90=df.exe +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "../../include" /I "../../../OpenThreads/include" /I "../../../Producer/include" /I "../../../3rdParty/include" /D "NDEBUG" /D "_MBCS" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "WIN32" /D "_WINDOWS" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /Zm200 /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nodefaultlib /nologo /out:"$(OutDir)/osgViewer_s.lib" + +!ELSEIF "$(CFG)" == "Core osgViewer - Win32 Debug Static" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "../../lib" +# PROP BASE Intermediate_Dir "Debug_Static" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "../../lib/$(PlatformName)" +# PROP Intermediate_Dir "$(PlatformName)/$(ConfigurationName)_Static" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +F90=df.exe +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /vmg /GR /GX /Z7 /Od /I "../../include" /I "../../../OpenThreads/include" /I "../../../Producer/include" /I "../../../3rdParty/include" /D "OSG_LIBRARY_STATIC" /D "OT_LIBRARY_STATIC" /D "PR_LIBRARY_STATIC" /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "_CRT_SECURE_NO_DEPRECATE" /YX /FD /GZ /Zm200 /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nodefaultlib /nologo /out:"$(OutDir)/osgViewerd_s.lib" +# SUBTRACT LIB32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "Core osgViewer - Win32 Release" +# Name "Core osgViewer - Win32 Debug" +# Name "Core osgViewer - Win32 Release Static" +# Name "Core osgViewer - Win32 Debug Static" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\..\src\osgViewer\SimpleViewer.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\src\osgViewer\Version.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter ";h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\..\Include\osgViewer\Export +# End Source File +# Begin Source File + +SOURCE=..\..\Include\osgViewer\GraphicsWindow +# End Source File +# Begin Source File + +SOURCE=..\..\Include\osgViewer\SimpleViewer +# End Source File +# Begin Source File + +SOURCE=..\..\Include\osgViewer\Version +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project + diff --git a/examples/osgkeyboardmouse/GNUmakefile b/examples/osgkeyboardmouse/GNUmakefile index 7a942a863..731307174 100644 --- a/examples/osgkeyboardmouse/GNUmakefile +++ b/examples/osgkeyboardmouse/GNUmakefile @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgkeyboardmouse.cpp\ -LIBS += -lProducer -losgFX -losgGA -losgDB -losgUtil -losg $(X_LIBS) $(OTHER_LIBS) -lOpenThreads +LIBS += -lProducer -losgFX -losgViewer -losgGA -losgDB -losgUtil -losg $(X_LIBS) $(OTHER_LIBS) -lOpenThreads INSTFILES = \ $(CXXFILES)\ diff --git a/examples/osgkeyboardmouse/GNUmakefile.inst b/examples/osgkeyboardmouse/GNUmakefile.inst index 9a2e627f9..1e28e44c9 100644 --- a/examples/osgkeyboardmouse/GNUmakefile.inst +++ b/examples/osgkeyboardmouse/GNUmakefile.inst @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgkeyboardmouse.cpp\ -LIBS += -lProducer -losgFX -losgDB --losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -lProducer -losgFX -losgViewer -losgGA -losgDB --losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) EXEC = osgkeyboardmouse diff --git a/examples/osgkeyboardmouse/osgkeyboardmouse.cpp b/examples/osgkeyboardmouse/osgkeyboardmouse.cpp index 1b98db0e9..17bf2acea 100644 --- a/examples/osgkeyboardmouse/osgkeyboardmouse.cpp +++ b/examples/osgkeyboardmouse/osgkeyboardmouse.cpp @@ -1,6 +1,6 @@ // C++ source file - (C) 2003 Robert Osfield, released under the OSGPL. // -// Simple example of use of Producer::RenderSurface + KeyboardMouseCallback + SceneView +// Simple example of use of Producer::RenderSurface + KeyboardMouseCallback + SimpleViewer // example that provides the user with control over view position with basic picking. #include @@ -11,17 +11,16 @@ #include #include -#include -#include #include #include #include -#include #include #include +#include + #include // ----------- Begining of glue classes to adapter Producer's keyboard mouse events to osgGA's abstraction events. @@ -138,21 +137,22 @@ public: class PickHandler : public osgGA::GUIEventHandler { public: - PickHandler(osgUtil::SceneView* sceneView): - _sceneView(sceneView), + PickHandler(): _mx(0.0),_my(0.0) {} ~PickHandler() {} - bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&) + bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) { + osgViewer::SimpleViewer* viewer = dynamic_cast(&aa); + switch(ea.getEventType()) { case(osgGA::GUIEventAdapter::KEYUP): { - if (ea.getKey()=='s') + if (ea.getKey()=='s' && viewer) { - saveSelectedModel(); + saveSelectedModel(viewer->getSceneData()); } return false; } @@ -168,7 +168,7 @@ public: if (_mx == ea.getX() && _my == ea.getY()) { // only do a pick if the mouse hasn't moved - pick(ea); + pick(ea,viewer); } return true; } @@ -178,39 +178,39 @@ public: } } - void pick(const osgGA::GUIEventAdapter& ea) + void pick(const osgGA::GUIEventAdapter& ea, osgViewer::SimpleViewer* viewer) { - - osg::Node* scene = _sceneView.valid() ? _sceneView->getSceneData() : 0; + osg::Node* scene = viewer->getSceneData(); if (!scene) return; - // remap the mouse x,y into viewport coordinates. osg::notify(osg::NOTICE)<getViewport()->x() + (int)((float)_sceneView->getViewport()->width()*(ea.getXnormalized()*0.5f+0.5f)); - float my = _sceneView->getViewport()->y() + (int)((float)_sceneView->getViewport()->height()*(ea.getYnormalized()*0.5f+0.5f)); + // remap the mouse x,y into viewport coordinates. + osg::Viewport* viewport = viewer->getCamera()->getViewport(); + float mx = viewport->x() + (int)((float)viewport->width()*(ea.getXnormalized()*0.5f+0.5f)); + float my = viewport->y() + (int)((float)viewport->height()*(ea.getYnormalized()*0.5f+0.5f)); osgUtil::LineSegmentIntersector* picker = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, osg::Vec3d(mx,my,0.0), osg::Vec3d(mx,my,1.0) ); + #endif osgUtil::IntersectionVisitor iv(picker); - _sceneView->getCamera()->accept(iv); - - osg::notify(osg::NOTICE)<<"Done pick, "<containsIntersections()<getCamera()->accept(iv); + if (picker->containsIntersections()) { osgUtil::LineSegmentIntersector::Intersection intersection = picker->getFirstIntersection(); - osg::notify(osg::NOTICE)<<"Picking "<=1)?nodePath[nodePath.size()-1]:0; osg::Group* parent = (nodePath.size()>=2)?dynamic_cast(nodePath[nodePath.size()-2]):0; @@ -247,37 +247,14 @@ public: } - - { - float mx = _sceneView->getViewport()->x() + (int)((float)_sceneView->getViewport()->width()*(ea.getXnormalized()*0.5f+0.5f)); - float my = _sceneView->getViewport()->y() + (int)((float)_sceneView->getViewport()->height()*(ea.getYnormalized()*0.5f+0.5f)); - - // do the pick traversal use the other PickVisitor to double check results. - osgUtil::PickVisitor pick(_sceneView->getViewport(), - _sceneView->getProjectionMatrix(), - _sceneView->getViewMatrix(), mx, my); - scene->accept(pick); - - osgUtil::PickVisitor::LineSegmentHitListMap& segHitList = pick.getSegHitList(); - if (!segHitList.empty() && !segHitList.begin()->second.empty()) - { - - // get the hits for the first segment - osgUtil::PickVisitor::HitList& hits = segHitList.begin()->second; - - // just take the first hit - nearest the eye point. - osgUtil::Hit& hit = hits.front(); - - std::cout<<"Got hits"<getSceneData()->accept(cmtsv); + scene->accept(cmtsv); if (cmtsv._group->getNumChildren()>0) { @@ -288,7 +265,6 @@ public: protected: - osg::observer_ptr _sceneView; float _mx,_my; }; @@ -317,7 +293,7 @@ int main( int argc, char **argv ) // create the view of the scene. - osgGA::SimpleViewer viewer; + osgViewer::SimpleViewer viewer; viewer.setSceneData(loadedModel.get()); // set up a KeyboardMouse to manage the events comming in from the RenderSurface @@ -334,7 +310,7 @@ int main( int argc, char **argv ) viewer.addEventHandler(statesetManipulator.get()); // add the pick handler - viewer.addEventHandler(new PickHandler(viewer.getSceneView())); + viewer.addEventHandler(new PickHandler()); // set the window dimensions viewer.getEventQueue()->getCurrentEventState()->setWindowRectangle(100,100,800,600); diff --git a/examples/osgsimple/GNUmakefile b/examples/osgsimple/GNUmakefile index 35d924512..9ee231af5 100644 --- a/examples/osgsimple/GNUmakefile +++ b/examples/osgsimple/GNUmakefile @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgsimple.cpp\ -LIBS += -lProducer -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) -lOpenThreads +LIBS += -lProducer -losgViewer -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) -lOpenThreads INSTFILES = \ $(CXXFILES)\ diff --git a/examples/osgsimple/GNUmakefile.inst b/examples/osgsimple/GNUmakefile.inst index 84ff36512..ad7e6353d 100644 --- a/examples/osgsimple/GNUmakefile.inst +++ b/examples/osgsimple/GNUmakefile.inst @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgsimple.cpp\ -LIBS += -lProducer -losgDB --losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -lProducer -losgViewer -losgDB --losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) EXEC = osgsimple diff --git a/examples/osgsimple/osgsimple.cpp b/examples/osgsimple/osgsimple.cpp index ad62f8088..589fceba6 100644 --- a/examples/osgsimple/osgsimple.cpp +++ b/examples/osgsimple/osgsimple.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include int main( int argc, char **argv ) @@ -34,7 +34,7 @@ int main( int argc, char **argv ) renderSurface->realize(); - osgGA::SimpleViewer viewer; + osgViewer::SimpleViewer viewer; viewer.setSceneData(loadedModel.get()); // initialize the view to look at the center of the scene graph diff --git a/examples/osgsimpleviewerFLTK/GNUmakefile b/examples/osgsimpleviewerFLTK/GNUmakefile index a3a1ab26b..3549ecf32 100644 --- a/examples/osgsimpleviewerFLTK/GNUmakefile +++ b/examples/osgsimpleviewerFLTK/GNUmakefile @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgsimpleviewerFLTK.cpp\ -LIBS += -losgGA -losgDB -losgUtil -losg -lfltk -lfltk_gl $(GL_LIBS) $(OTHER_LIBS) +LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg -lfltk -lfltk_gl $(GL_LIBS) $(OTHER_LIBS) INSTFILES = \ $(CXXFILES)\ diff --git a/examples/osgsimpleviewerFLTK/GNUmakefile.inst b/examples/osgsimpleviewerFLTK/GNUmakefile.inst index 5afed00d2..b9916f814 100644 --- a/examples/osgsimpleviewerFLTK/GNUmakefile.inst +++ b/examples/osgsimpleviewerFLTK/GNUmakefile.inst @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgsimpleviewerQT3.cpp\ -LIBS += -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) EXEC = osgsimpleviewerQT3 diff --git a/examples/osgsimpleviewerFLTK/osgsimpleviewerFLTK.cpp b/examples/osgsimpleviewerFLTK/osgsimpleviewerFLTK.cpp index 30b432653..907c5b2cf 100644 --- a/examples/osgsimpleviewerFLTK/osgsimpleviewerFLTK.cpp +++ b/examples/osgsimpleviewerFLTK/osgsimpleviewerFLTK.cpp @@ -3,7 +3,7 @@ // Simple example using GLUT to create an OpenGL window and OSG for rendering. // Derived from osgGLUTsimple.cpp and osgkeyboardmouse.cpp -#include +#include #include #include @@ -12,7 +12,7 @@ #include -class GraphicsWindowFLTK : public Fl_Gl_Window, virtual osgGA::GraphicsWindow +class GraphicsWindowFLTK : public Fl_Gl_Window, virtual osgViewer::GraphicsWindow { public: @@ -70,7 +70,7 @@ void idle_cb() } -class SimpleViewerFLTK : public osgGA::SimpleViewer, public GraphicsWindowFLTK +class SimpleViewerFLTK : public osgViewer::SimpleViewer, public GraphicsWindowFLTK { public: SimpleViewerFLTK(int x, int y, int w, int h, const char *label=0): diff --git a/examples/osgsimpleviewerGLUT/GNUmakefile b/examples/osgsimpleviewerGLUT/GNUmakefile index 0ea40de7a..4e517d91d 100644 --- a/examples/osgsimpleviewerGLUT/GNUmakefile +++ b/examples/osgsimpleviewerGLUT/GNUmakefile @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgsimpleviewerGLUT.cpp\ -LIBS += -losgGA -losgDB -losgUtil -losg $(GLUT_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg $(GLUT_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) INSTFILES = \ $(CXXFILES)\ diff --git a/examples/osgsimpleviewerGLUT/GNUmakefile.inst b/examples/osgsimpleviewerGLUT/GNUmakefile.inst index 660258928..8648908df 100644 --- a/examples/osgsimpleviewerGLUT/GNUmakefile.inst +++ b/examples/osgsimpleviewerGLUT/GNUmakefile.inst @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgsimpleviewerGLUT.cpp\ -LIBS += -losgGA -losgDB -losgUtil -losg -lglut $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg -lglut $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) EXEC = osgsimpleviewerGLUT diff --git a/examples/osgsimpleviewerGLUT/osgsimpleviewerGLUT.cpp b/examples/osgsimpleviewerGLUT/osgsimpleviewerGLUT.cpp index 9ae4b847e..eb3e2bdae 100644 --- a/examples/osgsimpleviewerGLUT/osgsimpleviewerGLUT.cpp +++ b/examples/osgsimpleviewerGLUT/osgsimpleviewerGLUT.cpp @@ -13,11 +13,11 @@ # include #endif -#include +#include #include #include -osg::ref_ptr viewer; +osg::ref_ptr viewer; void display(void) { @@ -89,7 +89,7 @@ int main( int argc, char **argv ) glutKeyboardFunc( keyboard ); // create the view of the scene. - viewer = new osgGA::SimpleViewer; + viewer = new osgViewer::SimpleViewer; viewer->setSceneData(loadedModel.get()); viewer->setCameraManipulator(new osgGA::TrackballManipulator); diff --git a/examples/osgsimpleviewerProducer/GNUmakefile b/examples/osgsimpleviewerProducer/GNUmakefile index f750c2a71..580bbeeba 100644 --- a/examples/osgsimpleviewerProducer/GNUmakefile +++ b/examples/osgsimpleviewerProducer/GNUmakefile @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgsimpleviewerProducer.cpp\ -LIBS += -lProducer -losgGA -losgDB -losgUtil -losg $(X_LIBS) $(OTHER_LIBS) -lOpenThreads +LIBS += -lProducer -losgViewer -losgGA -losgDB -losgUtil -losg $(X_LIBS) $(OTHER_LIBS) -lOpenThreads INSTFILES = \ $(CXXFILES)\ diff --git a/examples/osgsimpleviewerProducer/GNUmakefile.inst b/examples/osgsimpleviewerProducer/GNUmakefile.inst index e9f615193..4849385ea 100644 --- a/examples/osgsimpleviewerProducer/GNUmakefile.inst +++ b/examples/osgsimpleviewerProducer/GNUmakefile.inst @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgsimpleviewerProducer.cpp\ -LIBS += -lProducer -losgGA -losgDB --losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -lProducer -losgViewer -losgGA -losgDB --losgUtil -losg $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) EXEC = osgsimpleviewerProducer diff --git a/examples/osgsimpleviewerProducer/osgsimpleviewerProducer.cpp b/examples/osgsimpleviewerProducer/osgsimpleviewerProducer.cpp index 82bf5e6d5..438515ff1 100644 --- a/examples/osgsimpleviewerProducer/osgsimpleviewerProducer.cpp +++ b/examples/osgsimpleviewerProducer/osgsimpleviewerProducer.cpp @@ -8,7 +8,7 @@ #include -#include +#include #include #include @@ -81,7 +81,7 @@ private: // first approach uses a custom GraphicsWindow // then uses multiple inheritance to create a SimpleViewerWindowProducer -class GraphicsWindowProducer : public virtual osgGA::GraphicsWindow, public Producer::RenderSurface +class GraphicsWindowProducer : public virtual osgViewer::GraphicsWindow, public Producer::RenderSurface { public: @@ -120,7 +120,7 @@ class GraphicsWindowProducer : public virtual osgGA::GraphicsWindow, public Prod osg::ref_ptr _kbmcb; }; -class SimplerViewerProducer : public osgGA::SimpleViewer, public GraphicsWindowProducer +class SimplerViewerProducer : public osgViewer::SimpleViewer, public GraphicsWindowProducer { public: SimplerViewerProducer() {} @@ -198,7 +198,7 @@ int main( int argc, char **argv ) // create the view of the scene. - osgGA::SimpleViewer viewer; + osgViewer::SimpleViewer viewer; viewer.setSceneData(loadedModel.get()); // set up a KeyboardMouse to manage the events comming in from the RenderSurface diff --git a/examples/osgsimpleviewerQT3/GNUmakefile b/examples/osgsimpleviewerQT3/GNUmakefile index 17e83a9b5..e51141bd5 100644 --- a/examples/osgsimpleviewerQT3/GNUmakefile +++ b/examples/osgsimpleviewerQT3/GNUmakefile @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgsimpleviewerQT3.cpp\ -LIBS += -losgGA -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(OTHER_LIBS) +LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(OTHER_LIBS) INSTFILES = \ $(CXXFILES)\ diff --git a/examples/osgsimpleviewerQT3/GNUmakefile.inst b/examples/osgsimpleviewerQT3/GNUmakefile.inst index 5afed00d2..b9916f814 100644 --- a/examples/osgsimpleviewerQT3/GNUmakefile.inst +++ b/examples/osgsimpleviewerQT3/GNUmakefile.inst @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgsimpleviewerQT3.cpp\ -LIBS += -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) EXEC = osgsimpleviewerQT3 diff --git a/examples/osgsimpleviewerQT3/osgsimpleviewerQT3.cpp b/examples/osgsimpleviewerQT3/osgsimpleviewerQT3.cpp index 300288f90..298668c99 100644 --- a/examples/osgsimpleviewerQT3/osgsimpleviewerQT3.cpp +++ b/examples/osgsimpleviewerQT3/osgsimpleviewerQT3.cpp @@ -3,7 +3,7 @@ // Simple example using GLUT to create an OpenGL window and OSG for rendering. // Derived from osgGLUTsimple.cpp and osgkeyboardmouse.cpp -#include +#include #include #include @@ -14,7 +14,7 @@ class QWidget; #include -class GraphicsWindowQT : public QGLWidget, virtual public osgGA::GraphicsWindow +class GraphicsWindowQT : public QGLWidget, virtual public osgViewer::GraphicsWindow { public: @@ -89,7 +89,7 @@ void GraphicsWindowQT::mouseMoveEvent( QMouseEvent* event ) } -class SimpleViewerQT : public osgGA::SimpleViewer, public GraphicsWindowQT +class SimpleViewerQT : public osgViewer::SimpleViewer, public GraphicsWindowQT { public: SimpleViewerQT() {} diff --git a/examples/osgsimpleviewerQT4/GNUmakefile b/examples/osgsimpleviewerQT4/GNUmakefile index c48dcd7ca..7e98096b0 100644 --- a/examples/osgsimpleviewerQT4/GNUmakefile +++ b/examples/osgsimpleviewerQT4/GNUmakefile @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgsimpleviewerQT4.cpp\ -LIBS += -losgGA -losgDB -losgUtil -losg -lQtOpenGL -lQtGui -lQtCore $(GL_LIBS) $(OTHER_LIBS) +LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg -lQtOpenGL -lQtGui -lQtCore $(GL_LIBS) $(OTHER_LIBS) INSTFILES = \ $(CXXFILES)\ diff --git a/examples/osgsimpleviewerQT4/GNUmakefile.inst b/examples/osgsimpleviewerQT4/GNUmakefile.inst index f0377de38..097a5bb59 100644 --- a/examples/osgsimpleviewerQT4/GNUmakefile.inst +++ b/examples/osgsimpleviewerQT4/GNUmakefile.inst @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgsimpleviewerQT4.cpp\ -LIBS += -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg -lqt-mt $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) EXEC = osgsimpleviewerQT4 diff --git a/examples/osgsimpleviewerQT4/osgsimpleviewerQT4.cpp b/examples/osgsimpleviewerQT4/osgsimpleviewerQT4.cpp index 83e3ee5de..db1769b4b 100644 --- a/examples/osgsimpleviewerQT4/osgsimpleviewerQT4.cpp +++ b/examples/osgsimpleviewerQT4/osgsimpleviewerQT4.cpp @@ -3,7 +3,7 @@ // Simple example using GLUT to create an OpenGL window and OSG for rendering. // Derived from osgGLUTsimple.cpp and osgkeyboardmouse.cpp -#include +#include #include #include @@ -14,7 +14,7 @@ #include -class GraphicsWindowQT : public QGLWidget, virtual osgGA::GraphicsWindow +class GraphicsWindowQT : public QGLWidget, virtual osgViewer::GraphicsWindow { public: @@ -89,7 +89,7 @@ void GraphicsWindowQT::mouseMoveEvent( QMouseEvent* event ) } -class SimpleViewerQT : public osgGA::SimpleViewer, public GraphicsWindowQT +class SimpleViewerQT : public osgViewer::SimpleViewer, public GraphicsWindowQT { public: SimpleViewerQT() {} diff --git a/examples/osgsimpleviewerSDL/GNUmakefile b/examples/osgsimpleviewerSDL/GNUmakefile index 3fed8884a..079d6ec7c 100644 --- a/examples/osgsimpleviewerSDL/GNUmakefile +++ b/examples/osgsimpleviewerSDL/GNUmakefile @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgsimpleviewerSDL.cpp\ -LIBS += -losgGA -losgDB -losgUtil -losg `sdl-config --libs` $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg `sdl-config --libs` $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) INSTFILES = \ $(CXXFILES)\ diff --git a/examples/osgsimpleviewerSDL/GNUmakefile.inst b/examples/osgsimpleviewerSDL/GNUmakefile.inst index 29573092a..a28029959 100644 --- a/examples/osgsimpleviewerSDL/GNUmakefile.inst +++ b/examples/osgsimpleviewerSDL/GNUmakefile.inst @@ -4,7 +4,7 @@ include $(TOPDIR)/Make/makedefs CXXFILES =\ osgsimpleviewerSDL.cpp\ -LIBS += -losgGA -losgDB -losgUtil -losg `sdl-config --libs` $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) +LIBS += -losgViewer -losgGA -losgDB -losgUtil -losg `sdl-config --libs` $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS) EXEC = osgsimpleviewerSDL diff --git a/examples/osgsimpleviewerSDL/osgsimpleviewerSDL.cpp b/examples/osgsimpleviewerSDL/osgsimpleviewerSDL.cpp index 1802b3b2e..f1be9633e 100644 --- a/examples/osgsimpleviewerSDL/osgsimpleviewerSDL.cpp +++ b/examples/osgsimpleviewerSDL/osgsimpleviewerSDL.cpp @@ -3,7 +3,7 @@ // Simple example using GLUT to create an OpenGL window and OSG for rendering. // Derived from osgGLUTsimple.cpp and osgkeyboardmouse.cpp -#include +#include #include #include @@ -90,7 +90,7 @@ int main( int argc, char **argv ) SDL_EnableUNICODE(1); - osgGA::SimpleViewer viewer; + osgViewer::SimpleViewer viewer; viewer.setSceneData(loadedModel.get()); viewer.setCameraManipulator(new osgGA::TrackballManipulator); viewer.getEventQueue()->windowResize(0, 0, windowWidth, windowHeight ); diff --git a/include/osgViewer/Export b/include/osgViewer/Export new file mode 100644 index 000000000..7e90a25ed --- /dev/null +++ b/include/osgViewer/Export @@ -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. + +*/ + + diff --git a/include/osgGA/GraphicsWindow b/include/osgViewer/GraphicsWindow similarity index 95% rename from include/osgGA/GraphicsWindow rename to include/osgViewer/GraphicsWindow index df7658e3a..92c55b339 100644 --- a/include/osgGA/GraphicsWindow +++ b/include/osgViewer/GraphicsWindow @@ -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 #include #include -namespace osgGA { +#include + +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: diff --git a/include/osgGA/SimpleViewer b/include/osgViewer/SimpleViewer similarity index 84% rename from include/osgGA/SimpleViewer rename to include/osgViewer/SimpleViewer index f8ccf45fd..2ef4dd920 100644 --- a/include/osgGA/SimpleViewer +++ b/include/osgViewer/SimpleViewer @@ -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 #include -#include + +#include #include #include -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 > EventHandlers; + typedef std::list< osg::ref_ptr > EventHandlers; - void addEventHandler(GUIEventHandler* eventHandler); + void addEventHandler(osgGA::GUIEventHandler* eventHandler); EventHandlers& getEventHandlers() { return _eventHandlers; } const EventHandlers& getEventHandlers() const { return _eventHandlers; } diff --git a/include/osgViewer/Version b/include/osgViewer/Version new file mode 100644 index 000000000..67f898df6 --- /dev/null +++ b/include/osgViewer/Version @@ -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 + + +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 + diff --git a/src/osgGA/GNUmakefile b/src/osgGA/GNUmakefile index b1046809d..848136630 100644 --- a/src/osgGA/GNUmakefile +++ b/src/osgGA/GNUmakefile @@ -14,7 +14,6 @@ CXXFILES = \ GUIEventHandler.cpp\ KeySwitchMatrixManipulator.cpp\ StateSetManipulator.cpp\ - SimpleViewer.cpp\ TerrainManipulator.cpp\ NodeTrackerManipulator.cpp\ TrackballManipulator.cpp\ @@ -22,7 +21,7 @@ CXXFILES = \ DEF += -DOSGGA_LIBRARY -LIBS += -losgDB -losgUtil -losg $(GL_LIBS) $(OTHER_LIBS) +LIBS += -losgUtil -losg $(GL_LIBS) $(OTHER_LIBS) TARGET_BASENAME = osgGA LIB = $(LIB_PREFIX)$(TARGET_BASENAME).$(LIB_EXT) diff --git a/src/osgViewer/GNUmakefile b/src/osgViewer/GNUmakefile new file mode 100644 index 000000000..b749bfcc8 --- /dev/null +++ b/src/osgViewer/GNUmakefile @@ -0,0 +1,16 @@ +TOPDIR = ../.. +include $(TOPDIR)/Make/makedefs + + +CXXFILES = \ + SimpleViewer.cpp\ + Version.cpp\ + +DEF += -DOSGVIEWER_LIBRARY + +LIBS += -losgGA -losgDB -losgUtil -losg $(GL_LIBS) $(OTHER_LIBS) + +TARGET_BASENAME = osgViewer +LIB = $(LIB_PREFIX)$(TARGET_BASENAME).$(LIB_EXT) + +include $(TOPDIR)/Make/makerules diff --git a/src/osgGA/SimpleViewer.cpp b/src/osgViewer/SimpleViewer.cpp similarity index 97% rename from src/osgGA/SimpleViewer.cpp rename to src/osgViewer/SimpleViewer.cpp index ab7a52659..2e9d99fbe 100644 --- a/src/osgGA/SimpleViewer.cpp +++ b/src/osgViewer/SimpleViewer.cpp @@ -11,10 +11,9 @@ * OpenSceneGraph Public License for more details. */ -#include -#include +#include -using namespace osgGA; +using namespace osgViewer; SimpleViewer::SimpleViewer(): _firstFrame(true) @@ -80,7 +79,7 @@ const osg::CameraNode* SimpleViewer::getCamera() const return _sceneView->getCamera(); } -void SimpleViewer::setCameraManipulator(MatrixManipulator* manipulator) +void SimpleViewer::setCameraManipulator(osgGA::MatrixManipulator* manipulator) { if (_cameraManipulator == manipulator) return; @@ -94,7 +93,7 @@ void SimpleViewer::setCameraManipulator(MatrixManipulator* manipulator) } } -void SimpleViewer::addEventHandler(GUIEventHandler* eventHandler) +void SimpleViewer::addEventHandler(osgGA::GUIEventHandler* eventHandler) { _eventHandlers.push_back(eventHandler); } diff --git a/src/osgViewer/Version.cpp b/src/osgViewer/Version.cpp new file mode 100644 index 000000000..39bd3314c --- /dev/null +++ b/src/osgViewer/Version.cpp @@ -0,0 +1,12 @@ +#include + +const char* osgGAGetVersion() +{ + return "1.2"; +} + + +const char* osgGAGetLibraryName() +{ + return "OpenSceneGraph Gui Adapter Library"; +}