osgEarth 2.1.1
Public Member Functions | Private Attributes

DebugTileSource Class Reference

Inheritance diagram for DebugTileSource:
Collaboration diagram for DebugTileSource:

List of all members.

Public Member Functions

 DebugTileSource (const DebugOptions &options)
void initialize (const std::string &referenceURI, const Profile *overrideProfile)
osg::Image * createImage (const TileKey &key, ProgressCallback *progress)
virtual std::string getExtension () const
virtual bool supportsPersistentCaching () const

Private Attributes

const DebugOptions _options
osg::ref_ptr< Geometry_geom
osg::ref_ptr< osgText::Font > _font
osg::Vec4 _color

Detailed Description

Definition at line 68 of file DebugTileSource.cpp.


Constructor & Destructor Documentation

DebugTileSource::DebugTileSource ( const DebugOptions options) [inline]

Definition at line 71 of file DebugTileSource.cpp.

                                                   : TileSource( options ), _options(options)
    {        
        _geom = new Ring();
        _geom->push_back( osg::Vec3(5, 5, 0) );
        _geom->push_back( osg::Vec3(250, 5, 0) );
        _geom->push_back( osg::Vec3(250, 250, 0) );
        _geom->push_back( osg::Vec3(5, 250, 0) );
        _font = osgText::readFontFile( "arial.ttf" );

        _color = osgEarth::htmlColorToVec4f( *_options.colorCode() );
    }

Here is the call graph for this function:


Member Function Documentation

osg::Image* DebugTileSource::createImage ( const TileKey key,
ProgressCallback progress 
) [inline, virtual]

Creates an image for the given TileKey. The returned object is new and is the responsibility of the caller.

Implements osgEarth::TileSource.

Definition at line 92 of file DebugTileSource.cpp.

    {
        // first draw the colored outline:
        GeometryRasterizer rasterizer( 256, 256 );
        rasterizer.draw( _geom.get(), colors[key.getLevelOfDetail() % 4] );
        osg::Image* image = rasterizer.finalize();
        
        // next render the tile key text:
        std::stringstream buf;        
        if (*_options.tms())
        {
            //Print out a TMS key for the TileKey
            unsigned int tileX, tileY;
            key.getTileXY(tileX, tileY);        
            unsigned int numRows, numCols;
            key.getProfile()->getNumTiles(key.getLevelOfDetail(), numCols, numRows);
            tileY  = numRows - tileY - 1;
            buf << key.getLevelOfDetail() << "/" << tileX << "/" << tileY;
        }
        else
        {
            buf << key.str();
        }        
        
        std::string text = buf.str();

        unsigned x = 10, y = 10;

        osgText::FontResolution resolution(32, 32);
        for( unsigned i=0; i<text.length(); ++i )
        {
#if !((OPENSCENEGRAPH_MAJOR_VERSION <= 2) && (OPENSCENEGRAPH_MINOR_VERSION <= 8))
            osgText::Glyph* glyph = _font->getGlyph( resolution, text.at(i) );
            copySubImageAndColorize( glyph, image, x, y, _color );
            x += glyph->s() + 1;
#endif
        }

        return image;
    }

Here is the call graph for this function:

virtual std::string DebugTileSource::getExtension ( ) const [inline, virtual]

Gets the preferred extension for this TileSource

Reimplemented from osgEarth::TileSource.

Definition at line 133 of file DebugTileSource.cpp.

    {
        return "png";
    }
void DebugTileSource::initialize ( const std::string &  referenceURI,
const Profile overrideProfile 
) [inline, virtual]

Initialize the TileSource. The profile should be computed and set here using setProfile()

Implements osgEarth::TileSource.

Definition at line 84 of file DebugTileSource.cpp.

    {
        if ( overrideProfile )
            setProfile( overrideProfile );
        else
            setProfile( Profile::create("global-geodetic") );
    }

Here is the call graph for this function:

virtual bool DebugTileSource::supportsPersistentCaching ( ) const [inline, virtual]

Returns true if data from this source can be cached to disk

Reimplemented from osgEarth::TileSource.

Definition at line 138 of file DebugTileSource.cpp.

    {
        return false;
    }

Member Data Documentation

osg::Vec4 DebugTileSource::_color [private]

Definition at line 147 of file DebugTileSource.cpp.

osg::ref_ptr<osgText::Font> DebugTileSource::_font [private]

Definition at line 146 of file DebugTileSource.cpp.

osg::ref_ptr<Geometry> DebugTileSource::_geom [private]

Definition at line 145 of file DebugTileSource.cpp.

Reimplemented from osgEarth::TileSource.

Definition at line 144 of file DebugTileSource.cpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines