osgEarth 2.1.1
Public Member Functions | Static Public Attributes

PopUpSymbolizer Struct Reference

List of all members.

Public Member Functions

bool compile (State< GeometryContent > *state, osg::Group *attachPoint)

Static Public Attributes

static int PopUpIndex = 0

Detailed Description

Definition at line 140 of file osgearth_symbology.cpp.


Member Function Documentation

bool PopUpSymbolizer::compile ( State< GeometryContent > *  state,
osg::Group *  attachPoint 
) [inline]

Definition at line 144 of file osgearth_symbology.cpp.

    {
        if ( !state || !attachPoint || !state->getContent() || !state->getStyle() )
            return false;

        PopUpSymbolizerContext* ctx = dynamic_cast<PopUpSymbolizerContext*>( state->getContext() );
        if (!ctx)
            return false;

        osg::ref_ptr<osg::Group> newSymbolized = new osg::Group;

        const GeometryList& geometryList = state->getContent()->getGeometryList();
        for (GeometryList::const_iterator it = geometryList.begin(); it != geometryList.end(); ++it)
        {
            Geometry* geometry = *it;
            if (!geometry)
                continue;

            osg::ref_ptr<osg::Geometry> osgGeom = new osg::Geometry;
            switch( geometry->getType())
            {
            case Geometry::TYPE_POINTSET:
            case Geometry::TYPE_LINESTRING:
            case Geometry::TYPE_RING:
            case Geometry::TYPE_POLYGON:
            {
                const PopupSymbol* symbol = state->getStyle()->getSymbol<PopupSymbol>();
                if (symbol)
                {
                    //osg::Image* image = 0;
                    //if (!symbol->theme()->empty())
                    //    image = osgDB::readImageFile(symbol->theme().value());
                    //osgText::Font* font = 0;
                    //if (!symbol->font()->empty())
                    //    font = osgText::readFontFile(symbol->font().value());
                    //float size = symbol->size().value();
                    //osg::Vec4 color = symbol->fill()->color();
                    
                    for ( osg::Vec3dArray::iterator it = geometry->begin(); it != geometry->end(); ++it)
                    {
                        osg::MatrixTransform* transform = new osg::MatrixTransform;
                        transform->setMatrix(osg::Matrix::translate(*it));
                        if (!PopUpIndex) {
                            std::stringstream ss;
                            ss << "Hit i Key to see more popup" << std::endl;
                            ss << "And hit a second time to hide them" << std::endl;
                            std::string text = ss.str();
                            std::string title = "Info";

                            TextPopup* popup = ctx->_wm->createTextPopup(title, text, symbol);
                            //popup->setFocusColor(osg::Vec4(getRandomValueInOne(), getRandomValueInOne() , getRandomValueInOne(), 1.0));
                            popup->attach(transform);
                            popup->setAppear();

                        } else {
                            std::stringstream ss;
                            ss << "osgEarth" << std::endl;
                            ss << "rocks at " << *it << " miles" << std::endl;
                            std::string text = ss.str();
                            std::string title = "osgEarthUtil";
                            TextPopup* popup = ctx->_wm->createTextPopup(title, text, symbol);
                            //popup->setFocusColor(osg::Vec4(getRandomValueInOne(), getRandomValueInOne() , getRandomValueInOne(), 1.0));
                            popup->attach(transform);
                            ctx->_widgetList.push_back(popup);
                        }
                        PopUpIndex++;
                        newSymbolized->addChild(transform);
                        transform->addChild(osgDB::readNodeFile("../data/tree.ive"));
                    }
                }
            }
            break;
            }
        }

        if (newSymbolized->getNumChildren()) 
        {
            attachPoint->removeChildren(0, attachPoint->getNumChildren());
            attachPoint->addChild(newSymbolized.get());
            return true;
        }

        return false;
    }

Here is the call graph for this function:


Member Data Documentation

int PopUpSymbolizer::PopUpIndex = 0 [static]

Definition at line 142 of file osgearth_symbology.cpp.


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