modified chart

This commit is contained in:
pimin 2025-10-22 09:32:34 +08:00
parent 2240f02a62
commit e69d916779
7 changed files with 115 additions and 24 deletions

View File

@ -220,7 +220,7 @@ void MainWindow::InitUI() {
// Restore previous UI layout if available
UiLayoutManager::Restore(this, 1);
InitChartLayout();
//InitChartLayout();
//ui->viewWidget->layout()->addWidget(qtOsgViewWidget_);
qtOsgViewWidget_->LoadDefaultScene();

View File

@ -10,10 +10,17 @@
#include <QCheckBox>
#include <QHBoxLayout>
#include "ui_FitCurve.h"
CurvePanel::CurvePanel(int index, const QString& filePath, QWidget* parent)
: DataPanel(index, FileEntryType::Curve, filePath, parent)
, hasChartData_(false)
{
m_iXMin = 0;
m_iXMax = 0;
m_iYMax = 0;
m_iYMin = 0;
LOG_INFO("Created CurvePanel {} for file: {}", index, filePath.toStdString());
}
@ -294,25 +301,51 @@ void CurvePanel::UpdateCurveDisplay()
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);
}
initQChartView();
//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";
}
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);
}

View File

@ -3,7 +3,11 @@
#include "DataPanel.h"
#include "workspace/ChartData.h"
#include <memory>
#include "ui/chartPlot/FitCurveChartView.h"
namespace Ui {
class FitCurve;
}
/**
* @file CurvePanel.h
* @brief Curve Panel Class
@ -67,7 +71,7 @@ protected:
/**
* @brief Initialize UI for curve-specific layout
*/
void InitUI() override;
virtual void InitUI();
/**
* @brief Get type display name
@ -75,6 +79,8 @@ protected:
*/
QString GetTypeDisplayName() const override;
void initQChartView();
private:
/**
* @brief Update curve display based on chart data
@ -84,4 +90,23 @@ private:
private:
std::shared_ptr<BaseChartData> chartData_; // Chart data containing curve information
bool hasChartData_; // Flag indicating if chart data is available
Ui::FitCurve* ui;
FitCurveChartView* curveChartView;
QChart* curveChart;
bool isPressed = false;
QPoint pressedPoint;
QValueAxis* m_pAxisX = NULL;
QValueAxis* m_pAxisY = NULL;
float m_iXMax;
float m_iXMin;
float m_iYMax;
float m_iYMin;
QMap<int, QSplineSeries*> m_seriesIDMap;
QMap< double, QMap<int, QVariantList> > m_dataWava;
QMap< double, QMap<int, QPointF> > m_dataReport;
};

View File

@ -16,7 +16,7 @@ DataPanel::DataPanel(int index, FileEntryType fileType, const QString& filePath,
, dockWidget_(nullptr)
{
title_ = GenerateTitle();
InitUI();
//InitUI();
LOG_INFO("Created DataPanel {} for {} file: {}", index_, FileEntryTypeToString(fileType_), filePath_.toStdString());
}

View File

@ -74,7 +74,10 @@ public:
* @brief Refresh panel content (virtual function, implemented by derived classes)
*/
virtual void RefreshPanel() {}
/**
* @brief Initialize UI (virtual function, derived classes implement specific layout)
*/
virtual void InitUI();
signals:
/**
* @brief Panel close signal
@ -88,10 +91,7 @@ protected:
*/
void closeEvent(QCloseEvent* event) override;
/**
* @brief Initialize UI (virtual function, derived classes implement specific layout)
*/
virtual void InitUI();
/**
* @brief Generate panel title

View File

@ -193,6 +193,8 @@ DataPanel* DataPanelManager::CreateDataPanel(FileEntryType fileType, const QStri
return nullptr;
}
panel->InitUI();
dockWidget->setWidget(panel);
// Set panel's dock widget reference

31
src/ui/Panel/FitCurve.ui Normal file
View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FitCurve</class>
<widget class="QDialog" name="FitCurve">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>977</width>
<height>703</height>
</rect>
</property>
<property name="windowTitle">
<string>FitCurveDialog</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>70</x>
<y>40</y>
<width>851</width>
<height>621</height>
</rect>
</property>
<layout class="QHBoxLayout" name="chartLayout"/>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>