Compare commits
6 Commits
c2c88b4ebc
...
fafd290244
| Author | SHA1 | Date | |
|---|---|---|---|
| fafd290244 | |||
| 7de04d4c34 | |||
| 42fd885400 | |||
| 06358b4bca | |||
| 02ad3dbe4b | |||
| 707c02e8a0 |
@ -1,5 +1,6 @@
|
|||||||
#include "ui/Panel/CurvePanel.h"
|
#include "ui/Panel/CurvePanel.h"
|
||||||
#include "ui/DockWidget.h"
|
#include "ui/DockWidget.h"
|
||||||
|
#include "ui/DockTitleBar.h"
|
||||||
#include "common/SpdLogger.h"
|
#include "common/SpdLogger.h"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
@ -26,6 +27,11 @@ CurvePanel::CurvePanel(int index, const QString& filePath, QWidget* parent)
|
|||||||
CurvePanel::CurvePanel(int index, std::shared_ptr<FileEntryCurve> fileEntry, QWidget* parent)
|
CurvePanel::CurvePanel(int index, std::shared_ptr<FileEntryCurve> fileEntry, QWidget* parent)
|
||||||
: DataPanel(index, fileEntry, parent)
|
: DataPanel(index, fileEntry, parent)
|
||||||
{
|
{
|
||||||
|
m_iXMin = 0;
|
||||||
|
m_iXMax = 0;
|
||||||
|
m_iYMax = 0;
|
||||||
|
m_iYMin = 0;
|
||||||
|
|
||||||
if (fileEntry) {
|
if (fileEntry) {
|
||||||
LOG_INFO("Created CurvePanel {} for chart: {}", index, fileEntry->GetName().toStdString());
|
LOG_INFO("Created CurvePanel {} for chart: {}", index, fileEntry->GetName().toStdString());
|
||||||
// Override the title with chart name
|
// Override the title with chart name
|
||||||
@ -49,9 +55,9 @@ void CurvePanel::RefreshPanel()
|
|||||||
OnDataPanelUpdated(fileEntry);
|
OnDataPanelUpdated(fileEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsValid()) {
|
//if (IsValid()) {
|
||||||
UpdateCurveDisplay();
|
// UpdateCurveDisplay();
|
||||||
}
|
//}
|
||||||
|
|
||||||
LOG_INFO("Refreshed CurvePanel {}", GetIndex());
|
LOG_INFO("Refreshed CurvePanel {}", GetIndex());
|
||||||
}
|
}
|
||||||
@ -299,7 +305,6 @@ void CurvePanel::UpdateCurveDisplay()
|
|||||||
void CurvePanel::InitUI()
|
void CurvePanel::InitUI()
|
||||||
{
|
{
|
||||||
initQChartView();
|
initQChartView();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CurvePanel::GetTypeDisplayName() const
|
QString CurvePanel::GetTypeDisplayName() const
|
||||||
@ -329,9 +334,394 @@ void CurvePanel::initQChartView() {
|
|||||||
curveChartView->setRenderHint(QPainter::Antialiasing);
|
curveChartView->setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
QHBoxLayout* pLayout = new QHBoxLayout(this);
|
QHBoxLayout* pLayout = new QHBoxLayout(this);
|
||||||
|
pLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
pLayout->addWidget(curveChartView);
|
pLayout->addWidget(curveChartView);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurvePanel::OnDataPanelUpdated(FileEntryCurve* fileEntry) {
|
void CurvePanel::OnDataPanelUpdated(FileEntryCurve* fileEntry) {
|
||||||
int a = 0;
|
FileEntryCurve::ChartProperties propChart = fileEntry->GetChartProperties();
|
||||||
|
|
||||||
|
QString strName = fileEntry->GetName();
|
||||||
|
updateTitle(strName);
|
||||||
|
|
||||||
|
updateTitleAxis(propChart.xTitle, propChart.yTitle);
|
||||||
|
updateMinMaxX(propChart.xMin, propChart.xMax, propChart.xCount);
|
||||||
|
updateMinMaxY(propChart.yMin, propChart.yMax, propChart.yCount);
|
||||||
|
|
||||||
|
QString strFile = fileEntry->GetPath() + "/" + fileEntry->GetFileName();
|
||||||
|
FileEntryCurve::CurveProperties propCurves = fileEntry->GetCurveProperties();
|
||||||
|
if (propChart.chartType == ChartType::Wave)
|
||||||
|
{
|
||||||
|
updateParseWaveFile(strFile, propChart.timeParam, propCurves);
|
||||||
|
}
|
||||||
|
else if (propChart.chartType == ChartType::Report)
|
||||||
|
{
|
||||||
|
updateParseReportFile(strFile, propChart.timeParam, propCurves);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CurvePanel::updateTitle(const QString & title)
|
||||||
|
{
|
||||||
|
if (nullptr != dockWidget_)
|
||||||
|
{
|
||||||
|
dockWidget_->setWindowTitle(title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CurvePanel::updateTitleAxis(const QString & xTitle, const QString & yTitle)
|
||||||
|
{
|
||||||
|
if (m_pAxisX)
|
||||||
|
{
|
||||||
|
if (!xTitle.isEmpty())
|
||||||
|
{
|
||||||
|
m_pAxisX->setTitleText(xTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_pAxisY)
|
||||||
|
{
|
||||||
|
if (!yTitle.isEmpty())
|
||||||
|
{
|
||||||
|
m_pAxisY->setTitleText(yTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CurvePanel::updateMinMaxX(float min, float max, int count)
|
||||||
|
{
|
||||||
|
if (max > min)
|
||||||
|
{
|
||||||
|
m_iXMin = min;
|
||||||
|
m_iXMax = max;
|
||||||
|
|
||||||
|
QList<QAbstractAxis*> axesX;
|
||||||
|
axesX = curveChart->axes(Qt::Horizontal);
|
||||||
|
QValueAxis* curAxisX = (QValueAxis*)axesX[0];
|
||||||
|
curAxisX->setRange(m_iXMin, m_iXMax);
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
curAxisX->setTickCount(count);
|
||||||
|
curAxisX->setLabelFormat("%d");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CurvePanel::updateMinMaxY(float min, float max, int count)
|
||||||
|
{
|
||||||
|
if (max > min)
|
||||||
|
{
|
||||||
|
m_iYMin = min;
|
||||||
|
m_iYMax = max;
|
||||||
|
|
||||||
|
QList<QAbstractAxis*> axesY;
|
||||||
|
axesY = curveChart->axes(Qt::Vertical);
|
||||||
|
QValueAxis* curAxisY = (QValueAxis*)axesY[0];
|
||||||
|
curAxisY->setRange(m_iYMin, m_iYMax);
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
curAxisY->setTickCount(count);
|
||||||
|
curAxisY->setLabelFormat("%d");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CurvePanel::updateParseWaveFile(const QString& strFile, int nT, FileEntryCurve::CurveProperties listCurve)
|
||||||
|
{
|
||||||
|
if (strFile.isEmpty())
|
||||||
|
{
|
||||||
|
QMessageBox::information(nullptr, QStringLiteral("Error"), QStringLiteral("Please check Wave file path"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile file(strFile);
|
||||||
|
if (file.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
for (int nI = 0; nI < listCurve.size(); nI++)
|
||||||
|
{
|
||||||
|
FileEntryCurve::CurveProperty propCurve = listCurve.at(nI);
|
||||||
|
|
||||||
|
QSplineSeries *pSeries = new QSplineSeries(this);
|
||||||
|
pSeries->setName(propCurve.name);
|
||||||
|
pSeries->setColor(propCurve.color);
|
||||||
|
pSeries->setUseOpenGL(true);
|
||||||
|
//pSeries->attachAxis(m_pAxisY);
|
||||||
|
//pSeries->attachAxis(m_pAxisX);
|
||||||
|
curveChart->addSeries(pSeries);
|
||||||
|
m_seriesIDMap.insert(nI, pSeries);
|
||||||
|
|
||||||
|
QPen pen(propCurve.color);
|
||||||
|
pen.setWidth(2);
|
||||||
|
pSeries->setPen(pen);
|
||||||
|
|
||||||
|
QList<QAbstractAxis*> axesX;
|
||||||
|
axesX = curveChart->axes(Qt::Horizontal);
|
||||||
|
QValueAxis* curAxisX = (QValueAxis*)axesX[0];
|
||||||
|
pSeries->attachAxis(curAxisX);
|
||||||
|
|
||||||
|
QList<QAbstractAxis*> axesY;
|
||||||
|
axesY = curveChart->axes(Qt::Vertical);
|
||||||
|
QValueAxis* curAxisY = (QValueAxis*)axesY[0];
|
||||||
|
pSeries->attachAxis(curAxisY);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bResetAxisX = false;
|
||||||
|
if (m_iXMax == m_iXMin)
|
||||||
|
{
|
||||||
|
bResetAxisX = true;
|
||||||
|
}
|
||||||
|
bool bResetAxisY = false;
|
||||||
|
if (m_iYMax == m_iYMin)
|
||||||
|
{
|
||||||
|
bResetAxisY = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
float maxY = -10000000.0;
|
||||||
|
float minY = 10000000.0;
|
||||||
|
|
||||||
|
while (!file.atEnd())
|
||||||
|
{
|
||||||
|
QString strLine = file.readLine().simplified();
|
||||||
|
if (!strLine.isEmpty())
|
||||||
|
{
|
||||||
|
QStringList listLine = strLine.split(" ");
|
||||||
|
double t = listLine.at(nT).toDouble();
|
||||||
|
|
||||||
|
QMap<int, QVariantList> mapData;
|
||||||
|
for (int nI = 0; nI < listCurve.size(); nI++)
|
||||||
|
{
|
||||||
|
FileEntryCurve::CurveProperty propCurve = listCurve.at(nI);
|
||||||
|
|
||||||
|
if (bResetAxisX)
|
||||||
|
{
|
||||||
|
int nMax = propCurve.data.wave.stop - propCurve.data.wave.start;
|
||||||
|
if (m_iXMax < nMax)
|
||||||
|
{
|
||||||
|
m_iXMax = nMax;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantList listData;
|
||||||
|
for (int nJ = propCurve.data.wave.start; nJ < propCurve.data.wave.stop; nJ++)
|
||||||
|
{
|
||||||
|
double value = listLine.at(nJ).toDouble();
|
||||||
|
listData.push_back(value);
|
||||||
|
|
||||||
|
if (bResetAxisY)
|
||||||
|
{
|
||||||
|
if (value < minY)
|
||||||
|
{
|
||||||
|
minY = value;
|
||||||
|
}
|
||||||
|
if (value > maxY)
|
||||||
|
{
|
||||||
|
maxY = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mapData.insert(nI, listData);
|
||||||
|
}
|
||||||
|
m_dataWava.insert(t, mapData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bResetAxisX)
|
||||||
|
{
|
||||||
|
updateMinMaxX(0, m_iXMax * 1.1, 0);
|
||||||
|
}
|
||||||
|
if (bResetAxisY)
|
||||||
|
{
|
||||||
|
updateMinMaxY(minY * 0.9, maxY * 1.1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CurvePanel::updateParseReportFile(const QString & strFile, int nT, FileEntryCurve::CurveProperties listCurve)
|
||||||
|
{
|
||||||
|
if (strFile.isEmpty())
|
||||||
|
{
|
||||||
|
QMessageBox::information(nullptr, QStringLiteral("Error"), QStringLiteral("Please check data file path"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile file(strFile);
|
||||||
|
if (file.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
|
for (int nI = 0; nI < listCurve.size(); nI++)
|
||||||
|
{
|
||||||
|
FileEntryCurve::CurveProperty propCurve = listCurve.at(nI);
|
||||||
|
|
||||||
|
QSplineSeries *pSeries = new QSplineSeries(this);
|
||||||
|
pSeries->setName(propCurve.name);
|
||||||
|
pSeries->setColor(propCurve.color);
|
||||||
|
pSeries->setUseOpenGL(true);
|
||||||
|
//pSeries->attachAxis(m_pAxisY);
|
||||||
|
//pSeries->attachAxis(m_pAxisX);
|
||||||
|
curveChart->addSeries(pSeries);
|
||||||
|
m_seriesIDMap.insert(nI, pSeries);
|
||||||
|
|
||||||
|
QPen pen(propCurve.color);
|
||||||
|
pen.setWidth(2);
|
||||||
|
pSeries->setPen(pen);
|
||||||
|
|
||||||
|
QList<QAbstractAxis*> axesX;
|
||||||
|
axesX = curveChart->axes(Qt::Horizontal);
|
||||||
|
QValueAxis* curAxisX = (QValueAxis*)axesX[0];
|
||||||
|
pSeries->attachAxis(curAxisX);
|
||||||
|
|
||||||
|
QList<QAbstractAxis*> axesY;
|
||||||
|
axesY = curveChart->axes(Qt::Vertical);
|
||||||
|
QValueAxis* curAxisY = (QValueAxis*)axesY[0];
|
||||||
|
pSeries->attachAxis(curAxisY);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bResetAxisX = false;
|
||||||
|
if (m_iXMax == m_iXMin)
|
||||||
|
{
|
||||||
|
bResetAxisX = true;
|
||||||
|
}
|
||||||
|
bool bResetAxisY = false;
|
||||||
|
if (m_iYMax == m_iYMin)
|
||||||
|
{
|
||||||
|
bResetAxisY = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
float maxX = -10000000.0;
|
||||||
|
float minX = 10000000.0;
|
||||||
|
float maxY = -10000000.0;
|
||||||
|
float minY = 10000000.0;
|
||||||
|
|
||||||
|
while (!file.atEnd())
|
||||||
|
{
|
||||||
|
QString strLine = file.readLine().simplified();
|
||||||
|
if (!strLine.isEmpty())
|
||||||
|
{
|
||||||
|
QStringList listLine = strLine.split(" ");
|
||||||
|
double t = listLine.at(nT).toDouble();
|
||||||
|
|
||||||
|
QMap<int, QPointF> mapData;
|
||||||
|
for (int nI = 0; nI < listCurve.size(); nI++)
|
||||||
|
{
|
||||||
|
FileEntryCurve::CurveProperty propCurve = listCurve.at(nI);
|
||||||
|
|
||||||
|
double x = listLine.at(propCurve.data.report.x).toDouble();
|
||||||
|
double y = listLine.at(propCurve.data.report.y).toDouble();
|
||||||
|
|
||||||
|
QPointF ptData = QPointF(x, y);
|
||||||
|
mapData.insert(nI, ptData);
|
||||||
|
|
||||||
|
if (bResetAxisX)
|
||||||
|
{
|
||||||
|
if (x < minX)
|
||||||
|
{
|
||||||
|
minX = x;
|
||||||
|
}
|
||||||
|
if (x > maxX)
|
||||||
|
{
|
||||||
|
maxX = x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bResetAxisY)
|
||||||
|
{
|
||||||
|
if (y < minY)
|
||||||
|
{
|
||||||
|
minY = y;
|
||||||
|
}
|
||||||
|
if (y > maxY)
|
||||||
|
{
|
||||||
|
maxY = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_dataReport.insert(t, mapData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bResetAxisX)
|
||||||
|
{
|
||||||
|
updateMinMaxX(minX * 0.9, maxX * 1.1, 0);
|
||||||
|
}
|
||||||
|
if (bResetAxisY)
|
||||||
|
{
|
||||||
|
updateMinMaxY(minY * 0.9, maxY * 1.1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CurvePanel::updateWaveData(double t)
|
||||||
|
{
|
||||||
|
if (m_dataWava.size() > 0)
|
||||||
|
{
|
||||||
|
QMap< double, QMap<int, QVariantList> >::const_iterator ite = m_dataWava.lowerBound(t);
|
||||||
|
if (ite == m_dataWava.end())
|
||||||
|
{
|
||||||
|
ite--;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<int, QVariantList> mapData = ite.value();
|
||||||
|
for (QMap<int, QVariantList>::Iterator it = mapData.begin(); it != mapData.end(); it++)
|
||||||
|
{
|
||||||
|
int nIndex = it.key();
|
||||||
|
QVariantList dataList = it.value();
|
||||||
|
|
||||||
|
QSplineSeries* pSeries = m_seriesIDMap.value(nIndex);
|
||||||
|
if (pSeries)
|
||||||
|
{
|
||||||
|
pSeries->clear();
|
||||||
|
for (int nI = 0; nI < dataList.size(); nI++)
|
||||||
|
{
|
||||||
|
float fY = dataList.at(nI).toFloat();
|
||||||
|
pSeries->append(QPointF(nI, fY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CurvePanel::updateReportData(double t)
|
||||||
|
{
|
||||||
|
if (m_dataReport.size() > 0)
|
||||||
|
{
|
||||||
|
for (QMap<int, QSplineSeries*>::Iterator itSeries = m_seriesIDMap.begin(); itSeries != m_seriesIDMap.end(); itSeries++)
|
||||||
|
{
|
||||||
|
QSplineSeries* pSeries = itSeries.value();
|
||||||
|
if (pSeries)
|
||||||
|
{
|
||||||
|
pSeries->clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap< double, QMap<int, QPointF> >::const_iterator ite = m_dataReport.lowerBound(t);
|
||||||
|
if (ite != m_dataReport.end())
|
||||||
|
{
|
||||||
|
ite++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (QMap< double, QMap<int, QPointF> >::Iterator itA = m_dataReport.begin(); itA != ite; itA++)
|
||||||
|
{
|
||||||
|
double dTime = itA.key();
|
||||||
|
QMap<int, QPointF> mapData = itA.value();
|
||||||
|
for (QMap<int, QPointF>::Iterator it = mapData.begin(); it != mapData.end(); it++)
|
||||||
|
{
|
||||||
|
int nIndex = it.key();
|
||||||
|
QPointF data = it.value();
|
||||||
|
|
||||||
|
QSplineSeries* pSeries = m_seriesIDMap.value(nIndex);
|
||||||
|
if (pSeries)
|
||||||
|
{
|
||||||
|
pSeries->append(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CurvePanel::OnTimeChanged(double time)
|
||||||
|
{
|
||||||
|
updateWaveData(time);
|
||||||
|
updateReportData(time);
|
||||||
}
|
}
|
||||||
@ -72,12 +72,25 @@ protected:
|
|||||||
|
|
||||||
void OnDataPanelUpdated(FileEntryCurve* fileEntry);
|
void OnDataPanelUpdated(FileEntryCurve* fileEntry);
|
||||||
|
|
||||||
|
virtual void OnTimeChanged(double time);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief Update curve display based on chart data
|
* @brief Update curve display based on chart data
|
||||||
*/
|
*/
|
||||||
void UpdateCurveDisplay();
|
void UpdateCurveDisplay();
|
||||||
|
|
||||||
|
void updateTitle(const QString& title);
|
||||||
|
void updateTitleAxis(const QString& xTitle, const QString& yTitle);
|
||||||
|
void updateMinMaxX(float min, float max, int count);
|
||||||
|
void updateMinMaxY(float min, float max, int count);
|
||||||
|
|
||||||
|
void updateParseWaveFile(const QString& strFile, int nT, FileEntryCurve::CurveProperties listCurve);
|
||||||
|
void updateParseReportFile(const QString& strFile, int nT, FileEntryCurve::CurveProperties listCurve);
|
||||||
|
|
||||||
|
void updateWaveData(double t);
|
||||||
|
void updateReportData(double t);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::FitCurve* ui;
|
Ui::FitCurve* ui;
|
||||||
FitCurveChartView* curveChartView;
|
FitCurveChartView* curveChartView;
|
||||||
|
|||||||
@ -16,7 +16,7 @@ DataPanel::DataPanel(int index, FileEntryType fileType, const QString& filePath,
|
|||||||
, dockWidget_(nullptr)
|
, dockWidget_(nullptr)
|
||||||
{
|
{
|
||||||
title_ = GenerateTitle();
|
title_ = GenerateTitle();
|
||||||
//InitUI();
|
InitUI();
|
||||||
|
|
||||||
LOG_INFO("Created DataPanel {} for {} file: {}", index_, FileEntryTypeToString(fileType_), filePath_.toStdString());
|
LOG_INFO("Created DataPanel {} for {} file: {}", index_, FileEntryTypeToString(fileType_), filePath_.toStdString());
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ void DataPanel::InitUI()
|
|||||||
// layout->addWidget(infoLabel);
|
// layout->addWidget(infoLabel);
|
||||||
// setLayout(layout);
|
// setLayout(layout);
|
||||||
|
|
||||||
RefreshPanel();
|
//RefreshPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DataPanel::GenerateTitle()
|
QString DataPanel::GenerateTitle()
|
||||||
|
|||||||
@ -94,6 +94,7 @@ public:
|
|||||||
virtual void InitUI();
|
virtual void InitUI();
|
||||||
|
|
||||||
bool IsValid() const { return fileEntry_ != nullptr; }
|
bool IsValid() const { return fileEntry_ != nullptr; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* @brief Panel close signal
|
* @brief Panel close signal
|
||||||
@ -107,8 +108,6 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void closeEvent(QCloseEvent* event) override;
|
void closeEvent(QCloseEvent* event) override;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Generate panel title
|
* @brief Generate panel title
|
||||||
* @return Generated title
|
* @return Generated title
|
||||||
|
|||||||
@ -207,19 +207,18 @@ DataPanel* DataPanelManager::CreateDataPanel(FileEntryType fileType, const QStri
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//panel->InitUI();
|
dockWidget->setWidget(panel);
|
||||||
|
|
||||||
|
// Set panel's dock widget reference
|
||||||
|
panel->SetDockWidget(dockWidget);
|
||||||
|
|
||||||
auto fileEntries = currentWorkspace_->GetFileEntries(fileType);
|
auto fileEntries = currentWorkspace_->GetFileEntries(fileType);
|
||||||
if (index < fileEntries.size()) {
|
if (index < fileEntries.size()) {
|
||||||
panel->SetFileEntry(fileEntries[index]);
|
panel->SetFileEntry(fileEntries[index]);
|
||||||
panel->InitUI();
|
panel->InitUI();
|
||||||
|
panel->RefreshPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
dockWidget->setWidget(panel);
|
|
||||||
|
|
||||||
// Set panel's dock widget reference
|
|
||||||
panel->SetDockWidget(dockWidget);
|
|
||||||
|
|
||||||
// Connect panel signals
|
// Connect panel signals
|
||||||
connect(panel, &DataPanel::PanelClosed, this, &DataPanelManager::OnPanelClosed);
|
connect(panel, &DataPanel::PanelClosed, this, &DataPanelManager::OnPanelClosed);
|
||||||
|
|
||||||
@ -316,7 +315,7 @@ int DataPanelManager::FindNextAvailableIndex(FileEntryType fileType) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i <= GetMaxPanelCount(); ++i) {
|
for (int i = 0; i < GetMaxPanelCount(); ++i) {
|
||||||
if (!usedIndices.contains(i)) {
|
if (!usedIndices.contains(i)) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,67 +106,46 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QComboBox" name="chartTypeComboBox">
|
<widget class="QComboBox" name="chartTypeComboBox"/>
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Wave</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Report</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="xTitleLabel">
|
<widget class="QLabel" name="xTitleLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>X Axis Title:</string>
|
<string>X Axis Title:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLineEdit" name="xTitleEdit">
|
<widget class="QLineEdit" name="xTitleEdit">
|
||||||
<property name="placeholderText">
|
<property name="placeholderText">
|
||||||
<string>Enter X axis title...</string>
|
<string>Enter X axis title...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="yTitleLabel">
|
<widget class="QLabel" name="yTitleLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Y Axis Title:</string>
|
<string>Y Axis Title:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QLineEdit" name="yTitleEdit">
|
<widget class="QLineEdit" name="yTitleEdit">
|
||||||
<property name="placeholderText">
|
<property name="placeholderText">
|
||||||
<string>Enter Y axis title...</string>
|
<string>Enter Y axis title...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="timeParamLabel">
|
<widget class="QLabel" name="timeParamLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Time Parameter:</string>
|
<string>Time:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="timeParamSpinBox">
|
<widget class="QSpinBox" name="timeParamSpinBox"/>
|
||||||
<property name="minimum">
|
</item>
|
||||||
<double>0.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<double>999999.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<double>0.000000000000000</double>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -486,16 +465,19 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="xValueLabel">
|
<widget class="QLabel" name="xValueLabel">
|
||||||
<property name="text">
|
|
||||||
<string>X Value:</string>
|
|
||||||
</property>
|
|
||||||
<property name="visible">
|
<property name="visible">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>X Value:</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="xValueSpinBox">
|
<widget class="QDoubleSpinBox" name="xValueSpinBox">
|
||||||
|
<property name="visible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<double>-999999.000000000000000</double>
|
<double>-999999.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
@ -505,23 +487,23 @@
|
|||||||
<property name="value">
|
<property name="value">
|
||||||
<double>0.000000000000000</double>
|
<double>0.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="visible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QLabel" name="yValueLabel">
|
<widget class="QLabel" name="yValueLabel">
|
||||||
<property name="text">
|
|
||||||
<string>Y Value:</string>
|
|
||||||
</property>
|
|
||||||
<property name="visible">
|
<property name="visible">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Y Value:</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="QDoubleSpinBox" name="yValueSpinBox">
|
<widget class="QDoubleSpinBox" name="yValueSpinBox">
|
||||||
|
<property name="visible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<double>-999999.000000000000000</double>
|
<double>-999999.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
@ -531,9 +513,6 @@
|
|||||||
<property name="value">
|
<property name="value">
|
||||||
<double>0.000000000000000</double>
|
<double>0.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="visible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
@ -280,8 +280,8 @@ bool FileEntryCurve::SaveFiles(tinyxml2::XMLElement* scene, tinyxml2::XMLDocumen
|
|||||||
|
|
||||||
// 根据Chart类型保存不同的属性
|
// 根据Chart类型保存不同的属性
|
||||||
if (chartProperties_.chartType == ChartType::Wave) {
|
if (chartProperties_.chartType == ChartType::Wave) {
|
||||||
curveElement->SetAttribute("startPoint", curve.data.wave.start);
|
curveElement->SetAttribute("start", curve.data.wave.start);
|
||||||
curveElement->SetAttribute("endPoint", curve.data.wave.stop);
|
curveElement->SetAttribute("stop", curve.data.wave.stop);
|
||||||
} else if (chartProperties_.chartType == ChartType::Report) {
|
} else if (chartProperties_.chartType == ChartType::Report) {
|
||||||
curveElement->SetAttribute("x", curve.data.report.x);
|
curveElement->SetAttribute("x", curve.data.report.x);
|
||||||
curveElement->SetAttribute("y", curve.data.report.y);
|
curveElement->SetAttribute("y", curve.data.report.y);
|
||||||
@ -292,18 +292,18 @@ bool FileEntryCurve::SaveFiles(tinyxml2::XMLElement* scene, tinyxml2::XMLDocumen
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FileEntryCurve ParseFiles implementation
|
// FileEntryCurve ParseFiles implementation
|
||||||
bool FileEntryCurve::ParseFiles(const tinyxml2::XMLElement* element) {
|
bool FileEntryCurve::ParseFiles(const tinyxml2::XMLElement* chartElement) {
|
||||||
if (!element) {
|
if (!chartElement) {
|
||||||
LOG_ERROR("Invalid XML element");
|
LOG_ERROR("Invalid XML element");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找<chart>元素
|
// 查找<chart>元素
|
||||||
const tinyxml2::XMLElement* chartElement = element->FirstChildElement("chart");
|
//const tinyxml2::XMLElement* chartElement = element->FirstChildElement("chart");
|
||||||
if (!chartElement) {
|
//if (!chartElement) {
|
||||||
LOG_ERROR("No chart element found");
|
// LOG_ERROR("No chart element found");
|
||||||
return false;
|
// return false;
|
||||||
}
|
//}
|
||||||
|
|
||||||
// 解析chart属性
|
// 解析chart属性
|
||||||
const char* nameAttr = chartElement->Attribute("name");
|
const char* nameAttr = chartElement->Attribute("name");
|
||||||
@ -358,8 +358,8 @@ bool FileEntryCurve::ParseFiles(const tinyxml2::XMLElement* element) {
|
|||||||
|
|
||||||
// 根据Chart类型解析不同的属性
|
// 根据Chart类型解析不同的属性
|
||||||
if (chartProperties_.chartType == ChartType::Wave) {
|
if (chartProperties_.chartType == ChartType::Wave) {
|
||||||
curve.data.wave.start = curveElement->IntAttribute("startPoint", 0);
|
curve.data.wave.start = curveElement->IntAttribute("start", 0);
|
||||||
curve.data.wave.stop = curveElement->IntAttribute("endPoint", 0);
|
curve.data.wave.stop = curveElement->IntAttribute("stop", 0);
|
||||||
} else if (chartProperties_.chartType == ChartType::Report) {
|
} else if (chartProperties_.chartType == ChartType::Report) {
|
||||||
curve.data.report.x = curveElement->DoubleAttribute("x", 0.0);
|
curve.data.report.x = curveElement->DoubleAttribute("x", 0.0);
|
||||||
curve.data.report.y = curveElement->DoubleAttribute("y", 0.0);
|
curve.data.report.y = curveElement->DoubleAttribute("y", 0.0);
|
||||||
|
|||||||
@ -119,6 +119,7 @@ public:
|
|||||||
struct CurveProperty {
|
struct CurveProperty {
|
||||||
QString name;
|
QString name;
|
||||||
QColor color;
|
QColor color;
|
||||||
|
|
||||||
// Wave类型使用start/stop,Report类型使用x/y
|
// Wave类型使用start/stop,Report类型使用x/y
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
|
|||||||
@ -132,17 +132,32 @@ bool WorkSpaceXMLParse::ParseFiles(const tinyxml2::XMLElement* element) {
|
|||||||
// Create FileEntry objects and call their ParseFiles method
|
// Create FileEntry objects and call their ParseFiles method
|
||||||
FileEntryType enumType;
|
FileEntryType enumType;
|
||||||
if (FileEntryTypeFromString(name, enumType)) {
|
if (FileEntryTypeFromString(name, enumType)) {
|
||||||
|
|
||||||
|
const tinyxml2::XMLElement* chartElement = typeElement->FirstChildElement("chart");
|
||||||
|
while (nullptr != chartElement) {
|
||||||
|
auto fileEntry = CreateEmptyFileEntry(enumType); // Create empty FileEntry for XML parsing
|
||||||
|
if (fileEntry) {
|
||||||
|
// Call the FileEntry's ParseFiles method to parse detailed data
|
||||||
|
if (fileEntry->ParseFiles(chartElement)) {
|
||||||
|
// Add the parsed FileEntry to workspace
|
||||||
|
workSpace_->SetFileEntry(fileEntry, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
chartElement = chartElement->NextSiblingElement();
|
||||||
|
}
|
||||||
|
|
||||||
// Create FileEntry objects for this type
|
// Create FileEntry objects for this type
|
||||||
for (int i = 0; i < count; ++i) {
|
//for (int i = 0; i < count; ++i) {
|
||||||
auto fileEntry = CreateEmptyFileEntry(enumType); // Create empty FileEntry for XML parsing
|
// auto fileEntry = CreateEmptyFileEntry(enumType); // Create empty FileEntry for XML parsing
|
||||||
if (fileEntry) {
|
// if (fileEntry) {
|
||||||
// Call the FileEntry's ParseFiles method to parse detailed data
|
// // Call the FileEntry's ParseFiles method to parse detailed data
|
||||||
if (fileEntry->ParseFiles(typeElement)) {
|
// if (fileEntry->ParseFiles(typeElement)) {
|
||||||
// Add the parsed FileEntry to workspace
|
// // Add the parsed FileEntry to workspace
|
||||||
workSpace_->SetFileEntry(fileEntry, false);
|
// workSpace_->SetFileEntry(fileEntry, false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Also set file entry count for backward compatibility
|
// Also set file entry count for backward compatibility
|
||||||
workSpace_->SetFileEntryCount(enumType, count);
|
workSpace_->SetFileEntryCount(enumType, count);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user