diff --git a/src/translations/Dyt_zh_CN.ts b/src/translations/Dyt_zh_CN.ts
index 15baec99..bbabbc89 100644
--- a/src/translations/Dyt_zh_CN.ts
+++ b/src/translations/Dyt_zh_CN.ts
@@ -46,69 +46,351 @@
- Curve Parameters
+ Chart Properties
- X Column:
+ Chart Name:
-
- Y Column:
+
+ Enter chart name...
-
- Separator:
+
+ X Axis Title:
-
- Comma (,)
+
+ Enter X axis title...
-
- Tab
+
+ Y Axis Title:
-
- Space
+
+ Enter Y axis title...
-
- Semicolon (;)
+
+ Time Parameter:
-
- File has header row
+
+ Axis Range Settings
-
- Description (Optional)
+
+ X Min:
-
- Enter file description...
+
+ X Max:
+
+
+
+
+ Y Min:
+ Y Max:
+
+
+
+
+ X Tick Count:
+
+
+
+
+ Curve Name:
+
+
+
+
+ Chart 1
+
+
+
+
+ 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
+
+
+ Curve %1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Validation Error
+
+
+
+
+ Please select a data file.
+
+
+
+
+ Selected file does not exist.
+
+
+
+
+ Selected file is not readable. Please check file permissions.
+
+
+
+
+ File is too large (over 100MB). Please select a smaller file.
+
+
+
+
+ At least one curve must be defined.
+
+
+
+
+ Curve %1 name cannot be empty.
+
+
+
+
+ Curve name '%1' is duplicated. Please use different names.
+
+
+
+
+ Curve name '%1' is too long. Please limit to 50 characters.
+
+
+
+
+ Curve '%1' start and stop values must be greater than 0.
+
+
+
+
+ Curve '%1' start value cannot be greater than stop value.
+
+
+
+
+ Curve '%1' data range is too small. At least 2 data points are required.
+
+
+
+
+ Curve '%1' stop value is too large. Please ensure it does not exceed 1000000.
+
+
+
+
+ Chart name cannot be empty.
+
+
+
+
+ Chart name is too long. Please limit to 100 characters.
+
+
+
+
+ X axis title is too long. Please limit to 50 characters.
+
+
+
+
+ Y axis title is too long. Please limit to 50 characters.
+
+
+
+
+ X axis minimum value must be less than maximum value.
+
+
+
+
+ Y axis minimum value must be less than maximum value.
+
+
+
+
+ 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.
+
+
AddLightFileDlg
diff --git a/src/ui/WorkSpace/AddCurveFileDlg.cpp b/src/ui/WorkSpace/AddCurveFileDlg.cpp
index 25ffbb04..a10e49f3 100644
--- a/src/ui/WorkSpace/AddCurveFileDlg.cpp
+++ b/src/ui/WorkSpace/AddCurveFileDlg.cpp
@@ -3,16 +3,21 @@
#include
#include
#include
+#include
+#include
#include "ui_AddCurveFileDlg.h"
AddCurveFileDlg::AddCurveFileDlg(QWidget* parent)
: BaseAddFileDlg(FileEntryType::Curve, parent)
- , ui(new Ui::AddCurveFileDlg) {
+ , ui(new Ui::AddCurveFileDlg)
+ , currentCurveIndex_(-1)
+ , selectedColor_(255, 0, 0) { // Default to red color
- ui->setupUi(this);
+ SetupUI(ui);
SetTitle(getDialogTitle());
setupSpecificUI();
+ setupConnections();
}
AddCurveFileDlg::~AddCurveFileDlg() {
@@ -20,16 +25,52 @@ AddCurveFileDlg::~AddCurveFileDlg() {
}
void AddCurveFileDlg::setupSpecificUI() {
- ui->xColumnSpinBox->setValue(1);
- ui->yColumnSpinBox->setValue(2);
- ui->separatorComboBox->setCurrentIndex(0);
- ui->hasHeaderCheckBox->setChecked(true);
+ // Initialize curve properties group as disabled
+ enableCurveProperties(false);
+
+ // Initialize color preview
+ updateColorPreview(selectedColor_);
+
+ // Add a default curve
+ CurveProperties defaultCurve;
+ defaultCurve.name = generateCurveName();
+ defaultCurve.color = generateCurveColor();
+ defaultCurve.start = 1;
+ defaultCurve.stop = 241;
+
+ curves_.append(defaultCurve);
+ addCurveToList(defaultCurve);
+
+ // Select the first curve
+ if (ui->curveListWidget->count() > 0) {
+ ui->curveListWidget->setCurrentRow(0);
+ onCurveSelectionChanged();
+ }
}
void AddCurveFileDlg::setupConnections() {
+ // File selection connections
connect(ui->selectFileBtn, &QToolButton::clicked, this, &AddCurveFileDlg::onSelectFileClicked);
connect(ui->filePathEdit, &QLineEdit::textChanged, this, &AddCurveFileDlg::onFilePathChanged);
- connect(ui->addBtn, &QPushButton::clicked, this, &QDialog::accept);
+
+ // Data format connections
+ connect(ui->separatorComboBox, QOverload::of(&QComboBox::currentIndexChanged),
+ this, &AddCurveFileDlg::onDelimiterChanged);
+ connect(ui->hasHeaderCheckBox, &QCheckBox::toggled, this, &AddCurveFileDlg::onHeaderToggled);
+
+ // Curve management connections
+ connect(ui->addCurveBtn, &QPushButton::clicked, this, &AddCurveFileDlg::onAddCurveClicked);
+ connect(ui->removeCurveBtn, &QPushButton::clicked, this, &AddCurveFileDlg::onRemoveCurveClicked);
+ connect(ui->curveListWidget, &QListWidget::currentRowChanged, this, &AddCurveFileDlg::onCurveSelectionChanged);
+
+ // Curve properties connections
+ connect(ui->colorButton, &QPushButton::clicked, this, &AddCurveFileDlg::onColorButtonClicked);
+ connect(ui->curveNameEdit, &QLineEdit::textChanged, this, &AddCurveFileDlg::onCurveNameChanged);
+ connect(ui->dataStartSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &AddCurveFileDlg::onCurveDataChanged);
+ connect(ui->dataStopSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &AddCurveFileDlg::onCurveDataChanged);
+
+ // Dialog buttons
+ connect(ui->addBtn, &QPushButton::clicked, this, &AddCurveFileDlg::onSure);
connect(ui->cancelBtn, &QPushButton::clicked, this, &QDialog::reject);
}
@@ -47,6 +88,17 @@ void AddCurveFileDlg::onSelectFileClicked() {
}
}
+void AddCurveFileDlg::updateFileInfo(const QString& filePath) {
+ QFileInfo fileInfo(filePath);
+ if (fileInfo.exists()) {
+ ui->fileNameValue->setText(fileInfo.fileName());
+ ui->fileSizeValue->setText(QString::number(fileInfo.size()) + " bytes");
+ } else {
+ ui->fileNameValue->setText("-");
+ ui->fileSizeValue->setText("-");
+ }
+}
+
void AddCurveFileDlg::onFilePathChanged() {
QString filePath = ui->filePathEdit->text();
if (!filePath.isEmpty()) {
@@ -54,23 +106,371 @@ void AddCurveFileDlg::onFilePathChanged() {
}
}
+void AddCurveFileDlg::onAddCurveClicked() {
+ // Save current curve properties if any curve is selected
+ if (currentCurveIndex_ >= 0) {
+ saveCurveProperties();
+ }
+
+ // Create new curve with default properties
+ CurveProperties newCurve;
+ newCurve.name = generateCurveName();
+ newCurve.color = generateCurveColor();
+ newCurve.start = 1;
+ newCurve.stop = 241;
+
+ // Add to curves list and UI
+ curves_.append(newCurve);
+ addCurveToList(newCurve);
+
+ // Select the new curve
+ ui->curveListWidget->setCurrentRow(curves_.size() - 1);
+}
+
+void AddCurveFileDlg::onRemoveCurveClicked() {
+ int currentRow = ui->curveListWidget->currentRow();
+ if (currentRow < 0 || currentRow >= curves_.size()) {
+ return;
+ }
+
+ // Don't allow removing the last curve
+ if (curves_.size() <= 1) {
+ QMessageBox::information(this, "Information", "At least one curve must remain.");
+ return;
+ }
+
+ // Remove from curves list and UI
+ curves_.removeAt(currentRow);
+ delete ui->curveListWidget->takeItem(currentRow);
+
+ // Update current index
+ if (currentRow >= curves_.size()) {
+ currentRow = curves_.size() - 1;
+ }
+
+ if (currentRow >= 0) {
+ ui->curveListWidget->setCurrentRow(currentRow);
+ } else {
+ currentCurveIndex_ = -1;
+ clearCurveProperties();
+ enableCurveProperties(false);
+ }
+}
+
+void AddCurveFileDlg::onCurveSelectionChanged() {
+ int currentRow = ui->curveListWidget->currentRow();
+
+ // Save previous curve properties
+ if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size()) {
+ saveCurveProperties();
+ }
+
+ currentCurveIndex_ = currentRow;
+
+ if (currentRow >= 0 && currentRow < curves_.size()) {
+ // Load selected curve properties
+ updateCurveProperties();
+ enableCurveProperties(true);
+ } else {
+ clearCurveProperties();
+ enableCurveProperties(false);
+ }
+}
+
+void AddCurveFileDlg::onCurveNameChanged() {
+ if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size()) {
+ QString newName = ui->curveNameEdit->text();
+ curves_[currentCurveIndex_].name = newName;
+
+ // Update list item text
+ QListWidgetItem* item = ui->curveListWidget->item(currentCurveIndex_);
+ if (item) {
+ item->setText(QString("%1 [%2,%3] (%4,%5,%6)")
+ .arg(newName)
+ .arg(curves_[currentCurveIndex_].start)
+ .arg(curves_[currentCurveIndex_].stop)
+ .arg(curves_[currentCurveIndex_].color.red())
+ .arg(curves_[currentCurveIndex_].color.green())
+ .arg(curves_[currentCurveIndex_].color.blue()));
+ }
+ }
+}
+
+void AddCurveFileDlg::onCurveDataChanged() {
+ if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size()) {
+ curves_[currentCurveIndex_].start = ui->dataStartSpinBox->value();
+ curves_[currentCurveIndex_].stop = ui->dataStopSpinBox->value();
+
+ // Update list item text
+ QListWidgetItem* item = ui->curveListWidget->item(currentCurveIndex_);
+ if (item) {
+ item->setText(QString("%1 [%2,%3] (%4,%5,%6)")
+ .arg(curves_[currentCurveIndex_].name)
+ .arg(curves_[currentCurveIndex_].start)
+ .arg(curves_[currentCurveIndex_].stop)
+ .arg(curves_[currentCurveIndex_].color.red())
+ .arg(curves_[currentCurveIndex_].color.green())
+ .arg(curves_[currentCurveIndex_].color.blue()));
+ }
+ }
+}
+
+void AddCurveFileDlg::onColorButtonClicked() {
+ if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size()) {
+ QColor color = QColorDialog::getColor(curves_[currentCurveIndex_].color, this, "Select Curve Color");
+ if (color.isValid()) {
+ curves_[currentCurveIndex_].color = color;
+ selectedColor_ = color;
+ updateColorPreview(color);
+
+ // Update list item text
+ QListWidgetItem* item = ui->curveListWidget->item(currentCurveIndex_);
+ if (item) {
+ item->setText(QString("%1 [%2,%3] (%4,%5,%6)")
+ .arg(curves_[currentCurveIndex_].name)
+ .arg(curves_[currentCurveIndex_].start)
+ .arg(curves_[currentCurveIndex_].stop)
+ .arg(color.red())
+ .arg(color.green())
+ .arg(color.blue()));
+ }
+ }
+ }
+}
+
+void AddCurveFileDlg::addCurveToList(const CurveProperties& curve) {
+ QString itemText = QString("%1 [%2,%3] (%4,%5,%6)")
+ .arg(curve.name)
+ .arg(curve.start)
+ .arg(curve.stop)
+ .arg(curve.color.red())
+ .arg(curve.color.green())
+ .arg(curve.color.blue());
+
+ ui->curveListWidget->addItem(itemText);
+}
+
+void AddCurveFileDlg::updateCurveProperties() {
+ if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size()) {
+ const CurveProperties& curve = curves_[currentCurveIndex_];
+
+ ui->curveNameEdit->setText(curve.name);
+ ui->dataStartSpinBox->setValue(curve.start);
+ ui->dataStopSpinBox->setValue(curve.stop);
+
+ selectedColor_ = curve.color;
+ updateColorPreview(curve.color);
+ }
+}
+
+void AddCurveFileDlg::saveCurveProperties() {
+ if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size()) {
+ curves_[currentCurveIndex_].name = ui->curveNameEdit->text();
+ curves_[currentCurveIndex_].start = ui->dataStartSpinBox->value();
+ curves_[currentCurveIndex_].stop = ui->dataStopSpinBox->value();
+ curves_[currentCurveIndex_].color = selectedColor_;
+ }
+}
+
+void AddCurveFileDlg::clearCurveProperties() {
+ ui->curveNameEdit->clear();
+ ui->dataStartSpinBox->setValue(1);
+ ui->dataStopSpinBox->setValue(241);
+ selectedColor_ = QColor(255, 0, 0);
+ updateColorPreview(selectedColor_);
+}
+
+void AddCurveFileDlg::enableCurveProperties(bool enabled) {
+ ui->curvePropertiesGroupBox->setEnabled(enabled);
+}
+
+QString AddCurveFileDlg::generateCurveName() {
+ return tr("Curve %1").arg(curves_.size() + 1);
+}
+
+QColor AddCurveFileDlg::generateCurveColor() const {
+ // Generate different colors for each curve
+ static const QColor colors[] = {
+ QColor(255, 0, 0), // Red
+ QColor(0, 255, 0), // Green
+ QColor(0, 0, 255), // Blue
+ QColor(255, 255, 0), // Yellow
+ QColor(255, 0, 255), // Magenta
+ QColor(0, 255, 255), // Cyan
+ QColor(255, 128, 0), // Orange
+ QColor(128, 0, 255), // Purple
+ };
+
+ int colorIndex = curves_.size() % (sizeof(colors) / sizeof(colors[0]));
+ return colors[colorIndex];
+}
+
+void AddCurveFileDlg::updateColorPreview(const QColor& color) {
+ QString styleSheet = QString("background-color: rgb(%1, %2, %3); border: 1px solid black;")
+ .arg(color.red())
+ .arg(color.green())
+ .arg(color.blue());
+ ui->colorPreview->setStyleSheet(styleSheet);
+}
+
bool AddCurveFileDlg::validateSpecificParams() {
- if (ui->filePathEdit->text().trimmed().isEmpty()) {
- QMessageBox::warning(this, QStringLiteral("Warning"),
- QStringLiteral("Please select a curve data file."));
+ // File path validation
+ if (ui->filePathEdit->text().isEmpty()) {
+ QMessageBox::warning(this, tr("Validation Error"), tr("Please select a data file."));
return false;
}
+ // File existence validation
QFileInfo fileInfo(ui->filePathEdit->text());
if (!fileInfo.exists()) {
- QMessageBox::warning(this, QStringLiteral("Warning"),
- QStringLiteral("The selected file does not exist."));
+ QMessageBox::warning(this, tr("Validation Error"), tr("Selected file does not exist."));
return false;
}
- if (ui->xColumnSpinBox->value() == ui->yColumnSpinBox->value()) {
- QMessageBox::warning(this, QStringLiteral("Warning"),
- QStringLiteral("X and Y columns must be different."));
+ // File readability validation
+ if (!fileInfo.isReadable()) {
+ QMessageBox::warning(this, tr("Validation Error"), tr("Selected file is not readable. Please check file permissions."));
+ return false;
+ }
+
+ // File size validation (avoid memory issues with large files)
+ if (fileInfo.size() > 100 * 1024 * 1024) { // 100MB limit
+ QMessageBox::warning(this, tr("Validation Error"), tr("File is too large (over 100MB). Please select a smaller file."));
+ return false;
+ }
+
+ // Curve count validation
+ if (curves_.isEmpty()) {
+ QMessageBox::warning(this, tr("Validation Error"), tr("At least one curve must be defined."));
+ return false;
+ }
+
+ // Save current curve properties
+ if (currentCurveIndex_ >= 0) {
+ saveCurveProperties();
+ }
+
+ // Curve name uniqueness validation
+ QStringList curveNames;
+ for (int i = 0; i < curves_.size(); ++i) {
+ const CurveProperties& curve = curves_[i];
+
+ if (curve.name.isEmpty()) {
+ QMessageBox::warning(this, tr("Validation Error"),
+ tr("Curve %1 name cannot be empty.").arg(i + 1));
+ return false;
+ }
+
+ if (curveNames.contains(curve.name)) {
+ QMessageBox::warning(this, tr("Validation Error"),
+ tr("Curve name '%1' is duplicated. Please use different names.").arg(curve.name));
+ return false;
+ }
+ curveNames.append(curve.name);
+
+ // Curve name length validation
+ if (curve.name.length() > 50) {
+ QMessageBox::warning(this, tr("Validation Error"),
+ tr("Curve name '%1' is too long. Please limit to 50 characters.").arg(curve.name));
+ return false;
+ }
+
+ // Data range validation
+ if (curve.start < 1 || curve.stop < 1) {
+ QMessageBox::warning(this, tr("Validation Error"),
+ tr("Curve '%1' start and stop values must be greater than 0.").arg(curve.name));
+ return false;
+ }
+
+ if (curve.start > curve.stop) {
+ QMessageBox::warning(this, tr("Validation Error"),
+ tr("Curve '%1' start value cannot be greater than stop value.").arg(curve.name));
+ return false;
+ }
+
+ // Data range reasonableness validation
+ if (curve.stop - curve.start < 1) {
+ QMessageBox::warning(this, tr("Validation Error"),
+ tr("Curve '%1' data range is too small. At least 2 data points are required.").arg(curve.name));
+ return false;
+ }
+
+ if (curve.stop > 1000000) {
+ QMessageBox::warning(this, tr("Validation Error"),
+ tr("Curve '%1' stop value is too large. Please ensure it does not exceed 1000000.").arg(curve.name));
+ return false;
+ }
+ }
+
+ // Chart properties validation
+ if (ui->chartNameEdit->text().isEmpty()) {
+ QMessageBox::warning(this, tr("Validation Error"), tr("Chart name cannot be empty."));
+ return false;
+ }
+
+ if (ui->chartNameEdit->text().length() > 100) {
+ QMessageBox::warning(this, tr("Validation Error"), tr("Chart name is too long. Please limit to 100 characters."));
+ return false;
+ }
+
+ // Axis title validation
+ if (ui->xTitleEdit->text().length() > 50) {
+ QMessageBox::warning(this, tr("Validation Error"), tr("X axis title is too long. Please limit to 50 characters."));
+ return false;
+ }
+
+ if (ui->yTitleEdit->text().length() > 50) {
+ QMessageBox::warning(this, tr("Validation Error"), tr("Y axis title is too long. Please limit to 50 characters."));
+ return false;
+ }
+
+ // Axis range validation
+ double xMin = ui->xMinSpinBox->value();
+ double xMax = ui->xMaxSpinBox->value();
+ double yMin = ui->yMinSpinBox->value();
+ double yMax = ui->yMaxSpinBox->value();
+
+ if (xMin >= xMax) {
+ QMessageBox::warning(this, tr("Validation Error"), tr("X axis minimum value must be less than maximum value."));
+ return false;
+ }
+
+ if (yMin >= yMax) {
+ QMessageBox::warning(this, tr("Validation Error"), tr("Y axis minimum value must be less than maximum value."));
+ 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) {
+ QMessageBox::warning(this, tr("Validation Error"), tr("Time parameter cannot be negative."));
+ return false;
+ }
+
+ // X axis tick count validation
+ int xTickCount = ui->xCountSpinBox->value();
+ if (xTickCount < 2) {
+ 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;
}
@@ -78,37 +478,75 @@ bool AddCurveFileDlg::validateSpecificParams() {
}
QString AddCurveFileDlg::getFileFilter() const {
- return QStringLiteral("Curve Data Files (*.txt *.csv *.dat);;All Files (*.*)");
+ return "Data Files (*.txt *.csv *.dat);;All Files (*.*)";
}
QString AddCurveFileDlg::getDialogTitle() const {
- return QStringLiteral("Add Curve Data File");
-}
-
-void AddCurveFileDlg::onDelimiterChanged() {
- // Handle delimiter change if needed
-}
-
-void AddCurveFileDlg::onHeaderToggled(bool hasHeader) {
- // Handle header toggle if needed
+ return "Add Curve Data File";
}
AddCurveFileDlg::CurveParams AddCurveFileDlg::getCurveParams() const {
CurveParams params;
- params.xColumn = ui->xColumnSpinBox->value();
- params.yColumn = ui->yColumnSpinBox->value();
+ params.chart = getChartProperties();
+ params.curves = getCurveProperties();
+ params.format = getDataFormatParams();
+ return params;
+}
+
+AddCurveFileDlg::ChartProperties AddCurveFileDlg::getChartProperties() const {
+ ChartProperties chart;
+ chart.name = ui->chartNameEdit->text();
+ chart.path = ui->filePathEdit->text();
+ chart.xTitle = ui->xTitleEdit->text();
+ chart.yTitle = ui->yTitleEdit->text();
+ chart.xMin = ui->xMinSpinBox->value();
+ chart.xMax = ui->xMaxSpinBox->value();
+ chart.xCount = ui->xCountSpinBox->value();
+ chart.yMin = ui->yMinSpinBox->value();
+ chart.yMax = ui->yMaxSpinBox->value();
+ chart.timeParam = ui->timeParamSpinBox->value();
+ return chart;
+}
+
+QList AddCurveFileDlg::getCurveProperties() const {
+ return curves_;
+}
+
+AddCurveFileDlg::DataFormatParams AddCurveFileDlg::getDataFormatParams() const {
+ DataFormatParams format;
- // 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;
+ // Get delimiter based on combo box selection
+ QString delimiterText = ui->separatorComboBox->currentText();
+ if (delimiterText.contains("Comma")) {
+ format.delimiter = ",";
+ } else if (delimiterText.contains("Tab")) {
+ format.delimiter = "\t";
+ } else if (delimiterText.contains("Space")) {
+ format.delimiter = " ";
+ } else if (delimiterText.contains("Semicolon")) {
+ format.delimiter = ";";
+ } else {
+ format.delimiter = ","; // Default
}
- params.hasHeader = ui->hasHeaderCheckBox->isChecked();
- params.description = ui->descriptionEdit->toPlainText().trimmed();
- return params;
+ format.hasHeader = ui->hasHeaderCheckBox->isChecked();
+ format.xColumn = ui->xColumnSpinBox->value();
+ format.yColumn = ui->yColumnSpinBox->value();
+ format.description = ui->descriptionEdit->toPlainText();
+
+ return format;
+}
+
+void AddCurveFileDlg::onDelimiterChanged() {
+ // This slot can be used for future delimiter-related logic
+}
+
+void AddCurveFileDlg::onHeaderToggled(bool hasHeader) {
+ // This slot can be used for future header-related logic
+}
+
+void AddCurveFileDlg::onSure() {
+ if (validateSpecificParams()) {
+ accept();
+ }
}
\ No newline at end of file
diff --git a/src/ui/WorkSpace/AddCurveFileDlg.h b/src/ui/WorkSpace/AddCurveFileDlg.h
index 72337c0a..d9989c34 100644
--- a/src/ui/WorkSpace/AddCurveFileDlg.h
+++ b/src/ui/WorkSpace/AddCurveFileDlg.h
@@ -1,16 +1,20 @@
#pragma once
#include "BaseAddFileDlg.h"
+#include
+#include
-QT_BEGIN_NAMESPACE
class QLineEdit;
class QCheckBox;
class QSpinBox;
+class QDoubleSpinBox;
class QComboBox;
class QTextEdit;
class QToolButton;
class QLabel;
-QT_END_NAMESPACE
+class QPushButton;
+class QListWidget;
+class QListWidgetItem;
namespace Ui {
class AddCurveFileDlg;
@@ -20,7 +24,30 @@ class AddCurveFileDlg : public BaseAddFileDlg {
Q_OBJECT
public:
- struct CurveParams {
+ // Chart properties structure
+ struct ChartProperties {
+ QString name;
+ QString path;
+ QString xTitle;
+ QString yTitle;
+ double xMin;
+ double xMax;
+ int xCount;
+ double yMin;
+ double yMax;
+ double timeParam;
+ };
+
+ // Curve properties structure
+ struct CurveProperties {
+ QString name;
+ QColor color;
+ int start;
+ int stop;
+ };
+
+ // Data format parameters structure
+ struct DataFormatParams {
QString delimiter;
bool hasHeader;
int xColumn;
@@ -28,10 +55,20 @@ public:
QString description;
};
+ // Combined parameters structure
+ struct CurveParams {
+ ChartProperties chart;
+ QList curves; // Changed to support multiple curves
+ DataFormatParams format;
+ };
+
explicit AddCurveFileDlg(QWidget* parent = nullptr);
~AddCurveFileDlg() override;
CurveParams getCurveParams() const;
+ ChartProperties getChartProperties() const;
+ QList getCurveProperties() const; // Changed to return list
+ DataFormatParams getDataFormatParams() const;
protected:
QString getFileFilter() const override;
@@ -44,10 +81,27 @@ private slots:
void onHeaderToggled(bool hasHeader);
void onSelectFileClicked();
void onFilePathChanged();
+ void onColorButtonClicked();
+ void onAddCurveClicked();
+ void onRemoveCurveClicked();
+ void onCurveSelectionChanged();
+ void onCurveNameChanged();
+ void onCurveDataChanged();
private:
void setupConnections();
+ void updateFileInfo(const QString& filePath);
+ void updateColorPreview(const QColor& color);
+ void addCurveToList(const CurveProperties& curve);
+ void updateCurveProperties();
+ void saveCurveProperties();
+ void clearCurveProperties();
+ void enableCurveProperties(bool enabled);
+ QString generateCurveName();
+ QColor generateCurveColor() const;
-private:
Ui::AddCurveFileDlg* ui;
+ QList curves_;
+ int currentCurveIndex_;
+ QColor selectedColor_;
};
\ No newline at end of file
diff --git a/src/ui/WorkSpace/AddCurveFileDlg.ui b/src/ui/WorkSpace/AddCurveFileDlg.ui
index a511758a..27208739 100644
--- a/src/ui/WorkSpace/AddCurveFileDlg.ui
+++ b/src/ui/WorkSpace/AddCurveFileDlg.ui
@@ -6,8 +6,8 @@
0
0
- 500
- 450
+ 600
+ 700
@@ -75,10 +75,384 @@
+ -
+
+
+ Chart Properties
+
+
+
-
+
+
+ Chart Name:
+
+
+
+ -
+
+
+ Chart 1
+
+
+ Enter chart name...
+
+
+
+ -
+
+
+ X Axis Title:
+
+
+
+ -
+
+
+ Enter X axis title...
+
+
+
+ -
+
+
+ Y Axis Title:
+
+
+
+ -
+
+
+ Enter Y axis title...
+
+
+
+ -
+
+
+ Time Parameter:
+
+
+
+ -
+
+
+ 0.000000000000000
+
+
+ 999999.000000000000000
+
+
+ 0.000000000000000
+
+
+
+
+
+
+ -
+
+
+ Axis Range Settings
+
+
+
-
+
+
+ X Min:
+
+
+
+ -
+
+
+ -999999.000000000000000
+
+
+ 999999.000000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ X Max:
+
+
+
+ -
+
+
+ -999999.000000000000000
+
+
+ 999999.000000000000000
+
+
+ 250.000000000000000
+
+
+
+ -
+
+
+ Y Min:
+
+
+
+ -
+
+
+ -999999.000000000000000
+
+
+ 999999.000000000000000
+
+
+ -800.000000000000000
+
+
+
+ -
+
+
+ Y Max:
+
+
+
+ -
+
+
+ -999999.000000000000000
+
+
+ 999999.000000000000000
+
+
+ 800.000000000000000
+
+
+
+ -
+
+
+ X Tick Count:
+
+
+
+ -
+
+
+ 2
+
+
+ 50
+
+
+ 6
+
+
+
+
+
+
+ -
+
+
+ Curve Management
+
+
+
-
+
+
-
+
+
+ Curves:
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Add Curve
+
+
+
+ 80
+ 16777215
+
+
+
+
+ -
+
+
+ Remove
+
+
+
+ 60
+ 16777215
+
+
+
+
+
+
+ -
+
+
+
+ 16777215
+ 120
+
+
+
+ true
+
+
+
+ -
+
+
+ Selected Curve Properties
+
+
+ false
+
+
+
-
+
+
+ Curve Name:
+
+
+
+ -
+
+
+ Enter curve name...
+
+
+
+ -
+
+
+ Curve Color:
+
+
+
+ -
+
+
-
+
+
+ Select Color
+
+
+
+ 100
+ 16777215
+
+
+
+
+ -
+
+
+
+ 50
+ 25
+
+
+
+ background-color: rgb(255, 0, 0); border: 1px solid black;
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ Data Start:
+
+
+
+ -
+
+
+ 1
+
+
+ 999999
+
+
+ 1
+
+
+
+ -
+
+
+ Data Stop:
+
+
+
+ -
+
+
+ 1
+
+
+ 999999
+
+
+ 241
+
+
+
+
+
+
+
+
+
-
- Curve Parameters
+ Data Format Parameters
-
@@ -176,7 +550,7 @@
16777215
- 80
+ 60
@@ -195,7 +569,7 @@
20
- 40
+ 20
diff --git a/src/ui/WorkSpace/BaseAddFileDlg.cpp b/src/ui/WorkSpace/BaseAddFileDlg.cpp
index 98a4a30b..8efc49c7 100644
--- a/src/ui/WorkSpace/BaseAddFileDlg.cpp
+++ b/src/ui/WorkSpace/BaseAddFileDlg.cpp
@@ -23,11 +23,9 @@ BaseAddFileDlg::BaseAddFileDlg(FileEntryType fileType, QWidget* parent)
, tbSelectFile_(nullptr)
, lblFileName_(nullptr)
, lblFileSize_(nullptr)
- , teDescription_(nullptr)
- , pbAdd_(nullptr)
- , pbCancel_(nullptr) {
+ , teDescription_(nullptr) {
- setupBaseUI();
+ //setupBaseUI();
initBaseConnect();
}
@@ -91,20 +89,10 @@ void BaseAddFileDlg::setupBaseUI() {
descLayout->addWidget(teDescription_);
mainLayout->addWidget(descGroup);
- QHBoxLayout* buttonLayout = new QHBoxLayout();
- buttonLayout->addStretch();
- pbAdd_ = new QPushButton(QStringLiteral("Add"), this);
- pbCancel_ = new QPushButton(QStringLiteral("Cancel"), this);
- buttonLayout->addWidget(pbAdd_);
- buttonLayout->addWidget(pbCancel_);
-
- mainLayout->addLayout(buttonLayout);
}
void BaseAddFileDlg::initBaseConnect() {
connect(tbSelectFile_, &QToolButton::clicked, this, &BaseAddFileDlg::OnSelectFile);
- connect(pbAdd_, &QPushButton::clicked, this, &BaseAddFileDlg::OnSure);
- connect(pbCancel_, &QPushButton::clicked, this, &BaseAddFileDlg::reject);
}
void BaseAddFileDlg::OnSelectFile() {
diff --git a/src/ui/WorkSpace/BaseAddFileDlg.h b/src/ui/WorkSpace/BaseAddFileDlg.h
index 9acb86c3..4de55b03 100644
--- a/src/ui/WorkSpace/BaseAddFileDlg.h
+++ b/src/ui/WorkSpace/BaseAddFileDlg.h
@@ -10,7 +10,6 @@
class QLineEdit;
class QLabel;
class QTextEdit;
-class QPushButton;
class QToolButton;
class BaseAddFileDlg : public Dialog {
@@ -38,8 +37,6 @@ protected:
QLabel* lblFileName_;
QLabel* lblFileSize_;
QTextEdit* teDescription_;
- QPushButton* pbAdd_;
- QPushButton* pbCancel_;
void setupBaseUI();
void initBaseConnect();