本文整理汇总了C++中osgga::GUIEventAdapter::getHandled方法的典型用法代码示例。如果您正苦于以下问题:C++ GUIEventAdapter::getHandled方法的具体用法?C++ GUIEventAdapter::getHandled怎么用?C++ GUIEventAdapter::getHandled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osgga::GUIEventAdapter
的用法示例。
在下文中一共展示了GUIEventAdapter::getHandled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle
bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
{
if (ea.getHandled())
return false;
switch (ea.getEventType())
{
case (osgGA::GUIEventAdapter::KEYUP):
{
if (ea.getKey() == osgGA::GUIEventAdapter::KEY_Escape)
{
osgViewer::View *view = dynamic_cast<osgViewer::View*>(&aa);
if (view)
view->getViewerBase()->setDone(true);
return true;
}
}
default:
return false;
}
return false;
}
示例2: handle
bool LODScaleHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
osg::Camera* camera = view ? view->getCamera() : 0;
if (!camera) return false;
if (ea.getHandled()) return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYUP):
{
if (ea.getKey() == _keyEventIncreaseLODScale)
{
camera->setLODScale(camera->getLODScale()*1.1);
osg::notify(osg::NOTICE)<<"LODScale = "<<camera->getLODScale()<<std::endl;
return true;
}
else if (ea.getKey() == _keyEventDecreaseLODScale)
{
camera->setLODScale(camera->getLODScale()/1.1);
osg::notify(osg::NOTICE)<<"LODScale = "<<camera->getLODScale()<<std::endl;
return true;
}
break;
}
default:
break;
}
return false;
}
示例3: handle
bool KeyboardMouseManipulator::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) {
bool bRes = false;
int nResEvent = ea.getEventType();
if (nResEvent == GUIEventAdapter::FRAME) {
bRes = OrbitManipulator::handleFrame(ea, aa);
}
if (nResEvent == GUIEventAdapter::RELEASE) {
bRes = OrbitManipulator::handleMouseRelease(ea, aa);
}
if (nResEvent == GUIEventAdapter::PUSH) {
bRes = OrbitManipulator::handleMousePush(ea, aa);
}
if (nResEvent == GUIEventAdapter::KEYDOWN) {
bRes = VR::KeyboardMouseManipulator::keyDown(ea, aa);
}
if (nResEvent == GUIEventAdapter::KEYUP) {
bRes = VR::KeyboardMouseManipulator::keyUp(ea, aa);
}
if(ea.getHandled())
return false;
if (nResEvent == GUIEventAdapter::DRAG) {
bRes = OrbitManipulator::handleMouseDrag(ea, aa);
}
return(bRes);
}
示例4: handle
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& /*aa*/, osg::Object* object, osg::NodeVisitor* /*nv*/)
{
osg::Switch* sw = dynamic_cast<osg::Switch*>(object);
if (!sw) return false;
if (ea.getHandled()) return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()=='n')
{
++_childNum;
if (_childNum >= sw->getNumChildren()) _childNum = 0;
sw->setSingleChildOn(_childNum);
return true;
}
break;
}
default:
break;
}
return false;
}
示例5: handle
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
if (ea.getHandled()) return false;
switch (ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYUP) :
{
if (ea.getKey() == 'o')
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
osg::Node* node = view ? view->getSceneData() : 0;
if (node)
{
osgDB::writeNodeFile(*node, "hud.osgt");
osgDB::writeNodeFile(*node, "hud.osgb");
}
return true;
}
if (ea.getKey() == _key)
{
osg::notify(osg::NOTICE) << "event handler" << std::endl;
_snapImage->_snapImage = true;
return true;
}
break;
}
default:
break;
}
return false;
}
示例6: handle
bool StatsHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
{
if (ea.getHandled()) return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()== _key)
{
osgViewer::View* myview = dynamic_cast<osgViewer::View*>(&aa);
if (!myview) return false;
osgViewer::ViewerBase* viewer = myview->getViewerBase();
toggle(viewer);
aa.requestRedraw();
return true;
}
break;
}
case osgGA::GUIEventAdapter::RESIZE:
{
setWindowSize(ea.getWindowWidth(), ea.getWindowHeight());
break;
}
default:
break;
}
return false;
}
示例7: handle
bool UFOManipulator::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter &aa)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::FRAME):
_frame(ea,aa);
return false;
default:
break;
}
if (ea.getHandled()) return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYUP):
_keyUp( ea, aa );
return false;
break;
case(osgGA::GUIEventAdapter::KEYDOWN):
_keyDown(ea, aa);
return false;
break;
case(osgGA::GUIEventAdapter::FRAME):
_frame(ea,aa);
return false;
break;
default:
return false;
}
}
示例8: handle
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(&aa);
if (!viewer) return false;
if (ea.getHandled()) return false;
if(ea.getEventType()==GUIEventAdapter::KEYDOWN)
{
switch( ea.getKey() )
{
case osgGA::GUIEventAdapter::KEY_Right:
// Toggle next switch
nextSwitch();
return true;
break;
case osgGA::GUIEventAdapter::KEY_Up:
// Increase animation speed
multiplyAnimation(2);
return true;
break;
case osgGA::GUIEventAdapter::KEY_Down:
// Decrease animation speed
multiplyAnimation(0.5);
return true;
break;
}
}
return false;
}
示例9: handle
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if ( ea.getHandled() ) return false;
if ( ea.getEventType() == osgGA::GUIEventAdapter::PUSH &&
ea.getButtonMask() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON &&
(ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_CTRL) != 0 &&
terrain_srs.valid() &&
layer.valid() )
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>( &aa );
if ( !view ) return false;
osgUtil::LineSegmentIntersector::Intersections hits;
if ( view->computeIntersections( ea.getX(), ea.getY(), hits ) )
{
osgUtil::LineSegmentIntersector::Intersection first = *hits.begin();
osg::Vec3d hit = first.getWorldIntersectPoint() - first.getWorldIntersectNormal()*0.2;
osgGIS::GeoPoint world( hit, terrain_srs.get() );
osgGIS::GeoPoint result = terrain_srs->getGeographicSRS()->transform( world );
osgGIS::FeatureCursor cursor = layer->getCursor( result );
highlight( cursor );
std::stringstream buf;
buf << "World: " << world.toString() << std::endl
<< "Geo: " << result.toString() << std::endl
<< "SRS: " << terrain_srs->getName() << std::endl;
int line_count = 2;
for( cursor.reset(); cursor.hasNext(); )
{
osgGIS::Feature* f = cursor.next();
osgGIS::AttributeList attrs = f->getAttributes();
for( osgGIS::AttributeList::const_iterator i = attrs.begin(); i != attrs.end(); i++ )
{
std::string key = i->getKey();
if ( key.length() > 0 )
{
buf << key << " : " << i->asString() << std::endl;
line_count++;
}
}
break;
}
if ( buf.str().length() == 0 )
{
buf << "Control-Left-Click to query";
line_count++;
}
hud_text->setText( buf.str() );
hud_text->setPosition( osg::Vec3( 10, line_count*TEXT_SIZE*1.1f, 0 ) );
hud_text->dirtyDisplayList();
}
}
return false; // never "handled"
}
示例10: handle
bool Dragger::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
if (ea.getHandled()) return false;
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
if (!view) return false;
if (ea.getEventType() == osgGA::GUIEventAdapter::PUSH)
{
Picker picker( view, this );
Picker::Hits hits;
if ( picker.pick( ea.getX(), ea.getY(), hits ) )
{
_dragging = true;
aa.requestRedraw();
return true;
}
}
else if (ea.getEventType() == osgGA::GUIEventAdapter::RELEASE)
{
_dragging = false;
aa.requestRedraw();
}
else if (ea.getEventType() == osgGA::GUIEventAdapter::DRAG)
{
if (_dragging)
{
osg::Vec3d world;
if ( _mapNode->getTerrain()->getWorldCoordsUnderMouse(view, ea.getX(), ea.getY(), world) )
{
GeoPoint mapPoint;
_mapNode->getMap()->worldPointToMapPoint(world, mapPoint);
setPosition( mapPoint );
aa.requestRedraw();
return true;
}
}
}
else if (ea.getEventType() == osgGA::GUIEventAdapter::MOVE)
{
Picker picker( view, this );
Picker::Hits hits;
if ( picker.pick( ea.getX(), ea.getY(), hits ) )
{
setHover( true );
}
else
{
setHover( false );
}
aa.requestRedraw();
}
return false;
}
示例11: handle
bool CameraManipulator::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::FRAME):
{
return handleFrame(ea, us);
}
default:
break;
}
if (ea.getHandled()) return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::PUSH):
{
return handlePush(ea, us);
}
case(osgGA::GUIEventAdapter::RELEASE):
{
return handleRelease(ea, us);
}
case(osgGA::GUIEventAdapter::DRAG):
case(osgGA::GUIEventAdapter::SCROLL):
{
return handleScroll(ea, us);
}
case(osgGA::GUIEventAdapter::MOVE):
{
return false;
}
case(osgGA::GUIEventAdapter::KEYDOWN):
{
return handleKeyDown(ea, us);
}
case(osgGA::GUIEventAdapter::KEYUP):
{
return handleKeyUp( ea, us );
}
case(osgGA::GUIEventAdapter::FRAME):
{
if (_thrown)
{
if (calcMovement()) us.requestRedraw();
}
return false;
}
default:
return false;
}
}
示例12: handle
virtual bool handle(const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter& /*aa*/,
Object*, NodeVisitor* /*nv*/)
{
if (ea.getHandled()) return false;
ref_ptr<Depth> depth;
if (!_depth.lock(depth)) return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYUP):
{
if (ea.getKey() == 'i')
{
_appState->invertRange = !_appState->invertRange;
if (!_appState->invertRange)
{
_appState->camera->setClearDepth(1.0f);
depth->setFunction(Depth::LESS);
depth->setRange(0.0f, 1.0f);
_appState->textInverted->setNodeMask(0u);
}
else
{
_appState->camera->setClearDepth(0.0f);
depth->setFunction(Depth::GEQUAL);
depth->setRange(1.0f, 0.0f);
_appState->textInverted->setNodeMask(~0u);
}
return true;
}
else if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Up ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Up)
{
_appState->zNear *= 2.0;
_appState->updateNear();
return true;
}
else if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Down ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Down)
{
_appState->zNear *= .5;
_appState->updateNear();
return true;
}
break;
}
default:
break;
}
return false;
}
示例13: handle
bool InteractiveImageHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv)
{
if (ea.getHandled()) return false;
if (!_image) return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::MOVE):
case(osgGA::GUIEventAdapter::DRAG):
case(osgGA::GUIEventAdapter::PUSH):
case(osgGA::GUIEventAdapter::RELEASE):
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
int x,y;
if (mousePosition(view, nv, ea, x, y))
{
return _image->sendPointerEvent(x, y, ea.getButtonMask());
}
break;
}
case(osgGA::GUIEventAdapter::KEYDOWN):
case(osgGA::GUIEventAdapter::KEYUP):
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
int x,y;
bool sendKeyEvent = mousePosition(view, nv, ea, x, y);
if (sendKeyEvent)
{
return _image->sendKeyEvent(ea.getKey(), ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN);
}
break;
}
case (osgGA::GUIEventAdapter::RESIZE):
{
if (_fullscreen && _camera.valid())
{
_camera->setViewport(0, 0, ea.getWindowWidth(), ea.getWindowHeight());
resize(ea.getWindowWidth(), ea.getWindowHeight());
return true;
}
break;
}
default:
return false;
}
return false;
}
示例14: handle
bool PickEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv)
{
if (ea.getHandled()) return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::MOVE):
case(osgGA::GUIEventAdapter::PUSH):
case(osgGA::GUIEventAdapter::RELEASE):
{
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(&aa);
osgUtil::LineSegmentIntersector::Intersections intersections;
if (viewer->computeIntersections(ea.getX(),ea.getY(), nv->getNodePath(), intersections))
{
for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr=intersections.begin();
hitr!=intersections.end();
++hitr)
{
if (ea.getEventType()==osgGA::GUIEventAdapter::MOVE)
{
OSG_INFO<<"Tooltip..."<<std::endl;
}
else if (ea.getEventType()==osgGA::GUIEventAdapter::RELEASE)
{
doOperation();
return true;
}
}
}
break;
}
case(osgGA::GUIEventAdapter::KEYDOWN):
{
//OSG_NOTICE<<"PickEventHandler KEYDOWN "<<(char)ea.getKey()<<std::endl;
//if (object) OSG_NOTICE<<" "<<object->className()<<std::endl;
break;
}
default:
break;
}
return false;
}
示例15: handle
bool KeyEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& /*aa*/, osg::Object*, osg::NodeVisitor* /*nv*/)
{
if (ea.getHandled()) return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()==_key)
{
doOperation();
return true;
}
break;
}
default:
break;
}
return false;
}