osgEarth 2.1.1
|
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 Style & | getStyle () 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 |
A Placemark combines an 2D icon, a label, support for mouse interaction and a popup control.
Definition at line 94 of file Annotation.
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 ); }
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 ); }
void PlacemarkNode::setIconImage | ( | osg::Image * | image | ) |
Image to use for the icon
Definition at line 121 of file Annotation.cpp.
void PlacemarkNode::setPosition | ( | const osg::Vec3d & | mapPosition | ) |
Sets the position of this annotation.
pos | Position 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; } } }
void PlacemarkNode::setStyle | ( | const Style & | style | ) |
Style (for text)
Definition at line 143 of file Annotation.cpp.
void PlacemarkNode::setText | ( | const std::string & | text | ) |
osg::ref_ptr<Container> osgEarth::Util::Annotation::PlacemarkNode::_container [private] |
Definition at line 136 of file Annotation.
osg::ref_ptr<ImageControl> osgEarth::Util::Annotation::PlacemarkNode::_icon [private] |
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.
osg::ref_ptr<LabelControl> osgEarth::Util::Annotation::PlacemarkNode::_label [private] |
Definition at line 138 of file Annotation.
osg::observer_ptr<MapNode> osgEarth::Util::Annotation::PlacemarkNode::_mapNode [private] |
Definition at line 140 of file Annotation.
Definition at line 134 of file Annotation.
std::string osgEarth::Util::Annotation::PlacemarkNode::_text [private] |
Definition at line 133 of file Annotation.