本文整理汇总了C++中osgga::GUIEventAdapter::getEventType方法的典型用法代码示例。如果您正苦于以下问题:C++ GUIEventAdapter::getEventType方法的具体用法?C++ GUIEventAdapter::getEventType怎么用?C++ GUIEventAdapter::getEventType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osgga::GUIEventAdapter
的用法示例。
在下文中一共展示了GUIEventAdapter::getEventType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle
//事件处理函数
bool CPickHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
{
switch(ea.getEventType())
{
//每一帧
case(osgGA::GUIEventAdapter::FRAME):
{
osg::ref_ptr<osgViewer::Viewer> viewer = dynamic_cast<osgViewer::Viewer*>(&aa);
//得到视图矩阵
viewer ->getCamera() ->getViewMatrixAsLookAt(position, center, up) ;
if (viewer)
{
//执行PICK动作
pick(viewer.get(),ea);
}
return false;
}
default:
return false;
}
}
示例2: handle
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor*)
{
osgViewer::Viewer* viewer=dynamic_cast<osgViewer::Viewer*>(&aa);
if (!viewer)
{
return false;
}
switch(ea.getEventType())
{
case osgGA::GUIEventAdapter::KEYDOWN:
/*if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Space)
{
int width=ea.getWindowWidth();
int height=ea.getWindowHeight();
viewer->requestWarpPointer(width*0.7,height*0.7);
}else*/
{
osg::Switch* root = dynamic_cast<osg::Switch*>(viewer->getSceneData());
if (!root)
{
return false;
}
if (ea.getKey()=='1')
{
root->setValue(0,true);
root->setValue(1,false);
}
else if (ea.getKey()=='2')
{
root->setValue(0,false);
root->setValue(1,true);
}
}
break;
default:
break;
}
return false;
}
示例3: handle
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& /*aa*/, osg::Object*, osg::NodeVisitor* /*nv*/)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey() == osgGA::GUIEventAdapter::KEY_Left)
loadSlide(_currentFile - 1);
else if (ea.getKey() == osgGA::GUIEventAdapter::KEY_Right)
loadSlide(_currentFile + 1);
else
return false;
return true;
}
break;
default:
break;
}
return false;
}
示例4: handle
bool handle( const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter& aa )
{
osgViewer::Viewer* viewer =
dynamic_cast<osgViewer::Viewer*>( &aa );
if (!viewer)
return false;
switch( ea.getEventType() )
{
case osgGA::GUIEventAdapter::PUSH:
case osgGA::GUIEventAdapter::MOVE:
{
// Record mouse location for the button press
// and move events.
_mX = ea.getX();
_mY = ea.getY();
return false;
}
case osgGA::GUIEventAdapter::RELEASE:
{
// If the mouse hasn't moved since the last
// button press or move event, perform a
// pick. (Otherwise, the trackball
// manipulator will handle it.)
if (_mX == ea.getX() && _mY == ea.getY())
{
if (pick( ea.getXnormalized(),
ea.getYnormalized(), viewer ))
return true;
}
return false;
}
default:
return false;
}
}
示例5: 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_NOTICE<<"LODScale = "<<camera->getLODScale()<<std::endl;
aa.requestRedraw();
return true;
}
else if (ea.getKey() == _keyEventDecreaseLODScale)
{
camera->setLODScale(camera->getLODScale()/1.1);
OSG_NOTICE<<"LODScale = "<<camera->getLODScale()<<std::endl;
aa.requestRedraw();
return true;
}
break;
}
default:
break;
}
return false;
}
示例6: handle
bool OsgKeyboardHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&)
{
bool result = false;
switch (ea.getEventType())
{
case (osgGA::GUIEventAdapter::KEYDOWN) :
{
// Note that we are setting the modifier mask here instead of the modifier itself
m_keyboardScaffold.lock()->updateDevice(ea.getUnmodifiedKey(), ea.getModKeyMask());
result = true;
break;
}
case (osgGA::GUIEventAdapter::KEYUP) :
{
m_keyboardScaffold.lock()->updateDevice(KeyCode::NONE, ModKeyMask::MODKEY_NONE);
result = true;
break;
}
default:
result = false;
break;
}
// We wan to to support some of the osg viewer keys, pass these through, we will still receive the event, but osg
// will also react here
int key = ea.getUnmodifiedKey();
if (key == 's' || key == 't' || key == 'v' || key == 'w')
{
// s: Stats Display
// t: texturing
// v: vsync
// w: wireframe
result = false;
}
return result;
}
示例7: handle
bool OSGCameraManipulator::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us) {
bool bRes = true;
int nResEvent = ea.getEventType();
//Orbit manipulator
if(nResEvent == GUIEventAdapter::EventType::DRAG ||
GUIEventAdapter::EventType::MOVE ||
GUIEventAdapter::EventType::PUSH ||
GUIEventAdapter::EventType::RELEASE ||
GUIEventAdapter::EventType::SCROLL) {
bRes = OrbitManipulator::handle(ea,us);
}
if(nResEvent == GUIEventAdapter::KEYDOWN) {
bRes = keyDown(ea, us);
}
else if(nResEvent == GUIEventAdapter::KEYUP) {
bRes = keyUp(ea, us);
}
return(bRes);
}
示例8: handle
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&)
{
if (ea.getHandled()) return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYUP):
{
if (ea.getKey() == _key)
{
osg::notify(osg::NOTICE)<<"event handler"<<std::endl;
_snapImage->_snapImage = true;
return true;
}
break;
}
default:
break;
}
return false;
}
示例9: handle
bool TimerHandler::handle( const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter& aa )
{
switch ( ea.getEventType())
{
case osgGA::GUIEventAdapter::FRAME:
float x = ea.getX();
float y = ea.getY();
std::cout << "X: " << x << std::endl;
std::cout << "Y: " << y << std::endl;
gameRender->updateDirection(x, y);
gameRender->updateGamePlay();
_count++;
break;
}
return false;
}
示例10: handle
bool EventHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa) {
bool suppressDefault = false;
osgGA::GUIEventAdapter::EventType t = ea.getEventType();
// keypress handlers (for convenience)
if (t == osgGA::GUIEventAdapter::KEYDOWN) {
pair<Scene::KeyCallbackMap::const_iterator, Scene::KeyCallbackMap::const_iterator> range =
scene.keyCallbacks.equal_range(ea.getKey());
for (Scene::KeyCallbackMap::const_iterator i = range.first; i != range.second; ++i)
suppressDefault |= i->second(ea);
}
// general handlers
pair<Scene::CallbackMap::const_iterator, Scene::CallbackMap::const_iterator> range =
scene.callbacks.equal_range(t);
for (Scene::CallbackMap::const_iterator i = range.first; i != range.second; ++i)
suppressDefault |= i->second(ea);
if (!suppressDefault)
return osgGA::TrackballManipulator::handle(ea, aa);
return false;
}
示例11: handle
bool MouseEventHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) {
if (ea.getEventType()!=osgGA::GUIEventAdapter::RELEASE ||
ea.getButton()!=osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON ||
!(ea.getModKeyMask()&osgGA::GUIEventAdapter::MODKEY_CTRL))
return false;
osgViewer::Viewer* viewer= dynamic_cast<osgViewer::Viewer*>(&aa);
if (viewer) {
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector=
new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(), ea.getY());
osgUtil::IntersectionVisitor iv(intersector.get());
// Sólo recorrer aquellos nodos con nodeMask=0x1
iv.setTraversalMask(~0x1);
viewer->getCamera()->accept(iv);
if (intersector->containsIntersections()) {
//osgUtil::LineSegmentIntersector::Intersection& elegido= *(intersector->getIntersections().begin());
//orbita= elegido.;
//std::cout<<"ola k ase\n";
// Hagamos lo que tengamos que hacer...
}
}
return false;
}
示例12: eventPick
//==============================================================================
void DefaultEventHandler::eventPick(const osgGA::GUIEventAdapter& ea)
{
MouseButtonEvent mbe;
switch(ea.getEventType())
{
case osgGA::GUIEventAdapter::PUSH:
mbe = BUTTON_PUSH;
break;
case osgGA::GUIEventAdapter::DRAG:
mbe = BUTTON_DRAG;
break;
case osgGA::GUIEventAdapter::RELEASE:
mbe = BUTTON_RELEASE;
break;
default:
return;
}
if( ( (ea.getButtonMask() & osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
&& !mSuppressButtonPicks[LEFT_MOUSE][mbe])
|| ( (ea.getButtonMask() & osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON)
&& !mSuppressButtonPicks[RIGHT_MOUSE][mbe])
|| ( (ea.getButtonMask() & osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON)
&& !mSuppressButtonPicks[MIDDLE_MOUSE][mbe]))
{
pick(mTempPicks, ea);
if(ea.getButtonMask() & osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
mButtonPicks[LEFT_MOUSE][mbe] = mTempPicks;
if(ea.getButtonMask() & osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON)
mButtonPicks[RIGHT_MOUSE][mbe] = mTempPicks;
if(ea.getButtonMask() & osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON)
mButtonPicks[MIDDLE_MOUSE][mbe] = mTempPicks;
}
}
示例13: handle
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()=='r')
{
_terrain->setSampleRatio(_terrain->getSampleRatio()*0.5);
osg::notify(osg::NOTICE)<<"Sample ratio "<<_terrain->getSampleRatio()<<std::endl;
return true;
}
else if (ea.getKey()=='R')
{
_terrain->setSampleRatio(_terrain->getSampleRatio()/0.5);
osg::notify(osg::NOTICE)<<"Sample ratio "<<_terrain->getSampleRatio()<<std::endl;
return true;
}
else if (ea.getKey()=='v')
{
_terrain->setVerticalScale(_terrain->getVerticalScale()*1.25);
osg::notify(osg::NOTICE)<<"Vertical scale "<<_terrain->getVerticalScale()<<std::endl;
return true;
}
else if (ea.getKey()=='V')
{
_terrain->setVerticalScale(_terrain->getVerticalScale()/1.25);
osg::notify(osg::NOTICE)<<"Vertical scale "<<_terrain->getVerticalScale()<<std::endl;
return true;
}
return false;
}
default:
return false;
}
}
示例14: handle
bool GameManagerKeyboardHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
{
std::string activeRenderingInstanceName = _gameManager->getActiveRenderingInstanceName();
// check if key is pressed or released
switch(ea.getEventType())
{
case osgGA::GUIEventAdapter::KEYDOWN:
// find out which key was pressed
switch(ea.getKey())
{
case K_EXIT:
if(activeRenderingInstanceName == "game")
_gameManager->selectRenderingInstance("road_select_menu");
else if(activeRenderingInstanceName == "road_select_menu")
_gameManager->selectRenderingInstance("main_menu");
else if(activeRenderingInstanceName == "main_menu")
exit(0);
break;
default:
return false;
}
break;
default:
return false;
}
return false;
}
示例15: handle
bool PointsEventHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter&)
{
switch (ea.getEventType())
{
case (osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey() == '+' || ea.getKey() == osgGA::GUIEventAdapter::KEY_KP_Add)
{
changePointSize(1.0f);
return true;
}
else if (ea.getKey() == '-' || ea.getKey() == osgGA::GUIEventAdapter::KEY_KP_Subtract)
{
changePointSize(-1.0f);
return true;
}
else if (ea.getKey() == '<')
{
changePointAttenuation(1.1f);
return true;
}
else if (ea.getKey() == '>')
{
changePointAttenuation(1.0f / 1.1f);
return true;
}
break;
}
default:
break;
}
return false;
}