OpenSceneGraph 3.6.5
Locator
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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 OSGVOLUME_LOCATOR
15#define OSGVOLUME_LOCATOR 1
16
17#include <osgVolume/Export>
18
19#include <osg/Object>
20#include <osg/observer_ptr>
21#include <osg/Matrixd>
22#include <osg/TexGen>
23#include <osg/MatrixTransform>
24
25#include <vector>
26
27namespace osgVolume {
28
30{
31 public:
32
34
35 Locator(const osg::Matrixd& transform) { setTransform(transform); }
36
39 osg::Object(locator, copyop),
40 _transform(locator._transform) {}
41
43
45 void setTransform(const osg::Matrixd& transform) { _transform = transform; _inverse.invert(_transform); locatorModified(); }
46
48 const osg::Matrixd& getTransform() const { return _transform; }
49
51 void setTransformAsExtents(double minX, double minY, double maxX, double maxY, double minZ, double maxZ);
52
53
54 virtual bool convertLocalToModel(const osg::Vec3d& /*local*/, osg::Vec3d& /*world*/) const;
55
56 virtual bool convertModelToLocal(const osg::Vec3d& /*world*/, osg::Vec3d& /*local*/) const;
57
58 static bool convertLocalCoordBetween(const Locator& source, const osg::Vec3d& sourceNDC,
59 const Locator& destination, osg::Vec3d& destinationNDC)
60 {
61 osg::Vec3d model;
62 if (!source.convertLocalToModel(sourceNDC, model)) return false;
63 if (!destination.convertModelToLocal(model, destinationNDC)) return false;
64 return true;
65 }
66
67 bool computeLocalBounds(osg::Vec3d& bottomLeft, osg::Vec3d& topRight) const;
68 bool computeLocalBounds(Locator& source, osg::Vec3d& bottomLeft, osg::Vec3d& topRight) const;
69
71 bool inverted() const;
72
75
76
78 class LocatorCallback : virtual public osg::Object
79 {
80 public:
84
85 virtual void locatorModified(Locator* /*locator*/) {};
86
87 protected:
88 virtual ~LocatorCallback() {}
89 };
90
92 template<class T> void addCallback(const osg::ref_ptr<T>& callback) { addCallback(callback.get()); }
93
94
96
97 typedef std::vector< osg::ref_ptr<LocatorCallback> > LocatorCallbacks;
100
101 protected:
102
106
108};
109
122
123
138
139
140}
141
142#endif
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
The osgVolume library is a NodeKit that extends the core scene graph to support volume rendering.
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
Definition Matrixd:27
MatrixTransform - is a subclass of Transform which has an osg::Matrix which represents a 4x4 transfor...
Definition MatrixTransform:26
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
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
Stores a set of modes and attributes which represent a set of OpenGL state.
Definition StateSet:46
TexGen encapsulates the OpenGL glTexGen (texture coordinate generation) state.
Definition TexGen:43
General purpose double triple for use as vertices, vectors and normals.
Definition Vec3d:30
Definition Locator:30
Locator(const osg::Matrixd &transform)
Definition Locator:35
const osg::Matrixd & getTransform() const
Set the transformation from local coordinates to model coordinates.
Definition Locator:48
bool inverted() const
Return true if the axis of the Locator are inverted requiring the faces of any cubes used from render...
void addCallback(const osg::ref_ptr< T > &callback)
Definition Locator:92
osg::Matrixd _transform
Definition Locator:104
Locator(const Locator &locator, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Copy constructor using CopyOp to manage deep vs shallow copy.
Definition Locator:38
std::vector< osg::ref_ptr< LocatorCallback > > LocatorCallbacks
Definition Locator:97
void removeCallback(LocatorCallback *callback)
bool computeLocalBounds(osg::Vec3d &bottomLeft, osg::Vec3d &topRight) const
static bool convertLocalCoordBetween(const Locator &source, const osg::Vec3d &sourceNDC, const Locator &destination, osg::Vec3d &destinationNDC)
Definition Locator:58
osg::Matrixd _inverse
Definition Locator:105
void applyAppropriateFrontFace(osg::StateSet *ss) const
apply the appropriate FrontFace setting to provided StateSet to ensure that the rendering of hull of ...
META_Object(osgVolume, Locator)
bool computeLocalBounds(Locator &source, osg::Vec3d &bottomLeft, osg::Vec3d &topRight) const
void addCallback(LocatorCallback *callback)
const LocatorCallbacks & getLocatorCallbacks() const
Definition Locator:99
void setTransform(const osg::Matrixd &transform)
Set the transformation from local coordinates to model coordinates.
Definition Locator:45
Locator()
Definition Locator:33
LocatorCallbacks _locatorCallbacks
Definition Locator:107
LocatorCallbacks & getLocatorCallbacks()
Definition Locator:98
void setTransformAsExtents(double minX, double minY, double maxX, double maxY, double minZ, double maxZ)
Set the extents of the local coords.
virtual bool convertLocalToModel(const osg::Vec3d &, osg::Vec3d &) const
virtual bool convertModelToLocal(const osg::Vec3d &, osg::Vec3d &) const
Callback interface for enabling the monitoring of changes to the Locator.
Definition Locator:79
META_Object(osgVolume, LocatorCallback)
virtual void locatorModified(Locator *)
Definition Locator:85
virtual ~LocatorCallback()
Definition Locator:88
LocatorCallback(const LocatorCallback &rhs, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Definition Locator:82
LocatorCallback()
Definition Locator:81
TransformLocatorCallback(osg::MatrixTransform *transform)
osg::observer_ptr< osg::MatrixTransform > _transform
Definition Locator:120
void locatorModified(Locator *locator)
osg::observer_ptr< osgVolume::Locator > _imageLocator
Definition Locator:136
osg::observer_ptr< osgVolume::Locator > _geometryLocator
Definition Locator:135
TexGenLocatorCallback(osg::TexGen *texgen, Locator *geometryLocator, Locator *imageLocator)
osg::observer_ptr< osg::TexGen > _texgen
Definition Locator:134
#define OSGVOLUME_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.