diff --git a/CallManage/CallManage.h b/CallManage/CallManage.h index 4cd1823..8bf132e 100644 --- a/CallManage/CallManage.h +++ b/CallManage/CallManage.h @@ -146,6 +146,9 @@ signals: void sig_changeWidth(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, int iCurrentCol, int iNewWidth); //改变道属性 void sig_changeTrackProperty(QVariantList vlist); + + //改变Draw属性 + void sig_changeDrawProperty(QVariantList vlist); //右键--添加分段线 void sig_AddShiftLine(QString strUuid, double left_Low, double right_Hight); diff --git a/logPlus/PropertyWidget.cpp b/logPlus/PropertyWidget.cpp index ba8351c..f0ef65c 100644 --- a/logPlus/PropertyWidget.cpp +++ b/logPlus/PropertyWidget.cpp @@ -67,6 +67,7 @@ void PropertyWidget::InitCurrentViewInfo() m_mapGroupItem.clear(); m_fromTop = NULL; + m_formInfo = NULL; m_item = NULL; m_strUuid = ""; m_strSlfName = ""; @@ -117,6 +118,38 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant } return; } + else if (m_strCurrentProperty == Wave_Property) + { + bool bDraw = false; + QStringList slist; + slist << "显示名称" << "显示单位" << "曲线名称" << "曲线单位" << "曲线刻度" + << "左刻度" << "右刻度" << "幅度刻度" << "最大振幅" << "显示刻度"; + for (int i = 0; i < slist.length(); i++) + { + if (slist.at(i) == m_propertyData[pProperty]) + { + bDraw = m_formInfo->setInfoProperty(m_propertyData[pProperty], variant); + break; + } + } + + if(!slist.contains(m_propertyData[pProperty])) + bDraw = true; + + if (bDraw) + { + QVariantList listCond; + listCond << m_strUuid; + listCond << m_strSlfName; + listCond << m_strWellName; + listCond << m_strTrackName; + listCond << m_strLineName; + listCond << m_propertyData[pProperty]; + listCond << variant; + emit CallManage::getInstance()->sig_changeDrawProperty(listCond); + } + return; + } if("深度比例尺" == m_propertyData[pProperty]) { //qDebug() << "深度比例尺->改变"; @@ -881,9 +914,6 @@ void PropertyWidget::initCurveProperty(FormInfo *formInfo, QStringList strListOt m_listMax.append(listMax); m_strListOtherScaleType.append(strListOtherScaleType); - //当前属性类型 - m_strCurrentProperty = Curve_Property; - QStringList listStyle; listStyle.append("无"); listStyle.append("实线"); @@ -944,6 +974,9 @@ void PropertyWidget::initCurveProperty(FormInfo *formInfo, QStringList strListOt } _CreateVariantPropertyItem("岩性填充", "岩性前景色", formInfo->m_frontColor, QVariant::Color); _CreateVariantPropertyItem("岩性填充", "岩性背景色", formInfo->m_backColor, QVariant::Color); + + //当前属性类型 + m_strCurrentProperty = Curve_Property; } @@ -1009,6 +1042,9 @@ void PropertyWidget::initProperty(FormInfo *formInfo) //初始化,清空 InitCurrentViewInfo(); + + m_formInfo = formInfo; + m_strUuid = formInfo->m_strUuid; // @@ -1025,7 +1061,10 @@ void PropertyWidget::initProperty(FormInfo *formInfo) { this->initRoseProperty(formInfo); } - + else if (formInfo->m_strType == "waveObject") + { + this->initWaveProperty(formInfo); + } } void PropertyWidget::initRoseProperty(FormInfo *formInfo) @@ -1058,3 +1097,70 @@ void PropertyWidget::initRoseProperty(FormInfo *formInfo) // _CreateVariantPropertyItem("玫瑰图", "道头字颜色", fromTop->m_fontColor, QVariant::Color); } +void PropertyWidget::initWaveProperty(FormInfo *formInfo) +{ + _CreateVariantPropertyItem("通常", "选择井曲线", m_strLineName + "@" + m_strSlfName, QVariant::String); + _CreateVariantPropertyItem("通常", "显示名称", formInfo->m_strLineName, QVariant::String); + //_CreateVariantPropertyItem("通常", "例区高度(cm)", formInfo->m_strUnit, QVariant::Double); + QStringList lineType; + lineType.append("线性"); + lineType.append("对数"); + lineType.append("核磁对数"); + lineType.append("二维核磁"); + lineType.append("色级图"); + lineType.append("时间对数"); + lineType.append("时间指数"); + _CreateEnumPropertyItem("通常", "曲线类型", lineType.indexOf("线性"), lineType); + + _CreateVariantPropertyItem("曲线单位", "显示单位", formInfo->m_strUnit, QVariant::String); + + _CreateVariantPropertyItem("字体", "曲线名称", formInfo->m_curveNameFont, QVariant::Font); + _CreateVariantPropertyItem("字体", "曲线单位", formInfo->m_curveUnitFont, QVariant::Font); + _CreateVariantPropertyItem("字体", "曲线刻度", formInfo->m_curveScaleFont, QVariant::Font); + + QStringList drawType; + drawType.append("波形"); + drawType.append("填充"); + drawType.append("变密度(成像)"); + drawType.append("全阵列"); + drawType.append("奇数阵列"); + drawType.append("偶数阵列"); + drawType.append("变密度(镜像)"); + drawType.append("自选阵列"); + drawType.append("三维图像"); + drawType.append("多臂井径"); + _CreateEnumPropertyItem("绘图类型", "类型", drawType.indexOf(formInfo->m_strDrawType), drawType); + + QStringList fillType; + fillType.append("全周"); + fillType.append("正半周"); + fillType.append("负半周"); + _CreateEnumPropertyItem("填充方式", "方式", fillType.indexOf(formInfo->m_strFillType), fillType); + + //_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); + + //_CreateVariantPropertyItem("成像显示", "RGBA数据", false, QVariant::Bool); + //_CreateVariantPropertyItem("成像显示", "绘制阵列数", 1, QVariant::Int); + //_CreateVariantPropertyItem("成像显示", "是否顶底倒置", false, QVariant::Bool); + //_CreateVariantPropertyItem("成像显示", "是否行列互换", false, QVariant::Bool); + //_CreateVariantPropertyItem("成像显示", "无效值跳过", false, QVariant::Bool); + //_CreateVariantPropertyItem("成像显示", "是否方位校正", false, QVariant::Bool); + //_CreateVariantPropertyItem("成像显示", "是否深度校正", false, QVariant::Bool); + //_CreateVariantPropertyItem("成像显示", "是否自动计算波参数", "", QVariant::String); + +// _CreateVariantPropertyItem("调色板参数设置", "色板", false, QVariant::Bool); +// _CreateVariantPropertyItem("调色板参数设置", "变密度颜色级数", 256, QVariant::Int); +// _CreateVariantPropertyItem("调色板参数设置", "图例置顶", false, QVariant::Bool); +// _CreateVariantPropertyItem("调色板参数设置", "反转显示", false, QVariant::Bool); + + m_strCurrentProperty = Wave_Property; +} + diff --git a/logPlus/PropertyWidget.h b/logPlus/PropertyWidget.h index e83140b..7e9b3e9 100644 --- a/logPlus/PropertyWidget.h +++ b/logPlus/PropertyWidget.h @@ -25,6 +25,7 @@ #define Well_Property "Well_Property" //井 #define Track_Property "Track_Property" //道 #define Curve_Property "Curve_Property" //曲线 +#define Wave_Property "Wave_Property" //波列 #define Head_Property "Head_Property" //图头,单元格 #pragma execution_character_set("utf-8") @@ -67,8 +68,8 @@ public: QList m_listMax; QStringList m_strListOtherScaleType; - FormTrackTop* m_fromTop = NULL; - + FormTrackTop* m_fromTop = NULL; + FormInfo * m_formInfo = NULL; FormHead *m_formHead; QTableWidget *m_tableWidget; QTableWidgetItem* m_item; @@ -103,8 +104,10 @@ public: void initDepthProperty(FormInfo *formInfo); void initProperty(FormInfo *formInfo); - + // 玫瑰图属性 void initRoseProperty(FormInfo *formInfo); + // 波列属性 + void initWaveProperty(FormInfo *formInfo); void ChangFillProperty();//填充属性改变 diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index e7f27f6..aebff72 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -806,7 +806,10 @@ void FormDraw::s_addWave(QString strUuid, QString strSlfName, QString strWellNam //curv->setMaximumHeight((int)dHight); //curv->setViewport(QRect(0, 0, g_iOneWidth, (int)dHight));//7500-3184 - curv->setGeometry(0, 0, g_iOneWidth, (int)dHight);//7500-3184 + int nW = m_nTrackW; + if (nW < 0) + nW = g_iOneWidth; + curv->setGeometry(0, 0, nW, (int)dHight);//7500-3184 //curv->resize(INT_MAX, INT_MAX); // 使用 INT_MAX 来避免16位整数的限制 @@ -831,7 +834,7 @@ void FormDraw::s_addWave(QString strUuid, QString strSlfName, QString strWellNam m_listWaveName.push_back(strWaveName); QString strAliasName = ""; - QString strUnit = ""; + QString strUnit = "mv"; QColor newlineColor=QColor(0,0,0); double width=2; QString strScaleType = ""; @@ -2573,7 +2576,7 @@ void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWa _Rlev = _wave.DepLevel; int m_Record=(float)(fabs((_EDep-_SDep)/_Rlev+0.5)); - _nSamples = _wave.TimeSamples; + _nSamples = _wave.TimeSamples; char *value=new char[(_nSamples+1)*m_Record*_wave.CodeLen+1]; logio->ReadWave(index,_SDep,m_Record,(void *)value); @@ -2584,15 +2587,15 @@ void FormDraw::initWave(QMyCustomPlot *widget, QString strSlfName, QString strWa float vmax = -9999;//(float)_nSamples; float vmin = -9999; // - double** wavedata; - wavedata = new double*[_nSamples]; - for(int kk = 0;kk<_nSamples;kk++){ - wavedata[kk] = new double[m_Record]; - } + 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; ixAxis = yAxis; widget->yAxis = xAxis; - //------------------- - // set up the QCPColorMap: - QCPColorMap *colorMap = new QCPColorMap(widget->xAxis, widget->yAxis); - 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实例来分配一些数据: - double x, y, z; - for (int xIndex=0; xIndexdata()->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]); - } - } + 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(); + - // 添加色标: - 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; isetGradient(gradient); - // 重新缩放数据维度(颜色),以使所有数据点都位于颜色渐变显示的范围内: - colorMap->rescaleDataRange(); } void FormDraw::initWave_3D(QMyCustomPlot *widget, QString strSlfName, QString strWaveName, int &_nSamples) diff --git a/logPlus/forminfo.cpp b/logPlus/forminfo.cpp index 26cfc35..aaed0bc 100644 --- a/logPlus/forminfo.cpp +++ b/logPlus/forminfo.cpp @@ -59,6 +59,12 @@ FormInfo::FormInfo(QWidget *parent, QString strSlfName, QString strWellName, QSt //修改曲线选择状态 iSelect=0未知,1标准曲线,2主曲线,3从曲线 connect(CallManage::getInstance(), SIGNAL(sig_ChangeLineStatus(QString, QString, QString, QString, QString, int, bool)), this, SLOT(s_ChangeLineStatus(QString, QString, QString, QString, QString, int, bool))); + QFont font1("微软雅黑", 10); + QFont font2("微软雅黑", 8); + m_curveNameFont = font1; // 曲线名称 + m_curveUnitFont = font2; // 曲线单位 + m_curveScaleFont = font2; // 曲线刻度 + m_bShowScale = true; } FormInfo::~FormInfo() @@ -171,8 +177,7 @@ void FormInfo::paintEvent(QPaintEvent* event) painter.drawRect(rectRound); painter.setBrush(Qt::NoBrush); // 确保文字不被填充色遮挡 - QFont font1("微软雅黑", 10, false, false); //fontSize 10 - painter.setFont(font1); + painter.setFont(m_curveNameFont); painter.setPen(m_lineColor); // fontColor QColor(220, 220, 220) //painter.drawText(rect.left() + 20, 30, m_strAliasName); // titleBarText QStringLiteral("动画") //painter.drawText(rect, Qt::AlignCenter, m_strAliasName); @@ -277,8 +282,7 @@ void FormInfo::paintEvent(QPaintEvent* event) } } - QFont font2("微软雅黑", 8, false, false); - painter.setFont(font2); + painter.setFont(m_curveUnitFont); painter.setPen(m_lineColor); //painter.drawText(rect.left() + 20, 55, m_strUnit); //painter.drawText(rect.left() + 20, 80, QString::number(m_vmin)+" ~ "+QString::number(m_vmax)); @@ -342,7 +346,17 @@ void FormInfo::paintEvent(QPaintEvent* event) if(m_strType=="waveObject" || m_strType=="curveObject") { - painter.drawText(rect.left(), rect.top()+rect.height()*2/3, rect.width(), rect.height()/3 ,Qt::AlignCenter, QString::number(m_vmin)+" ~ "+QString::number(m_vmax)); + painter.drawText(rect.left()+10, rect.top() + rect.height() * 2 / 3, rect.width(), rect.height() / 3, Qt::AlignCenter, m_strUnit); + + // 显示刻度 + if (m_bShowScale) + { + painter.setFont(m_curveScaleFont); + QFontMetrics fm1(m_curveScaleFont); + QRect textRect = fm1.boundingRect(QString::number(m_vmax, 'f', 0)); + painter.drawText(rect.left() + 10, rect.top() + rect.height() * 2 / 3, rect.width(), rect.height() / 3, Qt::AlignLeft | Qt::AlignVCenter, QString::number(m_vmin));// +" ~ " + QString::number(m_vmax)); + painter.drawText(rect.left() + 10, rect.top() + rect.height() * 2 / 3, rect.width() - textRect.width(), rect.height() / 3, Qt::AlignRight | Qt::AlignVCenter, QString::number(m_vmax)); + } } } @@ -500,6 +514,55 @@ QColor FormInfo::getBackColor() return m_backColor; } +bool FormInfo::setInfoProperty(QString strProName, QVariant val) +{ + bool bDraw = false; + if ("显示名称" == strProName) + { + this->m_strLineName = val.toString(); + } + else if ("显示单位" == strProName) + { + this->m_strUnit = val.toString(); + } + else if ("曲线名称" == strProName) + { + this->m_curveNameFont = val.value(); + } + else if ("曲线单位" == strProName) + { + this->m_curveUnitFont = val.value(); + } + else if ("曲线刻度" == strProName) + { + this->m_curveScaleFont = val.value(); + } + else if ("左刻度" == strProName) + { + bDraw = true; + this->m_vmin = val.toDouble(); + } + else if ("右刻度" == strProName) + { + bDraw = true; + this->m_vmax = val.toDouble(); + } + else if ("幅度刻度" == strProName) + { + this->m_strAmp = val.toString(); + } + else if ("最大振幅" == strProName) + { + this->m_fMaxAmp = val.toFloat(); + } + else if ("显示刻度" == strProName) + { + this->m_bShowScale = val.toBool(); + } + this->update(); + return bDraw; +} + //修改曲线选择状态 iSelect=0未知,1标准曲线,2主曲线,3从曲线 void FormInfo::s_ChangeLineStatus(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int iSelect, bool bMerge) { @@ -640,3 +703,4 @@ void FormInfo::s_ChangeFillMode(QString strUuid, QString strSlfName, QString str } } + diff --git a/logPlus/forminfo.h b/logPlus/forminfo.h index 2ee081a..5017fd9 100644 --- a/logPlus/forminfo.h +++ b/logPlus/forminfo.h @@ -78,6 +78,10 @@ public: float m_vmax;//右刻度 QString m_strScaleType;//刻度类型(线性,对数) + QFont m_curveNameFont; // 曲线名称 + QFont m_curveUnitFont; // 曲线单位 + QFont m_curveScaleFont; // 曲线刻度 + //岩性填充 QString m_newHeadFill;//头部图例 QString m_newTargetLine;//目标曲线 @@ -93,6 +97,13 @@ public: int m_nJg; + + QString m_strDrawType; // 绘图类型 + QString m_strFillType; // 填充类型 + QString m_strAmp; // 幅度刻度 + float m_fMaxAmp; // 最大振幅 + bool m_bShowScale; // 显示刻度 + public: void setLineWidth(double dWidth); double getLineWidth(); @@ -112,6 +123,8 @@ public: void setBackColor(QColor backColor); QColor getBackColor(); + bool setInfoProperty(QString strProName, QVariant val); + QJsonObject makeJson(); //public: @@ -133,4 +146,5 @@ private: QPoint startPosition; }; + #endif // FORMINFO_H diff --git a/logPlus/formtrack.cpp b/logPlus/formtrack.cpp index 6a3b988..3c8ea6a 100644 --- a/logPlus/formtrack.cpp +++ b/logPlus/formtrack.cpp @@ -321,8 +321,8 @@ void FormTrack::s_addWave(QString strSlfName, QString strWellName, QString strTr //ui->tableWidget->resize(g_iOneWidth, 100*(row + 1)+10); //this->resize(g_iOneWidth, 100*(row + 1)+30); - //曲线信息栏 - FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor); + //波列信息栏 + FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor); formInfo->m_strUuid = m_strUuid; formInfo->m_strAliasName = strAliasName; formInfo->m_strUnit = strUnit; @@ -331,8 +331,12 @@ void FormTrack::s_addWave(QString strSlfName, QString strWellName, QString strTr formInfo->setLineWidth(dWidth); formInfo->setVMax(vmax); formInfo->setVMin(vmin); - formInfo->setFrontColor(QColor(0,0,0)); - formInfo->setBackColor(QColor(255,255,255)); + + formInfo->m_curveNameFont = QFont("黑体", 12); + formInfo->m_curveUnitFont = QFont("黑体", 10); + formInfo->m_curveScaleFont = QFont("黑体", 10); + formInfo->m_fMaxAmp = 1023.0f; + //设置高度 ui->tableWidget->setRowHeight(row, 100); //单元格委托 @@ -340,17 +344,6 @@ void FormTrack::s_addWave(QString strSlfName, QString strWellName, QString strTr // ui->tableWidget->setCellWidget(row, 0, formInfo); - - //------------------------------------ -// QFont font("微软雅黑", 10, QFont::Bold, false); -// // -// QTableWidgetItem* item = new QTableWidgetItem(strLineName); -// item->setFlags(item->flags() & (~Qt::ItemIsEditable)); -// item->setForeground(QBrush(lineColor));// 设置字体颜色 -// item->setFont(font); // 应用新的字体 -// item->setTextAlignment(Qt::AlignCenter);//居中 -// // -// ui->tableWidget->setItem(row, 0, item); } void FormTrack::s_AddTableLine(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType) diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 64d6254..05996ae 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -91,6 +91,74 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel //Plot重新加载数据 connect(CallManage::getInstance(), SIGNAL(sig_ReloadPlot(QString, QString, QString)), this, SLOT(s_ReloadPlot(QString, QString, QString))); + + connect(CallManage::getInstance(), SIGNAL(sig_changeDrawProperty(QVariantList)), this, SLOT(s_changeDrawProperty(QVariantList))); +} + +double** QMyCustomPlot::getWavedata(int nrow, int ncol) +{ + if (nrow > 0 && m_wavedata) + { + for (int i = 0; i < m_nRow; i++) + { + if (m_wavedata[i]) + { + delete[] m_wavedata[i]; + } + } + delete[] m_wavedata; + m_wavedata = NULL; + } + m_nRow = nrow; + m_nCol = ncol; + m_wavedata = new double*[nrow]; + for (int kk = 0; kk < nrow; kk++) { + m_wavedata[kk] = new double[ncol]; + } + return m_wavedata; +} + +QCPColorMap * QMyCustomPlot::updateWave() +{ + int nx = m_nCol; + int ny = m_nRow; + + // :现在,我们通过访问颜色贴图的QCPColorMapData实例来分配一些数据: + double x, y, z; + for (int xIndex = 0; xIndex < nx; ++xIndex) + { + for (int yIndex = 0; yIndex < ny; ++yIndex) + { + double dz = m_wavedata[yIndex][xIndex]; + if (m_nMode == 0) + { + if (m_wavedata[yIndex][xIndex] == -9999) + { + dz = m_fmax; + } + } + else if (m_nMode == 1) + { + if (m_wavedata[yIndex][xIndex] == -9999) + { + dz = m_fmin; + } + } + else if (m_nMode == 2) + { + if (m_wavedata[yIndex][xIndex] == -9999) + { + dz = m_fmax; + } + else + { + dz = m_fmin; + } + } + m_colorMap->data()->setCell(nx - xIndex - 1, yIndex, dz); + } + } + return m_colorMap; } //蝌蚪图,重绘网格线 @@ -702,6 +770,44 @@ void QMyCustomPlot::s_ReloadPlot(QString strUuid, QString strSlfName, QString st replot(QCustomPlot::rpQueuedReplot); //刷新曲线 } +void QMyCustomPlot::s_changeDrawProperty(QVariantList vlist) +{ + QString strUuid = vlist.at(0).toString(); + QString strSlfName = vlist.at(1).toString(); + QString strWellName = vlist.at(2).toString(); + QString strTrackName = vlist.at(3).toString(); + QString strLineName = vlist.at(4).toString(); + + if (m_strUuid == strUuid && + m_strSlfName == strSlfName && + m_strWellName == strWellName && + m_strTrackName == strTrackName && + m_strLineName == strLineName) + { + QString strProperty = vlist.at(5).toString(); + QString strValue = vlist.at(6).toString(); + if ("方式" == strProperty) + { + m_nMode = strValue.toFloat(); + this->updateWave(); + this->replot(); + } + else if ("左刻度" == strProperty) + { + + } + else if ("右刻度" == strProperty) + { + if (m_colorMap) + { + float f = 264 / strValue.toFloat(); + m_colorMap->data()->setValueRange(QCPRange(m_fmin, m_fmax*f)); + this->replot(); + } + } + } +} + void QMyCustomPlot::addLineToPlot(double left_Low, double right_Hight, const QString strText, QColor crColor) { QtCommonClass *qtCommon = new QtCommonClass(this); diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index b6e0602..1ac6b08 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -20,6 +20,8 @@ public: { } + double** getWavedata(int nrow, int ncol); + QCPColorMap * updateWave(); protected: //virtual void mouseMoveEvent(QMouseEvent *event); @@ -61,7 +63,15 @@ public: bool singleDragMove = false; float singleOldPosition = 0; - + QCPColorMap *m_colorMap = NULL; + QCPColorScale * m_colorScale = NULL; + double** m_wavedata = NULL; + int m_nRow = 0; + int m_nCol = 0; + // 0.全周 1.正半周 2.负半周 + int m_nMode = 1; + float m_fmin; + float m_fmax; public: //分段刷新 QVector m_x; @@ -171,6 +181,8 @@ public slots: //Plot重新加载数据 void s_ReloadPlot(QString strUuid, QString strSlfName, QString strLineName); + void s_changeDrawProperty(QVariantList vlist); + void onAddRect(); //蝌蚪图重绘网格线