osgEarth 2.1.1
Public Member Functions | Public Attributes

QueryTileHandler Struct Reference

List of all members.

Public Member Functions

 QueryTileHandler (osg::MatrixTransform *flag, const osgEarth::SpatialReference *srs)
void update (float x, float y, osgViewer::View *view)
bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)

Public Attributes

bool _mouseDown
osg::ref_ptr
< osg::MatrixTransform > 
_flag
osg::ref_ptr< const
osgEarth::SpatialReference
_srs

Detailed Description

Definition at line 92 of file osgearth_seamless.cpp.


Constructor & Destructor Documentation

QueryTileHandler::QueryTileHandler ( osg::MatrixTransform *  flag,
const osgEarth::SpatialReference srs 
) [inline]

Definition at line 94 of file osgearth_seamless.cpp.

        : _mouseDown(false), _flag(flag), _srs(srs) { }

Member Function Documentation

bool QueryTileHandler::handle ( const osgGA::GUIEventAdapter &  ea,
osgGA::GUIActionAdapter &  aa 
) [inline]

Definition at line 142 of file osgearth_seamless.cpp.

    {
        if ( ea.getEventType() == osgGA::GUIEventAdapter::MOVE )
        {
            osgViewer::View* view = static_cast<osgViewer::View*>(aa.asView());
            update( ea.getX(), ea.getY(), view );
        }

        return false;
    }
void QueryTileHandler::update ( float  x,
float  y,
osgViewer::View *  view 
) [inline]

Definition at line 98 of file osgearth_seamless.cpp.

    {
        using namespace osg;
        using namespace osgUtil;
        using namespace osgEarth;
        LineSegmentIntersector::Intersections results;
        TileKey key(TileKey::INVALID);
        if ( view->computeIntersections( x, y, results, 0x01 ) )
        {
            // find the first hit under the mouse:
            LineSegmentIntersector::Intersection first
                = *(results.begin());
            for (NodePath::const_reverse_iterator itr = first.nodePath.rbegin(),
                     end = first.nodePath.rend();
                 itr != end;
                 ++itr)
            {
                const PagedLOD* plod = dynamic_cast<const PagedLOD*>(*itr);
                if (!plod)
                    continue;
                const seamless::PatchInfo* popt
                    = dynamic_cast<const seamless::PatchInfo*>(
                        plod->getDatabaseOptions());
                if (!popt)
                    continue;
                key = popt->getTileKey();
                break;
            }

            if (!key.valid())
            {
                OE_WARN << "Couldn't get tile key.\n";
                return;
            }
            osg::Vec3d point = first.getWorldIntersectPoint();
            
            // transform it to map coordinates:
            Matrixd coordFrame;
            _srs->getEllipsoid()->computeLocalToWorldTransformFromXYZ(
                point.x(), point.y(), point.z(), coordFrame);
            updateFlag(_flag.get(), coordFrame, key);
        }
    }

Here is the call graph for this function:


Member Data Documentation

osg::ref_ptr<osg::MatrixTransform> QueryTileHandler::_flag

Definition at line 154 of file osgearth_seamless.cpp.

Definition at line 153 of file osgearth_seamless.cpp.

Definition at line 155 of file osgearth_seamless.cpp.


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