318 lines
13 KiB
C++
318 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>
|
|
|
|
CurvePanel::CurvePanel(int index, const QString& filePath, QWidget* parent)
|
|
: DataPanel(index, FileEntryType::Curve, filePath, parent)
|
|
, hasChartData_(false)
|
|
{
|
|
LOG_INFO("Created CurvePanel {} for file: {}", index, filePath.toStdString());
|
|
}
|
|
|
|
CurvePanel::CurvePanel(int index, std::shared_ptr<BaseChartData> chartData, QWidget* parent)
|
|
: DataPanel(index, FileEntryType::Curve, chartData ? chartData->path : QString(), parent)
|
|
, chartData_(chartData)
|
|
, hasChartData_(chartData != nullptr)
|
|
{
|
|
if (chartData) {
|
|
LOG_INFO("Created CurvePanel {} for chart: {}", index, chartData->name.toStdString());
|
|
// Override the title with chart name
|
|
title_ = QString("Curve Panel %1 - %2").arg(index).arg(chartData->name);
|
|
} 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 (hasChartData_) {
|
|
UpdateCurveDisplay();
|
|
}
|
|
|
|
LOG_INFO("Refreshed CurvePanel {}", GetIndex());
|
|
}
|
|
|
|
void CurvePanel::SetChartData(std::shared_ptr<BaseChartData> chartData)
|
|
{
|
|
chartData_ = chartData;
|
|
hasChartData_ = (chartData != nullptr);
|
|
|
|
if (chartData) {
|
|
// Update title
|
|
title_ = QString("Curve Panel %1 - %2").arg(GetIndex()).arg(chartData->name);
|
|
|
|
// Refresh the display
|
|
UpdateCurveDisplay();
|
|
|
|
LOG_INFO("Set chart data for CurvePanel {}: {}", GetIndex(), chartData->name.toStdString());
|
|
} else {
|
|
LOG_WARN("Set null chart data for CurvePanel {}", GetIndex());
|
|
}
|
|
}
|
|
|
|
void CurvePanel::UpdateCurveDisplay()
|
|
{
|
|
if (!hasChartData_ || !chartData_) {
|
|
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(chartData_->name));
|
|
QVBoxLayout* chartInfoLayout = new QVBoxLayout(chartInfoGroup);
|
|
|
|
// Chart details - handle different chart types
|
|
QLabel* pathLabel = new QLabel(QString("File: %1").arg(QFileInfo(chartData_->path).fileName()));
|
|
chartInfoLayout->addWidget(pathLabel);
|
|
|
|
// Type-specific information
|
|
if (auto curveChart = std::dynamic_pointer_cast<CurveChartData>(chartData_)) {
|
|
QLabel* titleLabel = new QLabel(QString("Title: X=%1, Y=%2").arg(curveChart->xTitle, curveChart->yTitle));
|
|
QLabel* rangeLabel = new QLabel(QString("Range: X[%1-%2], Y[%3-%4]")
|
|
.arg(curveChart->xMin).arg(curveChart->xMax)
|
|
.arg(curveChart->yMin).arg(curveChart->yMax));
|
|
QLabel* countLabel = new QLabel(QString("Count: X=%1, T=%2").arg(curveChart->xCount).arg(curveChart->t));
|
|
|
|
chartInfoLayout->addWidget(titleLabel);
|
|
chartInfoLayout->addWidget(rangeLabel);
|
|
chartInfoLayout->addWidget(countLabel);
|
|
|
|
// Curves section
|
|
if (!curveChart->curves.isEmpty()) {
|
|
QGroupBox* curvesGroup = new QGroupBox(QString("Curves (%1)").arg(curveChart->curves.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 CurveData& curve : curveChart->curves) {
|
|
QHBoxLayout* curveLayout = new QHBoxLayout();
|
|
|
|
// Curve checkbox for show/hide
|
|
QCheckBox* curveCheckBox = new QCheckBox(curve.name);
|
|
curveCheckBox->setChecked(true);
|
|
|
|
// Curve info
|
|
QLabel* curveInfo = new QLabel(QString("Range: %1-%2, Color: %3")
|
|
.arg(curve.start).arg(curve.stop).arg(curve.color));
|
|
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 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.start).arg(curve.stop).arg(curve.color)
|
|
.arg(curve.x).arg(curve.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()
|
|
{
|
|
if (hasChartData_) {
|
|
UpdateCurveDisplay();
|
|
} else {
|
|
// Create basic layout for file-based panel
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
|
|
|
// Add placeholder label showing panel information
|
|
QLabel* infoLabel = new QLabel(QString("Curve Panel %1\nFile: %2\n\nCurve Drawing Area\nPlease inherit this class to implement specific drawing functionality")
|
|
.arg(GetIndex())
|
|
.arg(QFileInfo(GetFilePath()).fileName()));
|
|
infoLabel->setAlignment(Qt::AlignCenter);
|
|
infoLabel->setStyleSheet("QLabel { color: #666; font-size: 12px; padding: 20px; }");
|
|
|
|
layout->addWidget(infoLabel);
|
|
setLayout(layout);
|
|
}
|
|
}
|
|
|
|
QString CurvePanel::GetTypeDisplayName() const
|
|
{
|
|
return "Curve";
|
|
} |