2025-07-06 15:33:27 +00:00
|
|
|
|
#include "fitcurvedialog.h"
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
|
|
|
|
|
#include <QLogValueAxis>
|
|
|
|
|
|
|
|
|
|
|
|
#include "../DockTitleBar.h"
|
|
|
|
|
|
#include "../DockWidget.h"
|
|
|
|
|
|
|
2025-01-05 11:12:18 +00:00
|
|
|
|
#include "common/SpdLogger.h"
|
|
|
|
|
|
#include "workspace/WorkSpace.h"
|
|
|
|
|
|
#include "workspace/Timestep.h"
|
|
|
|
|
|
#include "workspace/WorkSpaceManager.h"
|
|
|
|
|
|
|
2025-01-04 04:12:51 +00:00
|
|
|
|
FitCurveDialog::FitCurveDialog(int iType, QWidget* parent) :
|
|
|
|
|
|
QDialog(parent),
|
|
|
|
|
|
ui(new Ui::FitCurveDialog)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iType = iType;
|
|
|
|
|
|
|
|
|
|
|
|
if (1 == m_iType)
|
|
|
|
|
|
{
|
|
|
|
|
|
setWindowTitle("2D Curve");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
setWindowTitle("2D(y(lg)) Curve");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
initQChartView();
|
2025-01-05 11:12:18 +00:00
|
|
|
|
|
|
|
|
|
|
connect(&WorkSpaceManager::Get(), &WorkSpaceManager::WorkSpaceChanged, this, &FitCurveDialog::OnWorkSpaceChanged);
|
2025-01-04 04:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::initQChartView() {
|
2025-07-06 15:33:27 +00:00
|
|
|
|
//创建图表框架
|
2025-01-04 04:12:51 +00:00
|
|
|
|
curveChartView = new FitCurveChartView(this);
|
|
|
|
|
|
curveChartView->setMaximumWidth(1730);
|
|
|
|
|
|
curveChartView->setMinimumHeight(480);
|
|
|
|
|
|
|
|
|
|
|
|
curveChart = new QChart();
|
|
|
|
|
|
curveChart->setTheme(QChart::ChartThemeBlueIcy);
|
2025-07-06 15:33:27 +00:00
|
|
|
|
//curveChart->setContentsMargins(0, 0, 0, 0); //设置外边界全部为0, 根据自己实际情况设置
|
|
|
|
|
|
//curveChart->setMargins(QMargins(5, -30, 5, 10)); //设置内边界, 根据自己实际情况设置
|
|
|
|
|
|
curveChart->setBackgroundRoundness(0); //设置表格边框圆角半径
|
2025-01-04 04:12:51 +00:00
|
|
|
|
curveChartView->setChart(curveChart);
|
|
|
|
|
|
|
|
|
|
|
|
//QObject::connect(fitPointsSeriesS, &QSplineSeries::clicked, [=](const QPointF& point)mutable {
|
|
|
|
|
|
// QPointF tempPoint;
|
2025-07-06 15:33:27 +00:00
|
|
|
|
// QVector<QPointF> tempList(fitPointsSeriesS->pointsVector()); //复制曲线中的数据进行计算, 因为直接使用会导致卡顿
|
2025-01-04 04:12:51 +00:00
|
|
|
|
// int tempX = qRound(point.x());
|
|
|
|
|
|
// int tempY = -999;
|
|
|
|
|
|
// for (int i = 0; i < tempList.size(); i++) {
|
|
|
|
|
|
// if (tempList[i].x() == tempX) {
|
|
|
|
|
|
// tempY = tempList[i].y();
|
|
|
|
|
|
// tempPoint.setX(tempX);
|
|
|
|
|
|
// tempPoint.setY(tempY);
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (tempY != -999) {
|
|
|
|
|
|
// QToolTip::showText(QCursor::pos(), QString("(%1,%2)").arg(tempX).arg(tempY));
|
|
|
|
|
|
// QVector<QPointF> tipList;
|
|
|
|
|
|
// tipList.append(tempPoint);
|
|
|
|
|
|
// tipSeries->replace(tipList);
|
|
|
|
|
|
// updateXYGuideLine();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
//创建坐标轴
|
2025-01-04 04:12:51 +00:00
|
|
|
|
m_pAxisX = new QValueAxis;
|
|
|
|
|
|
m_pAxisX->setRange(0, 10);
|
|
|
|
|
|
m_pAxisX->setTickCount(21);
|
|
|
|
|
|
m_pAxisX->setLabelFormat("%d");
|
2025-07-06 15:33:27 +00:00
|
|
|
|
m_pAxisX->setLabelsAngle(-90); //坐标刻度文字显示角度
|
2025-01-04 04:12:51 +00:00
|
|
|
|
curveChart->addAxis(m_pAxisX, Qt::AlignBottom);
|
|
|
|
|
|
|
|
|
|
|
|
//xGuideSeries->attachAxis(m_pAxisX);
|
|
|
|
|
|
//yGuideSeries->attachAxis(m_pAxisX);
|
|
|
|
|
|
// fitPointsSeriesS->attachAxis(m_pAxisX);
|
|
|
|
|
|
// tipSeries->attachAxis(m_pAxisX);
|
|
|
|
|
|
|
|
|
|
|
|
if (1 == m_iType)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pAxisY = new QValueAxis;
|
|
|
|
|
|
m_pAxisY->setRange(0, 10);
|
|
|
|
|
|
m_pAxisY->setTickCount(11);
|
|
|
|
|
|
m_pAxisY->setLabelFormat("%d");
|
|
|
|
|
|
curveChart->addAxis(m_pAxisY, Qt::AlignLeft);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pLgAxisY = new QLogValueAxis();
|
|
|
|
|
|
m_pLgAxisY->setLabelFormat("%e");
|
|
|
|
|
|
m_pLgAxisY->setMinorTickCount(9);
|
|
|
|
|
|
//axisY->setMinorTickLineVisible(true);
|
|
|
|
|
|
m_pLgAxisY->setLabelsAngle(90);
|
|
|
|
|
|
m_pLgAxisY->setRange(1, 100);
|
|
|
|
|
|
|
|
|
|
|
|
curveChart->addAxis(m_pLgAxisY, Qt::AlignLeft);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
// axisX->setGridLineVisible(false); //隐藏背景网格X轴框线
|
|
|
|
|
|
// axisY->setGridLineVisible(false); //隐藏背景网格Y轴框线
|
2025-01-04 04:12:51 +00:00
|
|
|
|
/*curveChart->legend()->markers()[0]->setVisible(false);
|
|
|
|
|
|
curveChart->legend()->markers()[1]->setVisible(false);
|
|
|
|
|
|
curveChart->legend()->markers()[2]->setVisible(false);
|
|
|
|
|
|
curveChart->legend()->markers()[3]->setVisible(false);*/
|
2025-07-06 15:33:27 +00:00
|
|
|
|
curveChartView->setRenderHint(QPainter::Antialiasing); //除锯齿
|
2025-01-04 04:12:51 +00:00
|
|
|
|
connect(curveChartView, &FitCurveChartView::signalMouseEvent, this, &FitCurveDialog::theSlotMouseEvent);
|
|
|
|
|
|
connect(curveChartView, &FitCurveChartView::signalWheelEvent, this, &FitCurveDialog::theSlotWheelEvent);
|
|
|
|
|
|
|
|
|
|
|
|
//curveChartView->show();
|
|
|
|
|
|
|
|
|
|
|
|
QHBoxLayout* pLayout = new QHBoxLayout(this);
|
|
|
|
|
|
pLayout->addWidget(curveChartView);
|
|
|
|
|
|
|
|
|
|
|
|
// ui->chartLayout->addWidget(curveChartView);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::theSlotMouseEvent(int eventId, QMouseEvent* event) {
|
2025-07-06 15:33:27 +00:00
|
|
|
|
if (eventId == 0) { //单击按下
|
2025-01-04 04:12:51 +00:00
|
|
|
|
isPressed = true;
|
|
|
|
|
|
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
|
|
|
|
|
|
pressedPoint = mouseEvent->pos();
|
|
|
|
|
|
}
|
2025-07-06 15:33:27 +00:00
|
|
|
|
else if (eventId == 1) { //鼠标移动
|
2025-01-04 04:12:51 +00:00
|
|
|
|
if (isPressed) {
|
|
|
|
|
|
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
|
|
|
|
|
|
curveChart->scroll(-(mouseEvent->pos().x() - pressedPoint.x()) / 10,
|
|
|
|
|
|
(mouseEvent->pos().y() - pressedPoint.y()) / 10);
|
|
|
|
|
|
updateXYGuideLine();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-07-06 15:33:27 +00:00
|
|
|
|
else if (eventId == 2) { //单击抬起
|
2025-01-04 04:12:51 +00:00
|
|
|
|
isPressed = false;
|
|
|
|
|
|
}
|
2025-07-06 15:33:27 +00:00
|
|
|
|
else if (eventId == 3) { //双击
|
2025-01-04 04:12:51 +00:00
|
|
|
|
resetZoomAndScroll();
|
|
|
|
|
|
updateXYGuideLine();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::theSlotWheelEvent(QWheelEvent* event) {
|
|
|
|
|
|
int delta = event->angleDelta().y();
|
|
|
|
|
|
if (delta > 0) {
|
|
|
|
|
|
curveChart->zoom(0.95);
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
curveChart->zoom(1.05);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateXYGuideLine();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::slotAddSeries(QVariant varSeriesData)
|
|
|
|
|
|
{
|
2025-07-06 15:33:27 +00:00
|
|
|
|
// 数据无效
|
2025-01-04 04:12:51 +00:00
|
|
|
|
if (!varSeriesData.isValid())
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
QString strName = varSeriesData.toMap().value("Name").toString(); // 曲线名称
|
|
|
|
|
|
QVariantList varCurDataList = varSeriesData.toMap().value("Data").toList(); // 数据
|
|
|
|
|
|
int iYType = varSeriesData.toMap().value("yType").toInt(); // y轴类型
|
|
|
|
|
|
QColor color = varSeriesData.toMap().value("Color").value<QColor>(); // 曲线颜色
|
|
|
|
|
|
QString strXName = varSeriesData.toMap().value("xTitle").toString(); // x轴名称
|
|
|
|
|
|
QString strYName = varSeriesData.toMap().value("yTitle").toString(); // y轴名称
|
|
|
|
|
|
QString strZName = varSeriesData.toMap().value("zTitle").toString(); // z轴名称
|
|
|
|
|
|
int iCurveType = varSeriesData.toMap().value("curveType").toInt(); // 曲线类型
|
|
|
|
|
|
int iID = varSeriesData.toMap().value("ID").toInt(); // y轴类型
|
|
|
|
|
|
bool bAdd = varSeriesData.toMap().value("Add").toBool(); // 曲线名称
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
if (iCurveType == 3) // 非二维曲线
|
2025-01-04 04:12:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool bNew = false;
|
|
|
|
|
|
QSplineSeries* pSeries = NULL;
|
|
|
|
|
|
if (m_seriesIDMap.contains(iID))
|
|
|
|
|
|
{
|
|
|
|
|
|
pSeries = m_seriesIDMap.value(iID);
|
2025-07-06 15:33:27 +00:00
|
|
|
|
pSeries->setName(strName); // 设置曲线名称
|
|
|
|
|
|
pSeries->setColor(color); // 设置曲线颜色
|
2025-01-04 04:12:51 +00:00
|
|
|
|
pSeries->setUseOpenGL(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!bAdd)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pSeries = new QSplineSeries(this);
|
2025-07-06 15:33:27 +00:00
|
|
|
|
pSeries->setName(strName); // 设置曲线名称
|
|
|
|
|
|
pSeries->setColor(color); // 设置曲线颜色
|
2025-01-04 04:12:51 +00:00
|
|
|
|
pSeries->setUseOpenGL(true);
|
|
|
|
|
|
|
|
|
|
|
|
bNew = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
m_pAxisX->setTitleText(strXName); // 设置x轴名称
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
// xy轴的范围
|
|
|
|
|
|
m_iXMax = m_pAxisX->max(); // 当前x轴的最大值
|
|
|
|
|
|
m_iXMin = m_pAxisX->min(); // 当前x轴的最小值
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
if (0 == iYType) // 一般曲线
|
2025-01-04 04:12:51 +00:00
|
|
|
|
{
|
2025-07-06 15:33:27 +00:00
|
|
|
|
m_iYMax = m_pAxisY->max(); // 当前y轴的最大值
|
|
|
|
|
|
m_iYMin = m_pAxisY->min(); // 当前y轴的最大值
|
2025-01-04 04:12:51 +00:00
|
|
|
|
}
|
2025-07-06 15:33:27 +00:00
|
|
|
|
else // 对数曲线
|
2025-01-04 04:12:51 +00:00
|
|
|
|
{
|
2025-07-06 15:33:27 +00:00
|
|
|
|
m_iYMax = m_pLgAxisY->max(); // 当前y轴的最大值
|
|
|
|
|
|
m_iYMin = m_pLgAxisY->min(); // 当前y轴的最大值
|
2025-01-04 04:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
// 曲线数据
|
2025-01-04 04:12:51 +00:00
|
|
|
|
QVector<QPointF> listKey;
|
|
|
|
|
|
for (size_t i = 0; i < varCurDataList.size(); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
QPointF ptKey = varCurDataList[i].toPointF();
|
|
|
|
|
|
listKey.push_back(ptKey);
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
// 更新x轴最大值最小值
|
2025-01-04 04:12:51 +00:00
|
|
|
|
if (m_iXMin > ptKey.x())
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iXMin = ptKey.x();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_iXMax < ptKey.x())
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iXMax = ptKey.x();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_iYMin > ptKey.y())
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iYMin = ptKey.y();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_iYMax < ptKey.y())
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iYMax = ptKey.y();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
// 更新x轴范围
|
2025-01-04 04:12:51 +00:00
|
|
|
|
m_pAxisX->setRange(m_iXMin, m_iXMax);
|
|
|
|
|
|
pSeries->replace(listKey);
|
|
|
|
|
|
|
|
|
|
|
|
if (bNew)
|
|
|
|
|
|
{
|
|
|
|
|
|
curveChart->addSeries(pSeries);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
// 更新y轴范围
|
2025-01-04 04:12:51 +00:00
|
|
|
|
if (iYType == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pAxisY->setRange(m_iYMin, m_iYMax);
|
|
|
|
|
|
|
|
|
|
|
|
if (bNew)
|
|
|
|
|
|
{
|
|
|
|
|
|
pSeries->attachAxis(m_pAxisY);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_pAxisY->setTitleText(strYName);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pLgAxisY->setRange(m_iYMin, m_iYMax);
|
|
|
|
|
|
|
|
|
|
|
|
if (bNew)
|
|
|
|
|
|
{
|
|
|
|
|
|
pSeries->attachAxis(m_pLgAxisY);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_pLgAxisY->setTitleText(strYName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (bNew)
|
|
|
|
|
|
{
|
|
|
|
|
|
pSeries->attachAxis(m_pAxisX);
|
|
|
|
|
|
m_seriesIDMap.insert(iID, pSeries);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//QObject::connect(fitPointsSeriesS, &QSplineSeries::clicked, [=](const QPointF& point)mutable {
|
|
|
|
|
|
// QPointF tempPoint;
|
2025-07-06 15:33:27 +00:00
|
|
|
|
// QVector<QPointF> tempList(fitPointsSeriesS->pointsVector()); //复制曲线中的数据进行计算, 因为直接使用会导致卡顿
|
2025-01-04 04:12:51 +00:00
|
|
|
|
// int tempX = qRound(point.x());
|
|
|
|
|
|
// int tempY = -999;
|
|
|
|
|
|
// for (int i = 0; i < tempList.size(); i++) {
|
|
|
|
|
|
// if (tempList[i].x() == tempX) {
|
|
|
|
|
|
// tempY = tempList[i].y();
|
|
|
|
|
|
// tempPoint.setX(tempX);
|
|
|
|
|
|
// tempPoint.setY(tempY);
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (tempY != -999) {
|
|
|
|
|
|
// QToolTip::showText(QCursor::pos(), QString("(%1,%2)").arg(tempX).arg(tempY));
|
|
|
|
|
|
// QVector<QPointF> tipList;
|
|
|
|
|
|
// tipList.append(tempPoint);
|
|
|
|
|
|
// tipSeries->replace(tipList);
|
|
|
|
|
|
// updateXYGuideLine();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::slotDelCurve(int iID)
|
|
|
|
|
|
{
|
|
|
|
|
|
QSplineSeries* pSeries = NULL;
|
|
|
|
|
|
if (m_seriesIDMap.contains(iID))
|
|
|
|
|
|
{
|
|
|
|
|
|
pSeries = m_seriesIDMap.value(iID);
|
|
|
|
|
|
curveChart->removeSeries(pSeries);
|
|
|
|
|
|
|
|
|
|
|
|
m_seriesIDMap.remove(iID);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::slotInserKeyPoint(int iID, float xValue, float yValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
QSplineSeries* pSeries = NULL;
|
|
|
|
|
|
if (m_seriesIDMap.contains(iID))
|
|
|
|
|
|
{
|
|
|
|
|
|
pSeries = m_seriesIDMap.value(iID);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (pSeries)
|
|
|
|
|
|
{
|
|
|
|
|
|
QVector<QPointF> vecKeyPoints = pSeries->pointsVector();
|
|
|
|
|
|
vecKeyPoints.push_back(QPointF(xValue, yValue));
|
|
|
|
|
|
|
|
|
|
|
|
if (m_iXMax < xValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iXMax = xValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_iXMin > xValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iXMin = xValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_iYMax < yValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iYMax = yValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_iYMin > yValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iYMin = yValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (1 == m_iType)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pAxisY->setRange(m_iXMin, m_iXMax);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pLgAxisY->setRange(m_iYMin, m_iYMax);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pSeries->replace(vecKeyPoints);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::slotUpdateTime(double dTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_vecWavePoint.size() > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dTime < 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
QMap<int, QSplineSeries*>::iterator pItor = m_seriesIDMap.begin();
|
|
|
|
|
|
while (pItor != m_seriesIDMap.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
pItor.value()->clear();
|
|
|
|
|
|
pItor++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((dTime - 1) >= m_vecWavePoint.size())
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::vector<float>> batch = m_vecWavePoint[dTime - 1];
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
m_pAxisX->setTitleText("x"); // 设置x轴名称
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
// xy轴的范围
|
|
|
|
|
|
m_iXMax = m_pAxisX->max(); // 当前x轴的最大值
|
|
|
|
|
|
m_iXMin = m_pAxisX->min(); // 当前x轴的最小值
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
m_iYMax = m_pAxisY->max(); // 当前y轴的最大值
|
|
|
|
|
|
m_iYMin = m_pAxisY->min(); // 当前y轴的最大值
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_iXMin = 0;
|
|
|
|
|
|
m_iYMin = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < batch.size(); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool bNew = false;
|
|
|
|
|
|
QSplineSeries* pSeries = nullptr;
|
|
|
|
|
|
if (m_seriesIDMap.contains(i+1))
|
|
|
|
|
|
{
|
|
|
|
|
|
pSeries = m_seriesIDMap.value(i + 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
pSeries = new QSplineSeries(this);
|
|
|
|
|
|
m_seriesIDMap.insert(i + 1, pSeries);
|
|
|
|
|
|
bNew = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
QString strName = QString::fromLocal8Bit("目标") + QString::number(i+1);
|
|
|
|
|
|
pSeries->setName(strName); // 设置曲线名称
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
|
|
|
|
|
if (bNew)
|
|
|
|
|
|
{
|
2025-07-06 15:33:27 +00:00
|
|
|
|
qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); // 初始化随机数生成器
|
2025-01-04 04:12:51 +00:00
|
|
|
|
QColor color(QRandomGenerator::global()->bounded(255), QRandomGenerator::global()->bounded(255), QRandomGenerator::global()->bounded(255));
|
2025-07-06 15:33:27 +00:00
|
|
|
|
pSeries->setColor(color); // 设置曲线颜色
|
2025-01-04 04:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pSeries->setUseOpenGL(true);
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<float> vecData = batch[i];
|
|
|
|
|
|
if (m_iXMax < vecData.size())
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iXMax = vecData.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QList<QPointF> listKey;
|
|
|
|
|
|
for (int j = 0; j < vecData.size(); j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
float fY = vecData[j];
|
|
|
|
|
|
|
|
|
|
|
|
listKey.push_back(QPointF(j+1, fY));
|
|
|
|
|
|
|
|
|
|
|
|
if (m_iYMax < fY)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iYMax = fY;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_iYMin > fY)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iYMin = fY;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_pAxisX->setRange(m_iXMin, m_iXMax);
|
|
|
|
|
|
pSeries->replace(listKey);
|
|
|
|
|
|
|
|
|
|
|
|
if (bNew)
|
|
|
|
|
|
{
|
|
|
|
|
|
curveChart->addSeries(pSeries);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_pAxisY->setRange(m_iYMin, m_iYMax);
|
|
|
|
|
|
|
|
|
|
|
|
if (bNew)
|
|
|
|
|
|
{
|
|
|
|
|
|
pSeries->attachAxis(m_pAxisY);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
m_pAxisY->setTitleText(QString::fromLocal8Bit("幅值"));
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
|
|
|
|
|
if (bNew)
|
|
|
|
|
|
{
|
|
|
|
|
|
pSeries->attachAxis(m_pAxisX);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_vecReportPoint.size() > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dTime < 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
QMap<int, QSplineSeries*>::iterator pItor = m_seriesIDMap.begin();
|
|
|
|
|
|
while (pItor != m_seriesIDMap.end())
|
|
|
|
|
|
{
|
|
|
|
|
|
pItor.value()->clear();
|
|
|
|
|
|
pItor++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((dTime - 1) >= m_vecReportPoint.size())
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::vector<float>> batch = m_vecReportPoint[dTime - 1];
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
m_pAxisX->setTitleText(QString::fromLocal8Bit("距离")); // 设置x轴名称
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
// xy轴的范围
|
|
|
|
|
|
m_iXMax = m_pAxisX->max(); // 当前x轴的最大值
|
|
|
|
|
|
m_iXMin = m_pAxisX->min(); // 当前x轴的最小值
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
m_iYMax = m_pAxisY->max(); // 当前y轴的最大值
|
|
|
|
|
|
m_iYMin = m_pAxisY->min(); // 当前y轴的最大值
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < batch.size(); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool bNew = false;
|
|
|
|
|
|
QSplineSeries* pSeries = nullptr;
|
|
|
|
|
|
if (m_seriesIDMap.contains(i + 1))
|
|
|
|
|
|
{
|
|
|
|
|
|
pSeries = m_seriesIDMap.value(i + 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
pSeries = new QSplineSeries(this);
|
|
|
|
|
|
m_seriesIDMap.insert(i + 1, pSeries);
|
|
|
|
|
|
bNew = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
QString strName = QString::fromLocal8Bit("目标") + QString::number(i + 1);
|
|
|
|
|
|
pSeries->setName(strName); // 设置曲线名称
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
|
|
|
|
|
if (bNew)
|
|
|
|
|
|
{
|
2025-07-06 15:33:27 +00:00
|
|
|
|
qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); // 初始化随机数生成器
|
2025-01-04 04:12:51 +00:00
|
|
|
|
QColor color(QRandomGenerator::global()->bounded(255), QRandomGenerator::global()->bounded(255), QRandomGenerator::global()->bounded(255));
|
2025-07-06 15:33:27 +00:00
|
|
|
|
pSeries->setColor(color); // 设置曲线颜色
|
2025-01-04 04:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pSeries->setUseOpenGL(true);
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<float> vecData = batch[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float fX = vecData[0];
|
|
|
|
|
|
float fY = vecData[1];
|
|
|
|
|
|
|
|
|
|
|
|
if (m_iYMax < fY)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iYMax = fY;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_iYMin > fY)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iYMin = fY;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_iXMax < fX)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iXMax = fX;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (m_iXMin > fX)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_iXMax = fX;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_pAxisX->setRange(m_iXMin, m_iXMax);
|
|
|
|
|
|
pSeries->append(QPointF(fX,fY));
|
|
|
|
|
|
|
|
|
|
|
|
if (bNew)
|
|
|
|
|
|
{
|
|
|
|
|
|
curveChart->addSeries(pSeries);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_pAxisY->setRange(m_iYMin, m_iYMax);
|
|
|
|
|
|
|
|
|
|
|
|
if (bNew)
|
|
|
|
|
|
{
|
|
|
|
|
|
pSeries->attachAxis(m_pAxisY);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-06 15:33:27 +00:00
|
|
|
|
m_pAxisY->setTitleText(QString::fromLocal8Bit("速度"));
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
|
|
|
|
|
if (bNew)
|
|
|
|
|
|
{
|
|
|
|
|
|
pSeries->attachAxis(m_pAxisX);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::updateXYGuideLine() {
|
|
|
|
|
|
/* if (tipSeries->points().size() > 0) {
|
|
|
|
|
|
QVector<int> axisRanges = getAxisRanges();
|
|
|
|
|
|
QVector<QPointF> xGuideList, yGuideList;
|
|
|
|
|
|
int tempX = tipSeries->points()[0].x();
|
|
|
|
|
|
int tempY = tipSeries->points()[0].y();
|
|
|
|
|
|
xGuideList.append(QPointF(tempX, axisRanges[2]));
|
|
|
|
|
|
xGuideList.append(QPointF(tempX, tempY));
|
|
|
|
|
|
yGuideList.append(QPointF(axisRanges[0], tempY));
|
|
|
|
|
|
yGuideList.append(QPointF(tempX, tempY));
|
|
|
|
|
|
xGuideSeries->replace(xGuideList);
|
|
|
|
|
|
yGuideSeries->replace(yGuideList);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
xGuideSeries->clear();
|
|
|
|
|
|
yGuideSeries->clear();
|
|
|
|
|
|
}*/
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::resetZoomAndScroll() {
|
|
|
|
|
|
curveChart->zoomReset();
|
|
|
|
|
|
QList<QAbstractAxis*> axesX, axesY;
|
|
|
|
|
|
axesX = curveChart->axes(Qt::Horizontal);
|
|
|
|
|
|
axesY = curveChart->axes(Qt::Vertical);
|
|
|
|
|
|
QValueAxis* curAxisX = (QValueAxis*)axesX[0];
|
|
|
|
|
|
QValueAxis* curAxisY = (QValueAxis*)axesY[0];
|
|
|
|
|
|
curAxisX->setRange(m_iXMin, m_iXMax);
|
|
|
|
|
|
curAxisY->setRange(m_iYMin, m_iYMax);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QVector<int> FitCurveDialog::getAxisRanges() {
|
|
|
|
|
|
QList<QAbstractAxis*> axesX, axesY;
|
|
|
|
|
|
axesX = curveChart->axes(Qt::Horizontal);
|
|
|
|
|
|
axesY = curveChart->axes(Qt::Vertical);
|
|
|
|
|
|
QValueAxis* curAxisX = (QValueAxis*)axesX[0];
|
|
|
|
|
|
QValueAxis* curAxisY = (QValueAxis*)axesY[0];
|
|
|
|
|
|
QVector<int> ranges = { int(curAxisX->min()), int(curAxisX->max()), int(curAxisY->min()), int(curAxisY->max()) };
|
|
|
|
|
|
return ranges;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::InitWaveFile(const QString& strFile, int iBatchCount)
|
|
|
|
|
|
{
|
2025-01-07 15:45:23 +00:00
|
|
|
|
if (strFile.isEmpty())
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2025-01-04 04:12:51 +00:00
|
|
|
|
m_vecWavePoint.clear();
|
2025-07-20 08:34:48 +00:00
|
|
|
|
bool bRet = ParseWave(strFile, m_vecWavePoint, iBatchCount);
|
|
|
|
|
|
if (nullptr != m_pDockTitleBar && bRet) {
|
|
|
|
|
|
QFileInfo fileInfo(strFile);
|
|
|
|
|
|
if (1 == m_iType) {
|
|
|
|
|
|
if (m_titleText.isEmpty()) {
|
|
|
|
|
|
m_pDockTitleBar->SetTitle(tr("2D Curve -- %1").arg(fileInfo.fileName()));
|
|
|
|
|
|
} else {
|
|
|
|
|
|
m_pDockTitleBar->SetTitle(tr("%1 -- %2").arg(m_titleText).arg(fileInfo.fileName()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (m_titleText.isEmpty()) {
|
|
|
|
|
|
m_pDockTitleBar->SetTitle(tr("2D(y(lg)) Curve -- %1").arg(fileInfo.fileName()));
|
|
|
|
|
|
} else {
|
|
|
|
|
|
m_pDockTitleBar->SetTitle(tr("%1 -- %2").arg(m_titleText).arg(fileInfo.fileName()));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-04 04:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::InitReportFile(const QString& strFile, int iBatchCount)
|
|
|
|
|
|
{
|
2025-01-07 15:45:23 +00:00
|
|
|
|
if (strFile.isEmpty())
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2025-01-04 04:12:51 +00:00
|
|
|
|
m_vecReportPoint.clear();
|
2025-07-20 08:34:48 +00:00
|
|
|
|
bool bRet = ParseReport(strFile, m_vecReportPoint, iBatchCount);
|
|
|
|
|
|
if (nullptr != m_pDockTitleBar && bRet) {
|
|
|
|
|
|
QFileInfo fileInfo(strFile);
|
|
|
|
|
|
if (1 == m_iType) {
|
|
|
|
|
|
if (m_titleText.isEmpty()) {
|
|
|
|
|
|
m_pDockTitleBar->SetTitle(tr("2D Curve -- %1").arg(fileInfo.fileName()));
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
m_pDockTitleBar->SetTitle(tr("%1 -- %2").arg(m_titleText).arg(fileInfo.fileName()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (m_titleText.isEmpty()) {
|
|
|
|
|
|
m_pDockTitleBar->SetTitle(tr("2D(y(lg)) Curve -- %1").arg(fileInfo.fileName()));
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
m_pDockTitleBar->SetTitle(tr("%1 -- %2").arg(m_titleText).arg(fileInfo.fileName()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-04 04:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-13 05:59:48 +00:00
|
|
|
|
void FitCurveDialog::updateTitle(const QString & xTitle, const QString & yTitle)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_pAxisX)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pAxisX->setTitleText(xTitle);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (m_pAxisY)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pAxisY->setTitleText(yTitle);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::updateMinMaxX(float min, float max, int count)
|
|
|
|
|
|
{
|
|
|
|
|
|
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);
|
|
|
|
|
|
curAxisX->setTickCount(count);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::updateMinMaxY(float min, float max)
|
|
|
|
|
|
{
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-20 08:34:48 +00:00
|
|
|
|
bool FitCurveDialog::ParseWave(const QString& strFile, std::vector<std::vector<std::vector<float>>>& vecWavePoint, int iRowCount)
|
2025-01-04 04:12:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (strFile.isEmpty())
|
|
|
|
|
|
{
|
2025-07-06 15:33:27 +00:00
|
|
|
|
QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请检查数据Wave文件路径!"));
|
2025-07-20 08:34:48 +00:00
|
|
|
|
return false;
|
2025-01-04 04:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QFile file(strFile);
|
|
|
|
|
|
if (file.open(QIODevice::ReadOnly))
|
|
|
|
|
|
{
|
|
|
|
|
|
std::vector<std::vector<float>> batch;
|
|
|
|
|
|
|
|
|
|
|
|
int iRow = 1;
|
|
|
|
|
|
while (!file.atEnd())
|
|
|
|
|
|
{
|
|
|
|
|
|
QString strLine = file.readLine().simplified();
|
|
|
|
|
|
if (!strLine.isEmpty())
|
|
|
|
|
|
{
|
|
|
|
|
|
QStringList listLine = strLine.split(" ");
|
|
|
|
|
|
std::vector<float> vecLine;
|
|
|
|
|
|
for (size_t i = 0; i < listLine.size(); i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
vecLine.push_back(listLine[i].toFloat());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
batch.push_back(vecLine);
|
|
|
|
|
|
|
|
|
|
|
|
if (iRow % iRowCount == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
vecWavePoint.push_back(batch);
|
|
|
|
|
|
batch.clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
iRow++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
file.close();
|
|
|
|
|
|
}
|
2025-07-20 08:34:48 +00:00
|
|
|
|
|
|
|
|
|
|
return true;
|
2025-01-04 04:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-20 08:34:48 +00:00
|
|
|
|
bool FitCurveDialog::ParseReport(const QString& strFile, std::vector<std::vector<std::vector<float>>>& vecReportPoint, int iRowCount)
|
2025-01-04 04:12:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (strFile.isEmpty())
|
|
|
|
|
|
{
|
2025-07-06 15:33:27 +00:00
|
|
|
|
QMessageBox::information(nullptr, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请检查数据Report文件路径!"));
|
2025-07-20 08:34:48 +00:00
|
|
|
|
return false;
|
2025-01-04 04:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QFile file(strFile);
|
|
|
|
|
|
if (file.open(QIODevice::ReadOnly))
|
|
|
|
|
|
{
|
|
|
|
|
|
std::vector<std::vector<float>> batch;
|
|
|
|
|
|
|
|
|
|
|
|
int iRow = 1;
|
|
|
|
|
|
while (!file.atEnd())
|
|
|
|
|
|
{
|
|
|
|
|
|
QString strLine = file.readLine().simplified();
|
|
|
|
|
|
if (!strLine.isEmpty())
|
|
|
|
|
|
{
|
|
|
|
|
|
QStringList listLine = strLine.split(" ");
|
|
|
|
|
|
std::vector<float> vecLine;
|
|
|
|
|
|
for (size_t i = 0; i < listLine.size(); i++)
|
|
|
|
|
|
{
|
2025-07-06 15:33:27 +00:00
|
|
|
|
if (12 == i || i == 13) // 距离、速度
|
2025-01-04 04:12:51 +00:00
|
|
|
|
{
|
|
|
|
|
|
vecLine.push_back(listLine[i].toFloat());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
batch.push_back(vecLine);
|
|
|
|
|
|
|
|
|
|
|
|
if (iRow % iRowCount == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
vecReportPoint.push_back(batch);
|
|
|
|
|
|
batch.clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
iRow++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
file.close();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
slotUpdateTime(1);
|
2025-07-20 08:34:48 +00:00
|
|
|
|
|
|
|
|
|
|
return true;
|
2025-01-04 04:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-05 11:12:18 +00:00
|
|
|
|
void FitCurveDialog::OnWorkSpaceChanged(WorkSpace* worksapce) {
|
|
|
|
|
|
if (worksapce == nullptr) {
|
|
|
|
|
|
LOG_ERROR("worksapce is nullptr");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
connect(worksapce, &WorkSpace::TimestepChanged, this, &FitCurveDialog::OnTimestepChanged);
|
2025-07-06 15:33:27 +00:00
|
|
|
|
InitWaveFile(worksapce->GetWavePath());
|
2025-01-05 11:12:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::OnTimestepChanged(Timestep* timestep) {
|
|
|
|
|
|
if (timestep == nullptr) {
|
|
|
|
|
|
LOG_ERROR("timestep is nullptr");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
connect(timestep, SIGNAL(TimeChanged(double)), this, SLOT(slotUpdateTime(double)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-04 04:12:51 +00:00
|
|
|
|
FitCurveDialog::~FitCurveDialog()
|
|
|
|
|
|
{
|
|
|
|
|
|
delete ui;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FitCurveDialog::AttachDock(DockWidget* dockWidget)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (nullptr == dockWidget) {
|
|
|
|
|
|
qDebug() << __FUNCTION__ << "dockwidget is nullptr";
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dockWidget->SetDockWidgetTitleBar(nullptr);
|
|
|
|
|
|
dockWidget->setWidget(this);
|
|
|
|
|
|
|
2025-07-20 08:34:48 +00:00
|
|
|
|
if (nullptr != dockWidget) {
|
|
|
|
|
|
m_titleText = dockWidget->windowTitle();
|
|
|
|
|
|
}
|
2025-01-04 04:12:51 +00:00
|
|
|
|
DockTitleBar* dockTitleBar = new DockTitleBar;
|
2025-07-20 08:34:48 +00:00
|
|
|
|
m_pDockTitleBar = dockTitleBar;
|
2025-01-04 04:12:51 +00:00
|
|
|
|
|
|
|
|
|
|
if (1 == m_iType)
|
|
|
|
|
|
{
|
2025-07-20 08:34:48 +00:00
|
|
|
|
if (m_titleText.isEmpty())
|
|
|
|
|
|
{
|
|
|
|
|
|
dockTitleBar->SetTitle(tr("2D Curve"));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dockTitleBar->SetTitle(m_titleText);
|
|
|
|
|
|
}
|
2025-01-04 04:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-07-20 08:34:48 +00:00
|
|
|
|
if (m_titleText.isEmpty())
|
|
|
|
|
|
{
|
|
|
|
|
|
dockTitleBar->SetTitle(tr("2D(y(lg)) Curve"));
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
dockTitleBar->SetTitle(m_titleText);
|
|
|
|
|
|
}
|
2025-01-04 04:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dockWidget->SetDockWidgetTitleBar(dockTitleBar);
|
|
|
|
|
|
}
|