本文整理汇总了C++中osgga::GUIEventAdapter::getButtonMask方法的典型用法代码示例。如果您正苦于以下问题:C++ GUIEventAdapter::getButtonMask方法的具体用法?C++ GUIEventAdapter::getButtonMask怎么用?C++ GUIEventAdapter::getButtonMask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osgga::GUIEventAdapter
的用法示例。
在下文中一共展示了GUIEventAdapter::getButtonMask方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle
bool TimerHandler::handle( const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter& aa )
{
switch ( ea.getEventType())
{
case osgGA::GUIEventAdapter::FRAME:
//std::cout << "MouseButton mask: " << ea.getButtonMask() << std::endl;
if(ea.getButtonMask() == 0)
Constants::getInstance()->mouseDown = false;
else if (ea.getButtonMask() & 2)
Constants::getInstance()->mouseDown = true;
float x = ea.getX();
float y = ea.getY();
//std::cout << "X: " << x << std::endl;
//std::cout << "Y: " << y << std::endl;
if(Constants::getInstance()->mouseDown == false && Constants::getInstance()->disableMouse == false && ScriptRunner::getInstance()->isRunning == false) gameRender->updateDirection(x, y);
gameRender->updateGamePlay();
_count++;
break;
}
return false;
}
示例2:
bool Vwr::CameraManipulator::handlePush(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us)
{
if (ea.getButtonMask() == GUIEventAdapter::MIDDLE_MOUSE_BUTTON)
{
if (_distance != 0)
{
lastDistance = _distance;
osg::Vec3d eye, cameraCenter, up;
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>( &us );
viewer->getCamera()->getViewMatrixAsLookAt(eye, cameraCenter, up);
_center = eye;
_distance = 0;
}
else
{
_distance = lastDistance;
}
return true;
}
else
{
flushMouseEventStack();
addMouseEvent(ea);
if (calcMovement()) us.requestRedraw();
us.requestContinuousUpdate(false);
_thrown = false;
return true;
}
}
示例3:
bool Vwr::CameraManipulator::handleRelease(const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter& us) {
if (ea.getButtonMask() == 0) {
double timeSinceLastRecordEvent = _ga_t0.valid() ? (ea.getTime()
- _ga_t0->getTime()) : DBL_MAX;
if (timeSinceLastRecordEvent > 0.02)
flushMouseEventStack();
if (isMouseMoving()) {
if (calcMovement()) {
us.requestRedraw();
us.requestContinuousUpdate(true);
_thrown = _allowThrow;
}
} else {
flushMouseEventStack();
addMouseEvent(ea);
if (calcMovement())
us.requestRedraw();
us.requestContinuousUpdate(false);
_thrown = false;
}
} else {
flushMouseEventStack();
addMouseEvent(ea);
if (calcMovement())
us.requestRedraw();
us.requestContinuousUpdate(false);
_thrown = false;
}
return true;
}
示例4: handle
bool TranslatePlaneDragger::handle(const PointerInfo& pointer, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
// Check if the dragger node is in the nodepath.
if (!pointer.contains(this)) return false;
if ((ea.getButtonMask() & osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON) &&
ea.getEventType() == osgGA::GUIEventAdapter::PUSH)
_usingTranslate1DDragger = true;
bool handled = false;
if (_usingTranslate1DDragger)
{
if (_translate1DDragger->handle(pointer, ea, aa))
handled = true;
}
else
{
if (_translate2DDragger->handle(pointer, ea, aa))
handled = true;
}
if (ea.getEventType() == osgGA::GUIEventAdapter::RELEASE)
_usingTranslate1DDragger = false;
return handled;
}
示例5: 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"
}
示例6: handleMouseRelease
bool OrbitCameraManipulator::handleMouseRelease( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
if( !view ) return false;
if( ea.getButtonMask() == 0 )
{
double timeSinceLastRecordEvent = _ga_t0.valid() ? (ea.getTime() - _ga_t0->getTime()) : DBL_MAX;
if( timeSinceLastRecordEvent > 0.02 )
{
flushMouseEventStack();
}
if( isMouseMoving() )
{
if( performMovement( ea, aa ) && _allowThrow )
{
aa.requestRedraw();
aa.requestContinuousUpdate( true );
_thrown = true;
// TODO: fade out throw animation
}
return true;
}
}
if( !m_pointer_push_drag )
{
// select object
bool intersection_geometry_found = intersectSceneSelect( ea, view );
if( !intersection_geometry_found )
{
// click to background -> unselect all
if( m_system != nullptr )
{
m_system->clearSelection();
}
}
}
m_pointer_push_drag = false;
flushMouseEventStack();
addMouseEvent( ea );
if( performMovement( ea, aa ) )
{
aa.requestRedraw();
}
aa.requestContinuousUpdate( false );
_thrown = false;
return true;
}
示例7: handle
bool NavigationControl::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, ControlContext& cx )
{
switch ( ea.getEventType() )
{
case osgGA::GUIEventAdapter::PUSH:
_mouse_down_event = &ea;
break;
case osgGA::GUIEventAdapter::FRAME:
if ( _mouse_down_event )
{
_mouse_down_event = &ea;
}
break;
case osgGA::GUIEventAdapter::RELEASE:
for ( ControlEventHandlerList::const_iterator i = _eventHandlers.begin(); i != _eventHandlers.end(); ++i )
{
NavigationControlHandler* handler = dynamic_cast<NavigationControlHandler*>( i->get() );
if ( handler )
{
handler->onClick( this, ea.getButtonMask(), ea, aa );
}
}
_mouse_down_event = NULL;
break;
default:
/* ignore */
;
}
if ( _mouse_down_event )
{
//OE_NOTICE << "NavigationControl::handle getEventType " << ea.getEventType() << std::endl;
for ( ControlEventHandlerList::const_iterator i = _eventHandlers.begin(); i != _eventHandlers.end(); ++i )
{
NavigationControlHandler* handler = dynamic_cast<NavigationControlHandler*>( i->get() );
if ( handler )
{
handler->onMouseDown( this, ea.getButtonMask() );
}
}
}
return Control::handle( ea, aa, cx );
}
示例8: 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;
}
示例9: handle
bool PickHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::PUSH):
{
if (ea.getModKeyMask() == 0)
return false;
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
if (view == NULL)
return false;
osgUtil::LineSegmentIntersector::Intersection intersection;
osg::NodePath node_path;
Renderable* renderable = NULL;
if (ea.getButtonMask() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
renderable = computeIntersection<Renderable>(view, ea, intersection, node_path);
else if (ea.getButtonMask() == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON)
renderable = computePointIntersection<Renderable>(view, ea, intersection, node_path);
else
return false;
if (renderable == NULL)
return false;
renderable->pickEvent(ea.getModKeyMask(), intersection.getWorldIntersectPoint());
return true;
}
break;
default:
return false;
}
return false;
}
示例10: write
void write(const osgGA::GUIEventAdapter& event)
{
writeUInt(event.getEventType());
writeUInt(event.getKey());
writeUInt(event.getButton());
writeInt(event.getWindowX());
writeInt(event.getWindowY());
writeUInt(event.getWindowWidth());
writeUInt(event.getWindowHeight());
writeFloat(event.getXmin());
writeFloat(event.getYmin());
writeFloat(event.getXmax());
writeFloat(event.getYmax());
writeFloat(event.getX());
writeFloat(event.getY());
writeUInt(event.getButtonMask());
writeUInt(event.getModKeyMask());
writeDouble(event.getTime());
}
示例11: handlePush
bool PickHandler::handlePush( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
if (ea.getButtonMask() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
{
leftButtonPressed = true;
origin_mX = ea.getX();
origin_mY = ea.getY();
origin_mX_normalized = ea.getXnormalized();
origin_mY_normalized = ea.getYnormalized();
if (pickMode != PickMode::NONE && !isShiftPressed && !isCtrlPressed)
{
unselectPickedNodes();
unselectPickedEdges();
}
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>( &aa );
if (!viewer)
return false;
if (pickMode == PickMode::MULTI)
{
isDrawingSelectionQuad = true;
drawSelectionQuad(origin_mX, origin_mY, viewer);
}
else
{
return pick(ea.getXnormalized() - 0.00005f, ea.getYnormalized() - 0.00005f, ea.getXnormalized() + 0.00005f, ea.getYnormalized() + 0.00005f, viewer );
}
}
_mX = ea.getX();
_mY = ea.getY();
return false;
}
示例12: handleMousePush
// mouse button has been pushed down
bool OrbitCameraManipulator::handleMousePush( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
if( !view )
{
return false;
}
m_pointer_push_drag = false;
flushMouseEventStack();
addMouseEvent( ea );
m_ga_pointer_push = &ea;
intersectSceneRotateCenter( ea, view );
int buttonMask = ea.getButtonMask();
if( buttonMask == osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON || buttonMask == (osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON | osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON) )
{
m_pan_point.set( m_pointer_intersection );
}
if( buttonMask == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON )
{
osg::Vec3d distance_intersect_eye( m_pointer_intersection - m_eye );
//double distance_eye_intersection = distance_intersect_eye.length();
// rotate the intersection cone into mouse ray direction
if( m_intersect_hit_geometry )
{
}
}
aa.requestRedraw();
aa.requestContinuousUpdate( false );
_thrown = false;
return false;
}
示例13: handle
bool TabPlaneDragger::handle(const PointerInfo& pointer, const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
if (ea.getButtonMask() & osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON) return false;
// Check if the dragger node is in the nodepath.
if (!pointer.contains(this)) return false;
// Since the translate plane and the handleNode lie on the same plane the hit could've been on either one. But we
// need to handle the scaling draggers before the translation. Check if the node path has the scaling nodes else
// check for the scaling nodes in next hit.
if (_cornerScaleDragger->handle(pointer, ea, aa))
return true;
if (_horzEdgeScaleDragger->handle(pointer, ea, aa))
return true;
if (_vertEdgeScaleDragger->handle(pointer, ea, aa))
return true;
PointerInfo nextPointer(pointer);
nextPointer.next();
while (!nextPointer.completed())
{
if (_cornerScaleDragger->handle(nextPointer, ea, aa))
return true;
if (_horzEdgeScaleDragger->handle(nextPointer, ea, aa))
return true;
if (_vertEdgeScaleDragger->handle(nextPointer, ea, aa))
return true;
nextPointer.next();
}
if (_translateDragger->handle(pointer, ea, aa))
return true;
return false;
}
示例14: assignEventToButtons
//==============================================================================
static void assignEventToButtons(
MouseButtonEvent (&mLastButtonEvent)[NUM_MOUSE_BUTTONS],
const osgGA::GUIEventAdapter& ea)
{
MouseButtonEvent event = BUTTON_NOTHING;
if(ea.getEventType() == osgGA::GUIEventAdapter::PUSH)
event = BUTTON_PUSH;
else if(ea.getEventType() == osgGA::GUIEventAdapter::DRAG)
event = BUTTON_DRAG;
else if(ea.getEventType() == osgGA::GUIEventAdapter::RELEASE)
event = BUTTON_RELEASE;
if(BUTTON_RELEASE == event)
{
if( (ea.getButtonMask() & osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON) == 0
&& wasActive(mLastButtonEvent[LEFT_MOUSE]) )
mLastButtonEvent[LEFT_MOUSE] = event;
if( (ea.getButtonMask() & osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON) == 0
&& wasActive(mLastButtonEvent[RIGHT_MOUSE]) )
mLastButtonEvent[RIGHT_MOUSE] = event;
if( (ea.getButtonMask() & osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON) == 0
&& wasActive(mLastButtonEvent[MIDDLE_MOUSE]) )
mLastButtonEvent[MIDDLE_MOUSE] = event;
}
else
{
if(ea.getButtonMask() & osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
mLastButtonEvent[LEFT_MOUSE] = event;
if(ea.getButtonMask() & osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON)
mLastButtonEvent[RIGHT_MOUSE] = event;
if(ea.getButtonMask() & osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON)
mLastButtonEvent[MIDDLE_MOUSE] = event;
}
}
示例15: 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;
}
}