modified ImageFile
This commit is contained in:
parent
8c03d98849
commit
0776e0aa07
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -84,6 +84,8 @@ QString DataPanel::GetTypeDisplayName() const
|
||||
return "Light";
|
||||
case FileEntryType::Polar:
|
||||
return "Polar";
|
||||
case FileEntryType::Image:
|
||||
return "Image";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "TablePanel.h"
|
||||
#include "LightPanel.h"
|
||||
#include "PolarPanel.h"
|
||||
#include "ImagePanel.h"
|
||||
|
||||
DataPanel* DataPanelFactory::CreatePanel(FileEntryType fileType, int index, const QString& filePath, QWidget* parent)
|
||||
{
|
||||
@ -36,6 +37,11 @@ DataPanel* DataPanelFactory::CreatePanel(FileEntryType fileType, int index, cons
|
||||
// TODO: Implement LightPanel
|
||||
LOG_WARN("PolarPanel not implemented yet, creating base DataPanel");
|
||||
return new PolarPanel(index, filePath, parent);
|
||||
|
||||
case FileEntryType::Image:
|
||||
// TODO: Implement LightPanel
|
||||
LOG_WARN("ImagePanel not implemented yet, creating base DataPanel");
|
||||
return new ImagePanel(index, filePath, parent);
|
||||
|
||||
default:
|
||||
LOG_ERROR("Unsupported file type: {}", static_cast<int>(fileType));
|
||||
@ -58,6 +64,7 @@ bool DataPanelFactory::IsTypeSupported(FileEntryType fileType)
|
||||
case FileEntryType::Table:
|
||||
case FileEntryType::Light:
|
||||
case FileEntryType::Polar:
|
||||
case FileEntryType::Image:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -77,6 +84,8 @@ QString DataPanelFactory::GetTypeDisplayName(FileEntryType fileType)
|
||||
return "Light";
|
||||
case FileEntryType::Polar:
|
||||
return "Polar";
|
||||
case FileEntryType::Image:
|
||||
return "Image";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
@ -66,6 +66,7 @@ void DataPanelManager::SetWorkspace(WorkSpace* workspace)
|
||||
UpdatePanelsForType(FileEntryType::Table);
|
||||
UpdatePanelsForType(FileEntryType::Light);
|
||||
UpdatePanelsForType(FileEntryType::Polar);
|
||||
UpdatePanelsForType(FileEntryType::Image);
|
||||
LOG_INFO("DataPanelManager::SetWorkspace - Reapplying UI layout after panels created");
|
||||
UiLayoutManager::Restore(mainWindow_, 1);
|
||||
} else {
|
||||
|
||||
@ -6,8 +6,11 @@
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "workspace/WorkSpaceManager.h"
|
||||
#include "workspace/WorkSpace.h"
|
||||
|
||||
ImagePanel::ImagePanel(int index, const QString& filePath, QWidget* parent)
|
||||
: DataPanel(index, FileEntryType::Table, filePath, parent)
|
||||
: DataPanel(index, FileEntryType::Image, filePath, parent)
|
||||
{
|
||||
LOG_INFO("Created ImagePanel {} for file: {}", index, filePath.toStdString());
|
||||
}
|
||||
@ -45,8 +48,10 @@ void ImagePanel::RefreshPanel()
|
||||
void ImagePanel::InitUI()
|
||||
{
|
||||
QGridLayout* pMainLyt = new QGridLayout(this);
|
||||
pMainLyt->setContentsMargins(5, 0, 5, 0);
|
||||
pMainLyt->setContentsMargins(0, 0, 0, 0);
|
||||
setLayout(pMainLyt);
|
||||
|
||||
setMinimumHeight(100);
|
||||
}
|
||||
|
||||
QString ImagePanel::GetTypeDisplayName() const
|
||||
@ -59,11 +64,39 @@ void ImagePanel::OnDataPanelUpdated(FileEntryImage* fileEntry)
|
||||
QString strName = fileEntry->GetName();
|
||||
updateTitle(strName);
|
||||
|
||||
FileEntryImage::ChartProperties propChart = fileEntry->GetChartProperties();
|
||||
|
||||
QString strFile = fileEntry->GetPath() + "/" + fileEntry->GetFileName();
|
||||
FileEntryImage::ImageProperties listCurve = fileEntry->GetImageProperties();
|
||||
updateParseFile(strFile, propChart.timeParam, listCurve);
|
||||
}
|
||||
|
||||
void ImagePanel::OnTimeChanged(double time)
|
||||
{
|
||||
|
||||
if (m_dataImage.size() > 0)
|
||||
{
|
||||
QMap< double, QVariantMap >::const_iterator ite = m_dataImage.lowerBound(time);
|
||||
if (ite == m_dataImage.end())
|
||||
{
|
||||
ite--;
|
||||
}
|
||||
|
||||
QVariantMap mapData = ite.value();
|
||||
for (QVariantMap::Iterator it = mapData.begin(); it != mapData.end(); it++)
|
||||
{
|
||||
QString strKey = it.key();
|
||||
QString sData = it.value().toString();
|
||||
|
||||
QLabel* pImgLabel = m_mapImage.value(strKey);
|
||||
if (pImgLabel)
|
||||
{
|
||||
QImage px;
|
||||
px.load(sData);
|
||||
|
||||
pImgLabel->setPixmap(QPixmap::fromImage(px));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ImagePanel::updateTitle(const QString & title)
|
||||
@ -72,4 +105,103 @@ void ImagePanel::updateTitle(const QString & title)
|
||||
{
|
||||
dockWidget_->setWindowTitle(title);
|
||||
}
|
||||
}
|
||||
|
||||
void ImagePanel::updateParseFile(const QString & strFile, int nT, FileEntryImage::ImageProperties listCurve)
|
||||
{
|
||||
if (strFile.isEmpty())
|
||||
{
|
||||
QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请检查数据文件路径!"));
|
||||
return;
|
||||
}
|
||||
|
||||
m_dataImage.clear();
|
||||
|
||||
clearImagePanel();
|
||||
|
||||
QGridLayout* layout = qobject_cast<QGridLayout*>(this->layout());
|
||||
if (!layout)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QFile file(strFile);
|
||||
if (file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
for (int nI = 0; nI < listCurve.size(); nI++)
|
||||
{
|
||||
FileEntryImage::ImageProperty prop = listCurve.at(nI);
|
||||
|
||||
for (auto i = 0; i < prop.names.size(); ++i)
|
||||
{
|
||||
QLabel* pImgLabel = new QLabel;
|
||||
pImgLabel->setStyleSheet(QString("background-color: rgb(190, 190, 190, 255);"));
|
||||
pImgLabel->setScaledContents(true);
|
||||
layout->addWidget(pImgLabel, nI, i);
|
||||
|
||||
QString strKey = QString::number(nI) + "-" + QString::number(i);
|
||||
m_mapImage.insert(strKey, pImgLabel);
|
||||
}
|
||||
}
|
||||
|
||||
QString strDir = WorkSpaceManager::Get().GetCurrent()->GetDir();
|
||||
|
||||
while (!file.atEnd())
|
||||
{
|
||||
QString strLine = file.readLine().simplified();
|
||||
if (!strLine.isEmpty())
|
||||
{
|
||||
QStringList listLine = strLine.split(" ");
|
||||
double t = listLine.at(nT).toDouble();
|
||||
|
||||
QVariantMap mapData;
|
||||
for (int nI = 0; nI < listCurve.size(); nI++)
|
||||
{
|
||||
FileEntryImage::ImageProperty prop = listCurve.at(nI);
|
||||
|
||||
for (int nJ = 0; nJ < prop.datas.size(); ++nJ)
|
||||
{
|
||||
int nIndex = prop.datas.at(nJ);
|
||||
QString sImage = listLine.at(nIndex);
|
||||
|
||||
if (prop.path.isEmpty())
|
||||
{
|
||||
sImage = strDir + "/" + prop.names.at(nI) + "/" + sImage + "." + prop.suffix;
|
||||
}
|
||||
else
|
||||
{
|
||||
sImage = prop.path + "/" + prop.names.at(nI) + "/" + sImage + "." + prop.suffix;
|
||||
}
|
||||
|
||||
QString strKey = QString::number(nI) + "-" + QString::number(nJ);
|
||||
mapData.insert(strKey, sImage);
|
||||
}
|
||||
}
|
||||
m_dataImage.insert(t, mapData);
|
||||
}
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void ImagePanel::clearImagePanel()
|
||||
{
|
||||
if (auto* layout = qobject_cast<QGridLayout*>(this->layout()))
|
||||
{
|
||||
while (layout->count() > 0)
|
||||
{
|
||||
QLayoutItem* item = layout->takeAt(0);
|
||||
if (item)
|
||||
{
|
||||
if (auto* w = item->widget())
|
||||
{
|
||||
w->deleteLater();
|
||||
}
|
||||
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_mapImage.clear();
|
||||
}
|
||||
@ -4,6 +4,9 @@
|
||||
#include "workspace/FileEntry.h"
|
||||
#include <memory>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QMap>
|
||||
|
||||
class ImagePanel : public DataPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -59,5 +62,11 @@ protected:
|
||||
|
||||
private:
|
||||
void updateTitle(const QString& title);
|
||||
void updateParseFile(const QString& strFile, int nT, FileEntryImage::ImageProperties listCurve);
|
||||
void clearImagePanel();
|
||||
|
||||
private:
|
||||
QMap<QString, QLabel *> m_mapImage;
|
||||
QMap< double, QVariantMap > m_dataImage;
|
||||
};
|
||||
|
||||
|
||||
@ -7,13 +7,302 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>580</width>
|
||||
<height>756</height>
|
||||
<height>601</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Add Image</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="curveGroupBox">
|
||||
<property name="title">
|
||||
<string>Curve Management</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="curveVerticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="curveButtonLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="curveListLabel">
|
||||
<property name="text">
|
||||
<string>Curves:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="curveButtonSpacer">
|
||||
<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="addCurveBtn">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeCurveBtn">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<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="curveListWidget">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>120</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="curvePropertiesGroupBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Selected Curve Properties</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="curveNameLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Names:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="image_name">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Enter image names (comma separated)...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="curveNameLabel_3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Datas:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="image_data">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Enter data values (comma separated integers)...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="filePathLabel_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="image_path">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Select data path...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="image_btn">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="curveNameLabel_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Suffix:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="image_suffix">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>png</string>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Enter data suffix...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="rowIndexLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Row Index:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="rowIndexValue">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="fileGroupBox">
|
||||
<property name="title">
|
||||
@ -117,624 +406,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="axisRangeGroupBox">
|
||||
<property name="title">
|
||||
<string>Angular Axis</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="xTitleLabel_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Title:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="TitleEdit_Angular">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Enter axis title...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="xMinLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Min:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="SpinBox_Min_Angular">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="yMinLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Max:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="SpinBox_Max_Angular">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="xCountLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Count:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="SpinBox_Count_Angular">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>13</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="xTitleLabel_3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Unit:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="TitleEdit_Unit_Angular">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Enter axis Unit...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QGroupBox" name="axisRangeGroupBox_2">
|
||||
<property name="title">
|
||||
<string>Radial Axis</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="xTitleLabel_4">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Title:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="TitleEdit_Radial">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Enter axis title...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="xMinLabel_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Min:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="SpinBox_Min_Radial">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="yMinLabel_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Max:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="SpinBox_Max_Radial">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="xCountLabel_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Count:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="SpinBox_Count_Radial">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>6</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="xTitleLabel_5">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Unit:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="TitleEdit_Unit_Radial">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Enter axis Unit...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="curveGroupBox">
|
||||
<property name="title">
|
||||
<string>Curve Management</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="curveVerticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="curveButtonLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="curveListLabel">
|
||||
<property name="text">
|
||||
<string>Curves:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="curveButtonSpacer">
|
||||
<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="addCurveBtn">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeCurveBtn">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<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="curveListWidget">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>120</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="curvePropertiesGroupBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Selected Curve Properties</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="curvePropertiesGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="curveNameLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="curveNameEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Enter curve name...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="curveColorLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="colorLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="colorButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<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="colorPreview">
|
||||
<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="colorSpacer">
|
||||
<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="dataStartLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Angular:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="SpinBox_Angular">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="dataStopLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Radial:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="SpinBox_Radial">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="xValueLabel">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>X Value:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QDoubleSpinBox" name="xValueSpinBox">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="yValueLabel">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Y Value:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QDoubleSpinBox" name="yValueSpinBox">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="buttonLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
|
||||
@ -15,9 +15,7 @@ AddImageFileDlg::AddImageFileDlg(QWidget* parent)
|
||||
: BaseAddFileDlg(FileEntryType::Polar, parent)
|
||||
, ui(new Ui::AddImageDlg)
|
||||
, currentCurveIndex_(-1)
|
||||
, selectedColor_(255, 0, 0)
|
||||
{
|
||||
|
||||
SetupUI(ui);
|
||||
SetTitle(getDialogTitle());
|
||||
|
||||
@ -29,7 +27,6 @@ AddImageFileDlg::~AddImageFileDlg()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
QString AddImageFileDlg::getFileFilter() const
|
||||
{
|
||||
return tr("Data Files (*.txt *.csv *.dat);;All Files (*.*)");
|
||||
@ -86,46 +83,36 @@ bool AddImageFileDlg::validateSpecificParams()
|
||||
}
|
||||
|
||||
// Curve name uniqueness validation
|
||||
QStringList curveNames;
|
||||
for (int i = 0; i < curves_.size(); ++i)
|
||||
{
|
||||
const FileEntryPolar::LineProperty& curve = curves_[i];
|
||||
|
||||
if (curve.name.isEmpty())
|
||||
const FileEntryImage::ImageProperty& curve = curves_[i];
|
||||
int nSizeName = curve.names.size();
|
||||
if (curve.names.isEmpty())
|
||||
{
|
||||
QMessageBox::warning(this, tr("Validation Error"),
|
||||
tr("Curve %1 name cannot be empty.").arg(i + 1));
|
||||
tr("Image %1 name cannot be empty.").arg(i + 1));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (curveNames.contains(curve.name))
|
||||
int nSizeData = curve.datas.size();
|
||||
if (nSizeData == 0)
|
||||
{
|
||||
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));
|
||||
tr("Image %1 data cannot be empty.").arg(i + 1));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Report type validation - ensure x and y values are reasonable
|
||||
if (curve.Angular < -1000000 || curve.Angular > 1000000)
|
||||
if (nSizeName != nSizeData)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Validation Error"),
|
||||
tr("Curve '%1' X value is out of range. Please ensure it is between -1000000 and 1000000.").arg(curve.name));
|
||||
tr("Image %1 name does not match data.").arg(i + 1));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (curve.Radial < -1000000 || curve.Radial > 1000000)
|
||||
if (curve.suffix.isEmpty())
|
||||
{
|
||||
QMessageBox::warning(this, tr("Validation Error"),
|
||||
tr("Curve '%1' Y value is out of range. Please ensure it is between -1000000 and 1000000.").arg(curve.name));
|
||||
tr("Image %1 suffix cannot be empty.").arg(i + 1));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -143,25 +130,6 @@ bool AddImageFileDlg::validateSpecificParams()
|
||||
return false;
|
||||
}
|
||||
|
||||
// Axis range validation
|
||||
double AngularMin = ui->SpinBox_Min_Angular->value();
|
||||
double AngularMax = ui->SpinBox_Max_Angular->value();
|
||||
double RadialMin = ui->SpinBox_Min_Radial->value();
|
||||
double RadialMax = ui->SpinBox_Max_Radial->value();
|
||||
|
||||
if (AngularMin > AngularMax)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Validation Error"), tr("Angular axis minimum value must be less than maximum value."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (RadialMin > RadialMax)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Validation Error"), tr("Radial axis minimum value must be less than maximum value."));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Time parameter validation
|
||||
double timeParam = ui->SpinBox_time->value();
|
||||
if (timeParam < 0)
|
||||
@ -211,54 +179,17 @@ void AddImageFileDlg::setupConnections()
|
||||
connect(ui->curveListWidget, &QListWidget::itemClicked, this, &AddImageFileDlg::onCurveListWidgetItemClicked);
|
||||
|
||||
// Curve properties connections
|
||||
connect(ui->colorButton, &QPushButton::clicked, this, &AddImageFileDlg::onColorButtonClicked);
|
||||
connect(ui->curveNameEdit, &QLineEdit::textChanged, this, &AddImageFileDlg::onCurveNameChanged);
|
||||
connect(ui->SpinBox_Angular, QOverload<int>::of(&QSpinBox::valueChanged), this, &AddImageFileDlg::onCurveDataChanged);
|
||||
connect(ui->SpinBox_Radial, QOverload<int>::of(&QSpinBox::valueChanged), this, &AddImageFileDlg::onCurveDataChanged);
|
||||
connect(ui->image_name, &QLineEdit::textChanged, this, &AddImageFileDlg::onNamesChanged);
|
||||
connect(ui->image_data, &QLineEdit::textChanged, this, &AddImageFileDlg::onDatasChanged);
|
||||
connect(ui->image_path, &QLineEdit::textChanged, this, &AddImageFileDlg::onPathChanged);
|
||||
connect(ui->image_suffix, &QLineEdit::textChanged, this, &AddImageFileDlg::onSuffixChanged);
|
||||
connect(ui->image_btn, &QToolButton::clicked, this, &AddImageFileDlg::onSelectDir);
|
||||
|
||||
// Dialog buttons
|
||||
connect(ui->addBtn, &QPushButton::clicked, this, &AddImageFileDlg::onSure);
|
||||
connect(ui->cancelBtn, &QPushButton::clicked, this, &QDialog::reject);
|
||||
}
|
||||
|
||||
void AddImageFileDlg::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)
|
||||
{
|
||||
QString itemText = QString("%1 (%2,%3) (%4,%5,%6)")
|
||||
.arg(curves_[currentCurveIndex_].name)
|
||||
.arg(curves_[currentCurveIndex_].Angular)
|
||||
.arg(curves_[currentCurveIndex_].Radial)
|
||||
.arg(color.red())
|
||||
.arg(color.green())
|
||||
.arg(color.blue());
|
||||
|
||||
item->setText(itemText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddImageFileDlg::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);
|
||||
}
|
||||
|
||||
void AddImageFileDlg::onAddCurveClicked()
|
||||
{
|
||||
// Save current curve properties if any curve is selected
|
||||
@ -268,29 +199,23 @@ void AddImageFileDlg::onAddCurveClicked()
|
||||
}
|
||||
|
||||
// Create new curve with default properties based on chart type
|
||||
FileEntryPolar::LineProperty newCurve;
|
||||
newCurve.name = generateCurveName();
|
||||
newCurve.color = generateCurveColor();
|
||||
newCurve.Angular = 0.0;
|
||||
newCurve.Radial = 0.0;
|
||||
|
||||
FileEntryImage::ImageProperty newCurve;
|
||||
newCurve.names = QStringList() << generateCurveName();
|
||||
newCurve.suffix = "png";
|
||||
// Add to curves list and UI
|
||||
curves_.append(newCurve);
|
||||
|
||||
// Add to UI list widget with appropriate display format
|
||||
QString displayText = QString("%1 (%2,%3) (%4,%5,%6)")
|
||||
.arg(newCurve.name)
|
||||
.arg(newCurve.Angular)
|
||||
.arg(newCurve.Radial)
|
||||
.arg(newCurve.color.red())
|
||||
.arg(newCurve.color.green())
|
||||
.arg(newCurve.color.blue());
|
||||
QString displayText = QString("[%1] [%2] [Row: %3]")
|
||||
.arg(newCurve.names.join(", "))
|
||||
.arg("")
|
||||
.arg(curves_.size() - 1);
|
||||
|
||||
QListWidgetItem* item = new QListWidgetItem(displayText);
|
||||
ui->curveListWidget->addItem(item);
|
||||
++currentCurveIndex_;
|
||||
|
||||
ui->curveNameEdit->setText(newCurve.name);
|
||||
updateCurveProperties();
|
||||
|
||||
// Select the new curve
|
||||
ui->curveListWidget->setCurrentRow(curves_.size() - 1);
|
||||
@ -341,24 +266,8 @@ void AddImageFileDlg::onCurveListWidgetItemClicked(QListWidgetItem* item)
|
||||
}
|
||||
|
||||
int clickedIndex = ui->curveListWidget->row(item);
|
||||
|
||||
if (clickedIndex == currentCurveIndex_)
|
||||
{
|
||||
ui->curveNameEdit->setText(curves_[currentCurveIndex_].name);
|
||||
|
||||
ui->SpinBox_Angular->blockSignals(true);
|
||||
ui->SpinBox_Angular->setValue(curves_[currentCurveIndex_].Angular);
|
||||
ui->SpinBox_Angular->blockSignals(false);
|
||||
|
||||
ui->SpinBox_Radial->blockSignals(true);
|
||||
ui->SpinBox_Radial->setValue(curves_[currentCurveIndex_].Radial);
|
||||
ui->SpinBox_Radial->blockSignals(false);
|
||||
|
||||
updateColorPreview(curves_[currentCurveIndex_].color);
|
||||
enableCurveProperties(true);
|
||||
|
||||
ui->curveNameEdit->setFocus();
|
||||
ui->curveNameEdit->selectAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -391,27 +300,18 @@ void AddImageFileDlg::onCurveSelectionChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void AddImageFileDlg::onCurveNameChanged()
|
||||
void AddImageFileDlg::onNamesChanged()
|
||||
{
|
||||
if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size())
|
||||
{
|
||||
QString newName = ui->curveNameEdit->text();
|
||||
curves_[currentCurveIndex_].name = newName;
|
||||
|
||||
// Update list item text with appropriate format
|
||||
QListWidgetItem* item = ui->curveListWidget->item(currentCurveIndex_);
|
||||
if (item)
|
||||
{
|
||||
QString displayText = QString("%1 (%2,%3) (%4,%5,%6)")
|
||||
.arg(newName)
|
||||
.arg(curves_[currentCurveIndex_].Angular)
|
||||
.arg(curves_[currentCurveIndex_].Radial)
|
||||
.arg(curves_[currentCurveIndex_].color.red())
|
||||
.arg(curves_[currentCurveIndex_].color.green())
|
||||
.arg(curves_[currentCurveIndex_].color.blue());
|
||||
|
||||
item->setText(displayText);
|
||||
QString namesText = ui->image_name->text();
|
||||
QStringList names = namesText.split(",", Qt::SkipEmptyParts);
|
||||
for (int i = 0; i < names.size(); ++i) {
|
||||
names[i] = names[i].trimmed();
|
||||
}
|
||||
curves_[currentCurveIndex_].names = names;
|
||||
|
||||
updateListDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
@ -419,26 +319,37 @@ void AddImageFileDlg::saveCurveProperties()
|
||||
{
|
||||
if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size())
|
||||
{
|
||||
curves_[currentCurveIndex_].name = ui->curveNameEdit->text();
|
||||
QString namesText = ui->image_name->text();
|
||||
QStringList names = namesText.split(",", Qt::SkipEmptyParts);
|
||||
for (int i = 0; i < names.size(); ++i) {
|
||||
names[i] = names[i].trimmed();
|
||||
}
|
||||
curves_[currentCurveIndex_].names = names;
|
||||
|
||||
// Save properties based on chart type
|
||||
curves_[currentCurveIndex_].Angular = ui->SpinBox_Angular->value();
|
||||
curves_[currentCurveIndex_].Radial = ui->SpinBox_Radial->value();
|
||||
QString dataText = ui->image_data->text();
|
||||
QStringList dataStrings = dataText.split(",", Qt::SkipEmptyParts);
|
||||
QList<int> dataValues;
|
||||
|
||||
curves_[currentCurveIndex_].color = selectedColor_;
|
||||
for (const QString& str : dataStrings) {
|
||||
bool ok;
|
||||
int dataValue = str.trimmed().toInt(&ok);
|
||||
if (ok) {
|
||||
dataValues.append(dataValue);
|
||||
}
|
||||
}
|
||||
curves_[currentCurveIndex_].datas = dataValues;
|
||||
|
||||
onPathChanged();
|
||||
onSuffixChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void AddImageFileDlg::clearCurveProperties()
|
||||
{
|
||||
ui->curveNameEdit->clear();
|
||||
|
||||
// Clear properties based on chart type
|
||||
ui->SpinBox_Angular->setValue(0.0);
|
||||
ui->SpinBox_Radial->setValue(0.0);
|
||||
|
||||
selectedColor_ = QColor(255, 0, 0);
|
||||
updateColorPreview(selectedColor_);
|
||||
ui->image_name->clear();
|
||||
ui->image_data->clear();
|
||||
ui->image_path->clear();
|
||||
ui->image_suffix->setText("png");
|
||||
}
|
||||
|
||||
void AddImageFileDlg::enableCurveProperties(bool enabled)
|
||||
@ -448,45 +359,37 @@ void AddImageFileDlg::enableCurveProperties(bool enabled)
|
||||
|
||||
QString AddImageFileDlg::generateCurveName()
|
||||
{
|
||||
return tr("Curve %1").arg(curves_.size() + 1);
|
||||
}
|
||||
|
||||
QColor AddImageFileDlg::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];
|
||||
return tr("Image %1").arg(curves_.size() + 1);
|
||||
}
|
||||
|
||||
void AddImageFileDlg::updateCurveProperties()
|
||||
{
|
||||
if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size())
|
||||
{
|
||||
const FileEntryPolar::LineProperty& curve = curves_[currentCurveIndex_];
|
||||
const FileEntryImage::ImageProperty& curve = curves_[currentCurveIndex_];
|
||||
|
||||
ui->curveNameEdit->setText(curve.name);
|
||||
ui->image_name->blockSignals(true);
|
||||
ui->image_name->setText(curve.names.join(", "));
|
||||
ui->image_name->blockSignals(false);
|
||||
|
||||
ui->SpinBox_Angular->blockSignals(true);
|
||||
ui->SpinBox_Angular->setValue(curve.Angular);
|
||||
ui->SpinBox_Angular->blockSignals(false);
|
||||
QStringList dataStrings;
|
||||
for (int dataValue : curve.datas)
|
||||
{
|
||||
dataStrings.append(QString::number(dataValue));
|
||||
}
|
||||
ui->image_data->blockSignals(true);
|
||||
ui->image_data->setText(dataStrings.join(", "));
|
||||
ui->image_data->blockSignals(false);
|
||||
|
||||
ui->SpinBox_Radial->blockSignals(true);
|
||||
ui->SpinBox_Radial->setValue(curve.Radial);
|
||||
ui->SpinBox_Radial->blockSignals(false);
|
||||
ui->image_path->blockSignals(true);
|
||||
ui->image_path->setText(curve.path);
|
||||
ui->image_path->blockSignals(false);
|
||||
|
||||
selectedColor_ = curve.color;
|
||||
updateColorPreview(curve.color);
|
||||
ui->image_suffix->blockSignals(true);
|
||||
ui->image_suffix->setText(curve.suffix);
|
||||
ui->image_suffix->blockSignals(false);
|
||||
|
||||
ui->rowIndexValue->setText(QString::number(currentCurveIndex_));
|
||||
}
|
||||
}
|
||||
|
||||
@ -495,35 +398,25 @@ void AddImageFileDlg::onSure()
|
||||
if (validateSpecificParams())
|
||||
{
|
||||
// Create FileEntryCurve object using factory function
|
||||
auto fileEntryPolar = CreateFileEntryPolar(getSelectedFilePath());
|
||||
if (!fileEntryPolar)
|
||||
auto fileEntryImage = CreateFileEntryImage(getSelectedFilePath());
|
||||
if (!fileEntryImage)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Error"), tr("Failed to create file entry"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Set curve properties
|
||||
fileEntryPolar->SetName(ui->chartNameEdit->text());
|
||||
fileEntryImage->SetName(ui->chartNameEdit->text());
|
||||
|
||||
// Set chart properties
|
||||
FileEntryPolar::ChartProperties chartProps;
|
||||
chartProps.AngularCount = ui->SpinBox_Count_Angular->value();
|
||||
chartProps.RadialCount = ui->SpinBox_Count_Radial->value();
|
||||
chartProps.AngularTitle = ui->TitleEdit_Angular->text();
|
||||
chartProps.RadialTitle = ui->TitleEdit_Radial->text();
|
||||
chartProps.AngularUnit = ui->TitleEdit_Unit_Angular->text();
|
||||
chartProps.RadialUnit = ui->TitleEdit_Unit_Radial->text();
|
||||
chartProps.AngularMin = ui->SpinBox_Min_Angular->value();
|
||||
chartProps.AngularMax = ui->SpinBox_Max_Angular->value();
|
||||
chartProps.RadialMin = ui->SpinBox_Min_Radial->value();
|
||||
chartProps.RadialMax = ui->SpinBox_Max_Radial->value();
|
||||
FileEntryImage::ChartProperties chartProps;
|
||||
chartProps.timeParam = ui->SpinBox_time->value();
|
||||
fileEntryPolar->SetChartProperties(chartProps);
|
||||
fileEntryImage->SetChartProperties(chartProps);
|
||||
|
||||
// Add curve properties
|
||||
for (const auto& curve : curves_)
|
||||
{
|
||||
fileEntryPolar->AddLineProperty(curve);
|
||||
fileEntryImage->AddImageProperty(curve);
|
||||
}
|
||||
|
||||
// Get current workspace
|
||||
@ -535,13 +428,13 @@ void AddImageFileDlg::onSure()
|
||||
}
|
||||
|
||||
// Add FileEntryCurve to workspace using new SetFileEntry method
|
||||
auto result = workspace->SetFileEntry(fileEntryPolar);
|
||||
auto result = workspace->SetFileEntry(fileEntryImage);
|
||||
if (result != WorkSpace::FileEntryResult::Ok)
|
||||
{
|
||||
QString errorMsg;
|
||||
switch (result) {
|
||||
case WorkSpace::FileEntryResult::LimitExceeded:
|
||||
errorMsg = tr("Polar file count has reached the limit (9 files)");
|
||||
errorMsg = tr("Image file count has reached the limit (9 files)");
|
||||
break;
|
||||
case WorkSpace::FileEntryResult::Duplicate:
|
||||
errorMsg = tr("File already exists");
|
||||
@ -564,30 +457,78 @@ void AddImageFileDlg::onSure()
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Failed to create Polar file entry."));
|
||||
QMessageBox::critical(this, tr("Error"), tr("Failed to create Image file entry."));
|
||||
}
|
||||
}
|
||||
|
||||
void AddImageFileDlg::onCurveDataChanged()
|
||||
void AddImageFileDlg::onDatasChanged()
|
||||
{
|
||||
if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size())
|
||||
{
|
||||
curves_[currentCurveIndex_].Angular = ui->SpinBox_Angular->value();
|
||||
curves_[currentCurveIndex_].Radial = ui->SpinBox_Radial->value();
|
||||
QString dataText = ui->image_data->text();
|
||||
QStringList dataStrings = dataText.split(',', Qt::SkipEmptyParts);
|
||||
|
||||
QList<int> dataValues;
|
||||
for (const QString& str : dataStrings) {
|
||||
bool ok;
|
||||
int dataValue = str.trimmed().toInt(&ok);
|
||||
if (ok) {
|
||||
dataValues.append(dataValue);
|
||||
}
|
||||
}
|
||||
curves_[currentCurveIndex_].datas = dataValues;
|
||||
|
||||
updateListDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
void AddImageFileDlg::onPathChanged()
|
||||
{
|
||||
if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size())
|
||||
{
|
||||
QString text = ui->image_path->text();
|
||||
curves_[currentCurveIndex_].path = text;
|
||||
}
|
||||
}
|
||||
|
||||
void AddImageFileDlg::onSuffixChanged()
|
||||
{
|
||||
if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size())
|
||||
{
|
||||
QString text = ui->image_suffix->text();
|
||||
curves_[currentCurveIndex_].suffix = text;
|
||||
}
|
||||
}
|
||||
|
||||
void AddImageFileDlg::updateListDisplay()
|
||||
{
|
||||
if (currentCurveIndex_ >= 0 && currentCurveIndex_ < curves_.size())
|
||||
{
|
||||
QStringList dataStrings;
|
||||
for (int dataValue : curves_[currentCurveIndex_].datas) {
|
||||
dataStrings.append(QString::number(dataValue));
|
||||
}
|
||||
|
||||
// Update display text in list widget
|
||||
QListWidgetItem* item = ui->curveListWidget->item(currentCurveIndex_);
|
||||
if (item)
|
||||
if (item)
|
||||
{
|
||||
QString itemText = QString("%1 (%2,%3) (%4,%5,%6)")
|
||||
.arg(curves_[currentCurveIndex_].name)
|
||||
.arg(curves_[currentCurveIndex_].Angular)
|
||||
.arg(curves_[currentCurveIndex_].Radial)
|
||||
.arg(curves_[currentCurveIndex_].color.red())
|
||||
.arg(curves_[currentCurveIndex_].color.green())
|
||||
.arg(curves_[currentCurveIndex_].color.blue());
|
||||
|
||||
item->setText(itemText);
|
||||
item->setText(QString("[%1] [%2] [Row: %3]")
|
||||
.arg(curves_[currentCurveIndex_].names.join(", "))
|
||||
.arg(dataStrings.join(", "))
|
||||
.arg(currentCurveIndex_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddImageFileDlg::onSelectDir()
|
||||
{
|
||||
QString workspacePath = WorkSpaceManager::Get().GetCurrent()->GetDir();
|
||||
const QString imagePath = QFileDialog::getExistingDirectory(this,
|
||||
tr("Select Image directory"), workspacePath, QFileDialog::DontResolveSymlinks);
|
||||
if (imagePath.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ui->image_path->setText(imagePath);
|
||||
}
|
||||
@ -32,30 +32,31 @@ protected:
|
||||
void updateFileInfo(const QString& filePath) override;
|
||||
|
||||
private slots:
|
||||
void onColorButtonClicked();
|
||||
void onAddCurveClicked();
|
||||
void onRemoveCurveClicked();
|
||||
void onCurveListWidgetItemClicked(class QListWidgetItem* item);
|
||||
void onCurveSelectionChanged();
|
||||
void onCurveNameChanged();
|
||||
void onCurveDataChanged();
|
||||
void onNamesChanged();
|
||||
void onDatasChanged();
|
||||
void onPathChanged();
|
||||
void onSuffixChanged();
|
||||
void onSelectDir();
|
||||
void onSure();
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
void updateColorPreview(const QColor& color);
|
||||
void updateCurveProperties();
|
||||
void saveCurveProperties();
|
||||
void clearCurveProperties();
|
||||
void enableCurveProperties(bool enabled);
|
||||
QString generateCurveName();
|
||||
QColor generateCurveColor() const;
|
||||
|
||||
void updateListDisplay();
|
||||
|
||||
private:
|
||||
Ui::AddImageDlg* ui;
|
||||
int currentCurveIndex_;
|
||||
QColor selectedColor_;
|
||||
|
||||
FileEntryPolar::ChartProperties chartProperties_;
|
||||
FileEntryPolar::LineProperties curves_;
|
||||
FileEntryImage::ChartProperties chartProperties_;
|
||||
FileEntryImage::ImageProperties curves_;
|
||||
};
|
||||
@ -521,42 +521,22 @@
|
||||
<string>Selected Curve Properties</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="curvePropertiesGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="curveNameLabel">
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="SpinBox_Radial">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="curveNameEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
<property name="maximum">
|
||||
<number>999999</number>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Enter curve name...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="curveColorLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -625,6 +605,32 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="curveColorLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="curveNameEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Enter curve name...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="SpinBox_Angular">
|
||||
<property name="minimumSize">
|
||||
@ -644,6 +650,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="curveNameLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="dataStopLabel">
|
||||
<property name="minimumSize">
|
||||
@ -657,77 +676,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="SpinBox_Radial">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="xValueLabel">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>X Value:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QDoubleSpinBox" name="xValueSpinBox">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="yValueLabel">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Y Value:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QDoubleSpinBox" name="yValueSpinBox">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>999999.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@ -864,4 +864,108 @@ const FileEntryImage::ImageProperties& FileEntryImage::GetImageProperties() cons
|
||||
|
||||
FileEntryImage* FileEntryImage::AsImage() {
|
||||
return this;
|
||||
}
|
||||
|
||||
//SaveFiles implementation
|
||||
bool FileEntryImage::SaveFiles(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc) {
|
||||
if (!scene || !doc) {
|
||||
LOG_ERROR("Invalid XML parameters");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 创建 <chart> 元素
|
||||
tinyxml2::XMLElement* chartElement = doc->NewElement("chart");
|
||||
scene->InsertEndChild(chartElement);
|
||||
|
||||
// 设置chart属性
|
||||
chartElement->SetAttribute("name", name_.toUtf8().constData());
|
||||
chartElement->SetAttribute("path", fileName_.toUtf8().constData());
|
||||
chartElement->SetAttribute("t", chartProperties_.timeParam);
|
||||
|
||||
for (const auto& imageRow : imageProperties_) {
|
||||
tinyxml2::XMLElement* imageElement = doc->NewElement("curve");
|
||||
chartElement->InsertEndChild(imageElement);
|
||||
|
||||
// 保存name列表(以逗号分隔)
|
||||
QString nameStr = imageRow.names.join(",");
|
||||
imageElement->SetAttribute("names", nameStr.toUtf8().constData());
|
||||
|
||||
// 保存data列表(以逗号分隔)
|
||||
QStringList dataStrList;
|
||||
for (int value : imageRow.datas) {
|
||||
dataStrList.append(QString::number(value));
|
||||
}
|
||||
QString dataStr = dataStrList.join(",");
|
||||
imageElement->SetAttribute("datas", dataStr.toUtf8().constData());
|
||||
|
||||
imageElement->SetAttribute("path", imageRow.path.toUtf8().constData());
|
||||
imageElement->SetAttribute("suffix", imageRow.suffix.toUtf8().constData());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//ParseFiles implementation
|
||||
bool FileEntryImage::ParseFiles(const tinyxml2::XMLElement* chartElement) {
|
||||
if (!chartElement) {
|
||||
LOG_ERROR("Invalid XML element");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 解析chart属性
|
||||
const char* nameAttr = chartElement->Attribute("name");
|
||||
const char* pathAttr = chartElement->Attribute("path");
|
||||
if (nameAttr) name_ = QString::fromUtf8(nameAttr);
|
||||
if (pathAttr) {
|
||||
QString fullPath = QString::fromUtf8(pathAttr);
|
||||
QFileInfo fileInfo(fullPath);
|
||||
fileName_ = fileInfo.fileName();
|
||||
path_ = fileInfo.absolutePath();
|
||||
}
|
||||
|
||||
chartProperties_.timeParam = chartElement->DoubleAttribute("t", 0.0);
|
||||
|
||||
// 解析所有<light>元素
|
||||
imageProperties_.clear();
|
||||
for (const tinyxml2::XMLElement* imageElement = chartElement->FirstChildElement("curve");
|
||||
imageElement != nullptr;
|
||||
imageElement = imageElement->NextSiblingElement("curve")) {
|
||||
|
||||
ImageProperty imageRow;
|
||||
|
||||
// 解析name属性(逗号分隔的字符串列表)
|
||||
const char* nameAttr = imageElement->Attribute("names");
|
||||
if (nameAttr) {
|
||||
QString nameStr = QString::fromUtf8(nameAttr);
|
||||
imageRow.names = nameStr.split(",", Qt::SkipEmptyParts);
|
||||
}
|
||||
|
||||
// 解析data属性(逗号分隔的整数列表)
|
||||
const char* dataAttr = imageElement->Attribute("datas");
|
||||
if (dataAttr) {
|
||||
QString dataStr = QString::fromUtf8(dataAttr);
|
||||
QStringList dataStrList = dataStr.split(",", Qt::SkipEmptyParts);
|
||||
for (const QString& str : dataStrList) {
|
||||
bool ok;
|
||||
int value = str.trimmed().toInt(&ok);
|
||||
if (ok) {
|
||||
imageRow.datas.append(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char* pathAttr = imageElement->Attribute("path");
|
||||
if (pathAttr) {
|
||||
imageRow.path = QString::fromUtf8(pathAttr);
|
||||
}
|
||||
|
||||
const char* suffixAttr = imageElement->Attribute("suffix");
|
||||
if (suffixAttr) {
|
||||
imageRow.suffix = QString::fromUtf8(suffixAttr);
|
||||
}
|
||||
|
||||
imageProperties_.append(imageRow);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -362,24 +362,14 @@ private:
|
||||
class FileEntryImage : public FileEntry {
|
||||
public:
|
||||
struct ChartProperties {
|
||||
int AngularCount;
|
||||
int RadialCount;
|
||||
QString AngularTitle;
|
||||
QString RadialTitle;
|
||||
double AngularMin;
|
||||
double AngularMax;
|
||||
double RadialMin;
|
||||
double RadialMax;
|
||||
QString AngularUnit;
|
||||
QString RadialUnit;
|
||||
double timeParam; // 对应XML的t
|
||||
};
|
||||
|
||||
struct ImageProperty {
|
||||
QString name;
|
||||
QColor color;
|
||||
int Angular;
|
||||
int Radial;
|
||||
QStringList names;
|
||||
QList<int> datas;
|
||||
QString path;
|
||||
QString suffix;
|
||||
};
|
||||
|
||||
using ImageProperties = QList<ImageProperty>;
|
||||
@ -400,9 +390,9 @@ public:
|
||||
// Type conversion
|
||||
FileEntryImage* AsImage() override;
|
||||
|
||||
//// XML处理方法
|
||||
//bool SaveFiles(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc) override;
|
||||
//bool ParseFiles(const tinyxml2::XMLElement* element) override;
|
||||
// XML处理方法
|
||||
bool SaveFiles(tinyxml2::XMLElement* scene, tinyxml2::XMLDocument* doc) override;
|
||||
bool ParseFiles(const tinyxml2::XMLElement* element) override;
|
||||
|
||||
private:
|
||||
ChartProperties chartProperties_;
|
||||
|
||||
@ -162,6 +162,9 @@ bool WorkSpace::SetFileEntryCount(FileEntryType type, int count) {
|
||||
case FileEntryType::Polar:
|
||||
fileEntry = std::make_shared<FileEntryPolar>();
|
||||
break;
|
||||
case FileEntryType::Image:
|
||||
fileEntry = std::make_shared<FileEntryImage>();
|
||||
break;
|
||||
default:
|
||||
return false; // Invalid type
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user