From 7a0a0b749550cd47952587767b1a7fe3ef70d4b2 Mon Sep 17 00:00:00 2001 From: brige Date: Sun, 2 Nov 2025 14:52:34 +0800 Subject: [PATCH 1/2] modify cmakelists --- src/CMakeLists.txt | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8a6d2d0..69a03ccc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,11 +25,27 @@ SET( TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/translations/Dyt_zh_CN.ts ) + +# 控制是否在构建时自动运行 lupdate 更新 TS 文件。 +# 关闭时仅在 TS 变更后编译生成 QM,避免每次构建都重新创建翻译文件。 +option(UPDATE_TRANSLATIONS "Run lupdate to refresh TS files during build" OFF) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) - qt6_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES}) + if(UPDATE_TRANSLATIONS) + # 运行 lupdate + lrelease:更新 TS 并生成 QM(可能导致每次构建都触发) + qt6_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES}) + else() + # 仅生成 QM,TS 未变化时不重新创建 + qt_add_translations(QM_FILES TS_FILES ${TS_FILES}) + endif() add_custom_target(translations DEPENDS ${QM_FILES}) else() - qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES}) + if(UPDATE_TRANSLATIONS) + # 运行 lupdate + lrelease + qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES}) + else() + # 仅运行 lrelease 生成 QM + qt5_add_translation(QM_FILES ${TS_FILES}) + endif() add_custom_target(translations DEPENDS ${QM_FILES}) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS WinExtras REQUIRED) endif() From f65ea8dcd8fcb87263fb85fc2ab6e27bc72ed122 Mon Sep 17 00:00:00 2001 From: brige Date: Sun, 2 Nov 2025 17:47:54 +0800 Subject: [PATCH 2/2] remove worksapce attribute --- src/ui/MainFrame.cpp | 1 - src/ui/MainWindow.cpp | 17 -- src/ui/MainWindow.h | 3 - src/ui/Menu/ChartPlotMenu.cpp | 241 +++--------------- src/ui/Menu/ChartPlotMenu.ui | 18 ++ src/ui/PropertyBrowser/qtpropertymanager.cpp | 60 +---- .../PropertyBrowser/qtworkspaceattribute.cpp | 83 +----- src/ui/PropertyBrowser/qtworkspaceattribute.h | 15 +- src/workspace/WorkSpace.cpp | 70 +---- src/workspace/WorkSpace.h | 45 +--- src/workspace/WorkSpaceXMLParse.cpp | 118 +-------- src/workspace/WorkSpaceXMLParse.h | 3 - src/workspace/WorkSpaceXMLWrite.cpp | 31 +-- 13 files changed, 67 insertions(+), 638 deletions(-) diff --git a/src/ui/MainFrame.cpp b/src/ui/MainFrame.cpp index f254b246..350df265 100644 --- a/src/ui/MainFrame.cpp +++ b/src/ui/MainFrame.cpp @@ -126,7 +126,6 @@ void MainFrame::InitUI() { OsgWidget* viewWidget = mainWindow->GetViewWidget(); connect(fileMenu, &FileManagerMenu::LoadDyt, viewWidget, &OsgWidget::OnLoadDyt); - connect(viewWidget, &OsgWidget::signalResetWorkSpace, mainWindow, &MainWindow::slotResetWorkSpace); //connect(system_, &SystemManagerMenu::signalShowUISetting, mainWindow, &MainWindow::slotShowUISetting); diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index 76047ec2..21342c31 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -140,20 +140,3 @@ void MainWindow::UninitUI() { } } -void MainWindow::slotResetWorkSpace() -{ - QString wavePath = "", speedPath = "", rdPath = ""; - if (WorkSpaceManager::Get().GetCurrent()) { - if (!WorkSpaceManager::Get().GetCurrent()->GetWavePath().isEmpty()) { - wavePath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetWavePath(); - } - - if (!WorkSpaceManager::Get().GetCurrent()->GetReportPath().isEmpty()) { - speedPath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetReportPath(); - } - - if (!WorkSpaceManager::Get().GetCurrent()->GetRDPath().isEmpty()) { - rdPath = RecourceHelper::Get().GetBasePath() + "/" + WorkSpaceManager::Get().GetCurrent()->GetRDPath(); - } - } -} diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 2cdbb586..c8cbd9db 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -36,9 +36,6 @@ public: return dataPanelManager_; } -public slots: - void slotResetWorkSpace(); - private: void InitUI(); void UninitUI(); diff --git a/src/ui/Menu/ChartPlotMenu.cpp b/src/ui/Menu/ChartPlotMenu.cpp index 6599800b..7389e9fe 100644 --- a/src/ui/Menu/ChartPlotMenu.cpp +++ b/src/ui/Menu/ChartPlotMenu.cpp @@ -1,4 +1,4 @@ -#include "ChartPlotMenu.h" +#include "ChartPlotMenu.h" #include "../Matlab/MatlabObject.h" #include "../../common/RecourceHelper.h" @@ -9,6 +9,7 @@ #include #include +#include ChartPlotMenu::ChartPlotMenu(QWidget *parent) : QWidget(parent) @@ -25,217 +26,35 @@ ChartPlotMenu::~ChartPlotMenu() void ChartPlotMenu::InitMenu() { - connect(ui.toolButton, &QToolButton::clicked, this, [=] { - if (WorkSpaceManager::Get().GetCurrent()) - { - QString strFile = WorkSpaceManager::Get().GetCurrent()->GetSimMatlab(); - if (!strFile.isEmpty()) - { - MatlabObject::GetInstance()->RunMatlabFile(strFile); - } - else - { - QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请检查仿真文件路径是否存在!")); - } - } - }); + // Deprecated: SimMatlab run action removed - connect(ui.toolButton_2, &QToolButton::clicked, this, [=] { - auto current = WorkSpaceManager::Get().GetCurrent(); - if (nullptr == current) { - QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请先创建空间!")); - return; - } - QString strSel = QFileDialog::getOpenFileName(this, u8"选择仿真运行文件", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.m"); - if (strSel.isEmpty()) { - LOG_WARN("选择文件为空"); - return; - } + // Deprecated: SimMatlab selection removed - const QString old = current->GetSimMatlab(); - if (old == strSel) { - LOG_INFO("选择文件与当前文件相同"); - return; - } else if (!old.isEmpty()) { - 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; - } - } - } - } + // Deprecated: Wave file selection removed - current->SetSimMatlab(strSel); - }); - - connect(ui.toolButton_5, &QToolButton::clicked, this, [=] { - auto current = WorkSpaceManager::Get().GetCurrent(); - if (nullptr == current) { - QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请先创建空间!")); - return; - } - QString strSel = QFileDialog::getOpenFileName(this, u8"选择Wave文件", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.txt"); - if (strSel.isEmpty()) { - LOG_WARN("选择文件为空"); - return; - } - - const QString old = current->GetWavePath(); - if (old == strSel) { - LOG_INFO("选择文件与当前文件相同"); - return; - } - else if (!old.isEmpty()) { - if (QFileInfo(old).isFile() && QFile::exists(old)) { - if (QMessageBox::Yes == QMessageBox::question(nullptr, - QString::fromLocal8Bit("询问"), - QString::fromLocal8Bit("替换当前Wave文件!"), - QMessageBox::Yes | QMessageBox::No) - ) { - if (!QFile::remove(old)) { - LOG_WARN("删除文件失败"); - QMessageBox::information(nullptr, - QString::fromLocal8Bit("提示"), - QString::fromLocal8Bit("删除文件失败!")); - return; - } - } - } - } - - current->SetWavePath(strSel); - }); - - connect(ui.toolButton_3, &QToolButton::clicked, this, [=] { - auto current = WorkSpaceManager::Get().GetCurrent(); - if (nullptr == current) { - QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请先创建空间!")); - return; - } - QString strSel = QFileDialog::getOpenFileName(this, u8"选择RD文件", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.txt"); - if (strSel.isEmpty()) { - LOG_WARN("选择文件为空"); - return; - } - - const QString old = current->GetRDPath(); - if (old == strSel) { - LOG_INFO("选择文件与当前文件相同"); - return; - } - else if (!old.isEmpty()) { - if (QFileInfo(old).isFile() && QFile::exists(old)) { - if (QMessageBox::Yes == QMessageBox::question(nullptr, - QString::fromLocal8Bit("询问"), - QString::fromLocal8Bit("替换当前RD文件!"), - QMessageBox::Yes | QMessageBox::No) - ) { - if (!QFile::remove(old)) { - LOG_WARN("删除文件失败"); - QMessageBox::information(nullptr, - QString::fromLocal8Bit("提示"), - QString::fromLocal8Bit("删除文件失败!")); - return; - } - } - } - } - - current->SetRDPath(strSel); - }); - - connect(ui.toolButton_4, &QToolButton::clicked, this, [=] { - auto current = WorkSpaceManager::Get().GetCurrent(); - if (nullptr == current) { - QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请先创建空间!")); - return; - } - QString strSel = QFileDialog::getOpenFileName(this, u8"选择Report文件", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.txt"); - if (strSel.isEmpty()) { - LOG_WARN("选择文件为空"); - return; - } - - const QString old = current->GetReportPath(); - if (old == strSel) { - LOG_INFO("选择文件与当前文件相同"); - return; - } - else if (!old.isEmpty()) { - 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; - } - } - } - } - - current->SetReportPath(strSel); - }); - - connect(ui.toolButton_6, &QToolButton::clicked, this, [=] { - auto current = WorkSpaceManager::Get().GetCurrent(); - if (nullptr == current) { - QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请先创建空间!")); - return; - } - QString strSel = QFileDialog::getOpenFileName(this, u8"选择Lamp文件", RecourceHelper::Get().GetBasePath() + "/workspace/", "*.txt"); - if (strSel.isEmpty()) { - LOG_WARN("选择文件为空"); - return; - } - - auto lampStatus = current->GetLampStatus(); - if (nullptr != lampStatus) { - const QString& old = lampStatus->GetPath(); - if (old == strSel) { - LOG_INFO("选择文件与当前文件相同"); - return; - } - else if (!old.isEmpty()) { - if (QFileInfo(old).isFile() && QFile::exists(old)) { - if (QMessageBox::Yes == QMessageBox::question(nullptr, - QString::fromLocal8Bit("询问"), - QString::fromLocal8Bit("替换当前Lamp文件!"), - QMessageBox::Yes | QMessageBox::No) - ) { - if (!QFile::remove(old)) { - LOG_WARN("删除文件失败"); - QMessageBox::information(nullptr, - QString::fromLocal8Bit("提示"), - QString::fromLocal8Bit("删除文件失败!")); - return; - } - } - } - } - } - - QFileInfo fileInfo(strSel); - QString dirPath = QString("%1/%2").arg(current->GetDir(), fileInfo.fileName()); - bool sucess = FileUtils::CopyFileToPath(strSel, dirPath, true); - LOG_INFO("copy Wave file {}: {} to {}", - strSel.toLocal8Bit().data(), - dirPath.toLocal8Bit().data(), - sucess); - current->SetLampPath(dirPath); - }); + // Deprecated: RD file selection removed + + // Deprecated: Report file selection removed + + // Restore Lamp file selection with safe encoding + connect(ui.toolButton_6, &QToolButton::clicked, this, [this]() { + auto* ws = WorkSpaceManager::Get().GetCurrent(); + const QString defaultDir = ws ? ws->GetDir() : QDir::currentPath(); + const QString title = QString::fromLocal8Bit("选择Lamp文件"); + const QString filters = QString::fromLocal8Bit("文本文件 (*.txt);;所有文件 (*.*)"); + const QString file = QFileDialog::getOpenFileName(this, title, defaultDir, filters); + if (file.isEmpty()) { + return; + } + if (!ws) { + QMessageBox::warning(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("当前无工作区")); + return; + } + const bool ok = ws->SetLampPath(file); + if (ok) { + QMessageBox::information(this, QString::fromLocal8Bit("Lamp"), QString::fromLocal8Bit("已加载 Lamp 文件")); + } else { + QMessageBox::warning(this, QString::fromLocal8Bit("Lamp"), QString::fromLocal8Bit("加载 Lamp 文件失败")); + } + }); } diff --git a/src/ui/Menu/ChartPlotMenu.ui b/src/ui/Menu/ChartPlotMenu.ui index 9e92758d..c6dad019 100644 --- a/src/ui/Menu/ChartPlotMenu.ui +++ b/src/ui/Menu/ChartPlotMenu.ui @@ -18,6 +18,9 @@ + + false + 60 @@ -31,6 +34,9 @@ + + false + 60 @@ -44,6 +50,9 @@ + + false + 60 @@ -57,6 +66,9 @@ + + false + 60 @@ -70,6 +82,9 @@ + + true + 60 @@ -83,6 +98,9 @@ + + false + 60 diff --git a/src/ui/PropertyBrowser/qtpropertymanager.cpp b/src/ui/PropertyBrowser/qtpropertymanager.cpp index 115408fc..87856c59 100644 --- a/src/ui/PropertyBrowser/qtpropertymanager.cpp +++ b/src/ui/PropertyBrowser/qtpropertymanager.cpp @@ -7991,25 +7991,9 @@ void QtWorkspacePropertyManagerPrivate::slotStringChanged(QtProperty* property, QWorkspaceAttribute c = m_values[prop]; c.SetTimeStep(value); q_ptr->setValue(prop, c); - } else if (QtProperty* prop = m_simMatlabToPropery.value(property, 0)) { + } else if (QtProperty* prop = m_commondPathToPropery.value(property, 0)) { QWorkspaceAttribute c = m_values[prop]; - c.SetSimMatlab(value); - q_ptr->setValue(prop, c); - } else if (QtProperty* prop = m_matlabParamToPropery.value(property, 0)) { - QWorkspaceAttribute c = m_values[prop]; - c.SetMatlabParam(value); - q_ptr->setValue(prop, c); - } else if (QtProperty* prop = m_wavePathToPropery.value(property, 0)) { - QWorkspaceAttribute c = m_values[prop]; - c.SetWavePath(value); - q_ptr->setValue(prop, c); - } else if (QtProperty* prop = m_reportPathToPropery.value(property, 0)) { - QWorkspaceAttribute c = m_values[prop]; - c.SetReportPath(value); - q_ptr->setValue(prop, c); - } else if (QtProperty* prop = m_rdPathToPropery.value(property, 0)) { - QWorkspaceAttribute c = m_values[prop]; - c.SetRDPath(value); + c.SetCommondFilePath(value); q_ptr->setValue(prop, c); } else if (QtProperty* prop = m_commondPathToPropery.value(property, 0)) { QWorkspaceAttribute c = m_values[prop]; @@ -8230,11 +8214,6 @@ void QtWorkspacePropertyManager::setValue(QtProperty* property, const QWorkspace d_ptr->m_stringProperyManager->setValue(d_ptr->m_properyToName[property], value.GetName()); d_ptr->m_stringProperyManager->setValue(d_ptr->m_properyToDescription[property], value.GetDescription()); d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToTimestep[property], value.GetTimeStep()); - d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToSimMatlab[property], value.GetSimMatlab()); - d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToMatlabParam[property], value.GetMatlabParam()); - d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToWavePath[property], value.GetWavePath()); - d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToReportPath[property], value.GetReportPath()); - d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToRDPath[property], value.GetRDPath()); d_ptr->m_filesProperyManager->setValue(d_ptr->m_properyToCommondPath[property], value.GetCommondFilePath()); auto syncGroup = [&](FileEntryType type, @@ -8323,40 +8302,7 @@ void QtWorkspacePropertyManager::initializeProperty(QtProperty* property) { d_ptr->m_timestepToPropery[prop] = property; property->addSubProperty(prop); - prop = d_ptr->m_filesProperyManager->addProperty(); - prop->setPropertyName(tr("SimMatlab")); - d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetSimMatlab()); - d_ptr->m_properyToSimMatlab[property] = prop; - d_ptr->m_simMatlabToPropery[prop] = property; - property->addSubProperty(prop); - - prop = d_ptr->m_filesProperyManager->addProperty(); - prop->setPropertyName(tr("MatlabParam")); - d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetMatlabParam()); - d_ptr->m_properyToMatlabParam[property] = prop; - d_ptr->m_matlabParamToPropery[prop] = property; - property->addSubProperty(prop); - - prop = d_ptr->m_filesProperyManager->addProperty(); - prop->setPropertyName(tr("WavePath")); - d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetWavePath()); - d_ptr->m_properyToWavePath[property] = prop; - d_ptr->m_wavePathToPropery[prop] = property; - property->addSubProperty(prop); - - prop = d_ptr->m_filesProperyManager->addProperty(); - prop->setPropertyName(tr("ReportPath")); - d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetReportPath()); - d_ptr->m_properyToReportPath[property] = prop; - d_ptr->m_reportPathToPropery[prop] = property; - property->addSubProperty(prop); - - prop = d_ptr->m_filesProperyManager->addProperty(); - prop->setPropertyName(tr("RDPath")); - d_ptr->m_filesProperyManager->setValueOnly(prop, val.GetRDPath()); - d_ptr->m_properyToRDPath[property] = prop; - d_ptr->m_rdPathToPropery[prop] = property; - property->addSubProperty(prop); + // Deprecated properties (SimMatlab/MatlabParam/WavePath/ReportPath/RDPath) removed from UI // Command XML path prop = d_ptr->m_filesProperyManager->addProperty(); diff --git a/src/ui/PropertyBrowser/qtworkspaceattribute.cpp b/src/ui/PropertyBrowser/qtworkspaceattribute.cpp index 6ef94bee..04a275c9 100644 --- a/src/ui/PropertyBrowser/qtworkspaceattribute.cpp +++ b/src/ui/PropertyBrowser/qtworkspaceattribute.cpp @@ -91,88 +91,7 @@ const QString QWorkspaceAttribute::GetTimeStep() const { return timestep->GetPath(); } -void QWorkspaceAttribute::SetSimMatlab(const QString& path) { - if (nullptr == workspace_) { - return; - } - - workspace_->SetSimMatlab(path); -} - -const QString QWorkspaceAttribute::GetSimMatlab() const { - if (nullptr == workspace_) { - return ""; - } - return workspace_->GetSimMatlab(); -} - -void QWorkspaceAttribute::SetMatlabParam(const QString& path) -{ - if (nullptr == workspace_) { - return; - } - - workspace_->SetMatlabParam(path); -} - -const QString QWorkspaceAttribute::GetMatlabParam() const -{ - if (nullptr == workspace_) { - return ""; - } - return workspace_->GetMatlabParam(); -} - -void QWorkspaceAttribute::SetWavePath(const QString& path) -{ - if (nullptr == workspace_) { - return; - } - - workspace_->SetWavePath(path); -} - -const QString QWorkspaceAttribute::GetWavePath() const -{ - if (nullptr == workspace_) { - return ""; - } - return workspace_->GetWavePath(); -} - -void QWorkspaceAttribute::SetReportPath(const QString& path) -{ - if (nullptr == workspace_) { - return; - } - - workspace_->SetReportPath(path); -} - -const QString QWorkspaceAttribute::GetReportPath() const -{ - if (nullptr == workspace_) { - return ""; - } - return workspace_->GetReportPath(); -} - -void QWorkspaceAttribute::SetRDPath(const QString& path) -{ - if (nullptr == workspace_) { - return; - } - - workspace_->SetRDPath(path); -} - -const QString QWorkspaceAttribute::GetRDPath() const -{ - if (nullptr == workspace_) { - return ""; - } - return workspace_->GetRDPath(); -} +// Deprecated workspace path setters/getters removed void QWorkspaceAttribute::SetCommondFilePath(const QString& path) { diff --git a/src/ui/PropertyBrowser/qtworkspaceattribute.h b/src/ui/PropertyBrowser/qtworkspaceattribute.h index 7efdc1a6..8970da9c 100644 --- a/src/ui/PropertyBrowser/qtworkspaceattribute.h +++ b/src/ui/PropertyBrowser/qtworkspaceattribute.h @@ -65,20 +65,7 @@ public: void SetTimeStep(const QString& timestep); const QString GetTimeStep() const; - void SetSimMatlab(const QString& path); - const QString GetSimMatlab() const; - - void SetMatlabParam(const QString& path); - const QString GetMatlabParam() const; - - void SetWavePath(const QString& path); - const QString GetWavePath() const; - - void SetReportPath(const QString& path); - const QString GetReportPath() const; - - void SetRDPath(const QString& path); - const QString GetRDPath() const; + // Deprecated fields removed: SimMatlab/MatlabParam/WavePath/ReportPath/RDPath // Command XML path void SetCommondFilePath(const QString& path); diff --git a/src/workspace/WorkSpace.cpp b/src/workspace/WorkSpace.cpp index 9ec1825d..aedda10d 100644 --- a/src/workspace/WorkSpace.cpp +++ b/src/workspace/WorkSpace.cpp @@ -55,69 +55,7 @@ void WorkSpace::SetCommondFilePath(const QString& path) { commondPath_ = fileInfo.fileName(); } -void WorkSpace::SetSimMatlab(const QString& path) { - QFileInfo fileInfo(path); - QString dirPath = QString("%1/%2").arg(GetDir(), fileInfo.fileName()); - bool sucess = FileUtils::CopyFileToPath(path, dirPath, true); - LOG_INFO("copy simmatlab file {}: {} to {}", - path.toLocal8Bit().data(), - dirPath.toLocal8Bit().data(), - sucess); - simMatlabPath_ = fileInfo.fileName(); -} - -const QString WorkSpace::GetSimMatlab() const { - QString path = QString("%1/%2").arg(GetDir(), simMatlabPath_); - return path; -} - -void WorkSpace::SetWavePath(const QString& path) -{ - QFileInfo fileInfo(path); - QString dirPath = QString("%1/%2").arg(GetDir(), fileInfo.fileName()); - bool sucess = FileUtils::CopyFileToPath(path, dirPath, true); - LOG_INFO("copy Wave file {}: {} to {}", - path.toLocal8Bit().data(), - dirPath.toLocal8Bit().data(), - sucess); - waveFile_ = fileInfo.fileName(); -} - -const QString WorkSpace::GetWavePath() const -{ - QString path = QString("%1/%2").arg(GetDir(), waveFile_); - return path; -} - -void WorkSpace::SetReportPath(const QString& path) -{ - QFileInfo fileInfo(path); - QString dirPath = QString("%1/%2").arg(GetDir(), fileInfo.fileName()); - bool sucess = FileUtils::CopyFileToPath(path, dirPath, true); - LOG_INFO("copy Wave file {}: {} to {}", - path.toLocal8Bit().data(), - dirPath.toLocal8Bit().data(), - sucess); - reportFile_ = fileInfo.fileName(); -} - -const QString WorkSpace::GetReportPath() const -{ - QString path = QString("%1/%2").arg(GetDir(), reportFile_); - return path; -} - -void WorkSpace::SetRDPath(const QString& path) -{ - QFileInfo fileInfo(path); - QString dirPath = QString("%1/%2").arg(GetDir(), fileInfo.fileName()); - bool sucess = FileUtils::CopyFileToPath(path, dirPath, true); - LOG_INFO("copy RD file {}: {} to {}", - path.toLocal8Bit().data(), - dirPath.toLocal8Bit().data(), - sucess); - rdFile_ = fileInfo.fileName(); -} +// Deprecated path APIs removed WorkSpace::FileEntryResult WorkSpace::SetFileEntry(std::shared_ptr fileEntry, bool is_copy) { if (!fileEntry) { @@ -253,11 +191,7 @@ QString WorkSpace::GetFileEntryAbsPath(FileEntryType type, int index) const { return QString("%1/%2").arg(GetDir(), name); } -const QString WorkSpace::GetRDPath() const -{ - QString path = QString("%1/%2").arg(GetDir(), rdFile_); - return path; -} +// RDPath API removed void WorkSpace::AddEntity(Entity* entity) { if (nullptr == entity) { diff --git a/src/workspace/WorkSpace.h b/src/workspace/WorkSpace.h index 0ac701c9..a2e5f724 100644 --- a/src/workspace/WorkSpace.h +++ b/src/workspace/WorkSpace.h @@ -60,24 +60,7 @@ public: enum class CommandWhen { OnCreate, OnLoad }; void ExecuteCommands(CommandWhen when); - void SetSimMatlab(const QString& path); - const QString GetSimMatlab() const; - - inline void SetMatlabParam(const QString& path) { - matlabParamPath_ = path; - } - inline const QString GetMatlabParam() const { - return matlabParamPath_; - } - - void SetWavePath(const QString& path); - const QString GetWavePath() const; - - void SetReportPath(const QString& path) ; - const QString GetReportPath() const; - - void SetRDPath(const QString& path); - const QString GetRDPath() const; + // Deprecated path APIs removed: SimMatlab/MatlabParam/Wave/Report/RD // Files list API (per-type, max 9 per type) enum class FileEntryResult { Ok, LimitExceeded, Duplicate, CopyFailed, TypeMismatch, InvalidFile }; @@ -142,7 +125,7 @@ public: void OnFrame(double dt); void End(); - void OnLoaded(); + void OnLoaded(); Q_SIGNALS: void EntityAdded(class Entity* entity); @@ -151,25 +134,15 @@ Q_SIGNALS: void LampStatusChanged(class LampStatus* lampStatus); void FilesChanged(FileEntryType type, std::shared_ptr fileEntry); -protected: - const QString& GetSimMatlabName() const { - return simMatlabPath_; - } - private: - QString name_; - QString uuid_; - QString describe_; - QString path_; - QString commondPath_; - QString simMatlabPath_; + QString name_; + QString uuid_; + QString describe_; + QString path_; + QString commondPath_; + // Removed deprecated path members: simMatlabPath_, waveFile_, reportFile_, rdFile_, matlabParamPath_ - QString waveFile_; - QString reportFile_; - QString rdFile_; - QString matlabParamPath_; - - osgEarth::Viewpoint homeViewpoint_; + osgEarth::Viewpoint homeViewpoint_; bool leaded_{ false }; std::vector entities_; diff --git a/src/workspace/WorkSpaceXMLParse.cpp b/src/workspace/WorkSpaceXMLParse.cpp index 6e4f98fe..207fb69e 100644 --- a/src/workspace/WorkSpaceXMLParse.cpp +++ b/src/workspace/WorkSpaceXMLParse.cpp @@ -183,112 +183,6 @@ bool WorkSpaceXMLParse::ParseEntities(const tinyxml2::XMLElement* element) { return false; } -bool WorkSpaceXMLParse::ParseChart(const tinyxml2::XMLElement* element) -{ - if (nullptr == element) { - LOG_WARN("element is nullptr"); - return false; - } - - const tinyxml2::XMLElement* xmlElement = element->FirstChildElement(); - while (nullptr != xmlElement) { - const char* name = xmlElement->Name(); - if (0 == strcmp(name, "Wave")) - { - QVariantMap varChart; - const tinyxml2::XMLAttribute* attribute = xmlElement->FirstAttribute(); - while (nullptr != attribute) { - - workSpace_->SetWavePath(QString::fromLocal8Bit(attribute->Value())); - attribute = attribute->Next(); - } - } - else if (0 == strcmp(name, "Report")) - { - QVariantMap varChart; - const tinyxml2::XMLAttribute* attribute = xmlElement->FirstAttribute(); - while (nullptr != attribute) { - - workSpace_->SetReportPath(QString::fromLocal8Bit(attribute->Value())); - attribute = attribute->Next(); - } - } - else if (0 == strcmp(name, "RD")) - { - QVariantMap varChart; - const tinyxml2::XMLAttribute* attribute = xmlElement->FirstAttribute(); - while (nullptr != attribute) { - - workSpace_->SetRDPath(QString::fromLocal8Bit(attribute->Value())); - attribute = attribute->Next(); - } - } - else if (0 == strcmp(name, "SimMatlab")) - { - QVariantMap varChart; - const tinyxml2::XMLAttribute* attribute = xmlElement->FirstAttribute(); - while (nullptr != attribute) { - - workSpace_->SetSimMatlab(QString::fromLocal8Bit(attribute->Value())); - attribute = attribute->Next(); - } - } - - xmlElement = xmlElement->NextSiblingElement(); - } - - return true; -} - -bool WorkSpaceXMLParse::ParseSimMatlab(const tinyxml2::XMLElement* element) -{ - if (nullptr == element) { - LOG_WARN("element is nullptr"); - return false; - } - - const tinyxml2::XMLElement* xmlElement = element->FirstChildElement(); - while (nullptr != xmlElement) { - const char* name = xmlElement->Name(); - if (0 == strcmp(name, "SimMatlab")) - { - QVariantMap varChart; - const tinyxml2::XMLAttribute* attribute = xmlElement->FirstAttribute(); - while (nullptr != attribute) { - - WorkSpaceManager::Get().GetCurrent()->SetSimMatlab(QString::fromLocal8Bit(attribute->Value())); - attribute = attribute->Next(); - } - } - - xmlElement = xmlElement->NextSiblingElement(); - } - - return true; -} - -bool WorkSpaceXMLParse::ParseReport(const tinyxml2::XMLElement* element) -{ - QString strFile = ""; - int iBatch = 0; - - const tinyxml2::XMLAttribute* attribute = element->FirstAttribute(); - while (nullptr != attribute) { - if (0 == strcmp(attribute->Name(), "file")) - { - strFile = QString::fromLocal8Bit(attribute->Value()); - } - else if (0 == strcmp(attribute->Name(), "batch")) - { - iBatch = atoi(attribute->Value()); - } - - attribute = attribute->Next(); - } - - return true; -} - bool WorkSpaceXMLParse::Load(const QString& dyt) { std::string path = dyt.toLocal8Bit().constData(); LOG_INFO("load path:{}", path); @@ -315,17 +209,7 @@ bool WorkSpaceXMLParse::Load(const QString& dyt) { ParseLamp(xmlElement); } else if (0 == strcmp(name, "commond")) { ParseCommond(xmlElement); - } - else if (0 == strcmp(name, "charts")) { - ParseChart(xmlElement); - } - else if (0 == strcmp(name, "ReportInfo")) { - ParseReport(xmlElement); - } - else if (0 == strcmp(name, "SimMatlab")) { - ParseSimMatlab(xmlElement); - } - else if (0 == strcmp(name, "files")) { + } else if (0 == strcmp(name, "files")) { ParseFiles(xmlElement); } xmlElement = xmlElement->NextSiblingElement(); diff --git a/src/workspace/WorkSpaceXMLParse.h b/src/workspace/WorkSpaceXMLParse.h index 8a52bf91..cb2aed81 100644 --- a/src/workspace/WorkSpaceXMLParse.h +++ b/src/workspace/WorkSpaceXMLParse.h @@ -33,9 +33,6 @@ private: bool ParseLamp(const tinyxml2::XMLElement* element); bool ParseCommond(const tinyxml2::XMLElement* element); bool ParseEntities(const tinyxml2::XMLElement* element); - bool ParseChart(const tinyxml2::XMLElement* element); - bool ParseReport(const tinyxml2::XMLElement* element); - bool ParseSimMatlab(const tinyxml2::XMLElement* element); bool ParseFiles(const tinyxml2::XMLElement* element); private: diff --git a/src/workspace/WorkSpaceXMLWrite.cpp b/src/workspace/WorkSpaceXMLWrite.cpp index b6121793..1a6170fa 100644 --- a/src/workspace/WorkSpaceXMLWrite.cpp +++ b/src/workspace/WorkSpaceXMLWrite.cpp @@ -110,36 +110,9 @@ bool WorkSpaceXMLWrite::SaveEntities(tinyxml2::XMLElement* scene, tinyxml2::XMLD bool WorkSpaceXMLWrite::SaveChart(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc) { - tinyxml2::XMLElement* charts= doc->NewElement("charts"); + // charts section retained for compatibility, but deprecated entries (Wave, Report, RD, SimMatlab) are no longer saved + tinyxml2::XMLElement* charts = doc->NewElement("charts"); scene->LinkEndChild(charts); - - { - tinyxml2::XMLElement* chart = doc->NewElement("Wave"); - charts->LinkEndChild(chart); - - chart->SetAttribute("file", workSpace_->GetWavePath().toLocal8Bit().constData()); - } - - { - tinyxml2::XMLElement* chart = doc->NewElement("Report"); - charts->LinkEndChild(chart); - - chart->SetAttribute("Report", workSpace_->GetReportPath().toLocal8Bit().constData()); - } - - { - tinyxml2::XMLElement* chart = doc->NewElement("RD"); - charts->LinkEndChild(chart); - - chart->SetAttribute("RD", workSpace_->GetRDPath().toLocal8Bit().constData()); - } - - { - tinyxml2::XMLElement* chart = doc->NewElement("SimMatlab"); - charts->LinkEndChild(chart); - - chart->SetAttribute("SimMatlab", workSpace_->GetSimMatlabName().toLocal8Bit().constData()); - } return true; }