osgEarth 2.1.1
Public Member Functions | Private Member Functions | Private Attributes

osgEarth::ModelLayer Class Reference

Inheritance diagram for osgEarth::ModelLayer:
Collaboration diagram for osgEarth::ModelLayer:

List of all members.

Public Member Functions

 ModelLayer (const ModelLayerOptions &options)
 ModelLayer (const std::string &name, const ModelSourceOptions &options)
 ModelLayer (const ModelLayerOptions &options, ModelSource *source)
 ModelLayer (const std::string &name, osg::Node *node)
const std::string & getName () const
const ModelLayerOptionsgetModelLayerOptions () const
const std::string & getReferenceURI () const
ModelSourcegetModelSource () const
osg::Node * getOrCreateNode (ProgressCallback *progress=0L)
bool getEnabled () const
void setEnabled (bool enabled)
bool getOverlay () const
void setOverlay (bool overlay)
void setLightingEnabled (bool value)
bool isLightingEnabled () const
void addCallback (ModelLayerCallback *cb)
void removeCallback (ModelLayerCallback *cb)
void initialize (const std::string &referenceURI, const Map *map)

Private Member Functions

virtual void fireCallback (ModelLayerCallbackMethodPtr method)
void copyOptions ()

Private Attributes

std::string _referenceURI
osg::ref_ptr< ModelSource_modelSource
const ModelLayerOptions _initOptions
ModelLayerOptions _runtimeOptions
osg::ref_ptr< osg::Node > _node
Revision _modelSourceRev
ModelLayerCallbackList _callbacks

Detailed Description

Definition at line 103 of file ModelLayer.


Constructor & Destructor Documentation

ModelLayer::ModelLayer ( const ModelLayerOptions options)

Constructs a new model layer.

Definition at line 83 of file ModelLayer.cpp.

                                                         :
_initOptions( options )
{
    copyOptions();
}

Here is the call graph for this function:

ModelLayer::ModelLayer ( const std::string &  name,
const ModelSourceOptions options 
)

Constructs a new model layer with a user-provided driver options.

Definition at line 89 of file ModelLayer.cpp.

                                                                                 :
_initOptions( ModelLayerOptions( name, options ) )
{
    copyOptions();
}

Here is the call graph for this function:

ModelLayer::ModelLayer ( const ModelLayerOptions options,
ModelSource source 
)

Constructs a new model layer with a user-provided model source.

Definition at line 95 of file ModelLayer.cpp.

                                                                              :
_modelSource( source ),
_initOptions( options )
{
    copyOptions();
}

Here is the call graph for this function:

ModelLayer::ModelLayer ( const std::string &  name,
osg::Node *  node 
)

Constructs a new model layer with a user provided name and an existing node

Definition at line 102 of file ModelLayer.cpp.

                                                          :
_initOptions(ModelLayerOptions( name )),
_node(node)
{
    copyOptions();
}

Here is the call graph for this function:


Member Function Documentation

void ModelLayer::addCallback ( ModelLayerCallback cb)

Adds a property notification callback to this layer

Definition at line 219 of file ModelLayer.cpp.

{
    _callbacks.push_back( cb );
}

Here is the caller graph for this function:

void ModelLayer::copyOptions ( ) [private]

Definition at line 110 of file ModelLayer.cpp.

Here is the caller graph for this function:

void ModelLayer::fireCallback ( ModelLayerCallbackMethodPtr  method) [private, virtual]

Definition at line 234 of file ModelLayer.cpp.

{
    for( ModelLayerCallbackList::const_iterator i = _callbacks.begin(); i != _callbacks.end(); ++i )
    {
        ModelLayerCallback* cb = i->get();
        (cb->*method)( this );
    }
}

Here is the caller graph for this function:

bool ModelLayer::getEnabled ( ) const

Whether this layer is rendered.

Definition at line 170 of file ModelLayer.cpp.

{
    return *_runtimeOptions.enabled();
}

Here is the call graph for this function:

const ModelLayerOptions& osgEarth::ModelLayer::getModelLayerOptions ( ) const [inline]

Gets the initialization options for this layer.

Definition at line 135 of file ModelLayer.

{ return _initOptions; }

Here is the caller graph for this function:

ModelSource* osgEarth::ModelLayer::getModelSource ( ) const [inline]

Access the underlying model source.

Definition at line 145 of file ModelLayer.

{ return _modelSource.get(); }

Here is the caller graph for this function:

const std::string& osgEarth::ModelLayer::getName ( ) const [inline]

Gets the name of this model layer

Definition at line 130 of file ModelLayer.

{ return *_runtimeOptions.name(); }

Here is the caller graph for this function:

osg::Node * ModelLayer::getOrCreateNode ( ProgressCallback progress = 0L)

Definition at line 132 of file ModelLayer.cpp.

{
    if ( _modelSource.valid() )
    {
        // if the model source has changed, regenerate the node.
        if ( _node.valid() && !_modelSource->inSyncWith(_modelSourceRev) )
        {
            _node = 0L;
        }

        if ( !_node.valid() )
        {
            _node = _modelSource->createNode( progress );

            if ( _runtimeOptions.enabled().isSet() )
                setEnabled( *_runtimeOptions.enabled() );

            if ( _runtimeOptions.lightingEnabled().isSet() )
                setLightingEnabled( *_runtimeOptions.lightingEnabled() );

            if ( _modelSource->getOptions().depthTestEnabled() == false )            
            {
                if ( _node )
                {
                    osg::StateSet* ss = _node->getOrCreateStateSet();
                    ss->setAttributeAndModes( new osg::Depth( osg::Depth::ALWAYS ) );
                    ss->setRenderBinDetails( 99999, "RenderBin" ); //TODO: configure this bin ...
                }
            }

            _modelSource->sync( _modelSourceRev );
        }
    }

    return _node.get();
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool ModelLayer::getOverlay ( ) const

Whether this layer is drawn as normal geometry or as a draped overlay.

Definition at line 203 of file ModelLayer.cpp.

{
    return *_runtimeOptions.overlay();
}

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string& osgEarth::ModelLayer::getReferenceURI ( ) const [inline]

Gets the reference URI (for resolving relative paths)

Definition at line 140 of file ModelLayer.

{ return _referenceURI; }
void ModelLayer::initialize ( const std::string &  referenceURI,
const Map map 
)

Definition at line 116 of file ModelLayer.cpp.

{
    _referenceURI = referenceURI;

    if ( !_modelSource.valid() && _initOptions.driver().isSet() )
    {
        _modelSource = ModelSourceFactory::create( *_initOptions.driver() );
    }

    if ( _modelSource.valid() )
    {
        _modelSource->initialize( _referenceURI, map );
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool ModelLayer::isLightingEnabled ( ) const

Definition at line 197 of file ModelLayer.cpp.

Here is the call graph for this function:

void ModelLayer::removeCallback ( ModelLayerCallback cb)

Removes a property notification callback from this layer

Definition at line 225 of file ModelLayer.cpp.

{
    ModelLayerCallbackList::iterator i = std::find( _callbacks.begin(), _callbacks.end(), cb );
    if ( i != _callbacks.end() ) 
        _callbacks.erase( i );
}

Here is the caller graph for this function:

void ModelLayer::setEnabled ( bool  enabled)

Definition at line 176 of file ModelLayer.cpp.

{
    _runtimeOptions.enabled() = enabled;
    if ( _node.valid() )
        _node->setNodeMask( enabled ? ~0 : 0 );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ModelLayer::setLightingEnabled ( bool  value)

whether to apply lighting to the model layer's root node

Definition at line 184 of file ModelLayer.cpp.

{
    _runtimeOptions.lightingEnabled() = value;
    if ( _node.valid() )
    {
        _node->getOrCreateStateSet()->setMode( 
            GL_LIGHTING, value ? osg::StateAttribute::ON : 
            (osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED) );

    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ModelLayer::setOverlay ( bool  overlay)

Definition at line 209 of file ModelLayer.cpp.

Here is the call graph for this function:


Member Data Documentation

Definition at line 193 of file ModelLayer.

Definition at line 182 of file ModelLayer.

Definition at line 180 of file ModelLayer.

Definition at line 191 of file ModelLayer.

osg::ref_ptr< osg::Node > osgEarth::ModelLayer::_node [private]

Definition at line 185 of file ModelLayer.

std::string osgEarth::ModelLayer::_referenceURI [private]

Definition at line 179 of file ModelLayer.

Definition at line 183 of file ModelLayer.


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