DYTSrouce/Source/src/viewer/OsgCameraManipulator.h
2024-11-22 23:11:48 +08:00

60 lines
2.0 KiB
C++

#pragma once
#include <QObject>
#include <osgGA/TrackballManipulator>
//#include "viewer/CameraManipulator.h"
class OsgSceneManipulator;
class OsgCameraManipulator : public QObject {
public:
explicit OsgCameraManipulator(osgGA::CameraManipulator* manipulator, QObject* parent = nullptr) noexcept;
~OsgCameraManipulator() override;
void Initialize(void);
void Uninitialize(void);
void SetHomePosition(const osg::Vec3& eye, const osg::Vec3& center, const osg::Vec3& up);
//void TrackNode(osg::Node* node);
//void SetEventHandle(Core::IEventHandle* pEventHandle);
//Core::IEventHandle* GetEventHandle() const;
osgGA::CameraManipulator* GetManipulator(void) const;
protected:
private:
osg::ref_ptr<osgGA::CameraManipulator> sceneManip_;
bool initialized_{ false };
};
class OsgSceneManipulator : public osgGA::TrackballManipulator {
public:
OsgSceneManipulator(void);
void setByMatrix(const osg::Matrixd& matrix) override;
void setByInverseMatrix(const osg::Matrixd& matrix) override;
osg::Matrixd getMatrix() const override;
osg::Matrixd getInverseMatrix() const override;
//void SetEventHandle(Core::IEventHandle* pEventHandle);
//Core::IEventHandle* GetEventHandle() const;
void SetSceneManipulator(OsgCameraManipulator* sceneManipulator) {
sceneManipulator_ = sceneManipulator;
}
protected:
~OsgSceneManipulator() override;
bool performMovementLeftMouseButton(const double eventTimeDelta,
const double dx, const double dy) override;
bool handleKeyDown(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us) override;
bool handleKeyUp(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us) override;
bool handleMousePush(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us) override;
bool handleMouseRelease(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us) override;
protected:
//Core::SharePtr<Scenes::EventHandle> m_pEventHandle;
OsgCameraManipulator* sceneManipulator_{ nullptr };
};