|
目的:我想在现有程序基础上通过添加一个菜单项,实现一个鼠标点击查询功能,对话框显示查询信息,我通过addEventHandler来实现
出现问题:这个功能不是常用功能,我在不用的时候,应该如何取消?或者如何与已有的鼠标事件兼容?比方我原来可以通过鼠标旋转物体,用了addEventHandler后就只能实现查询了~~
谢谢@@
程序:
菜单函数
if (flag == m_coordsFlagAction->isChecked())
{
m_coordsFlagAction->setChecked(true);
return true;
}
else
{
m_coordsFlagAction->setChecked(false);
MapNode *mapNode = MapNode::findMapNode(m_centralOSGWidget->getSceneData());
m_centralOSGWidget->addEventHandler( new MouseCoordsHandler(mouseCoords, mapNode->getMap()));
}
MouseCoordsHandler class:
struct MouseCoordsHandler : public osgGA::GUIEventHandler
{
MouseCoordsHandler( LabelControl* label, const osgEarth::Map* map )
: _label( label ),
_map( map),
_elevationQuery(map)
{
_elevationQuery.setMaxTilesToCache(10);
}
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
osgViewer::View* view = static_cast<osgViewer::View*>(aa.asView());
switch(ea.getEventType())
{
case osgGA::GUIEventAdapter:USH:
QMessageBox::information(0,QString("Attribute"),QString("test dialog"));
break;
case osgGA::GUIEventAdapter::RELEASE:
break;
case osgGA::GUIEventAdapter::MOVE:
break;
default:
break;
}
return true;
}
osg::ref_ptr< LabelControl > _label;
const Map* _map;
osgEarth::ElevationQuery _elevationQuery;
};
} |
|