本文整理汇总了C++中osgga::GUIEventAdapter::getKey方法的典型用法代码示例。如果您正苦于以下问题:C++ GUIEventAdapter::getKey方法的具体用法?C++ GUIEventAdapter::getKey怎么用?C++ GUIEventAdapter::getKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osgga::GUIEventAdapter
的用法示例。
在下文中一共展示了GUIEventAdapter::getKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle
bool TechniqueEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Right ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Right)
{
_ops_index++;
if (_ops_index>=_ops_nb) _ops_index=0;
_logicOp->setOpcode(_operations[_ops_index]);
std::cout<<"Operation name = "<<_ops_name[_ops_index]<<std::endl;
return true;
}
else if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Left ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Left)
{
_ops_index--;
if (_ops_index<0) _ops_index=_ops_nb-1;
_logicOp->setOpcode(_operations[_ops_index]);
std::cout<<"Operation name = "<<_ops_name[_ops_index]<<std::endl;
return true;
}
return false;
}
default:
return false;
}
}
示例2: 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;
}
示例3: handle
bool ShowEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& /*aa*/, osg::Object* object, osg::NodeVisitor* /*nv*/)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYUP):
{
osg::notify(osg::INFO)<<"ShowEventHandler KEYUP "<<(int)ea.getKey()<<std::endl;
if (ea.getKey()>=osgGA::GUIEventAdapter::KEY_F1 &&
ea.getKey()<=osgGA::GUIEventAdapter::KEY_F8)
{
unsigned int child = ea.getKey()-osgGA::GUIEventAdapter::KEY_F1;
osg::notify(osg::INFO)<<" Select "<<child<<std::endl;
osg::Switch* showSwitch = dynamic_cast<osg::Switch*>(object);
if (showSwitch)
{
if (child<showSwitch->getNumChildren())
{
osg::notify(osg::INFO)<<" Switched "<<child<<std::endl;
showSwitch->setSingleChildOn(child);
return true;
}
}
}
break;
}
default:
break;
}
return false;
}
示例4: handle
bool HumanController::handle(const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter& aa)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
osg::Vec3 delta = _left^_up;
delta.normalize();
delta *= _velocity;
if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Up) {
_eye += delta;
}
if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Down) {
_eye -= delta;
}
if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Left) {
_eye += _left*_velocity;
}
if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Right) {
_eye -= _left*_velocity;
}
return true;
}
return false;
}
示例5: handle
bool TechniqueEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&, osg::Object*, osg::NodeVisitor*)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()=='n' ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_Right ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Right)
{
_ForestTechniqueManager->advanceToNextTechnique(1);
return true;
}
else if (ea.getKey()=='p' ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_Left ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Left)
{
_ForestTechniqueManager->advanceToNextTechnique(-1);
return true;
}
return false;
}
default:
return false;
}
}
示例6: handle
bool KeyboardEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey() == osgGA::GUIEventAdapter::KEY_F1) {
m_spring_node->setEnable(!m_spring_node->getEnable());
std::string str = m_spring_node->getEnable() ? "Enabled" : "Disabled";
osg::notify(osg::WARN) << str << " rendering of spring" << std::endl;
return true;
}
if (ea.getKey() == osgGA::GUIEventAdapter::KEY_F2) {
osgHaptics::SpringForceOperator *spring = m_spring_node->getForceOperator();
if (ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_SHIFT)
spring->setStiffness(spring->getStiffness()*0.9);
else
spring->setStiffness(spring->getStiffness()*1.1);
osg::notify(osg::WARN) << "Stiffness : " << spring->getStiffness() << std::endl;
return true;
}
return false;
}
default:
return false;
}
return false;
}
示例7: handle
virtual bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *o, osg::NodeVisitor *)
{
osgGA::GUIEventAdapter::EventType etype = ea.getEventType();
CeguiDrawable* myDrawable = static_cast<CeguiDrawable*>(o);
if (etype & (osgGA::GUIEventAdapter::RELEASE | osgGA::GUIEventAdapter::PUSH | osgGA::GUIEventAdapter::MOVE | osgGA::GUIEventAdapter::DRAG | osgGA::GUIEventAdapter::KEYDOWN | osgGA::GUIEventAdapter::KEYUP))
{
if (etype == osgGA::GUIEventAdapter::KEYDOWN && ea.getKey() == osgGA::GUIEventAdapter::KEY_F7)
{
myDrawable->addEvent(ea);
return true;
}
if (!m_guiHandlesEvents && etype == osgGA::GUIEventAdapter::KEYDOWN && ea.getKey() == osgGA::GUIEventAdapter::KEY_Tab)
{
using namespace CEGUI;
m_guiHandlesEvents = true;
GUIContext & gui = System::getSingleton().getDefaultGUIContext();
gui.getMouseCursor().show();
m_guiApp->hudGotFocus();
return true;
}
if (!m_guiHandlesEvents)
return false;
// HACK: don't send events directly to CEGUI, instead wait until the required OpenGL context is active
// as CEGUI will probably try to change OpenGL objects/state, which will SILENTLY fail in case of the
// wrong or no active OpenGL context(thanks to gDEBugger I've actually seen this happen).
// which means, that we should do the injection in draw phase...
myDrawable->addEvent(ea);
return true;
}
return false;
}
示例8: handle
virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) {
static float scale = 1.0f;
if(
ea.getEventType() != osgGA::GUIEventAdapter::KEYDOWN ||
(
ea.getKey() != '=' &&
ea.getKey() != '-'
)
) return false;
osg::MatrixTransform* matrix = getMatrix(aa);
if(!matrix) return false;
osg::StateSet* state = matrix->getStateSet();
osg::Uniform* aMin = state->getUniform("AlphaMin");
osg::Uniform* aMax = state->getUniform("AlphaMax");
if(ea.getKey() == '=') scale += SCALE_STEP;
else if(ea.getKey() == '-') scale -= SCALE_STEP;
// OSG_NOTICE << "New Scale: " << scale << std::endl;
aMin->set(std::max(0.0f, 0.5f - 0.07f / (scale / 2.0f)));
aMax->set(std::min(0.5f + 0.07f / (scale / 2.0f), 1.0f));
matrix->setMatrix(osg::Matrix::scale(scale, scale, 1.0f));
// OSG_NOTICE << "AlphaMin: " << std::max(0.0f, 0.5f - 0.07f / scale) << std::endl;
// OSG_NOTICE << "AlphaMax: " << std::min(0.5f + 0.07f / scale, 1.0f) << std::endl;
return true;
}
示例9: handle
/** Handle keyboard event. */
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&) {
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Right ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Right)
{
global_date += (1.0 / 24) / 4;
force_update_of_sky_dome = true;
return true;
}
else if (ea.getKey()==osgGA::GUIEventAdapter::KEY_Left ||
ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Left)
{
global_date -= (1.0 / 24) / 4;
force_update_of_sky_dome = true;
return true;
}
return false;
}
default:
return false;
}
}
示例10: handle
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& /*aa*/)
{
if (!_layer) return false;
float scale = 1.2;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey() == 'q')
{
_layer->transform(0.0, scale);
return true;
}
else if (ea.getKey() == 'a')
{
_layer->transform(0.0, 1.0f/scale);
return true;
}
break;
}
default:
break;
}
return false;
}
示例11: 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;
}
示例12: handle
virtual bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
int x = ea.getX(), y = ea.getY(), width = ea.getWindowWidth(), height = ea.getWindowHeight();
if ( ea.getMouseYOrientation()==osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS )
y = ea.getWindowHeight() - y;
if ( !CEGUI::System::getSingletonPtr() )
return false;
CEGUI::GUIContext& context = CEGUI::System::getSingleton().getDefaultGUIContext();
switch ( ea.getEventType() )
{
case osgGA::GUIEventAdapter::KEYDOWN:
context.injectKeyDown(key_conv(ea.getKey()));
context.injectChar(char_conv(ea.getKey()));
// return key_conv(ea.getKey()) != CEGUI::Key::Unknown;
break;
case osgGA::GUIEventAdapter::KEYUP:
context.injectKeyUp(key_conv(ea.getKey()));
// return key_conv(ea.getKey()) != CEGUI::Key::Unknown;
break;
case osgGA::GUIEventAdapter::PUSH:
context.injectMousePosition( x, y );
context.injectMouseButtonDown(convertMouseButton(ea.getButton()));
break;
case osgGA::GUIEventAdapter::RELEASE:
context.injectMousePosition(x, y);
context.injectMouseButtonUp(convertMouseButton(ea.getButton()));
break;
case osgGA::GUIEventAdapter::SCROLL:
if ( ea.getScrollingMotion()==osgGA::GUIEventAdapter::SCROLL_DOWN )
context.injectMouseWheelChange(-1);
else if ( ea.getScrollingMotion()==osgGA::GUIEventAdapter::SCROLL_UP )
context.injectMouseWheelChange(+1);
break;
case osgGA::GUIEventAdapter::DRAG:
case osgGA::GUIEventAdapter::MOVE:
context.injectMousePosition(x, y);
break;
case osgGA::GUIEventAdapter::RESIZE:
if ( _camera.valid() )
{
_camera->setProjectionMatrix( osg::Matrixd::ortho2D(0.0, width, 0.0, height) );
_camera->setViewport( 0.0, 0.0, width, height );
}
break;
default:
return false;
}
CEGUI::Window* rootWindow = context.getRootWindow();
if ( rootWindow )
{
CEGUI::Window* anyWindow = rootWindow->getChildAtPosition( CEGUI::Vector2f(x, y) );
if ( anyWindow ) return true;
}
return false;
}
示例13: handle
bool QOsgEventHandler::handle(
const osgGA::GUIEventAdapter &ea
, osgGA::GUIActionAdapter &)
{
if(ea.getEventType() == osgGA::GUIEventAdapter::FRAME
|| ea.getEventType() == osgGA::GUIEventAdapter::MOVE)
return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if(ea.getKey() == '-'
|| ea.getKey() == '+')
{
const float f = 1.00f
+ (ea.getKey() == '+' ? +0.004f : -0.004f);
if(m_fov * f >= 1.f && m_fov * f <= 179.f)
m_fov *= f;
emit fovChanged(m_fov);
}
}
break;
case(osgGA::GUIEventAdapter::SCROLL):
{
const float f = 1.00f
+ (ea.getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_DOWN ? -0.08f : +0.08f);
if(m_fov * f >= 1.f && m_fov * f <= 179.f)
m_fov *= f;
emit fovChanged(m_fov);
return true;
}
break;
case(osgGA::GUIEventAdapter::RELEASE):
if(ea.getButton() == osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON
&& (ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_CTRL) != 0)
{
m_fov = m_fovBackup;
emit fovChanged(m_fov);
return true;
}
break;
default:
break;
};
return false;
}
示例14: handle
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>( &aa );
if ( !view ) return false;
switch( ea.getEventType() )
{
case osgGA::GUIEventAdapter::FRAME:
if ( view->getDatabasePager() )
{
// Wait until all paged nodes are processed
if ( view->getDatabasePager()->getRequestsInProgress() )
break;
}
if ( _printer.valid() )
{
_printer->frame( view->getFrameStamp(), view->getSceneData() );
if ( _started && _printer->done() )
{
osg::Switch* root = dynamic_cast<osg::Switch*>( view->getSceneData() );
if ( root )
{
// Assume child 0 is the loaded model and 1 is the poster camera
// Switch them in time to prevent dual traversals of subgraph
root->setValue( 0, true );
root->setValue( 1, false );
}
_started = false;
}
}
break;
case osgGA::GUIEventAdapter::KEYDOWN:
if ( ea.getKey()=='p' || ea.getKey()=='P' )
{
if ( _printer.valid() )
{
osg::Switch* root = dynamic_cast<osg::Switch*>( view->getSceneData() );
if ( root )
{
// Assume child 0 is the loaded model and 1 is the poster camera
root->setValue( 0, false );
root->setValue( 1, true );
}
_printer->init( view->getCamera() );
_started = true;
}
return true;
}
break;
default:
break;
}
return false;
}
示例15: handle
bool myKeyBoardEventHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
int pressedKeyId = ea.getKey();
if( pressedKeyId > 0 )
{
if( ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN )
cout << "get button : " << ea.getKey() << endl;
}
return true;
}