From 63eeca008647e9413a6f63c984cee51f4bef6e01 Mon Sep 17 00:00:00 2001 From: brige Date: Sun, 6 Jul 2025 22:34:23 +0800 Subject: [PATCH] modify play menu and add label and update sim --- src/translations/Dyt_zh_CN.ts | 21 ++++++++--- src/ui/Menu/ChartPlotMenu.cpp | 50 +++++++++++++------------ src/ui/Menu/PlayManagerMenu.cpp | 2 +- src/ui/ModelBrowser/ModelTreeWidget.cpp | 11 +++++- src/viewer/OsgWidget.cpp | 1 + 5 files changed, 54 insertions(+), 31 deletions(-) diff --git a/src/translations/Dyt_zh_CN.ts b/src/translations/Dyt_zh_CN.ts index 3c79bcc8..2272fcf4 100644 --- a/src/translations/Dyt_zh_CN.ts +++ b/src/translations/Dyt_zh_CN.ts @@ -623,7 +623,7 @@ ModelTreeWidget - + Release Track @@ -658,22 +658,27 @@ - + Track - + + Add Label Component + + + + Add Mesh Component - + Add Path Component - + Delete @@ -758,7 +763,6 @@ - @@ -768,6 +772,11 @@ has not workspace + + + not timestep + + diff --git a/src/ui/Menu/ChartPlotMenu.cpp b/src/ui/Menu/ChartPlotMenu.cpp index 225215b8..aee1b365 100644 --- a/src/ui/Menu/ChartPlotMenu.cpp +++ b/src/ui/Menu/ChartPlotMenu.cpp @@ -55,17 +55,19 @@ void ChartPlotMenu::InitMenu() LOG_INFO("选择文件与当前文件相同"); return; } else if (!old.isEmpty()) { - if (QMessageBox::Yes == QMessageBox::question(nullptr, - QString::fromLocal8Bit("询问"), - QString::fromLocal8Bit("替换当前仿真文件!"), - QMessageBox::Yes | QMessageBox::No) - ) { - if (!QFile::remove(old)) { - LOG_WARN("删除文件失败"); - QMessageBox::information(nullptr, - QString::fromLocal8Bit("提示"), - QString::fromLocal8Bit("删除文件失败!")); - return; + if (QFileInfo(old).isFile() && QFile::exists(old)) { + if (QMessageBox::Yes == QMessageBox::question(nullptr, + QString::fromLocal8Bit("询问"), + QString::fromLocal8Bit("替换当前仿真文件!"), + QMessageBox::Yes | QMessageBox::No) + ) { + if (!QFile::remove(old)) { + LOG_WARN("删除文件失败"); + QMessageBox::information(nullptr, + QString::fromLocal8Bit("提示"), + QString::fromLocal8Bit("删除文件失败!")); + return; + } } } } @@ -129,7 +131,7 @@ void ChartPlotMenu::InitMenu() return; } else if (!old.isEmpty()) { - if (QFileInfo(old).isFile()) { + if (QFileInfo(old).isFile() && QFile::exists(old)) { if (QMessageBox::Yes == QMessageBox::question(nullptr, QString::fromLocal8Bit("询问"), QString::fromLocal8Bit("替换当前RD文件!"), @@ -167,17 +169,19 @@ void ChartPlotMenu::InitMenu() return; } else if (!old.isEmpty()) { - if (QMessageBox::Yes == QMessageBox::question(nullptr, - QString::fromLocal8Bit("询问"), - QString::fromLocal8Bit("替换当前Report文件!"), - QMessageBox::Yes | QMessageBox::No) - ) { - if (!QFile::remove(old)) { - LOG_WARN("删除文件失败"); - QMessageBox::information(nullptr, - QString::fromLocal8Bit("提示"), - QString::fromLocal8Bit("删除文件失败!")); - return; + if (QFileInfo(old).isFile() && QFile::exists(old)) { + if (QMessageBox::Yes == QMessageBox::question(nullptr, + QString::fromLocal8Bit("询问"), + QString::fromLocal8Bit("替换当前Report文件!"), + QMessageBox::Yes | QMessageBox::No) + ) { + if (!QFile::remove(old)) { + LOG_WARN("删除文件失败"); + QMessageBox::information(nullptr, + QString::fromLocal8Bit("提示"), + QString::fromLocal8Bit("删除文件失败!")); + return; + } } } } diff --git a/src/ui/Menu/PlayManagerMenu.cpp b/src/ui/Menu/PlayManagerMenu.cpp index 867ab80f..c79ae567 100644 --- a/src/ui/Menu/PlayManagerMenu.cpp +++ b/src/ui/Menu/PlayManagerMenu.cpp @@ -38,7 +38,7 @@ void PlayManagerMenu::OnPlay() { } Timestep* timestep = workSpace_->GetTimestep(); if (nullptr == timestep) { - QMessageBox::warning(&MainFrame::Get(), tr("warning"), tr("has not workspace"), + QMessageBox::warning(&MainFrame::Get(), tr("warning"), tr("not timestep"), QMessageBox::Ok); LOG_INFO("current is nullptr"); return; diff --git a/src/ui/ModelBrowser/ModelTreeWidget.cpp b/src/ui/ModelBrowser/ModelTreeWidget.cpp index c92e7ff3..6a96c766 100644 --- a/src/ui/ModelBrowser/ModelTreeWidget.cpp +++ b/src/ui/ModelBrowser/ModelTreeWidget.cpp @@ -208,6 +208,8 @@ void ModelTreeWidget::OnAddMeshEntity(const QString& mesh, const QString& name) int count = currentWorkSpace_->GetEntities().size(); entity->SetName(QString("%1_%2").arg(name).arg(count)); currentWorkSpace_->AddEntity(entity); + + OnAddComponent("LabelComponent", entity); } SceneComponent* ModelTreeWidget::OnAddComponent(const QString& typeName, Entity* entity) { @@ -265,7 +267,14 @@ void ModelTreeWidget::PopupEntityMenu(QContextMenuEvent* event, Entity* entity) ); } - QAction* addEntiy = new QAction(tr("Add Mesh Component"), this); + QAction* addEntiy = new QAction(tr("Add Label Component"), this); + menu.addAction(addEntiy); + connect(addEntiy, &QAction::triggered, [this, entity]() { + OnAddComponent("LabelComponent", entity); + } + ); + + addEntiy = new QAction(tr("Add Mesh Component"), this); menu.addAction(addEntiy); addEntiy = new QAction(tr("Add Path Component"), this); diff --git a/src/viewer/OsgWidget.cpp b/src/viewer/OsgWidget.cpp index c2902f79..326d71c6 100644 --- a/src/viewer/OsgWidget.cpp +++ b/src/viewer/OsgWidget.cpp @@ -178,6 +178,7 @@ void OsgWidget::resizeEvent(QResizeEvent* event) { } void OsgWidget::paintEvent(QPaintEvent*) { + WorkSpaceManager::Get().OnFrame(); frame(); }