DYTSrouce/src/viewer/OsgWidget.h
2025-11-17 00:07:24 +08:00

52 lines
1.5 KiB
C++

#pragma once
#include <QTimer>
#include <osgViewer/CompositeViewer>
#include "osgqt/GraphicsWindowQt.h"
class OEScene;
class OsgWidget : public QWidget, public osgViewer::CompositeViewer {
Q_OBJECT
public:
OsgWidget(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr);
~OsgWidget() override;
QPaintEngine* paintEngine() const override { return nullptr; }
void Initialize(void);
void Uninitialize(void);
void LoadDefaultScene(void);
void AttachDock(class DockWidget* dockWidget);
signals:
void signalScaleInfo(const QString&);
protected:
osgQt::GraphicsWindowQt* createGraphicsWindow( int x, int y, int w, int h,
const std::string& name="", bool windowDecoration=false );
QWidget* addViewWidget( osgQt::GraphicsWindowQt* gw);
void resizeEvent(QResizeEvent* event) override;
void paintEvent( QPaintEvent* /*event*/ ) override;
void dragEnterEvent(QDragEnterEvent* event) override;
void dragMoveEvent(QDragMoveEvent* event) override;
void dropEvent(QDropEvent* event) override;
public slots:
void OnPresetModelDropped(const QString& modelType, const QString& modelName, const QPointF& position = QPointF());
bool ScreenToWorldCoordinate(int x, int y, double& longitude, double& latitude, double& altitude);
private:
QTimer timer_;
osg::ref_ptr<OEScene> activeScene_;
osg::ref_ptr<class OsgViewUI> viewUI_;
osg::ref_ptr<osgViewer::View> view_;
// class OsgView* view_{nullptr};
};