modify AddSurfaceFileDlg

This commit is contained in:
brige 2025-10-26 17:48:34 +08:00
parent 8c0f345454
commit 1e7538796a
7 changed files with 1148 additions and 335 deletions

1
.gitignore vendored
View File

@ -3,4 +3,5 @@ build/
bin/
thirdparty/
tritoin/
CMakeFiles/
QWEN.md

View File

@ -683,11 +683,6 @@
</context>
<context>
<name>AddSurfaceFileDlg</name>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="14"/>
<source>Add Surface Data File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="20"/>
<source>File Selection</source>
@ -695,113 +690,242 @@
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="26"/>
<source>File Path:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="33"/>
<source>Select surface data file...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="14"/>
<source>Add Surface File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="33"/>
<source>Browse...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="43"/>
<source>...</source>
<source>Chart Properties</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="50"/>
<source>File Name:</source>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="49"/>
<source>X Axis Title:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="57"/>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="71"/>
<source>-</source>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="59"/>
<source>Y Axis Title:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="64"/>
<source>File Size:</source>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="69"/>
<source>Z Axis Title:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="81"/>
<source>Surface Parameters</source>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="79"/>
<source>Time Parameter:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="87"/>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="99"/>
<source>X Range:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="121"/>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="185"/>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="249"/>
<source>to</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="143"/>
<source>X Count:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="163"/>
<source>Y Range:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="207"/>
<source>Y Count:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="227"/>
<source>Z Range:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="271"/>
<source>Z Count:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="294"/>
<source>Surface Management</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="302"/>
<source>Add Surface</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="319"/>
<source>Remove</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="328"/>
<source>Surface Properties</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="334"/>
<source>Name:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="344"/>
<source>Color:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="357"/>
<source>Select Color</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="364"/>
<source>Start Point:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="381"/>
<source>End Point:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="404"/>
<source>Data Format Parameters</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="410"/>
<source>X Column:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="107"/>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="430"/>
<source>Y Column:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="127"/>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="450"/>
<source>Z Column:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="147"/>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="470"/>
<source>Separator:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="155"/>
<source>Comma (,)</source>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="477"/>
<source>,</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="160"/>
<source>Tab</source>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="524"/>
<source>Has Header Row</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="165"/>
<source>Space</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="170"/>
<source>Semicolon (;)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="178"/>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="484"/>
<source>X Grid Size:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="198"/>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="504"/>
<source>Y Grid Size:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="218"/>
<source>File has header row</source>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="112"/>
<source>Select Surface Data File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="231"/>
<source>Description (Optional)</source>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="118"/>
<source>Please add at least one surface.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="243"/>
<source>Enter file description...</source>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="107"/>
<source>Surface Data Files (*.txt *.dat *.csv);;All Files (*.*)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="281"/>
<source>Add File</source>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="118"/>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="124"/>
<source>Warning</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.ui" line="291"/>
<source>Cancel</source>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="124"/>
<source>Please fill in all axis titles.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="153"/>
<source>Select Surface Color</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="365"/>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="383"/>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="408"/>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="365"/>
<source>Failed to create surface file entry.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="383"/>
<source>Unable to get current workspace</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="393"/>
<source>Surface file count has reached the limit (9 files)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="396"/>
<source>File already exists</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="399"/>
<source>File copy failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="402"/>
<source>Invalid file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/WorkSpace/AddSurfaceFileDlg.cpp" line="405"/>
<source>Failed to add file</source>
<translation type="unfinished"></translation>
</message>
</context>

View File

@ -1,135 +1,414 @@
#include "AddSurfaceFileDlg.h"
#include <QMessageBox>
#include <QFileInfo>
#include <QFileDialog>
#include "app/Application.h"
#include "ui_AddSurfaceFileDlg.h"
#include "workspace/WorkSpaceManager.h"
#include "workspace/WorkSpace.h"
#include "common/SpdLogger.h"
#include "ui_AddSurfaceFileDlg.h"
#include <QFileDialog>
#include <QFileInfo>
#include <QColorDialog>
#include <QMessageBox>
#include <QListWidgetItem>
#include <QStandardPaths>
#include <QDir>
AddSurfaceFileDlg::AddSurfaceFileDlg(QWidget* parent)
AddSurfaceFileDlg::AddSurfaceFileDlg(QWidget *parent)
: BaseAddFileDlg(FileEntryType::Surface, parent)
, ui_(new Ui::AddSurfaceFileDlg) {
ui_->setupUi(this);
, ui(new Ui::AddSurfaceFileDlg)
, currentSurfaceIndex_(-1)
, selectedColor_(Qt::blue)
{
SetupUI(ui);
SetTitle(getDialogTitle());
setupConnections();
// Initialize chart properties with default values
chartProperties_.xCount = 100;
chartProperties_.yCount = 100;
chartProperties_.zCount = 100;
chartProperties_.xMin = 0.0;
chartProperties_.xMax = 1.0;
chartProperties_.yMin = 0.0;
chartProperties_.yMax = 1.0;
chartProperties_.zMin = 0.0;
chartProperties_.zMax = 1.0;
chartProperties_.timeParam = 0.0;
chartProperties_.xTitle = "X Axis";
chartProperties_.yTitle = "Y Axis";
chartProperties_.zTitle = "Z Axis";
// Set default UI values
ui->xCountSpinBox->setValue(chartProperties_.xCount);
ui->yCountSpinBox->setValue(chartProperties_.yCount);
ui->zCountSpinBox->setValue(chartProperties_.zCount);
ui->xMinSpinBox->setValue(chartProperties_.xMin);
ui->xMaxSpinBox->setValue(chartProperties_.xMax);
ui->yMinSpinBox->setValue(chartProperties_.yMin);
ui->yMaxSpinBox->setValue(chartProperties_.yMax);
ui->zMinSpinBox->setValue(chartProperties_.zMin);
ui->zMaxSpinBox->setValue(chartProperties_.zMax);
ui->timeParamSpinBox->setValue(chartProperties_.timeParam);
ui->xTitleLineEdit->setText(chartProperties_.xTitle);
ui->yTitleLineEdit->setText(chartProperties_.yTitle);
ui->zTitleLineEdit->setText(chartProperties_.zTitle);
// Initialize color preview
updateColorPreview(ui->surfaceColorButton, selectedColor_);
// Clear surface properties initially
clearSurfaceProperties();
}
AddSurfaceFileDlg::~AddSurfaceFileDlg() {
delete ui_;
AddSurfaceFileDlg::~AddSurfaceFileDlg()
{
delete ui;
}
void AddSurfaceFileDlg::setupConnections() {
connect(ui_->selectFileBtn, &QToolButton::clicked, this, &AddSurfaceFileDlg::onSelectFileClicked);
connect(ui_->filePathEdit, &QLineEdit::textChanged, this, &AddSurfaceFileDlg::onFilePathChanged);
connect(ui_->addBtn, &QPushButton::clicked, this, [this]() { OnSure(); });
connect(ui_->cancelBtn, &QPushButton::clicked, this, &QDialog::reject);
void AddSurfaceFileDlg::setupConnections()
{
// File selection connections
connect(ui->browseButton, &QPushButton::clicked, this, &AddSurfaceFileDlg::onSelectFile);
connect(ui->filePathLineEdit, &QLineEdit::textChanged, this, &AddSurfaceFileDlg::onFilePathChanged);
// Surface management connections
connect(ui->surfaceColorButton, &QPushButton::clicked, this, &AddSurfaceFileDlg::onSurfaceColorButtonClicked);
connect(ui->addSurfaceButton, &QPushButton::clicked, this, &AddSurfaceFileDlg::onAddSurfaceClicked);
connect(ui->removeSurfaceButton, &QPushButton::clicked, this, &AddSurfaceFileDlg::onRemoveSurfaceClicked);
connect(ui->surfaceListWidget, &QListWidget::itemClicked, this, &AddSurfaceFileDlg::onSurfaceListItemClicked);
connect(ui->surfaceListWidget, &QListWidget::itemSelectionChanged, this, &AddSurfaceFileDlg::onSurfaceSelectionChanged);
// Surface properties connections
connect(ui->surfaceNameLineEdit, &QLineEdit::textChanged, this, &AddSurfaceFileDlg::onSurfaceNameChanged);
connect(ui->surfaceStartSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &AddSurfaceFileDlg::onSurfaceDataChanged);
connect(ui->surfaceStopSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &AddSurfaceFileDlg::onSurfaceDataChanged);
// Chart properties connections (save to member variables when changed)
connect(ui->xCountSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), [this](int value) { chartProperties_.xCount = value; });
connect(ui->yCountSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), [this](int value) { chartProperties_.yCount = value; });
connect(ui->zCountSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), [this](int value) { chartProperties_.zCount = value; });
connect(ui->xMinSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double value) { chartProperties_.xMin = value; });
connect(ui->xMaxSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double value) { chartProperties_.xMax = value; });
connect(ui->yMinSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double value) { chartProperties_.yMin = value; });
connect(ui->yMaxSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double value) { chartProperties_.yMax = value; });
connect(ui->zMinSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double value) { chartProperties_.zMin = value; });
connect(ui->zMaxSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double value) { chartProperties_.zMax = value; });
connect(ui->timeParamSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [this](double value) { chartProperties_.timeParam = value; });
connect(ui->xTitleLineEdit, &QLineEdit::textChanged, [this](const QString& text) { chartProperties_.xTitle = text; });
connect(ui->yTitleLineEdit, &QLineEdit::textChanged, [this](const QString& text) { chartProperties_.yTitle = text; });
connect(ui->zTitleLineEdit, &QLineEdit::textChanged, [this](const QString& text) { chartProperties_.zTitle = text; });
// Dialog button connections
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &AddSurfaceFileDlg::accept);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &AddSurfaceFileDlg::reject);
}
void AddSurfaceFileDlg::onSelectFileClicked() {
const QString workspacePath = Application::GetWorkSpacePath();
QString filePath = QFileDialog::getOpenFileName(
this,
QStringLiteral("Select Surface Data File"),
workspacePath,
getFileFilter()
);
if (filePath.isEmpty()) {
return;
}
ui_->filePathEdit->setText(filePath);
updateFileInfo(filePath);
LOG_INFO("Selected surface file: {}", filePath.toStdString());
QString AddSurfaceFileDlg::getFileFilter() const
{
return tr("Surface Data Files (*.txt *.dat *.csv);;All Files (*.*)");
}
void AddSurfaceFileDlg::onFilePathChanged() {
QString filePath = ui_->filePathEdit->text();
if (!filePath.isEmpty()) {
updateFileInfo(filePath);
}
QString AddSurfaceFileDlg::getDialogTitle() const
{
return tr("Select Surface Data File");
}
void AddSurfaceFileDlg::updateFileInfo(const QString& filePath) {
QFileInfo fileInfo(filePath);
ui_->fileNameValue->setText(fileInfo.fileName());
qint64 size = fileInfo.size();
QString sizeText;
if (size < 1024) {
sizeText = QString("%1 B").arg(size);
} else if (size < 1024 * 1024) {
sizeText = QString("%1 KB").arg(size / 1024.0, 0, 'f', 1);
} else {
sizeText = QString("%1 MB").arg(size / (1024.0 * 1024.0), 0, 'f', 1);
}
ui_->fileSizeValue->setText(sizeText);
}
bool AddSurfaceFileDlg::validateSpecificParams() {
if (ui_->filePathEdit->text().isEmpty()) {
QMessageBox::warning(this, QStringLiteral("Warning"),
QStringLiteral("Please select a surface data file."));
bool AddSurfaceFileDlg::validateSpecificParams()
{
if (surfaces_.isEmpty()) {
QMessageBox::warning(this, tr("Warning"), tr("Please add at least one surface."));
return false;
}
QFileInfo fileInfo(ui_->filePathEdit->text());
if (!fileInfo.exists()) {
QMessageBox::warning(this, QStringLiteral("Warning"),
QStringLiteral("The selected file does not exist."));
return false;
}
if (ui_->xColumnSpinBox->value() == ui_->yColumnSpinBox->value() ||
ui_->xColumnSpinBox->value() == ui_->zColumnSpinBox->value() ||
ui_->yColumnSpinBox->value() == ui_->zColumnSpinBox->value()) {
QMessageBox::warning(this, QStringLiteral("Warning"),
QStringLiteral("X, Y, and Z columns must be different."));
// Validate chart properties
if (chartProperties_.xTitle.isEmpty() || chartProperties_.yTitle.isEmpty() || chartProperties_.zTitle.isEmpty()) {
QMessageBox::warning(this, tr("Warning"), tr("Please fill in all axis titles."));
return false;
}
return true;
}
QString AddSurfaceFileDlg::getFileFilter() const {
return QStringLiteral("Surface Data Files (*.txt *.csv *.dat *.xyz);;All Files (*.*)");
void AddSurfaceFileDlg::updateFileInfo(const QString& filePath)
{
ui->filePathLineEdit->setText(filePath);
}
QString AddSurfaceFileDlg::getDialogTitle() const {
return QStringLiteral("Add Surface Data File");
}
void AddSurfaceFileDlg::onSelectFile()
{
QString documentsPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
QString fileName = QFileDialog::getOpenFileName(this, getDialogTitle(), documentsPath, getFileFilter());
QString AddSurfaceFileDlg::getSelectedFilePath() const {
return ui_->filePathEdit->text();
}
QString AddSurfaceFileDlg::getDescription() const {
return ui_->descriptionEdit->toPlainText().trimmed();
}
AddSurfaceFileDlg::SurfaceParams AddSurfaceFileDlg::getSurfaceParams() const {
SurfaceParams params;
params.xColumn = ui_->xColumnSpinBox->value();
params.yColumn = ui_->yColumnSpinBox->value();
params.zColumn = ui_->zColumnSpinBox->value();
params.xGridSize = ui_->xGridSizeSpinBox->value();
params.yGridSize = ui_->yGridSizeSpinBox->value();
params.hasHeader = ui_->hasHeaderCheckBox->isChecked();
params.description = ui_->descriptionEdit->toPlainText().trimmed();
// Get delimiter from combo box
int index = ui_->separatorComboBox->currentIndex();
switch (index) {
case 0: params.delimiter = ","; break;
case 1: params.delimiter = "\t"; break;
case 2: params.delimiter = " "; break;
case 3: params.delimiter = ";"; break;
default: params.delimiter = ","; break;
if (!fileName.isEmpty()) {
updateFileInfo(fileName);
}
}
void AddSurfaceFileDlg::onFilePathChanged()
{
// File path changed, could update preview or validation here
}
void AddSurfaceFileDlg::onSurfaceColorButtonClicked()
{
QColor color = QColorDialog::getColor(selectedColor_, this, tr("Select Surface Color"));
if (color.isValid()) {
selectedColor_ = color;
updateColorPreview(ui->surfaceColorButton, selectedColor_);
// Update current surface color if one is selected
if (currentSurfaceIndex_ >= 0 && currentSurfaceIndex_ < surfaces_.size()) {
surfaces_[currentSurfaceIndex_].color = selectedColor_;
// Update list item color
QListWidgetItem* item = ui->surfaceListWidget->item(currentSurfaceIndex_);
if (item) {
QPixmap pixmap(16, 16);
pixmap.fill(selectedColor_);
item->setIcon(QIcon(pixmap));
}
}
}
}
void AddSurfaceFileDlg::onAddSurfaceClicked()
{
FileEntrySurface::SurfaceProperty surface;
surface.name = generateSurfaceName();
surface.color = generateSurfaceColor();
surface.start = 0;
surface.stop = 1000;
surface.x = QString::number(ui->xColumnSpinBox->value());
surface.y = QString::number(ui->yColumnSpinBox->value());
surface.z = QString::number(ui->zColumnSpinBox->value());
surfaces_.append(surface);
addSurfaceToList(surface);
// Select the newly added surface
ui->surfaceListWidget->setCurrentRow(surfaces_.size() - 1);
}
void AddSurfaceFileDlg::onRemoveSurfaceClicked()
{
int currentRow = ui->surfaceListWidget->currentRow();
if (currentRow >= 0 && currentRow < surfaces_.size()) {
surfaces_.removeAt(currentRow);
delete ui->surfaceListWidget->takeItem(currentRow);
// Update current surface index
if (currentRow < surfaces_.size()) {
ui->surfaceListWidget->setCurrentRow(currentRow);
} else if (surfaces_.size() > 0) {
ui->surfaceListWidget->setCurrentRow(surfaces_.size() - 1);
} else {
currentSurfaceIndex_ = -1;
clearSurfaceProperties();
}
}
}
void AddSurfaceFileDlg::onSurfaceListItemClicked(QListWidgetItem* item)
{
int row = ui->surfaceListWidget->row(item);
if (row >= 0 && row < surfaces_.size()) {
saveSurfaceProperties(); // Save current surface properties
currentSurfaceIndex_ = row;
updateSurfaceProperties(); // Load new surface properties
}
}
void AddSurfaceFileDlg::onSurfaceSelectionChanged()
{
int currentRow = ui->surfaceListWidget->currentRow();
if (currentRow >= 0 && currentRow < surfaces_.size()) {
saveSurfaceProperties(); // Save current surface properties
currentSurfaceIndex_ = currentRow;
updateSurfaceProperties(); // Load new surface properties
} else {
currentSurfaceIndex_ = -1;
clearSurfaceProperties();
}
}
void AddSurfaceFileDlg::onSurfaceNameChanged()
{
if (currentSurfaceIndex_ >= 0 && currentSurfaceIndex_ < surfaces_.size()) {
QString newName = ui->surfaceNameLineEdit->text();
surfaces_[currentSurfaceIndex_].name = newName;
// Update list item text
QListWidgetItem* item = ui->surfaceListWidget->item(currentSurfaceIndex_);
if (item) {
item->setText(newName);
}
}
}
void AddSurfaceFileDlg::onSurfaceDataChanged()
{
if (currentSurfaceIndex_ >= 0 && currentSurfaceIndex_ < surfaces_.size()) {
surfaces_[currentSurfaceIndex_].start = ui->surfaceStartSpinBox->value();
surfaces_[currentSurfaceIndex_].stop = ui->surfaceStopSpinBox->value();
}
}
void AddSurfaceFileDlg::updateColorPreview(QPushButton* button, const QColor& color)
{
if (button && color.isValid()) {
QString styleSheet = QString("QPushButton { background-color: %1; }").arg(color.name());
button->setStyleSheet(styleSheet);
}
}
void AddSurfaceFileDlg::addSurfaceToList(const FileEntrySurface::SurfaceProperty& surface)
{
QListWidgetItem* item = new QListWidgetItem(surface.name);
// Set color icon
QPixmap pixmap(16, 16);
pixmap.fill(surface.color);
item->setIcon(QIcon(pixmap));
ui->surfaceListWidget->addItem(item);
}
void AddSurfaceFileDlg::updateSurfaceProperties()
{
if (currentSurfaceIndex_ >= 0 && currentSurfaceIndex_ < surfaces_.size()) {
const auto& surface = surfaces_[currentSurfaceIndex_];
ui->surfaceNameLineEdit->setText(surface.name);
ui->surfaceStartSpinBox->setValue(surface.start);
ui->surfaceStopSpinBox->setValue(surface.stop);
selectedColor_ = surface.color;
updateColorPreview(ui->surfaceColorButton, selectedColor_);
ui->surfacePropertiesGroupBox->setEnabled(true);
} else {
clearSurfaceProperties();
}
}
void AddSurfaceFileDlg::saveSurfaceProperties()
{
if (currentSurfaceIndex_ >= 0 && currentSurfaceIndex_ < surfaces_.size()) {
surfaces_[currentSurfaceIndex_].name = ui->surfaceNameLineEdit->text();
surfaces_[currentSurfaceIndex_].start = ui->surfaceStartSpinBox->value();
surfaces_[currentSurfaceIndex_].stop = ui->surfaceStopSpinBox->value();
surfaces_[currentSurfaceIndex_].color = selectedColor_;
}
}
void AddSurfaceFileDlg::clearSurfaceProperties()
{
ui->surfaceNameLineEdit->clear();
ui->surfaceStartSpinBox->setValue(0);
ui->surfaceStopSpinBox->setValue(1000);
selectedColor_ = Qt::blue;
updateColorPreview(ui->surfaceColorButton, selectedColor_);
ui->surfacePropertiesGroupBox->setEnabled(false);
}
QString AddSurfaceFileDlg::generateSurfaceName() const
{
return QString("Surface %1").arg(surfaces_.size() + 1);
}
QColor AddSurfaceFileDlg::generateSurfaceColor() const
{
// Generate different colors for each surface
static const QColor colors[] = {
Qt::blue, Qt::red, Qt::green, Qt::magenta, Qt::cyan, Qt::yellow,
Qt::darkBlue, Qt::darkRed, Qt::darkGreen, Qt::darkMagenta, Qt::darkCyan, Qt::darkYellow
};
int colorIndex = surfaces_.size() % (sizeof(colors) / sizeof(colors[0]));
return colors[colorIndex];
}
AddSurfaceFileDlg::SurfaceParams AddSurfaceFileDlg::GetSurfaceParams() const
{
SurfaceParams params;
params.xColumn = ui->xColumnSpinBox->value();
params.yColumn = ui->yColumnSpinBox->value();
params.zColumn = ui->zColumnSpinBox->value();
params.separator = ui->separatorLineEdit->text();
params.xGridSize = ui->xGridSizeSpinBox->value();
params.yGridSize = ui->yGridSizeSpinBox->value();
params.hasHeader = ui->hasHeaderCheckBox->isChecked();
return params;
}
QString AddSurfaceFileDlg::GetSelectedFilePath() const
{
return ui->filePathLineEdit->text();
}
QString AddSurfaceFileDlg::GetDescription() const
{
return getDescription(); // 使用基类的getDescription方法
}
void AddSurfaceFileDlg::accept()
{
if (!validateSpecificParams()) {
return;
}
// Save current surface properties before creating FileEntry
saveSurfaceProperties();
// Create FileEntrySurface
auto fileEntry = std::dynamic_pointer_cast<FileEntrySurface>(CreateFileEntrySurface(GetSelectedFilePath()));
if (!fileEntry) {
QMessageBox::critical(this, tr("Error"), tr("Failed to create surface file entry."));
return;
}
// Set chart properties
fileEntry->SetChartProperties(chartProperties_);
// Set surface properties
for (const auto& surface : surfaces_) {
fileEntry->AddSurfaceProperty(surface);
}
// Set description
fileEntry->SetDescription(GetDescription());
// Add to workspace
WorkSpace* workspace = WorkSpaceManager::Get().GetCurrent();
if (!workspace) {
QMessageBox::critical(this, tr("Error"), tr("Unable to get current workspace"));
return;
}
// Add FileEntrySurface to workspace using SetFileEntry method
auto result = workspace->SetFileEntry(fileEntry);
if (result != WorkSpace::FileEntryResult::Ok) {
QString errorMsg;
switch (result) {
case WorkSpace::FileEntryResult::LimitExceeded:
errorMsg = tr("Surface file count has reached the limit (9 files)");
break;
case WorkSpace::FileEntryResult::Duplicate:
errorMsg = tr("File already exists");
break;
case WorkSpace::FileEntryResult::CopyFailed:
errorMsg = tr("File copy failed");
break;
case WorkSpace::FileEntryResult::InvalidFile:
errorMsg = tr("Invalid file");
break;
default:
errorMsg = tr("Failed to add file");
break;
}
QMessageBox::warning(this, tr("Error"), errorMsg);
return;
}
LOG_INFO("Added surface file to workspace: {}", GetSelectedFilePath().toUtf8().constData());
QDialog::accept();
}

View File

@ -1,56 +1,86 @@
#pragma once
#include "BaseAddFileDlg.h"
#include "workspace/FileEntry.h"
#include <QWidget>
#include <QColor>
#include <QList>
#include <memory>
QT_BEGIN_NAMESPACE
class QLineEdit;
class QCheckBox;
class QSpinBox;
class QComboBox;
class QCheckBox;
class QTextEdit;
class QToolButton;
class QLabel;
QT_END_NAMESPACE
class QComboBox;
class QPushButton;
class QListWidget;
class QListWidgetItem;
class QDoubleSpinBox;
namespace Ui {
class AddSurfaceFileDlg;
class AddSurfaceFileDlg;
}
class AddSurfaceFileDlg : public BaseAddFileDlg {
class AddSurfaceFileDlg : public BaseAddFileDlg
{
Q_OBJECT
public:
struct SurfaceParams {
QString delimiter;
bool hasHeader;
int xColumn;
int yColumn;
int zColumn;
QString separator;
int xGridSize;
int yGridSize;
QString description;
bool hasHeader;
};
explicit AddSurfaceFileDlg(QWidget* parent = nullptr);
~AddSurfaceFileDlg() override;
public:
explicit AddSurfaceFileDlg(QWidget *parent = nullptr);
~AddSurfaceFileDlg();
SurfaceParams getSurfaceParams() const;
QString getSelectedFilePath() const;
QString getDescription() const;
protected:
// BaseAddFileDlg interface
QString getFileFilter() const override;
QString getDialogTitle() const override;
bool validateSpecificParams() override;
void updateFileInfo(const QString& filePath) override;
// Get surface parameters
SurfaceParams GetSurfaceParams() const;
QString GetSelectedFilePath() const;
QString GetDescription() const;
private slots:
void onSelectFileClicked();
void onSelectFile();
void onFilePathChanged();
// Surface management slots
void onSurfaceColorButtonClicked();
void onAddSurfaceClicked();
void onRemoveSurfaceClicked();
void onSurfaceListItemClicked(QListWidgetItem* item);
void onSurfaceSelectionChanged();
void onSurfaceNameChanged();
void onSurfaceDataChanged();
public slots:
void accept() override;
private:
void setupConnections();
void updateFileInfo(const QString& filePath);
void updateColorPreview(QPushButton* button, const QColor& color);
void addSurfaceToList(const FileEntrySurface::SurfaceProperty& surface);
void updateSurfaceProperties();
void saveSurfaceProperties();
void clearSurfaceProperties();
QString generateSurfaceName() const;
QColor generateSurfaceColor() const;
private:
Ui::AddSurfaceFileDlg* ui_;
Ui::AddSurfaceFileDlg *ui;
int currentSurfaceIndex_;
QColor selectedColor_;
FileEntrySurface::ChartProperties chartProperties_;
FileEntrySurface::SurfaceProperties surfaces_;
};

View File

@ -6,12 +6,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>520</height>
<width>800</width>
<height>726</height>
</rect>
</property>
<property name="windowTitle">
<string>Add Surface Data File</string>
<string>Add Surface File</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
@ -19,56 +19,18 @@
<property name="title">
<string>File Selection</string>
</property>
<layout class="QGridLayout" name="fileGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="filePathLabel">
<property name="text">
<string>File Path:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="filePathEdit">
<layout class="QHBoxLayout" name="fileLayout">
<item>
<widget class="QLineEdit" name="filePathLineEdit">
<property name="placeholderText">
<string>Select surface data file...</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="selectFileBtn">
<item>
<widget class="QPushButton" name="browseButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="fileNameLabel">
<property name="text">
<string>File Name:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLabel" name="fileNameValue">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="fileSizeLabel">
<property name="text">
<string>File Size:</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLabel" name="fileSizeValue">
<property name="text">
<string>-</string>
<string>Browse...</string>
</property>
</widget>
</item>
@ -76,11 +38,372 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="paramsGroupBox">
<widget class="QGroupBox" name="chartPropertiesGroupBox">
<property name="title">
<string>Surface Parameters</string>
<string>Chart Properties</string>
</property>
<layout class="QGridLayout" name="paramsGridLayout">
<layout class="QGridLayout" name="chartPropertiesLayout">
<item row="0" column="0">
<widget class="QLabel" name="xTitleLabel">
<property name="text">
<string>X Axis Title:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="xTitleLineEdit"/>
</item>
<item row="0" column="2">
<widget class="QLabel" name="yTitleLabel">
<property name="text">
<string>Y Axis Title:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="yTitleLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="zTitleLabel">
<property name="text">
<string>Z Axis Title:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="zTitleLineEdit"/>
</item>
<item row="1" column="2">
<widget class="QLabel" name="timeParamLabel">
<property name="text">
<string>Time Parameter:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QDoubleSpinBox" name="timeParamSpinBox">
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>-999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="xRangeLabel">
<property name="text">
<string>X Range:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="xRangeLayout">
<item>
<widget class="QDoubleSpinBox" name="xMinSpinBox">
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>-999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="xToLabel">
<property name="text">
<string>to</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="xMaxSpinBox">
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>-999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="2">
<widget class="QLabel" name="xCountLabel">
<property name="text">
<string>X Count:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QSpinBox" name="xCountSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="yRangeLabel">
<property name="text">
<string>Y Range:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="yRangeLayout">
<item>
<widget class="QDoubleSpinBox" name="yMinSpinBox">
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>-999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="yToLabel">
<property name="text">
<string>to</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="yMaxSpinBox">
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>-999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="2">
<widget class="QLabel" name="yCountLabel">
<property name="text">
<string>Y Count:</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QSpinBox" name="yCountSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="zRangeLabel">
<property name="text">
<string>Z Range:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="zRangeLayout">
<item>
<widget class="QDoubleSpinBox" name="zMinSpinBox">
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>-999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="zToLabel">
<property name="text">
<string>to</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="zMaxSpinBox">
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>-999999.000000000000000</double>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="2">
<widget class="QLabel" name="zCountLabel">
<property name="text">
<string>Z Count:</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QSpinBox" name="zCountSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="surfaceManagementGroupBox">
<property name="title">
<string>Surface Management</string>
</property>
<layout class="QHBoxLayout" name="surfaceManagementLayout">
<item>
<layout class="QVBoxLayout" name="surfaceListLayout">
<item>
<widget class="QPushButton" name="addSurfaceButton">
<property name="text">
<string>Add Surface</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="surfaceListWidget">
<property name="minimumSize">
<size>
<width>200</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeSurfaceButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="surfacePropertiesGroupBox">
<property name="title">
<string>Surface Properties</string>
</property>
<layout class="QGridLayout" name="surfacePropertiesLayout">
<item row="0" column="0">
<widget class="QLabel" name="surfaceNameLabel">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="surfaceNameLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="surfaceColorLabel">
<property name="text">
<string>Color:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="surfaceColorButton">
<property name="minimumSize">
<size>
<width>100</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Select Color</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="surfaceStartLabel">
<property name="text">
<string>Start Point:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="surfaceStartSpinBox">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="surfaceStopLabel">
<property name="text">
<string>End Point:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="surfaceStopSpinBox">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>999999</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="dataFormatGroupBox">
<property name="title">
<string>Data Format Parameters</string>
</property>
<layout class="QGridLayout" name="dataFormatLayout">
<item row="0" column="0">
<widget class="QLabel" name="xColumnLabel">
<property name="text">
@ -94,92 +417,75 @@
<number>1</number>
</property>
<property name="maximum">
<number>100</number>
<number>1000</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="0" column="2">
<widget class="QLabel" name="yColumnLabel">
<property name="text">
<string>Y Column:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="0" column="3">
<widget class="QSpinBox" name="yColumnSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100</number>
<number>1000</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="1" column="0">
<widget class="QLabel" name="zColumnLabel">
<property name="text">
<string>Z Column:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="1" column="1">
<widget class="QSpinBox" name="zColumnSpinBox">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100</number>
<number>1000</number>
</property>
<property name="value">
<number>3</number>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="1" column="2">
<widget class="QLabel" name="separatorLabel">
<property name="text">
<string>Separator:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="separatorComboBox">
<item>
<property name="text">
<string>Comma (,)</string>
</property>
</item>
<item>
<property name="text">
<string>Tab</string>
</property>
</item>
<item>
<property name="text">
<string>Space</string>
</property>
</item>
<item>
<property name="text">
<string>Semicolon (;)</string>
</property>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="separatorLineEdit">
<property name="text">
<string>,</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="2" column="0">
<widget class="QLabel" name="xGridSizeLabel">
<property name="text">
<string>X Grid Size:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="2" column="1">
<widget class="QSpinBox" name="xGridSizeSpinBox">
<property name="minimum">
<number>1</number>
@ -192,14 +498,14 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="2" column="2">
<widget class="QLabel" name="yGridSizeLabel">
<property name="text">
<string>Y Grid Size:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="2" column="3">
<widget class="QSpinBox" name="yGridSizeSpinBox">
<property name="minimum">
<number>1</number>
@ -212,13 +518,10 @@
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="hasHeaderCheckBox">
<property name="text">
<string>File has header row</string>
</property>
<property name="checked">
<bool>true</bool>
<string>Has Header Row</string>
</property>
</widget>
</item>
@ -226,76 +529,50 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="descGroupBox">
<property name="title">
<string>Description (Optional)</string>
</property>
<layout class="QVBoxLayout" name="descVerticalLayout">
<item>
<widget class="QTextEdit" name="descriptionEdit">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
<property name="placeholderText">
<string>Enter file description...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="buttonLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="addBtn">
<property name="text">
<string>Add File</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelBtn">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AddSurfaceFileDlg</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AddSurfaceFileDlg</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -46,13 +46,16 @@ std::shared_ptr<FileEntryCurve> CreateFileEntryCurve(const QString& filePath) {
}
std::shared_ptr<FileEntry> CreateFileEntrySurface(const QString& filePath) {
auto fileEntry = std::make_shared<FileEntry>();
fileEntry->SetType(FileEntryType::Surface);
if (!filePath.isEmpty()) {
fileEntry->SetPath(filePath);
QFileInfo fileInfo(filePath);
if (!fileInfo.exists()) {
LOG_ERROR("File does not exist: {}", filePath.toUtf8().constData());
return nullptr;
}
auto fileEntry = std::make_shared<FileEntrySurface>();
fileEntry->SetPath(filePath);
fileEntry->SetName(fileInfo.baseName()); // Use base name as default display name
return fileEntry;
}
@ -80,3 +83,44 @@ std::shared_ptr<FileEntryLight> CreateFileEntryLight(const QString& filePath) {
return fileEntry;
}
// FileEntrySurface method implementations
void FileEntrySurface::SetChartProperties(const ChartProperties& properties) {
chartProperties_ = properties;
}
const FileEntrySurface::ChartProperties& FileEntrySurface::GetChartProperties() const {
return chartProperties_;
}
void FileEntrySurface::AddSurfaceProperty(const SurfaceProperty& surface) {
surfaceProperties_.append(surface);
}
void FileEntrySurface::RemoveSurfaceProperty(int index) {
if (index >= 0 && index < surfaceProperties_.size()) {
surfaceProperties_.removeAt(index);
}
}
void FileEntrySurface::SetSurfaceProperty(int index, const SurfaceProperty& surface) {
if (index >= 0 && index < surfaceProperties_.size()) {
surfaceProperties_[index] = surface;
}
}
const FileEntrySurface::SurfaceProperties& FileEntrySurface::GetSurfaceProperties() const {
return surfaceProperties_;
}
FileEntrySurface* FileEntrySurface::AsSurface() {
return this;
}
void FileEntrySurface::SetDescription(const QString& description) {
description_ = description;
}
const QString& FileEntrySurface::GetDescription() const {
return description_;
}

View File

@ -31,6 +31,7 @@ inline bool FileEntryTypeFromString(const char* s, FileEntryType& out) {
class FileEntryCurve;
class FileEntryLight;
class FileEntrySurface;
class FileEntry {
public:
@ -48,8 +49,9 @@ public:
void SetName(const QString& name) { name_ = name; }
QString GetName() const { return name_; }
virtual FileEntryCurve* AsCurve() { return nullptr; }
virtual FileEntryLight* AsLight() { return nullptr; }
virtual FileEntryCurve* AsCurve() { return nullptr; }
virtual FileEntryLight* AsLight() { return nullptr; }
virtual FileEntrySurface* AsSurface() { return nullptr; }
protected:
FileEntryType type_;
@ -105,6 +107,62 @@ private:
CurveProperties curveProperties_;
};
class FileEntrySurface : public FileEntry {
public:
struct ChartProperties {
int xCount;
int yCount; // Added missing yCount
int zCount; // Added missing zCount
QString xTitle;
QString yTitle;
QString zTitle;
double xMin;
double xMax;
double yMin;
double yMax;
double zMin;
double zMax;
double timeParam;
};
struct SurfaceProperty {
QString name;
QColor color;
int start;
int stop;
QString x;
QString y;
QString z;
};
using SurfaceProperties = QList<SurfaceProperty>;
public:
FileEntrySurface() { type_ = FileEntryType::Surface; }
// Chart properties management
void SetChartProperties(const ChartProperties& properties);
const ChartProperties& GetChartProperties() const;
// Surface properties management
void AddSurfaceProperty(const SurfaceProperty& surface);
void RemoveSurfaceProperty(int index);
void SetSurfaceProperty(int index, const SurfaceProperty& surface);
const SurfaceProperties& GetSurfaceProperties() const;
// Type conversion
FileEntrySurface* AsSurface() override;
// Description management
void SetDescription(const QString& description);
const QString& GetDescription() const;
private:
ChartProperties chartProperties_;
SurfaceProperties surfaceProperties_;
QString description_;
};
class FileEntryLight : public FileEntry {
public:
struct ColorProperties {