From fa982e1f2d1d5f22db103b7f675c32867cfa7e71 Mon Sep 17 00:00:00 2001 From: pimin <362371171@qq.com> Date: Sat, 15 Nov 2025 21:44:17 +0800 Subject: [PATCH] modified bug --- src/entities/SceneComponent.cpp | 5 +++++ src/entities/SceneComponent.h | 2 ++ src/ui/MainWindow.cpp | 6 ++++++ src/ui/MainWindow.h | 3 +++ src/ui/PropertyBrowser.cpp | 1 + src/viewer/OsgWidget.cpp | 4 +++- 6 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/entities/SceneComponent.cpp b/src/entities/SceneComponent.cpp index 9591357c..345480cf 100644 --- a/src/entities/SceneComponent.cpp +++ b/src/entities/SceneComponent.cpp @@ -125,6 +125,11 @@ const osg::Vec3& SceneComponent::GetLocation() const { return transform_.GetLocation(); } +void SceneComponent::SetScale(const osg::Vec3 & s) +{ + transform_.SetScale(s); +} + void SceneComponent::AttachScene(Entity* entity) { WorkSpace* workspace = entity->GetWorkspace(); if (nullptr == workspace) { diff --git a/src/entities/SceneComponent.h b/src/entities/SceneComponent.h index 7a26a899..42052a25 100644 --- a/src/entities/SceneComponent.h +++ b/src/entities/SceneComponent.h @@ -57,6 +57,8 @@ public: void SetLocation(const osg::Vec3& location); const osg::Vec3& GetLocation() const; + void SetScale(const osg::Vec3& s); + void AttachScene(class Entity* entity); void AttachParent(class Entity* entity); void AttachParent(SceneComponent* parent); diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index 570c12a2..078938ba 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -42,6 +42,8 @@ MainWindow::MainWindow(QWidget* parent) LOG_INFO("MainWindow::MainWindow - Constructor called, about to call InitUI"); InitUI(); LOG_INFO("MainWindow::MainWindow - Constructor completed"); + + QTimer::singleShot(1000.0, this, SLOT(slotUpdateShowMax())); } MainWindow::~MainWindow() { @@ -204,3 +206,7 @@ void MainWindow::UninitUI() { } } +void MainWindow::slotUpdateShowMax() +{ + showMaximized(); +} \ No newline at end of file diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index c8cbd9db..598e2651 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -36,6 +36,9 @@ public: return dataPanelManager_; } +protected slots: + void slotUpdateShowMax(); + private: void InitUI(); void UninitUI(); diff --git a/src/ui/PropertyBrowser.cpp b/src/ui/PropertyBrowser.cpp index 66ddc610..30f2caff 100644 --- a/src/ui/PropertyBrowser.cpp +++ b/src/ui/PropertyBrowser.cpp @@ -1124,6 +1124,7 @@ void PropertyBrowser::OnFileEntryChange(const QVariant& value) { QtProperty* pth = stringManager_->addProperty(tr("path")); stringManager_->setValue(pth, im.path); + pth->setEnabled(false); item->addSubProperty(pth); stringSetters_[ds] = [img, entry, i](const QString& s) diff --git a/src/viewer/OsgWidget.cpp b/src/viewer/OsgWidget.cpp index 5be81ae1..26db5d2c 100644 --- a/src/viewer/OsgWidget.cpp +++ b/src/viewer/OsgWidget.cpp @@ -275,9 +275,10 @@ void OsgWidget::OnPresetModelDropped(const QString& modelType, const QString& mo return; } + osg::Viewport* vp = view_->getCamera()->getViewport(); // 将屏幕坐标转换为世界坐标 double longitude, latitude, height; - if (!ScreenToWorldCoordinate(static_cast(position.x()), static_cast(position.y()), longitude, latitude, height)) { + if (!ScreenToWorldCoordinate(static_cast(position.x()), static_cast(vp->height() - position.y()), longitude, latitude, height)) { LOG_WARN("OsgWidget::OnPresetModelDropped - Failed to convert screen coordinates to world coordinates"); // 使用默认位置 longitude = 0.0; @@ -310,6 +311,7 @@ void OsgWidget::OnPresetModelDropped(const QString& modelType, const QString& mo if (rootComponent) { osg::Vec3 worldPos(longitude, latitude, height); rootComponent->SetLocation(worldPos); + rootComponent->SetScale(osg::Vec3(1000, 1000, 1000)); LOG_INFO("OsgWidget::OnPresetModelDropped - Set entity position to ({:.6f}, {:.6f}, {:.2f})", longitude, latitude, height); }