root/OpenSceneGraph/trunk/include/osgViewer/Viewer @ 8893

Revision 8893, 3.9 kB (checked in by robert, 6 years ago)

refactored the getWindows(..) and getContexts(..) methods so that they produce
consistent ordering based on the order Camera/slave camera ordering.

  • 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 OSGVIEWER_Viewer
15#define OSGVIEWER_Viewer 1
16
17#include <osg/ArgumentParser>
18#include <osgGA/EventVisitor>
19#include <osgUtil/UpdateVisitor>
20#include <osgViewer/GraphicsWindow>
21#include <osgViewer/View>
22
23
24namespace osgViewer {
25
26/** Viewer holds a single view on to a single scene.*/
27class OSGVIEWER_EXPORT Viewer : public ViewerBase, public osgViewer::View
28{
29    public:
30
31        Viewer();
32
33        Viewer(osg::ArgumentParser& arguments);
34
35        Viewer(const osgViewer::Viewer& viewer, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
36
37        virtual ~Viewer();
38       
39        META_Object(osgViewer,Viewer);
40
41        /** Take all the settings, Camera and Slaves from the passed in view(er), leaving it empty. */
42        virtual void take(View& rhs);
43
44        /** read the viewer configuration from a configuration file.*/
45        virtual bool readConfiguration(const std::string& filename);
46       
47        /** Get whether at least of one of this viewers windows are realized.*/
48        virtual bool isRealized() const;
49
50        /** set up windows and associated threads.*/
51        virtual void realize();
52
53        virtual void setStartTick(osg::Timer_t tick);
54        void setReferenceTime(double time=0.0);
55
56        /** Set the sene graph data that viewer with view.*/
57        virtual void setSceneData(osg::Node* node);
58
59
60        /** Convenience method for setting up the viewer so it can be used embedded in an external managed window.
61          * Returns the GraphicsWindowEmbedded that can be used by applications to pass in events to the viewer. */
62        virtual GraphicsWindowEmbedded* setUpViewerAsEmbeddedInWindow(int x, int y, int width, int height);
63
64
65        virtual double elapsedTime();
66       
67        virtual osg::FrameStamp* getViewerFrameStamp() { return getFrameStamp(); }
68
69
70        /** Execute a main frame loop.
71          * Equivalent to while (!viewer.done()) viewer.frame();
72          * Also calls realize() if the viewer is not already realized,
73          * and installs trackball manipulator if one is not already assigned.
74          */
75        virtual int run();
76
77        virtual void advance(double simulationTime=USE_REFERENCE_TIME);
78
79        virtual void eventTraversal();
80
81        virtual void updateTraversal();
82       
83        void setCameraWithFocus(osg::Camera* camera) { _cameraWithFocus = camera; }
84        osg::Camera* getCameraWithFocus() { return _cameraWithFocus.get(); }
85        const osg::Camera* getCameraWithFocus() const { return _cameraWithFocus.get(); }
86       
87        virtual void getCameras(Cameras& cameras, bool onlyActive=true);
88       
89        virtual void getContexts(Contexts& contexts, bool onlyValid=true);
90
91        virtual void getAllThreads(Threads& threads, bool onlyActive=true);
92
93        virtual void getOperationThreads(OperationThreads& threads, bool onlyActive=true);
94
95        virtual void getScenes(Scenes& scenes, bool onlyValid=true);
96
97        virtual void getViews(Views& views, bool onlyValid=true);
98
99        /** Get the keyboard and mouse usage of this viewer.*/
100        virtual void getUsage(osg::ApplicationUsage& usage) const;
101
102
103    protected:
104   
105        void constructorInit();
106       
107        virtual void viewerInit() { init(); }
108
109        osg::observer_ptr<osg::Camera>              _cameraWithFocus;
110       
111
112};
113
114
115}
116
117#endif
Note: See TracBrowser for help on using the browser.