osgEarth 2.1.1
Functions

/home/cube/sources/osgearth/src/applications/osgearth_kml/osgearth_kml.cpp File Reference

#include <osg/Notify>
#include <osgGA/StateSetManipulator>
#include <osgGA/GUIEventHandler>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgEarth/MapNode>
#include <osgEarthUtil/EarthManipulator>
#include <osgEarthUtil/AutoClipPlaneHandler>
#include <osgEarthDrivers/kml/KML>
Include dependency graph for osgearth_kml.cpp:

Go to the source code of this file.

Functions

int usage (const std::string &msg)
int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 42 of file osgearth_kml.cpp.

{
    osg::ArgumentParser arguments(&argc,argv);
    osgViewer::Viewer viewer(arguments);

    osg::Group* root = new osg::Group();

    // load the .earth file from the command line.
    MapNode* mapNode = MapNode::load( arguments );
    if (!mapNode)
        return usage( "Unable to load earth model." );

    root->addChild( mapNode );

    for( int a = 1; a < argc; ++a )
    {
        std::string kmlFile( argv[a] );
        if ( endsWith( kmlFile, ".kml" ) )
        {
            osg::ref_ptr<osgDB::Options> options = new osgDB::Options();
            options->setPluginData( "osgEarth::MapNode", mapNode );
            osg::Node* kml = osgDB::readNodeFile( kmlFile, options.get() );
            if ( kml )
                root->addChild( kml );
        }
    }

    viewer.setCameraManipulator( new EarthManipulator() );
    viewer.setSceneData( root );
    viewer.getDatabasePager()->setDoPreCompile( true );

    // add some stock OSG handlers:
    viewer.addEventHandler(new osgViewer::StatsHandler());
    viewer.addEventHandler(new osgViewer::WindowSizeHandler());
    viewer.addEventHandler(new osgViewer::ThreadingHandler());
    viewer.addEventHandler(new osgViewer::LODScaleHandler());
    viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));
    viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage()));

    return viewer.run();
}

Here is the call graph for this function:

int usage ( const std::string &  msg)

Definition at line 33 of file osgearth_kml.cpp.

{
    OE_NOTICE << msg << std::endl;
    OE_NOTICE << std::endl;
    OE_NOTICE << "USAGE: osgearth_kml file.earth file.kml" << std::endl;
    return -1;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines