OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Locator.h
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 OSGTERRAIN_LOCATOR
15 #define OSGTERRAIN_LOCATOR 1
16 
17 #include <osg/Object>
18 #include <osg/Vec3d>
19 #include <osg/CoordinateSystemNode>
20 
21 #include <osgTerrain/Export>
22 
23 namespace osgTerrain {
24 
26 {
27  public:
28 
29  Locator();
30 
33 
35 
38  {
41 
44 
46  PROJECTED
47  };
48 
51  void setCoordinateSystemType(CoordinateSystemType type) { _coordinateSystemType = type; }
52 
54  CoordinateSystemType getCoordinateSystemType() const { return _coordinateSystemType; }
55 
57  void setFormat(const std::string& format) { _format = format; }
58 
60  const std::string& getFormat() const { return _format; }
61 
63  void setCoordinateSystem(const std::string& cs) { _cs = cs; }
64 
66  const std::string& getCoordinateSystem() const { return _cs; }
67 
68 
70  void setEllipsoidModel(osg::EllipsoidModel* ellipsode) { _ellipsoidModel = ellipsode; }
71 
73  osg::EllipsoidModel* getEllipsoidModel() { return _ellipsoidModel.get(); }
74 
76  const osg::EllipsoidModel* getEllipsoidModel() const { return _ellipsoidModel.get(); }
77 
78 
80  void setTransform(const osg::Matrixd& transform) { _transform = transform; _inverse.invert(_transform); }
81 
83  const osg::Matrixd& getTransform() const { return _transform; }
84 
86  void setTransformAsExtents(double minX, double minY, double maxX, double maxY);
87 
88 
89  virtual bool orientationOpenGL() const;
90 
91  virtual bool convertLocalToModel(const osg::Vec3d& local, osg::Vec3d& world) const;
92 
93  virtual bool convertModelToLocal(const osg::Vec3d& world, osg::Vec3d& local) const;
94 
95  static bool convertLocalCoordBetween(const Locator& source, const osg::Vec3d& sourceNDC,
96  const Locator& destination, osg::Vec3d& destinationNDC)
97  {
98  osg::Vec3d model;
99  if (!source.convertLocalToModel(sourceNDC, model)) return false;
100  if (!destination.convertModelToLocal(model, destinationNDC)) return false;
101  return true;
102  }
103 
104  bool computeLocalBounds(Locator& source, osg::Vec3d& bottomLeft, osg::Vec3d& topRight) const;
105 
106  void setDefinedInFile(bool flag) { _definedInFile = flag; }
107  bool getDefinedInFile() const { return _definedInFile; }
108 
109  void setTransformScaledByResolution(bool scaledByResolution) { _transformScaledByResolution = scaledByResolution; }
110  bool getTransformScaledByResolution() const { return _transformScaledByResolution; }
111 
112  protected:
113 
114  virtual ~Locator();
115 
117 
118  std::string _format;
119  std::string _cs;
121 
124 
127 
128 };
129 
130 }
131 
132 #endif
void setEllipsoidModel(osg::EllipsoidModel *ellipsode)
Definition: Locator.h:70
const std::string & getFormat() const
Definition: Locator.h:60
static bool convertLocalCoordBetween(const Locator &source, const osg::Vec3d &sourceNDC, const Locator &destination, osg::Vec3d &destinationNDC)
Definition: Locator.h:95
const osg::EllipsoidModel * getEllipsoidModel() const
Definition: Locator.h:76
osg::Matrixd _inverse
Definition: Locator.h:123
void setDefinedInFile(bool flag)
Definition: Locator.h:106
virtual bool convertModelToLocal(const osg::Vec3d &world, osg::Vec3d &local) const
void setCoordinateSystemType(CoordinateSystemType type)
Definition: Locator.h:51
void setFormat(const std::string &format)
Definition: Locator.h:57
osg::Matrixd _transform
Definition: Locator.h:122
virtual bool convertLocalToModel(const osg::Vec3d &local, osg::Vec3d &world) const
#define OSGTERRAIN_EXPORT
Definition: Export.h:39
bool _transformScaledByResolution
Definition: Locator.h:126
CoordinateSystemType _coordinateSystemType
Definition: Locator.h:116
void setTransformScaledByResolution(bool scaledByResolution)
Definition: Locator.h:109
#define META_Object(library, name)
Definition: Object.h:42
std::string _format
Definition: Locator.h:118
const osg::Matrixd & getTransform() const
Definition: Locator.h:83
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: GLU.h:71
bool getDefinedInFile() const
Definition: Locator.h:107
std::string _cs
Definition: Locator.h:119
CoordinateSystemType getCoordinateSystemType() const
Definition: Locator.h:54
osg::EllipsoidModel * getEllipsoidModel()
Definition: Locator.h:73
void setCoordinateSystem(const std::string &cs)
Definition: Locator.h:63
bool invert(const Matrixd &rhs)
Definition: Matrixd.h:233
bool getTransformScaledByResolution() const
Definition: Locator.h:110
osg::ref_ptr< osg::EllipsoidModel > _ellipsoidModel
Definition: Locator.h:120
const std::string & getCoordinateSystem() const
Definition: Locator.h:66
void setTransform(const osg::Matrixd &transform)
Definition: Locator.h:80
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
Definition: GLU.h:71