modify light
This commit is contained in:
parent
05d2968d41
commit
8c0f345454
@ -436,11 +436,6 @@
|
||||
</context>
|
||||
<context>
|
||||
<name>AddLightFileDlg</name>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="14"/>
|
||||
<source>Add Light Spectrum File</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="20"/>
|
||||
<source>File Selection</source>
|
||||
@ -452,8 +447,13 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="33"/>
|
||||
<source>Select light spectrum file...</source>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="14"/>
|
||||
<source>Add Light Data File</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="36"/>
|
||||
<source>Select light data file...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
@ -479,144 +479,121 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="81"/>
|
||||
<source>Spectrum Parameters</source>
|
||||
<source>Color Properties</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="87"/>
|
||||
<source>Wavelength Column:</source>
|
||||
<source>Open Color:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="107"/>
|
||||
<source>Intensity Column:</source>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="102"/>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="155"/>
|
||||
<source>Select Color</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="127"/>
|
||||
<source>Separator:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="135"/>
|
||||
<source>Comma (,)</source>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="115"/>
|
||||
<source>background-color: rgb(0, 255, 0); border: 1px solid black;</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="140"/>
|
||||
<source>Tab</source>
|
||||
<source>Close Color:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="145"/>
|
||||
<source>Space</source>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="168"/>
|
||||
<source>background-color: rgb(255, 0, 0); border: 1px solid black;</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="150"/>
|
||||
<source>Semicolon (;)</source>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="196"/>
|
||||
<source>Light Management</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="158"/>
|
||||
<source>Wavelength Unit:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="166"/>
|
||||
<source>nm (nanometer)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="171"/>
|
||||
<source>μm (micrometer)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="176"/>
|
||||
<source>cm⁻¹ (wavenumber)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="181"/>
|
||||
<source>eV (electron volt)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="189"/>
|
||||
<source>Intensity Unit:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="197"/>
|
||||
<source>Arbitrary Units</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="202"/>
|
||||
<source>Counts</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="207"/>
|
||||
<source>W/m²/nm</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="212"/>
|
||||
<source>μW/cm²/nm</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="220"/>
|
||||
<source>File has header row</source>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="204"/>
|
||||
<source>Lights:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="230"/>
|
||||
<source>Normalize intensity values</source>
|
||||
<source>Add Light</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="243"/>
|
||||
<source>Wavelength Range (Optional)</source>
|
||||
<source>Remove</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="249"/>
|
||||
<source>Min Wavelength:</source>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="268"/>
|
||||
<source>Selected Light Properties</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="269"/>
|
||||
<source>Max Wavelength:</source>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="274"/>
|
||||
<source>Light Name:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="289"/>
|
||||
<source>Enable wavelength range filtering</source>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="281"/>
|
||||
<source>Enter light name...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="302"/>
|
||||
<source>Description (Optional)</source>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="288"/>
|
||||
<source>Light Index:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="314"/>
|
||||
<source>Enter file description...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="352"/>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="329"/>
|
||||
<source>Add File</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="362"/>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.ui" line="336"/>
|
||||
<source>Cancel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.cpp" line="302"/>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.cpp" line="339"/>
|
||||
<source>Error</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.cpp" line="302"/>
|
||||
<source>Unable to get current workspace</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.cpp" line="324"/>
|
||||
<source>Curve file count has reached the limit (9 files)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.cpp" line="327"/>
|
||||
<source>File already exists</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.cpp" line="330"/>
|
||||
<source>File copy failed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.cpp" line="333"/>
|
||||
<source>Invalid file</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/AddLightFileDlg.cpp" line="336"/>
|
||||
<source>Failed to add file</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>AddParamSetting</name>
|
||||
|
||||
@ -1,28 +1,277 @@
|
||||
#include "AddLightFileDlg.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QColorDialog>
|
||||
#include <QListWidget>
|
||||
|
||||
#include "workspace/WorkSpace.h"
|
||||
#include "workspace/WorkSpaceManager.h"
|
||||
|
||||
#include "ui_AddLightFileDlg.h"
|
||||
|
||||
AddLightFileDlg::AddLightFileDlg(QWidget* parent)
|
||||
: BaseAddFileDlg(FileEntryType::Light, parent)
|
||||
, ui(new Ui::AddLightFileDlg) {
|
||||
, ui(new Ui::AddLightFileDlg)
|
||||
, currentLightIndex_(-1)
|
||||
, openColor_(0, 255, 0) // Default to green color
|
||||
, closeColor_(255, 0, 0) { // Default to red color
|
||||
|
||||
ui->setupUi(this);
|
||||
SetupUI(ui);
|
||||
SetTitle(getDialogTitle());
|
||||
setupConnections();
|
||||
|
||||
// Initialize color properties
|
||||
colorProperties_.openColor = openColor_;
|
||||
colorProperties_.closeColor = closeColor_;
|
||||
|
||||
// Update color previews
|
||||
updateOpenColorPreview(openColor_);
|
||||
updateCloseColorPreview(closeColor_);
|
||||
}
|
||||
|
||||
AddLightFileDlg::~AddLightFileDlg() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool AddLightFileDlg::validateSpecificParams() {
|
||||
LightParams params = getLightParams();
|
||||
void AddLightFileDlg::setupConnections() {
|
||||
// File selection connections
|
||||
connect(ui->selectFileBtn, &QToolButton::clicked, this, &AddLightFileDlg::OnSelectFile);
|
||||
|
||||
if (params.delimiter.isEmpty()) {
|
||||
QMessageBox::warning(this, QStringLiteral("Warning"),
|
||||
QStringLiteral("Please specify a delimiter for light data."));
|
||||
// Color selection connections
|
||||
connect(ui->openColorButton, &QPushButton::clicked, this, &AddLightFileDlg::onOpenColorButtonClicked);
|
||||
connect(ui->closeColorButton, &QPushButton::clicked, this, &AddLightFileDlg::onCloseColorButtonClicked);
|
||||
|
||||
// Light management connections
|
||||
connect(ui->addLightBtn, &QPushButton::clicked, this, &AddLightFileDlg::onAddLightClicked);
|
||||
connect(ui->removeLightBtn, &QPushButton::clicked, this, &AddLightFileDlg::onRemoveLightClicked);
|
||||
connect(ui->lightListWidget, &QListWidget::currentRowChanged, this, &AddLightFileDlg::onLightSelectionChanged);
|
||||
connect(ui->lightListWidget, &QListWidget::itemClicked, this, &AddLightFileDlg::onLightListWidgetItemClicked);
|
||||
|
||||
// Light properties connections
|
||||
connect(ui->lightNameEdit, &QLineEdit::textChanged, this, &AddLightFileDlg::onLightNameChanged);
|
||||
connect(ui->lightIndexSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &AddLightFileDlg::onLightIndexChanged);
|
||||
|
||||
// Dialog buttons
|
||||
connect(ui->addFileBtn, &QPushButton::clicked, this, &AddLightFileDlg::onSure);
|
||||
connect(ui->cancelBtn, &QPushButton::clicked, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
void AddLightFileDlg::updateFileInfo(const QString& filePath) {
|
||||
QFileInfo fileInfo(filePath);
|
||||
if (fileInfo.exists()) {
|
||||
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);
|
||||
} else {
|
||||
ui->fileNameValue->setText("-");
|
||||
ui->fileSizeValue->setText("-");
|
||||
}
|
||||
|
||||
ui->filePathEdit->setText(filePath);
|
||||
}
|
||||
|
||||
void AddLightFileDlg::onOpenColorButtonClicked() {
|
||||
QColor color = QColorDialog::getColor(openColor_, this, "Select Open Color");
|
||||
if (color.isValid()) {
|
||||
openColor_ = color;
|
||||
colorProperties_.openColor = color;
|
||||
updateOpenColorPreview(color);
|
||||
}
|
||||
}
|
||||
|
||||
void AddLightFileDlg::onCloseColorButtonClicked() {
|
||||
QColor color = QColorDialog::getColor(closeColor_, this, "Select Close Color");
|
||||
if (color.isValid()) {
|
||||
closeColor_ = color;
|
||||
colorProperties_.closeColor = color;
|
||||
updateCloseColorPreview(color);
|
||||
}
|
||||
}
|
||||
|
||||
void AddLightFileDlg::onAddLightClicked() {
|
||||
// Save current light properties if any light is selected
|
||||
if (currentLightIndex_ >= 0) {
|
||||
saveLightProperties();
|
||||
}
|
||||
|
||||
// Create new light with default properties
|
||||
FileEntryLight::LightProperty newLight;
|
||||
newLight.name = generateLightName();
|
||||
newLight.index = lights_.size();
|
||||
|
||||
// Add to lights list
|
||||
lights_.append(newLight);
|
||||
|
||||
// Add to UI list widget
|
||||
QListWidgetItem* item = new QListWidgetItem(QString("%1 [Index: %2]")
|
||||
.arg(newLight.name)
|
||||
.arg(newLight.index));
|
||||
ui->lightListWidget->addItem(item);
|
||||
|
||||
// Select the new item
|
||||
ui->lightListWidget->setCurrentRow(lights_.size() - 1);
|
||||
currentLightIndex_ = lights_.size() - 1;
|
||||
|
||||
// Enable properties editing
|
||||
enableLightProperties(true);
|
||||
updateLightProperties();
|
||||
}
|
||||
|
||||
void AddLightFileDlg::onRemoveLightClicked() {
|
||||
int currentRow = ui->lightListWidget->currentRow();
|
||||
if (currentRow >= 0 && currentRow < lights_.size()) {
|
||||
// Remove from data
|
||||
lights_.removeAt(currentRow);
|
||||
|
||||
// Remove from UI
|
||||
delete ui->lightListWidget->takeItem(currentRow);
|
||||
|
||||
// Update current index
|
||||
if (lights_.isEmpty()) {
|
||||
currentLightIndex_ = -1;
|
||||
enableLightProperties(false);
|
||||
clearLightProperties();
|
||||
} else {
|
||||
// Select next item or previous if at end
|
||||
int newIndex = qMin(currentRow, lights_.size() - 1);
|
||||
ui->lightListWidget->setCurrentRow(newIndex);
|
||||
currentLightIndex_ = newIndex;
|
||||
updateLightProperties();
|
||||
}
|
||||
|
||||
// Update list display with new indices
|
||||
for (int i = 0; i < lights_.size(); ++i) {
|
||||
lights_[i].index = i;
|
||||
QListWidgetItem* item = ui->lightListWidget->item(i);
|
||||
if (item) {
|
||||
item->setText(QString("%1 [Index: %2]")
|
||||
.arg(lights_[i].name)
|
||||
.arg(lights_[i].index));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddLightFileDlg::onLightListWidgetItemClicked(QListWidgetItem* item) {
|
||||
Q_UNUSED(item)
|
||||
onLightSelectionChanged();
|
||||
}
|
||||
|
||||
void AddLightFileDlg::onLightSelectionChanged() {
|
||||
int currentRow = ui->lightListWidget->currentRow();
|
||||
if (currentRow >= 0 && currentRow < lights_.size()) {
|
||||
// Save previous light properties
|
||||
if (currentLightIndex_ >= 0 && currentLightIndex_ < lights_.size()) {
|
||||
saveLightProperties();
|
||||
}
|
||||
|
||||
currentLightIndex_ = currentRow;
|
||||
enableLightProperties(true);
|
||||
updateLightProperties();
|
||||
} else {
|
||||
currentLightIndex_ = -1;
|
||||
enableLightProperties(false);
|
||||
clearLightProperties();
|
||||
}
|
||||
}
|
||||
|
||||
void AddLightFileDlg::onLightNameChanged() {
|
||||
if (currentLightIndex_ >= 0 && currentLightIndex_ < lights_.size()) {
|
||||
QString newName = ui->lightNameEdit->text();
|
||||
lights_[currentLightIndex_].name = newName;
|
||||
|
||||
// Update list widget item text
|
||||
QListWidgetItem* item = ui->lightListWidget->item(currentLightIndex_);
|
||||
if (item) {
|
||||
item->setText(QString("%1 [Index: %2]")
|
||||
.arg(newName)
|
||||
.arg(lights_[currentLightIndex_].index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddLightFileDlg::onLightIndexChanged() {
|
||||
if (currentLightIndex_ >= 0 && currentLightIndex_ < lights_.size()) {
|
||||
int newIndex = ui->lightIndexSpinBox->value();
|
||||
lights_[currentLightIndex_].index = newIndex;
|
||||
|
||||
// Update list widget item text
|
||||
QListWidgetItem* item = ui->lightListWidget->item(currentLightIndex_);
|
||||
if (item) {
|
||||
item->setText(QString("%1 [Index: %2]")
|
||||
.arg(lights_[currentLightIndex_].name)
|
||||
.arg(newIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddLightFileDlg::updateOpenColorPreview(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->openColorPreview->setStyleSheet(styleSheet);
|
||||
}
|
||||
|
||||
void AddLightFileDlg::updateCloseColorPreview(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->closeColorPreview->setStyleSheet(styleSheet);
|
||||
}
|
||||
|
||||
void AddLightFileDlg::addLightToList(const FileEntryLight::LightProperty& light) {
|
||||
QListWidgetItem* item = new QListWidgetItem(QString("%1 [Index: %2]")
|
||||
.arg(light.name)
|
||||
.arg(light.index));
|
||||
ui->lightListWidget->addItem(item);
|
||||
}
|
||||
|
||||
void AddLightFileDlg::updateLightProperties() {
|
||||
if (currentLightIndex_ >= 0 && currentLightIndex_ < lights_.size()) {
|
||||
const FileEntryLight::LightProperty& light = lights_[currentLightIndex_];
|
||||
ui->lightNameEdit->setText(light.name);
|
||||
ui->lightIndexSpinBox->setValue(light.index);
|
||||
}
|
||||
}
|
||||
|
||||
void AddLightFileDlg::saveLightProperties() {
|
||||
if (currentLightIndex_ >= 0 && currentLightIndex_ < lights_.size()) {
|
||||
lights_[currentLightIndex_].name = ui->lightNameEdit->text();
|
||||
lights_[currentLightIndex_].index = ui->lightIndexSpinBox->value();
|
||||
}
|
||||
}
|
||||
|
||||
void AddLightFileDlg::clearLightProperties() {
|
||||
ui->lightNameEdit->clear();
|
||||
ui->lightIndexSpinBox->setValue(0);
|
||||
}
|
||||
|
||||
void AddLightFileDlg::enableLightProperties(bool enabled) {
|
||||
ui->lightPropertiesGroupBox->setEnabled(enabled);
|
||||
}
|
||||
|
||||
QString AddLightFileDlg::generateLightName() {
|
||||
return QString("Light %1").arg(lights_.size() + 1);
|
||||
}
|
||||
|
||||
bool AddLightFileDlg::validateSpecificParams() {
|
||||
// Check if at least one light is defined
|
||||
if (lights_.isEmpty()) {
|
||||
QMessageBox::warning(this, "Validation Error", "At least one light must be defined.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -30,37 +279,69 @@ bool AddLightFileDlg::validateSpecificParams() {
|
||||
}
|
||||
|
||||
QString AddLightFileDlg::getFileFilter() const {
|
||||
return QStringLiteral("Light Spectrum Files (*.txt *.csv *.dat *.spe *.asc);;All Files (*.*)");
|
||||
return "Light Data Files (*.txt *.csv *.dat);;All Files (*.*)";
|
||||
}
|
||||
|
||||
QString AddLightFileDlg::getDialogTitle() const {
|
||||
return QStringLiteral("Add Light Spectrum File");
|
||||
return "Add Light Data File";
|
||||
}
|
||||
|
||||
void AddLightFileDlg::onDelimiterChanged() {
|
||||
// Handle delimiter change if needed
|
||||
}
|
||||
|
||||
void AddLightFileDlg::onHeaderToggled(bool hasHeader) {
|
||||
// Handle header toggle if needed
|
||||
}
|
||||
|
||||
AddLightFileDlg::LightParams AddLightFileDlg::getLightParams() const {
|
||||
LightParams params;
|
||||
params.wavelengthColumn = ui->wavelengthColumnSpinBox->value();
|
||||
params.intensityColumn = ui->intensityColumnSpinBox->value();
|
||||
|
||||
// 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;
|
||||
void AddLightFileDlg::onSure() {
|
||||
// Save current light properties if any light is selected
|
||||
if (currentLightIndex_ >= 0) {
|
||||
saveLightProperties();
|
||||
}
|
||||
|
||||
params.hasHeader = ui->hasHeaderCheckBox->isChecked();
|
||||
params.description = ui->descriptionEdit->toPlainText().trimmed();
|
||||
return params;
|
||||
if (!validateSpecificParams()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get current workspace
|
||||
WorkSpace* workspace = WorkSpaceManager::Get().GetCurrent();
|
||||
if (!workspace) {
|
||||
QMessageBox::warning(this, tr("Error"), tr("Unable to get current workspace"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Create FileEntryLight and set properties
|
||||
auto lightEntry = CreateFileEntryLight(getSelectedFilePath());
|
||||
if (lightEntry) {
|
||||
// Set color properties
|
||||
lightEntry->SetColorProperties(colorProperties_);
|
||||
|
||||
// Add all light properties
|
||||
for (const auto& light : lights_) {
|
||||
lightEntry->AddLightProperty(light);
|
||||
}
|
||||
|
||||
// Add to workspace
|
||||
auto result = workspace->SetFileEntry(lightEntry);
|
||||
if (result != WorkSpace::FileEntryResult::Ok) {
|
||||
QString errorMsg;
|
||||
switch (result) {
|
||||
case WorkSpace::FileEntryResult::LimitExceeded:
|
||||
errorMsg = tr("Curve 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;
|
||||
}
|
||||
|
||||
accept();
|
||||
} else {
|
||||
QMessageBox::critical(this, "Error", "Failed to create light file entry.");
|
||||
}
|
||||
}
|
||||
@ -1,39 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include "BaseAddFileDlg.h"
|
||||
#include "workspace/FileEntry.h"
|
||||
#include <QColor>
|
||||
#include <QList>
|
||||
#include <memory>
|
||||
|
||||
class QLineEdit;
|
||||
class QCheckBox;
|
||||
class QSpinBox;
|
||||
class QDoubleSpinBox;
|
||||
class QTextEdit;
|
||||
class QToolButton;
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
class QListWidget;
|
||||
class QListWidgetItem;
|
||||
|
||||
namespace Ui {
|
||||
class AddLightFileDlg;
|
||||
}
|
||||
|
||||
#include "BaseAddFileDlg.h"
|
||||
|
||||
|
||||
class AddLightFileDlg : public BaseAddFileDlg {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
struct LightParams {
|
||||
QString delimiter;
|
||||
bool hasHeader;
|
||||
int wavelengthColumn;
|
||||
int intensityColumn;
|
||||
QString description;
|
||||
};
|
||||
|
||||
explicit AddLightFileDlg(QWidget* parent = nullptr);
|
||||
~AddLightFileDlg() override;
|
||||
|
||||
LightParams getLightParams() const;
|
||||
|
||||
protected:
|
||||
QString getFileFilter() const override;
|
||||
QString getDialogTitle() const override;
|
||||
bool validateSpecificParams() override;
|
||||
void updateFileInfo(const QString& filePath) override {}
|
||||
void updateFileInfo(const QString& filePath) override;
|
||||
|
||||
private slots:
|
||||
void onDelimiterChanged();
|
||||
void onHeaderToggled(bool hasHeader);
|
||||
void onOpenColorButtonClicked();
|
||||
void onCloseColorButtonClicked();
|
||||
void onAddLightClicked();
|
||||
void onRemoveLightClicked();
|
||||
void onLightListWidgetItemClicked(QListWidgetItem* item);
|
||||
void onLightSelectionChanged();
|
||||
void onLightNameChanged();
|
||||
void onLightIndexChanged();
|
||||
void onSure();
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
void updateOpenColorPreview(const QColor& color);
|
||||
void updateCloseColorPreview(const QColor& color);
|
||||
void addLightToList(const FileEntryLight::LightProperty& light);
|
||||
void updateLightProperties();
|
||||
void saveLightProperties();
|
||||
void clearLightProperties();
|
||||
void enableLightProperties(bool enabled);
|
||||
QString generateLightName();
|
||||
|
||||
Ui::AddLightFileDlg* ui;
|
||||
int currentLightIndex_;
|
||||
QColor openColor_;
|
||||
QColor closeColor_;
|
||||
|
||||
FileEntryLight::ColorProperties colorProperties_;
|
||||
FileEntryLight::LightProperties lights_;
|
||||
};
|
||||
@ -6,12 +6,12 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>480</height>
|
||||
<width>600</width>
|
||||
<height>487</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Add Light Spectrum File</string>
|
||||
<string>Add Light Data File</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
@ -29,12 +29,12 @@
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="filePathEdit">
|
||||
<property name="placeholderText">
|
||||
<string>Select light spectrum file...</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Select light data file...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
@ -76,265 +76,242 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="paramsGroupBox">
|
||||
<widget class="QGroupBox" name="colorPropertiesGroupBox">
|
||||
<property name="title">
|
||||
<string>Spectrum Parameters</string>
|
||||
<string>Color Properties</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="paramsGridLayout">
|
||||
<layout class="QGridLayout" name="colorPropertiesGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="wavelengthColumnLabel">
|
||||
<widget class="QLabel" name="openColorLabel">
|
||||
<property name="text">
|
||||
<string>Wavelength Column:</string>
|
||||
<string>Open Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="wavelengthColumnSpinBox">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="openColorLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="openColorButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="openColorPreview">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string>background-color: rgb(0, 255, 0); border: 1px solid black;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="openColorSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="intensityColumnLabel">
|
||||
<widget class="QLabel" name="closeColorLabel">
|
||||
<property name="text">
|
||||
<string>Intensity Column:</string>
|
||||
<string>Close Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="intensityColumnSpinBox">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2</number>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="closeColorLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="closeColorButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="closeColorPreview">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string>background-color: rgb(255, 0, 0); border: 1px solid black;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="closeColorSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="separatorLabel">
|
||||
<property name="text">
|
||||
<string>Separator:</string>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="lightGroupBox">
|
||||
<property name="title">
|
||||
<string>Light Management</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="lightVerticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="lightButtonLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lightListLabel">
|
||||
<property name="text">
|
||||
<string>Lights:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="lightButtonSpacer">
|
||||
<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="addLightBtn">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Light</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeLightBtn">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="lightListWidget">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>120</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" 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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="wavelengthUnitLabel">
|
||||
<property name="text">
|
||||
<string>Wavelength Unit:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="wavelengthUnitComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>nm (nanometer)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>μm (micrometer)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>cm⁻¹ (wavenumber)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>eV (electron volt)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="intensityUnitLabel">
|
||||
<property name="text">
|
||||
<string>Intensity Unit:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="intensityUnitComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Arbitrary Units</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Counts</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>W/m²/nm</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>μW/cm²/nm</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="hasHeaderCheckBox">
|
||||
<property name="text">
|
||||
<string>File has header row</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="normalizeCheckBox">
|
||||
<property name="text">
|
||||
<string>Normalize intensity values</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="rangeGroupBox">
|
||||
<property name="title">
|
||||
<string>Wavelength Range (Optional)</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="rangeGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="minWavelengthLabel">
|
||||
<property name="text">
|
||||
<string>Min Wavelength:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="minWavelengthSpinBox">
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>10000.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>380.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="maxWavelengthLabel">
|
||||
<property name="text">
|
||||
<string>Max Wavelength:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="maxWavelengthSpinBox">
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>10000.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>780.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="enableRangeCheckBox">
|
||||
<property name="text">
|
||||
<string>Enable wavelength range filtering</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</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>60</height>
|
||||
</size>
|
||||
<widget class="QGroupBox" name="lightPropertiesGroupBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Enter file description...</string>
|
||||
<property name="title">
|
||||
<string>Selected Light Properties</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="lightPropertiesGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lightNameLabel">
|
||||
<property name="text">
|
||||
<string>Light Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lightNameEdit">
|
||||
<property name="placeholderText">
|
||||
<string>Enter light name...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lightIndexLabel">
|
||||
<property name="text">
|
||||
<string>Light Index:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="lightIndexSpinBox">
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="buttonLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<spacer name="buttonSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@ -347,13 +324,10 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="addBtn">
|
||||
<widget class="QPushButton" name="addFileBtn">
|
||||
<property name="text">
|
||||
<string>Add File</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -369,4 +343,4 @@
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
</ui>
|
||||
|
||||
@ -67,13 +67,16 @@ std::shared_ptr<FileEntry> CreateFileEntryTable(const QString& filePath) {
|
||||
return fileEntry;
|
||||
}
|
||||
|
||||
std::shared_ptr<FileEntry> CreateFileEntryLight(const QString& filePath) {
|
||||
auto fileEntry = std::make_shared<FileEntry>();
|
||||
fileEntry->SetType(FileEntryType::Light);
|
||||
|
||||
if (!filePath.isEmpty()) {
|
||||
fileEntry->SetPath(filePath);
|
||||
std::shared_ptr<FileEntryLight> CreateFileEntryLight(const QString& filePath) {
|
||||
QFileInfo fileInfo(filePath);
|
||||
if (!fileInfo.exists()) {
|
||||
LOG_ERROR("File does not exist: {}", filePath.toUtf8().constData());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
auto fileEntry = std::make_shared<FileEntryLight>();
|
||||
fileEntry->SetPath(filePath);
|
||||
fileEntry->SetName(fileInfo.baseName()); // Use base name as default display name
|
||||
|
||||
return fileEntry;
|
||||
}
|
||||
@ -30,6 +30,7 @@ inline bool FileEntryTypeFromString(const char* s, FileEntryType& out) {
|
||||
}
|
||||
|
||||
class FileEntryCurve;
|
||||
class FileEntryLight;
|
||||
|
||||
class FileEntry {
|
||||
public:
|
||||
@ -48,6 +49,7 @@ public:
|
||||
QString GetName() const { return name_; }
|
||||
|
||||
virtual FileEntryCurve* AsCurve() { return nullptr; }
|
||||
virtual FileEntryLight* AsLight() { return nullptr; }
|
||||
|
||||
protected:
|
||||
FileEntryType type_;
|
||||
@ -61,7 +63,7 @@ std::shared_ptr<FileEntry> CreateFileEntry(FileEntryType type, const QString& fi
|
||||
std::shared_ptr<FileEntryCurve> CreateFileEntryCurve(const QString& filePath);
|
||||
std::shared_ptr<FileEntry> CreateFileEntrySurface(const QString& filePath);
|
||||
std::shared_ptr<FileEntry> CreateFileEntryTable(const QString& filePath);
|
||||
std::shared_ptr<FileEntry> CreateFileEntryLight(const QString& filePath);
|
||||
std::shared_ptr<FileEntryLight> CreateFileEntryLight(const QString& filePath);
|
||||
|
||||
|
||||
class FileEntryCurve : public FileEntry {
|
||||
@ -102,3 +104,35 @@ private:
|
||||
ChartProperties chartProperties_;
|
||||
CurveProperties curveProperties_;
|
||||
};
|
||||
|
||||
class FileEntryLight : public FileEntry {
|
||||
public:
|
||||
struct ColorProperties {
|
||||
QColor openColor;
|
||||
QColor closeColor;
|
||||
};
|
||||
|
||||
struct LightProperty {
|
||||
QString name;
|
||||
int index;
|
||||
};
|
||||
|
||||
using LightProperties = QList<LightProperty>;
|
||||
|
||||
public:
|
||||
FileEntryLight() { type_ = FileEntryType::Light; }
|
||||
|
||||
void SetColorProperties(const ColorProperties& props) { colorProperties_ = props; }
|
||||
const ColorProperties& GetColorProperties() const { return colorProperties_; }
|
||||
|
||||
void AddLightProperty(const LightProperty& prop) { lightProperties_.append(prop); }
|
||||
void RemoveLightProperty(int index) { lightProperties_.removeAt(index); }
|
||||
const LightProperties& GetLightProperties() const { return lightProperties_; }
|
||||
|
||||
FileEntryLight* AsLight() override { return this; }
|
||||
|
||||
private:
|
||||
ColorProperties colorProperties_;
|
||||
LightProperties lightProperties_;
|
||||
};
|
||||
|
||||
|
||||
@ -211,9 +211,7 @@ bool WorkSpace::SetFileEntryCount(FileEntryType type, int count) {
|
||||
fileEntry->SetType(FileEntryType::Table);
|
||||
break;
|
||||
case FileEntryType::Light:
|
||||
// TODO: Create FileEntryLight when implemented
|
||||
fileEntry = std::make_shared<FileEntry>();
|
||||
fileEntry->SetType(FileEntryType::Light);
|
||||
fileEntry = std::make_shared<FileEntryLight>();
|
||||
break;
|
||||
default:
|
||||
return false; // Invalid type
|
||||
|
||||
Loading…
Reference in New Issue
Block a user