From 4b1cd2bac99ccc114d1a0d45dfb2f59bc888259f Mon Sep 17 00:00:00 2001 From: "DESKTOP-450PEFP\\mainc" Date: Fri, 6 Feb 2026 09:20:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A2=E5=88=97=E5=AE=9E=E7=8E=B0=EF=BC=8C?= =?UTF-8?q?=E6=B3=A2=E5=BD=A2=E6=98=BE=E7=A4=BA=E6=95=88=E6=9E=9C=20?= =?UTF-8?q?=E6=B3=A2=E5=BD=A2=E7=BB=98=E5=9B=BE=E7=B1=BB=E5=9E=8B=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E6=98=BE=E7=A4=BA=E6=95=88=E6=9E=9C=EF=BC=8C=E6=B3=A2?= =?UTF-8?q?=E5=BD=A2=E3=80=81=E5=8F=98=E5=AF=86=E5=BA=A6=E6=88=90=E5=83=8F?= =?UTF-8?q?=EF=BC=8C=E5=A1=AB=E5=85=85=E6=98=BE=E7=A4=BA=20=E6=B3=A2?= =?UTF-8?q?=E5=88=97=E9=97=B4=E9=9A=94=EF=BC=8C=E6=B3=A2=E5=88=97=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E5=B1=9E=E6=80=A7=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logPlus/PropertyWidget.cpp | 78 +++++++++++++------ logPlus/PropertyWidget.h | 4 +- logPlus/formdraw.cpp | 144 ++---------------------------------- logPlus/formdraw.h | 3 - logPlus/forminfo.cpp | 90 +++++++++++++++++----- logPlus/forminfo.h | 9 +++ logPlus/qmycustomplot.cpp | 148 +++++++++++++++++++++++++------------ logPlus/qmycustomplot.h | 10 ++- 8 files changed, 251 insertions(+), 235 deletions(-) diff --git a/logPlus/PropertyWidget.cpp b/logPlus/PropertyWidget.cpp index cc8d6b4..44141f5 100644 --- a/logPlus/PropertyWidget.cpp +++ b/logPlus/PropertyWidget.cpp @@ -55,7 +55,7 @@ QWidget* PropertyWidget::GetPropertyWidget() } //初始化,清空 -void PropertyWidget::InitCurrentViewInfo() +void PropertyWidget::InitCurrentViewInfo(bool bAll) { QList propertyList = m_pPropertyBrowser->properties(); m_pPropertyBrowser->clear(); @@ -71,16 +71,19 @@ void PropertyWidget::InitCurrentViewInfo() m_propertyData.clear(); m_mapGroupItem.clear(); - m_fromTop = NULL; - m_formInfo = NULL; - m_item = NULL; - m_strUuid = ""; - m_strSlfName = ""; - m_strWellName = ""; - m_strTrackName = ""; - m_strLineName = ""; - // - m_strCurrentProperty = ""; + if (bAll) + { + m_fromTop = NULL; + m_formInfo = NULL; + m_item = NULL; + m_strUuid = ""; + m_strSlfName = ""; + m_strWellName = ""; + m_strTrackName = ""; + m_strLineName = ""; + // + m_strCurrentProperty = ""; + } } void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant &variant ) @@ -128,7 +131,8 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant bool bDraw = false; QStringList slist; slist << "显示名称" << "显示单位" << "曲线名称" << "曲线单位" << "曲线刻度" - << "类型" << "方式" << "左刻度" << "右刻度" << "幅度刻度" << "最大振幅" << "显示刻度" << "色板" << "变密度颜色级数"; + << "类型" << "方式" << "左刻度" << "右刻度" << "幅度刻度" << "最大振幅" << "颜色" << "线宽" + << "波形间隔" << "显示刻度" << "色板" << "变密度颜色级数"; for (int i = 0; i < slist.length(); i++) { if (slist.at(i) == m_propertyData[pProperty]) @@ -153,6 +157,12 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant listCond << variant; emit CallManage::getInstance()->sig_changeDrawProperty(listCond); } + + if ("类型" == m_propertyData[pProperty]) + { + this->InitCurrentViewInfo(false); + initWaveProperty(m_formInfo, variant.toInt()); + } return; } if("深度比例尺" == m_propertyData[pProperty]) @@ -1179,7 +1189,7 @@ void PropertyWidget::initProperty(FormInfo *formInfo) } else if (formInfo->m_strType == "waveObject") { - this->initWaveProperty(formInfo); + this->initWaveProperty(formInfo, formInfo->m_nDrawType); } } @@ -1213,8 +1223,11 @@ void PropertyWidget::initRoseProperty(FormInfo *formInfo) // _CreateVariantPropertyItem("玫瑰图", "道头字颜色", fromTop->m_fontColor, QVariant::Color); } -void PropertyWidget::initWaveProperty(FormInfo *formInfo) +void PropertyWidget::initWaveProperty(FormInfo *formInfo, int nType) { + if (formInfo == NULL) + return; + _CreateVariantPropertyItem("通常", "选择井曲线", m_strLineName + "@" + m_strSlfName, QVariant::String); _CreateVariantPropertyItem("通常", "显示名称", formInfo->m_strLineName, QVariant::String); //_CreateVariantPropertyItem("通常", "例区高度(cm)", formInfo->m_strUnit, QVariant::Double); @@ -1247,22 +1260,36 @@ void PropertyWidget::initWaveProperty(FormInfo *formInfo) drawType.append("多臂井径"); _CreateEnumPropertyItem("绘图类型", "类型", formInfo->m_nDrawType, drawType); - QStringList fillType; - fillType.append("全周"); - fillType.append("正半周"); - fillType.append("负半周"); - _CreateEnumPropertyItem("填充方式", "方式", formInfo->m_nFillType, fillType); + if (nType == 2) + { + QStringList fillType; + fillType.append("全周"); + fillType.append("正半周"); + fillType.append("负半周"); + _CreateEnumPropertyItem("填充方式", "方式", formInfo->m_nFillType, fillType); + } + if (nType == 0 || nType == 1) + { + _CreateVariantPropertyItem("波形绘制参数", "绘制波深度", formInfo->m_bDrawDepth, QVariant::Bool); + _CreateVariantPropertyItem("波形绘制参数", "绘制波基线", formInfo->m_bDrawBase, QVariant::Bool); + _CreateVariantPropertyItem("波形绘制参数", "奇偶配色", formInfo->m_bOddEven, QVariant::Bool); + } //_CreateVariantPropertyItem("波形绘制参数", "自动平滑", true, QVariant::Bool); _CreateVariantPropertyItem("波形绘制参数", "左刻度", formInfo->m_vmin, QVariant::Double); _CreateVariantPropertyItem("波形绘制参数", "右刻度", formInfo->m_vmax, QVariant::Double); _CreateVariantPropertyItem("波形绘制参数", "幅度刻度", formInfo->m_strAmp, QVariant::String); _CreateVariantPropertyItem("波形绘制参数", "最大振幅", formInfo->m_fMaxAmp, QVariant::Double); _CreateVariantPropertyItem("波形绘制参数", "显示刻度", formInfo->m_bShowScale, QVariant::Bool); - //_CreateVariantPropertyItem("波形绘制参数", "波列基值", 0, QVariant::Double); - //_CreateVariantPropertyItem("波形绘制参数", "波形间隔", 1, QVariant::Int); - //_CreateVariantPropertyItem("波形绘制参数", "波形高度", 1, QVariant::Double); + if (nType == 0 || nType == 1) + { + _CreateVariantPropertyItem("波形绘制参数", "波列基值", formInfo->m_fWaveBase, QVariant::Double); + _CreateVariantPropertyItem("波形绘制参数", "波形间隔", formInfo->m_nWaveJg, QVariant::Int); + _CreateVariantPropertyItem("波形绘制参数", "波形高度", formInfo->m_fWaveHei, QVariant::Double); + _CreateVariantPropertyItem("波形绘制参数", "线宽", formInfo->m_dWidth, QVariant::Int); + _CreateVariantPropertyItem("波形绘制参数", "颜色", formInfo->m_lineColor, QVariant::Color); + } //_CreateVariantPropertyItem("成像显示", "RGBA数据", false, QVariant::Bool); //_CreateVariantPropertyItem("成像显示", "绘制阵列数", 1, QVariant::Int); //_CreateVariantPropertyItem("成像显示", "是否顶底倒置", false, QVariant::Bool); @@ -1272,8 +1299,11 @@ void PropertyWidget::initWaveProperty(FormInfo *formInfo) //_CreateVariantPropertyItem("成像显示", "是否深度校正", false, QVariant::Bool); //_CreateVariantPropertyItem("成像显示", "是否自动计算波参数", "", QVariant::String); - _CreateColorSchemePropertyItem("调色板参数设置", "色板", formInfo->m_nSchemeIndex); - _CreateVariantPropertyItem("调色板参数设置", "变密度颜色级数", formInfo->m_nColorNum, QVariant::Int); + if (nType == 2) + { + _CreateColorSchemePropertyItem("调色板参数设置", "色板", formInfo->m_nSchemeIndex); + _CreateVariantPropertyItem("调色板参数设置", "变密度颜色级数", formInfo->m_nColorNum, QVariant::Int); + } // _CreateVariantPropertyItem("调色板参数设置", "图例置顶", false, QVariant::Bool); // _CreateVariantPropertyItem("调色板参数设置", "反转显示", false, QVariant::Bool); diff --git a/logPlus/PropertyWidget.h b/logPlus/PropertyWidget.h index 303e603..666b463 100644 --- a/logPlus/PropertyWidget.h +++ b/logPlus/PropertyWidget.h @@ -100,7 +100,7 @@ public: void _CreateColorSchemePropertyItem(QString strGroup, QString strPropertyCaption, QVariant vtPropertyValue); - void InitCurrentViewInfo(); //初始化属性,清空 + void InitCurrentViewInfo(bool bAll = true); //初始化属性,清空 void initWidgetProperty(QString strUuid, int iScale); //可视解释整体属性 //井 void initWellProperty(QString strUuid, QString strSlfName, QString strWellName, double iY1, double iY2); @@ -117,7 +117,7 @@ public: // 玫瑰图属性 void initRoseProperty(FormInfo *formInfo); // 波列属性 - void initWaveProperty(FormInfo *formInfo); + void initWaveProperty(FormInfo *formInfo, int nType = 3); void ChangFillProperty();//填充属性改变 diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index 1a37c93..7062cf6 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -807,6 +807,8 @@ void FormDraw::s_addWave(QString strUuid, QString strSlfName, QString strWellNam curv->show(); + curv->m_iY1 = m_iY1; + curv->m_iY2 = m_iY2; int _nSamples = 0; if(g_iSupport3D) { @@ -814,10 +816,10 @@ void FormDraw::s_addWave(QString strUuid, QString strSlfName, QString strWellNam } else { - initWave(curv, strSlfName, strWaveName, _nSamples); + curv->initWave(strSlfName, strWaveName); + _nSamples = curv->getScaleV(); } - - curv->initColorTable(); + curv->replot(); connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*))); // @@ -2501,142 +2503,6 @@ void FormDraw::initForm(QMyCustomPlot *widget, QString strSlfName, QString strLi //AppendConsole(PAI_INFO, "FormDraw initForm end"); } -void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWaveName, int &_nSamples) -{ - CLogIO *logio=new CLogIO(); - logio->Open(strSlfName.toStdString().c_str(), CSlfIO::modeRead); - // - int index=logio->OpenWave(strWaveName.toStdString().c_str()); - if(index<0) { - delete logio; - return; - } - - - Slf_WAVE _wave; - logio->GetWaveInfo(index, &_wave); - float _SDep,_EDep,_Rlev; - _SDep = _wave.StartDepth; - _EDep = _wave.EndDepth; -// _SDep = 0.0 - m_iY2; -// _EDep = 0.0 - m_iY1; - _Rlev = _wave.DepLevel; - int m_Record=(float)(fabs((_EDep-_SDep)/_Rlev+0.5)); - - _nSamples = _wave.TimeSamples; - - char *value=new char[(_nSamples+1)*m_Record*_wave.CodeLen+1]; - logio->ReadWave(index,_SDep,m_Record,(void *)value); - logio->CloseWave(index); - delete logio; - - bool bFistValue=false; - float vmax = -9999;//(float)_nSamples; - float vmin = -9999; - // - double** wavedata = widget->getWavedata(_nSamples, m_Record); - //wavedata = new double*[_nSamples]; - //for(int kk = 0;kk<_nSamples;kk++){ - // wavedata[kk] = new double[m_Record]; - //} - - for (int i=0; ival)vmin=val; - } - } - delete[] value; - -// m_iY1 = 0.0 -_EDep; -// m_iY2 = 0.0 -_SDep; - //------------------------ - widget->m_iX1 = vmin; - widget->m_iX2 = vmax; - widget->m_iY1 = m_iY1; - widget->m_iY2 = m_iY2; - // - widget->xAxis->setRange(vmin, vmax); - widget->yAxis->setRange(m_iY1, m_iY2); - widget->axisRect()->setupFullAxesBox(); - // - widget->xAxis->ticker()->setTickCount(10);//x个主刻度 - widget->yAxis->ticker()->setTickCount(60);//y个主刻度 - - //对调XY轴,在最前面设置 - QCPAxis *yAxis = widget->yAxis; - QCPAxis *xAxis = widget->xAxis; - widget->xAxis = yAxis; - widget->yAxis = xAxis; - - widget->m_fmin = vmin; - widget->m_fmax = vmax; - - //------------------- - // set up the QCPColorMap: - QCPColorMap *colorMap = new QCPColorMap(widget->xAxis, widget->yAxis); - widget->m_colorMap = colorMap; - - int nx = m_Record; - int ny = _nSamples; - colorMap->data()->setSize(nx, ny); // 我们希望彩色地图有nx*ny的数据点 - //colorMap->data()->setRange(QCPRange(m_iY1, m_iY2), QCPRange(vmin, vmax)); // 并在键(x)和值(y)维上跨越坐标范围-4..4 - colorMap->data()->setRange(QCPRange(0 - _EDep, 0 - _SDep), QCPRange(vmin, vmax)); - // :现在,我们通过访问颜色贴图的QCPColorMapData实例来分配一些数据: - for (int xIndex = 0; xIndex < nx; ++xIndex) - { - for (int yIndex = 0; yIndex < ny; ++yIndex) - { - if (wavedata[yIndex][xIndex] == -9999) - { - colorMap->data()->setCell(nx - xIndex - 1, yIndex, vmin); - continue; - } - //colorMap->data()->setCell(xIndex, yIndex, wavedata[yIndex][xIndex]); - colorMap->data()->setCell(nx - xIndex - 1, yIndex, wavedata[yIndex][xIndex]); - } - } - - // 添加色标: - QCPColorScale *colorScale = new QCPColorScale(widget); - colorMap->setColorScale(colorScale); // 将颜色图与色标关联 - // 将颜色贴图的“颜色渐变”设置为其中一个预设 - //colorMap->setGradient(QCPColorGradient::gpPolar);//gpJet); - // 我们还可以创建一个QCPColorGradient实例并向其中添加自己的颜色 - // 渐变,请参阅QCPColorGradient的文档以获取可能的效果. - //int nIndex = 11; - //QVector colorList; - //bool inpolation = true; - //int iColorNum = getSystemColor(nIndex, colorList, inpolation); - //// - //QCPColorGradient gradient; - //for (int i = 0; i < iColorNum; i++) - //{ - // double dbTmpIndex = (double)(i + 1) / iColorNum; - // gradient.setColorStopAt(dbTmpIndex, colorList[i].color); // x% 位置的颜色 - //} - //colorMap->setGradient(gradient); - // 重新缩放数据维度(颜色),以使所有数据点都位于颜色渐变显示的范围内: - colorMap->rescaleDataRange(); - - -} - void FormDraw::initWave_3D(QMyCustomPlot *widget, QString strSlfName, QString strWaveName, int &_nSamples) { CLogIO *logio=new CLogIO(); diff --git a/logPlus/formdraw.h b/logPlus/formdraw.h index 5651018..81f60df 100644 --- a/logPlus/formdraw.h +++ b/logPlus/formdraw.h @@ -103,10 +103,7 @@ public: void setupSelectionDemo(QMyCustomPlot *customPlot); //波列 - void initWave(QMyCustomPlot *widget, QString strSlfName, QString strWaveName, int &_nSamples); void initWave_3D(QMyCustomPlot *widget, QString strSlfName, QString strWaveName, int &_nSamples); - // 绘图类型-波形 - void initWave2(QMyCustomPlot *widget, QString strSlfName, QString strWaveName); //图像-3d成图 int getColorConfig(QVector &qFiles); diff --git a/logPlus/forminfo.cpp b/logPlus/forminfo.cpp index c47e758..0032b4d 100644 --- a/logPlus/forminfo.cpp +++ b/logPlus/forminfo.cpp @@ -293,26 +293,59 @@ void FormInfo::paintEvent(QPaintEvent* event) if(m_strType=="waveObject") { - QtColorTableData::getInstance()->SetCurrentSchemeIndex(m_nSchemeIndex); - //ColorTableIndex = ind; - - QtColorTableData::getInstance()->ChangeColorNum(m_nColorNum); - QList rgbList = QtColorTableData::getInstance()->GetRgb(); - int iColorNum = rgbList.size(); - - //头部绘制调色板 - float scale = (float)(rect.width() - 4) / (float)iColorNum; - QRectF rt7 = QRectF(rect.left() + 2, rect.top() + rect.height() / 3, rect.width() - 4, rect.height() / 3); - for (int i = 0; i < iColorNum; i++) + if (m_nDrawType == 0 || m_nDrawType == 1) { - QColor acolor = rgbList.at(i); - float temp = (float)i * scale; - if (i)rt7.setLeft(rect.left() + 2 + temp); - else rt7.setLeft(rect.left() + 2 + temp + 1); - temp = (float)(i + 1) * scale; - rt7.setRight(rect.left() + 2 + temp); - QBrush HeadBrush = QBrush(acolor); - painter.fillRect(rt7, HeadBrush); + int nbot = rect.bottom()- rect.height() / 3.0; + QVector pts; + int i = 0; + pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot)); + pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot - rect.height() / 15.0)); + pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot - rect.height() / 12.0)); + pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot - rect.height() / 9.0)); + pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot - rect.height() / 6.0)); + pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot - rect.height() / 3.0)); + pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot - rect.height() / 9.0)); + pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot - rect.height() / 15.0)); + pts.append(QPointF(rect.left() + rect.width() / 3.0 + (i++)*rect.width() / 3.0 / 8.0, nbot)); + pts.append(QPointF(rect.left() + rect.width() / 3.0, nbot)); + + if (m_nDrawType == 1) { + QPolygonF cRgn; + for (int j = 0; j < pts.size(); j++) { + cRgn.push_back(pts[j]); + } + QPainterPath path; + path.addPolygon(cRgn); + painter.fillPath(path, QBrush(m_lineColor)); + } + else + { + painter.drawPolygon(pts); + } + } + else + { + QtColorTableData::getInstance()->SetCurrentSchemeIndex(m_nSchemeIndex); + //ColorTableIndex = ind; + + QtColorTableData::getInstance()->ChangeColorNum(m_nColorNum); + QList rgbList = QtColorTableData::getInstance()->GetRgb(); + int iColorNum = rgbList.size(); + + //头部绘制调色板 + float scale = (float)(rect.width() - 4) / (float)iColorNum; + QRectF rt7 = QRectF(rect.left() + 2, rect.top() + rect.height() / 3, rect.width() - 4, rect.height() / 3); + for (int i = 0; i < iColorNum; i++) + { + QColor acolor = rgbList.at(i); + float temp = (float)i * scale; + if (i)rt7.setLeft(rect.left() + 2 + temp); + else rt7.setLeft(rect.left() + 2 + temp + 1); + temp = (float)(i + 1) * scale; + rt7.setRight(rect.left() + 2 + temp); + QBrush HeadBrush = QBrush(acolor); + painter.fillRect(rt7, HeadBrush); + } } } @@ -603,6 +636,25 @@ bool FormInfo::setInfoProperty(QString strProName, QVariant val) { this->m_bShowScale = val.toBool(); } + else if ("波形间隔" == strProName) + { + bDraw = true; + this->m_nWaveJg = val.toInt(); + } + else if ("波形高度" == strProName) + { + bDraw = true; + this->m_fWaveHei = val.toInt(); + } + else if ("颜色" == strProName) + { + bDraw = true; + this->m_lineColor = val.value(); + } + else if ("线宽" == strProName) + { + this->m_dWidth = val.toInt(); + } else if ("色板" == strProName) { this->m_nSchemeIndex = val.toInt(); diff --git a/logPlus/forminfo.h b/logPlus/forminfo.h index 7ab1f07..ff1cf33 100644 --- a/logPlus/forminfo.h +++ b/logPlus/forminfo.h @@ -100,10 +100,19 @@ public: int m_nDrawType; // 绘图类型 int m_nFillType; // 填充类型 + + bool m_bDrawDepth = false; // 绘制波深度 + bool m_bDrawBase = false; // 绘制波基线 + bool m_bOddEven = false; // 奇偶配色 + QString m_strAmp; // 幅度刻度 float m_fMaxAmp; // 最大振幅 bool m_bShowScale; // 显示刻度 + float m_fWaveBase = 0.0f; // 波列基值 + int m_nWaveJg = 100; // 波形间隔 + float m_fWaveHei = 1; // 波形高度 + int m_nColorNum = 256; // 调色板参数设置-变密度颜色级数 int m_nSchemeIndex = 1; // 调色板参数设置-色板 diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 77fd99d..b3e57e2 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -34,7 +34,7 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel setObjectName("QMyCustomPlot"); //this->setOpenGl(true);//不开启,电脑不支持会卡 // this->setNotAntialiasedElements(QCP::aeAll); // 关闭所有抗锯齿 - + m_newColor = Qt::black; // 开启抗锯齿 this->setAntialiasedElement(QCP::aeAll); @@ -104,6 +104,36 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel connect(CallManage::getInstance(), SIGNAL(sig_changeDrawProperty(QVariantList)), this, SLOT(s_changeDrawProperty(QVariantList))); } +void QMyCustomPlot::changePropertyWaveUpdate() +{ + if (m_nDrawType == 0 || m_nDrawType == 1) + { + if (this->m_colorMap) + this->m_colorMap->setVisible(false); + + clearGraphs(); + + if (this->m_bX2Y) + { + QCPAxis *yAxis = this->yAxis; + QCPAxis *xAxis = this->xAxis; + this->xAxis = yAxis; + this->yAxis = xAxis; + this->m_bX2Y = false; + } + this->initWave2(m_strSlfName, m_strLineName); + } + else if (m_nDrawType == 2) + { + if (this->m_colorMap) + this->m_colorMap->setVisible(true); + clearGraphs(); + + this->m_bX2Y = true; + this->initWave(m_strSlfName, m_strLineName); + } +} + void QMyCustomPlot::initWave(QString strSlfName, QString strWaveName) { CLogIO *logio = new CLogIO(); @@ -127,7 +157,8 @@ void QMyCustomPlot::initWave(QString strSlfName, QString strWaveName) int m_Record = (float)(fabs((_EDep - _SDep) / _Rlev + 0.5)); int _nSamples = _wave.TimeSamples; - + if (m_fScaleV <= 0.0f) + m_fScaleV = _nSamples; char *value = new char[(_nSamples + 1)*m_Record*_wave.CodeLen + 1]; logio->ReadWave(index, _SDep, m_Record, (void *)value); logio->CloseWave(index); @@ -181,6 +212,11 @@ void QMyCustomPlot::initWave(QString strSlfName, QString strWaveName) widget->xAxis->ticker()->setTickCount(10);//x个主刻度 widget->yAxis->ticker()->setTickCount(60);//y个主刻度 + widget->xAxis->setTicks(false); + widget->yAxis->setTicks(false); + widget->xAxis2->setTicks(false); + widget->yAxis2->setTicks(false); + //对调XY轴,在最前面设置 QCPAxis *yAxis = widget->yAxis; QCPAxis *xAxis = widget->xAxis; @@ -274,7 +310,10 @@ void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName) float m_Base = 0.0f; float DifBase = (m_MaxRange - m_Base) / 1; - int nStep = 600;// mWaveMes.m_WaveSpace; + int nStep = m_nWaveJg;// mWaveMes.m_WaveSpace; + if (m_nWaveJg < 10) + nStep = 10; + if (nStep < 1) nStep = 1; float m_r = m_Rlev * nStep; detp = int((detp - m_PlotSdep) / m_r)*m_r + m_PlotSdep; @@ -323,8 +362,8 @@ void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName) else if (_wave.RepCode == REPR_FLOAT) { ch = vVdl.vfloat[i + lpoint]; } - //else - //ch = GetData(_wave.RepCode, (char *)&vVdl.vchar[(i + lpoint)*_wave.CodeLen]); + else + ch = GetData(_wave.RepCode, (char *)&vVdl.vchar[(i + lpoint)*_wave.CodeLen]); if (ch == -9999.0 || ch == -99999.0 || ch == -999.25) ch = 0; } @@ -334,29 +373,51 @@ void QMyCustomPlot::initWave2(QString strSlfName, QString strWaveName) { nmy = ch; } - //if (objViewInfo->m_Logarithmic == AXIS_LOGARITHMIC || - // objViewInfo->m_maxRange == -99999) { - // if (vmin > ch) vmin = ch; - // if (vmax < ch) vmax = ch; - //} } QVector vx; QVector vy; + double dminy = 0.0; for (int i = 0; i < nPoint; i++) { vx << i; - vy << (-dep1 - 1) + vals[i] / nmy; + + double d = (-dep1 - 1) + vals[i] / (nmy/ m_nWaveHei); + vy << d; + if (d < dminy) + dminy = d; } - QCPGraph * graph = widget->graph(nidx); - if (graph == NULL) + QCPGraph * graph0 = widget->graph(nidx); + if (graph0 == NULL) { - graph = widget->addGraph(); - //graph->setPen(QPen(clor)); + graph0 = widget->addGraph(); + graph0->setPen(QPen(m_newColor)); } - graph->setData(vx, vy); + graph0->setData(vx, vy); + //graph->setBrush(QBrush(QColor(255, 0, 0, 100))); nidx++; + + if (m_nDrawType == 1) + { + QCPGraph * graph1 = widget->graph(nidx); + if (graph1 == NULL) + { + graph1 = widget->addGraph(); + graph1->setPen(QPen(m_newColor)); + } + double dx1 = vx[0]; + double dx2 = vx[vx.size() - 1]; + vx.clear(); + vx << dx1 << dx2; + vy.clear(); + vy << dminy << dminy; + graph1->setData(vx, vy); + nidx++; + + graph0->setBrush(QBrush(m_newColor)); + graph0->setChannelFillGraph(graph1); + } } widget->replot(); @@ -461,6 +522,11 @@ QCPColorMap * QMyCustomPlot::updateWave() return m_colorMap; } +float QMyCustomPlot::getScaleV() +{ + return m_fScaleV; +} + //蝌蚪图,重绘网格线 void QMyCustomPlot::drawCustomElements() { @@ -1240,36 +1306,23 @@ void QMyCustomPlot::s_changeDrawProperty(QVariantList vlist) QString strValue = vlist.at(6).toString(); if ("类型" == strProperty) { - if (strValue == "0") - { - if (this->m_colorMap) - this->m_colorMap->setVisible(false); - for (int i = 0; i < graphCount(); i++) - { - graph(i)->setVisible(true); - } - - if (this->m_bX2Y) - { - QCPAxis *yAxis = this->yAxis; - QCPAxis *xAxis = this->xAxis; - this->xAxis = yAxis; - this->yAxis = xAxis; - this->m_bX2Y = false; - } - this->initWave2(m_strSlfName, m_strLineName); - } - else if (strValue == "2") - { - if (this->m_colorMap) - this->m_colorMap->setVisible(true); - for (int i = 0; i < graphCount(); i++) - { - graph(i)->setVisible(false); - } - this->m_bX2Y = true; - this->initWave(m_strSlfName, m_strLineName); - } + m_nDrawType = strValue.toInt(); + this->changePropertyWaveUpdate(); + } + else if ("波形间隔" == strProperty) + { + m_nWaveJg = strValue.toInt(); + this->changePropertyWaveUpdate(); + } + else if ("波形高度" == strProperty) + { + m_nWaveHei = strValue.toInt(); + this->changePropertyWaveUpdate(); + } + else if ("颜色" == strProperty) + { + m_newColor = vlist.at(6).value(); + this->changePropertyWaveUpdate(); } else if ("方式" == strProperty) { @@ -1284,7 +1337,8 @@ void QMyCustomPlot::s_changeDrawProperty(QVariantList vlist) { if (m_colorMap) { - float f = 264 / strValue.toFloat(); + m_fScaleV = strValue.toFloat(); + float f = 264 / m_fScaleV; m_colorMap->data()->setValueRange(QCPRange(m_fmin, m_fmax*f)); } } diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index 9f53d15..71362d1 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -21,7 +21,10 @@ public: { } + void changePropertyWaveUpdate(); + // 绘图类型-变密度(成像) void initWave(QString strSlfName, QString strWaveName); + // 绘图类型-波形 void initWave2(QString strSlfName, QString strWaveName); @@ -29,6 +32,8 @@ public: void setSchemeIndex(int nidx, int colorNum); double** getWavedata(int nrow, int ncol); QCPColorMap * updateWave(); + + float getScaleV(); protected: //virtual void mouseMoveEvent(QMouseEvent *event); @@ -75,13 +80,16 @@ public: double** m_wavedata = NULL; int m_nRow = 0; int m_nCol = 0; + int m_nDrawType = 3; // 绘图类型 // 0.全周 1.正半周 2.负半周 int m_nMode = 1; - float m_fScaleV = 264.0f; + float m_fScaleV = 0.0f; float m_fmin; float m_fmax; int m_nColorNum = 256; int m_nSchemeIndex = 1; + int m_nWaveJg = 100; + int m_nWaveHei = 1; public: //分段刷新 QVector m_x;