OSGEarth嵌入Qt的QGraphicsView框架(二)

该博客介绍了如何将OSGEarth嵌入到Qt的QGraphicsView框架中,通过创建一个继承自EventAdapter的GraphicsView类,并利用OpenGL在QGraphicsView的Viewport上进行绘制。为了实现每一帧的更新,博客中提到了使用定时器每隔10ms调用OSG的frame操作。此外,还提供了获取OSGEarth相关组件如Viewer、Group、MapNode等的方法。
摘要由CSDN通过智能技术生成

上一篇处理了QGraphicsView的鼠标、按键事件,本篇接着嵌入OSGEarth。
新建一继承自EventAdapter(一)的类GraphicsView,完成OSGEarth的嵌入工作。实现思路是QGraphicsView的Viewport用OpenGL来绘制,这样才可以完全OSG的update。而要完成每帧的更新,则需要一个定时器,每隔10ms更新一次,即每10ms调用一次OSG的frame操作。
实现代码:graphicsview.h

class GraphicsView : public EventAdapter
{
    Q_OBJECT

public:
    GraphicsView(QWidget* parent = 0);
    ~GraphicsView();

    osgViewer::Viewer* getOSGViewer(){ return m_pViewer; }
    osg::Group* getRoot(){ return m_pSceneData; }
    osgEarth::MapNode* getMapNode(){ return m_pMapNode; }
    const osgEarth::SpatialReference* getSRS(){ return m_pMapSRS; }
    osgEarth::Util::EarthManipulator* getManipulator(){ return m_pEarthManipulator; }

protected:
    // 完成OSG每一帧的update操作
    virtual void drawBackground(QPainter *painter, const QRectF& rect);
    virtual 
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值