OpenSceneGraph 3.6.5
View
Go to the documentation of this file.
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_VIEW
15#define OSGVIEWER_VIEW 1
16
17#include <osg/View>
18
21#include <osgUtil/UpdateVisitor>
22#include <osgUtil/SceneView>
23
25#include <osgGA/EventVisitor>
26#include <osgGA/EventQueue>
27#include <osgGA/Device>
28
29#include <osgViewer/Scene>
30#include <osgViewer/ViewerBase>
31#include <osgViewer/Keystone>
32
33namespace osgViewer {
34
35
38{
39 public:
40
42
43 ViewConfig(const ViewConfig& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : osg::Object(rhs,copyop) {}
44
46
48 virtual void configure(osgViewer::View& /*view*/) const {}
49
52};
53
54
56{
62
64
65 virtual bool getDepthRange(osg::View& view, unsigned int partition, double& zNear, double& zFar);
66
68 double _zNear;
69 double _zMid;
70 double _zFar;
71};
72
73
76{
77 public:
78
80
82
84
87 virtual osg::View* asView() { return this; }
88
93
95 virtual void take(osg::View& rhs);
96
97 virtual void setStartTick(osg::Timer_t tick);
99
100 Scene* getScene() { return _scene.get(); }
101 const Scene* getScene() const { return _scene.get(); }
102
104 virtual void setSceneData(osg::Node* node);
105
106 template<class T> void setSceneData(const osg::ref_ptr<T>& node) { setSceneData(node.get()); }
107
109 osg::Node* getSceneData() { return _scene.valid() ? _scene->getSceneData() : 0; }
110
112 const osg::Node* getSceneData() const { return _scene.valid() ? _scene->getSceneData() : 0; }
113
114
117
118 template<class T> void setDatabasePager(const osg::ref_ptr<T>& dp) { setDatabasePager(dp.get()); }
119
122
125
126
129
130 template<class T> void setImagePager(const osg::ref_ptr<T>& ip) { setImagePager(ip.get()); }
131
134
137
138
141 void addDevice(osgGA::Device* eventSource);
142
143 template<class T> void addDevice(const osg::ref_ptr<T>& eventSource) { addDevice(eventSource.get()); }
144
146 void removeDevice(osgGA::Device* eventSource);
147
148 template<class T> void removeDevice(const osg::ref_ptr<T>& eventSource) { removeDevice(eventSource.get()); }
149
150 typedef std::vector< osg::ref_ptr<osgGA::Device> > Devices;
151
153 const Devices& getDevices() const { return _eventSources; }
154
155
156 /* Set the EventQueue that the View uses to integrate external non window related events.*/
157 void setEventQueue(osgGA::EventQueue* eventQueue) { _eventQueue = eventQueue; }
158
159 template<class T> void setEventQueue(const osg::ref_ptr<T>& eventQueue) { setEventQueue(eventQueue.get()); }
160
161 /* Get the View's EventQueue.*/
163
164 /* Get the const View's EventQueue.*/
165 const osgGA::EventQueue* getEventQueue() const { return _eventQueue.get(); }
166
169 void setCameraManipulator(osgGA::CameraManipulator* manipulator, bool resetPosition = true);
170
171 template<class T> void setCameraManipulator(const osg::ref_ptr<T>& manipulator, bool resetPosition = true) { setCameraManipulator(manipulator.get(), resetPosition); }
172
175
178
181 void home();
182
183
184 typedef std::list< osg::ref_ptr<osgGA::EventHandler> > EventHandlers;
185
188
189 template<class T> void addEventHandler(const osg::ref_ptr<T>& eventHandler) { addEventHandler(eventHandler.get()); }
190
193
194 template<class T> void removeEventHandler(const osg::ref_ptr<T>& eventHandler) { removeEventHandler(eventHandler.get()); }
195
198
201
202
207
210
213
214
217
218 template<class T> void setDisplaySettings(const osg::ref_ptr<T>& ds) { setDisplaySettings(ds.get()); }
219
222
225
228 {
229 _fusionDistanceMode = mode;
230 _fusionDistanceValue = value;
231 }
232
235
238
239
241 void apply(ViewConfig* config);
242
243 template<class T> void apply(const osg::ref_ptr<T>& config) { apply(config.get()); }
244
247
248
251
253 void setUpViewInWindow(int x, int y, int width, int height, unsigned int screenNum=0);
254
256 void setUpViewOnSingleScreen(unsigned int screenNum=0);
257
259 void setUpViewFor3DSphericalDisplay(double radius=1.0, double collar=0.45, unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd());
260
262 void setUpViewForPanoramicSphericalDisplay(double radius=1.0, double collar=0.45, unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd());
263
265 void setUpViewForWoWVxDisplay(unsigned int screenNum, unsigned char wow_content, unsigned char wow_factor, unsigned char wow_offset, float wow_disparity_Zd, float wow_disparity_vz, float wow_disparity_M, float wow_disparity_C);
266
267
268
271
274
275
277 bool containsCamera(const osg::Camera* camera) const;
278
279 template<class T> bool containsCamera(const osg::ref_ptr<T>& camera) const { return containsCamera(camera.get()); }
280
282 const osg::Camera* getCameraContainingPosition(float x, float y, float& local_x, float& local_y) const;
283
285 bool computeIntersections(float x,float y, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask = 0xffffffff);
286
288 bool computeIntersections(float x,float y, const osg::NodePath& nodePath, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask = 0xffffffff);
289
290
293
296
297
300
302 bool computeIntersections(const osg::Camera* camera, osgUtil::Intersector::CoordinateFrame cf, float x,float y, const osg::NodePath& nodePath, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask = 0xffffffff);
303
304 virtual void requestRedraw();
305 virtual void requestContinuousUpdate(bool needed=true);
306 virtual void requestWarpPointer(float x,float y);
307
309 virtual bool requiresUpdateSceneGraph() const;
310
312 virtual bool requiresRedraw() const;
313
314public:
315
316 osg::Texture* createDistortionTexture(int width, int height);
318 osg::Camera* assignKeystoneDistortionCamera(osg::DisplaySettings* ds, osg::GraphicsContext* gc, int x, int y, int width, int height, GLenum buffer, osg::Texture* texture, Keystone* keystone);
319 osg::Camera* assignStereoCamera(osg::DisplaySettings* ds, osg::GraphicsContext* gc, int x, int y, int width, int height, GLenum buffer, double eyeScale);
321
331
332
333 public:
334
336 void init();
337
338 protected:
339
340 friend class CompositeViewer;
341
342 virtual ~View();
343
345
347
348
350
352
357
359
363
365
366};
367
368}
369
370#endif
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
std::vector< Node * > NodePath
A vector of Nodes pointers which is used to describe the path from a root node to a descendant.
Definition Node:47
unsigned long long Timer_t
Definition Timer:24
The osgViewer library provides high level viewer functionality designed to make it easier to write a ...
Camera - is a subclass of Transform which represents encapsulates the settings of a Camera.
Definition Camera:45
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
DisplaySettings class for encapsulating what visuals are required and have been set up,...
Definition DisplaySettings:34
Base class for providing Windowing API agnostic access to creating and managing graphics context.
Definition GraphicsContext:30
Definition GraphicsThread:36
Image class for encapsulating the storage texture image data.
Definition Image:179
Definition Matrixd:27
Base class for all internal nodes in the scene graph.
Definition Node:72
unsigned int NodeMask
This is a set of bits (flags) that represent the Node.
Definition Node:363
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Object()
Construct an object.
Definition Object:69
Smart pointer for observed objects, that automatically set pointers to them to null when they are del...
Definition observer_ptr:39
ObserverNodePath is an observer class for tracking changes to a NodePath, that automatically invalida...
Definition ObserverNodePath:28
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
Base class for providing reference counted objects.
Definition Referenced:44
Texture pure virtual base class that encapsulates OpenGL texture functionality common to the various ...
Definition Texture:422
View - maintains a master camera view and a list of slave cameras that are relative to this master ca...
Definition View:30
Slave allows one to up a camera that follows the master with a local offset to the project and view m...
Definition View:98
Database paging class which manages the loading of files in a background thread, and synchronizing of...
Definition DatabasePager:50
Definition ImagePager:33
CameraManipulator is an abstract base class defining the interface, and a certain amount of default f...
Definition CameraManipulator:40
Device base class from abstracting away from devices/windows that can generate events.
Definition Device:25
EventHandler is base class for adding handling of events, either as node event callback,...
Definition EventHandler:34
EventQueue implementation for collecting and adapting windowing events.
Definition EventQueue:31
Definition GUIActionAdapter:62
Event class for storing Keyboard, mouse and window events.
Definition GUIEventAdapter:82
CoordinateFrame
Definition IntersectionVisitor:38
std::multiset< Intersection > Intersections
Definition LineSegmentIntersector:74
FusionDistanceMode
FusionDistanceMode is used only when working in stereo.
Definition SceneView:339
Definition Keystone:29
Scene holds the higher level reference to a single scene graph.
Definition Scene:30
Base class for View configurations for setting up Camera and Windowing.
Definition View:38
META_Object(osgViewer, ViewConfig)
virtual osg::DisplaySettings * getActiveDisplaySetting(osgViewer::View &view) const
convenience method for getting the relevant display settings to use.
ViewConfig(const ViewConfig &rhs, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Definition View:43
ViewConfig()
Definition View:41
virtual void configure(osgViewer::View &) const
configure method that is overridden by Config subclasses.
Definition View:48
virtual bool getDepthRange(osg::View &view, unsigned int partition, double &zNear, double &zFar)
double _zNear
Definition View:68
DepthMode _mode
Definition View:67
DepthPartitionSettings(DepthMode mode=BOUNDING_VOLUME)
double _zMid
Definition View:69
double _zFar
Definition View:70
@ FIXED_RANGE
Definition View:59
@ BOUNDING_VOLUME
Definition View:60
View holds a single view on a scene, this view may be composed of one or more slave cameras.
Definition View:76
void addEventHandler(const osg::ref_ptr< T > &eventHandler)
Definition View:189
void removeEventHandler(const osg::ref_ptr< T > &eventHandler)
Definition View:194
const osgDB::ImagePager * getImagePager() const
Get the const View's image pager.
float getFusionDistanceValue() const
Get the FusionDistanceValue.
Definition View:237
EventHandlers _eventHandlers
Definition View:356
const osg::Camera * getCameraContainingPosition(float x, float y, float &local_x, float &local_y) const
deprecated.
bool computeIntersections(float x, float y, osgUtil::LineSegmentIntersector::Intersections &intersections, osg::Node::NodeMask traversalMask=0xffffffff)
deprecated.
bool computeIntersections(const osgGA::GUIEventAdapter &ea, const osg::NodePath &nodePath, osgUtil::LineSegmentIntersector::Intersections &intersections, osg::Node::NodeMask traversalMask=0xffffffff)
Compute intersections of a ray, starting the current mouse position, through the specified master cam...
osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const
Get the FusionDistanceMode.
Definition View:234
osg::Texture * createDistortionTexture(int width, int height)
void setCoordinateSystemNodePath(const osg::NodePath &nodePath)
Set the NodePath to any active CoordinateSystemNode present in the Scene.
void addEventHandler(osgGA::EventHandler *eventHandler)
Add an EventHandler that adds handling of events to the View.
osgGA::CameraManipulator * getCameraManipulator()
Get the View's CameraManipulator.
Definition View:174
void removeDevice(const osg::ref_ptr< T > &eventSource)
Definition View:148
void setEventQueue(const osg::ref_ptr< T > &eventQueue)
Definition View:159
osg::ref_ptr< osgGA::EventQueue > _eventQueue
Definition View:354
virtual osg::View * asView()
Provide a mechanism for getting the osg::View associated from the GUIActionAdapter.
Definition View:87
void apply(ViewConfig *config)
Apply a viewer configuration to set up Cameras and Windowing.
bool computeIntersections(const osg::Camera *camera, osgUtil::Intersector::CoordinateFrame cf, float x, float y, osgUtil::LineSegmentIntersector::Intersections &intersections, osg::Node::NodeMask traversalMask=0xffffffff)
Compute intersections of a ray through the specified camera.
const osgGA::EventQueue * getEventQueue() const
Definition View:165
osg::ref_ptr< ViewConfig > _lastAppliedViewConfig
Definition View:364
void setUpViewOnSingleScreen(unsigned int screenNum=0)
deprecated, use view.apply(new osgViewer::SingleScreen(screenNum)).
void addDevice(const osg::ref_ptr< T > &eventSource)
Definition View:143
void setUpViewAcrossAllScreens()
deprecated, use view.apply(new osgViewer::AcrossAllScreens()).
virtual void setStartTick(osg::Timer_t tick)
virtual void requestRedraw()
requestRedraw() requests a single redraw.
osg::ref_ptr< osgGA::CameraManipulator > _cameraManipulator
Definition View:355
osg::NodePath getCoordinateSystemNodePath() const
Get the NodePath to any active CoordinateSystemNode present in the Scene.
osgDB::ImagePager * getImagePager()
Get the View's image pager.
osg::ObserverNodePath _coordinateSystemNodePath
Definition View:358
void setImagePager(osgDB::ImagePager *ip)
Set the View's image pager.
Devices _eventSources
Definition View:351
bool computeIntersections(float x, float y, const osg::NodePath &nodePath, osgUtil::LineSegmentIntersector::Intersections &intersections, osg::Node::NodeMask traversalMask=0xffffffff)
deprecated.
osg::observer_ptr< ViewerBase > _viewerBase
Definition View:346
const osgDB::DatabasePager * getDatabasePager() const
Get the const View's database pager.
osg::Node * getSceneData()
Get the View's scene graph.
Definition View:109
void setCameraManipulator(const osg::ref_ptr< T > &manipulator, bool resetPosition=true)
Definition View:171
void addDevice(osgGA::Device *eventSource)
Add a Device.
osg::Camera * assignStereoCamera(osg::DisplaySettings *ds, osg::GraphicsContext *gc, int x, int y, int width, int height, GLenum buffer, double eyeScale)
osg::Timer_t _startTick
Definition View:349
bool computeIntersections(const osg::Camera *camera, osgUtil::Intersector::CoordinateFrame cf, float x, float y, const osg::NodePath &nodePath, osgUtil::LineSegmentIntersector::Intersections &intersections, osg::Node::NodeMask traversalMask=0xffffffff)
Compute intersections of a ray through the specified camera and a specified nodePath's subgraph.
void assignSceneDataToCameras()
const ViewConfig * getLastAppliedViewConfig() const
Definition View:246
osg::ref_ptr< osg::DisplaySettings > _displaySettings
Definition View:360
const Scene * getScene() const
Definition View:101
osg::Camera * assignRenderToTextureCamera(osg::GraphicsContext *gc, int width, int height, osg::Texture *texture)
void setCameraManipulator(osgGA::CameraManipulator *manipulator, bool resetPosition=true)
Set the CameraManipulator that moves the View's master Camera position in response to events.
void assignStereoOrKeystoneToCamera(osg::Camera *camera, osg::DisplaySettings *ds)
bool computeIntersections(const osgGA::GUIEventAdapter &ea, osgUtil::LineSegmentIntersector::Intersections &intersections, osg::Node::NodeMask traversalMask=0xffffffff)
Compute intersections of a ray, starting the current mouse position, through the specified camera.
osg::Camera * assignKeystoneDistortionCamera(osg::DisplaySettings *ds, osg::GraphicsContext *gc, int x, int y, int width, int height, GLenum buffer, osg::Texture *texture, Keystone *keystone)
void setDatabasePager(osgDB::DatabasePager *dp)
Set the View's database pager.
void setFusionDistance(osgUtil::SceneView::FusionDistanceMode mode, float value=1.0f)
Set the FusionDistanceMode and Value.
Definition View:227
virtual void requestContinuousUpdate(bool needed=true)
requestContinuousUpdate(bool) is for en/disabling a throw or idle callback to be requested by a GUIEv...
virtual void setSceneData(osg::Node *node)
Set the scene graph that the View will use.
Scene * getScene()
Definition View:100
EventHandlers & getEventHandlers()
Get the View's list of EventHandlers.
Definition View:197
void setDisplaySettings(const osg::ref_ptr< T > &ds)
Definition View:218
friend class CompositeViewer
Definition View:340
void apply(const osg::ref_ptr< T > &config)
Definition View:243
void home()
Set the view to the CameraManipulator's home position, if none is attached home() it does nothing.
osgGA::EventQueue * getEventQueue()
Definition View:162
ViewConfig * getLastAppliedViewConfig()
Definition View:245
const EventHandlers & getEventHandlers() const
Get the const View's list of EventHandlers.
Definition View:200
osg::DisplaySettings * getDisplaySettings()
Set the DisplaySettings object associated with this view.
Definition View:221
osgDB::DatabasePager * getDatabasePager()
Get the View's database pager.
virtual void take(osg::View &rhs)
Take all the settings, Camera and Slaves from the passed in view, leaving it empty.
virtual bool requiresUpdateSceneGraph() const
Return true if there are pending updates to the scene graph that require an update.
void removeDevice(osgGA::Device *eventSource)
Remove a Device.
bool setUpDepthPartition(DepthPartitionSettings *dsp=0)
Convenience method for setting up multiple slave cameras with depth partitioning on each of the view'...
osg::ref_ptr< osgViewer::Scene > _scene
Definition View:353
virtual void requestWarpPointer(float x, float y)
requestWarpPointer(int,int) is requesting a repositioning of the mouse pointer to a specified x,...
bool setUpDepthPartitionForCamera(osg::Camera *cameraToPartition, DepthPartitionSettings *dps=0)
Convenience method for setting up depth partitioning on the specified camera.
std::list< osg::ref_ptr< osgGA::EventHandler > > EventHandlers
Definition View:184
void setImagePager(const osg::ref_ptr< T > &ip)
Definition View:130
virtual bool requiresRedraw() const
Return true if there are graphics operations that require a draw of the grpahics context.
virtual ~View()
void setDatabasePager(const osg::ref_ptr< T > &dp)
Definition View:118
View(const osgViewer::View &view, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
const osgGA::CameraManipulator * getCameraManipulator() const
Get the const View's CameraManipulator.
Definition View:177
void setUpViewInWindow(int x, int y, int width, int height, unsigned int screenNum=0)
deprecated, use view.apply(new osgViewer::SingleWindow(x,y,width,screenNum)).
bool containsCamera(const osg::ref_ptr< T > &camera) const
Definition View:279
void setUpViewForWoWVxDisplay(unsigned int screenNum, unsigned char wow_content, unsigned char wow_factor, unsigned char wow_offset, float wow_disparity_Zd, float wow_disparity_vz, float wow_disparity_M, float wow_disparity_C)
deprecated.
virtual osg::GraphicsOperation * createRenderer(osg::Camera *camera)
const osg::Node * getSceneData() const
Get the const View's scene graph.
Definition View:112
osgUtil::SceneView::FusionDistanceMode _fusionDistanceMode
Definition View:361
void removeEventHandler(osgGA::EventHandler *eventHandler)
Remove an EventHandler from View.
void computeActiveCoordinateSystemNodePath()
Compute the NodePath to any active CoordinateSystemNode present in the Scene.
float _fusionDistanceValue
Definition View:362
const osg::DisplaySettings * getDisplaySettings() const
Set the DisplaySettings object associated with this view.
Definition View:224
bool containsCamera(const osg::Camera *camera) const
Return true if this view contains a specified camera.
ViewerBase * getViewerBase()
Provide a mechanism for getting the viewer object from this osgViewer::View.
Definition View:92
META_Object(osgViewer, View)
Devices & getDevices()
Definition View:152
void setUpViewFor3DSphericalDisplay(double radius=1.0, double collar=0.45, unsigned int screenNum=0, osg::Image *intensityMap=0, const osg::Matrixd &projectorMatrix=osg::Matrixd())
deprecated, use view.apply(new osgViewer::SphericalDisplay(radius, collar, screenNum,...
const Devices & getDevices() const
Definition View:153
osg::Timer_t getStartTick() const
Definition View:98
void setEventQueue(osgGA::EventQueue *eventQueue)
Definition View:157
void setUpViewForPanoramicSphericalDisplay(double radius=1.0, double collar=0.45, unsigned int screenNum=0, osg::Image *intensityMap=0, const osg::Matrixd &projectorMatrix=osg::Matrixd())
deprecated, use view.apply(new osgViewer::PanoramicSphericalDisplay(radius, collar,...
std::vector< osg::ref_ptr< osgGA::Device > > Devices
Definition View:150
void setDisplaySettings(osg::DisplaySettings *ds)
Set the DisplaySettings object associated with this view.
Definition View:216
void setSceneData(const osg::ref_ptr< T > &node)
Definition View:106
StereoSlaveCallback(osg::DisplaySettings *ds, double eyeScale)
Definition View:324
double _eyeScale
Definition View:329
osg::ref_ptr< osg::DisplaySettings > _ds
Definition View:328
virtual void updateSlave(osg::View &view, osg::View::Slave &slave)
ViewerBase is the view base class that is inherited by both Viewer and CompositeViewer.
Definition ViewerBase:36
#define OSGVIEWER_EXPORT
Definition Export:40

osg logo
Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.