|
osgEarth 2.1.1
|
Collaboration diagram for MouseCoordsHandler:Public Member Functions | |
| MouseCoordsHandler (LabelControl *label, osgEarth::MapNode *mapNode) | |
| bool | handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa) |
Public Attributes | |
| osg::ref_ptr< LabelControl > | _label |
| MapNode * | _mapNode |
| osg::NodePath | _mapNodePath |
Definition at line 98 of file osgearth_viewer.cpp.
| MouseCoordsHandler::MouseCoordsHandler | ( | LabelControl * | label, |
| osgEarth::MapNode * | mapNode | ||
| ) | [inline] |
Definition at line 100 of file osgearth_viewer.cpp.
: _label( label ), _mapNode( mapNode ) { _mapNodePath.push_back( mapNode->getTerrainEngine() ); }
Here is the call graph for this function:| bool MouseCoordsHandler::handle | ( | const osgGA::GUIEventAdapter & | ea, |
| osgGA::GUIActionAdapter & | aa | ||
| ) | [inline] |
Definition at line 107 of file osgearth_viewer.cpp.
{
osgViewer::View* view = static_cast<osgViewer::View*>(aa.asView());
if (ea.getEventType() == ea.MOVE || ea.getEventType() == ea.DRAG)
{
osgUtil::LineSegmentIntersector::Intersections results;
if ( view->computeIntersections( ea.getX(), ea.getY(), _mapNodePath, results ) )
{
// find the first hit under the mouse:
osgUtil::LineSegmentIntersector::Intersection first = *(results.begin());
osg::Vec3d point = first.getWorldIntersectPoint();
osg::Vec3d lla;
// transform it to map coordinates:
_mapNode->getMap()->worldPointToMapPoint(point, lla);
std::stringstream ss;
if ( s_mgrs )
{
MGRSFormatter f( MGRSFormatter::PRECISION_1M );
ss << "MGRS: " << f.format(lla.y(), lla.x()) << " ";
}
// lat/long
{
LatLongFormatter::AngularFormat fFormat = s_dms?
LatLongFormatter::FORMAT_DEGREES_MINUTES_SECONDS :
LatLongFormatter::FORMAT_DECIMAL_DEGREES;
LatLongFormatter f( fFormat );
ss
<< "Lat: " << f.format( Angular(lla.y(),Units::DEGREES), 4 ) << " "
<< "Lon: " << f.format( Angular(lla.x(),Units::DEGREES), 5 );
}
_label->setText( ss.str() );
}
else
{
//Clear the text
_label->setText( "" );
}
}
return false;
}
Here is the call graph for this function:| osg::ref_ptr< LabelControl > MouseCoordsHandler::_label |
Definition at line 154 of file osgearth_viewer.cpp.
Definition at line 155 of file osgearth_viewer.cpp.
| osg::NodePath MouseCoordsHandler::_mapNodePath |
Definition at line 156 of file osgearth_viewer.cpp.
1.7.3