osgEarth 2.1.1
Public Member Functions | Protected Attributes

anonymous_namespace{FeatureLabelModelSource.cpp}::LabelNodeFactory Class Reference

Inheritance diagram for anonymous_namespace{FeatureLabelModelSource.cpp}::LabelNodeFactory:
Collaboration diagram for anonymous_namespace{FeatureLabelModelSource.cpp}::LabelNodeFactory:

List of all members.

Public Member Functions

 LabelNodeFactory (const FeatureLabelModelOptions &options)
bool createOrUpdateNode (FeatureCursor *cursor, const Style &style, const FilterContext &context, osg::ref_ptr< osg::Node > &node)

Protected Attributes

const FeatureLabelModelOptions _options

Detailed Description

Definition at line 42 of file FeatureLabelModelSource.cpp.


Constructor & Destructor Documentation

anonymous_namespace{FeatureLabelModelSource.cpp}::LabelNodeFactory::LabelNodeFactory ( const FeatureLabelModelOptions options) [inline]

Definition at line 48 of file FeatureLabelModelSource.cpp.

            : _options(options) { }

Member Function Documentation

bool anonymous_namespace{FeatureLabelModelSource.cpp}::LabelNodeFactory::createOrUpdateNode ( FeatureCursor cursor,
const Style style,
const FilterContext context,
osg::ref_ptr< osg::Node > &  node 
) [inline, virtual]

Render (or update) a list of features into a node according to the specified style.

Implements osgEarth::Features::FeatureNodeFactory.

Definition at line 52 of file FeatureLabelModelSource.cpp.

        {
            const MapInfo& mi = context.getSession()->getMapInfo();

            // A processing context to use with the filters:
            FilterContext cx = context;

            // Make a working copy of the features:
            FeatureList featureList;
            cursor->fill( featureList );
            //for (FeatureList::const_iterator it = features.begin(); it != features.end(); ++it)
            //    featureList.push_back(osg::clone((*it).get(),osg::CopyOp::DEEP_COPY_ALL));

            // Transform them into the map's SRS:
            TransformFilter xform( mi.getProfile()->getSRS(), mi.isGeocentric() );
            xform.setLocalizeCoordinates( true );
            xform.setMatrix( osg::Matrixd::translate( 0, 0, *_options.heightOffset() ) );
            //xform.setHeightOffset( *_options.heightOffset() );
            cx = xform.push( featureList, cx );        
            
            // Make some labels
            osg::ref_ptr<const TextSymbol> textSymbol = style.getSymbol<TextSymbol>();
            //Use a default symbol if we have no text symbol
            if (!textSymbol) textSymbol = new TextSymbol();
            osg::Node* labels = NULL;
            if (textSymbol.valid())
            {
                BuildTextOperator textOperator;
                labels = textOperator(featureList, textSymbol.get(), cx);
            }

            osg::Node* result = labels;

            // If the context specifies a reference frame, apply it to the resulting model.
            if ( cx.hasReferenceFrame() )
            {
                osg::MatrixTransform* delocalizer = new osg::MatrixTransform( cx.inverseReferenceFrame() );
                delocalizer->addChild( labels );
                result = delocalizer;
            }

            // Apply an LOD if required:
            if ( _options.minRange().isSet() || _options.maxRange().isSet() )
            {
                osg::LOD* lod = new osg::LOD();
                lod->addChild( result, *_options.minRange(), *_options.maxRange() );
                result = lod;
            }

            node = result;
            return true;
        }

Here is the call graph for this function:


Member Data Documentation

const FeatureLabelModelOptions anonymous_namespace{FeatureLabelModelSource.cpp}::LabelNodeFactory::_options [protected]

Definition at line 45 of file FeatureLabelModelSource.cpp.


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