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

osgEarth::Util::Annotation::PlacemarkNode Class Reference

Collaboration diagram for osgEarth::Util::Annotation::PlacemarkNode:

List of all members.

Public Member Functions

 PlacemarkNode (MapNode *mapNode, const osg::Vec3d &position, osg::Image *iconImage, const std::string &labelText, const Style &style=Style())
void setPosition (const osg::Vec3d &mapPosition)
void setIconImage (osg::Image *image)
osg::Image * getIconImage () const
void setText (const std::string &text)
const std::string & getText () const
void setStyle (const Style &style)
const StylegetStyle () const

Private Member Functions

void init ()

Private Attributes

osg::ref_ptr< osg::Image > _image
std::string _text
Style _style
osg::ref_ptr< Container_container
osg::ref_ptr< ImageControl_icon
osg::ref_ptr< LabelControl_label
osg::observer_ptr< MapNode_mapNode

Detailed Description

A Placemark combines an 2D icon, a label, support for mouse interaction and a popup control.

Definition at line 94 of file Annotation.


Constructor & Destructor Documentation

PlacemarkNode::PlacemarkNode ( MapNode mapNode,
const osg::Vec3d &  position,
osg::Image *  iconImage,
const std::string &  labelText,
const Style style = Style() 
)

Constructs a new node (convenience function)

Definition at line 35 of file Annotation.cpp.

                                                        :
_mapNode( mapNode ),
_image  ( image ),
_text   ( text ),
_style  ( style )
{
    init();
    setPosition( mapPosition );
}

Here is the call graph for this function:


Member Function Documentation

osg::Image* osgEarth::Util::Annotation::PlacemarkNode::getIconImage ( ) const [inline]

Definition at line 117 of file Annotation.

{ return _image.get(); }
const Style& osgEarth::Util::Annotation::PlacemarkNode::getStyle ( ) const [inline]

Definition at line 129 of file Annotation.

{ return _style; }
const std::string& osgEarth::Util::Annotation::PlacemarkNode::getText ( ) const [inline]

Definition at line 123 of file Annotation.

{ return _text; }
void PlacemarkNode::init ( ) [private]

Definition at line 64 of file Annotation.cpp.

{
    // remove any old stuff to make way for the new stuff.
    this->removeChildren(0, this->getNumChildren());

    this->setCullCallback( new CullNodeByHorizon(
        osg::Vec3d(0,0,1),
        _mapNode->getMap()->getProfile()->getSRS()->getEllipsoid()) );

    _label = new LabelControl(_text);

    TextSymbol* s = _style.get<TextSymbol>();
    if ( s )
    {
        if ( s->font().isSet() )
            _label->setFont( osgText::readFontFile( *s->font() ) );
        if ( s->size().isSet() )
            _label->setFontSize( *s->size() );
        if ( s->fill().isSet() )
            _label->setForeColor( s->fill()->color() );
        if ( s->halo().isSet() )
            _label->setHaloColor( s->halo()->color() );
        if ( s->content().isSet() && _text.empty() )
            _label->setText( s->content()->eval() );
    }

    if ( !_image.valid() )
    {
        MarkerSymbol* marker = _style.get<MarkerSymbol>();
        if ( marker )
        {
            _image = marker->getImage();
            if ( !_image.valid() && marker->url().isSet() )
            {
                _image = URI(marker->url()->expr()).readImage();
            }
        }
    }
    _icon = new ImageControl( _image.get() );

    _container = new HBox();
    _container->setChildSpacing( 8 );
    
    _container->addControl( _icon.get() );
    _container->addControl( _label.get() );

    _container->setHorizAlign( Control::ALIGN_RIGHT );
    _container->setVertAlign( Control::ALIGN_CENTER );

    //todo: set up the "ANCHOR POINT" for the sweet spot

    // wrap the other controls in a scene node.
    ControlNode* node = new ControlNode( _container.get() );
    this->addChild( node );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PlacemarkNode::setIconImage ( osg::Image *  image)

Image to use for the icon

Definition at line 121 of file Annotation.cpp.

{
    if ( image )
    {
        _image = image;
        if ( _icon.valid() )
            _icon->setImage( image );
    }
}
void PlacemarkNode::setPosition ( const osg::Vec3d &  mapPosition)

Sets the position of this annotation.

Parameters:
posPosition data

Definition at line 50 of file Annotation.cpp.

{
    if ( _mapNode.valid() )
    {
        osg::Vec3d world;
        if ( _mapNode->getMap()->mapPointToWorldPoint(pos, world) )
        {
            this->setMatrix( osg::Matrix::translate(world) );
            static_cast<CullNodeByHorizon*>(this->getCullCallback())->_world = world;
        }
    }
}

Here is the caller graph for this function:

void PlacemarkNode::setStyle ( const Style style)

Style (for text)

Definition at line 143 of file Annotation.cpp.

{
    _style = style;
    init();
}

Here is the call graph for this function:

void PlacemarkNode::setText ( const std::string &  text)

Text label content

Definition at line 132 of file Annotation.cpp.

{
    if ( text != _text )
    {
        _text = text;
        if ( _label.valid() )
            _label->setText( text );
    }
}

Member Data Documentation

Definition at line 136 of file Annotation.

Definition at line 137 of file Annotation.

osg::ref_ptr<osg::Image> osgEarth::Util::Annotation::PlacemarkNode::_image [private]

Definition at line 132 of file Annotation.

Definition at line 138 of file Annotation.

Definition at line 140 of file Annotation.

Definition at line 134 of file Annotation.

Definition at line 133 of file Annotation.


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