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


C++ GUIActionAdapter::asView方法代码示例

本文整理汇总了C++中osgga::GUIActionAdapter::asView方法的典型用法代码示例。如果您正苦于以下问题:C++ GUIActionAdapter::asView方法的具体用法?C++ GUIActionAdapter::asView怎么用?C++ GUIActionAdapter::asView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在osgga::GUIActionAdapter的用法示例。


在下文中一共展示了GUIActionAdapter::asView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

bool
RTTPicker::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
    if ( ea.getEventType() == ea.FRAME )
    {
        osg::FrameStamp* fs = aa.asView() ? aa.asView()->getFrameStamp() : 0L;
        if ( fs )
        {
            runPicks( fs->getFrameNumber() );           
        }

        // if there are picks in the queue, need to continuing rendering:
        if ( !_picks.empty() )
        {
            aa.requestRedraw();
        }
    }

    else if ( _defaultCallback.valid() && _defaultCallback->accept(ea, aa) )
    {        
        pick( aa.asView(), ea.getX(), ea.getY(), _defaultCallback.get() );
        aa.requestRedraw();
    }

    return false;
}
开发者ID:Karamaz0V1,项目名称:osgearth,代码行数:26,代码来源:RTTPicker.cpp

示例2: switch

    bool WeaponHUD::WeaponSwitchHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) {
        switch (ea.getEventType()) {
        case osgGA::GUIEventAdapter::SCROLL:
        {
	  /*
	   * catches multiple activations of the weapon switching
	   * per frame because linux triggers keys twice
	   */
            if (_frameNumber == aa.asView()->getFrameStamp()->getFrameNumber()) {
                return false;
            }
            _frameNumber = aa.asView()->getFrameStamp()->getFrameNumber();
	    //Debug message
            OSG_ALWAYS << "SCROLL: " << aa.asView()->getFrameStamp()->getFrameNumber() << std::endl;
            osgGA::GUIEventAdapter::ScrollingMotion sm = ea.getScrollingMotion();
            switch (sm) {
            /*
	     * switches backwards through weapon list when
	     * the mouse wheel is scrolled down
	     */
            case osgGA::GUIEventAdapter::SCROLL_DOWN:
	    //Debug message
	      OSG_ALWAYS << "SCROLL DOWN" << std::endl;
		_switch->setValue(_curWeapon, false);
                _curWeapon--;
                /*
		 * if the first weapon is selected and another
		 * scroll backwards is triggered, the last weapon
		 * gets selected
		 */
		if (_curWeapon < 0)
                    _curWeapon = _switch->getNumChildren() - 1;
                _curWeapon = _curWeapon % _switch->getNumChildren();
                _switch->setValue(_curWeapon, true);
                return true;
	    /*
	     * switches forward through weapon list when
	     * the mouse wheel is scrolled up
	     */
	    case osgGA::GUIEventAdapter::SCROLL_UP:
	      //Debug message
                OSG_ALWAYS << "SCROLL UP" << std::endl;
                _switch->setValue(_curWeapon, false);
                _curWeapon++;
                _curWeapon = _curWeapon % _switch->getNumChildren();
                _switch->setValue(_curWeapon, true);
                return true;
            default:
                return false;
            }
        }
        default:
            return false;
        }
    }
开发者ID:goost,项目名称:BrainTrain,代码行数:55,代码来源:WeaponHUD.cpp

示例3: handle

    bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
    {
        if (ea.getEventType() == osgGA::GUIEventAdapter::MOVE &&
            aa.asView()->getFrameStamp()->getFrameNumber() % 10 == 0)
        {
            osgViewer::View* view = static_cast<osgViewer::View*>(aa.asView());
            update( ea.getX(), ea.getY(), view );
        }

        return false;
    }
开发者ID:Vantica,项目名称:osgearth,代码行数:11,代码来源:osgearth_elevation.cpp

示例4: 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

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

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

示例8: sqrt

void
AutoClipPlaneHandler::frame( osgGA::GUIActionAdapter& aa )
{
    osg::Camera* cam = aa.asView()->getCamera();

    if ( _rp < 0 )
    {
        osg::ref_ptr<MapNode> tempNode = osgEarth::findTopMostNodeOfType<MapNode>( cam );
        if ( tempNode.valid() && tempNode->getMap()->getProfile() )
        {
            _geocentric = tempNode->getMap()->isGeocentric();
            if ( _geocentric )
                _rp = tempNode->getMap()->getProfile()->getSRS()->getEllipsoid()->getRadiusPolar();
            else
                OE_INFO << "[AutoClipPlaneHandler] disabled for non-geocentric map" << std::endl;

            //_mapNode = tempNode.get();
        }
    }

    if ( _rp > 0 && _geocentric ) // _mapNode.valid() && _geocentric )
    {
        cam->setComputeNearFarMode( osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR );

        osg::Vec3d eye, center, up;
        cam->getViewMatrixAsLookAt( eye, center, up );

        double d = eye.length();

        if ( d < _rp )
            d = _rp;

        if ( d > _rp )
        {
            double fovy, ar, znear, zfar, finalZfar;
            cam->getProjectionMatrixAsPerspective( fovy, ar, znear, finalZfar );

            // far clip at the horizon:
            zfar = sqrt( d*d - _rp*_rp );

            if (_autoFarPlaneClipping)
            {
                finalZfar = zfar;
            }

            double nfr = _nfrAtRadius + _nfrAtDoubleRadius * ((d-_rp)/d);
            znear = osg::clampAbove( zfar * nfr, 1.0 );

            cam->setProjectionMatrixAsPerspective( fovy, ar, znear, finalZfar );

            //OE_NOTICE << fixed
            //    << "near=" << znear << ", far=" << zfar << std::endl;
        }
    }
}
开发者ID:dgraves,项目名称:osgearth,代码行数:55,代码来源:AutoClipPlaneHandler.cpp

示例9: iv

bool
MouseCoordsTool::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
    if (ea.getEventType() == ea.MOVE || ea.getEventType() == ea.DRAG)
    {
        osg::Vec3d world;
        if ( _mapNode->getTerrain()->getWorldCoordsUnderMouse(aa.asView(), ea.getX(), ea.getY(), world) )
        {
            GeoPoint map;
            map.fromWorld( _mapNode->getMapSRS(), world );

            for( Callbacks::iterator i = _callbacks.begin(); i != _callbacks.end(); ++i )
                i->get()->set( map, aa.asView(), _mapNode );
        }
        else
        {
            for( Callbacks::iterator i = _callbacks.begin(); i != _callbacks.end(); ++i )
                i->get()->reset( aa.asView(), _mapNode );
        }

#if 1 // testing AGL, Dist to Point
        osg::Vec3d eye, center, up;
        aa.asView()->getCamera()->getViewMatrixAsLookAt(eye, center, up);
        DPLineSegmentIntersector* lsi = new DPLineSegmentIntersector(eye, osg::Vec3d(0,0,0));
        osgUtil::IntersectionVisitor iv(lsi);
        lsi->setIntersectionLimit(lsi->LIMIT_NEAREST);
        //iv.setUserData( new Map() );
        _mapNode->accept(iv);

        if ( !lsi->getIntersections().empty() )
        {            
            double agl = (eye - lsi->getFirstIntersection().getWorldIntersectPoint()).length();
            double dtp = (eye - world).length();
            //OE_NOTICE << "AGL = " << agl << "m; DPT = " << dtp << "m" << std::endl;
            Registry::instance()->startActivity("AGL", Stringify() << agl << " m");
            Registry::instance()->startActivity("Range", Stringify() << dtp << " m");
        }
#endif
    }

    return false;
}
开发者ID:ldelgass,项目名称:osgearth,代码行数:42,代码来源:MouseCoordsTool.cpp

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

示例11:

bool
MouseCoordsTool::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
{
    if (ea.getEventType() == ea.MOVE || ea.getEventType() == ea.DRAG)
    {
        osg::Vec3d world;
        if ( _mapNode->getTerrain()->getWorldCoordsUnderMouse(aa.asView(), ea.getX(), ea.getY(), world) )
        {
            GeoPoint map;
            map.fromWorld( _mapNode->getMapSRS(), world );

            for( Callbacks::iterator i = _callbacks.begin(); i != _callbacks.end(); ++i )
                i->get()->set( map, aa.asView(), _mapNode );
        }
        else
        {
            for( Callbacks::iterator i = _callbacks.begin(); i != _callbacks.end(); ++i )
                i->get()->reset( aa.asView(), _mapNode );
        }
    }

    return false;
}
开发者ID:JohnDr,项目名称:osgearth,代码行数:23,代码来源:MouseCoordsTool.cpp

示例12: handleMouseRelease

bool SelectionManipulator::handleMouseRelease( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us )
{
	osgViewer::View* curView = (osgViewer::View*)us.asView();
	bool release = osgGA::StandardManipulator::handleMouseRelease(ea, us);
	if (m_edgeGroup != NULL)
	{
		m_edgeGroup->setNodeMask(m_orgEdgeState);
	}
	if(m_vertexGroup != NULL)
	{
		m_vertexGroup->setNodeMask(m_orgVertexState);
	}
	curView->requestRedraw();
	return release;
}
开发者ID:binhpt,项目名称:vltest,代码行数:15,代码来源:SelectionManipulator.cpp

示例13: 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;
 }
开发者ID:a11656358,项目名称:QGIS,代码行数:15,代码来源:globe_plugin.cpp

示例14: setCenterByMousePointer

bool TerrainZoomManipulator::setCenterByMousePointer( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us )
{
    osg::View* view = us.asView();
    if( !view )
        return false;

    osg::Camera *camera = view->getCamera();
    if( !camera )
        return false;

    // prepare variables
    float x = ( ea.getX() - ea.getXmin() ) / ( ea.getXmax() - ea.getXmin() );
    float y = ( ea.getY() - ea.getYmin() ) / ( ea.getYmax() - ea.getYmin() );

    osg::Matrix VPW = camera->getProjectionMatrix()
            * camera->getViewport()->computeWindowMatrix();

    osg::Matrix invVPW;
    bool success = invVPW.invert(VPW);

    osg::Vec3f nearPoint = osg::Vec3f(ea.getX(), ea.getY(), 0.f) * invVPW;
    osg::Vec3f farPoint = osg::Vec3f(ea.getX(), ea.getY(), 1.f) * invVPW;

    // scale
    float scale = 1.0f -_wheelZoomFactor;
    float distance = _distance * scale;

    float x_new = ((_distance - distance) * farPoint.x()) / _distance;
    float y_new = ((_distance - distance) * farPoint.y()) / _distance;


    switch( ea.getScrollingMotion() )
    {
        case osgGA::GUIEventAdapter::SCROLL_DOWN:
        {
            panModel(x_new, y_new, 0);
            return true;
        }
        default:
            return false;
    }    
}
开发者ID:arneboe,项目名称:gui-osgviz-osgviz,代码行数:42,代码来源:TerrainZoomManipulator.cpp

示例15: handle

 bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
 {
     if ( ea.getEventType() == ea.RELEASE )
     {
         IntersectionPicker picker(dynamic_cast<osgViewer::View*>(aa.asView()));
         IntersectionPicker::Hits hits;
         if(picker.pick(ea.getX(), ea.getY(), hits)) {
             std::set<ObjectID> oids;
             if (picker.getObjectIDs(hits, oids)) {
                 ObjectIndex* index = Registry::objectIndex();
                 ObjectID oid = *oids.begin();
                 osg::ref_ptr<FeatureIndex> fi = index->get<FeatureIndex>(oid);
                 if ( fi.valid() ) {
                     OE_NOTICE << "IsectPicker: found OID " << oid << "\n";
                     Feature* f = fi->getFeature(oid);
                     if ( f ) {
                         OE_NOTICE << "...feature ID = " << f->getFID() << "\n";
                     }
                 }      
                 osg::ref_ptr<Feature> f = index->get<Feature>(oid);
                 if ( f.valid() ) {
                     OE_NOTICE << "IsectPicker: found OID " << oid << "\n";
                     OE_NOTICE << "...feature ID = " << f->getFID() << "\n";
                 }
                 osg::ref_ptr<AnnotationNode> a = index->get<AnnotationNode>(oid);
                 if ( a ) {
                     OE_NOTICE << "IsectPicker: found annotation " << a->getName() << "\n";
                 }
             }
             else {
                 OE_NOTICE << "IsectPicker: picked, but no OIDs\n";
             }
         }
         else {
             OE_NOTICE << "IsectPicker: no intersect\n";
         }
     }
     return false;
 }
开发者ID:2php,项目名称:osgearth,代码行数:39,代码来源:osgearth_pick.cpp


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