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

Revision 13041, 4.4 kB (checked in by robert, 3 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 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(osg::View& rhs);
43
44
45        /** Set the Stats object used for collect various frame related timing and scene graph stats.*/
46        virtual void setViewerStats(osg::Stats* stats) { setStats(stats); }
47
48        /** Get the Viewers Stats object.*/
49        virtual osg::Stats* getViewerStats() { return getStats(); }
50
51        /** Get the Viewers Stats object.*/
52        virtual const osg::Stats* getViewerStats() const { return getStats(); }
53
54
55        /** read the viewer configuration from a configuration file.*/
56        virtual bool readConfiguration(const std::string& filename);
57
58        /** Get whether at least of one of this viewers windows are realized.*/
59        virtual bool isRealized() const;
60
61        /** set up windows and associated threads.*/
62        virtual void realize();
63
64        virtual void setStartTick(osg::Timer_t tick);
65        void setReferenceTime(double time=0.0);
66
67        /** Set the sene graph data that viewer with view.*/
68        virtual void setSceneData(osg::Node* node);
69
70
71        /** Convenience method for setting up the viewer so it can be used embedded in an external managed window.
72          * Returns the GraphicsWindowEmbedded that can be used by applications to pass in events to the viewer. */
73        virtual GraphicsWindowEmbedded* setUpViewerAsEmbeddedInWindow(int x, int y, int width, int height);
74
75
76        virtual double elapsedTime();
77
78        virtual osg::FrameStamp* getViewerFrameStamp() { return getFrameStamp(); }
79
80        /** Execute a main frame loop.
81          * Equivalent to while (!viewer.done()) viewer.frame();
82          * Also calls realize() if the viewer is not already realized,
83          * and installs trackball manipulator if one is not already assigned.
84          */
85        virtual int run();
86
87        /** check to see if the new frame is required, called by run(..) when FrameScheme is set to ON_DEMAND.*/
88        virtual bool checkNeedToDoFrame();
89
90        virtual void advance(double simulationTime=USE_REFERENCE_TIME);
91
92        virtual void eventTraversal();
93
94        virtual void updateTraversal();
95
96        void setCameraWithFocus(osg::Camera* camera) { _cameraWithFocus = camera; }
97        osg::Camera* getCameraWithFocus() { return _cameraWithFocus.get(); }
98        const osg::Camera* getCameraWithFocus() const { return _cameraWithFocus.get(); }
99
100        virtual void getCameras(Cameras& cameras, bool onlyActive=true);
101
102        virtual void getContexts(Contexts& contexts, bool onlyValid=true);
103
104        virtual void getAllThreads(Threads& threads, bool onlyActive=true);
105
106        virtual void getOperationThreads(OperationThreads& threads, bool onlyActive=true);
107
108        virtual void getScenes(Scenes& scenes, bool onlyValid=true);
109
110        virtual void getViews(Views& views, bool onlyValid=true);
111
112        /** Get the keyboard and mouse usage of this viewer.*/
113        virtual void getUsage(osg::ApplicationUsage& usage) const;
114
115
116    protected:
117
118        void constructorInit();
119
120        virtual void viewerInit() { init(); }
121
122        osg::observer_ptr<osg::Camera>              _cameraWithFocus;
123
124
125};
126
127
128}
129
130#endif
Note: See TracBrowser for help on using the browser.