From 8223afefd973eff83644d5e105542ea3cb869ba7 Mon Sep 17 00:00:00 2001 From: "DESKTOP-450PEFP\\mainc" Date: Fri, 6 Feb 2026 11:30:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A2=E5=88=97-=E6=B3=A2?= =?UTF-8?q?=E5=BD=A2=E5=B1=9E=E6=80=A7=EF=BC=8C=E7=BB=98=E5=88=B6=E6=B3=A2?= =?UTF-8?q?=E6=B7=B1=E5=BA=A6=E3=80=81=E7=BB=98=E5=88=B6=E6=B3=A2=E5=9F=BA?= =?UTF-8?q?=E7=BA=BF=E3=80=81=E5=A5=87=E5=81=B6=E9=85=8D=E8=89=B2=E3=80=81?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E6=8C=AF=E5=B9=85=E3=80=81=E6=B3=A2=E5=88=97?= =?UTF-8?q?=E5=9F=BA=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logPlus/PropertyWidget.cpp | 3 +- logPlus/forminfo.cpp | 21 +++++++++ logPlus/qmycustomplot.cpp | 87 +++++++++++++++++++++++++++++--------- logPlus/qmycustomplot.h | 5 +++ 4 files changed, 94 insertions(+), 22 deletions(-) diff --git a/logPlus/PropertyWidget.cpp b/logPlus/PropertyWidget.cpp index 205ca67..3d3711f 100644 --- a/logPlus/PropertyWidget.cpp +++ b/logPlus/PropertyWidget.cpp @@ -134,7 +134,8 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant QStringList slist; slist << "显示名称" << "显示单位" << "曲线名称" << "曲线单位" << "曲线刻度" << "类型" << "方式" << "左刻度" << "右刻度" << "幅度刻度" << "最大振幅" << "颜色" << "线宽" - << "波形间隔" << "显示刻度" << "色板" << "变密度颜色级数"; + << "绘制波深度" << "绘制波基线" << "奇偶配色" + << "波列基值" << "波形间隔" << "波形高度" << "显示刻度" << "色板" << "变密度颜色级数"; for (int i = 0; i < slist.length(); i++) { if (slist.at(i) == m_propertyData[pProperty]) diff --git a/logPlus/forminfo.cpp b/logPlus/forminfo.cpp index a5d8596..c819582 100644 --- a/logPlus/forminfo.cpp +++ b/logPlus/forminfo.cpp @@ -621,12 +621,33 @@ bool FormInfo::setInfoProperty(QString strProName, QVariant val) } else if ("最大振幅" == strProName) { + bDraw = true; this->m_fMaxAmp = val.toFloat(); } else if ("显示刻度" == strProName) { this->m_bShowScale = val.toBool(); } + else if ("绘制波深度" == strProName) + { + bDraw = true; + this->m_bDrawDepth = val.toBool(); + } + else if ("绘制波基线" == strProName) + { + bDraw = true; + this->m_bDrawBase = val.toBool(); + } + else if ("奇偶配色" == strProName) + { + bDraw = true; + this->m_bOddEven = val.toBool(); + } + else if ("波列基值" == strProName) + { + bDraw = true; + this->m_fWaveBase = val.toFloat(); + } else if ("波形间隔" == strProName) { bDraw = true; diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index b3e57e2..6367410 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -112,6 +112,7 @@ void QMyCustomPlot::changePropertyWaveUpdate() this->m_colorMap->setVisible(false); clearGraphs(); + clearItems(); if (this->m_bX2Y) { @@ -128,6 +129,7 @@ void QMyCustomPlot::changePropertyWaveUpdate() if (this->m_colorMap) this->m_colorMap->setVisible(true); clearGraphs(); + clearItems(); this->m_bX2Y = true; this->initWave(m_strSlfName, m_strLineName); @@ -306,9 +308,9 @@ void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName) float edepc = -m_iY1; float m_PlotSdep = -m_iY2; float m_MoveDep = 0.0f; - float m_MaxRange = 1023.0f; - float m_Base = 0.0f; float DifBase = (m_MaxRange - m_Base) / 1; + float yscale = m_nWaveHei; + yscale = yscale / DifBase; int nStep = m_nWaveJg;// mWaveMes.m_WaveSpace; if (m_nWaveJg < 10) @@ -318,6 +320,7 @@ void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName) float m_r = m_Rlev * nStep; detp = int((detp - m_PlotSdep) / m_r)*m_r + m_PlotSdep; + int nOdd = 0; int nidx = 0; for (float dep1 = detp - m_r; dep1 < edepc + m_MoveDep + m_r; dep1 += m_r) { @@ -338,7 +341,6 @@ void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName) vals.resize(nPoint); vVdl.vchar = &((char *)value)[iIndex*_nSamples*_wave.CodeLen]; - float nmy = 0; for (int i = 0; i < nPoint; i++) { float ch = 0.0f; @@ -369,10 +371,6 @@ void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName) } else ch = 0; vals[i] = ch; - if (ch > nmy) - { - nmy = ch; - } } QVector vx; @@ -382,7 +380,7 @@ void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName) { vx << i; - double d = (-dep1 - 1) + vals[i] / (nmy/ m_nWaveHei); + double d = (-dep1 - 1) + vals[i] * yscale; vy << d; if (d < dminy) dminy = d; @@ -394,11 +392,27 @@ void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName) graph0 = widget->addGraph(); graph0->setPen(QPen(m_newColor)); } + if (m_nDrawType == 0 && m_bOddEven) // 波形&&奇偶配色 + { + if (nOdd % 2 == 1) + graph0->setPen(QPen(QColor(255, 0, 0))); + } graph0->setData(vx, vy); + + if (m_bDrawDepth) + { + QCPItemText* pText = new QCPItemText(this); + pText->setText(QString::number(dminy*-1, 'f', 2)); + pText->position->setCoords(30, dminy); + if (m_bOddEven && nOdd % 2 == 1) + pText->setColor(QColor(255, 0, 0)); + else + pText->setColor(m_newColor); + } //graph->setBrush(QBrush(QColor(255, 0, 0, 100))); nidx++; - if (m_nDrawType == 1) + if (m_bDrawBase || m_nDrawType == 1) // 填充 || 绘制波基线 { QCPGraph * graph1 = widget->graph(nidx); if (graph1 == NULL) @@ -406,6 +420,8 @@ void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName) graph1 = widget->addGraph(); graph1->setPen(QPen(m_newColor)); } + if (m_bOddEven && nOdd % 2 == 1) + graph1->setPen(QPen(QColor(255, 0, 0))); double dx1 = vx[0]; double dx2 = vx[vx.size() - 1]; vx.clear(); @@ -414,10 +430,14 @@ void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName) vy << dminy << dminy; graph1->setData(vx, vy); nidx++; - - graph0->setBrush(QBrush(m_newColor)); - graph0->setChannelFillGraph(graph1); + if (m_nDrawType == 1) + { + graph0->setBrush(QBrush(m_newColor)); + graph0->setChannelFillGraph(graph1); + } } + + nOdd++; } widget->replot(); @@ -1303,30 +1323,50 @@ void QMyCustomPlot::s_changeDrawProperty(QVariantList vlist) m_strLineName == strLineName) { QString strProperty = vlist.at(5).toString(); - QString strValue = vlist.at(6).toString(); + QVariant varVal = vlist.at(6).toString(); if ("类型" == strProperty) { - m_nDrawType = strValue.toInt(); + m_nDrawType = varVal.toInt(); + this->changePropertyWaveUpdate(); + } + else if ("绘制波深度" == strProperty) + { + m_bDrawDepth = varVal.toBool(); + this->changePropertyWaveUpdate(); + } + else if ("绘制波基线" == strProperty) + { + m_bDrawBase = varVal.toBool(); + this->changePropertyWaveUpdate(); + } + else if ("奇偶配色" == strProperty) + { + m_bOddEven = varVal.toBool(); + this->changePropertyWaveUpdate(); + } + else if ("波列基值" == strProperty) + { + m_Base = varVal.toFloat(); this->changePropertyWaveUpdate(); } else if ("波形间隔" == strProperty) { - m_nWaveJg = strValue.toInt(); + m_nWaveJg = varVal.toInt(); this->changePropertyWaveUpdate(); } else if ("波形高度" == strProperty) { - m_nWaveHei = strValue.toInt(); + m_nWaveHei = varVal.toInt(); this->changePropertyWaveUpdate(); } else if ("颜色" == strProperty) { - m_newColor = vlist.at(6).value(); + m_newColor = varVal.value(); this->changePropertyWaveUpdate(); } else if ("方式" == strProperty) { - m_nMode = strValue.toFloat(); + m_nMode = varVal.toFloat(); this->updateWave(); } else if ("左刻度" == strProperty) @@ -1337,18 +1377,23 @@ void QMyCustomPlot::s_changeDrawProperty(QVariantList vlist) { if (m_colorMap) { - m_fScaleV = strValue.toFloat(); + m_fScaleV = varVal.toFloat(); float f = 264 / m_fScaleV; m_colorMap->data()->setValueRange(QCPRange(m_fmin, m_fmax*f)); } } + else if ("最大振幅" == strProperty) + { + m_MaxRange = varVal.toDouble(); + this->changePropertyWaveUpdate(); + } else if ("色板" == strProperty) { - this->setSchemeIndex(strValue.toInt(), m_nColorNum); + this->setSchemeIndex(varVal.toInt(), m_nColorNum); } else if ("变密度颜色级数" == strProperty) { - this->setSchemeIndex(m_nSchemeIndex, strValue.toInt()); + this->setSchemeIndex(m_nSchemeIndex, varVal.toInt()); } this->replot(); } diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index 71362d1..8458f38 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -88,6 +88,11 @@ public: float m_fmax; int m_nColorNum = 256; int m_nSchemeIndex = 1; + bool m_bDrawDepth = false; // 绘制波深度 + bool m_bDrawBase = false; // 绘制波基线 + bool m_bOddEven = false; // 奇偶配色 + float m_Base = 0.0f; + float m_MaxRange = 1023.0f; int m_nWaveJg = 100; int m_nWaveHei = 1; public: