338 lines
13 KiB
C++
338 lines
13 KiB
C++
#include "ui/Panel/CurvePanel.h"
|
|
#include "ui/DockWidget.h"
|
|
#include "common/SpdLogger.h"
|
|
|
|
#include <QVBoxLayout>
|
|
#include <QLabel>
|
|
#include <QFileInfo>
|
|
#include <QScrollArea>
|
|
#include <QGroupBox>
|
|
#include <QCheckBox>
|
|
#include <QHBoxLayout>
|
|
|
|
#include "ui_FitCurve.h"
|
|
|
|
CurvePanel::CurvePanel(int index, const QString& filePath, QWidget* parent)
|
|
: DataPanel(index, FileEntryType::Curve, filePath, parent)
|
|
{
|
|
m_iXMin = 0;
|
|
m_iXMax = 0;
|
|
m_iYMax = 0;
|
|
m_iYMin = 0;
|
|
|
|
LOG_INFO("Created CurvePanel {} for file: {}", index, filePath.toStdString());
|
|
}
|
|
|
|
CurvePanel::CurvePanel(int index, std::shared_ptr<FileEntryCurve> fileEntry, QWidget* parent)
|
|
: DataPanel(index, fileEntry, parent)
|
|
{
|
|
if (fileEntry) {
|
|
LOG_INFO("Created CurvePanel {} for chart: {}", index, fileEntry->GetName().toStdString());
|
|
// Override the title with chart name
|
|
title_ = QString("Curve Panel %1 - %2").arg(index).arg(fileEntry->GetName());
|
|
} else {
|
|
LOG_WARN("Created CurvePanel {} with null chart data", index);
|
|
}
|
|
}
|
|
|
|
CurvePanel::~CurvePanel()
|
|
{
|
|
LOG_INFO("Destroyed CurvePanel {}", GetIndex());
|
|
}
|
|
|
|
void CurvePanel::RefreshPanel()
|
|
{
|
|
// Implement curve-specific refresh logic here
|
|
DataPanel::RefreshPanel();
|
|
|
|
if (auto fileEntry = fileEntry_->AsCurve()) {
|
|
OnDataPanelUpdated(fileEntry);
|
|
}
|
|
|
|
if (IsValid()) {
|
|
UpdateCurveDisplay();
|
|
}
|
|
|
|
LOG_INFO("Refreshed CurvePanel {}", GetIndex());
|
|
}
|
|
|
|
void CurvePanel::UpdateCurveDisplay()
|
|
{
|
|
if (!IsValid()) {
|
|
return;
|
|
}
|
|
|
|
// Clear existing layout and recreate
|
|
if (layout()) {
|
|
QLayoutItem* item;
|
|
while ((item = layout()->takeAt(0)) != nullptr) {
|
|
delete item->widget();
|
|
delete item;
|
|
}
|
|
delete layout();
|
|
}
|
|
|
|
// Create new layout with chart information
|
|
QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
|
|
|
// Chart info section
|
|
QGroupBox* chartInfoGroup = new QGroupBox(QString("Chart: %1").arg(fileEntry_->GetName()));
|
|
QVBoxLayout* chartInfoLayout = new QVBoxLayout(chartInfoGroup);
|
|
|
|
// Chart details - handle different chart types
|
|
QLabel* pathLabel = new QLabel(QString("File: %1").arg(fileEntry_->GetFileName()));
|
|
chartInfoLayout->addWidget(pathLabel);
|
|
|
|
auto chartProperties = fileEntry_->AsCurve()->GetChartProperties();
|
|
// Type-specific information
|
|
QLabel* titleLabel = new QLabel(QString("Title: X=%1, Y=%2").arg(chartProperties.xTitle, chartProperties.yTitle));
|
|
QLabel* rangeLabel = new QLabel(QString("Range: X[%1-%2], Y[%3-%4]")
|
|
.arg(chartProperties.xMin).arg(chartProperties.xMax)
|
|
.arg(chartProperties.yMin).arg(chartProperties.yMax));
|
|
QLabel* countLabel = new QLabel(QString("Count: X=%1, T=%2").arg(chartProperties.xCount).arg(chartProperties.timeParam));
|
|
|
|
chartInfoLayout->addWidget(titleLabel);
|
|
chartInfoLayout->addWidget(rangeLabel);
|
|
chartInfoLayout->addWidget(countLabel);
|
|
|
|
// Curves section
|
|
const auto& curveProperties = fileEntry_->AsCurve()->GetCurveProperties();
|
|
if (!curveProperties.isEmpty()) {
|
|
QGroupBox* curvesGroup = new QGroupBox(QString("Curves (%1)").arg(curveProperties.size()));
|
|
QVBoxLayout* curvesLayout = new QVBoxLayout(curvesGroup);
|
|
|
|
// Add scroll area for curves
|
|
QScrollArea* scrollArea = new QScrollArea();
|
|
QWidget* scrollWidget = new QWidget();
|
|
QVBoxLayout* scrollLayout = new QVBoxLayout(scrollWidget);
|
|
|
|
for (const auto& curve : curveProperties) {
|
|
QHBoxLayout* curveLayout = new QHBoxLayout();
|
|
|
|
// Curve checkbox for show/hide
|
|
QCheckBox* curveCheckBox = new QCheckBox(curve.name);
|
|
curveCheckBox->setChecked(true);
|
|
|
|
// Curve info - display different information based on chart type
|
|
QString colorStr = QString("rgb(%1,%2,%3)").arg(curve.color.red()).arg(curve.color.green()).arg(curve.color.blue());
|
|
QLabel* curveInfo;
|
|
|
|
if (chartProperties.chartType == ChartType::Wave) {
|
|
curveInfo = new QLabel(QString("Range: %1-%2, Color: %3")
|
|
.arg(curve.data.wave.start).arg(curve.data.wave.stop).arg(colorStr));
|
|
} else {
|
|
curveInfo = new QLabel(QString("Position: (%1,%2), Color: %3")
|
|
.arg(curve.data.report.x).arg(curve.data.report.y).arg(colorStr));
|
|
}
|
|
|
|
curveInfo->setStyleSheet(QString("QLabel { color: %1; }").arg(colorStr));
|
|
|
|
curveLayout->addWidget(curveCheckBox);
|
|
curveLayout->addWidget(curveInfo);
|
|
curveLayout->addStretch();
|
|
|
|
scrollLayout->addLayout(curveLayout);
|
|
}
|
|
|
|
scrollWidget->setLayout(scrollLayout);
|
|
scrollArea->setWidget(scrollWidget);
|
|
scrollArea->setWidgetResizable(true);
|
|
scrollArea->setMaximumHeight(200);
|
|
|
|
curvesLayout->addWidget(scrollArea);
|
|
mainLayout->addWidget(curvesGroup);
|
|
}
|
|
// if (auto curveChart = std::dynamic_pointer_cast<CurveChartData>(fileEntry_->chartData)) {
|
|
|
|
// }
|
|
|
|
// }
|
|
// else if (auto surfaceChart = std::dynamic_pointer_cast<SurfaceChartData>(chartData_)) {
|
|
// QLabel* titleLabel = new QLabel(QString("Title: X=%1, Y=%2, Z=%3")
|
|
// .arg(surfaceChart->xTitle, surfaceChart->yTitle, surfaceChart->zTitle));
|
|
// QLabel* rangeLabel = new QLabel(QString("Range: X[%1-%2], Y[%3-%4], Z[%5-%6]")
|
|
// .arg(surfaceChart->xMin).arg(surfaceChart->xMax)
|
|
// .arg(surfaceChart->yMin).arg(surfaceChart->yMax)
|
|
// .arg(surfaceChart->zMin).arg(surfaceChart->zMax));
|
|
// QLabel* countLabel = new QLabel(QString("Count: X=%1, Y=%2, Z=%3, T=%4")
|
|
// .arg(surfaceChart->xCount).arg(surfaceChart->yCount)
|
|
// .arg(surfaceChart->zCount).arg(surfaceChart->t));
|
|
|
|
// chartInfoLayout->addWidget(titleLabel);
|
|
// chartInfoLayout->addWidget(rangeLabel);
|
|
// chartInfoLayout->addWidget(countLabel);
|
|
|
|
// // Surface curves section
|
|
// if (!surfaceChart->curves.isEmpty()) {
|
|
// QGroupBox* curvesGroup = new QGroupBox(QString("Surface Curves (%1)").arg(surfaceChart->curves.size()));
|
|
// QVBoxLayout* curvesLayout = new QVBoxLayout(curvesGroup);
|
|
|
|
// QScrollArea* scrollArea = new QScrollArea();
|
|
// QWidget* scrollWidget = new QWidget();
|
|
// QVBoxLayout* scrollLayout = new QVBoxLayout(scrollWidget);
|
|
|
|
// for (const SurfaceCurveData& curve : surfaceChart->curves) {
|
|
// QHBoxLayout* curveLayout = new QHBoxLayout();
|
|
|
|
// QCheckBox* curveCheckBox = new QCheckBox(curve.name);
|
|
// curveCheckBox->setChecked(true);
|
|
|
|
// QLabel* curveInfo = new QLabel(QString("Range: %1-%2, Color: %3, Pos: (%4,%5,%6)")
|
|
// .arg(curve.data.wave.start).arg(curve.data.wave.stop).arg(curve.color)
|
|
// .arg(curve.data.report.x).arg(curve.data.report.y).arg(curve.z));
|
|
// curveInfo->setStyleSheet(QString("QLabel { color: rgb(%1); }").arg(curve.color));
|
|
|
|
// curveLayout->addWidget(curveCheckBox);
|
|
// curveLayout->addWidget(curveInfo);
|
|
// curveLayout->addStretch();
|
|
|
|
// scrollLayout->addLayout(curveLayout);
|
|
// }
|
|
|
|
// scrollWidget->setLayout(scrollLayout);
|
|
// scrollArea->setWidget(scrollWidget);
|
|
// scrollArea->setWidgetResizable(true);
|
|
// scrollArea->setMaximumHeight(200);
|
|
|
|
// curvesLayout->addWidget(scrollArea);
|
|
// mainLayout->addWidget(curvesGroup);
|
|
// }
|
|
|
|
// } else if (auto tableChart = std::dynamic_pointer_cast<TableChartData>(chartData_)) {
|
|
// QLabel* headLabel = new QLabel(QString("Head: %1").arg(tableChart->head));
|
|
// QLabel* timeLabel = new QLabel(QString("Time: %1").arg(tableChart->t));
|
|
|
|
// chartInfoLayout->addWidget(headLabel);
|
|
// chartInfoLayout->addWidget(timeLabel);
|
|
|
|
// // Table curves section
|
|
// if (!tableChart->curves.isEmpty()) {
|
|
// QGroupBox* curvesGroup = new QGroupBox(QString("Table Data (%1)").arg(tableChart->curves.size()));
|
|
// QVBoxLayout* curvesLayout = new QVBoxLayout(curvesGroup);
|
|
|
|
// QScrollArea* scrollArea = new QScrollArea();
|
|
// QWidget* scrollWidget = new QWidget();
|
|
// QVBoxLayout* scrollLayout = new QVBoxLayout(scrollWidget);
|
|
|
|
// for (const TableCurveData& curve : tableChart->curves) {
|
|
// QHBoxLayout* curveLayout = new QHBoxLayout();
|
|
|
|
// QCheckBox* curveCheckBox = new QCheckBox(curve.name);
|
|
// curveCheckBox->setChecked(true);
|
|
|
|
// QLabel* curveInfo = new QLabel(QString("Color: %1, Data: %2")
|
|
// .arg(curve.color).arg(curve.data));
|
|
// curveInfo->setStyleSheet(QString("QLabel { color: rgb(%1); }").arg(curve.color));
|
|
|
|
// curveLayout->addWidget(curveCheckBox);
|
|
// curveLayout->addWidget(curveInfo);
|
|
// curveLayout->addStretch();
|
|
|
|
// scrollLayout->addLayout(curveLayout);
|
|
// }
|
|
|
|
// scrollWidget->setLayout(scrollLayout);
|
|
// scrollArea->setWidget(scrollWidget);
|
|
// scrollArea->setWidgetResizable(true);
|
|
// scrollArea->setMaximumHeight(200);
|
|
|
|
// curvesLayout->addWidget(scrollArea);
|
|
// mainLayout->addWidget(curvesGroup);
|
|
// }
|
|
|
|
// } else if (auto lightChart = std::dynamic_pointer_cast<LightChartData>(chartData_)) {
|
|
// QLabel* colorLabel = new QLabel(QString("Open Color: %1, Close Color: %2")
|
|
// .arg(lightChart->openColor).arg(lightChart->closeColor));
|
|
// QLabel* timeLabel = new QLabel(QString("Time: %1").arg(lightChart->t));
|
|
|
|
// chartInfoLayout->addWidget(colorLabel);
|
|
// chartInfoLayout->addWidget(timeLabel);
|
|
|
|
// // Light curves section
|
|
// if (!lightChart->curves.isEmpty()) {
|
|
// QGroupBox* curvesGroup = new QGroupBox(QString("Light Data (%1)").arg(lightChart->curves.size()));
|
|
// QVBoxLayout* curvesLayout = new QVBoxLayout(curvesGroup);
|
|
|
|
// QScrollArea* scrollArea = new QScrollArea();
|
|
// QWidget* scrollWidget = new QWidget();
|
|
// QVBoxLayout* scrollLayout = new QVBoxLayout(scrollWidget);
|
|
|
|
// for (const LightCurveData& curve : lightChart->curves) {
|
|
// QHBoxLayout* curveLayout = new QHBoxLayout();
|
|
|
|
// QCheckBox* curveCheckBox = new QCheckBox(curve.name);
|
|
// curveCheckBox->setChecked(true);
|
|
|
|
// QLabel* curveInfo = new QLabel(QString("Data: %1").arg(curve.data));
|
|
|
|
// curveLayout->addWidget(curveCheckBox);
|
|
// curveLayout->addWidget(curveInfo);
|
|
// curveLayout->addStretch();
|
|
|
|
// scrollLayout->addLayout(curveLayout);
|
|
// }
|
|
|
|
// scrollWidget->setLayout(scrollLayout);
|
|
// scrollArea->setWidget(scrollWidget);
|
|
// scrollArea->setWidgetResizable(true);
|
|
// scrollArea->setMaximumHeight(200);
|
|
|
|
// curvesLayout->addWidget(scrollArea);
|
|
// mainLayout->addWidget(curvesGroup);
|
|
// }
|
|
// }
|
|
|
|
mainLayout->addWidget(chartInfoGroup);
|
|
|
|
// Placeholder for actual curve rendering
|
|
QLabel* renderLabel = new QLabel("Curve Rendering Area\n(To be implemented by rendering team)");
|
|
renderLabel->setAlignment(Qt::AlignCenter);
|
|
renderLabel->setStyleSheet("QLabel { color: #666; font-size: 12px; padding: 20px; border: 1px dashed #ccc; }");
|
|
renderLabel->setMinimumHeight(200);
|
|
|
|
mainLayout->addWidget(renderLabel);
|
|
mainLayout->addStretch();
|
|
|
|
setLayout(mainLayout);
|
|
}
|
|
|
|
void CurvePanel::InitUI()
|
|
{
|
|
initQChartView();
|
|
|
|
}
|
|
|
|
QString CurvePanel::GetTypeDisplayName() const
|
|
{
|
|
return "Curve";
|
|
}
|
|
|
|
void CurvePanel::initQChartView() {
|
|
curveChartView = new FitCurveChartView(this);
|
|
//curveChartView->setMaximumWidth(1730);
|
|
//curveChartView->setMinimumHeight(480);
|
|
|
|
curveChart = new QChart();
|
|
curveChart->setTheme(QChart::ChartThemeBlueIcy);
|
|
curveChart->setBackgroundRoundness(0);
|
|
curveChartView->setChart(curveChart);
|
|
|
|
m_pAxisX = new QValueAxis;
|
|
m_pAxisX->setRange(0, 10);
|
|
m_pAxisX->setLabelsAngle(-90);
|
|
curveChart->addAxis(m_pAxisX, Qt::AlignBottom);
|
|
|
|
m_pAxisY = new QValueAxis;
|
|
m_pAxisY->setRange(0, 10);
|
|
curveChart->addAxis(m_pAxisY, Qt::AlignLeft);
|
|
|
|
curveChartView->setRenderHint(QPainter::Antialiasing);
|
|
|
|
QHBoxLayout* pLayout = new QHBoxLayout(this);
|
|
pLayout->addWidget(curveChartView);
|
|
}
|
|
|
|
void CurvePanel::OnDataPanelUpdated(FileEntryCurve* fileEntry) {
|
|
int a = 0;
|
|
}
|