add new render mode
This commit is contained in:
parent
b900683dbe
commit
7237c650a3
@ -26,7 +26,7 @@ QString Application::GetWorkSpacePath() {
|
|||||||
|
|
||||||
void Application::Init() {
|
void Application::Init() {
|
||||||
Singleton<MeshManager>::Create(this);
|
Singleton<MeshManager>::Create(this);
|
||||||
Singleton<OsgViewer>::Create(this);
|
//Singleton<OsgViewer>::Create(this);
|
||||||
Singleton<RecourceHelper>::Create(this);
|
Singleton<RecourceHelper>::Create(this);
|
||||||
Singleton<EntitiesManager>::Create(this);
|
Singleton<EntitiesManager>::Create(this);
|
||||||
Singleton<WorkSpaceManager>::Create(this);
|
Singleton<WorkSpaceManager>::Create(this);
|
||||||
@ -40,6 +40,6 @@ void Application::Uninit() {
|
|||||||
Singleton<WorkSpaceManager>::Destory();
|
Singleton<WorkSpaceManager>::Destory();
|
||||||
Singleton<EntitiesManager>::Destory();
|
Singleton<EntitiesManager>::Destory();
|
||||||
Singleton<RecourceHelper>::Destory();
|
Singleton<RecourceHelper>::Destory();
|
||||||
Singleton<OsgViewer>::Destory();
|
//Singleton<OsgViewer>::Destory();
|
||||||
Singleton<MeshManager>::Destory();
|
Singleton<MeshManager>::Destory();
|
||||||
}
|
}
|
||||||
|
138
src/main.cpp
138
src/main.cpp
@ -1,3 +1,4 @@
|
|||||||
|
#if 1
|
||||||
#include "app/Application.h"
|
#include "app/Application.h"
|
||||||
|
|
||||||
#include "common/SpdLogger.h"
|
#include "common/SpdLogger.h"
|
||||||
@ -25,3 +26,140 @@ int main(int argc, char* argv[]) {
|
|||||||
ret = app.exec();
|
ret = app.exec();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <osgDB/ReadFile>
|
||||||
|
|
||||||
|
#include <osgWidget/Util>
|
||||||
|
#include <osgWidget/WindowManager>
|
||||||
|
#include <osgWidget/Frame>
|
||||||
|
#include <osgWidget/Box>
|
||||||
|
|
||||||
|
const unsigned int MASK_2D = 0xF0000000;
|
||||||
|
|
||||||
|
// NOTE: THIS IS JUST A TEMPORARY HACK! :) This functionality will all eventually be
|
||||||
|
// encapsulate into another class in osgWidget proper.
|
||||||
|
bool scrollWindow(osgWidget::Event& ev) {
|
||||||
|
// The first thing we need to do is make sure we have a Frame object...
|
||||||
|
osgWidget::Frame* frame = dynamic_cast<osgWidget::Frame*>(ev.getWindow());
|
||||||
|
|
||||||
|
if (!frame) return false;
|
||||||
|
|
||||||
|
// And now we need to make sure our Frame has a valid internal EmbeddedWindow widget.
|
||||||
|
osgWidget::Window::EmbeddedWindow* ew =
|
||||||
|
dynamic_cast<osgWidget::Window::EmbeddedWindow*>(frame->getEmbeddedWindow())
|
||||||
|
;
|
||||||
|
|
||||||
|
if (!ew) return false;
|
||||||
|
|
||||||
|
// Lets get the visible area so that we can use it to make sure our scrolling action
|
||||||
|
// is necessary in the first place.
|
||||||
|
const osgWidget::Quad& va = ew->getWindow()->getVisibleArea();
|
||||||
|
|
||||||
|
// The user wants to scroll up; make sure that the visible area's Y origin isn't already
|
||||||
|
// at 0.0f, 0.0f.
|
||||||
|
if (ev.getWindowManager()->isMouseScrollingUp() && va[1] != 0.0f)
|
||||||
|
ew->getWindow()->addVisibleArea(0, -20)
|
||||||
|
;
|
||||||
|
|
||||||
|
else if (va[1] <= (ew->getWindow()->getHeight() - ew->getHeight()))
|
||||||
|
ew->getWindow()->addVisibleArea(0, 20)
|
||||||
|
;
|
||||||
|
|
||||||
|
// We need to manually call update to make sure the visible area scissoring is done
|
||||||
|
// properly.
|
||||||
|
frame->update();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool changeTheme(osgWidget::Event& ev) {
|
||||||
|
std::string theme;
|
||||||
|
|
||||||
|
if (ev.key == osgGA::GUIEventAdapter::KEY_Right)
|
||||||
|
theme = "osgWidget/theme-1.png"
|
||||||
|
;
|
||||||
|
|
||||||
|
else if (ev.key == osgGA::GUIEventAdapter::KEY_Left)
|
||||||
|
theme = "osgWidget/theme-2.png"
|
||||||
|
;
|
||||||
|
|
||||||
|
else return false;
|
||||||
|
|
||||||
|
osgWidget::Frame* frame = dynamic_cast<osgWidget::Frame*>(ev.getWindow());
|
||||||
|
|
||||||
|
if (!frame) return false;
|
||||||
|
|
||||||
|
// This is just one way to access all our Widgets; we could just as well have used:
|
||||||
|
//
|
||||||
|
// for(osgWidget::Frame::Iterator i = frame.begin(); i != frame.end() i++) {}
|
||||||
|
//
|
||||||
|
// ...and it have worked, too.
|
||||||
|
for (unsigned int row = 0; row < 3; row++) {
|
||||||
|
for (unsigned int col = 0; col < 3; col++) {
|
||||||
|
frame->getByRowCol(row, col)->setImage(theme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**) {
|
||||||
|
osgViewer::Viewer viewer;
|
||||||
|
|
||||||
|
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
|
||||||
|
&viewer,
|
||||||
|
1280.0f,
|
||||||
|
1024.0f,
|
||||||
|
MASK_2D,
|
||||||
|
osgWidget::WindowManager::WM_PICK_DEBUG
|
||||||
|
//osgWidget::WindowManager::WM_NO_INVERT_Y
|
||||||
|
);
|
||||||
|
|
||||||
|
std::string baes("D:/Project/DYTSrouce/bin/Release/data/");
|
||||||
|
osgWidget::Frame* frame = osgWidget::Frame::createSimpleFrameFromTheme(
|
||||||
|
"frame",
|
||||||
|
osgDB::readRefImageFile(baes + "osgWidget/theme.png"),
|
||||||
|
40.0f,
|
||||||
|
40.0f,
|
||||||
|
osgWidget::Frame::FRAME_ALL
|
||||||
|
);
|
||||||
|
|
||||||
|
frame->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
// This is our Transformers box. :)
|
||||||
|
osgWidget::Box* box = new osgWidget::Box("images", osgWidget::Box::VERTICAL);
|
||||||
|
osgWidget::Widget* img1 = new osgWidget::Widget("im1", 512.0f, 512.0f);
|
||||||
|
osgWidget::Widget* img2 = new osgWidget::Widget("im2", 512.0f, 512.0f);
|
||||||
|
osgWidget::Widget* img3 = new osgWidget::Widget("im3", 512.0f, 512.0f);
|
||||||
|
osgWidget::Widget* img4 = new osgWidget::Widget("im4", 512.0f, 512.0f);
|
||||||
|
|
||||||
|
const std::string image1 = "D:/Project/DYTSrouce/bin/Release/resources/northarrow/_n.png";
|
||||||
|
img1->setImage(image1, true);
|
||||||
|
img2->setImage(baes + "osgWidget/scrolled2.jpg", true);
|
||||||
|
img3->setImage(baes + "osgWidget/scrolled3.jpg", true);
|
||||||
|
img4->setImage(baes + "osgWidget/scrolled4.jpg", true);
|
||||||
|
|
||||||
|
img1->setMinimumSize(10.0f, 10.0f);
|
||||||
|
img2->setMinimumSize(10.0f, 10.0f);
|
||||||
|
img3->setMinimumSize(10.0f, 10.0f);
|
||||||
|
img4->setMinimumSize(10.0f, 10.0f);
|
||||||
|
|
||||||
|
box->addWidget(img1);
|
||||||
|
box->addWidget(img2);
|
||||||
|
box->addWidget(img3);
|
||||||
|
box->addWidget(img4);
|
||||||
|
box->setEventMask(osgWidget::EVENT_NONE);
|
||||||
|
|
||||||
|
//frame->getEmbeddedWindow()->setWindow(box);
|
||||||
|
frame->setWindow(box);
|
||||||
|
frame->getEmbeddedWindow()->setColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
frame->resize(300.0f, 300.0f);
|
||||||
|
frame->addCallback(new osgWidget::Callback(&scrollWindow, osgWidget::EVENT_MOUSE_SCROLL));
|
||||||
|
frame->addCallback(new osgWidget::Callback(&changeTheme, osgWidget::EVENT_KEY_DOWN));
|
||||||
|
|
||||||
|
wm->addChild(frame);
|
||||||
|
|
||||||
|
return osgWidget::createExample(viewer, wm);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -40,8 +40,12 @@ void OEScene::InitEventHandle(class OsgView* view) {
|
|||||||
|
|
||||||
//view->GetView()->addEventHandler(new osgEarth::Util::EarthManipulator());
|
//view->GetView()->addEventHandler(new osgEarth::Util::EarthManipulator());
|
||||||
|
|
||||||
view->GetView()->addEventHandler(new osgViewer::HelpHandler);
|
InitEventHandle(view->GetView());
|
||||||
view->GetView()->addEventHandler(new osgViewer::StatsHandler);
|
}
|
||||||
|
|
||||||
|
void OEScene::InitEventHandle(osgViewer::View* view) {
|
||||||
|
view->addEventHandler(new osgViewer::HelpHandler);
|
||||||
|
view->addEventHandler(new osgViewer::StatsHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OEScene::AttachView(OsgView* view) {
|
void OEScene::AttachView(OsgView* view) {
|
||||||
@ -50,6 +54,11 @@ void OEScene::AttachView(OsgView* view) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AttachView(view->GetView());
|
||||||
|
}
|
||||||
|
|
||||||
|
void OEScene::AttachView(osgViewer::View* view) {
|
||||||
earthRootNode_ = osgDB::readNodeFile("triton.earth");
|
earthRootNode_ = osgDB::readNodeFile("triton.earth");
|
||||||
if (!earthRootNode_) {
|
if (!earthRootNode_) {
|
||||||
LOG_ERROR("read earth node(triton.earth) failed");
|
LOG_ERROR("read earth node(triton.earth) failed");
|
||||||
@ -75,10 +84,10 @@ void OEScene::AttachView(OsgView* view) {
|
|||||||
|
|
||||||
skyDome_->addChild(earthMapNode_);
|
skyDome_->addChild(earthMapNode_);
|
||||||
|
|
||||||
osg::Node* node = view->GetView()->getSceneData();
|
osg::Node* node = view->getSceneData();
|
||||||
if (nullptr == node) {
|
if (nullptr == node) {
|
||||||
LOG_INFO("view scene data is nullptr, root valid:{}", skyDome_.valid());
|
LOG_INFO("view scene data is nullptr, root valid:{}", skyDome_.valid());
|
||||||
view->GetView()->setSceneData(skyDome_);
|
view->setSceneData(skyDome_);
|
||||||
} else {
|
} else {
|
||||||
osg::Group* group = node->asGroup();
|
osg::Group* group = node->asGroup();
|
||||||
if (nullptr != group) {
|
if (nullptr != group) {
|
||||||
@ -88,8 +97,8 @@ void OEScene::AttachView(OsgView* view) {
|
|||||||
LOG_INFO("node is not group");
|
LOG_INFO("node is not group");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
skyDome_->attach(view->GetView());
|
skyDome_->attach(view);
|
||||||
|
|
||||||
skyDome_->setAtmosphereVisible(true);
|
skyDome_->setAtmosphereVisible(true);
|
||||||
skyDome_->setSunVisible(true);
|
skyDome_->setSunVisible(true);
|
||||||
@ -99,8 +108,7 @@ void OEScene::AttachView(OsgView* view) {
|
|||||||
skyDome_->setDateTime(osgEarth::DateTime(2024, 12, 24, 3));
|
skyDome_->setDateTime(osgEarth::DateTime(2024, 12, 24, 3));
|
||||||
skyDome_->setSimulationTimeTracksDateTime(true);
|
skyDome_->setSimulationTimeTracksDateTime(true);
|
||||||
|
|
||||||
logarithmicDepthBuffer_->install(view->GetView()->getCamera());
|
logarithmicDepthBuffer_->install(view->getCamera());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OEScene::DetachView(OsgView* view) {
|
void OEScene::DetachView(OsgView* view) {
|
||||||
|
@ -20,7 +20,9 @@ class OEScene : public osg::Referenced {
|
|||||||
public:
|
public:
|
||||||
OEScene();
|
OEScene();
|
||||||
void InitEventHandle(OsgView* view);
|
void InitEventHandle(OsgView* view);
|
||||||
|
void InitEventHandle(osgViewer::View* view);
|
||||||
void AttachView(OsgView* view);
|
void AttachView(OsgView* view);
|
||||||
|
void AttachView(osgViewer::View* view);
|
||||||
void DetachView(OsgView* view);
|
void DetachView(OsgView* view);
|
||||||
|
|
||||||
osg::ref_ptr<osg::TextureCubeMap> LoadCubeMapTextures(const std::string& dir);
|
osg::ref_ptr<osg::TextureCubeMap> LoadCubeMapTextures(const std::string& dir);
|
||||||
|
@ -479,153 +479,153 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="71"/>
|
<location filename="../ui/MainWindow.cpp" line="70"/>
|
||||||
<source>model elements</source>
|
<source>model elements</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="77"/>
|
<location filename="../ui/MainWindow.cpp" line="76"/>
|
||||||
<source>attribte</source>
|
<source>attribte</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="114"/>
|
<location filename="../ui/MainWindow.cpp" line="113"/>
|
||||||
<source>Wave Curve</source>
|
<source>Wave Curve</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="122"/>
|
<location filename="../ui/MainWindow.cpp" line="121"/>
|
||||||
<source>Speed Curve</source>
|
<source>Speed Curve</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="131"/>
|
<location filename="../ui/MainWindow.cpp" line="130"/>
|
||||||
<source>3D Curve</source>
|
<source>3D Curve</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="143"/>
|
<location filename="../ui/MainWindow.cpp" line="142"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="168"/>
|
<location filename="../ui/MainWindow.cpp" line="167"/>
|
||||||
<source>Target number</source>
|
<source>Target number</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="143"/>
|
<location filename="../ui/MainWindow.cpp" line="142"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="168"/>
|
<location filename="../ui/MainWindow.cpp" line="167"/>
|
||||||
<source>Signal-to-noise ratio</source>
|
<source>Signal-to-noise ratio</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="144"/>
|
<location filename="../ui/MainWindow.cpp" line="143"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="169"/>
|
<location filename="../ui/MainWindow.cpp" line="168"/>
|
||||||
<source>Azimuth line of sight</source>
|
<source>Azimuth line of sight</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="144"/>
|
<location filename="../ui/MainWindow.cpp" line="143"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="169"/>
|
<location filename="../ui/MainWindow.cpp" line="168"/>
|
||||||
<source>Pitch gaze angle</source>
|
<source>Pitch gaze angle</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="145"/>
|
<location filename="../ui/MainWindow.cpp" line="144"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="170"/>
|
<location filename="../ui/MainWindow.cpp" line="169"/>
|
||||||
<source>azimuth</source>
|
<source>azimuth</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="145"/>
|
<location filename="../ui/MainWindow.cpp" line="144"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="170"/>
|
<location filename="../ui/MainWindow.cpp" line="169"/>
|
||||||
<source>Pitch angle</source>
|
<source>Pitch angle</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="146"/>
|
<location filename="../ui/MainWindow.cpp" line="145"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="171"/>
|
<location filename="../ui/MainWindow.cpp" line="170"/>
|
||||||
<source>attribute</source>
|
<source>attribute</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="146"/>
|
<location filename="../ui/MainWindow.cpp" line="145"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="171"/>
|
<location filename="../ui/MainWindow.cpp" line="170"/>
|
||||||
<source>Doppler</source>
|
<source>Doppler</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="147"/>
|
<location filename="../ui/MainWindow.cpp" line="146"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="172"/>
|
<location filename="../ui/MainWindow.cpp" line="171"/>
|
||||||
<source>course</source>
|
<source>course</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="147"/>
|
<location filename="../ui/MainWindow.cpp" line="146"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="172"/>
|
<location filename="../ui/MainWindow.cpp" line="171"/>
|
||||||
<source>Speed</source>
|
<source>Speed</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="148"/>
|
<location filename="../ui/MainWindow.cpp" line="147"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="173"/>
|
<location filename="../ui/MainWindow.cpp" line="172"/>
|
||||||
<source>longitude</source>
|
<source>longitude</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="148"/>
|
<location filename="../ui/MainWindow.cpp" line="147"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="173"/>
|
<location filename="../ui/MainWindow.cpp" line="172"/>
|
||||||
<source>latitude</source>
|
<source>latitude</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="149"/>
|
<location filename="../ui/MainWindow.cpp" line="148"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="174"/>
|
<location filename="../ui/MainWindow.cpp" line="173"/>
|
||||||
<source>distance</source>
|
<source>distance</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="149"/>
|
<location filename="../ui/MainWindow.cpp" line="148"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="174"/>
|
<location filename="../ui/MainWindow.cpp" line="173"/>
|
||||||
<source>velocity</source>
|
<source>velocity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="150"/>
|
<location filename="../ui/MainWindow.cpp" line="149"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="175"/>
|
<location filename="../ui/MainWindow.cpp" line="174"/>
|
||||||
<source>Radial dimensions</source>
|
<source>Radial dimensions</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="150"/>
|
<location filename="../ui/MainWindow.cpp" line="149"/>
|
||||||
<location filename="../ui/MainWindow.cpp" line="175"/>
|
<location filename="../ui/MainWindow.cpp" line="174"/>
|
||||||
<source>Target RCS</source>
|
<source>Target RCS</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="156"/>
|
<location filename="../ui/MainWindow.cpp" line="155"/>
|
||||||
<source>Report Table</source>
|
<source>Report Table</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="181"/>
|
<location filename="../ui/MainWindow.cpp" line="180"/>
|
||||||
<source>Report</source>
|
<source>Report</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="190"/>
|
<location filename="../ui/MainWindow.cpp" line="189"/>
|
||||||
<source>Signal Indicator Lamp</source>
|
<source>Signal Indicator Lamp</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="197"/>
|
<location filename="../ui/MainWindow.cpp" line="196"/>
|
||||||
<source>ParamSetting</source>
|
<source>ParamSetting</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="202"/>
|
<location filename="../ui/MainWindow.cpp" line="201"/>
|
||||||
<source>Matlab File</source>
|
<source>Matlab File</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/MainWindow.cpp" line="207"/>
|
<location filename="../ui/MainWindow.cpp" line="206"/>
|
||||||
<source>name: 5year 0412</source>
|
<source>name: 5year 0412</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -113,9 +113,9 @@ void MainFrame::InitUI() {
|
|||||||
MainWindow* mainWindow = new MainWindow(this);
|
MainWindow* mainWindow = new MainWindow(this);
|
||||||
layout->addWidget(mainWindow);
|
layout->addWidget(mainWindow);
|
||||||
|
|
||||||
QtOsgViewWidget* viewWidget = mainWindow->GetViewWidget();
|
/* QtOsgViewWidget* viewWidget = mainWindow->GetViewWidget();
|
||||||
connect(fileMenu, &FileManagerMenu::LoadDyt, viewWidget, &QtOsgViewWidget::OnLoadDyt);
|
connect(fileMenu, &FileManagerMenu::LoadDyt, viewWidget, &QtOsgViewWidget::OnLoadDyt);
|
||||||
connect(viewWidget, &QtOsgViewWidget::signalResetWorkSpace, mainWindow, &MainWindow::slotResetWorkSpace);
|
connect(viewWidget, &QtOsgViewWidget::signalResetWorkSpace, mainWindow, &MainWindow::slotResetWorkSpace);*/
|
||||||
|
|
||||||
connect(system_, &SystemManagerMenu::signalShowUISetting, mainWindow, &MainWindow::slotShowUISetting);
|
connect(system_, &SystemManagerMenu::signalShowUISetting, mainWindow, &MainWindow::slotShowUISetting);
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include "ModelBrowser.h"
|
#include "ModelBrowser.h"
|
||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
|
|
||||||
#include "viewer/QtOsgViewWidget.h"
|
#include "viewer/ViewWidget.h"
|
||||||
#include "viewer/OsgViewer.h"
|
#include "viewer/OsgViewer.h"
|
||||||
|
|
||||||
#include "chartPlot/FitCurveDialog.h"
|
#include "chartPlot/FitCurveDialog.h"
|
||||||
@ -44,7 +44,6 @@ MainWindow::MainWindow(QWidget* parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
OsgViewer::Get().Uninitialize();
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +82,7 @@ void MainWindow::InitUI() {
|
|||||||
connect(modelBrowser_, &ModelBrowser::WorkSpaceChange, propertyBrowser_, &PropertyBrowser::OnWorkSpaceChange);
|
connect(modelBrowser_, &ModelBrowser::WorkSpaceChange, propertyBrowser_, &PropertyBrowser::OnWorkSpaceChange);
|
||||||
connect(modelBrowser_, &ModelBrowser::EntityChange, propertyBrowser_, &PropertyBrowser::OnEntityChange);
|
connect(modelBrowser_, &ModelBrowser::EntityChange, propertyBrowser_, &PropertyBrowser::OnEntityChange);
|
||||||
|
|
||||||
qtOsgViewWidget_ = new QtOsgViewWidget;
|
qtOsgViewWidget_ = new ViewWidget;
|
||||||
qtOsgViewWidget_->Initialize();
|
qtOsgViewWidget_->Initialize();
|
||||||
m_mapDockWidget.insert("PropertyBrowser", attribte);
|
m_mapDockWidget.insert("PropertyBrowser", attribte);
|
||||||
|
|
||||||
@ -211,8 +210,8 @@ void MainWindow::InitUI() {
|
|||||||
|
|
||||||
//ui->viewWidget->layout()->addWidget(qtOsgViewWidget_);
|
//ui->viewWidget->layout()->addWidget(qtOsgViewWidget_);
|
||||||
qtOsgViewWidget_->LoadDefaultScene();
|
qtOsgViewWidget_->LoadDefaultScene();
|
||||||
OsgViewer::Get().Initialize();
|
//OsgViewer::Get().Initialize();
|
||||||
OsgViewer::Get().OnFrame();
|
//OsgViewer::Get().OnFrame();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
MatlabObject* mtlb = new MatlabObject;
|
MatlabObject* mtlb = new MatlabObject;
|
||||||
@ -237,8 +236,8 @@ void MainWindow::InitDockLayout() {
|
|||||||
tabWidget_->insertTab(i, mainWindow_, strTabName);
|
tabWidget_->insertTab(i, mainWindow_, strTabName);
|
||||||
if (listDocArea[0].toList().size() > 0) {
|
if (listDocArea[0].toList().size() > 0) {
|
||||||
mainWindow_->setCentralWidget(qtOsgViewWidget_);
|
mainWindow_->setCentralWidget(qtOsgViewWidget_);
|
||||||
OsgViewer::Get().Initialize();
|
//OsgViewer::Get().Initialize();
|
||||||
OsgViewer::Get().OnFrame();
|
//OsgViewer::Get().OnFrame();
|
||||||
} else {
|
} else {
|
||||||
mainWindow_->takeCentralWidget();
|
mainWindow_->takeCentralWidget();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
class ModelBrowser* GetModelBrowser() const {
|
class ModelBrowser* GetModelBrowser() const {
|
||||||
return modelBrowser_;
|
return modelBrowser_;
|
||||||
}
|
}
|
||||||
class QtOsgViewWidget* GetViewWidget() const {
|
class ViewWidget* GetViewWidget() const {
|
||||||
return qtOsgViewWidget_;
|
return qtOsgViewWidget_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ private:
|
|||||||
class ModelBrowser* modelBrowser_{ nullptr };
|
class ModelBrowser* modelBrowser_{ nullptr };
|
||||||
class PropertyBrowser* propertyBrowser_{ nullptr };
|
class PropertyBrowser* propertyBrowser_{ nullptr };
|
||||||
class QWebEngineView* webEngineView_{ nullptr };
|
class QWebEngineView* webEngineView_{ nullptr };
|
||||||
class QtOsgViewWidget* qtOsgViewWidget_{ nullptr };
|
class ViewWidget* qtOsgViewWidget_{ nullptr };
|
||||||
|
|
||||||
class FitCurveDialog* fitCurveDlg_{ nullptr };
|
class FitCurveDialog* fitCurveDlg_{ nullptr };
|
||||||
class FitCurveDialog* fitYLgCurveDlg_{ nullptr };
|
class FitCurveDialog* fitYLgCurveDlg_{ nullptr };
|
||||||
|
@ -2,39 +2,14 @@
|
|||||||
#include "viewer/StateEx.h"
|
#include "viewer/StateEx.h"
|
||||||
|
|
||||||
GraphicsWindowEx::GraphicsWindowEx(osg::GraphicsContext::Traits* traits)
|
GraphicsWindowEx::GraphicsWindowEx(osg::GraphicsContext::Traits* traits)
|
||||||
{
|
: osgViewer::GraphicsWindowEmbedded(traits) {
|
||||||
_traits = traits;
|
_traits = traits;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsWindowEx::GraphicsWindowEx(int x, int y, int width, int height)
|
GraphicsWindowEx::GraphicsWindowEx(int x, int y, int width, int height)
|
||||||
|
: osgViewer::GraphicsWindowEmbedded(x, y, width, height)
|
||||||
{
|
{
|
||||||
_traits = new osg::GraphicsContext::Traits();
|
|
||||||
_traits->x = x;
|
|
||||||
_traits->x = y;
|
|
||||||
_traits->width = width;
|
|
||||||
_traits->height = height;
|
|
||||||
|
|
||||||
init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsWindowEx::init()
|
|
||||||
{
|
|
||||||
if(valid())
|
|
||||||
{
|
|
||||||
// inject our "extended" state
|
|
||||||
setState(new StateEx());
|
|
||||||
getState()->setGraphicsContext(this);
|
|
||||||
|
|
||||||
if(_traits.valid() && _traits->sharedContext.valid())
|
|
||||||
{
|
|
||||||
getState()->setContextID(_traits->sharedContext->getState()->getContextID());
|
|
||||||
incrementContextIDUsageCount(getState()->getContextID());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getState()->setContextID(osg::GraphicsContext::createNewContextID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -9,11 +9,9 @@
|
|||||||
class GraphicsWindowEx : public osgViewer::GraphicsWindowEmbedded
|
class GraphicsWindowEx : public osgViewer::GraphicsWindowEmbedded
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GraphicsWindowEx(osg::GraphicsContext::Traits* traits);
|
GraphicsWindowEx(osg::GraphicsContext::Traits* traits = 0);
|
||||||
GraphicsWindowEx(int x, int y, int width, int height);
|
GraphicsWindowEx(int x, int y, int width, int height);
|
||||||
|
|
||||||
void init();
|
|
||||||
|
|
||||||
virtual bool isSameKindAs(const osg::Object* object) const
|
virtual bool isSameKindAs(const osg::Object* object) const
|
||||||
{
|
{
|
||||||
return dynamic_cast<const GraphicsWindowEx*>(object) != 0;
|
return dynamic_cast<const GraphicsWindowEx*>(object) != 0;
|
||||||
|
154
src/viewer/OsgViewWidget.cpp
Normal file
154
src/viewer/OsgViewWidget.cpp
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
#include "viewer/OsgViewWidget.h"
|
||||||
|
|
||||||
|
#include <QWheelEvent>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QOpenGLContext>
|
||||||
|
#include <QOpenGLFunctions>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QResizeEvent>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
|
#include <osgEarth/EarthManipulator>
|
||||||
|
#include <osgEarth/Viewpoint>
|
||||||
|
#include <osgEarth/GeoMath>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "app/Application.h"
|
||||||
|
#include "common/SpdLogger.h"
|
||||||
|
#include "viewer/OsgView.h"
|
||||||
|
#include "viewer/OsgViewer.h"
|
||||||
|
#include "viewer/OsgCameraManipulator.h"
|
||||||
|
#include "viewer/CameraControlManipulator.h"
|
||||||
|
#include "viewer/OsgViewUI.h"
|
||||||
|
#include "scene/OsgScene.h"
|
||||||
|
#include "workspace/WorkSpace.h"
|
||||||
|
#include "workspace/WorkSpaceManager.h"
|
||||||
|
#include "scene/SceneContent.h"
|
||||||
|
#include "scene/ui/OESceneUI.h"
|
||||||
|
#include "ui/MainFrame.h"
|
||||||
|
|
||||||
|
|
||||||
|
OsgViewWidget::OsgViewWidget(QWidget* parent /*= nullptr*/)
|
||||||
|
: QGLWidget(parent) {
|
||||||
|
osgEarth::initialize();
|
||||||
|
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||||
|
traits->x = 0;
|
||||||
|
traits->y = 0;
|
||||||
|
traits->width = width();
|
||||||
|
traits->height = height();
|
||||||
|
traits->doubleBuffer = true;
|
||||||
|
traits->depth = 32;
|
||||||
|
traits->samples = 16;
|
||||||
|
gw_ = new GraphicsWindowEx(traits.get());
|
||||||
|
setFocusPolicy(Qt::ClickFocus);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OsgViewWidget::Initialize(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgViewWidget::Uninitialize(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgViewWidget::LoadDefaultScene(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgViewWidget::OnLoadDyt(const QString& path) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgViewWidget::resizeGL(int width, int height) {
|
||||||
|
gw_->getEventQueue()->windowResize(0, 0, width, height);
|
||||||
|
gw_->resized(0, 0, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgViewWidget::keyPressEvent(QKeyEvent* event) {
|
||||||
|
switch (event->key()) {
|
||||||
|
case Qt::Key_Escape:
|
||||||
|
//emit quitFullScreen(); //for operation
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gw_->getEventQueue()->keyPress((osgGA::GUIEventAdapter::KeySymbol) * (event->text().toLatin1().data()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgViewWidget::keyReleaseEvent(QKeyEvent* event) {
|
||||||
|
gw_->getEventQueue()->keyRelease((osgGA::GUIEventAdapter::KeySymbol) * (event->text()./*toAscii()*/toLatin1().data()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgViewWidget::mouseMoveEvent(QMouseEvent* event) {
|
||||||
|
gw_->getEventQueue()->mouseMotion(event->x(), event->y());
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgViewWidget::mousePressEvent(QMouseEvent* event) {
|
||||||
|
int button = 0;
|
||||||
|
switch (event->button()) {
|
||||||
|
case(Qt::LeftButton): button = 1; break;
|
||||||
|
case(Qt::MidButton): button = 2; break;
|
||||||
|
case(Qt::RightButton): button = 3; break;
|
||||||
|
case(Qt::NoButton): button = 0; break;
|
||||||
|
default: button = 0; break;
|
||||||
|
}
|
||||||
|
gw_->getEventQueue()->mouseButtonPress(event->x(), event->y(), button);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgViewWidget::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
|
int button = 0;
|
||||||
|
switch (event->button()) {
|
||||||
|
case(Qt::LeftButton): button = 1; break;
|
||||||
|
case(Qt::MidButton): button = 2; break;
|
||||||
|
case(Qt::RightButton): button = 3; break;
|
||||||
|
case(Qt::NoButton): button = 0; break;
|
||||||
|
default: button = 0; break;
|
||||||
|
}
|
||||||
|
gw_->getEventQueue()->mouseButtonRelease(event->x(), event->y(), button);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgViewWidget::mouseDoubleClickEvent(QMouseEvent* event) {
|
||||||
|
QPoint pos = QCursor::pos();
|
||||||
|
// QList<QGraphicsItem*> listItems = items(mapToScene(pos.x(), pos.y()).toPoint());
|
||||||
|
// if (listItems.size() > 0)
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
int button = 0;
|
||||||
|
switch (event->button()) {
|
||||||
|
case Qt::LeftButton: button = 1; break;
|
||||||
|
case Qt::MidButton: button = 2; break;
|
||||||
|
case Qt::RightButton: button = 3; break;
|
||||||
|
case Qt::NoButton: button = 0; break;
|
||||||
|
default: button = 0; break;
|
||||||
|
}
|
||||||
|
setKeyboardModifiers(event);
|
||||||
|
gw_->getEventQueue()->mouseDoubleButtonPress(event->x(), event->y(), button);
|
||||||
|
|
||||||
|
QGLWidget::mouseDoubleClickEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgViewWidget::wheelEvent(QWheelEvent* event) {
|
||||||
|
setKeyboardModifiers(event);
|
||||||
|
gw_->getEventQueue()->mouseScroll(
|
||||||
|
event->orientation() == Qt::Vertical ?
|
||||||
|
(event->delta() > 0 ? osgGA::GUIEventAdapter::SCROLL_UP : osgGA::GUIEventAdapter::SCROLL_DOWN) :
|
||||||
|
(event->delta() > 0 ? osgGA::GUIEventAdapter::SCROLL_LEFT : osgGA::GUIEventAdapter::SCROLL_RIGHT));
|
||||||
|
QGLWidget::wheelEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OsgViewWidget::setKeyboardModifiers(QInputEvent* event) {
|
||||||
|
int modkey = event->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier);
|
||||||
|
unsigned int mask = 0;
|
||||||
|
if (modkey & Qt::ShiftModifier) mask |= osgGA::GUIEventAdapter::MODKEY_SHIFT;
|
||||||
|
if (modkey & Qt::ControlModifier) mask |= osgGA::GUIEventAdapter::MODKEY_CTRL;
|
||||||
|
if (modkey & Qt::AltModifier) mask |= osgGA::GUIEventAdapter::MODKEY_ALT;
|
||||||
|
|
||||||
|
gw_->getEventQueue()->getCurrentEventState()->setModKeyMask(mask);
|
||||||
|
}
|
||||||
|
|
70
src/viewer/OsgViewWidget.h
Normal file
70
src/viewer/OsgViewWidget.h
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QGLWidget>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "scene/OEScene.h"
|
||||||
|
#include "viewer/OsgViewWidget.h"
|
||||||
|
#include "viewer/GraphicsWindowEx.h"
|
||||||
|
|
||||||
|
|
||||||
|
class QMouseEvent;
|
||||||
|
class QWheelEvent;
|
||||||
|
class QKeyEvent;
|
||||||
|
class QInputEvent;
|
||||||
|
class QResizeEvent;
|
||||||
|
|
||||||
|
class OsgViewWidget : public QGLWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit OsgViewWidget(QWidget* parent = nullptr);
|
||||||
|
~OsgViewWidget() override = default;
|
||||||
|
|
||||||
|
//void setKeyboardModifiers(QInputEvent* event) override;
|
||||||
|
QPaintEngine* paintEngine() const override {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
GraphicsWindowEx* getGraphicsWindow() {
|
||||||
|
return gw_.get();
|
||||||
|
}
|
||||||
|
const GraphicsWindowEx* getGraphicsWindow() const {
|
||||||
|
return gw_.get();
|
||||||
|
}
|
||||||
|
osg::GraphicsContext* getGraphicsContext() {
|
||||||
|
return gc_.get();
|
||||||
|
}
|
||||||
|
const osg::GraphicsContext* getGraphicsContext() const {
|
||||||
|
return gc_.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Initialize(void);
|
||||||
|
virtual void Uninitialize(void);
|
||||||
|
|
||||||
|
void LoadDefaultScene(void);
|
||||||
|
|
||||||
|
void OnLoadDyt(const QString& path);
|
||||||
|
//void setKeyboardModifiers(QInputEvent* event);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void signalResetWorkSpace();
|
||||||
|
void signalScaleInfo(const QString&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void init();
|
||||||
|
void resizeGL(int width, int height) override;
|
||||||
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
|
void keyReleaseEvent(QKeyEvent* event) override;
|
||||||
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
|
void mouseDoubleClickEvent(QMouseEvent* event) override;
|
||||||
|
void wheelEvent(QWheelEvent* event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setKeyboardModifiers(QInputEvent* event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
osg::ref_ptr<GraphicsWindowEx> gw_;
|
||||||
|
osg::ref_ptr<osg::GraphicsContext> gc_;
|
||||||
|
};
|
@ -21,7 +21,7 @@ OsgViewer::OsgViewer(QObject* parent) noexcept
|
|||||||
, compositeViewer_(new osgViewer::CompositeViewer) {
|
, compositeViewer_(new osgViewer::CompositeViewer) {
|
||||||
LOG_INFO("actor, self={}", fmt::ptr(this));
|
LOG_INFO("actor, self={}", fmt::ptr(this));
|
||||||
compositeViewer_->setKeyEventSetsDone(0);
|
compositeViewer_->setKeyEventSetsDone(0);
|
||||||
compositeViewer_->getDatabasePager()->setUnrefImageDataAfterApplyPolicy(true, false);
|
//compositeViewer_->getDatabasePager()->setUnrefImageDataAfterApplyPolicy(true, false);
|
||||||
osgEarth::initialize();
|
osgEarth::initialize();
|
||||||
osgDB::Registry::instance()->getObjectWrapperManager()->findWrapper("osg::Image");
|
osgDB::Registry::instance()->getObjectWrapperManager()->findWrapper("osg::Image");
|
||||||
compositeViewer_->setThreadingModel(osgViewer::ViewerBase::ThreadingModel::SingleThreaded);
|
compositeViewer_->setThreadingModel(osgViewer::ViewerBase::ThreadingModel::SingleThreaded);
|
||||||
@ -38,6 +38,7 @@ void OsgViewer::OnDestory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OsgViewer::OnFrame(void) {
|
void OsgViewer::OnFrame(void) {
|
||||||
|
return;
|
||||||
assert(nullptr != compositeViewer_);
|
assert(nullptr != compositeViewer_);
|
||||||
|
|
||||||
WorkSpaceManager::Get().OnFrame();
|
WorkSpaceManager::Get().OnFrame();
|
||||||
|
105
src/viewer/ViewWidget.cpp
Normal file
105
src/viewer/ViewWidget.cpp
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
#include "viewer/ViewWidget.h"
|
||||||
|
|
||||||
|
#include <QWheelEvent>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QOpenGLContext>
|
||||||
|
#include <QOpenGLFunctions>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QResizeEvent>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
|
#include <osgEarth/EarthManipulator>
|
||||||
|
#include <osgEarth/Viewpoint>
|
||||||
|
#include <osgEarth/GeoMath>
|
||||||
|
#include <osgEarth/GLUtils>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "app/Application.h"
|
||||||
|
#include "common/SpdLogger.h"
|
||||||
|
#include "viewer/OsgView.h"
|
||||||
|
#include "viewer/OsgViewer.h"
|
||||||
|
#include "viewer/OsgCameraManipulator.h"
|
||||||
|
#include "viewer/CameraControlManipulator.h"
|
||||||
|
#include "viewer/OsgViewUI.h"
|
||||||
|
#include "scene/OsgScene.h"
|
||||||
|
#include "workspace/WorkSpace.h"
|
||||||
|
#include "workspace/WorkSpaceManager.h"
|
||||||
|
#include "scene/SceneContent.h"
|
||||||
|
#include "scene/ui/OESceneUI.h"
|
||||||
|
#include "ui/MainFrame.h"
|
||||||
|
|
||||||
|
ViewWidget::ViewWidget(QWidget* parent /*= nullptr*/)
|
||||||
|
: OsgViewWidget(parent) {
|
||||||
|
//osg::DisplaySettings::instance()->setNumMultiSamples(16);
|
||||||
|
setKeyEventSetsDone(0);
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::Viewport> viewPort = new osg::Viewport(0, 0, width(), height());
|
||||||
|
getCamera()->setViewport(viewPort);
|
||||||
|
|
||||||
|
getCamera()->setProjectionMatrixAsPerspective(30.0f,
|
||||||
|
static_cast<double>(width()) / static_cast<double>(height()), 1.0f, 10000.0f);
|
||||||
|
getCamera()->setGraphicsContext(getGraphicsWindow());
|
||||||
|
setRealizeOperation(new osgEarth::GL3RealizeOperation());
|
||||||
|
//setThreadingModel(osgViewer::ViewerBase::SingleThreaded);
|
||||||
|
//getCamera()->setNearFarRatio(0.0000001);
|
||||||
|
//getCamera()->setComputeNearFarMode(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES);//);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewWidget::Initialize(void) {
|
||||||
|
OEScene* activeScene_ = new OEScene;
|
||||||
|
activeScene_->AttachView(this);
|
||||||
|
activeScene_->InitEventHandle(this);
|
||||||
|
|
||||||
|
const osg::Viewport* viewport = getCamera()->getViewport();
|
||||||
|
osg::Viewport::value_type width = viewport->width();
|
||||||
|
osg::Viewport::value_type height = viewport->height();
|
||||||
|
viewUI_ = new OsgViewUI(this, width, height);
|
||||||
|
osg::Group* root = getSceneData()->asGroup();
|
||||||
|
dyt_check(nullptr != root);
|
||||||
|
root->addChild(viewUI_.get());
|
||||||
|
|
||||||
|
|
||||||
|
osgEarth::Util::EarthManipulator* manipulator = new osgEarth::Util::EarthManipulator;
|
||||||
|
/* connect(&WorkSpaceManager::Get(), &WorkSpaceManager::WorkSpaceChanged, [](WorkSpace* workspace) {
|
||||||
|
LOG_INFO("WorkSpaceChanged");
|
||||||
|
if (nullptr == workspace) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OsgCameraManipulator* manipulator = OsgViewer::Get().GetView()->GetCameraManipulator();
|
||||||
|
if (nullptr == manipulator) {
|
||||||
|
LOG_WARN("manipulator is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
osgGA::CameraManipulator* gaManipulator = manipulator->GetManipulator();
|
||||||
|
osgEarth::Util::EarthManipulator* ccm = dynamic_cast<osgEarth::Util::EarthManipulator*>(gaManipulator);
|
||||||
|
if (nullptr == ccm) {
|
||||||
|
LOG_WARN("ccm is nullptr");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ccm->setViewpoint(workspace->GetHomeViewpoint(), 3.0);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
OsgCameraManipulator* cameraManipulator = new OsgCameraManipulator(manipulator, this);
|
||||||
|
view_->Initialize(cameraManipulator);*/
|
||||||
|
setCameraManipulator(manipulator);
|
||||||
|
|
||||||
|
|
||||||
|
viewUI_->AddUI(activeScene_->GetOrCreateSceneUI());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewWidget::Uninitialize(void) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewWidget::paintGL() {
|
||||||
|
frame();
|
||||||
|
update();
|
||||||
|
}
|
23
src/viewer/ViewWidget.h
Normal file
23
src/viewer/ViewWidget.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <osgViewer/Viewer>
|
||||||
|
|
||||||
|
#include "scene/OEScene.h"
|
||||||
|
#include "viewer/OsgViewWidget.h"
|
||||||
|
|
||||||
|
|
||||||
|
class ViewWidget : public OsgViewWidget, public osgViewer::Viewer {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ViewWidget(QWidget* parent = nullptr);
|
||||||
|
~ViewWidget() override = default;
|
||||||
|
|
||||||
|
void Initialize(void) override;
|
||||||
|
void Uninitialize(void) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintGL() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
osg::ref_ptr<class OsgViewUI> viewUI_;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user