osgVolume/Locator
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 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 OSGVOLUME_LOCATOR
#define OSGVOLUME_LOCATOR 1
#include <osgVolume/Export>
#include <osg/Object>
#include <osg/observer_ptr>
#include <osg/Matrixd>
#include <osg/TexGen>
#include <osg/MatrixTransform>
#include <vector>
namespace osgVolume {
class OSGVOLUME_EXPORT Locator : public osg::Object
{
public:
Locator() {}
Locator(const osg::Matrixd& transform) { setTransform(transform); }
Locator(const Locator& locator,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
osg::Object(locator, copyop),
_transform(locator._transform) {}
META_Object(osgVolume, Locator);
void setTransform(const osg::Matrixd& transform) { _transform = transform; _inverse.invert(_transform); locatorModified(); }
const osg::Matrixd& getTransform() const { return _transform; }
void setTransformAsExtents(double minX, double minY, double maxX, double maxY, double minZ, double maxZ);
virtual bool convertLocalToModel(const osg::Vec3d& /*local*/, osg::Vec3d& /*world*/) const;
virtual bool convertModelToLocal(const osg::Vec3d& /*world*/, osg::Vec3d& /*local*/) const;
static bool convertLocalCoordBetween(const Locator& source, const osg::Vec3d& sourceNDC,
const Locator& destination, osg::Vec3d& destinationNDC)
{
osg::Vec3d model;
if (!source.convertLocalToModel(sourceNDC, model)) return false;
if (!destination.convertModelToLocal(model, destinationNDC)) return false;
return true;
}
bool computeLocalBounds(osg::Vec3d& bottomLeft, osg::Vec3d& topRight) const;
bool computeLocalBounds(Locator& source, osg::Vec3d& bottomLeft, osg::Vec3d& topRight) const;
bool inverted() const;
void applyAppropriateFrontFace(osg::StateSet* ss) const;
class LocatorCallback : virtual public osg::Object
{
public:
LocatorCallback() {}
LocatorCallback(const LocatorCallback& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY): osg::Object(rhs,copyop) {}
META_Object(osgVolume, LocatorCallback);
virtual void locatorModified(Locator* /*locator*/) {};
protected:
virtual ~LocatorCallback() {}
};
void addCallback(LocatorCallback* callback);
template<class T> void addCallback(const osg::ref_ptr<T>& callback) { addCallback(callback.get()); }
void removeCallback(LocatorCallback* callback);
typedef std::vector< osg::ref_ptr<LocatorCallback> > LocatorCallbacks;
LocatorCallbacks& getLocatorCallbacks() { return _locatorCallbacks; }
const LocatorCallbacks& getLocatorCallbacks() const { return _locatorCallbacks; }
protected:
void locatorModified();
osg::Matrixd _transform;
osg::Matrixd _inverse;
LocatorCallbacks _locatorCallbacks;
};
class OSGVOLUME_EXPORT TransformLocatorCallback : public Locator::LocatorCallback
{
public:
TransformLocatorCallback(osg::MatrixTransform* transform);
void locatorModified(Locator* locator);
protected:
osg::observer_ptr<osg::MatrixTransform> _transform;
};
class OSGVOLUME_EXPORT TexGenLocatorCallback : public Locator::LocatorCallback
{
public:
TexGenLocatorCallback(osg::TexGen* texgen, Locator* geometryLocator, Locator* imageLocator);
void locatorModified(Locator*);
protected:
osg::observer_ptr<osg::TexGen> _texgen;
osg::observer_ptr<osgVolume::Locator> _geometryLocator;
osg::observer_ptr<osgVolume::Locator> _imageLocator;
};
}
#endif
MatrixTransform
Matrixd
Object
TexGen
osgVolume::Locator::LocatorCallback
Definition osgVolume/Locator:79
osgVolume::Locator::LocatorCallback::META_Object
META_Object(osgVolume, LocatorCallback)
osgVolume::Locator::LocatorCallback::locatorModified
virtual void locatorModified(Locator *)
Definition osgVolume/Locator:85
osgVolume::Locator::LocatorCallback::~LocatorCallback
virtual ~LocatorCallback()
Definition osgVolume/Locator:88
osgVolume::Locator::LocatorCallback::LocatorCallback
LocatorCallback(const LocatorCallback &rhs, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Definition osgVolume/Locator:82
osgVolume::Locator::LocatorCallback::LocatorCallback
LocatorCallback()
Definition osgVolume/Locator:81
osgVolume::Locator
Definition osgVolume/Locator:30
osgVolume::Locator::Locator
Locator(const osg::Matrixd &transform)
Definition osgVolume/Locator:35
osgVolume::Locator::getTransform
const osg::Matrixd & getTransform() const
Definition osgVolume/Locator:48
osgVolume::Locator::inverted
bool inverted() const
osgVolume::Locator::addCallback
void addCallback(const osg::ref_ptr< T > &callback)
Definition osgVolume/Locator:92
osgVolume::Locator::_transform
osg::Matrixd _transform
Definition osgVolume/Locator:104
osgVolume::Locator::Locator
Locator(const Locator &locator, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Definition osgVolume/Locator:38
osgVolume::Locator::LocatorCallbacks
std::vector< osg::ref_ptr< LocatorCallback > > LocatorCallbacks
Definition osgVolume/Locator:97
osgVolume::Locator::removeCallback
void removeCallback(LocatorCallback *callback)
osgVolume::Locator::computeLocalBounds
bool computeLocalBounds(osg::Vec3d &bottomLeft, osg::Vec3d &topRight) const
osgVolume::Locator::convertLocalCoordBetween
static bool convertLocalCoordBetween(const Locator &source, const osg::Vec3d &sourceNDC, const Locator &destination, osg::Vec3d &destinationNDC)
Definition osgVolume/Locator:58
osgVolume::Locator::_inverse
osg::Matrixd _inverse
Definition osgVolume/Locator:105
osgVolume::Locator::applyAppropriateFrontFace
void applyAppropriateFrontFace(osg::StateSet *ss) const
osgVolume::Locator::META_Object
META_Object(osgVolume, Locator)
osgVolume::Locator::computeLocalBounds
bool computeLocalBounds(Locator &source, osg::Vec3d &bottomLeft, osg::Vec3d &topRight) const
osgVolume::Locator::addCallback
void addCallback(LocatorCallback *callback)
osgVolume::Locator::getLocatorCallbacks
const LocatorCallbacks & getLocatorCallbacks() const
Definition osgVolume/Locator:99
osgVolume::Locator::setTransform
void setTransform(const osg::Matrixd &transform)
Definition osgVolume/Locator:45
osgVolume::Locator::locatorModified
void locatorModified()
osgVolume::Locator::Locator
Locator()
Definition osgVolume/Locator:33
osgVolume::Locator::_locatorCallbacks
LocatorCallbacks _locatorCallbacks
Definition osgVolume/Locator:107
osgVolume::Locator::getLocatorCallbacks
LocatorCallbacks & getLocatorCallbacks()
Definition osgVolume/Locator:98
osgVolume::Locator::setTransformAsExtents
void setTransformAsExtents(double minX, double minY, double maxX, double maxY, double minZ, double maxZ)
osgVolume::Locator::convertLocalToModel
virtual bool convertLocalToModel(const osg::Vec3d &, osg::Vec3d &) const
osgVolume::Locator::convertModelToLocal
virtual bool convertModelToLocal(const osg::Vec3d &, osg::Vec3d &) const
osgVolume::TexGenLocatorCallback::_imageLocator
osg::observer_ptr< osgVolume::Locator > _imageLocator
Definition osgVolume/Locator:136
osgVolume::TexGenLocatorCallback::_geometryLocator
osg::observer_ptr< osgVolume::Locator > _geometryLocator
Definition osgVolume/Locator:135
osgVolume::TexGenLocatorCallback::TexGenLocatorCallback
TexGenLocatorCallback(osg::TexGen *texgen, Locator *geometryLocator, Locator *imageLocator)
osgVolume::TexGenLocatorCallback::locatorModified
void locatorModified(Locator *)
osgVolume::TexGenLocatorCallback::_texgen
osg::observer_ptr< osg::TexGen > _texgen
Definition osgVolume/Locator:134
osgVolume::TransformLocatorCallback::TransformLocatorCallback
TransformLocatorCallback(osg::MatrixTransform *transform)
osgVolume::TransformLocatorCallback::_transform
osg::observer_ptr< osg::MatrixTransform > _transform
Definition osgVolume/Locator:120
osgVolume::TransformLocatorCallback::locatorModified
void locatorModified(Locator *locator)
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::MatrixTransform
Definition MatrixTransform:26
osg::Matrixd
Definition Matrixd:27
osg::Object
Definition Object:61
osg::Object::Object
Object()
Definition Object:69
osg::StateSet
Definition StateSet:46
osg::TexGen
Definition TexGen:43
osg::Vec3d
Definition Vec3d:30
osg::observer_ptr
Definition observer_ptr:39
osg::ref_ptr
Definition ref_ptr:32
osg::ref_ptr::get
T * get() const
Definition ref_ptr:117
osgVolume
osg
Definition AlphaFunc:19
observer_ptr
Export
OSGVOLUME_EXPORT
#define OSGVOLUME_EXPORT
Definition osgVolume/Export:39