当前位置: 首页>>代码示例>>C++>>正文


C++ GUIEventAdapter::getButton方法代码示例

本文整理汇总了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;
}
开发者ID:Brucezhou1979,项目名称:osgearth,代码行数:35,代码来源:FeatureEditing.cpp

示例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;
    }
开发者ID:wangfeilong321,项目名称:test_osg,代码行数:59,代码来源:cegui_main.cpp

示例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;
	}
}
开发者ID:leloulight,项目名称:lbanet,代码行数:56,代码来源:OSGHandler.cpp

示例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;

}
开发者ID:nmattia,项目名称:Minotaur,代码行数:28,代码来源:PickHandler.cpp

示例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;
      }
开发者ID:airwzz999,项目名称:osgearth-for-android,代码行数:30,代码来源:osgearth_terrainprofile.cpp

示例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);
}
开发者ID:spencerg,项目名称:osgearth,代码行数:26,代码来源:AreaSelectControl.cpp

示例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;
    }
开发者ID:wow2006,项目名称:OSG_Book,代码行数:30,代码来源:myProject01.cpp

示例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;
}
开发者ID:3dcl,项目名称:osghimmel,代码行数:58,代码来源:qosgeventhandler.cpp

示例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;
    }
开发者ID:philipdumont,项目名称:osgearth,代码行数:10,代码来源:osgearth_createtile.cpp

示例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;
}
开发者ID:Noesis,项目名称:OSGBindings,代码行数:11,代码来源:NoesisWrapper.cpp

示例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;
}
开发者ID:WriterOfAlicrow,项目名称:SOTE,代码行数:14,代码来源:ThirdPersonCameraManipulator.cpp

示例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
}
开发者ID:ClementCvl,项目名称:CppMasterRace_50yIUT,代码行数:36,代码来源:main.cpp

示例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;
}
开发者ID:ChrisWC,项目名称:OpenSceneGraph,代码行数:18,代码来源:OscSendingDevice.cpp

示例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;
}
开发者ID:joevandyk,项目名称:osg,代码行数:18,代码来源:ViewerEventHandlers.cpp

示例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;
}
开发者ID:dilawar,项目名称:moogli,代码行数:43,代码来源:GeometrySelector.cpp


注:本文中的osgga::GUIEventAdapter::getButton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。