|
本帖最后由 就是那个胖子 于 2013-12-11 08:41 编辑
从网上找的,可以实现,代码如下:
//显示鼠标所在位置处经纬度坐标及高程值
void CCustomOSGWnd::ShowLocation(osgViewer::Viewer* pViewer,osgEarth::MapNode* pMapNode)
{
//鼠标位置信息显示
osgEarth::Util::Formatter* formatter = new osgEarth::Util:atLongFormatter();
osgEarth::Util::LabelControl* readout = new osgEarth::Util::LabelControl();
osgEarth::Util::ControlCanvas::get( pViewer, true )->addControl( readout );
readout->setFontSize(25.0);//设置字体大小
osgEarth::Util::MouseCoordsTool* tool = new osgEarth::Util::MouseCoordsTool( pMapNode );
tool->addCallback( new osgEarth::Util::MouseCoordsLabelCallback(readout, formatter) );
pViewer->addEventHandler( tool );
// add the state manipulator
pViewer->addEventHandler( new osgGA::StateSetManipulator(pViewer->getCamera()->getOrCreateStateSet()) );
// add the thread model handler
pViewer->addEventHandler(new osgViewer::ThreadingHandler);
// add the window size toggle handler
pViewer->addEventHandler(new osgViewer::WindowSizeHandler);
// add the stats handler
pViewer->addEventHandler(new osgViewer::StatsHandler);
// add the record camera path handler
pViewer->addEventHandler(new osgViewer::RecordCameraPathHandler);
// add the LOD Scale handler
pViewer->addEventHandler(new osgViewer::LODScaleHandler);
// add the screen capture handler
pViewer->addEventHandler(new osgViewer::ScreenCaptureHandler);
}
显示鼠标处位置经纬度及高程值
没添加高程数据,所以高程现在不正确,想请假下,怎么设置坐标在窗口显示的位置,函数里默认是0,0,看起来被挡住了,不知道怎么设置,求大神指点,谢谢 |
|