osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/engine_seamless/PatchGroup

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003  * Copyright 2010 Pelican Ventures, Inc.
00004  * http://osgearth.org
00005  *
00006  * osgEarth is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018  */
00019 
00020 #ifndef SEAMLESS_PATCHGROUP
00021 #define SEAMLESS_PATCHGROUP 1
00022 
00023 #include <osg/PagedLOD>
00024 #include <osg/Vec2d>
00025 
00026 #include <osgDB/Registry>
00027 
00028 #include <osgEarth/TileKey>
00029 
00030 #include "PatchInfo"
00031 
00032 namespace seamless
00033 {
00034 class Patch;
00035 class PatchSet;
00036 class PatchOptions;
00037 
00038 class PatchGroup : public osg::PagedLOD
00039 {
00040 public:
00041     PatchGroup();
00042     PatchGroup(const PatchGroup&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
00043 
00044     META_Node(seamless, PatchGroup);
00045 
00046     virtual void traverse(osg::NodeVisitor& nv);
00047     // patch extents come from the PatchOptions object stored with the node.
00048     void getPatchExtents(osg::Vec2d& lowerLeft, osg::Vec2d& upperRight) const;
00049     void setOptions(PatchOptions* options);
00050     PatchOptions* getOptions();
00051     const PatchOptions* getOptions() const;
00052 protected:
00053     ~PatchGroup();
00054 };
00055 
00056 // Database options for creating a patch
00057 
00058 class PatchOptions : public osgDB::Options, public PatchInfo
00059 {
00060 public:
00061     PatchOptions();
00062     PatchOptions(const std::string& str);
00063     PatchOptions(const PatchOptions& rhs,
00064                  const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
00065     ~PatchOptions();
00066 
00067     META_Object(seamless, PatchOptions);
00068     void setPatchExtents(const osg::Vec2d& lowerLeft,
00069                          const osg::Vec2d& upperRight)
00070     {
00071         _lowerLeft = lowerLeft;  _upperRight = upperRight;
00072     }
00073     void getPatchExtents(osg::Vec2d& lowerLeft, osg::Vec2d& upperRight) const
00074     {
00075         lowerLeft = _lowerLeft;  upperRight = _upperRight;
00076     }
00077     void setPatchLevel(int level) { _level = level; }
00078     int getPatchLevel() const { return _level; }
00079     void setPatchSet(PatchSet* patchSet);
00080     PatchSet* getPatchSet() const;
00081     void setTileKey(const osgEarth::TileKey& key) { _tileKey = key; }
00082     osgEarth::TileKey getTileKey() { return _tileKey; }
00083     const osgEarth::TileKey& getTileKey() const { return _tileKey; }
00084 protected:
00085     osg::Vec2d _lowerLeft;
00086     osg::Vec2d _upperRight;
00087     int _level;
00088     osg::ref_ptr<PatchSet> _patchSet;
00089     osgEarth::TileKey _tileKey;
00090 };
00091 
00092 inline void PatchGroup::setOptions(PatchOptions* options)
00093 {
00094     setDatabaseOptions(options);
00095 }
00096 
00097 inline PatchOptions* PatchGroup::getOptions()
00098 {
00099     return static_cast<PatchOptions*>(getDatabaseOptions());
00100 }
00101 
00102 inline const PatchOptions* PatchGroup::getOptions() const
00103 {
00104     return static_cast<const PatchOptions*>(getDatabaseOptions());
00105 }
00106 }
00107 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines