modified bug

This commit is contained in:
pimin 2025-11-15 21:44:17 +08:00
parent 4fb15b371b
commit fa982e1f2d
6 changed files with 20 additions and 1 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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();
}

View File

@ -36,6 +36,9 @@ public:
return dataPanelManager_;
}
protected slots:
void slotUpdateShowMax();
private:
void InitUI();
void UninitUI();

View File

@ -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)

View File

@ -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<int>(position.x()), static_cast<int>(position.y()), longitude, latitude, height)) {
if (!ScreenToWorldCoordinate(static_cast<int>(position.x()), static_cast<int>(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);
}