Compare commits
No commits in common. "9a2459587337266380b76392a4fff741ee4cd125" and "3eb885a0e0df876efb1c1e20481785578ffe7382" have entirely different histories.
9a24595873
...
3eb885a0e0
26
src/main.cpp
26
src/main.cpp
@ -1,6 +1,14 @@
|
|||||||
|
|
||||||
#include "app/Application.h"
|
#include "app/Application.h"
|
||||||
|
|
||||||
|
#include "common/SpdLogger.h"
|
||||||
|
#include "common/RecourceHelper.h"
|
||||||
|
#include "common/CrashHandler.h"
|
||||||
|
|
||||||
|
#include "ui/MainFrame.h"
|
||||||
|
#include "ui/MainWindow.h"
|
||||||
|
#include "viewer/OsgWidget.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
@ -9,14 +17,19 @@
|
|||||||
#include <QLockFile>
|
#include <QLockFile>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
#include "common/SpdLogger.h"
|
#include <osgViewer/CompositeViewer>
|
||||||
#include "common/RecourceHelper.h"
|
#include <osgViewer/ViewerEventHandlers>
|
||||||
#include "common/CrashHandler.h"
|
|
||||||
|
|
||||||
#include "workspace/WorkspaceManager.h"
|
#include <osgGA/MultiTouchTrackballManipulator>
|
||||||
|
|
||||||
#include "ui/MainFrame.h"
|
#include <osgDB/ReadFile>
|
||||||
|
#include <osgEarth/MapNode>
|
||||||
|
#include <osgEarthUtil/ExampleResources>
|
||||||
|
#include <osgGA/StateSetManipulator>
|
||||||
|
|
||||||
|
#include "osgqt/GraphicsWindowQt.h"
|
||||||
|
#include "scene/ui/CompositeWidgetManager.h"
|
||||||
|
#include "scene/ui/QueryElevationWidget.h"
|
||||||
|
|
||||||
#ifndef LC
|
#ifndef LC
|
||||||
#define LC "DYT"
|
#define LC "DYT"
|
||||||
@ -59,12 +72,9 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
MainFrame mainWindow;
|
MainFrame mainWindow;
|
||||||
splash.showMessage(("正在创建主窗口..."), Qt::AlignHCenter | Qt::AlignBottom, Qt::white);
|
splash.showMessage(("正在创建主窗口..."), Qt::AlignHCenter | Qt::AlignBottom, Qt::white);
|
||||||
// 先显示窗口,再在事件循环启动后最大化,避免首次显示时原生窗口放置未就绪导致尺寸异常
|
|
||||||
mainWindow.showMaximized();
|
mainWindow.showMaximized();
|
||||||
// QTimer::singleShot(0, &mainWindow, &MainFrame::showMaximized);
|
|
||||||
splash.finish(&mainWindow);
|
splash.finish(&mainWindow);
|
||||||
|
|
||||||
|
|
||||||
int ret = app.exec();
|
int ret = app.exec();
|
||||||
// app.Uninit();
|
// app.Uninit();
|
||||||
Sleep(200);
|
Sleep(200);
|
||||||
|
|||||||
@ -8,7 +8,6 @@
|
|||||||
#include <osgDB/ReadFile>
|
#include <osgDB/ReadFile>
|
||||||
#include <osgEarthUtil/EarthManipulator>
|
#include <osgEarthUtil/EarthManipulator>
|
||||||
#include <osgGA/StateSetManipulator>
|
#include <osgGA/StateSetManipulator>
|
||||||
#include <osgEarth/Registry>
|
|
||||||
|
|
||||||
#include <osgShadow/ShadowedScene>
|
#include <osgShadow/ShadowedScene>
|
||||||
#include <osgShadow/ViewDependentShadowMap>
|
#include <osgShadow/ViewDependentShadowMap>
|
||||||
@ -35,34 +34,21 @@ OEScene::OEScene() {
|
|||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
OEScene::~OEScene() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void OEScene::AttachView(osgViewer::View* view) {
|
void OEScene::AttachView(osgViewer::View* view) {
|
||||||
if (!view) return;
|
|
||||||
if (curentView_ == view) return;
|
|
||||||
|
|
||||||
dyt_check(nullptr != earthRootNode_);
|
dyt_check(nullptr != earthRootNode_);
|
||||||
|
skyDome_ = osgEarth::Util::SkyNode::create(earthMapNode_);
|
||||||
if (!earthMapNode_) {
|
if (!earthMapNode_) {
|
||||||
LOG_WARN("eart map node is nullptr");
|
LOG_WARN("eart map node is nullptr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skyDome_.valid()) {
|
dyt_check(nullptr != earthManipulator_);
|
||||||
removeChild(skyDome_.get());
|
view->setCameraManipulator(earthManipulator_);
|
||||||
skyDome_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
skyDome_ = osgEarth::Util::SkyNode::create(earthMapNode_);
|
|
||||||
skyDome_->attach(view);
|
skyDome_->attach(view);
|
||||||
skyDome_->getSunLight()->setAmbient(osg::Vec4(0.5,0.5,0.5,1.0));
|
skyDome_->getSunLight()->setAmbient(osg::Vec4(0.5,0.5,0.5,1.0));
|
||||||
addChild(skyDome_);
|
addChild(skyDome_);
|
||||||
skyDome_->setDateTime(osgEarth::DateTime(2024, 12, 24, 3));
|
|
||||||
|
|
||||||
dyt_check(nullptr != earthManipulator_);
|
skyDome_->setDateTime(osgEarth::DateTime(2024, 12, 24, 3));
|
||||||
view->setCameraManipulator(earthManipulator_);
|
|
||||||
|
|
||||||
view->setSceneData(this);
|
view->setSceneData(this);
|
||||||
curentView_ = view;
|
curentView_ = view;
|
||||||
@ -70,42 +56,29 @@ void OEScene::AttachView(osgViewer::View* view) {
|
|||||||
|
|
||||||
void OEScene::DetachView(osgViewer::View* view) {
|
void OEScene::DetachView(osgViewer::View* view) {
|
||||||
if (!view) return;
|
if (!view) return;
|
||||||
if (view != curentView_) return;
|
|
||||||
|
|
||||||
|
// Remove sky dome from this group if present; SkyNode has no detach in osgEarth 2.8
|
||||||
if (skyDome_.valid()) {
|
if (skyDome_.valid()) {
|
||||||
|
// Proactively disable lighting/effects to reduce interactions with the View
|
||||||
skyDome_->setLighting(osg::StateAttribute::OFF);
|
skyDome_->setLighting(osg::StateAttribute::OFF);
|
||||||
skyDome_->setSunVisible(false);
|
skyDome_->setSunVisible(false);
|
||||||
skyDome_->setMoonVisible(false);
|
skyDome_->setMoonVisible(false);
|
||||||
skyDome_->setStarsVisible(false);
|
skyDome_->setStarsVisible(false);
|
||||||
skyDome_->setAtmosphereVisible(false);
|
skyDome_->setAtmosphereVisible(false);
|
||||||
}
|
|
||||||
|
|
||||||
if (earthManipulator_.valid()) {
|
|
||||||
view->setCameraManipulator(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skyDome_.valid()) {
|
|
||||||
removeChild(skyDome_.get());
|
removeChild(skyDome_.get());
|
||||||
skyDome_ = nullptr;
|
skyDome_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entityRoot_.valid()) {
|
// Clear scene data
|
||||||
removeChild(entityRoot_);
|
|
||||||
entityRoot_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (earthRootNode_.valid()) {
|
|
||||||
removeChild(earthRootNode_);
|
|
||||||
earthRootNode_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
view->setSceneData(nullptr);
|
view->setSceneData(nullptr);
|
||||||
|
|
||||||
// 清理内部视图指针
|
// Clear manipulator association
|
||||||
if (curentView_ == view) {
|
if (earthManipulator_.valid()) {
|
||||||
curentView_ = nullptr;
|
view->setCameraManipulator(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear internal view pointer
|
||||||
|
curentView_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OEScene::AddToScene(osg::Node* node) const {
|
bool OEScene::AddToScene(osg::Node* node) const {
|
||||||
@ -225,19 +198,18 @@ void OEScene::Init() {
|
|||||||
|
|
||||||
std::string earthPath(earthFile.toLocal8Bit().constData());
|
std::string earthPath(earthFile.toLocal8Bit().constData());
|
||||||
LOG_INFO("Loading earth file from: {}", earthPath);
|
LOG_INFO("Loading earth file from: {}", earthPath);
|
||||||
|
// earthRootNode_ = osgDB::readNodeFile("triton.earth");
|
||||||
osg::ref_ptr<osgDB::Options> myReadOptions = osgEarth::Registry::cloneOrCreateOptions();
|
|
||||||
earthRootNode_ = osgDB::readNodeFile(earthPath);
|
earthRootNode_ = osgDB::readNodeFile(earthPath);
|
||||||
dyt_check(nullptr != earthRootNode_);
|
dyt_check(nullptr != earthRootNode_);
|
||||||
|
addChild(earthRootNode_);
|
||||||
|
|
||||||
earthMapNode_ = osgEarth::MapNode::findMapNode(earthRootNode_);
|
earthMapNode_ = osgEarth::MapNode::get(earthRootNode_);
|
||||||
dyt_check(nullptr != earthMapNode_);
|
dyt_check(nullptr != earthMapNode_);
|
||||||
addChild(earthMapNode_);
|
|
||||||
|
|
||||||
LOG_INFO("earth map node get success: {}", earthMapNode_.valid());
|
LOG_INFO("earth map node get success: {}", earthMapNode_.valid());
|
||||||
g_srs_ = earthMapNode_->getMapSRS();
|
g_srs_ = earthMapNode_->getMapSRS();
|
||||||
|
|
||||||
earthManipulator_ = new osgEarth::Util::EarthManipulator();
|
earthManipulator_ = new osgEarth::Util::EarthManipulator();
|
||||||
|
earthManipulator_->getSettings()->setMinMaxPitch(-90.0, -10.0);
|
||||||
|
|
||||||
|
|
||||||
entityRoot_ = new osg::Group;
|
entityRoot_ = new osg::Group;
|
||||||
|
|||||||
@ -17,7 +17,6 @@ namespace Util {
|
|||||||
class OEScene : public osg::Group {
|
class OEScene : public osg::Group {
|
||||||
public:
|
public:
|
||||||
OEScene();
|
OEScene();
|
||||||
~OEScene();
|
|
||||||
void AttachView(osgViewer::View* view);
|
void AttachView(osgViewer::View* view);
|
||||||
void DetachView(osgViewer::View* view);
|
void DetachView(osgViewer::View* view);
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "scene/ui/OESceneUI.h"
|
#include "scene/ui/OESceneUI.h"
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "common/SpdLogger.h"
|
#include "common/SpdLogger.h"
|
||||||
@ -18,10 +18,11 @@ OESceneUI::OESceneUI(OEScene* oeScene)
|
|||||||
|
|
||||||
OESceneUI::~OESceneUI(void) {
|
OESceneUI::~OESceneUI(void) {
|
||||||
LOG_INFO("dctor self={}", spdlog::fmt_lib::ptr(this));
|
LOG_INFO("dctor self={}", spdlog::fmt_lib::ptr(this));
|
||||||
|
/* if (compositeWidgetManager_) {
|
||||||
|
compositeWidgetManager_->DetachViewUI();
|
||||||
|
delete compositeWidgetManager_;
|
||||||
compositeWidgetManager_ = nullptr;
|
compositeWidgetManager_ = nullptr;
|
||||||
queryElevationWidget_ = nullptr;
|
}*/
|
||||||
oeScene_ = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OESceneUI::InitUI(OsgViewUI* ui) {
|
void OESceneUI::InitUI(OsgViewUI* ui) {
|
||||||
@ -52,20 +53,12 @@ void OESceneUI::UninitUI(OsgViewUI* ui) {
|
|||||||
LOG_INFO("not init");
|
LOG_INFO("not init");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 安全清理,不访问可能已销毁的资源
|
|
||||||
if (compositeWidgetManager_) {
|
if (compositeWidgetManager_) {
|
||||||
// 只在ui有效时才调用DetachViewUI
|
|
||||||
if (ui) {
|
|
||||||
compositeWidgetManager_->DetachViewUI(ui);
|
compositeWidgetManager_->DetachViewUI(ui);
|
||||||
}
|
|
||||||
compositeWidgetManager_ = nullptr;
|
compositeWidgetManager_ = nullptr;
|
||||||
}
|
}
|
||||||
if (queryElevationWidget_) {
|
if (queryElevationWidget_) {
|
||||||
// 只在ui有效时才调用DetachViewUI
|
|
||||||
if (ui) {
|
|
||||||
queryElevationWidget_->DetachViewUI(ui);
|
queryElevationWidget_->DetachViewUI(ui);
|
||||||
}
|
|
||||||
queryElevationWidget_ = nullptr;
|
queryElevationWidget_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -162,31 +162,19 @@ bool FramelessDelegateWin::nativeEvent(const QByteArray & eventType, void* messa
|
|||||||
case WM_NCHITTEST: {
|
case WM_NCHITTEST: {
|
||||||
return OnNCTitTest(msg, result);
|
return OnNCTitTest(msg, result);
|
||||||
}
|
}
|
||||||
case WM_GETMINMAXINFO: {
|
case WM_GETMINMAXINFO:
|
||||||
// 使用工作区定义最大化位置与大小,避免遮挡任务栏
|
{
|
||||||
MINMAXINFO* mmi = reinterpret_cast<MINMAXINFO*>(msg->lParam);
|
|
||||||
HMONITOR monitor = MonitorFromWindow(msg->hwnd, MONITOR_DEFAULTTONEAREST);
|
|
||||||
MONITORINFO mi;
|
|
||||||
::ZeroMemory(&mi, sizeof(mi));
|
|
||||||
mi.cbSize = sizeof(mi);
|
|
||||||
if (monitor && GetMonitorInfo(monitor, &mi)) {
|
|
||||||
const RECT& work = mi.rcWork;
|
|
||||||
const RECT& rcMon = mi.rcMonitor;
|
|
||||||
mmi->ptMaxPosition.x = work.left;
|
|
||||||
mmi->ptMaxPosition.y = work.top;
|
|
||||||
mmi->ptMaxSize.x = work.right - work.left;
|
|
||||||
mmi->ptMaxSize.y = work.bottom - work.top;
|
|
||||||
// 限制拖动最大尺寸为监视器大小(非必须,但较合理)
|
|
||||||
mmi->ptMaxTrackSize.x = rcMon.right - rcMon.left;
|
|
||||||
mmi->ptMaxTrackSize.y = rcMon.bottom - rcMon.top;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (::IsZoomed(msg->hwnd)) {
|
if (::IsZoomed(msg->hwnd)) {
|
||||||
// 最大化时不叠加系统边框内边距
|
RECT frame = { 0, 0, 0, 0 };
|
||||||
|
AdjustWindowRectEx(&frame, WS_OVERLAPPEDWINDOW, FALSE, 0);
|
||||||
|
double dpr = mainWidget_->devicePixelRatioF();
|
||||||
|
|
||||||
|
// 最大化时不叠加系统边框内边距,避免左右出现可见空隙
|
||||||
frames_.setLeft(0);
|
frames_.setLeft(0);
|
||||||
frames_.setTop(0);
|
frames_.setTop(0);
|
||||||
frames_.setRight(0);
|
frames_.setRight(0);
|
||||||
frames_.setBottom(0);
|
frames_.setBottom(0);
|
||||||
|
|
||||||
mainWidget_->setContentsMargins(margins_);
|
mainWidget_->setContentsMargins(margins_);
|
||||||
justMaximized_ = true;
|
justMaximized_ = true;
|
||||||
} else {
|
} else {
|
||||||
@ -200,16 +188,14 @@ bool FramelessDelegateWin::nativeEvent(const QByteArray & eventType, void* messa
|
|||||||
if (nullptr != titleBar_ && flag) {
|
if (nullptr != titleBar_ && flag) {
|
||||||
titleBar_->OnMaximized(justMaximized_);
|
titleBar_->OnMaximized(justMaximized_);
|
||||||
}
|
}
|
||||||
*result = 0;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case WM_NCLBUTTONDBLCLK: {
|
case WM_NCLBUTTONDBLCLK: {
|
||||||
*result = 0;
|
|
||||||
if (mainWidget_->maximumSize() == QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX) &&
|
if (mainWidget_->maximumSize() == QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX) &&
|
||||||
mainWidget_->windowFlags().testFlag(Qt::WindowMaximizeButtonHint))
|
mainWidget_->windowFlags().testFlag(Qt::WindowMaximizeButtonHint))
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
case WM_NCRBUTTONUP:
|
case WM_NCRBUTTONUP:
|
||||||
{
|
{
|
||||||
@ -225,13 +211,13 @@ bool FramelessDelegateWin::nativeEvent(const QByteArray & eventType, void* messa
|
|||||||
|
|
||||||
void FramelessDelegateWin::OnShow() {
|
void FramelessDelegateWin::OnShow() {
|
||||||
if (isFirstShow_) {
|
if (isFirstShow_) {
|
||||||
SetNativeWindowLong();
|
|
||||||
isFirstShow_ = false;
|
isFirstShow_ = false;
|
||||||
|
|
||||||
|
SetNativeWindowLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
mainWidget_->setAttribute(Qt::WA_Resized);
|
mainWidget_->setAttribute(Qt::WA_Resized);
|
||||||
// 仅当存在有效的窗口放置信息(length 已设置)时才恢复窗口位置,避免首次显示使用未初始化的数据
|
if (!isFirstShow_ && mainWidget_->isMaximized()) {
|
||||||
if (!isFirstShow_ && mainWidget_->isMaximized() && wndPlaceMent_.length == sizeof(wndPlaceMent_)) {
|
|
||||||
QMetaObject::invokeMethod(
|
QMetaObject::invokeMethod(
|
||||||
this,
|
this,
|
||||||
[=]() {
|
[=]() {
|
||||||
@ -382,13 +368,12 @@ void FramelessDelegateWin::SetNativeWindowLong() {
|
|||||||
style &= ~WS_MINIMIZEBOX;
|
style &= ~WS_MINIMIZEBOX;
|
||||||
style &= ~WS_MAXIMIZEBOX;
|
style &= ~WS_MAXIMIZEBOX;
|
||||||
|
|
||||||
// 根据 Qt 窗口标志与大小约束,启用系统最小化/最大化按钮能力
|
if (!mainWidget_->windowFlags().testFlag(Qt::WindowMinimizeButtonHint) ||
|
||||||
const bool canResize = (mainWidget_->maximumSize() == QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
|
mainWidget_->maximumSize() != QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)) {
|
||||||
if (mainWidget_->windowFlags().testFlag(Qt::WindowMinimizeButtonHint) && canResize) {
|
style &= ~WS_MINIMIZEBOX;
|
||||||
style |= WS_MINIMIZEBOX;
|
|
||||||
}
|
}
|
||||||
if (mainWidget_->windowFlags().testFlag(Qt::WindowMaximizeButtonHint) && canResize) {
|
if (!mainWidget_->windowFlags().testFlag(Qt::WindowMaximizeButtonHint)) {
|
||||||
style |= WS_MAXIMIZEBOX;
|
style &= ~WS_MAXIMIZEBOX;
|
||||||
}
|
}
|
||||||
|
|
||||||
::SetWindowLongPtr(hwnd, GWL_STYLE, style);
|
::SetWindowLongPtr(hwnd, GWL_STYLE, style);
|
||||||
|
|||||||
@ -6,13 +6,9 @@
|
|||||||
|
|
||||||
FramelessWindow::FramelessWindow(QWidget* parent)
|
FramelessWindow::FramelessWindow(QWidget* parent)
|
||||||
: QFrame(parent) {
|
: QFrame(parent) {
|
||||||
setWindowFlags(windowFlags()
|
setWindowFlags(windowFlags() | Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
|
||||||
| Qt::Window
|
|
||||||
| Qt::FramelessWindowHint
|
|
||||||
| Qt::WindowSystemMenuHint
|
|
||||||
| Qt::WindowMaximizeButtonHint
|
|
||||||
| Qt::WindowMinimizeButtonHint);
|
|
||||||
|
|
||||||
|
// 初始化平台相关的无边框委托,用于命中测试和缩放。
|
||||||
delegate_ = FramelessDelegate::Create(this);
|
delegate_ = FramelessDelegate::Create(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -123,8 +123,8 @@ void MainFrame::InitUI() {
|
|||||||
|
|
||||||
simuRunMenu->SetMainWindow(mainWindow);
|
simuRunMenu->SetMainWindow(mainWindow);
|
||||||
|
|
||||||
/*OsgWidget* viewWidget = mainWindow->GetViewWidget();
|
OsgWidget* viewWidget = mainWindow->GetViewWidget();
|
||||||
connect(fileMenu, &FileManagerMenu::LoadDyt, viewWidget, &OsgWidget::OnLoadDyt);*/
|
connect(fileMenu, &FileManagerMenu::LoadDyt, viewWidget, &OsgWidget::OnLoadDyt);
|
||||||
|
|
||||||
//connect(system_, &SystemManagerMenu::signalShowUISetting, mainWindow, &MainWindow::slotShowUISetting);
|
//connect(system_, &SystemManagerMenu::signalShowUISetting, mainWindow, &MainWindow::slotShowUISetting);
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,8 @@ MainWindow::MainWindow(QWidget* parent)
|
|||||||
LOG_INFO("MainWindow::MainWindow - Constructor called, about to call InitUI");
|
LOG_INFO("MainWindow::MainWindow - Constructor called, about to call InitUI");
|
||||||
InitUI();
|
InitUI();
|
||||||
LOG_INFO("MainWindow::MainWindow - Constructor completed");
|
LOG_INFO("MainWindow::MainWindow - Constructor completed");
|
||||||
|
|
||||||
|
QTimer::singleShot(1000.0, this, SLOT(slotUpdateShowMax()));
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
@ -180,7 +182,9 @@ void MainWindow::InitUI() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ui->viewWidget->layout()->addWidget(qtOsgViewWidget_);
|
||||||
qtOsgViewWidget_->LoadDefaultScene();
|
qtOsgViewWidget_->LoadDefaultScene();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
MatlabObject::GetInstance()->RunMatlabFile("");
|
MatlabObject::GetInstance()->RunMatlabFile("");
|
||||||
#endif // 1
|
#endif // 1
|
||||||
@ -202,3 +206,7 @@ void MainWindow::UninitUI() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::slotUpdateShowMax()
|
||||||
|
{
|
||||||
|
showMaximized();
|
||||||
|
}
|
||||||
@ -36,6 +36,9 @@ public:
|
|||||||
return dataPanelManager_;
|
return dataPanelManager_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void slotUpdateShowMax();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitUI();
|
void InitUI();
|
||||||
void UninitUI();
|
void UninitUI();
|
||||||
|
|||||||
@ -75,7 +75,6 @@ void FileManagerMenu::OpenWorkSpace() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("open workspace: {}", fileName.toLocal8Bit().constData());
|
LOG_INFO("open workspace: {}", fileName.toLocal8Bit().constData());
|
||||||
WorkSpaceManager::Get().LoadDyt(fileName);
|
|
||||||
emit LoadDyt(fileName);
|
emit LoadDyt(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -48,9 +48,10 @@ OsgWidget::OsgWidget(QWidget* parent, Qt::WindowFlags f)
|
|||||||
: QWidget(parent, f)
|
: QWidget(parent, f)
|
||||||
{
|
{
|
||||||
// setAttribute(Qt::WA_PaintOnScreen, true);
|
// setAttribute(Qt::WA_PaintOnScreen, true);
|
||||||
setAttribute(Qt::WA_StaticContents, true);
|
// setAttribute(Qt::WA_StaticContents, true);
|
||||||
setAttribute(Qt::WA_NoSystemBackground, true);
|
// setAttribute(Qt::WA_NoSystemBackground, true);
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent, true);
|
//setAttribute(Qt::WA_OpaquePaintEvent, true);
|
||||||
|
// setAttribute(Qt::WA_DontCreateNativeAncestors, false);
|
||||||
|
|
||||||
setThreadingModel(osgViewer::ViewerBase::SingleThreaded);
|
setThreadingModel(osgViewer::ViewerBase::SingleThreaded);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
@ -72,6 +73,16 @@ OsgWidget::~OsgWidget() {
|
|||||||
if (timer_.isActive()) {
|
if (timer_.isActive()) {
|
||||||
timer_.stop();
|
timer_.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First unload the workspace while scene/view are still valid,
|
||||||
|
// so entities can detach cleanly from the scene graph
|
||||||
|
if (nullptr != workspace_) {
|
||||||
|
workspace_->Unlaod();
|
||||||
|
workspace_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then perform the viewer teardown (detach UI, view, and scene)
|
||||||
|
Uninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgWidget::Initialize() {
|
void OsgWidget::Initialize() {
|
||||||
@ -98,11 +109,6 @@ void OsgWidget::Initialize() {
|
|||||||
|
|
||||||
void OsgWidget::Uninitialize() {
|
void OsgWidget::Uninitialize() {
|
||||||
LOG_INFO("OsgWidget::Uninitialize");
|
LOG_INFO("OsgWidget::Uninitialize");
|
||||||
|
|
||||||
if (nullptr != activeScene_) {
|
|
||||||
activeScene_->DetachView(view_);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nullptr != viewUI_) {
|
if (nullptr != viewUI_) {
|
||||||
// Avoid creating UI during teardown; only remove if it exists
|
// Avoid creating UI during teardown; only remove if it exists
|
||||||
if (activeScene_.valid()) {
|
if (activeScene_.valid()) {
|
||||||
@ -113,8 +119,8 @@ void OsgWidget::Uninitialize() {
|
|||||||
}
|
}
|
||||||
viewUI_ = nullptr;
|
viewUI_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nullptr != activeScene_) {
|
if (nullptr != activeScene_) {
|
||||||
|
activeScene_->DetachView(view_);
|
||||||
activeScene_ = nullptr;
|
activeScene_ = nullptr;
|
||||||
}
|
}
|
||||||
if (nullptr != view_) {
|
if (nullptr != view_) {
|
||||||
@ -131,6 +137,29 @@ void OsgWidget::LoadDefaultScene() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OsgWidget::OnLoadDyt(const QString& path) {
|
||||||
|
LOG_INFO("load dyt path:{}", path.toStdString());
|
||||||
|
WorkSpace* workSpace = WorkSpaceManager::Get().LoadDyt(path);
|
||||||
|
if (nullptr == workSpace) {
|
||||||
|
QMessageBox::warning(&MainFrame::Get(), tr("warning"),
|
||||||
|
tr("open dyt file failed"), QMessageBox::Ok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString& name = workSpace->GetName();
|
||||||
|
const QString windowTitle = MainFrame::Get().windowTitle();
|
||||||
|
|
||||||
|
MainFrame::Get().setWindowTitle(windowTitle + "-" + name);
|
||||||
|
WorkSpaceManager::Get().SetCurrent(workSpace);
|
||||||
|
if (nullptr != workspace_ && workspace_ != workSpace) {
|
||||||
|
workspace_->Unlaod();
|
||||||
|
}
|
||||||
|
|
||||||
|
workspace_ = workSpace;
|
||||||
|
|
||||||
|
emit signalResetWorkSpace();
|
||||||
|
}
|
||||||
|
|
||||||
osgQt::GraphicsWindowQt* OsgWidget::createGraphicsWindow(int x, int y, int w, int h, const std::string& name,
|
osgQt::GraphicsWindowQt* OsgWidget::createGraphicsWindow(int x, int y, int w, int h, const std::string& name,
|
||||||
bool windowDecoration) {
|
bool windowDecoration) {
|
||||||
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
|
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
|
||||||
@ -153,6 +182,7 @@ osgQt::GraphicsWindowQt* OsgWidget::createGraphicsWindow(int x, int y, int w, in
|
|||||||
QWidget* OsgWidget::addViewWidget(osgQt::GraphicsWindowQt* gw) {
|
QWidget* OsgWidget::addViewWidget(osgQt::GraphicsWindowQt* gw) {
|
||||||
view_ = new osgViewer::View;
|
view_ = new osgViewer::View;
|
||||||
addView( view_ );
|
addView( view_ );
|
||||||
|
ConfigureView(view_);
|
||||||
|
|
||||||
osg::Camera* camera = view_->getCamera();
|
osg::Camera* camera = view_->getCamera();
|
||||||
camera->setGraphicsContext( gw );
|
camera->setGraphicsContext( gw );
|
||||||
@ -164,9 +194,6 @@ QWidget* OsgWidget::addViewWidget(osgQt::GraphicsWindowQt* gw) {
|
|||||||
camera->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f, 10000.0f );
|
camera->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f, 10000.0f );
|
||||||
|
|
||||||
activeScene_->AttachView(view_);
|
activeScene_->AttachView(view_);
|
||||||
|
|
||||||
ConfigureView(view_);
|
|
||||||
|
|
||||||
return gw->getGLWidget();
|
return gw->getGLWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,8 +16,10 @@ public:
|
|||||||
void Initialize(void);
|
void Initialize(void);
|
||||||
void Uninitialize(void);
|
void Uninitialize(void);
|
||||||
void LoadDefaultScene(void);
|
void LoadDefaultScene(void);
|
||||||
|
void OnLoadDyt(const QString& path);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void signalResetWorkSpace();
|
||||||
void signalScaleInfo(const QString&);
|
void signalScaleInfo(const QString&);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -50,6 +52,7 @@ private:
|
|||||||
|
|
||||||
osg::ref_ptr<OEScene> activeScene_;
|
osg::ref_ptr<OEScene> activeScene_;
|
||||||
osg::ref_ptr<class OsgViewUI> viewUI_;
|
osg::ref_ptr<class OsgViewUI> viewUI_;
|
||||||
|
class WorkSpace* workspace_{ nullptr };
|
||||||
osg::ref_ptr<osgViewer::View> view_;
|
osg::ref_ptr<osgViewer::View> view_;
|
||||||
// class OsgView* view_{nullptr};
|
// class OsgView* view_{nullptr};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -152,7 +152,6 @@ WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
workSpaces_[dyt] = workspace;
|
workSpaces_[dyt] = workspace;
|
||||||
SetCurrent(workspace);
|
|
||||||
return workspace;
|
return workspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user