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 // Restore previous UI layout if available
UiLayoutManager::Restore(this, 1); UiLayoutManager::Restore(this, 1);
InitChartLayout(); //InitChartLayout();
//ui->viewWidget->layout()->addWidget(qtOsgViewWidget_); //ui->viewWidget->layout()->addWidget(qtOsgViewWidget_);
qtOsgViewWidget_->LoadDefaultScene(); qtOsgViewWidget_->LoadDefaultScene();

View File

@ -10,10 +10,17 @@
#include <QCheckBox> #include <QCheckBox>
#include <QHBoxLayout> #include <QHBoxLayout>
#include "ui_FitCurve.h"
CurvePanel::CurvePanel(int index, const QString& filePath, QWidget* parent) CurvePanel::CurvePanel(int index, const QString& filePath, QWidget* parent)
: DataPanel(index, FileEntryType::Curve, filePath, parent) : DataPanel(index, FileEntryType::Curve, filePath, parent)
, hasChartData_(false) , hasChartData_(false)
{ {
m_iXMin = 0;
m_iXMax = 0;
m_iYMax = 0;
m_iYMin = 0;
LOG_INFO("Created CurvePanel {} for file: {}", index, filePath.toStdString()); LOG_INFO("Created CurvePanel {} for file: {}", index, filePath.toStdString());
} }
@ -294,25 +301,51 @@ void CurvePanel::UpdateCurveDisplay()
void CurvePanel::InitUI() void CurvePanel::InitUI()
{ {
if (hasChartData_) { initQChartView();
UpdateCurveDisplay(); //if (hasChartData_) {
} else { // UpdateCurveDisplay();
// Create basic layout for file-based panel //} else {
QVBoxLayout* layout = new QVBoxLayout(this); // // 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") // // Add placeholder label showing panel information
.arg(GetIndex()) // QLabel* infoLabel = new QLabel(QString("Curve Panel %1\nFile: %2\n\nCurve Drawing Area\nPlease inherit this class to implement specific drawing functionality")
.arg(QFileInfo(GetFilePath()).fileName())); // .arg(GetIndex())
infoLabel->setAlignment(Qt::AlignCenter); // .arg(QFileInfo(GetFilePath()).fileName()));
infoLabel->setStyleSheet("QLabel { color: #666; font-size: 12px; padding: 20px; }"); // infoLabel->setAlignment(Qt::AlignCenter);
// infoLabel->setStyleSheet("QLabel { color: #666; font-size: 12px; padding: 20px; }");
layout->addWidget(infoLabel); //
setLayout(layout); // layout->addWidget(infoLabel);
} // setLayout(layout);
//}
} }
QString CurvePanel::GetTypeDisplayName() const QString CurvePanel::GetTypeDisplayName() const
{ {
return "Curve"; 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 "DataPanel.h"
#include "workspace/ChartData.h" #include "workspace/ChartData.h"
#include <memory> #include <memory>
#include "ui/chartPlot/FitCurveChartView.h"
namespace Ui {
class FitCurve;
}
/** /**
* @file CurvePanel.h * @file CurvePanel.h
* @brief Curve Panel Class * @brief Curve Panel Class
@ -67,7 +71,7 @@ protected:
/** /**
* @brief Initialize UI for curve-specific layout * @brief Initialize UI for curve-specific layout
*/ */
void InitUI() override; virtual void InitUI();
/** /**
* @brief Get type display name * @brief Get type display name
@ -75,6 +79,8 @@ protected:
*/ */
QString GetTypeDisplayName() const override; QString GetTypeDisplayName() const override;
void initQChartView();
private: private:
/** /**
* @brief Update curve display based on chart data * @brief Update curve display based on chart data
@ -84,4 +90,23 @@ private:
private: private:
std::shared_ptr<BaseChartData> chartData_; // Chart data containing curve information std::shared_ptr<BaseChartData> chartData_; // Chart data containing curve information
bool hasChartData_; // Flag indicating if chart data is available 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) , 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());
} }

View File

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

View File

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