osgTerrain/Locator
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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 OSGTERRAIN_LOCATOR
#define OSGTERRAIN_LOCATOR 1
#include <osg/Object>
#include <osg/Vec3d>
#include <osg/CoordinateSystemNode>
#include <osgTerrain/Export>
namespace osgTerrain {
class OSGTERRAIN_EXPORT Locator : public osg::Object
{
public:
Locator();
Locator(const Locator&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgTerrain, Locator);
enum CoordinateSystemType
{
GEOCENTRIC,
GEOGRAPHIC,
PROJECTED
};
void setCoordinateSystemType(CoordinateSystemType type) { _coordinateSystemType = type; }
CoordinateSystemType getCoordinateSystemType() const { return _coordinateSystemType; }
void setFormat(const std::string& format) { _format = format; }
const std::string& getFormat() const { return _format; }
void setCoordinateSystem(const std::string& cs) { _cs = cs; }
const std::string& getCoordinateSystem() const { return _cs; }
void setEllipsoidModel(osg::EllipsoidModel* ellipsode) { _ellipsoidModel = ellipsode; }
osg::EllipsoidModel* getEllipsoidModel() { return _ellipsoidModel.get(); }
const osg::EllipsoidModel* getEllipsoidModel() const { return _ellipsoidModel.get(); }
void setTransform(const osg::Matrixd& transform) { _transform = transform; _inverse.invert(_transform); }
const osg::Matrixd& getTransform() const { return _transform; }
void setTransformAsExtents(double minX, double minY, double maxX, double maxY);
virtual bool orientationOpenGL() const;
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(Locator& source, osg::Vec3d& bottomLeft, osg::Vec3d& topRight) const;
void setDefinedInFile(bool flag) { _definedInFile = flag; }
bool getDefinedInFile() const { return _definedInFile; }
void setTransformScaledByResolution(bool scaledByResolution) { _transformScaledByResolution = scaledByResolution; }
bool getTransformScaledByResolution() const { return _transformScaledByResolution; }
protected:
virtual ~Locator();
CoordinateSystemType _coordinateSystemType;
std::string _format;
std::string _cs;
osg::ref_ptr<osg::EllipsoidModel> _ellipsoidModel;
osg::Matrixd _transform;
osg::Matrixd _inverse;
bool _definedInFile;
bool _transformScaledByResolution;
};
}
#endif
CoordinateSystemNode
Object
Vec3d
osgTerrain::Locator::_transform
osg::Matrixd _transform
Definition osgTerrain/Locator:122
osgTerrain::Locator::_format
std::string _format
Definition osgTerrain/Locator:118
osgTerrain::Locator::getEllipsoidModel
osg::EllipsoidModel * getEllipsoidModel()
Definition osgTerrain/Locator:73
osgTerrain::Locator::META_Object
META_Object(osgTerrain, Locator)
osgTerrain::Locator::getEllipsoidModel
const osg::EllipsoidModel * getEllipsoidModel() const
Definition osgTerrain/Locator:76
osgTerrain::Locator::getDefinedInFile
bool getDefinedInFile() const
Definition osgTerrain/Locator:107
osgTerrain::Locator::getCoordinateSystemType
CoordinateSystemType getCoordinateSystemType() const
Definition osgTerrain/Locator:54
osgTerrain::Locator::orientationOpenGL
virtual bool orientationOpenGL() const
osgTerrain::Locator::setDefinedInFile
void setDefinedInFile(bool flag)
Definition osgTerrain/Locator:106
osgTerrain::Locator::convertLocalToModel
virtual bool convertLocalToModel(const osg::Vec3d &local, osg::Vec3d &world) const
osgTerrain::Locator::CoordinateSystemType
CoordinateSystemType
Definition osgTerrain/Locator:38
osgTerrain::Locator::GEOGRAPHIC
@ GEOGRAPHIC
Definition osgTerrain/Locator:43
osgTerrain::Locator::GEOCENTRIC
@ GEOCENTRIC
Definition osgTerrain/Locator:40
osgTerrain::Locator::PROJECTED
@ PROJECTED
Definition osgTerrain/Locator:46
osgTerrain::Locator::setTransform
void setTransform(const osg::Matrixd &transform)
Definition osgTerrain/Locator:80
osgTerrain::Locator::_definedInFile
bool _definedInFile
Definition osgTerrain/Locator:125
osgTerrain::Locator::getFormat
const std::string & getFormat() const
Definition osgTerrain/Locator:60
osgTerrain::Locator::~Locator
virtual ~Locator()
osgTerrain::Locator::Locator
Locator(const Locator &, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
osgTerrain::Locator::setFormat
void setFormat(const std::string &format)
Definition osgTerrain/Locator:57
osgTerrain::Locator::setTransformScaledByResolution
void setTransformScaledByResolution(bool scaledByResolution)
Definition osgTerrain/Locator:109
osgTerrain::Locator::setCoordinateSystemType
void setCoordinateSystemType(CoordinateSystemType type)
Definition osgTerrain/Locator:51
osgTerrain::Locator::getCoordinateSystem
const std::string & getCoordinateSystem() const
Definition osgTerrain/Locator:66
osgTerrain::Locator::_coordinateSystemType
CoordinateSystemType _coordinateSystemType
Definition osgTerrain/Locator:116
osgTerrain::Locator::setTransformAsExtents
void setTransformAsExtents(double minX, double minY, double maxX, double maxY)
osgTerrain::Locator::_ellipsoidModel
osg::ref_ptr< osg::EllipsoidModel > _ellipsoidModel
Definition osgTerrain/Locator:120
osgTerrain::Locator::Locator
Locator()
osgTerrain::Locator::setEllipsoidModel
void setEllipsoidModel(osg::EllipsoidModel *ellipsode)
Definition osgTerrain/Locator:70
osgTerrain::Locator::convertLocalCoordBetween
static bool convertLocalCoordBetween(const Locator &source, const osg::Vec3d &sourceNDC, const Locator &destination, osg::Vec3d &destinationNDC)
Definition osgTerrain/Locator:95
osgTerrain::Locator::_transformScaledByResolution
bool _transformScaledByResolution
Definition osgTerrain/Locator:126
osgTerrain::Locator::getTransform
const osg::Matrixd & getTransform() const
Definition osgTerrain/Locator:83
osgTerrain::Locator::computeLocalBounds
bool computeLocalBounds(Locator &source, osg::Vec3d &bottomLeft, osg::Vec3d &topRight) const
osgTerrain::Locator::convertModelToLocal
virtual bool convertModelToLocal(const osg::Vec3d &world, osg::Vec3d &local) const
osgTerrain::Locator::_inverse
osg::Matrixd _inverse
Definition osgTerrain/Locator:123
osgTerrain::Locator::setCoordinateSystem
void setCoordinateSystem(const std::string &cs)
Definition osgTerrain/Locator:63
osgTerrain::Locator::_cs
std::string _cs
Definition osgTerrain/Locator:119
osgTerrain::Locator::getTransformScaledByResolution
bool getTransformScaledByResolution() const
Definition osgTerrain/Locator:110
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::EllipsoidModel
Definition CoordinateSystemNode:31
osg::Matrixd
Definition Matrixd:27
osg::Object
Definition Object:61
osg::Vec3d
Definition Vec3d:30
osg::ref_ptr
Definition ref_ptr:32
osgTerrain
Definition Node:29
Export
OSGTERRAIN_EXPORT
#define OSGTERRAIN_EXPORT
Definition osgTerrain/Export:39