本文整理汇总了C++中osgga::GUIEventAdapter类的典型用法代码示例。如果您正苦于以下问题:C++ GUIEventAdapter类的具体用法?C++ GUIEventAdapter怎么用?C++ GUIEventAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GUIEventAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor*)
{
if (ea.getEventType() == ea.KEYDOWN && ea.getKey() == _c)
{
osg::Vec3d world;
_mapNode->getTerrain()->getWorldCoordsUnderMouse(aa.asView(), ea.getX(), ea.getY(), world);
GeoPoint coords;
coords.fromWorld(s_activeMap->getSRS(), world);
osg::ref_ptr<ElevationEnvelope> env = s_activeMap->getElevationPool()->createEnvelope(s_activeMap->getSRS(), 23u);
float ep_elev = env->getElevation(coords.x(), coords.y());
OE_NOTICE << "Elevations under mouse. EP=" << ep_elev << "\n";
}
return false;
}
示例2: handle
bool QueryCoordinatesHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if ( ea.getEventType() == osgGA::GUIEventAdapter::MOVE )
{
osgViewer::View* view = static_cast<osgViewer::View*>( aa.asView() );
osg::Vec3d coords = getCoords( ea.getX(), ea.getY(), view, false );
mGlobe->showCurrentCoordinates( coords.x(), coords.y() );
}
if ( ea.getEventType() == osgGA::GUIEventAdapter::PUSH
&& ea.getButtonMask() == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON )
{
osgViewer::View* view = static_cast<osgViewer::View*>( aa.asView() );
osg::Vec3d coords = getCoords( ea.getX(), ea.getY(), view, false );
OE_NOTICE << "SelectedCoordinates set to:\nLon: " << coords.x() << " Lat: " << coords.y()
<< " Ele: " << coords.z() << std::endl;
mGlobe->setSelectedCoordinates( coords );
if ( ea.getModKeyMask() == osgGA::GUIEventAdapter::MODKEY_CTRL )
//ctrl + rightclick pops up a QMessageBox
{
mGlobe->showSelectedCoordinates();
}
}
return false;
}
示例3: handle
bool KeyboardHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
if(ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN)
{
if(ea.getKey() == 'w')
{
std::cout << "W pressed" << std::endl;
return false;
}
}
return false;
}
示例4: handleEvent
bool MYGUIManager::handleEvent(const osgGA::GUIEventAdapter& ea, bool async) const {
if (async || !_platform || !_initialized) {
const_cast<MYGUIManager*>(this)->pushEvent(&ea);
return false;
}
int x = ea.getX(), y = ea.getY(), key = ea.getKey();
static int z = 0;
if (ea.getMouseYOrientation() == osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS)
y = ea.getWindowHeight() - y;
x = int(floor(float(x) / _uiScale + 0.5f));
y = int(floor(float(y) / _uiScale + 0.5f));
switch (ea.getEventType())
{
case osgGA::GUIEventAdapter::PUSH:
return MyGUI::InputManager::getInstance().injectMousePress(x, y, convertMouseButton(ea.getButton()));
break;
case osgGA::GUIEventAdapter::RELEASE:
return MyGUI::InputManager::getInstance().injectMouseRelease(x, y, convertMouseButton(ea.getButton()));
break;
case osgGA::GUIEventAdapter::SCROLL:
switch (ea.getScrollingMotion()) {
case osgGA::GUIEventAdapter::SCROLL_UP:
z++; break;
case osgGA::GUIEventAdapter::SCROLL_DOWN:
z--; break;
}
// fall through
case osgGA::GUIEventAdapter::DRAG:
case osgGA::GUIEventAdapter::MOVE:
return MyGUI::InputManager::getInstance().injectMouseMove(x, y, z);
break;
case osgGA::GUIEventAdapter::KEYDOWN:
if (key<127)
return MyGUI::InputManager::getInstance().injectKeyPress(convertKeyCode(key), (char)key);
else
return MyGUI::InputManager::getInstance().injectKeyPress(convertKeyCode(key));
break;
case osgGA::GUIEventAdapter::KEYUP:
return MyGUI::InputManager::getInstance().injectKeyRelease(convertKeyCode(key));
break;
case osgGA::GUIEventAdapter::RESIZE:
_platform->getRenderManagerPtr()->setViewSize(
int(floor(float(ea.getWindowWidth()) / _uiScale + 0.5f)),
int(floor(float(ea.getWindowHeight()) / _uiScale + 0.5f)));
break;
default:
break;
}
return false;
}
示例5: handle
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if ( ea.getEventType() == osgGA::GUIEventAdapter::MOVE )
{
osgViewer::View* view = static_cast<osgViewer::View*>( aa.asView() );
osgUtil::LineSegmentIntersector::Intersections hits;
if ( view->computeIntersections( ea.getX(), ea.getY(), hits ) )
{
osgEarth::GeoPoint isectPoint;
isectPoint.fromWorld( mGlobe->mapNode()->getMapSRS()->getGeodeticSRS(), hits.begin()->getWorldIntersectPoint() );
mGlobe->showCurrentCoordinates( isectPoint );
}
}
return false;
}
示例6: handle
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& /*aa*/)
{
if (!_gt) return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey() == 'g')
{
osg::notify(osg::NOTICE)<<"Gaussian"<<std::endl;
_gt->setFilterMatrixAs(osgTerrain::GeometryTechnique::GAUSSIAN);
return true;
}
else if (ea.getKey() == 's')
{
osg::notify(osg::NOTICE)<<"Smooth"<<std::endl;
_gt->setFilterMatrixAs(osgTerrain::GeometryTechnique::SMOOTH);
return true;
}
else if (ea.getKey() == 'S')
{
osg::notify(osg::NOTICE)<<"Sharpen"<<std::endl;
_gt->setFilterMatrixAs(osgTerrain::GeometryTechnique::SHARPEN);
return true;
}
else if (ea.getKey() == '+')
{
_gt->setFilterWidth(_gt->getFilterWidth()*1.1);
osg::notify(osg::NOTICE)<<"Filter width = "<<_gt->getFilterWidth()<<std::endl;
return true;
}
else if (ea.getKey() == '-')
{
_gt->setFilterWidth(_gt->getFilterWidth()/1.1);
osg::notify(osg::NOTICE)<<"Filter width = "<<_gt->getFilterWidth()<<std::endl;
return true;
}
else if (ea.getKey() == '>')
{
_gt->setFilterBias(_gt->getFilterBias()+0.1);
osg::notify(osg::NOTICE)<<"Filter bias = "<<_gt->getFilterBias()<<std::endl;
return true;
}
else if (ea.getKey() == '<')
{
_gt->setFilterBias(_gt->getFilterBias()-0.1);
osg::notify(osg::NOTICE)<<"Filter bias = "<<_gt->getFilterBias()<<std::endl;
return true;
}
break;
}
default:
break;
}
return false;
}
示例7: handle
bool KeyboardEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
switch(ea.getKey())
{
case '1':
placeStreams(GRID_LAYOUT);
return false;
break;
case '2':
placeStreams(ROW_LAYOUT);
return false;
break;
case '3':
colorStreams(MEMORY_COLORING);
return false;
break;
case '4':
colorStreams(EXECUTION_FREQ_COLORING);
return false;
break;
case 'h':
hideByImage(HIDE);
return false;
break;
case 'u':
hideByImage(HIDE_ALL_ELSE);
return false;
break;
case 'n':
updateTimeline(1);
return false;
break;
case 'p':
updateTimeline(-1);
return false;
break;
default:
return false;
}
}
default:
return false;
}
}
示例8: handleMouseWheel
bool OrbitCameraManipulator::handleMouseWheel( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
osgGA::GUIEventAdapter::ScrollingMotion sm = ea.getScrollingMotion();
// TODO: increase scroll factor when eye is far away from model bounding sphere
double scroll_distance_factor = ( m_eye - m_rotate_center ).length()*0.1;
switch( sm )
{
// mouse scroll up event
case osgGA::GUIEventAdapter::SCROLL_UP:
{
// perform zoom
zoomCamera( m_wheel_zoom_factor*scroll_distance_factor );
aa.requestRedraw();
aa.requestContinuousUpdate( isAnimating() || _thrown );
return true;
}
// mouse scroll down event
case osgGA::GUIEventAdapter::SCROLL_DOWN:
{
// perform zoom
zoomCamera( -m_wheel_zoom_factor*scroll_distance_factor );
aa.requestRedraw();
aa.requestContinuousUpdate( isAnimating() || _thrown );
return true;
}
// unhandled mouse scrolling motion
default:
return false;
}
}
示例9: handle
bool WeaponHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
{
/* osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
if (!view) return false;
osgViewer::ViewerBase* viewer = view->getViewerBase();
*/
// if (ea.getHandled()) return false;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::RELEASE):
//case(osgGA::GUIEventAdapter::DOUBLECLICK):
{
//shoot
// if(ea.getButtonMask() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
{
//if(osgGA::GUIEventAdapter::RELEASE == ea.getEventType())
GameManager::instance()->getWeaponManager()->Tire();
}
break;
}
default:
break;
}
return false;
}
示例10: home
void UFOManipulator::home(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us)
{
home(ea.getTime());
us.requestRedraw();
us.requestContinuousUpdate(false);
}
示例11: handle
bool CScreenCapture::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
osgViewer::ViewerBase* viewer = dynamic_cast<osgViewer::View*>(&aa)->getViewerBase();
if (!viewer) return false;
switch (ea.getEventType())
{
case (osgGA::GUIEventAdapter::FRAME) :
{
// Booleans aren't the best way of doing this, but I want to do
// the actual adding here because I don't want to require
// startCapture() take a viewer as argument, which could not be
// the right one.
if (_startCapture)
{
// Start capturing with the currently set number of frames.
// If set to -1 it will capture continuously, if set to >0
// it will capture that number of frames.
_startCapture = false;
addCallbackToViewer(*viewer);
}
else if (_stopCapture)
{
_stopCapture = false;
removeCallbackFromViewer(*viewer);
}
break;
}
default:
break;
}
return false;
}
示例12: handle
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& )
{
if( ea.getEventType() != osgGA::GUIEventAdapter::KEYDOWN )
return false;
switch( ea.getKey() )
{
case 'x':
_gl2Scene->reloadShaderSource();
return true;
case 'y':
_gl2Scene->toggleShaderEnable();
return true;
}
return false;
}
示例13: keyUp
bool OSGCameraManipulator::keyUp(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter &aa) {
int bRes = true;
int nResKey = ea.getKey();
if ((nResKey == osgGA::GUIEventAdapter::KEY_Control_L) ||
(nResKey == osgGA::GUIEventAdapter::KEY_Control_R)) {
m_bCtrl = false;
}
if ((nResKey == osgGA::GUIEventAdapter::KEY_Shift_L) ||
(nResKey == osgGA::GUIEventAdapter::KEY_Shift_R)) {
m_bShift = false;
m_dbDefaultMoveSpeed = 1;
}
if ((nResKey == osgGA::GUIEventAdapter::KEY_Up) ||
(nResKey == osgGA::GUIEventAdapter::KEY_Down)) {
m_dbForwardFactor = 0.0;
m_dbLateralRotationRate = 0.0;
m_dbDefaultMoveSpeed = 1;
}
if ((nResKey == osgGA::GUIEventAdapter::KEY_Left) ||
(nResKey == osgGA::GUIEventAdapter::KEY_Right)) {
m_dbDirectionRotationRate = 0.0;
m_dbPitchOffsetRate = 0.0;
m_dbDefaultMoveSpeed = 1;
}
return(bRes);
}
示例14: handleMouseWheel
bool GISManipulator::handleMouseWheel( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us )
{
osgGA::GUIEventAdapter::ScrollingMotion sm = ea.getScrollingMotion();
osg::Vec3d eye, center, up;
getTransformation( eye, center, up );
double altitude = eye[2];
if ( sm == osgGA::GUIEventAdapter::SCROLL_UP ) {
altitude /= 1.41;
}
else if ( sm == osgGA::GUIEventAdapter::SCROLL_DOWN ) {
altitude *= 1.41;
}
else {
return false;
}
eye[2] = altitude;
center[2] = eye[2] - 1.0;
setTransformation( eye, center, up );
us.requestRedraw();
us.requestContinuousUpdate( isAnimating() );
return true;
}
示例15: pick_measure
void PickHandler::pick_measure(osgViewer::Viewer* viewer, const osgGA::GUIEventAdapter& ea)
{
osgUtil::LineSegmentIntersector::Intersections intersections;
if (viewer->computeIntersections(ea.getX(), ea.getY(), intersections)){
// use the nearest intersection
const osgUtil::LineSegmentIntersector::Intersection& intersection = *(intersections.begin());
(*measure_vertices)[1].set( intersection.getWorldIntersectPoint());
// cout << (*measure_vertices)[1] <<endl;
}
}