diff --git a/src/translations/Dyt_zh_CN.ts b/src/translations/Dyt_zh_CN.ts index b6a4a1c6..21ae8592 100644 --- a/src/translations/Dyt_zh_CN.ts +++ b/src/translations/Dyt_zh_CN.ts @@ -19,7 +19,7 @@ - + Select curve data file... @@ -90,32 +90,32 @@ - + X Min: - + X Max: - + Y Min: - + Y Max: - + X Tick Count: - + Curve Name: @@ -125,122 +125,72 @@ - + + Y Tick Count: + + + + Curve Management - + Curves: - + Add Curve - + Remove - + Selected Curve Properties - + Enter curve name... - + Curve Color: - + Select Color - + background-color: rgb(255, 0, 0); border: 1px solid black; - + Data Start: - + Data Stop: - - Data Format Parameters - - - - - X Column: - - - - - Y Column: - - - - - Separator: - - - - - Comma (,) - - - - - Tab - - - - - Space - - - - - Semicolon (;) - - - - - File has header row - - - - - Description (Optional) - - - - - Enter file description... - - - - + Add File - + Cancel @@ -268,11 +218,8 @@ - - - - - + + Validation Error @@ -367,69 +314,54 @@ - - X column and Y column cannot be the same. - - - - - Data column indices must be greater than 0. - - - - + Time parameter cannot be negative. - + X axis tick count must be at least 2. - - Description is too long. Please limit to 500 characters. - - - - - - + + + Error - + Failed to create file entry - + Unable to get current workspace - + Curve file count has reached the limit (9 files) - + File already exists - + File copy failed - + Invalid file - + Failed to add file diff --git a/src/ui/Panel/CurvePanel.cpp b/src/ui/Panel/CurvePanel.cpp index 8c2f32ac..311bf5cb 100644 --- a/src/ui/Panel/CurvePanel.cpp +++ b/src/ui/Panel/CurvePanel.cpp @@ -14,7 +14,6 @@ CurvePanel::CurvePanel(int index, const QString& filePath, QWidget* parent) : DataPanel(index, FileEntryType::Curve, filePath, parent) - , hasChartData_(false) { m_iXMin = 0; m_iXMax = 0; @@ -24,15 +23,13 @@ CurvePanel::CurvePanel(int index, const QString& filePath, QWidget* parent) LOG_INFO("Created CurvePanel {} for file: {}", index, filePath.toStdString()); } -CurvePanel::CurvePanel(int index, std::shared_ptr chartData, QWidget* parent) - : DataPanel(index, FileEntryType::Curve, chartData ? chartData->path : QString(), parent) - , chartData_(chartData) - , hasChartData_(chartData != nullptr) +CurvePanel::CurvePanel(int index, std::shared_ptr fileEntry, QWidget* parent) + : DataPanel(index, fileEntry, parent) { - if (chartData) { - LOG_INFO("Created CurvePanel {} for chart: {}", index, chartData->name.toStdString()); + if (fileEntry) { + LOG_INFO("Created CurvePanel {} for chart: {}", index, fileEntry->GetName().toStdString()); // Override the title with chart name - title_ = QString("Curve Panel %1 - %2").arg(index).arg(chartData->name); + title_ = QString("Curve Panel %1 - %2").arg(index).arg(fileEntry->GetName()); } else { LOG_WARN("Created CurvePanel {} with null chart data", index); } @@ -48,38 +45,20 @@ void CurvePanel::RefreshPanel() // Implement curve-specific refresh logic here DataPanel::RefreshPanel(); - if (auto fileEntry = std::dynamic_pointer_cast(fileEntry_)) { - OnDataPanelUpdated(fileEntry.get()); + if (auto fileEntry = fileEntry_->AsCurve()) { + OnDataPanelUpdated(fileEntry); } - if (hasChartData_) { + if (IsValid()) { UpdateCurveDisplay(); } LOG_INFO("Refreshed CurvePanel {}", GetIndex()); } -void CurvePanel::SetChartData(std::shared_ptr chartData) -{ - chartData_ = chartData; - hasChartData_ = (chartData != nullptr); - - if (chartData) { - // Update title - title_ = QString("Curve Panel %1 - %2").arg(GetIndex()).arg(chartData->name); - - // Refresh the display - UpdateCurveDisplay(); - - LOG_INFO("Set chart data for CurvePanel {}: {}", GetIndex(), chartData->name.toStdString()); - } else { - LOG_WARN("Set null chart data for CurvePanel {}", GetIndex()); - } -} - void CurvePanel::UpdateCurveDisplay() { - if (!hasChartData_ || !chartData_) { + if (!IsValid()) { return; } @@ -97,197 +76,203 @@ void CurvePanel::UpdateCurveDisplay() QVBoxLayout* mainLayout = new QVBoxLayout(this); // Chart info section - QGroupBox* chartInfoGroup = new QGroupBox(QString("Chart: %1").arg(chartData_->name)); + QGroupBox* chartInfoGroup = new QGroupBox(QString("Chart: %1").arg(fileEntry_->GetName())); QVBoxLayout* chartInfoLayout = new QVBoxLayout(chartInfoGroup); // Chart details - handle different chart types - QLabel* pathLabel = new QLabel(QString("File: %1").arg(QFileInfo(chartData_->path).fileName())); + QLabel* pathLabel = new QLabel(QString("File: %1").arg(fileEntry_->GetFileName())); chartInfoLayout->addWidget(pathLabel); + auto chartProperties = fileEntry_->AsCurve()->GetChartProperties(); // Type-specific information - if (auto curveChart = std::dynamic_pointer_cast(chartData_)) { - QLabel* titleLabel = new QLabel(QString("Title: X=%1, Y=%2").arg(curveChart->xTitle, curveChart->yTitle)); - QLabel* rangeLabel = new QLabel(QString("Range: X[%1-%2], Y[%3-%4]") - .arg(curveChart->xMin).arg(curveChart->xMax) - .arg(curveChart->yMin).arg(curveChart->yMax)); - QLabel* countLabel = new QLabel(QString("Count: X=%1, T=%2").arg(curveChart->xCount).arg(curveChart->t)); + QLabel* titleLabel = new QLabel(QString("Title: X=%1, Y=%2").arg(chartProperties.xTitle, chartProperties.yTitle)); + QLabel* rangeLabel = new QLabel(QString("Range: X[%1-%2], Y[%3-%4]") + .arg(chartProperties.xMin).arg(chartProperties.xMax) + .arg(chartProperties.yMin).arg(chartProperties.yMax)); + QLabel* countLabel = new QLabel(QString("Count: X=%1, T=%2").arg(chartProperties.xCount).arg(chartProperties.timeParam)); + + chartInfoLayout->addWidget(titleLabel); + chartInfoLayout->addWidget(rangeLabel); + chartInfoLayout->addWidget(countLabel); + + // Curves section + const auto& curveProperties = fileEntry_->AsCurve()->GetCurveProperties(); + if (!curveProperties.isEmpty()) { + QGroupBox* curvesGroup = new QGroupBox(QString("Curves (%1)").arg(curveProperties.size())); + QVBoxLayout* curvesLayout = new QVBoxLayout(curvesGroup); - chartInfoLayout->addWidget(titleLabel); - chartInfoLayout->addWidget(rangeLabel); - chartInfoLayout->addWidget(countLabel); + // Add scroll area for curves + QScrollArea* scrollArea = new QScrollArea(); + QWidget* scrollWidget = new QWidget(); + QVBoxLayout* scrollLayout = new QVBoxLayout(scrollWidget); - // Curves section - if (!curveChart->curves.isEmpty()) { - QGroupBox* curvesGroup = new QGroupBox(QString("Curves (%1)").arg(curveChart->curves.size())); - QVBoxLayout* curvesLayout = new QVBoxLayout(curvesGroup); + for (const auto& curve : curveProperties) { + QHBoxLayout* curveLayout = new QHBoxLayout(); - // Add scroll area for curves - QScrollArea* scrollArea = new QScrollArea(); - QWidget* scrollWidget = new QWidget(); - QVBoxLayout* scrollLayout = new QVBoxLayout(scrollWidget); + // Curve checkbox for show/hide + QCheckBox* curveCheckBox = new QCheckBox(curve.name); + curveCheckBox->setChecked(true); - for (const CurveData& curve : curveChart->curves) { - QHBoxLayout* curveLayout = new QHBoxLayout(); - - // Curve checkbox for show/hide - QCheckBox* curveCheckBox = new QCheckBox(curve.name); - curveCheckBox->setChecked(true); - - // Curve info - QLabel* curveInfo = new QLabel(QString("Range: %1-%2, Color: %3") - .arg(curve.start).arg(curve.stop).arg(curve.color)); - curveInfo->setStyleSheet(QString("QLabel { color: rgb(%1); }").arg(curve.color)); - - curveLayout->addWidget(curveCheckBox); - curveLayout->addWidget(curveInfo); - curveLayout->addStretch(); - - scrollLayout->addLayout(curveLayout); - } + // Curve info + QString colorStr = QString("rgb(%1,%2,%3)").arg(curve.color.red()).arg(curve.color.green()).arg(curve.color.blue()); + QLabel* curveInfo = new QLabel(QString("Range: %1-%2, Color: %3") + .arg(curve.start).arg(curve.stop).arg(colorStr)); + curveInfo->setStyleSheet(QString("QLabel { color: %1; }").arg(colorStr)); - scrollWidget->setLayout(scrollLayout); - scrollArea->setWidget(scrollWidget); - scrollArea->setWidgetResizable(true); - scrollArea->setMaximumHeight(200); + curveLayout->addWidget(curveCheckBox); + curveLayout->addWidget(curveInfo); + curveLayout->addStretch(); - curvesLayout->addWidget(scrollArea); - mainLayout->addWidget(curvesGroup); + scrollLayout->addLayout(curveLayout); } - } else if (auto surfaceChart = std::dynamic_pointer_cast(chartData_)) { - QLabel* titleLabel = new QLabel(QString("Title: X=%1, Y=%2, Z=%3") - .arg(surfaceChart->xTitle, surfaceChart->yTitle, surfaceChart->zTitle)); - QLabel* rangeLabel = new QLabel(QString("Range: X[%1-%2], Y[%3-%4], Z[%5-%6]") - .arg(surfaceChart->xMin).arg(surfaceChart->xMax) - .arg(surfaceChart->yMin).arg(surfaceChart->yMax) - .arg(surfaceChart->zMin).arg(surfaceChart->zMax)); - QLabel* countLabel = new QLabel(QString("Count: X=%1, Y=%2, Z=%3, T=%4") - .arg(surfaceChart->xCount).arg(surfaceChart->yCount) - .arg(surfaceChart->zCount).arg(surfaceChart->t)); + scrollWidget->setLayout(scrollLayout); + scrollArea->setWidget(scrollWidget); + scrollArea->setWidgetResizable(true); + scrollArea->setMaximumHeight(200); - chartInfoLayout->addWidget(titleLabel); - chartInfoLayout->addWidget(rangeLabel); - chartInfoLayout->addWidget(countLabel); - - // Surface curves section - if (!surfaceChart->curves.isEmpty()) { - QGroupBox* curvesGroup = new QGroupBox(QString("Surface Curves (%1)").arg(surfaceChart->curves.size())); - QVBoxLayout* curvesLayout = new QVBoxLayout(curvesGroup); - - QScrollArea* scrollArea = new QScrollArea(); - QWidget* scrollWidget = new QWidget(); - QVBoxLayout* scrollLayout = new QVBoxLayout(scrollWidget); - - for (const SurfaceCurveData& curve : surfaceChart->curves) { - QHBoxLayout* curveLayout = new QHBoxLayout(); - - QCheckBox* curveCheckBox = new QCheckBox(curve.name); - curveCheckBox->setChecked(true); - - QLabel* curveInfo = new QLabel(QString("Range: %1-%2, Color: %3, Pos: (%4,%5,%6)") - .arg(curve.start).arg(curve.stop).arg(curve.color) - .arg(curve.x).arg(curve.y).arg(curve.z)); - curveInfo->setStyleSheet(QString("QLabel { color: rgb(%1); }").arg(curve.color)); - - curveLayout->addWidget(curveCheckBox); - curveLayout->addWidget(curveInfo); - curveLayout->addStretch(); - - scrollLayout->addLayout(curveLayout); - } - - scrollWidget->setLayout(scrollLayout); - scrollArea->setWidget(scrollWidget); - scrollArea->setWidgetResizable(true); - scrollArea->setMaximumHeight(200); - - curvesLayout->addWidget(scrollArea); - mainLayout->addWidget(curvesGroup); - } - - } else if (auto tableChart = std::dynamic_pointer_cast(chartData_)) { - QLabel* headLabel = new QLabel(QString("Head: %1").arg(tableChart->head)); - QLabel* timeLabel = new QLabel(QString("Time: %1").arg(tableChart->t)); - - chartInfoLayout->addWidget(headLabel); - chartInfoLayout->addWidget(timeLabel); - - // Table curves section - if (!tableChart->curves.isEmpty()) { - QGroupBox* curvesGroup = new QGroupBox(QString("Table Data (%1)").arg(tableChart->curves.size())); - QVBoxLayout* curvesLayout = new QVBoxLayout(curvesGroup); - - QScrollArea* scrollArea = new QScrollArea(); - QWidget* scrollWidget = new QWidget(); - QVBoxLayout* scrollLayout = new QVBoxLayout(scrollWidget); - - for (const TableCurveData& curve : tableChart->curves) { - QHBoxLayout* curveLayout = new QHBoxLayout(); - - QCheckBox* curveCheckBox = new QCheckBox(curve.name); - curveCheckBox->setChecked(true); - - QLabel* curveInfo = new QLabel(QString("Color: %1, Data: %2") - .arg(curve.color).arg(curve.data)); - curveInfo->setStyleSheet(QString("QLabel { color: rgb(%1); }").arg(curve.color)); - - curveLayout->addWidget(curveCheckBox); - curveLayout->addWidget(curveInfo); - curveLayout->addStretch(); - - scrollLayout->addLayout(curveLayout); - } - - scrollWidget->setLayout(scrollLayout); - scrollArea->setWidget(scrollWidget); - scrollArea->setWidgetResizable(true); - scrollArea->setMaximumHeight(200); - - curvesLayout->addWidget(scrollArea); - mainLayout->addWidget(curvesGroup); - } - - } else if (auto lightChart = std::dynamic_pointer_cast(chartData_)) { - QLabel* colorLabel = new QLabel(QString("Open Color: %1, Close Color: %2") - .arg(lightChart->openColor).arg(lightChart->closeColor)); - QLabel* timeLabel = new QLabel(QString("Time: %1").arg(lightChart->t)); - - chartInfoLayout->addWidget(colorLabel); - chartInfoLayout->addWidget(timeLabel); - - // Light curves section - if (!lightChart->curves.isEmpty()) { - QGroupBox* curvesGroup = new QGroupBox(QString("Light Data (%1)").arg(lightChart->curves.size())); - QVBoxLayout* curvesLayout = new QVBoxLayout(curvesGroup); - - QScrollArea* scrollArea = new QScrollArea(); - QWidget* scrollWidget = new QWidget(); - QVBoxLayout* scrollLayout = new QVBoxLayout(scrollWidget); - - for (const LightCurveData& curve : lightChart->curves) { - QHBoxLayout* curveLayout = new QHBoxLayout(); - - QCheckBox* curveCheckBox = new QCheckBox(curve.name); - curveCheckBox->setChecked(true); - - QLabel* curveInfo = new QLabel(QString("Data: %1").arg(curve.data)); - - curveLayout->addWidget(curveCheckBox); - curveLayout->addWidget(curveInfo); - curveLayout->addStretch(); - - scrollLayout->addLayout(curveLayout); - } - - scrollWidget->setLayout(scrollLayout); - scrollArea->setWidget(scrollWidget); - scrollArea->setWidgetResizable(true); - scrollArea->setMaximumHeight(200); - - curvesLayout->addWidget(scrollArea); - mainLayout->addWidget(curvesGroup); - } + curvesLayout->addWidget(scrollArea); + mainLayout->addWidget(curvesGroup); } + // if (auto curveChart = std::dynamic_pointer_cast(fileEntry_->chartData)) { + + // } + + // } + // else if (auto surfaceChart = std::dynamic_pointer_cast(chartData_)) { + // QLabel* titleLabel = new QLabel(QString("Title: X=%1, Y=%2, Z=%3") + // .arg(surfaceChart->xTitle, surfaceChart->yTitle, surfaceChart->zTitle)); + // QLabel* rangeLabel = new QLabel(QString("Range: X[%1-%2], Y[%3-%4], Z[%5-%6]") + // .arg(surfaceChart->xMin).arg(surfaceChart->xMax) + // .arg(surfaceChart->yMin).arg(surfaceChart->yMax) + // .arg(surfaceChart->zMin).arg(surfaceChart->zMax)); + // QLabel* countLabel = new QLabel(QString("Count: X=%1, Y=%2, Z=%3, T=%4") + // .arg(surfaceChart->xCount).arg(surfaceChart->yCount) + // .arg(surfaceChart->zCount).arg(surfaceChart->t)); + + // chartInfoLayout->addWidget(titleLabel); + // chartInfoLayout->addWidget(rangeLabel); + // chartInfoLayout->addWidget(countLabel); + + // // Surface curves section + // if (!surfaceChart->curves.isEmpty()) { + // QGroupBox* curvesGroup = new QGroupBox(QString("Surface Curves (%1)").arg(surfaceChart->curves.size())); + // QVBoxLayout* curvesLayout = new QVBoxLayout(curvesGroup); + + // QScrollArea* scrollArea = new QScrollArea(); + // QWidget* scrollWidget = new QWidget(); + // QVBoxLayout* scrollLayout = new QVBoxLayout(scrollWidget); + + // for (const SurfaceCurveData& curve : surfaceChart->curves) { + // QHBoxLayout* curveLayout = new QHBoxLayout(); + + // QCheckBox* curveCheckBox = new QCheckBox(curve.name); + // curveCheckBox->setChecked(true); + + // QLabel* curveInfo = new QLabel(QString("Range: %1-%2, Color: %3, Pos: (%4,%5,%6)") + // .arg(curve.start).arg(curve.stop).arg(curve.color) + // .arg(curve.x).arg(curve.y).arg(curve.z)); + // curveInfo->setStyleSheet(QString("QLabel { color: rgb(%1); }").arg(curve.color)); + + // curveLayout->addWidget(curveCheckBox); + // curveLayout->addWidget(curveInfo); + // curveLayout->addStretch(); + + // scrollLayout->addLayout(curveLayout); + // } + + // scrollWidget->setLayout(scrollLayout); + // scrollArea->setWidget(scrollWidget); + // scrollArea->setWidgetResizable(true); + // scrollArea->setMaximumHeight(200); + + // curvesLayout->addWidget(scrollArea); + // mainLayout->addWidget(curvesGroup); + // } + + // } else if (auto tableChart = std::dynamic_pointer_cast(chartData_)) { + // QLabel* headLabel = new QLabel(QString("Head: %1").arg(tableChart->head)); + // QLabel* timeLabel = new QLabel(QString("Time: %1").arg(tableChart->t)); + + // chartInfoLayout->addWidget(headLabel); + // chartInfoLayout->addWidget(timeLabel); + + // // Table curves section + // if (!tableChart->curves.isEmpty()) { + // QGroupBox* curvesGroup = new QGroupBox(QString("Table Data (%1)").arg(tableChart->curves.size())); + // QVBoxLayout* curvesLayout = new QVBoxLayout(curvesGroup); + + // QScrollArea* scrollArea = new QScrollArea(); + // QWidget* scrollWidget = new QWidget(); + // QVBoxLayout* scrollLayout = new QVBoxLayout(scrollWidget); + + // for (const TableCurveData& curve : tableChart->curves) { + // QHBoxLayout* curveLayout = new QHBoxLayout(); + + // QCheckBox* curveCheckBox = new QCheckBox(curve.name); + // curveCheckBox->setChecked(true); + + // QLabel* curveInfo = new QLabel(QString("Color: %1, Data: %2") + // .arg(curve.color).arg(curve.data)); + // curveInfo->setStyleSheet(QString("QLabel { color: rgb(%1); }").arg(curve.color)); + + // curveLayout->addWidget(curveCheckBox); + // curveLayout->addWidget(curveInfo); + // curveLayout->addStretch(); + + // scrollLayout->addLayout(curveLayout); + // } + + // scrollWidget->setLayout(scrollLayout); + // scrollArea->setWidget(scrollWidget); + // scrollArea->setWidgetResizable(true); + // scrollArea->setMaximumHeight(200); + + // curvesLayout->addWidget(scrollArea); + // mainLayout->addWidget(curvesGroup); + // } + + // } else if (auto lightChart = std::dynamic_pointer_cast(chartData_)) { + // QLabel* colorLabel = new QLabel(QString("Open Color: %1, Close Color: %2") + // .arg(lightChart->openColor).arg(lightChart->closeColor)); + // QLabel* timeLabel = new QLabel(QString("Time: %1").arg(lightChart->t)); + + // chartInfoLayout->addWidget(colorLabel); + // chartInfoLayout->addWidget(timeLabel); + + // // Light curves section + // if (!lightChart->curves.isEmpty()) { + // QGroupBox* curvesGroup = new QGroupBox(QString("Light Data (%1)").arg(lightChart->curves.size())); + // QVBoxLayout* curvesLayout = new QVBoxLayout(curvesGroup); + + // QScrollArea* scrollArea = new QScrollArea(); + // QWidget* scrollWidget = new QWidget(); + // QVBoxLayout* scrollLayout = new QVBoxLayout(scrollWidget); + + // for (const LightCurveData& curve : lightChart->curves) { + // QHBoxLayout* curveLayout = new QHBoxLayout(); + + // QCheckBox* curveCheckBox = new QCheckBox(curve.name); + // curveCheckBox->setChecked(true); + + // QLabel* curveInfo = new QLabel(QString("Data: %1").arg(curve.data)); + + // curveLayout->addWidget(curveCheckBox); + // curveLayout->addWidget(curveInfo); + // curveLayout->addStretch(); + + // scrollLayout->addLayout(curveLayout); + // } + + // scrollWidget->setLayout(scrollLayout); + // scrollArea->setWidget(scrollWidget); + // scrollArea->setWidgetResizable(true); + // scrollArea->setMaximumHeight(200); + + // curvesLayout->addWidget(scrollArea); + // mainLayout->addWidget(curvesGroup); + // } + // } mainLayout->addWidget(chartInfoGroup); @@ -306,22 +291,7 @@ void CurvePanel::UpdateCurveDisplay() void CurvePanel::InitUI() { initQChartView(); - //if (hasChartData_) { - // UpdateCurveDisplay(); - //} else { - // // Create basic layout for file-based panel - // QVBoxLayout* layout = new QVBoxLayout(this); - // - // // Add placeholder label showing panel information - // QLabel* infoLabel = new QLabel(QString("Curve Panel %1\nFile: %2\n\nCurve Drawing Area\nPlease inherit this class to implement specific drawing functionality") - // .arg(GetIndex()) - // .arg(QFileInfo(GetFilePath()).fileName())); - // infoLabel->setAlignment(Qt::AlignCenter); - // infoLabel->setStyleSheet("QLabel { color: #666; font-size: 12px; padding: 20px; }"); - // - // layout->addWidget(infoLabel); - // setLayout(layout); - //} + } QString CurvePanel::GetTypeDisplayName() const diff --git a/src/ui/Panel/CurvePanel.h b/src/ui/Panel/CurvePanel.h index 71f32185..3ecf2d18 100644 --- a/src/ui/Panel/CurvePanel.h +++ b/src/ui/Panel/CurvePanel.h @@ -38,7 +38,7 @@ public: * @param chartData Chart data containing curve information * @param parent Parent widget */ - explicit CurvePanel(int index, std::shared_ptr chartData, QWidget* parent = nullptr); + explicit CurvePanel(int index, std::shared_ptr fileEntry, QWidget* parent = nullptr); /** * @brief Destructor @@ -56,18 +56,6 @@ public: */ void RefreshPanel() override; - /** - * @brief Set chart data - * @param chartData Chart data to display - */ - void SetChartData(std::shared_ptr chartData); - - /** - * @brief Get current chart data - * @return Current chart data - */ - std::shared_ptr GetChartData() const { return chartData_; } - protected: /** * @brief Initialize UI for curve-specific layout @@ -92,9 +80,6 @@ private: void UpdateCurveDisplay(); private: - std::shared_ptr chartData_; // Chart data containing curve information - bool hasChartData_; // Flag indicating if chart data is available - Ui::FitCurve* ui; FitCurveChartView* curveChartView; QChart* curveChart; diff --git a/src/ui/Panel/DataPanel.cpp b/src/ui/Panel/DataPanel.cpp index 217a3f08..4235fe11 100644 --- a/src/ui/Panel/DataPanel.cpp +++ b/src/ui/Panel/DataPanel.cpp @@ -21,6 +21,17 @@ DataPanel::DataPanel(int index, FileEntryType fileType, const QString& filePath, LOG_INFO("Created DataPanel {} for {} file: {}", index_, FileEntryTypeToString(fileType_), filePath_.toStdString()); } +DataPanel::DataPanel(int index, std::shared_ptr fileEntry, QWidget* parent) + : QWidget(parent) + , index_(index) + , fileType_(fileEntry->GetType()) + , filePath_(fileEntry->GetPath()) + , title_() + , dockWidget_(nullptr) + , fileEntry_(fileEntry) +{ +} + DataPanel::~DataPanel() { LOG_INFO("Destroyed DataPanel {} ({})", index_, FileEntryTypeToString(fileType_)); @@ -34,21 +45,23 @@ void DataPanel::closeEvent(QCloseEvent* event) void DataPanel::InitUI() { - // Create basic layout - QVBoxLayout* layout = new QVBoxLayout(this); + // // Create basic layout + // QVBoxLayout* layout = new QVBoxLayout(this); - // Add placeholder label showing panel information - QString typeDisplayName = GetTypeDisplayName(); - QLabel* infoLabel = new QLabel(QString("Panel %1 (%2)\nFile: %3\n\n%4 Data Area\nPlease inherit this class to implement specific functionality") - .arg(index_) - .arg(typeDisplayName) - .arg(QFileInfo(filePath_).fileName()) - .arg(typeDisplayName)); - infoLabel->setAlignment(Qt::AlignCenter); - infoLabel->setStyleSheet("QLabel { color: #666; font-size: 12px; padding: 20px; }"); + // // Add placeholder label showing panel information + // QString typeDisplayName = GetTypeDisplayName(); + // QLabel* infoLabel = new QLabel(QString("Panel %1 (%2)\nFile: %3\n\n%4 Data Area\nPlease inherit this class to implement specific functionality") + // .arg(index_) + // .arg(typeDisplayName) + // .arg(QFileInfo(filePath_).fileName()) + // .arg(typeDisplayName)); + // infoLabel->setAlignment(Qt::AlignCenter); + // infoLabel->setStyleSheet("QLabel { color: #666; font-size: 12px; padding: 20px; }"); - layout->addWidget(infoLabel); - setLayout(layout); + // layout->addWidget(infoLabel); + // setLayout(layout); + + RefreshPanel(); } QString DataPanel::GenerateTitle() diff --git a/src/ui/Panel/DataPanel.h b/src/ui/Panel/DataPanel.h index 56c8bea2..0e6ca4ce 100644 --- a/src/ui/Panel/DataPanel.h +++ b/src/ui/Panel/DataPanel.h @@ -28,6 +28,7 @@ public: * @param parent Parent widget */ explicit DataPanel(int index, FileEntryType fileType, const QString& filePath, QWidget* parent = nullptr); + explicit DataPanel(int index, std::shared_ptr fileEntry, QWidget* parent = nullptr); /** * @brief Destructor @@ -84,6 +85,8 @@ public: * @brief Initialize UI (virtual function, derived classes implement specific layout) */ virtual void InitUI(); + + bool IsValid() const { return fileEntry_ != nullptr; } signals: /** * @brief Panel close signal @@ -117,6 +120,6 @@ protected: QString filePath_; // Associated file path QString title_; // Panel title DockWidget* dockWidget_; // Dock widget reference - - std::shared_ptr fileEntry_; // Associated file entry + + std::shared_ptr fileEntry_{nullptr}; // Associated file entry }; \ No newline at end of file diff --git a/src/ui/Panel/DataPanelFactory.cpp b/src/ui/Panel/DataPanelFactory.cpp index 49ae32f6..7dad248d 100644 --- a/src/ui/Panel/DataPanelFactory.cpp +++ b/src/ui/Panel/DataPanelFactory.cpp @@ -37,11 +37,11 @@ DataPanel* DataPanelFactory::CreatePanel(FileEntryType fileType, int index, cons } } -DataPanel* DataPanelFactory::CreatePanelWithChartData(FileEntryType type, int index, std::shared_ptr chartData, QWidget* parent) +DataPanel* DataPanelFactory::CreatePanelWithChartData(FileEntryType type, int index, std::shared_ptr fileEntry, QWidget* parent) { // Currently only CurvePanel supports ChartData // In the future, other panel types may also support chart data - return new CurvePanel(index, chartData, parent); + return new CurvePanel(index, fileEntry, parent); } bool DataPanelFactory::IsTypeSupported(FileEntryType fileType) diff --git a/src/ui/Panel/DataPanelFactory.h b/src/ui/Panel/DataPanelFactory.h index 988722ec..e3cc191a 100644 --- a/src/ui/Panel/DataPanelFactory.h +++ b/src/ui/Panel/DataPanelFactory.h @@ -1,7 +1,7 @@ #pragma once #include "ui/Panel/DataPanel.h" -#include "workspace/ChartData.h" +#include "workspace/FileEntry.h" #include class DataPanelFactory @@ -11,7 +11,7 @@ public: static DataPanel* CreatePanel(FileEntryType type, int index, const QString& filePath, QWidget* parent = nullptr); // Create panel with chart data - static DataPanel* CreatePanelWithChartData(FileEntryType type, int index, std::shared_ptr chartData, QWidget* parent = nullptr); + static DataPanel* CreatePanelWithChartData(FileEntryType type, int index, std::shared_ptr fileEntry, QWidget* parent = nullptr); // Check if a panel type is supported static bool IsTypeSupported(FileEntryType type); diff --git a/src/ui/Panel/DataPanelManager.cpp b/src/ui/Panel/DataPanelManager.cpp index 1670bab3..f77759f5 100644 --- a/src/ui/Panel/DataPanelManager.cpp +++ b/src/ui/Panel/DataPanelManager.cpp @@ -198,6 +198,7 @@ DataPanel* DataPanelManager::CreateDataPanel(FileEntryType fileType, const QStri auto fileEntries = currentWorkspace_->GetFileEntries(fileType); if (index < fileEntries.size()) { panel->SetFileEntry(fileEntries[index]); + panel->InitUI(); } dockWidget->setWidget(panel); diff --git a/src/ui/WorkSpace/AddCurveFileDlg.cpp b/src/ui/WorkSpace/AddCurveFileDlg.cpp index 3c75f77c..85a899d4 100644 --- a/src/ui/WorkSpace/AddCurveFileDlg.cpp +++ b/src/ui/WorkSpace/AddCurveFileDlg.cpp @@ -444,20 +444,7 @@ bool AddCurveFileDlg::validateSpecificParams() { return false; } - // Data column validation - int xColumn = ui->xColumnSpinBox->value(); - int yColumn = ui->yColumnSpinBox->value(); - - if (xColumn == yColumn) { - QMessageBox::warning(this, tr("Validation Error"), tr("X column and Y column cannot be the same.")); - return false; - } - - if (xColumn < 1 || yColumn < 1) { - QMessageBox::warning(this, tr("Validation Error"), tr("Data column indices must be greater than 0.")); - return false; - } - + // Time parameter validation double timeParam = ui->timeParamSpinBox->value(); if (timeParam < 0) { @@ -471,13 +458,7 @@ bool AddCurveFileDlg::validateSpecificParams() { QMessageBox::warning(this, tr("Validation Error"), tr("X axis tick count must be at least 2.")); return false; } - - // Description length validation - if (ui->descriptionEdit->toPlainText().length() > 500) { - QMessageBox::warning(this, tr("Validation Error"), tr("Description is too long. Please limit to 500 characters.")); - return false; - } - + return true; } @@ -504,6 +485,7 @@ void AddCurveFileDlg::onSure() { // Set chart properties FileEntryCurve::ChartProperties chartProps; chartProps.xCount = ui->xCountSpinBox->value(); + chartProps.yCount = ui->yCountSpinBox->value(); chartProps.xTitle = ui->xTitleEdit->text(); chartProps.yTitle = ui->yTitleEdit->text(); chartProps.xMin = ui->xMinSpinBox->value(); diff --git a/src/ui/WorkSpace/AddCurveFileDlg.ui b/src/ui/WorkSpace/AddCurveFileDlg.ui index 27208739..a65caf16 100644 --- a/src/ui/WorkSpace/AddCurveFileDlg.ui +++ b/src/ui/WorkSpace/AddCurveFileDlg.ui @@ -7,7 +7,7 @@ 0 0 600 - 700 + 705 @@ -29,12 +29,12 @@ - - Select curve data file... - true + + Select curve data file... + @@ -155,10 +155,36 @@ Axis Range Settings - - + + + + -999999.000000000000000 + + + 999999.000000000000000 + + + 800.000000000000000 + + + + + + + 2 + + + 50 + + + 6 + + + + + - X Min: + X Tick Count: @@ -175,23 +201,17 @@ - - + + - X Max: + X Min: - - - - -999999.000000000000000 - - - 999999.000000000000000 - - - 250.000000000000000 + + + + Y Max: @@ -202,6 +222,19 @@ + + + + 2 + + + 50 + + + 6 + + + @@ -215,15 +248,8 @@ - - - - Y Max: - - - - - + + -999999.000000000000000 @@ -231,27 +257,21 @@ 999999.000000000000000 - 800.000000000000000 + 250.000000000000000 - - + + - X Tick Count: + X Max: - - - - 2 - - - 50 - - - 6 + + + + Y Tick Count: @@ -288,28 +308,28 @@ - - Add Curve - 80 16777215 + + Add Curve + - - Remove - 60 16777215 + + Remove + @@ -329,12 +349,12 @@ - - Selected Curve Properties - false + + Selected Curve Properties + @@ -361,15 +381,15 @@ - - Select Color - 100 16777215 + + Select Color + @@ -449,131 +469,6 @@ - - - - Data Format Parameters - - - - - - X Column: - - - - - - - 1 - - - 100 - - - 1 - - - - - - - Y Column: - - - - - - - 1 - - - 100 - - - 2 - - - - - - - Separator: - - - - - - - - Comma (,) - - - - - Tab - - - - - Space - - - - - Semicolon (;) - - - - - - - - File has header row - - - true - - - - - - - - - - Description (Optional) - - - - - - - 16777215 - 60 - - - - Enter file description... - - - - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - @@ -612,4 +507,4 @@ - \ No newline at end of file + diff --git a/src/workspace/FileEntry.cpp b/src/workspace/FileEntry.cpp index aa3ea179..27a2ca1d 100644 --- a/src/workspace/FileEntry.cpp +++ b/src/workspace/FileEntry.cpp @@ -4,6 +4,25 @@ #include "common/SpdLogger.h" +// 颜色转换辅助函数 +QString QColorToString(const QColor& color) { + return QString("%1,%2,%3").arg(color.red()).arg(color.green()).arg(color.blue()); +} + +QColor StringToQColor(const QString& colorStr) { + QStringList rgb = colorStr.split(','); + if (rgb.size() == 3) { + bool ok1, ok2, ok3; + int r = rgb[0].toInt(&ok1); + int g = rgb[1].toInt(&ok2); + int b = rgb[2].toInt(&ok3); + if (ok1 && ok2 && ok3) { + return QColor(r, g, b); + } + } + return QColor(); // 返回无效颜色 +} + void FileEntry::SetPath(const QString& path) { QFileInfo fileInfo(path); if (!fileInfo.exists()) { @@ -87,6 +106,47 @@ std::shared_ptr CreateFileEntryLight(const QString& filePath) { return fileEntry; } +// Factory functions for creating empty FileEntry objects (for XML parsing) +std::shared_ptr CreateEmptyFileEntry(FileEntryType type) { + switch (type) { + case FileEntryType::Curve: + return CreateEmptyFileEntryCurve(); + case FileEntryType::Surface: + return CreateEmptyFileEntrySurface(); + case FileEntryType::Table: + return CreateEmptyFileEntryTable(); + case FileEntryType::Light: + return CreateEmptyFileEntryLight(); + default: + LOG_ERROR("Unknown FileEntryType: {}", static_cast(type)); + return nullptr; + } +} + +std::shared_ptr CreateEmptyFileEntryCurve() { + auto fileEntry = std::make_shared(); + // Don't set path or name - these will be set during XML parsing + return fileEntry; +} + +std::shared_ptr CreateEmptyFileEntrySurface() { + auto fileEntry = std::make_shared(); + // Don't set path or name - these will be set during XML parsing + return fileEntry; +} + +std::shared_ptr CreateEmptyFileEntryTable() { + auto fileEntry = std::make_shared(); + // Don't set path or name - these will be set during XML parsing + return fileEntry; +} + +std::shared_ptr CreateEmptyFileEntryLight() { + auto fileEntry = std::make_shared(); + // Don't set path or name - these will be set during XML parsing + return fileEntry; +} + // FileEntrySurface method implementations void FileEntrySurface::SetChartProperties(const ChartProperties& properties) { chartProperties_ = properties; @@ -183,4 +243,103 @@ void FileEntryTable::SetDescription(const QString& description) { const QString& FileEntryTable::GetDescription() const { return description_; +} + +// FileEntryCurve SaveFiles implementation +bool FileEntryCurve::SaveFiles(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc) { + if (!scene || !doc) { + LOG_ERROR("Invalid XML parameters"); + return false; + } + + // 创建 元素 + tinyxml2::XMLElement* chartElement = doc->NewElement("chart"); + scene->InsertEndChild(chartElement); + + // 设置chart属性 + chartElement->SetAttribute("name", name_.toUtf8().constData()); + chartElement->SetAttribute("path", fileName_.toUtf8().constData()); + chartElement->SetAttribute("xCount", chartProperties_.xCount); + chartElement->SetAttribute("yCount", chartProperties_.yCount); + chartElement->SetAttribute("xTitle", chartProperties_.xTitle.toUtf8().constData()); + chartElement->SetAttribute("yTitle", chartProperties_.yTitle.toUtf8().constData()); + chartElement->SetAttribute("xMin", chartProperties_.xMin); + chartElement->SetAttribute("xMax", chartProperties_.xMax); + chartElement->SetAttribute("yMin", chartProperties_.yMin); + chartElement->SetAttribute("yMax", chartProperties_.yMax); + chartElement->SetAttribute("t", chartProperties_.timeParam); + + // 为每个CurveProperty创建元素 + for (const auto& curve : curveProperties_) { + tinyxml2::XMLElement* curveElement = doc->NewElement("curve"); + chartElement->InsertEndChild(curveElement); + + curveElement->SetAttribute("name", curve.name.toUtf8().constData()); + curveElement->SetAttribute("color", QColorToString(curve.color).toUtf8().constData()); + curveElement->SetAttribute("startPoint", curve.start); + curveElement->SetAttribute("endPoint", curve.stop); + } + + return true; +} + +// FileEntryCurve ParseFiles implementation +bool FileEntryCurve::ParseFiles(const tinyxml2::XMLElement* element) { + if (!element) { + LOG_ERROR("Invalid XML element"); + return false; + } + + // 查找元素 + const tinyxml2::XMLElement* chartElement = element->FirstChildElement("chart"); + if (!chartElement) { + LOG_ERROR("No chart element found"); + return false; + } + + // 解析chart属性 + const char* nameAttr = chartElement->Attribute("name"); + const char* pathAttr = chartElement->Attribute("path"); + if (nameAttr) name_ = QString::fromUtf8(nameAttr); + if (pathAttr) { + QString fullPath = QString::fromUtf8(pathAttr); + QFileInfo fileInfo(fullPath); + fileName_ = fileInfo.fileName(); + path_ = fileInfo.absolutePath(); + } + + chartProperties_.xCount = chartElement->IntAttribute("xCount", 0); + chartProperties_.yCount = chartElement->IntAttribute("yCount", 0); + + const char* xTitleAttr = chartElement->Attribute("xTitle"); + const char* yTitleAttr = chartElement->Attribute("yTitle"); + if (xTitleAttr) chartProperties_.xTitle = QString::fromUtf8(xTitleAttr); + if (yTitleAttr) chartProperties_.yTitle = QString::fromUtf8(yTitleAttr); + + chartProperties_.xMin = chartElement->DoubleAttribute("xMin", 0.0); + chartProperties_.xMax = chartElement->DoubleAttribute("xMax", 0.0); + chartProperties_.yMin = chartElement->DoubleAttribute("yMin", 0.0); + chartProperties_.yMax = chartElement->DoubleAttribute("yMax", 0.0); + chartProperties_.timeParam = chartElement->DoubleAttribute("t", 0.0); + + // 解析所有元素 + curveProperties_.clear(); + for (const tinyxml2::XMLElement* curveElement = chartElement->FirstChildElement("curve"); + curveElement != nullptr; + curveElement = curveElement->NextSiblingElement("curve")) { + + CurveProperty curve; + + const char* curveNameAttr = curveElement->Attribute("name"); + const char* colorAttr = curveElement->Attribute("color"); + if (curveNameAttr) curve.name = QString::fromUtf8(curveNameAttr); + if (colorAttr) curve.color = StringToQColor(QString::fromUtf8(colorAttr)); + + curve.start = curveElement->IntAttribute("startPoint", 0); + curve.stop = curveElement->IntAttribute("endPoint", 0); + + curveProperties_.append(curve); + } + + return true; } \ No newline at end of file diff --git a/src/workspace/FileEntry.h b/src/workspace/FileEntry.h index acb5f64e..1449257e 100644 --- a/src/workspace/FileEntry.h +++ b/src/workspace/FileEntry.h @@ -2,6 +2,7 @@ #include #include +#include "xml/tinyxml2.h" enum class FileEntryType { Curve, @@ -55,6 +56,9 @@ public: virtual FileEntrySurface* AsSurface() { return nullptr; } virtual FileEntryTable* AsTable() { return nullptr; } + virtual bool ParseFiles(const tinyxml2::XMLElement* element) { return false; } + virtual bool SaveFiles(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc) { return false; } + protected: FileEntryType type_; QString path_; @@ -69,18 +73,26 @@ std::shared_ptr CreateFileEntrySurface(const QString& filePath); std::shared_ptr CreateFileEntryTable(const QString& filePath); std::shared_ptr CreateFileEntryLight(const QString& filePath); +// Factory functions for creating empty FileEntry objects (for XML parsing) +std::shared_ptr CreateEmptyFileEntry(FileEntryType type); +std::shared_ptr CreateEmptyFileEntryCurve(); +std::shared_ptr CreateEmptyFileEntrySurface(); +std::shared_ptr CreateEmptyFileEntryTable(); +std::shared_ptr CreateEmptyFileEntryLight(); + class FileEntryCurve : public FileEntry { public: struct ChartProperties { int xCount; + int yCount; // 对应XML的yCount QString xTitle; QString yTitle; double xMin; double xMax; double yMin; double yMax; - double timeParam; + double timeParam; // 对应XML的t }; struct CurveProperty { @@ -104,6 +116,10 @@ public: FileEntryCurve* AsCurve() override { return this; } + // XML处理方法 + bool SaveFiles(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc) override; + bool ParseFiles(const tinyxml2::XMLElement* element) override; + private: ChartProperties chartProperties_; CurveProperties curveProperties_; diff --git a/src/workspace/WorkSpace.cpp b/src/workspace/WorkSpace.cpp index 8a9990fd..2ea8d723 100644 --- a/src/workspace/WorkSpace.cpp +++ b/src/workspace/WorkSpace.cpp @@ -119,7 +119,7 @@ void WorkSpace::SetRDPath(const QString& path) rdFile_ = fileInfo.fileName(); } -WorkSpace::FileEntryResult WorkSpace::SetFileEntry(std::shared_ptr fileEntry) { +WorkSpace::FileEntryResult WorkSpace::SetFileEntry(std::shared_ptr fileEntry, bool is_copy) { if (!fileEntry) { LOG_ERROR("FileEntry is null"); return FileEntryResult::InvalidFile; @@ -134,44 +134,53 @@ WorkSpace::FileEntryResult WorkSpace::SetFileEntry(std::shared_ptr fi return FileEntryResult::LimitExceeded; } - // Check for duplicates by file path - QString filePath = QString("%1/%2").arg(fileEntry->GetPath(), fileEntry->GetFileName()); - for (const auto& existingEntry : vec) { - if (existingEntry->GetPath() == filePath) { - LOG_WARN("Duplicate file entry: {}", filePath.toUtf8().constData()); - return FileEntryResult::Duplicate; + QString fileName; + if (is_copy) { + // Check for duplicates by file path + QString filePath = QString("%1/%2").arg(fileEntry->GetPath(), fileEntry->GetFileName()); + for (const auto& existingEntry : vec) { + if (existingEntry->GetPath() == filePath) { + LOG_WARN("Duplicate file entry: {}", filePath.toUtf8().constData()); + return FileEntryResult::Duplicate; + } } + + // Copy file to workspace directory + QFileInfo fileInfo(filePath); + if (!fileInfo.exists()) { + LOG_ERROR("File does not exist: {}", filePath.toUtf8().constData()); + return FileEntryResult::InvalidFile; + } + + QString targetPath = QString("%1/%2").arg(GetDir(), fileInfo.fileName()); + bool copySuccess = FileUtils::CopyFileToPath(filePath, targetPath, true); + LOG_INFO("Copy file {} to {}: {}", + filePath.toLocal8Bit().data(), + targetPath.toLocal8Bit().data(), + copySuccess); + + if (!copySuccess) { + LOG_ERROR("Failed to copy file to workspace"); + return FileEntryResult::CopyFailed; + } + + // Update file entry with workspace-relative path + fileName = fileInfo.fileName(); + fileEntry->SetFileNanme(fileInfo.fileName()); } - - // Copy file to workspace directory - QFileInfo fileInfo(filePath); - if (!fileInfo.exists()) { - LOG_ERROR("File does not exist: {}", filePath.toUtf8().constData()); - return FileEntryResult::InvalidFile; + else { + QString filePath = QString("%1/%2").arg(GetDir(), fileEntry->GetFileName()); + fileEntry->SetPath(filePath); + fileName = fileEntry->GetFileName(); } - QString targetPath = QString("%1/%2").arg(GetDir(), fileInfo.fileName()); - bool copySuccess = FileUtils::CopyFileToPath(filePath, targetPath, true); - LOG_INFO("Copy file {} to {}: {}", - filePath.toLocal8Bit().data(), - targetPath.toLocal8Bit().data(), - copySuccess); - - if (!copySuccess) { - LOG_ERROR("Failed to copy file to workspace"); - return FileEntryResult::CopyFailed; - } - - // Update file entry with workspace-relative path - fileEntry->SetFileNanme(fileInfo.fileName()); - // Add to files collection vec.push_back(fileEntry); ++filesSeq_; emit FilesChanged(type); LOG_INFO("Successfully added file entry: {} (type: {})", - fileInfo.fileName().toUtf8().constData(), + fileName.toUtf8().constData(), FileEntryTypeToString(type)); return FileEntryResult::Ok; diff --git a/src/workspace/WorkSpace.h b/src/workspace/WorkSpace.h index 3a0396ae..44406388 100644 --- a/src/workspace/WorkSpace.h +++ b/src/workspace/WorkSpace.h @@ -84,7 +84,7 @@ public: enum class FileEntryResult { Ok, LimitExceeded, Duplicate, CopyFailed, TypeMismatch, InvalidFile }; // New unified file entry management - FileEntryResult SetFileEntry(std::shared_ptr fileEntry); + FileEntryResult SetFileEntry(std::shared_ptr fileEntry, bool is_copy = true); std::vector> GetFileEntries(FileEntryType type) const; diff --git a/src/workspace/WorkSpaceXMLParse.cpp b/src/workspace/WorkSpaceXMLParse.cpp index 7ab221f5..d66a5c2c 100644 --- a/src/workspace/WorkSpaceXMLParse.cpp +++ b/src/workspace/WorkSpaceXMLParse.cpp @@ -122,7 +122,26 @@ bool WorkSpaceXMLParse::ParseFiles(const tinyxml2::XMLElement* element) { QString typeName = QString::fromLocal8Bit(name); - // Parse chart elements within this type + // Create FileEntry objects and call their ParseFiles method + FileEntryType enumType; + if (FileEntryTypeFromString(name, enumType)) { + // Create FileEntry objects for this type + for (int i = 0; i < count; ++i) { + auto fileEntry = CreateEmptyFileEntry(enumType); // Create empty FileEntry for XML parsing + if (fileEntry) { + // Call the FileEntry's ParseFiles method to parse detailed data + if (fileEntry->ParseFiles(typeElement)) { + // Add the parsed FileEntry to workspace + workSpace_->SetFileEntry(fileEntry, false); + } + } + } + + // Also set file entry count for backward compatibility + workSpace_->SetFileEntryCount(enumType, count); + } + + // Parse chart elements within this type (for chart data storage) const tinyxml2::XMLElement* chartElement = typeElement->FirstChildElement("chart"); while (nullptr != chartElement) { std::shared_ptr chartData; @@ -385,11 +404,8 @@ bool WorkSpaceXMLParse::ParseFiles(const tinyxml2::XMLElement* element) { fileTypes.append(fileTypeData); - // Also create file entries for backward compatibility - FileEntryType enumType; - if (FileEntryTypeFromString(name, enumType)) { - workSpace_->SetFileEntryCount(enumType, count); - } + // Note: FileEntry creation and parsing is already handled above + // No need for additional backward compatibility code here } typeElement = typeElement->NextSiblingElement("type"); } diff --git a/src/workspace/WorkSpaceXMLWrite.cpp b/src/workspace/WorkSpaceXMLWrite.cpp index 4e4d00f6..e75d5a15 100644 --- a/src/workspace/WorkSpaceXMLWrite.cpp +++ b/src/workspace/WorkSpaceXMLWrite.cpp @@ -150,6 +150,13 @@ bool WorkSpaceXMLWrite::SaveFiles(tinyxml2::XMLElement* scene, tinyxml2::XMLDocu typeElem->SetAttribute("name", FileEntryTypeToString(type)); typeElem->SetAttribute("count", static_cast(vec.size())); files->LinkEndChild(typeElem); + + // Call SaveFiles method for each FileEntry to save detailed data + for (const auto& fileEntry : vec) { + if (fileEntry) { + fileEntry->SaveFiles(typeElem, doc); + } + } } return true; }