本文整理汇总了C++中osgga::GUIEventAdapter::getButton方法的典型用法代码示例。如果您正苦于以下问题:C++ GUIEventAdapter::getButton方法的具体用法?C++ GUIEventAdapter::getButton怎么用?C++ GUIEventAdapter::getButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osgga::GUIEventAdapter
的用法示例。
在下文中一共展示了GUIEventAdapter::getButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addPoint
bool
AddPointHandler::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
osgViewer::View* view = static_cast<osgViewer::View*>(aa.asView());
if ( ea.getEventType() == osgGA::GUIEventAdapter::PUSH )
{
if (ea.getButton() == _mouseButton)
{
_mouseDown = true;
_firstMove = true;
return addPoint( ea.getX(), ea.getY(), view );
}
}
else if (ea.getEventType() == osgGA::GUIEventAdapter::RELEASE)
{
if (ea.getButton() == _mouseButton)
{
_mouseDown = false;
}
}
else if (ea.getEventType() == osgGA::GUIEventAdapter::MOVE || ea.getEventType() == osgGA::GUIEventAdapter::DRAG)
{
if (_mouseDown)
{
if (!_firstMove)
{
return addPoint( ea.getX(), ea.getY(), view );
}
_firstMove = false;
}
return true;
}
return false;
}
示例2: 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;
}
示例3: handle
/***********************************************************
handle inputs
***********************************************************/
bool UserInputsHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::PUSH):
{
if(ea.getButton() == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON)
{
_mouse_Y = ea.getY();
_right_button_pressed = true;
return true;
}
}
case(osgGA::GUIEventAdapter::RELEASE):
{
if(ea.getButton() == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON)
{
_right_button_pressed = false;
return true;
}
}
// update Zenit on mouse move with right button pressed
case(osgGA::GUIEventAdapter::DRAG):
{
if(_right_button_pressed)
{
OsgHandler::getInstance()->DeltaUpdateCameraZenit(_mouse_Y-ea.getY());
_mouse_Y = ea.getY();
return true;
}
}
// zoom on mouse scroll
case(osgGA::GUIEventAdapter::SCROLL):
{
if(ea.getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_DOWN)
OsgHandler::getInstance()->DeltaUpdateCameraDistance(5);
if(ea.getScrollingMotion() == osgGA::GUIEventAdapter::SCROLL_UP)
OsgHandler::getInstance()->DeltaUpdateCameraDistance(-5);
return true;
}
default:
return false;
}
}
示例4: handle
bool PickHandler::handle(const osgGA::GUIEventAdapter & ea,
osgGA::GUIActionAdapter & aa) {
if (!_f)
return false;
if (ea.getEventType() != osgGA::GUIEventAdapter::RELEASE
|| ea.getButton() != osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
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());
iv.setTraversalMask(~0x1);
viewer->getCamera()->accept(iv);
if (intersector->containsIntersections()) {
const osgUtil::LineSegmentIntersector::Intersection &result =
*(intersector->getIntersections().begin());
_f(result);
}
}
return false;
}
示例5: handle
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if (ea.getEventType() == ea.PUSH && ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
{
osg::Vec3d world;
if ( _mapNode->getTerrain()->getWorldCoordsUnderMouse( aa.asView(), ea.getX(), ea.getY(), world ))
{
GeoPoint mapPoint;
_mapNode->getMap()->worldPointToMapPoint( world, mapPoint );
if (!_startValid)
{
_startValid = true;
_start = mapPoint.vec3d();
if (_featureNode.valid())
{
_root->removeChild( _featureNode.get() );
_featureNode = 0;
}
}
else
{
_end = mapPoint.vec3d();
compute();
_startValid = false;
}
}
}
return false;
}
示例6: handle
bool WaitingForSecondSelection::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
bool handled = false;
osgUtil::LineSegmentIntersector::Intersections results;
osgViewer::View* view = static_cast<osgViewer::View*>(aa.asView());
if ((ea.getEventType() == ea.DRAG) && view->computeIntersections(ea.getX(), ea.getY(), results, 0x01))
{
// find the first hit under the mouse:
osgUtil::LineSegmentIntersector::Intersection first = *(results.begin());
osg::Vec3d point = first.getWorldIntersectPoint();
// transform it to map coordinates:
osg::Vec3d newPoint;
m_control->getMapNode()->getMap()->worldPointToMapPoint(point, newPoint);
m_control->setSecondPoint(newPoint);
m_control->drawRectangle();
}
else if ((ea.getEventType() == ea.DOUBLECLICK) && (ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON))
{
m_control->currentState() = new Complete(m_control);
handled = true;
}
return (handled);
}
示例7: handle
virtual bool 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() );
iv.setTraversalMask( ~0x1 );
viewer->getCamera()->accept( iv );
if ( intersector->containsIntersections() )
{
const osgUtil::LineSegmentIntersector::Intersection& result =
*(intersector->getIntersections().begin());
osg::BoundingBox bb = result.drawable->getBound();
osg::Vec3 worldCenter = bb.center() * osg::computeLocalToWorld(result.nodePath);
_selectionBox->setMatrix(
osg::Matrix::scale(bb.xMax()-bb.xMin(), bb.yMax()-bb.yMin(), bb.zMax()-bb.zMin()) *
osg::Matrix::translate(worldCenter) );
}
}
return false;
}
示例8: 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;
}
示例9: handle
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if (ea.getEventType() == osgGA::GUIEventAdapter::PUSH && ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
{
osgViewer::View* view = static_cast<osgViewer::View*>(aa.asView());
update( ea.getX(), ea.getY(), view );
}
return false;
}
示例10: convertMouseButton
MouseButton NoesisEventCallback::convertMouseButton( const osgGA::GUIEventAdapter& ea )
{
switch ( ea.getButton() )
{
case osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON: return MouseButton_Left;
case osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON: return MouseButton_Middle;
case osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON: return MouseButton_Right;
default: break;
}
return MouseButton_Left;
}
示例11: handleMouseRelease
bool ThirdPersonCameraManipulator::handleMouseRelease( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if (ea.getButton() == GUIEventAdapter::LEFT_MOUSE_BUTTON)
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
osgUtil::LineSegmentIntersector::Intersections intersections;
if (view->computeIntersections(ea, intersections ))
{
getActivePlayer()->setPosition(intersections.begin()->getWorldIntersectPoint());
}
}
centerMousePointer( ea, aa );
return false;
}
示例12: handle
bool GestionEvenements::handle( const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter& aa)
{
switch(ea.getEventType()){
case osgGA::GUIEventAdapter::KEYDOWN :
switch(ea.getKey()){
case 'a':
viewer.setCameraManipulator(trackCone.get());
break;
case 'z':
viewer.setCameraManipulator(trackBoite.get());
break;
case 'e':
viewer.setCameraManipulator(trackSphere.get());
break;
}
break;
case osgGA::GUIEventAdapter::PUSH :{
int x = ea.getX();
int y = ea.getY();
if( ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
std::cout << "bouton gauche" << std::endl;
if (ea.getButton() == osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON)
std::cout << "bouton milieu" << std::endl;
if (ea.getButton() == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON)
std::cout << "bouton droit" << std::endl;
break;
}
case osgGA::GUIEventAdapter::DOUBLECLICK :
break;
}
return false; // pour que l'événement soit traité par d'autres gestionnaires
}
示例13: getButtonNum
int OscSendingDevice::getButtonNum(const osgGA::GUIEventAdapter& ea)
{
switch(ea.getButton())
{
case osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON:
return 1;
break;
case osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON:
return 2;
break;
case osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON:
return 3;
break;
default:
return -1;
}
return -1;
}
示例14: handle
bool MouseHandler::handle(
const osgGA::GUIEventAdapter& gea,
osgGA::GUIActionAdapter& gaa,
osg::Object* obj,
osg::NodeVisitor* nv
) {
osgGA::GUIEventAdapter::EventType ev = gea.getEventType();
MouseAction ma = _isMouseEvent(ev);
if(ma) {
// If we're scrolling, we need to inform the WindowManager of that.
_wm->setScrollingMotion(gea.getScrollingMotion());
return (this->*ma)(gea.getX(), gea.getY(), gea.getButton());
}
return false;
}
示例15: getName
bool
GeometrySelector::handle( const osgGA::GUIEventAdapter& ea
, osgGA::GUIActionAdapter& aa
)
{
// RECORD_INFO("reaching here");
osgViewer::View* viewer = dynamic_cast<osgViewer::View*>(&aa);
if ( !viewer )
{
return false;
}
bool drag_event_occurred = ea.getEventType() & osgGA::GUIEventAdapter::DRAG;
bool push_event_occurred = ea.getEventType() & osgGA::GUIEventAdapter::PUSH;
bool release_event_occurred = ea.getEventType() & osgGA::GUIEventAdapter::RELEASE;
bool left_mouse_button_pressed = ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON;
bool ctrl_key_pressed = ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_CTRL;
if(left_mouse_button_pressed && push_event_occurred)
{
Geometry * geometry = _get_intersection(ea,viewer);
bool blank_click = geometry == nullptr;
if(blank_click)
{
id = "";
selected = false;
RECORD_INFO("not selected");
}
else
{
id = geometry -> getName();
selected = true;
RECORD_INFO(std::string("Selected") + geometry -> getName() );
}
}
else
{
selected = false;
}
return false;
}