Compare commits

..

No commits in common. "f65ea8dcd8fcb87263fb85fc2ab6e27bc72ed122" and "0b5fa3746acba2d8f55e11eb84b5299ef0be65b8" have entirely different histories.

14 changed files with 641 additions and 86 deletions

View File

@ -25,27 +25,11 @@ 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)
if(UPDATE_TRANSLATIONS)
# lupdate + lrelease TS QM
qt6_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
else()
# QMTS
qt_add_translations(QM_FILES TS_FILES ${TS_FILES})
endif()
qt6_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
add_custom_target(translations DEPENDS ${QM_FILES})
else()
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()
qt5_create_translation(QM_FILES ${CMAKE_CURRENT_SOURCE_DIR} ${TS_FILES})
add_custom_target(translations DEPENDS ${QM_FILES})
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS WinExtras REQUIRED)
endif()

View File

@ -126,6 +126,7 @@ 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);

View File

@ -140,3 +140,20 @@ 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();
}
}
}

View File

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

View File

@ -1,4 +1,4 @@
#include "ChartPlotMenu.h"
#include "ChartPlotMenu.h"
#include "../Matlab/MatlabObject.h"
#include "../../common/RecourceHelper.h"
@ -9,7 +9,6 @@
#include <qmessagebox.h>
#include <qfiledialog.h>
#include <QDir>
ChartPlotMenu::ChartPlotMenu(QWidget *parent)
: QWidget(parent)
@ -26,35 +25,217 @@ ChartPlotMenu::~ChartPlotMenu()
void ChartPlotMenu::InitMenu()
{
// Deprecated: SimMatlab run action removed
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 selection 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: Wave file 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: 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 文件失败"));
}
});
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);
});
}

View File

@ -18,9 +18,6 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="toolButton_5">
<property name="visible">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>60</width>
@ -34,9 +31,6 @@
</item>
<item>
<widget class="QToolButton" name="toolButton_4">
<property name="visible">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>60</width>
@ -50,9 +44,6 @@
</item>
<item>
<widget class="QToolButton" name="toolButton_3">
<property name="visible">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>60</width>
@ -66,9 +57,6 @@
</item>
<item>
<widget class="QToolButton" name="toolButton_2">
<property name="visible">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>60</width>
@ -82,9 +70,6 @@
</item>
<item>
<widget class="QToolButton" name="toolButton_6">
<property name="visible">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>60</width>
@ -98,9 +83,6 @@
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="visible">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>60</width>

View File

@ -7991,9 +7991,25 @@ void QtWorkspacePropertyManagerPrivate::slotStringChanged(QtProperty* property,
QWorkspaceAttribute c = m_values[prop];
c.SetTimeStep(value);
q_ptr->setValue(prop, c);
} else if (QtProperty* prop = m_commondPathToPropery.value(property, 0)) {
} else if (QtProperty* prop = m_simMatlabToPropery.value(property, 0)) {
QWorkspaceAttribute c = m_values[prop];
c.SetCommondFilePath(value);
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);
q_ptr->setValue(prop, c);
} else if (QtProperty* prop = m_commondPathToPropery.value(property, 0)) {
QWorkspaceAttribute c = m_values[prop];
@ -8214,6 +8230,11 @@ 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,
@ -8302,7 +8323,40 @@ void QtWorkspacePropertyManager::initializeProperty(QtProperty* property) {
d_ptr->m_timestepToPropery[prop] = property;
property->addSubProperty(prop);
// Deprecated properties (SimMatlab/MatlabParam/WavePath/ReportPath/RDPath) removed from UI
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);
// Command XML path
prop = d_ptr->m_filesProperyManager->addProperty();

View File

@ -91,7 +91,88 @@ const QString QWorkspaceAttribute::GetTimeStep() const {
return timestep->GetPath();
}
// Deprecated workspace path setters/getters removed
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();
}
void QWorkspaceAttribute::SetCommondFilePath(const QString& path)
{

View File

@ -65,7 +65,20 @@ public:
void SetTimeStep(const QString& timestep);
const QString GetTimeStep() const;
// Deprecated fields removed: SimMatlab/MatlabParam/WavePath/ReportPath/RDPath
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;
// Command XML path
void SetCommondFilePath(const QString& path);

View File

@ -55,7 +55,69 @@ void WorkSpace::SetCommondFilePath(const QString& path) {
commondPath_ = fileInfo.fileName();
}
// Deprecated path APIs removed
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();
}
WorkSpace::FileEntryResult WorkSpace::SetFileEntry(std::shared_ptr<FileEntry> fileEntry, bool is_copy) {
if (!fileEntry) {
@ -191,7 +253,11 @@ QString WorkSpace::GetFileEntryAbsPath(FileEntryType type, int index) const {
return QString("%1/%2").arg(GetDir(), name);
}
// RDPath API removed
const QString WorkSpace::GetRDPath() const
{
QString path = QString("%1/%2").arg(GetDir(), rdFile_);
return path;
}
void WorkSpace::AddEntity(Entity* entity) {
if (nullptr == entity) {

View File

@ -60,7 +60,24 @@ public:
enum class CommandWhen { OnCreate, OnLoad };
void ExecuteCommands(CommandWhen when);
// Deprecated path APIs removed: SimMatlab/MatlabParam/Wave/Report/RD
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;
// Files list API (per-type, max 9 per type)
enum class FileEntryResult { Ok, LimitExceeded, Duplicate, CopyFailed, TypeMismatch, InvalidFile };
@ -125,7 +142,7 @@ public:
void OnFrame(double dt);
void End();
void OnLoaded();
void OnLoaded();
Q_SIGNALS:
void EntityAdded(class Entity* entity);
@ -134,15 +151,25 @@ Q_SIGNALS:
void LampStatusChanged(class LampStatus* lampStatus);
void FilesChanged(FileEntryType type, std::shared_ptr<FileEntry> fileEntry);
private:
QString name_;
QString uuid_;
QString describe_;
QString path_;
QString commondPath_;
// Removed deprecated path members: simMatlabPath_, waveFile_, reportFile_, rdFile_, matlabParamPath_
protected:
const QString& GetSimMatlabName() const {
return simMatlabPath_;
}
osgEarth::Viewpoint homeViewpoint_;
private:
QString name_;
QString uuid_;
QString describe_;
QString path_;
QString commondPath_;
QString simMatlabPath_;
QString waveFile_;
QString reportFile_;
QString rdFile_;
QString matlabParamPath_;
osgEarth::Viewpoint homeViewpoint_;
bool leaded_{ false };
std::vector<class Entity*> entities_;

View File

@ -183,6 +183,112 @@ 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);
@ -209,7 +315,17 @@ bool WorkSpaceXMLParse::Load(const QString& dyt) {
ParseLamp(xmlElement);
} else if (0 == strcmp(name, "commond")) {
ParseCommond(xmlElement);
} else if (0 == strcmp(name, "files")) {
}
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")) {
ParseFiles(xmlElement);
}
xmlElement = xmlElement->NextSiblingElement();

View File

@ -33,6 +33,9 @@ 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:

View File

@ -110,9 +110,36 @@ bool WorkSpaceXMLWrite::SaveEntities(tinyxml2::XMLElement* scene, tinyxml2::XMLD
bool WorkSpaceXMLWrite::SaveChart(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc)
{
// charts section retained for compatibility, but deprecated entries (Wave, Report, RD, SimMatlab) are no longer saved
tinyxml2::XMLElement* charts = doc->NewElement("charts");
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;
}