From 945436e7d9c49adb2126d1617d1c3abb3caad349 Mon Sep 17 00:00:00 2001 From: jiayulong Date: Wed, 22 Apr 2026 15:14:50 +0800 Subject: [PATCH 1/7] =?UTF-8?q?1.=E6=9D=86=E7=8A=B6=E5=9B=BE=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E8=BF=BD=E5=8A=A0=202.=E6=94=AF=E6=8C=81=E4=BB=8Ejson?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=8A=A0=E8=BD=BD=E6=9D=86=E7=8A=B6=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CallManage/CallManage.h | 4 + logPlus/PropertyWidget.cpp | 114 +++++++++++- logPlus/PropertyWidget.h | 5 + logPlus/formdraw.cpp | 344 ++++++++++-------------------------- logPlus/formdraw.h | 6 +- logPlus/forminfo.cpp | 118 ++++++++++++- logPlus/forminfo.h | 2 + logPlus/formtrack.cpp | 39 ++++ logPlus/formtrack.h | 1 + logPlus/mainwindowcurve.cpp | 2 +- logPlus/qmycustomplot.cpp | 175 +++++++++++++++++- logPlus/qmycustomplot.h | 6 + 12 files changed, 547 insertions(+), 269 deletions(-) diff --git a/CallManage/CallManage.h b/CallManage/CallManage.h index 8833b3b..4d2b71d 100644 --- a/CallManage/CallManage.h +++ b/CallManage/CallManage.h @@ -265,6 +265,10 @@ signals: //改变蝌蚪图属性 void sig_changeKedouProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); + + //改变杆状图属性 + void sig_changeGanzhuangProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); + // //void sig_addImageToPlot(QMyCustomPlot* customPlot, double left_Low, double right_Hight, QString imagePath); diff --git a/logPlus/PropertyWidget.cpp b/logPlus/PropertyWidget.cpp index da75902..52429c8 100644 --- a/logPlus/PropertyWidget.cpp +++ b/logPlus/PropertyWidget.cpp @@ -2371,7 +2371,13 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant // changedKedouProperty(m_propertyData[pProperty], variant); } - + else if (m_strCurrentProperty == Ganzhuang_Property)//杆状图 + { + //先处理通用属性 + CommonPropertyChanged(pProperty, variant); + // + changedGanzhuangProperty(m_propertyData[pProperty], variant); + } } @@ -3198,6 +3204,11 @@ void PropertyWidget::initProperty(FormInfo *formInfo) //蝌蚪图 this->initKedouProperty(formInfo); } + else if (m_strLineName == "GANZHUANG.LINE") + { + //杆状图 + this->initGanzhuangProperty(formInfo); + } else { this->initTableProperty(formInfo); @@ -5247,8 +5258,6 @@ void PropertyWidget::changedKedouProperty(QString strProperty, QVariant varVal) if ("名称" == strProperty) { QFont newFont = varVal.value(); -// this->m_formInfo->m_strAliasNameFont = newFont; -// this->m_formInfo->repaint(); m_formInfo->m_curveNameFont = newFont; m_formInfo->update(); } @@ -5319,11 +5328,13 @@ void PropertyWidget::changedKedouProperty(QString strProperty, QVariant varVal) else if ("最小倾角" == strProperty) { this->m_formInfo->m_pl_minInclination = varVal.toDouble(); + this->m_formInfo->repaint(); flag = true; } else if ("最大倾角" == strProperty) { this->m_formInfo->m_pl_maxInclination = varVal.toDouble(); + this->m_formInfo->repaint(); flag = true; } else if ("可信度1" == strProperty) @@ -5444,3 +5455,100 @@ void PropertyWidget::changedKedouProperty(QString strProperty, QVariant varVal) emit CallManage::getInstance()->sig_changeKedouProperty(m_formInfo->m_strUuid, m_formInfo->m_strSlfName, m_formInfo->m_strWellName, m_formInfo->m_strTrackName, m_formInfo->m_strLineName); } } + + +void PropertyWidget::initGanzhuangProperty(FormInfo *formInfo) +{ + + _CreateVariantPropertyItem("曲线图名", "显示名称", formInfo->m_strAliasName, QVariant::String); + _CreateVariantPropertyItem("井文件名", "井文件名称", m_strSlfName, QVariant::String); + + // + _CreateVariantPropertyItem("曲线选择", "方位曲线", formInfo->m_pl_azimuthCurve, QVariant::String); + _CreateVariantPropertyItem("曲线选择", "倾角曲线", formInfo->m_pl_inclinationCurve, QVariant::String); + _CreateVariantPropertyItem("曲线选择", "可信度曲线", formInfo->m_pl_GradCurve, QVariant::String); + // + _CreateVariantPropertyItem("倾角刻度", "最小倾角", formInfo->m_pl_minInclination, QVariant::Double); + _CreateVariantPropertyItem("倾角刻度", "最大倾角", formInfo->m_pl_maxInclination, QVariant::Double); + // + _CreateVariantPropertyItem("可信度", "可信度1", formInfo->m_flGrad1, QVariant::Double); + _CreateVariantPropertyItem("可信度", "可信度2", formInfo->m_flGrad2, QVariant::Double); + // + _CreateVariantPropertyItem("曲线单位", "显示单位", formInfo->m_strUnit, QVariant::String); + // + _CreateVariantPropertyItem("杆设置", "线长度", formInfo->m_nTailLen, QVariant::Double); + _CreateVariantPropertyItem("杆设置", "线宽度", formInfo->m_nTailWidth, QVariant::Double); + _CreateVariantPropertyItem("杆设置", "线颜色", formInfo->m_crTail, QVariant::Color); + + m_strCurrentProperty = Ganzhuang_Property; +} + +void PropertyWidget::changedGanzhuangProperty(QString strProperty, QVariant varVal) +{ + bool flag = false; + + if ("方位曲线" == strProperty) + { + this->m_formInfo->m_pl_azimuthCurve = varVal.toString(); + flag = true; + } + else if ("倾角曲线" == strProperty) + { + this->m_formInfo->m_pl_inclinationCurve = varVal.toString(); + flag = true; + } + else if ("可信度曲线" == strProperty) + { + this->m_formInfo->m_pl_GradCurve = varVal.toString(); + flag = true; + } + // 杆 + else if ("线长度" == strProperty) + { + this->m_formInfo->m_nTailLen = varVal.toDouble(); + flag = true; + } + else if ("线宽度" == strProperty) + { + this->m_formInfo->m_nTailWidth = varVal.toDouble(); + flag = true; + } + else if ("线颜色" == strProperty) + { + this->m_formInfo->m_crTail = varVal.value(); + flag = true; + } + // + else if ("最小倾角" == strProperty) + { + this->m_formInfo->m_pl_minInclination = varVal.toDouble(); + this->m_formInfo->repaint(); + flag = true; + } + else if ("最大倾角" == strProperty) + { + this->m_formInfo->m_pl_maxInclination = varVal.toDouble(); + this->m_formInfo->repaint(); + flag = true; + } + else if ("可信度1" == strProperty) + { + this->m_formInfo->m_flGrad1 = varVal.toDouble(); + flag = true; + } + else if ("可信度2" == strProperty) + { + this->m_formInfo->m_flGrad2 = varVal.toDouble(); + flag = true; + } + else if ("显示单位" == strProperty) + { + this->m_formInfo->m_strUnit = varVal.toString(); + this->m_formInfo->repaint(); + } + + if(flag) + { + emit CallManage::getInstance()->sig_changeGanzhuangProperty(m_formInfo->m_strUuid, m_formInfo->m_strSlfName, m_formInfo->m_strWellName, m_formInfo->m_strTrackName, m_formInfo->m_strLineName); + } +} diff --git a/logPlus/PropertyWidget.h b/logPlus/PropertyWidget.h index e81e14e..45a2b16 100644 --- a/logPlus/PropertyWidget.h +++ b/logPlus/PropertyWidget.h @@ -78,6 +78,7 @@ #define TubingItem_Property "TubingItem_Property" //套管组件item #define Kedou_Property "Kedou_Property" //蝌蚪图 +#define Ganzhuang_Property "Ganzhuang_Property" //杆状图 #pragma execution_character_set("utf-8") @@ -262,6 +263,10 @@ public: void initKedouProperty(FormInfo *formInfo); void changedKedouProperty(QString strProName, QVariant val); + //杆状图 + void initGanzhuangProperty(FormInfo *formInfo); + void changedGanzhuangProperty(QString strProName, QVariant val); + public slots: void SlotPropertyChanged(QtProperty *property, const QVariant &variant); void SlotPropertyChanged(QtProperty *property, const int &val, bool islinestyle); diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index e1bac3b..927b4e0 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -59,7 +59,7 @@ FormDraw::FormDraw(QWidget *parent, QString strSlfName, QString strWellName, QSt connect(CallManage::getInstance(), SIGNAL(sig_AddTableLine(QString, QString, QString, QString, QString)), this, SLOT(s_addTableLine(QString, QString, QString, QString, QString))); connect(CallManage::getInstance(), SIGNAL(sig_delTableLine(QString, QString, QString, QString)), this, SLOT(s_delTableLine(QString, QString, QString, QString))); - connect(CallManage::getInstance(), SIGNAL(sig_AddGanZhuangTu(QString, QString, QString, QString, QString, int)), this, SLOT(s_addGanZuangTu(QString, QString, QString, QString, QString,int))); + connect(CallManage::getInstance(), SIGNAL(sig_AddGanZhuangTu(QString, QString, QString, QString, QString, int)), this, SLOT(s_addGanZhuangTu(QString, QString, QString, QString, QString,int))); //井眼垮塌矢量图 connect(CallManage::getInstance(), SIGNAL(sig_AddJykt(QString, QString, QString, QString, QString, int)), this, SLOT(s_addJykt(QString, QString, QString, QString, QString,int))); @@ -536,9 +536,9 @@ void FormDraw::DisplayLines(QJsonArray linesArray) // 岩心照片 displayImageData(lineObjInfo); } - else if (strLineName == "FRAC_HOLE.TABLE") + else if (strLineName == "FRAC_HOLE.TABLE" || strLineName == "GANZHUANG.LINE") { - // 蝌蚪图 + // 蝌蚪图、杆状图 DisplayKedou_One(lineObjInfo); } } @@ -1194,15 +1194,9 @@ void FormDraw::DisplayKedou_One(QJsonObject lineObjInfo) if (strLineName != "") { - /* - QVariantMap variantMap; - // 数据 - variantMap["AliasName"] = strAliasName; - variantMap["curveNameFont"] = curveNameFont;*/ - - //结论 + //蝌蚪图、杆状 this->addKedou(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName, lineObjInfo); - } + } } //气测/FMT/射孔/文本 @@ -2908,14 +2902,6 @@ QMyCustomPlot* FormDraw::addTableLine(QString strUuid, QString strSlfName, QStri if (strLineName == "FRAC_HOLE.TABLE") { //蝌蚪图 - curv->mKedou = true; - //隐藏网格 - curv->xAxis->grid()->setVisible(false); - curv->yAxis->grid()->setVisible(false); - // - curv->m_bRowGridVisible = false; - curv->m_bColGridVisible = false; - // initKedou(curv, strSlfName, strLineName); } else if (strLineName == "WORDS_RELUST") @@ -3032,13 +3018,9 @@ QMyCustomPlot* FormDraw::addTableLine(QString strUuid, QString strSlfName, QStri QMyCustomPlot* FormDraw::addKedou(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QJsonObject listOtherProperty) { - if (strLineName == "FRAC_HOLE.TABLE" || strLineName == "WORDS_RELUST" || strLineName == "RESULT" - || strLineName == "GEO_LITH" || strLineName == "SWALL_CORE" - || strLineName == "GUJING1_RESULT" || strLineName == "GUJING2_RESULT" || strLineName == "GUJING3_RESULT" - || strLineName == "CORE_PHYSICS" || strLineName == "IMAGE_DATA" - || strLineName == "LAYER_DATA" ) + //蝌蚪、杆状 + if (strLineName == "FRAC_HOLE.TABLE" || strLineName == "GANZHUANG.LINE") { - } else { @@ -3070,14 +3052,6 @@ QMyCustomPlot* FormDraw::addKedou(QString strUuid, QString strSlfName, QString s if (strLineName == "FRAC_HOLE.TABLE") { //蝌蚪图 - curv->mKedou = true; - //隐藏网格 - curv->xAxis->grid()->setVisible(false); - curv->yAxis->grid()->setVisible(false); - // - curv->m_bRowGridVisible = false; - curv->m_bColGridVisible = false; - QString strAliasName = "蝌蚪图"; QColor newlineColor=QColor(0,0,0); // 显示名称 @@ -3092,6 +3066,23 @@ QMyCustomPlot* FormDraw::addKedou(QString strUuid, QString strSlfName, QString s // initKedou(curv, strSlfName, strLineName, strAliasName, newlineColor, listOtherProperty); } + else if(strLineName == "GANZHUANG.LINE") + { + QString strAliasName = "杆状图"; + QColor newlineColor=QColor(0,0,0); + // 显示名称 + // 显示名称 + if (listOtherProperty.contains("AliasName")) + { + QJsonValue value = listOtherProperty.value("AliasName"); + if (value.isString()) { + strAliasName = value.toString(); + } + } + // + initGanzhuang(curv, strSlfName, strLineName, strAliasName, newlineColor, listOtherProperty); + } + connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*))); // m_listLineName.push_back(strLineName); @@ -3716,9 +3707,8 @@ void FormDraw::s_selectionRectAccepted(const QRect &rect, QMouseEvent *event) // double y2 = widget->yAxis->pixelToCoord(rect.bottom()); } -void FormDraw::s_addGanZuangTu(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW) +void FormDraw::s_addGanZhuangTu(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW) { - //井名&道名不一致 if(strUuid == m_strUuid && m_strWellName == strWellName && m_strTrackName == strTrackName) { @@ -3741,100 +3731,17 @@ void FormDraw::s_addGanZuangTu(QString strUuid, QString strSlfName, QString strW curv->m_strUuid = m_strUuid; curv->setDepthY(m_iY1, m_iY2); curv->initGeometry(m_strUuid, m_iScale, g_iOneWidth); - curv->show(); + //杆状图 + initGanzhuang(curv, strSlfName, strLineName); - //////////////////////////////////////// - m_Value=NULL; - m_Value2=NULL; - m_Value3=NULL; - m_bTableData=0;//表格或曲线 - //m_csCurveDDIR="DDIR"; - //m_csCurveDANG="DANG"; - //m_csCurveGrad="GRAD"; - m_nTailWidth=2; - m_crTail=qRgb(0,0,0); - m_crPointFill=qRgb(0,0,0); - - m_crGridSmall=qRgb(100,100,100); - m_nRadius = 6; - m_nTailLen = 10; - m_nCircleWidth=1; - m_flGrad1 = 10; - m_flGrad2 = 50; - - //Table dip - m_qsTable="FRAC_HOLE.TABLE"; - m_qsDIR=("DIR"); // 方位 曲线名 - m_qsDIP=("DIPorS");//倾角 - m_qsDepth="DEP"; - m_qsID = "ID"; - m_qsProperty=("ID"); - m_iPrecision = 3; - - //读数据 - m_csCurveDDIR = "DDIR"; // 方位 曲线名 - m_csCurveDANG = "DANG";//倾角 - m_csCurveGrad = "GRAD"; - this->ReadData(strSlfName, m_csCurveDDIR, 0, &m_Curve); - this->ReadData(strSlfName, m_csCurveDANG, 1, &m_Curve2); - this->ReadData(strSlfName, m_csCurveGrad, 2, &m_Curve3); - curv->yAxis->setTickLabels(true); - curv->yAxis->setTickLabelSide(QCPAxis::lsInside); - QFont font1("微软雅黑", 16); //fontSize 10 - curv->yAxis->setTickLabelFont(font1); - // - // curv->xAxis->ticker()->setTickCount(10);//x个主刻度 - // curv->yAxis->ticker()->setTickCount(60);//y个主刻度 - int iMyWidth = curv->axisRect(0)->width(); - float vmax = iMyWidth; - float vmin = 0; - curv->setScaleX(vmin, vmax); - curv->axisRect()->setupFullAxesBox(); - // - curv->xAxis->ticker()->setTickCount(10);//x个主刻度 - curv->yAxis->ticker()->setTickCount(60);//y个主刻度 - - //对调XY轴,在最前面设置 - QCPAxis *yAxis = curv->yAxis; - QCPAxis *xAxis = curv->xAxis; - curv->xAxis = yAxis; - curv->yAxis = xAxis; - - - m_LeftVal = 0; - m_RightVal = 90; - //隐藏刻度 - curv->xAxis->setTicks(false); - curv->yAxis->setTicks(false); - curv->xAxis2->setTicks(false); - curv->yAxis2->setTicks(false); - curv->xAxis->setVisible(false); - curv->xAxis2->setVisible(false); - curv->yAxis->setVisible(false); - curv->yAxis2->setVisible(false); - //蝌蚪图 - // curv->mKedou = true; - //隐藏网格 - // curv->xAxis->grid()->setVisible(false); - // curv->yAxis->grid()->setVisible(false); - DrawStck(curv); - - - //道-对象 - QString strAliasName = "杆状图"; - QString strUnit = ""; - QColor newlineColor=QColor(0,0,0); - double width=2; - QString strScaleType = ""; - //道-对象 - m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "ganzhuangtuObject"); // connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*))); m_listLineName.push_back(strLineName); } + void FormDraw::s_addJykt(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW) { //井名&道名不一致 @@ -5156,6 +5063,15 @@ void FormDraw::DrawImageNew_NoFilter(QMyCustomPlot *widget, QString strSlfName, //蝌蚪图 void FormDraw::initKedou(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName, QColor newlineColor, QJsonObject listOtherProperty) { + widget->mKedou = true; + + //隐藏网格 + widget->xAxis->grid()->setVisible(false); + widget->yAxis->grid()->setVisible(false); + // + widget->m_bRowGridVisible = false; + widget->m_bColGridVisible = false; + int iMyWidth = widget->axisRect(0)->width(); float vmax = iMyWidth; float vmin = 0; @@ -5185,7 +5101,7 @@ void FormDraw::initKedou(QMyCustomPlot *widget, QString strSlfName, QString strL widget->yAxis2->setVisible(false); //----------------------------------- - QString strUnit = ""; + QString strUnit = "(°)"; double width=2; QString strScaleType = ""; //道-对象 @@ -5193,8 +5109,59 @@ void FormDraw::initKedou(QMyCustomPlot *widget, QString strSlfName, QString strL //蝌蚪图 widget->Draw_Kedou(); +} +//杆状图 +void FormDraw::initGanzhuang(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName, QColor newlineColor, QJsonObject listOtherProperty) +{ + //隐藏网格 + widget->xAxis->grid()->setVisible(false); + widget->yAxis->grid()->setVisible(false); + // + widget->m_bRowGridVisible = false; + widget->m_bColGridVisible = false; + int iMyWidth = widget->axisRect(0)->width(); + float vmax = iMyWidth; + float vmin = 0; + + widget->setScaleX(vmin, iMyWidth); + 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; + + m_LeftVal = 0; + m_RightVal = 90; + //隐藏刻度 + widget->xAxis->setTicks(false); + widget->yAxis->setTicks(false); + widget->xAxis2->setTicks(false); + widget->yAxis2->setTicks(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); + + //----------------------------------- + QString strUnit = "(°)"; + double width=2; + QString strScaleType = ""; + if(!listOtherProperty.isEmpty()) + { + strUnit = listOtherProperty["Unit"].toString(); // 单位 + } + //道-对象 + FormInfo* pInfo = m_formTrack->AddGanzhuang(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject", listOtherProperty); + + //杆状图 + widget->Draw_Ganzhuang(); } void FormDraw::initWords(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName, QColor newlineColor, QStringList listOtherProperty) @@ -6796,139 +6763,6 @@ void FormDraw::DrawDenv(QMyCustomPlot *widget, QString strSlfName) } } -void FormDraw::DrawStck(QMyCustomPlot *widget) -{ - float flWidth[50]; - int l; - float dep; - int m_nScaleThinGrid=10; - float lstk=2; - float dang,ddir; - float dg,dy,dx; - // 计算位置 - int iMyWidth = widget->axisRect(0)->width(); - float x1 = 0; - float x2 = iMyWidth; - float x=0,y=0; - int j=0,i=0,k=0; - float flTemp=0; - for(int i=0;i<50;i++) flWidth[i]=0; - CalcDipWidth(m_nScaleThinGrid, flWidth, 1.2, x1, x2, 1.); - - - QPen pPen(m_crTail,m_nTailWidth); - QBrush cBrushFill(m_crPointFill); - - float flDepthScale,tempf,flVal; - int nPointNum=0,tempi; - QRectF rt,rtRect; - float dgtord,dr; - for(int i=0;i<50;i++) flWidth[i]=0; - if(m_Value==0 || m_Value2==0) - { - Refurbish(); - } - if ( m_Value==0 || m_Value2==0 ) - return ; - - dgtord=3.14159265/180.; - - CalcDipWidth(9, flWidth, 1.2, 0, iMyWidth, 1); - - - while ( 1) - { - dep = m_SDep + k * m_Rlev; - if ( dep >m_EDep ) - break; - - if(dep m_RightVal || flVal < m_LeftVal ) - { - k++; - continue; - } - - tempi = (int)( flVal /10.); - - tempf = 0.; - for (j=0; jsetPen(pPen);// [5/22/2019 9:43 hxb] - // rtRect.setLeft(x - GetLineWidth(pDC,m_nRadius)); - // rtRect.setRight(x + GetLineWidth(pDC,m_nRadius)); - // rtRect.setBottom(y +GetLineWidth(pDC,m_nRadius)); - // rtRect.setTop(y -GetLineWidth(pDC,m_nRadius)); - // pDC->setPen(PenCircle); - // pDC->drawEllipse(rtRect.center(),m_nRadius,m_nRadius); - - // QCPItemEllipse *qcpItemEllipse = new QCPItemEllipse(widget); - // qcpItemEllipse->setPen(pPen); - // qcpItemEllipse->m_bCustom = true; - // qcpItemEllipse->m_nRadius = m_nRadius; - // qcpItemEllipse->topLeft->setCoords(y, x);//圆心位置 - // qcpItemEllipse->bottomRight->setCoords(y, x);//圆心位置 - // qcpItemEllipse->setBrush(cBrushFill);//填充圆的颜色 - - - //方位 - dang = GetData(m_Curve.RepCode,(char *)&m_Value[i*m_Curve.CodeLen]);//DDIR - dr=dang*dgtord; - //dx=abs(lstk*cos(dr)); - // dy=sqrt(lstk*lstk*(1-cos(dr)*cos(dr))); - // // 注意映射方式 - // x +=GetLineWidth(pDC,m_nRadius)*sin(dr); - // y -=GetLineWidth(pDC,m_nRadius)*cos(dr); - // float x1=x +GetLineWidth(pDC,m_nTailLen)*sin(dr); - // float y1=y -GetLineWidth(pDC,m_nTailLen)*cos(dr); - // pDC->setPen(pPen); - // pDC->drawLine(QPointF(x,y),QPointF(x1,y1)); - - QCPItemLine *qcpItemLine = new QCPItemLine(widget); - qcpItemLine->start->setCoords(y, x);//圆心位置 - qcpItemLine->end->setCoords(y, x);//圆心位置 - qcpItemLine->setPen(pPen); - qcpItemLine->m_bCustom = true; - qcpItemLine->m_nTailLen = m_nSltk; //杆长 - qcpItemLine->m_nRadius = 0; //半径 - qcpItemLine->m_dr = dr; - QCPItemLine *qcpItemLine1 = new QCPItemLine(widget); - qcpItemLine1->start->setCoords(y, x);//圆心位置 - qcpItemLine1->end->setCoords(y, x);//圆心位置 - qcpItemLine1->setPen(pPen); - qcpItemLine1->m_bCustom = true; - qcpItemLine1->m_nTailLen = m_nSltk; //杆长 - qcpItemLine1->m_nRadius = 0; //半径 - qcpItemLine1->m_dr = dr+PI; - - //移动对象 - // widget->mSizeHandleManager->addItem(qcpItemEllipse, true); - // widget->mSizeHandleManager->addItem(qcpItemLine, true); - - k++; - } -} - //read config file: FRAC.CFG,save info into m_FracDef void FormDraw::ReadFracDef() diff --git a/logPlus/formdraw.h b/logPlus/formdraw.h index 0bba313..c04a2d6 100644 --- a/logPlus/formdraw.h +++ b/logPlus/formdraw.h @@ -150,10 +150,12 @@ public: //表格曲线 void initKedou(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName = "蝌蚪图", QColor newlineColor=QColor(0,0,0), QJsonObject listOtherProperty={}); + void initGanzhuang(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName = "杆状图", QColor newlineColor=QColor(0,0,0), QJsonObject listOtherProperty={}); + void ReadFracDef(); void ReadData(QString strSlfName, QString strLineName);//表格 void ReadData(QString strSlfName, QString strLineName, int iCurve, Slf_CURVE *curve);//曲线 - void DrawStck(QMyCustomPlot *widget); + void CalcDipWidth(int nColumn,float *flWidth,float factor,int x1,int x2,float flHoriRatio); void Refurbish(); void DrawJykt(QMyCustomPlot *widget, QString strSlfName); @@ -255,7 +257,7 @@ public slots: void s_handleRectRangeChange(QCPRange newRange); void s_selectionRectAccepted(const QRect &rect, QMouseEvent *event); - void s_addGanZuangTu(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW);//杆状图 + void s_addGanZhuangTu(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW);//杆状图 //井眼垮塌矢量图 void s_addJykt(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW); //井斜方位图 diff --git a/logPlus/forminfo.cpp b/logPlus/forminfo.cpp index 43679c8..71658ec 100644 --- a/logPlus/forminfo.cpp +++ b/logPlus/forminfo.cpp @@ -127,8 +127,8 @@ void FormInfo::initProperty_Kedou(QJsonObject obj) // 显示控制 this->m_pl_minInclination = 0; // 最小倾角 this->m_pl_maxInclination = 360; // 最大倾角 - this->m_flGrad1 = 10; // 可信度1 - this->m_flGrad2 = 50; // 可信度2 + this->m_flGrad1 = 1; // 可信度1 + this->m_flGrad2 = 5; // 可信度2 // 显示控制(数据表) this->m_crack_decimal_digits = 2; // 小数位数 @@ -212,6 +212,59 @@ void FormInfo::initProperty_Kedou(QJsonObject obj) } } +void FormInfo::initProperty_Ganzhuang(QJsonObject obj) +{ + if(obj.isEmpty()) + { + // 字体 + + // 曲线选择 + this->m_pl_azimuthCurve = "DDIR"; // 方位曲线 + this->m_pl_inclinationCurve = "DANG"; // 倾角曲线 + this->m_pl_GradCurve = "GRAD"; // 可信度曲线 + + //杆 + this->m_nTailLen = 15; // 尾线长度 + this->m_nTailWidth = 2; // 尾线宽度 + + // 显示控制 + this->m_pl_minInclination = 0; // 最小倾角 + this->m_pl_maxInclination = 90; // 最大倾角 + this->m_flGrad1 = 10; // 可信度1 + this->m_flGrad2 = 50; // 可信度2 + // + this->m_strUnit = "(°)"; + } + else + { + QString strType = obj.value("Type").toString(); + if ("tableObject" == strType) + { + // 字体 + // 名称 + this->m_curveNameFont.fromString(obj["curveNameFont"].toString()); + + // 曲线选择 + this->m_pl_azimuthCurve = obj["m_pl_azimuthCurve"].toString(); // 方位曲线 + this->m_pl_inclinationCurve = obj["m_pl_inclinationCurve"].toString(); // 倾角曲线 + this->m_pl_GradCurve = obj["m_pl_GradCurve"].toString(); // 可信度曲线 + + //杆 + this->m_nTailLen = obj["m_nTailLen"].toDouble(); // 尾线长度 + this->m_nTailWidth = obj["m_nTailWidth"].toDouble(); // 尾线宽度 + this->m_crTail.setNamedColor(obj["m_crTail"].toString());// 尾线颜色 + + // 显示控制 + this->m_pl_minInclination = obj["m_pl_minInclination"].toDouble(); // 最小倾角 + this->m_pl_maxInclination = obj["m_pl_maxInclination"].toDouble(); // 最大倾角 + this->m_flGrad1 = obj["m_flGrad1"].toDouble(); // 可信度1 + this->m_flGrad2 = obj["m_flGrad2"].toDouble(); // 可信度2 + // + this->m_strUnit = obj["Unit"].toString(); // 单位 + } + } +} + void FormInfo::initProperty(QJsonObject obj) { m_vmin = obj.value("vmin").toDouble(); @@ -484,7 +537,6 @@ QJsonObject FormInfo::makeJson() { //蝌蚪图 // 字体 - //rootObj["m_strAliasNameFont"] = this->m_strAliasNameFont.toString(); // 名称 rootObj["m_strUnitFont"] = this->m_strUnitFont.toString(); // 单位 rootObj["m_pl_fontScale"] = this->m_pl_fontScale.toString(); // 刻度 // 数据类型选择 @@ -530,6 +582,29 @@ QJsonObject FormInfo::makeJson() rootObj["m_pl_custom2"] = this->m_pl_custom2; // 自定义2 return rootObj; } + else if (m_strLineName == "GANZHUANG.LINE") + { + //杆状图 + // 字体 + rootObj["m_strUnitFont"] = this->m_strUnitFont.toString(); // 单位 + rootObj["m_pl_fontScale"] = this->m_pl_fontScale.toString(); // 刻度 + // 曲线选择 + rootObj["m_pl_azimuthCurve"] = this->m_pl_azimuthCurve; // 方位曲线 + rootObj["m_pl_inclinationCurve"] = this->m_pl_inclinationCurve; // 倾角曲线 + rootObj["m_pl_GradCurve"] = this->m_pl_GradCurve; // 可信度曲线 + //杆 + rootObj["m_nTailLen"] = this->m_nTailLen; // 尾线长度 + rootObj["m_nTailWidth"] = this->m_nTailWidth; // 尾线宽度 + rootObj["m_crTail"] = this->m_crTail.name(); // 尾线颜色 + // 显示控制 + rootObj["m_pl_minInclination"] = this->m_pl_minInclination; // 最小倾角 + rootObj["m_pl_maxInclination"] = this->m_pl_maxInclination; // 最大倾角 + rootObj["m_flGrad1"] = this->m_flGrad1; // 可信度1 + rootObj["m_flGrad2"] = this->m_flGrad2; // 可信度2 + //单位 + rootObj["Unit"] = m_strUnit; + return rootObj; + } } else if (m_strType == "JiegutextObject") { @@ -1229,6 +1304,21 @@ void FormInfo::paintEvent(QPaintEvent* event) 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)); } + //蝌蚪图、杆状图 + if(m_strLineName == "FRAC_HOLE.TABLE" || m_strLineName=="GANZHUANG.LINE") + { + int nbay = rect.height() - 5; + + // 显示刻度 + if (m_bShowScale) + { + drawScale_Kedou(painter, rect); + } + QFontMetrics fm2(m_curveUnitFont); + QRect tRect = fm2.boundingRect(m_strUnit); + painter.drawText(rect.width()/2- tRect.width()/2, nbay - 6, m_strUnit); + } + if(m_strLineName == "深度") { QFont oldFont = painter.font(); @@ -1575,6 +1665,28 @@ void FormInfo::drawScale(QPainter& painter, const QRect& rect) } } +void FormInfo::drawScale_Kedou(QPainter& painter, const QRect& rect) +{ + int nbay = rect.height() - 5; + QVector vecScale; + + vecScale << QStringList({ QString::number(m_pl_minInclination) , QString::number(m_pl_maxInclination) }); + + painter.setFont(m_curveScaleFont); + QFontMetrics fm1(m_curveScaleFont); + QRect textRect = fm1.boundingRect(QString::number(m_pl_minInclination, 'f', 0)); + int ntxthei = textRect.height() - 4; + int nyy = nbay - ntxthei * vecScale.size() - 3; + for (int i = 0; i < vecScale.size(); i++) + { + const QStringList& slist = vecScale.at(i); + QRect textRect = fm1.boundingRect(slist.at(1)); + int y = nyy + (i + 1) * ntxthei; + painter.drawText(rect.x() + 3, y, slist.at(0)); + painter.drawText(rect.width() - textRect.width() - 3, y, slist.at(1)); + } +} + void FormInfo::paintClassify(QPainter &painter, int compassCenterY) { // 绘制分类 diff --git a/logPlus/forminfo.h b/logPlus/forminfo.h index ffdd2b3..795caef 100644 --- a/logPlus/forminfo.h +++ b/logPlus/forminfo.h @@ -27,6 +27,7 @@ public: void initProperty(QJsonObject obj); void initProperty_Kedou(QJsonObject obj); + void initProperty_Ganzhuang(QJsonObject obj); void paintClassify(QPainter &painter, int compassCenterY); private: @@ -37,6 +38,7 @@ protected: // 绘制刻度 void drawScale(QPainter& painter, const QRect& rect); + void drawScale_Kedou(QPainter& painter, const QRect& rect); public slots: void dragEnterEvent(QDragEnterEvent* event); diff --git a/logPlus/formtrack.cpp b/logPlus/formtrack.cpp index 6b99167..a16cd8b 100644 --- a/logPlus/formtrack.cpp +++ b/logPlus/formtrack.cpp @@ -347,6 +347,45 @@ FormInfo* FormTrack::AddKedou(QString strSlfName, QString strWellName, QString s ui->tableWidget->setRowHeight(row, 100); // ui->tableWidget->setCellWidget(row, 0, formInfo); + return formInfo; +} + +FormInfo* FormTrack::AddGanzhuang(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty) +{ + if(strLineName == "GANZHUANG.LINE") + { + + } + else + { + return nullptr; + } + + qDebug() << "FormTrack AddGanzhuang"; + + ui->tableWidget->m_strUuid = m_strUuid; + int row = ui->tableWidget->rowCount(); + ui->tableWidget->setRowCount(row + 1); + + //曲线信息栏 + FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor); + formInfo->m_strUuid = m_strUuid; + //formInfo->m_strUnit = strUnit; + formInfo->initProperty_Ganzhuang(listOtherProperty); + formInfo->m_strAliasName = strAliasName; + formInfo->m_strScaleType = strScaleType; + formInfo->m_strType = "tableObject"; + formInfo->setLineWidth(dWidth); + formInfo->setVMax(vmax); + formInfo->setVMin(vmin); + formInfo->setFrontColor(QColor(0,0,0)); + formInfo->setBackColor(QColor(255,255,255)); + + //设置高度 + ui->tableWidget->setRowHeight(row, 100); + // + ui->tableWidget->setCellWidget(row, 0, formInfo); + return formInfo; } FormInfo* FormTrack::setDrawDt(QStringList listdt, QJsonObject obj) diff --git a/logPlus/formtrack.h b/logPlus/formtrack.h index 5bc18f1..2d248c3 100644 --- a/logPlus/formtrack.h +++ b/logPlus/formtrack.h @@ -45,6 +45,7 @@ public: public: void Add(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QStringList listOtherProperty={}); FormInfo* AddKedou(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty={}); + FormInfo* AddGanzhuang(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty={}); FormInfo* setDrawDt(QStringList listdt, QJsonObject obj); diff --git a/logPlus/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index e2a51bc..7457fe4 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -3667,7 +3667,7 @@ void MainWindowCurve::s_NewGanZhuangTu() QString strSlfName = sret.at(1); //新建道 - emit CallManage::getInstance()->sig_NewTrack(m_strUuid, strWellName, strSlfName, "杆状图", "ganzhuangtuObject", nW); + emit CallManage::getInstance()->sig_NewTrack(m_strUuid, strWellName, strSlfName, "GANZHUANG.LINE", "ganzhuangtuObject", nW); } void MainWindowCurve::s_roseAc() diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 30cbe69..18a7c58 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -215,6 +215,8 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel connect(CallManage::getInstance(), SIGNAL(sig_changeGuanD(QString, QString, QString, QString, QString, QString, double)), this, SLOT(s_changeGuanD(QString, QString, QString, QString, QString, QString, double))); //改变蝌蚪图属性 connect(CallManage::getInstance(), SIGNAL(sig_changeKedouProperty(QString, QString, QString, QString, QString)), this, SLOT(s_changeKedouProperty(QString, QString, QString, QString, QString))); + //改变杆状图属性 + connect(CallManage::getInstance(), SIGNAL(sig_changeGanzhuangProperty(QString, QString, QString, QString, QString)), this, SLOT(s_changeGanzhuangProperty(QString, QString, QString, QString, QString))); } void QMyCustomPlot::initGeometry(QString strUuid, int nscale, double fW) @@ -11977,10 +11979,6 @@ void QMyCustomPlot::Draw_Kedou() if (m_bTableData) { ReadFracDef_gaodaofeng(); -// for (int i = 0 ; i < iFracType ; i++) -// { -// m_bTypeDraw[i] = true; -// } ReadData(m_strSlfName, m_strLineName); } else @@ -12247,7 +12245,8 @@ void QMyCustomPlot::DrawDip_Kedou() } bool bFillBrush = true; - if ( m_Value3!=NULL)// && m_Value3 !=0xcdcdcdcd ) + //可信度 + if ( m_Value3!=NULL) { flVal = GetData(m_Curve3.RepCode,(char *)&m_Value3[i*m_Curve3.CodeLen]);//置信度 if ( flVal < m_flGrad1 ) @@ -12337,3 +12336,169 @@ void QMyCustomPlot::s_changeKedouProperty(QString strUuid, QString strSlfName, Q //绘制蝌蚪图 Draw_Kedou(); } + +//改变杆状图属性 +void QMyCustomPlot::s_changeGanzhuangProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName) +{ + if(m_strUuid == strUuid && + m_strSlfName == strSlfName && + m_strWellName == strWellName && + m_strTrackName == strTrackName && + m_strLineName == strLineName) + { + + } + else + { + return; + } + //绘制杆状图 + Draw_Ganzhuang(); +} + +void QMyCustomPlot::Draw_Ganzhuang() +{ + this->clearItems(); + + // + FormInfo* pInfo = m_formTrack->getFormInfoByParameters(m_strUuid, m_strWellName, m_strTrackName, m_strLineName); + if (pInfo == NULL) + { + return; + } + + //----------------------------------- + this->m_Value=NULL; + this->m_Value2=NULL; + this->m_Value3=NULL; + // 曲线选择 + this->m_csCurveDDIR = pInfo->m_pl_azimuthCurve; // 方位 曲线名 + this->m_csCurveDANG = pInfo->m_pl_inclinationCurve;//倾角 + this->m_csCurveGrad = pInfo->m_pl_GradCurve; // 可信度曲线 + //蝌蚪符号 + this->m_nTailLen = pInfo->m_nTailLen; // 尾线长度 + this->m_nTailWidth = pInfo->m_nTailWidth; // 尾线宽度 + this->m_crTail = pInfo->m_crTail; // 尾线颜色 + + // 显示控制 + this->m_pl_minInclination = pInfo->m_pl_minInclination; // 最小倾角 + this->m_pl_maxInclination = pInfo->m_pl_maxInclination; // 最大倾角 + this->m_flGrad1 = pInfo->m_flGrad1; //可信度1 + this->m_flGrad2 = pInfo->m_flGrad2; //可信度2 + + //读数据 + this->ReadData(m_strSlfName, m_csCurveDDIR, 0, &m_Curve); + this->ReadData(m_strSlfName, m_csCurveDANG, 1, &m_Curve2); + this->ReadData(m_strSlfName, m_csCurveGrad, 2, &m_Curve3); + + float flWidth[50]; + int l; + float dep; + int m_nScaleThinGrid=10; + float lstk=2; + float dang,ddir; + float dg,dy,dx; + // 计算位置 + int iMyWidth = this->axisRect(0)->width(); + float x1 = 0; + float x2 = iMyWidth; + float x=0,y=0; + int j=0,i=0,k=0; + float flTemp=0; + for(int i=0;i<50;i++) flWidth[i]=0; + CalcDipWidth(m_nScaleThinGrid, flWidth, 1.2, x1, x2, 1.); + + + QPen pPenTail(m_crTail,m_nTailWidth); + + float flDepthScale,tempf,flVal; + int nPointNum=0,tempi; + QRectF rt,rtRect; + float dgtord,dr; + for(int i=0;i<50;i++) flWidth[i]=0; + if(m_Value==0 || m_Value2==0) + { + Refurbish(); + } + if ( m_Value==0 || m_Value2==0 ) + return ; + + dgtord=3.14159265/180.; + + CalcDipWidth(9, flWidth, 1.2, 0, iMyWidth, 1); + + + while ( 1) + { + dep = m_SDep + k * m_Rlev; + if ( dep >m_EDep ) + break; + + if(dep m_flGrad2 ) + { + k++; + continue; + } + } + + flVal = GetData(m_Curve2.RepCode,(char *)&m_Value2[i*m_Curve2.CodeLen]);//DANG + if ( flVal > m_pl_maxInclination || flVal < m_pl_minInclination ) + { + k++; + continue; + } + + tempi = (int)( flVal /10.); + + tempf = 0.; + for (j=0; jstart->setCoords(y, x);//圆心位置 + qcpItemLine->end->setCoords(y, x);//圆心位置 + qcpItemLine->setPen(pPenTail); + qcpItemLine->m_bCustom = true; + qcpItemLine->m_nTailLen = m_nTailLen/2.0; //杆长 + qcpItemLine->m_nRadius = 0; //半径 + qcpItemLine->m_dr = dr; + // + QCPItemLine *qcpItemLine1 = new QCPItemLine(this); + qcpItemLine1->start->setCoords(y, x);//圆心位置 + qcpItemLine1->end->setCoords(y, x);//圆心位置 + qcpItemLine1->setPen(pPenTail); + qcpItemLine1->m_bCustom = true; + qcpItemLine1->m_nTailLen = m_nTailLen/2.0; //杆长 + qcpItemLine1->m_nRadius = 0; //半径 + qcpItemLine1->m_dr = dr+PI; + + k++; + } + this->replot(); +} diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index d09d6fc..d544d27 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -677,6 +677,9 @@ public slots: //改变蝌蚪图属性 void s_changeKedouProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); + //改变杆状图属性 + void s_changeGanzhuangProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); + public: //蝌蚪图重绘网格线 bool mKedou = false; @@ -748,6 +751,9 @@ public: void ReadFracDef_gaodaofeng(); + //杆状图 + void Draw_Ganzhuang(); + private: }; From f729823ed3de5095123bb37bd03f9f08f2f8ce9d Mon Sep 17 00:00:00 2001 From: "DESKTOP-450PEFP\\mainc" Date: Wed, 22 Apr 2026 17:28:35 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=9B=BA=E4=BA=95=E7=BB=93=E8=AE=BA?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=BD=91=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logPlus/PropertyWidget.cpp | 6 +++--- logPlus/customtabwidget.cpp | 18 +++++++++++++++--- logPlus/formdraw.cpp | 2 ++ logPlus/formtracktop.cpp | 6 ++++++ logPlus/formtracktop.h | 2 +- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/logPlus/PropertyWidget.cpp b/logPlus/PropertyWidget.cpp index 7acbe2a..633b84d 100644 --- a/logPlus/PropertyWidget.cpp +++ b/logPlus/PropertyWidget.cpp @@ -611,7 +611,7 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant if("道名称" == m_propertyData[pProperty]) { - m_fromTop->m_strTrackName = variant.toString(); + m_fromTop->setTrackName(variant.toString()); } else if("道头字体" == m_propertyData[pProperty]) { @@ -2811,8 +2811,8 @@ void PropertyWidget::initTrackProperty(FormTrackTop *fromTop, int iWidth, QMyTab _CreateVariantPropertyItem("通常", "道头字体", fromTop->m_font, QVariant::Font); _CreateVariantPropertyItem("通常", "道头字颜色", fromTop->m_fontColor, QVariant::Color); // -// _CreateVariantPropertyItem("网格", "水平", fromTop->m_nTrackW, QVariant::Bool); -// _CreateVariantPropertyItem("网格", "垂直", fromTop->m_nTrackW, QVariant::Bool); + _CreateVariantPropertyItem("网格", "水平", fromTop->m_nTrackW, QVariant::Bool); + _CreateVariantPropertyItem("网格", "垂直", fromTop->m_nTrackW, QVariant::Bool); // _CreateVariantPropertyItem("网格", "道左刻度", fromTop->m_nTrackW, QVariant::Double); // _CreateVariantPropertyItem("网格", "道右刻度", fromTop->m_nTrackW, QVariant::Double); // _CreateVariantPropertyItem("网格", "同步修改曲线刻度", fromTop->m_nTrackW, QVariant::Double); diff --git a/logPlus/customtabwidget.cpp b/logPlus/customtabwidget.cpp index c19a358..aa11a1e 100644 --- a/logPlus/customtabwidget.cpp +++ b/logPlus/customtabwidget.cpp @@ -44,9 +44,21 @@ CustomTabWidget::~CustomTabWidget() void CustomTabWidget::addTab(QWidget *widget, const QString &strTab) { - int iIndex = m_pTabBar->addTab(strTab); - m_pStackedWidget->addWidget(widget); - widget->setAcceptDrops(true); + int iIndex = -1; + for (int i = 0; i < m_pStackedWidget->count(); i++) + { + if (m_pStackedWidget->widget(i) == widget) + { + iIndex = i; + break; + } + } + if (iIndex < 0) + { + iIndex = m_pTabBar->addTab(strTab); + m_pStackedWidget->addWidget(widget); + widget->setAcceptDrops(true); + } // m_pTabBar->setCurrentIndex(iIndex); } diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index a35e309..2d46aa4 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -2903,6 +2903,8 @@ QMyCustomPlot* FormDraw::addTableLine(QString strUuid, QString strSlfName, QStri } else if (strLineName == "GUJING1_RESULT" || strLineName == "GUJING2_RESULT" || strLineName == "GUJING3_RESULT") { + curv->setRowGridVisible(false); + curv->setColGridVisible(false); //固井结论 if(listOtherProperty.size()>=3) { diff --git a/logPlus/formtracktop.cpp b/logPlus/formtracktop.cpp index 7188e17..9e8b5fd 100644 --- a/logPlus/formtracktop.cpp +++ b/logPlus/formtracktop.cpp @@ -33,6 +33,12 @@ FormTrackTop::~FormTrackTop() delete ui; } +void FormTrackTop::setTrackName(QString strTName) +{ + m_strTrackName = strTName; + update(); +} + // void FormTrackTop::setBorderFlags(BorderFlags flags) // { // m_BorderFlags = flags; diff --git a/logPlus/formtracktop.h b/logPlus/formtracktop.h index 1bfdf8b..927e34b 100644 --- a/logPlus/formtracktop.h +++ b/logPlus/formtracktop.h @@ -23,7 +23,7 @@ class FormTrackTop : public FormBase public: explicit FormTrackTop(QWidget*, QString strSlfName="", QString strWellName="", QString strTrackName="", QString strLineName="", QColor lineColor=QColor(255,0,0)); ~FormTrackTop(); - + void setTrackName(QString strTName); void setTrackTopPropert(QJsonObject topObj); private: Ui::FormTrackTop *ui; From 008191977ca72736582fa544cf1bcb7cadae5ad1 Mon Sep 17 00:00:00 2001 From: jiayulong Date: Wed, 22 Apr 2026 18:13:03 +0800 Subject: [PATCH 3/7] =?UTF-8?q?1.=E8=BF=BD=E5=8A=A0=E4=BA=95=E7=9C=BC?= =?UTF-8?q?=E5=9E=AE=E5=A1=8C=E7=9F=A2=E9=87=8F=E5=9B=BE=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=202.=E6=94=AF=E6=8C=81json=E6=A8=A1=E6=9D=BF=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CallManage/CallManage.h | 3 + logPlus/PropertyWidget.cpp | 134 ++++++++++++++++++++- logPlus/PropertyWidget.h | 7 +- logPlus/formdraw.cpp | 226 +++++++++++++----------------------- logPlus/formdraw.h | 6 +- logPlus/forminfo.cpp | 110 +++++++++++++++++- logPlus/forminfo.h | 12 +- logPlus/formtrack.cpp | 40 ++++++- logPlus/formtrack.h | 4 + logPlus/mainwindowcurve.cpp | 42 ++----- logPlus/qmycustomplot.cpp | 166 ++++++++++++++++++++++++-- logPlus/qmycustomplot.h | 11 ++ 12 files changed, 560 insertions(+), 201 deletions(-) diff --git a/CallManage/CallManage.h b/CallManage/CallManage.h index 4d2b71d..ca5c73e 100644 --- a/CallManage/CallManage.h +++ b/CallManage/CallManage.h @@ -269,6 +269,9 @@ signals: //改变杆状图属性 void sig_changeGanzhuangProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); + //改变井眼垮塌矢量图属性 + void sig_changeJyktProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); + // //void sig_addImageToPlot(QMyCustomPlot* customPlot, double left_Low, double right_Hight, QString imagePath); diff --git a/logPlus/PropertyWidget.cpp b/logPlus/PropertyWidget.cpp index d3dd1c5..a126f75 100644 --- a/logPlus/PropertyWidget.cpp +++ b/logPlus/PropertyWidget.cpp @@ -2378,7 +2378,13 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant // changedGanzhuangProperty(m_propertyData[pProperty], variant); } - + else if (m_strCurrentProperty == Jykt_Property)//井眼垮塌矢量图 + { + //先处理通用属性 + CommonPropertyChanged(pProperty, variant); + // + changedJyktProperty(m_propertyData[pProperty], variant); + } } void PropertyWidget::SlotPropertyChanged(QtProperty *property, const int &val, bool islinestyle) @@ -3209,6 +3215,11 @@ void PropertyWidget::initProperty(FormInfo *formInfo) //杆状图 this->initGanzhuangProperty(formInfo); } + else if (m_strLineName == "JINGYANKUATA.LINE") + { + //井眼垮塌矢量图 + this->initJyktProperty(formInfo); + } else { this->initTableProperty(formInfo); @@ -5210,7 +5221,6 @@ void PropertyWidget::changedRoseProperty(QString strProperty, QVariant varVal) void PropertyWidget::initKedouProperty(FormInfo *formInfo) { - _CreateVariantPropertyItem("曲线图名", "显示名称", formInfo->m_strAliasName, QVariant::String); _CreateVariantPropertyItem("字体", "名称", formInfo->m_curveNameFont, QVariant::Font); _CreateVariantPropertyItem("字体", "单位", formInfo->m_strUnitFont, QVariant::Font); @@ -5226,7 +5236,7 @@ void PropertyWidget::initKedouProperty(FormInfo *formInfo) _CreateVariantPropertyItem("曲线选择", "方位曲线", formInfo->m_pl_azimuthCurve, QVariant::String); _CreateVariantPropertyItem("曲线选择", "倾角曲线", formInfo->m_pl_inclinationCurve, QVariant::String); _CreateVariantPropertyItem("曲线选择", "可信度曲线", formInfo->m_pl_GradCurve, QVariant::String); - // + // _CreateVariantPropertyItem("蝌蚪符号", "圆半径", formInfo->m_nRadius, QVariant::Double); _CreateVariantPropertyItem("蝌蚪符号", "圆线宽度", formInfo->m_nCircleWidth, QVariant::Double); _CreateVariantPropertyItem("蝌蚪符号", "尾线长度", formInfo->m_nTailLen, QVariant::Double); @@ -5456,10 +5466,8 @@ void PropertyWidget::changedKedouProperty(QString strProperty, QVariant varVal) } } - void PropertyWidget::initGanzhuangProperty(FormInfo *formInfo) { - _CreateVariantPropertyItem("曲线图名", "显示名称", formInfo->m_strAliasName, QVariant::String); _CreateVariantPropertyItem("井文件名", "井文件名称", m_strSlfName, QVariant::String); @@ -5476,6 +5484,7 @@ void PropertyWidget::initGanzhuangProperty(FormInfo *formInfo) // _CreateVariantPropertyItem("曲线单位", "显示单位", formInfo->m_strUnit, QVariant::String); // + _CreateVariantPropertyItem("杆设置", "深度间隔", formInfo->m_flStep, QVariant::Double); _CreateVariantPropertyItem("杆设置", "线长度", formInfo->m_nTailLen, QVariant::Double); _CreateVariantPropertyItem("杆设置", "线宽度", formInfo->m_nTailWidth, QVariant::Double); _CreateVariantPropertyItem("杆设置", "线颜色", formInfo->m_crTail, QVariant::Color); @@ -5546,9 +5555,124 @@ void PropertyWidget::changedGanzhuangProperty(QString strProperty, QVariant varV this->m_formInfo->m_strUnit = varVal.toString(); this->m_formInfo->repaint(); } + else if ("深度间隔" == strProperty) + { + this->m_formInfo->m_flStep = varVal.toDouble(); + flag = true; + } if(flag) { emit CallManage::getInstance()->sig_changeGanzhuangProperty(m_formInfo->m_strUuid, m_formInfo->m_strSlfName, m_formInfo->m_strWellName, m_formInfo->m_strTrackName, m_formInfo->m_strLineName); } } + +void PropertyWidget::initJyktProperty(FormInfo *formInfo) +{ + _CreateVariantPropertyItem("曲线图名", "显示名称", formInfo->m_strAliasName, QVariant::String); + _CreateVariantPropertyItem("井文件名", "井文件名称", m_strSlfName, QVariant::String); + // + _CreateVariantPropertyItem("曲线选择", "方位曲线", formInfo->m_pl_azimuthCurve, QVariant::String); + _CreateVariantPropertyItem("曲线选择", "井径差曲线", formInfo->m_pl_deltaCurve, QVariant::String); + // + _CreateVariantPropertyItem("崩落设置", "左刻度", formInfo->m_vmin, QVariant::Double); + _CreateVariantPropertyItem("崩落设置", "右刻度", formInfo->m_vmax, QVariant::Double); + _CreateVariantPropertyItem("崩落设置", "深度间隔", formInfo->m_flStep, QVariant::Double); + _CreateVariantPropertyItem("崩落设置", "角度偏移", formInfo->m_nOffset, QVariant::Double); + _CreateVariantPropertyItem("崩落设置", "显示单位", formInfo->m_strUnit, QVariant::String); + // + _CreateVariantPropertyItem("蝌蚪设置", "圆半径", formInfo->m_nRadius, QVariant::Double); + _CreateVariantPropertyItem("蝌蚪设置", "圆线宽度", formInfo->m_nCircleWidth, QVariant::Double); + _CreateVariantPropertyItem("蝌蚪设置", "尾线长度", formInfo->m_nTailLen, QVariant::Double); + _CreateVariantPropertyItem("蝌蚪设置", "尾线宽度", formInfo->m_nTailWidth, QVariant::Double); + _CreateVariantPropertyItem("蝌蚪设置", "圆线颜色", formInfo->m_crCircle, QVariant::Color); + _CreateVariantPropertyItem("蝌蚪设置", "尾线颜色", formInfo->m_crTail, QVariant::Color); + _CreateVariantPropertyItem("蝌蚪设置", "圆填充色", formInfo->m_crPointFill, QVariant::Color); + + m_strCurrentProperty = Jykt_Property; +} + +void PropertyWidget::changedJyktProperty(QString strProperty, QVariant varVal) +{ + bool flag = false; + // 字体 + if ("方位曲线" == strProperty) + { + this->m_formInfo->m_pl_azimuthCurve = varVal.toString(); + flag = true; + } + else if ("井径差曲线" == strProperty) + { + this->m_formInfo->m_pl_deltaCurve = varVal.toString(); + flag = true; + } + // 蝌蚪符号 + else if ("圆半径" == strProperty) + { + this->m_formInfo->m_nRadius = varVal.toDouble(); + flag = true; + } + else if ("圆线宽度" == strProperty) + { + this->m_formInfo->m_nCircleWidth = varVal.toDouble(); + flag = true; + } + else if ("尾线长度" == strProperty) + { + this->m_formInfo->m_nTailLen = varVal.toDouble(); + flag = true; + } + else if ("尾线宽度" == strProperty) + { + this->m_formInfo->m_nTailWidth = varVal.toDouble(); + flag = true; + } + else if ("圆线颜色" == strProperty) + { + this->m_formInfo->m_crCircle = varVal.value(); + flag = true; + } + else if ("尾线颜色" == strProperty) + { + this->m_formInfo->m_crTail = varVal.value(); + flag = true; + } + else if ("圆填充色" == strProperty) + { + this->m_formInfo->m_crPointFill = varVal.value(); + flag = true; + } + // + else if ("左刻度" == strProperty) + { + this->m_formInfo->m_vmin = varVal.toDouble(); + this->m_formInfo->repaint(); + flag = true; + } + else if ("右刻度" == strProperty) + { + this->m_formInfo->m_vmax = varVal.toDouble(); + this->m_formInfo->repaint(); + flag = true; + } + else if ("深度间隔" == strProperty) + { + this->m_formInfo->m_flStep = varVal.toDouble(); + flag = true; + } + else if ("角度偏移" == strProperty) + { + this->m_formInfo->m_nOffset = varVal.toDouble(); + flag = true; + } + else if ("显示单位" == strProperty) + { + this->m_formInfo->m_strUnit = varVal.toString(); + this->m_formInfo->repaint(); + } + + if(flag) + { + emit CallManage::getInstance()->sig_changeJyktProperty(m_formInfo->m_strUuid, m_formInfo->m_strSlfName, m_formInfo->m_strWellName, m_formInfo->m_strTrackName, m_formInfo->m_strLineName); + } +} diff --git a/logPlus/PropertyWidget.h b/logPlus/PropertyWidget.h index 45a2b16..8e461c9 100644 --- a/logPlus/PropertyWidget.h +++ b/logPlus/PropertyWidget.h @@ -78,7 +78,8 @@ #define TubingItem_Property "TubingItem_Property" //套管组件item #define Kedou_Property "Kedou_Property" //蝌蚪图 -#define Ganzhuang_Property "Ganzhuang_Property" //杆状图 +#define Ganzhuang_Property "Ganzhuang_Property" //杆状图 +#define Jykt_Property "Jykt_Property" //井眼垮塌矢量图 #pragma execution_character_set("utf-8") @@ -267,6 +268,10 @@ public: void initGanzhuangProperty(FormInfo *formInfo); void changedGanzhuangProperty(QString strProName, QVariant val); + //井眼垮塌矢量图 + void initJyktProperty(FormInfo *formInfo); + void changedJyktProperty(QString strProName, QVariant val); + public slots: void SlotPropertyChanged(QtProperty *property, const QVariant &variant); void SlotPropertyChanged(QtProperty *property, const int &val, bool islinestyle); diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index b5212cd..9a79368 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -536,7 +536,7 @@ void FormDraw::DisplayLines(QJsonArray linesArray) // 岩心照片 displayImageData(lineObjInfo); } - else if (strLineName == "FRAC_HOLE.TABLE" || strLineName == "GANZHUANG.LINE") + else if (strLineName == "FRAC_HOLE.TABLE" || strLineName == "GANZHUANG.LINE" || strLineName == "JINGYANKUATA.LINE") { // 蝌蚪图、杆状图 DisplayKedou_One(lineObjInfo); @@ -1194,7 +1194,7 @@ void FormDraw::DisplayKedou_One(QJsonObject lineObjInfo) if (strLineName != "") { - //蝌蚪图、杆状 + //蝌蚪图、杆状、井眼垮塌矢量图 this->addKedou(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName, lineObjInfo); } } @@ -3020,8 +3020,8 @@ QMyCustomPlot* FormDraw::addTableLine(QString strUuid, QString strSlfName, QStri QMyCustomPlot* FormDraw::addKedou(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QJsonObject listOtherProperty) { - //蝌蚪、杆状 - if (strLineName == "FRAC_HOLE.TABLE" || strLineName == "GANZHUANG.LINE") + //蝌蚪、杆状、井眼垮塌矢量图 + if (strLineName == "FRAC_HOLE.TABLE" || strLineName == "GANZHUANG.LINE" || strLineName == "JINGYANKUATA.LINE") { } else @@ -3084,6 +3084,22 @@ QMyCustomPlot* FormDraw::addKedou(QString strUuid, QString strSlfName, QString s // initGanzhuang(curv, strSlfName, strLineName, strAliasName, newlineColor, listOtherProperty); } + else if(strLineName == "JINGYANKUATA.LINE") + { + QString strAliasName = "井眼崩落矢量图"; + QColor newlineColor=QColor(0,0,0); + // 显示名称 + // 显示名称 + if (listOtherProperty.contains("AliasName")) + { + QJsonValue value = listOtherProperty.value("AliasName"); + if (value.isString()) { + strAliasName = value.toString(); + } + } + // + initJykt(curv, strSlfName, strLineName, strAliasName, newlineColor, listOtherProperty); + } connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*))); // @@ -3767,25 +3783,12 @@ void FormDraw::s_addJykt(QString strUuid, QString strSlfName, QString strWellNam curv->m_formTrack = m_formTrack; curv->setDepthY(m_iY1, m_iY2); curv->initGeometry(m_strUuid, m_iScale, g_iOneWidth); - - //curv->resize(INT_MAX, INT_MAX); // 使用 INT_MAX 来避免16位整数的限制 - // QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); - // curv->setSizePolicy(policy); - curv->show(); - //井眼垮塌矢量图 - DrawJykt(curv, strSlfName); - - //道-对象 - QString strAliasName = "井眼垮塌矢量图"; - QString strUnit = "(°)"; - QColor newlineColor=QColor(0,0,0); - double width=2; - QString strScaleType = ""; - //道-对象 - m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "JyktObject"); - // + initJykt(curv, strSlfName, strLineName); + + + // connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*))); // @@ -5166,6 +5169,65 @@ void FormDraw::initGanzhuang(QMyCustomPlot *widget, QString strSlfName, QString widget->Draw_Ganzhuang(); } + +//井眼垮塌矢量图 +void FormDraw::initJykt(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName, QColor newlineColor, QJsonObject listOtherProperty) +{ + //隐藏网格 + widget->xAxis->grid()->setVisible(false); + widget->yAxis->grid()->setVisible(false); + // + widget->m_bRowGridVisible = false; + widget->m_bColGridVisible = false; + + //------------------- + m_LeftVal = 0; + m_RightVal = 10; + if(!listOtherProperty.isEmpty()) + { + m_LeftVal = listOtherProperty["vmin"].toDouble(); + m_RightVal = listOtherProperty["vmax"].toDouble(); + } + + float vmax = m_RightVal; + float vmin = m_LeftVal; + widget->setScaleX(vmin, vmax); + 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->xAxis->setTicks(false); + widget->yAxis->setTicks(false); + widget->xAxis2->setTicks(false); + widget->yAxis2->setTicks(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); + + //----------------------------------- + QString strUnit = "(°)"; + double width=2; + QString strScaleType = ""; + if(!listOtherProperty.isEmpty()) + { + strUnit = listOtherProperty["Unit"].toString(); // 单位 + } + //道-对象 + FormInfo* pInfo = m_formTrack->AddJykt(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject", listOtherProperty); + + //杆状图 + widget->Draw_Jykt(); +} + void FormDraw::initWords(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName, QColor newlineColor, QStringList listOtherProperty) { int iMyWidth = widget->axisRect(0)->width(); @@ -6540,128 +6602,6 @@ void FormDraw::CalcDipWidth(int nColumn,float *flWidth,float factor,int x1,int x } } - -void FormDraw::DrawJykt(QMyCustomPlot *widget, QString strSlfName) -{ - //初始化数据 - m_nRadius=4; - m_nTailLen = 8; - m_nCircleLineWidth = 2 ; - m_nTailWidth = 2; - m_flStep = 0.5; - m_nOffset = 90; - m_crTailLine = qRgb(0,0,0); - m_crLine = qRgb(0,0,0); - m_crPointFill = qRgb(0,0,0); - - //读取曲线数据 - m_csCurveDDIR="STRDIR"; //"DDIR"; - m_csCurveCAL="CALM"; - this->ReadData(strSlfName, m_csCurveCAL, 0, &m_Curve); - this->ReadData(strSlfName, m_csCurveDDIR, 1, &m_Curve2); - - //------------------- - m_LeftVal = 0; - m_RightVal = 10; - - float vmax = m_RightVal; - float vmin = m_LeftVal; - widget->setScaleX(vmin, vmax); - 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->xAxis->setTicks(false); - widget->yAxis->setTicks(false); - widget->xAxis2->setTicks(false); - widget->yAxis2->setTicks(false); - widget->xAxis->setVisible(false); - widget->xAxis2->setVisible(false); - widget->yAxis->setVisible(false); - widget->yAxis2->setVisible(false); - - //------------- - float tempf,flVal; - float flDep; - int i,j,iPoint=0,nPointNum=0,tempi; - QRectF rt,rtRect; - float x,y,x1,y1,x2,y2; - float dang,ddir; - float dg,dy; - float dgtord; - float deps; - - tempf = (m_EDep - m_SDep)/m_Rlev; - nPointNum = tempf+1; - - // - dgtord=3.14159265/180.; - QPen pPenTail = QPen(m_crTailLine, m_nTailWidth);// - QPen pPenCircle = QPen(m_crLine, m_nCircleLineWidth);// add for:圆线宽度单独使用 - QBrush brush2(m_crPointFill); - - // 注意映射方式 - float flVal1=0; - if (m_flStep <=0) m_flStep = 0.5;//add for:用户要输入0.5,当输入到0时,系统已经刷新,除0异常 [5/23/2019 16:35 hxb] - for (flDep = m_SDep; flDep < m_EDep; flDep += m_flStep) - { - y = -flDep;//起始深度 - - // 绘制圆 - i=(flDep-m_Curve.StartDepth)/m_Curve.DepLevel+0.5; - if(i<0) continue; - // - j=(flDep-m_Curve2.StartDepth)/m_Curve2.DepLevel+0.5; - if(j<0) continue; - - flVal1 = GetData(m_Curve2.RepCode, (char *)&m_Value2[j*m_Curve2.CodeLen]); - //角度小于0,不绘制 - if ( flVal1 <0) - { - continue; - } - - // - flVal = GetData(m_Curve.RepCode, (char *)&m_Value[i*m_Curve.CodeLen]); - x = flVal; - - //圆 - QCPItemEllipse *qcpItemEllipse = new QCPItemEllipse(widget); - qcpItemEllipse->setPen(pPenCircle); - qcpItemEllipse->m_bCustom = true; - qcpItemEllipse->m_nRadius = m_nRadius; - qcpItemEllipse->topLeft->setCoords(y, x);//圆心位置 - qcpItemEllipse->bottomRight->setCoords(y, x);//圆心位置 - qcpItemEllipse->setBrush(brush2);//填充圆的颜色 - - //尾巴 - flVal=flVal1; - flVal+=m_nOffset; - if ( flVal >=180.)flVal -= 180; - float dr=flVal*dgtord; - - QCPItemLine *qcpItemLine = new QCPItemLine(widget); - qcpItemLine->start->setCoords(y, x);//圆心位置 - qcpItemLine->end->setCoords(y, x);//圆心位置 - qcpItemLine->setPen(pPenTail); - qcpItemLine->m_bCustom = true; - qcpItemLine->m_nTailLen = m_nTailLen; //尾长 - qcpItemLine->m_nRadius = m_nRadius; //半径 - qcpItemLine->m_dr = dr; - - //break; - } -} - - void FormDraw::DrawDenv(QMyCustomPlot *widget, QString strSlfName) { //初始化数据 diff --git a/logPlus/formdraw.h b/logPlus/formdraw.h index c04a2d6..43fc6c5 100644 --- a/logPlus/formdraw.h +++ b/logPlus/formdraw.h @@ -148,9 +148,12 @@ public: int getColorConfig(QVector &qFiles); void DrawImageNew_NoFilter(QMyCustomPlot *widget, QString strSlfName, QString &strWaveName, int &_nSamples); - //表格曲线 + //蝌蚪图 void initKedou(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName = "蝌蚪图", QColor newlineColor=QColor(0,0,0), QJsonObject listOtherProperty={}); + //杆状图 void initGanzhuang(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName = "杆状图", QColor newlineColor=QColor(0,0,0), QJsonObject listOtherProperty={}); + //井眼垮塌矢量图 + void initJykt(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName = "井眼崩落矢量图", QColor newlineColor=QColor(0,0,0), QJsonObject listOtherProperty={}); void ReadFracDef(); void ReadData(QString strSlfName, QString strLineName);//表格 @@ -158,7 +161,6 @@ public: void CalcDipWidth(int nColumn,float *flWidth,float factor,int x1,int x2,float flHoriRatio); void Refurbish(); - void DrawJykt(QMyCustomPlot *widget, QString strSlfName); void DrawDenv(QMyCustomPlot *widget, QString strSlfName); int m_PointNum; diff --git a/logPlus/forminfo.cpp b/logPlus/forminfo.cpp index 71658ec..07fb488 100644 --- a/logPlus/forminfo.cpp +++ b/logPlus/forminfo.cpp @@ -234,6 +234,7 @@ void FormInfo::initProperty_Ganzhuang(QJsonObject obj) this->m_flGrad2 = 50; // 可信度2 // this->m_strUnit = "(°)"; + this->m_flStep = 0.5; // 深度间隔 } else { @@ -261,6 +262,70 @@ void FormInfo::initProperty_Ganzhuang(QJsonObject obj) this->m_flGrad2 = obj["m_flGrad2"].toDouble(); // 可信度2 // this->m_strUnit = obj["Unit"].toString(); // 单位 + this->m_flStep = obj["m_flStep"].toDouble(); // 深度间隔 + } + } +} + + +void FormInfo::initProperty_Jykt(QJsonObject obj) +{ + if(obj.isEmpty()) + { + // 字体 + + // 曲线选择 + this->m_pl_azimuthCurve = "STRDIR"; // 方位曲线 + this->m_pl_deltaCurve = "CALM"; // 井径差曲线 + + //蝌蚪符号 + this->m_nRadius = 6; // 圆半径 + this->m_nCircleWidth = 1; // 圆线宽度 + this->m_nTailLen = 10; // 尾线长度 + this->m_nTailWidth = 2; // 尾线宽度 + + // 显示控制 + this->m_vmin = 0; // 左刻度 + this->m_vmax = 10; // 右刻度 + this->m_flStep = 0.5; // 深度间隔 + this->m_nOffset = 90; // 角度偏移 + // + this->m_strUnit = "(°)"; + } + else + { + QString strType = obj.value("Type").toString(); + if ("tableObject" == strType) + { + // 字体 + // 名称 + this->m_curveNameFont.fromString(obj["curveNameFont"].toString()); + // 单位 + this->m_strUnitFont.fromString(obj["m_strUnitFont"].toString()); + // 刻度 + this->m_pl_fontScale.fromString(obj["m_pl_fontScale"].toString()); + + + // 曲线选择 + this->m_pl_azimuthCurve = obj["m_pl_azimuthCurve"].toString(); // 方位曲线 + this->m_pl_deltaCurve = obj["m_pl_deltaCurve"].toString(); // 井径差曲线 + + //蝌蚪符号 + this->m_nRadius = obj["m_nRadius"].toDouble(); // 圆半径 + this->m_nCircleWidth = obj["m_nCircleWidth"].toDouble();// 圆线宽度 + this->m_nTailLen = obj["m_nTailLen"].toDouble(); // 尾线长度 + this->m_nTailWidth = obj["m_nTailWidth"].toDouble(); // 尾线宽度 + this->m_crCircle.setNamedColor(obj["m_crCircle"].toString());// 圆线颜色 + this->m_crTail.setNamedColor(obj["m_crTail"].toString());// 尾线颜色 + this->m_crPointFill.setNamedColor(obj["m_crPointFill"].toString());// 圆填充色 + + // 刻度 + this->m_vmin = obj["vmin"].toDouble(); // 左刻度 + this->m_vmax = obj["vmax"].toDouble(); // 右刻度 + this->m_flStep = obj["m_flStep"].toDouble(); // 深度间隔 + this->m_nOffset = obj["m_nOffset"].toDouble(); // 角度偏移 + // + this->m_strUnit = obj["Unit"].toString(); // 单位 } } } @@ -603,6 +668,33 @@ QJsonObject FormInfo::makeJson() rootObj["m_flGrad2"] = this->m_flGrad2; // 可信度2 //单位 rootObj["Unit"] = m_strUnit; + rootObj["m_flStep"] = m_flStep;//深度间隔 + return rootObj; + } + else if (m_strLineName == "JINGYANKUATA.LINE") + { + //井眼垮塌矢量图 + // 字体 + rootObj["m_strUnitFont"] = this->m_strUnitFont.toString(); // 单位 + rootObj["m_pl_fontScale"] = this->m_pl_fontScale.toString(); // 刻度 + // 曲线选择 + rootObj["m_pl_azimuthCurve"] = this->m_pl_azimuthCurve; // 方位曲线 + rootObj["m_pl_deltaCurve"] = this->m_pl_deltaCurve; // 井径差曲线 + //蝌蚪符号 + rootObj["m_nRadius"] = this->m_nRadius; // 圆半径 + rootObj["m_nCircleWidth"] = this->m_nCircleWidth; // 圆线宽度 + rootObj["m_nTailLen"] = this->m_nTailLen; // 尾线长度 + rootObj["m_nTailWidth"] = this->m_nTailWidth; // 尾线宽度 + rootObj["m_crCircle"] = this->m_crCircle.name(); // 圆线颜色 + rootObj["m_crTail"] = this->m_crTail.name(); // 尾线颜色 + rootObj["m_crPointFill"] = this->m_crPointFill.name(); // 圆填充色 + // + rootObj["vmax"] = m_vmax;//右刻度 + rootObj["vmin"] = m_vmin;//左刻度 + rootObj["m_flStep"] = m_flStep;//深度间隔 + rootObj["m_nOffset"] = m_nOffset;//角度偏移 + //单位 + rootObj["Unit"] = m_strUnit; return rootObj; } } @@ -1297,8 +1389,7 @@ void FormInfo::paintEvent(QPaintEvent* event) } } - if(m_strLineName=="井眼垮塌矢量图" - || m_strLineName=="井斜方位图") + if(m_strLineName=="井斜方位图") { painter.drawText(rect.left(), rect.top()+rect.height()/3, rect.width(), rect.height()/3, Qt::AlignCenter, m_strUnit); 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)); @@ -1319,6 +1410,21 @@ void FormInfo::paintEvent(QPaintEvent* event) painter.drawText(rect.width()/2- tRect.width()/2, nbay - 6, m_strUnit); } + //井眼垮塌矢量图 + if(m_strLineName=="JINGYANKUATA.LINE") + { + int nbay = rect.height() - 5; + + // 显示刻度 + if (m_bShowScale) + { + drawScale(painter, rect); + } + QFontMetrics fm2(m_curveUnitFont); + QRect tRect = fm2.boundingRect(m_strUnit); + painter.drawText(rect.width()/2- tRect.width()/2, nbay - 6, m_strUnit); + } + if(m_strLineName == "深度") { QFont oldFont = painter.font(); diff --git a/logPlus/forminfo.h b/logPlus/forminfo.h index 795caef..b66a375 100644 --- a/logPlus/forminfo.h +++ b/logPlus/forminfo.h @@ -28,6 +28,7 @@ public: void initProperty(QJsonObject obj); void initProperty_Kedou(QJsonObject obj); void initProperty_Ganzhuang(QJsonObject obj); + void initProperty_Jykt(QJsonObject obj); void paintClassify(QPainter &painter, int compassCenterY); private: @@ -373,9 +374,14 @@ public: float m_nCircleWidth = 2; // 圆线宽度 float m_nTailWidth = 2; // 尾宽度 float m_nTailLen = 10; // 尾长 - QColor m_crCircle = qRgb(0,0,0); //颜色 - QColor m_crTail = qRgb(0,0,0); //颜色 - QColor m_crPointFill = qRgb(0,0,0); + QColor m_crCircle = qRgb(0,0,0); // 圆线颜色 + QColor m_crTail = qRgb(0,0,0); // 尾线颜色 + QColor m_crPointFill = qRgb(0,0,0); // 圆填充色 + + //井眼垮塌矢量图 + QString m_pl_deltaCurve = "CALM"; // 井径差曲线 + float m_flStep;// 增加深度间隔 + float m_nOffset; // 角度偏移=0,主应力方向,=90,长轴方向 public: void setLineWidth(double dWidth); diff --git a/logPlus/formtrack.cpp b/logPlus/formtrack.cpp index a16cd8b..10c1496 100644 --- a/logPlus/formtrack.cpp +++ b/logPlus/formtrack.cpp @@ -370,9 +370,47 @@ FormInfo* FormTrack::AddGanzhuang(QString strSlfName, QString strWellName, QStri //曲线信息栏 FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor); formInfo->m_strUuid = m_strUuid; - //formInfo->m_strUnit = strUnit; formInfo->initProperty_Ganzhuang(listOtherProperty); formInfo->m_strAliasName = strAliasName; + formInfo->m_strUnit = strUnit; + formInfo->m_strScaleType = strScaleType; + formInfo->m_strType = "tableObject"; + formInfo->setLineWidth(dWidth); + formInfo->setVMax(vmax); + formInfo->setVMin(vmin); + formInfo->setFrontColor(QColor(0,0,0)); + formInfo->setBackColor(QColor(255,255,255)); + + //设置高度 + ui->tableWidget->setRowHeight(row, 100); + // + ui->tableWidget->setCellWidget(row, 0, formInfo); + return formInfo; +} + +FormInfo* FormTrack::AddJykt(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty) +{ + if(strLineName == "JINGYANKUATA.LINE") + { + + } + else + { + return nullptr; + } + + qDebug() << "FormTrack AddJykt"; + + ui->tableWidget->m_strUuid = m_strUuid; + int row = ui->tableWidget->rowCount(); + ui->tableWidget->setRowCount(row + 1); + + //曲线信息栏 + FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor); + formInfo->m_strUuid = m_strUuid; + formInfo->initProperty_Jykt(listOtherProperty); + formInfo->m_strAliasName = strAliasName; + formInfo->m_strUnit = strUnit; formInfo->m_strScaleType = strScaleType; formInfo->m_strType = "tableObject"; formInfo->setLineWidth(dWidth); diff --git a/logPlus/formtrack.h b/logPlus/formtrack.h index 2d248c3..94649ed 100644 --- a/logPlus/formtrack.h +++ b/logPlus/formtrack.h @@ -44,8 +44,12 @@ public: public: void Add(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QStringList listOtherProperty={}); + //蝌蚪图 FormInfo* AddKedou(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty={}); + //杆状图 FormInfo* AddGanzhuang(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty={}); + //井眼垮塌矢量图 + FormInfo* AddJykt(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty={}); FormInfo* setDrawDt(QStringList listdt, QJsonObject obj); diff --git a/logPlus/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index 7457fe4..acb86eb 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -3709,44 +3709,16 @@ void MainWindowCurve::s_dcaAc() //井眼垮塌矢量图 void MainWindowCurve::s_Jykt() { - if(ui->tableWidget_2->columnCount()==0) - { - return; - } - - int column = ui->tableWidget_2->currentColumn();//列编号从0开始 - if(column<0) - { - //当前没有选中井 - QMessageBox::warning(this, "提示", "当前没有选中井", "确定"); - return; - } - - if(column%2==0) - { - } - else - { - //空白列 - QMessageBox::warning(this, "提示", "当前没有选中井", "确定"); - return; - } - - QStringList sret = this->getSelectWell_New(); - if (sret.length() <= 0) - return; - QString strWellName = sret.at(0); - //直接从选中的井获取,data记录slf路径 - QString strSlfName = sret.at(1); - - int iWidth = ui->tableWidget_2->columnWidth(column); - int nW = 4; - //设置列宽 - ui->tableWidget_2->setColumnWidth(column, iWidth+nW*g_dPixelPerCm+8); + QStringList sret = this->insertCol(nW); + if (sret.length() <= 0) + return; + QString strWellName = sret.at(0); + //直接从选中的井获取,data记录slf路径 + QString strSlfName = sret.at(1); //新建道 - emit CallManage::getInstance()->sig_NewTrack(m_strUuid, strWellName, strSlfName, "井眼垮塌矢量图", "JyktObject", nW); + emit CallManage::getInstance()->sig_NewTrack(m_strUuid, strWellName, strSlfName, "JINGYANKUATA.LINE", "JyktObject", nW); } //井斜方位图 diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 18a7c58..246040c 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -217,6 +217,8 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel connect(CallManage::getInstance(), SIGNAL(sig_changeKedouProperty(QString, QString, QString, QString, QString)), this, SLOT(s_changeKedouProperty(QString, QString, QString, QString, QString))); //改变杆状图属性 connect(CallManage::getInstance(), SIGNAL(sig_changeGanzhuangProperty(QString, QString, QString, QString, QString)), this, SLOT(s_changeGanzhuangProperty(QString, QString, QString, QString, QString))); + //改变井眼垮塌矢量图属性 + connect(CallManage::getInstance(), SIGNAL(sig_changeJyktProperty(QString, QString, QString, QString, QString)), this, SLOT(s_changeJyktProperty(QString, QString, QString, QString, QString))); } void QMyCustomPlot::initGeometry(QString strUuid, int nscale, double fW) @@ -12021,7 +12023,7 @@ void QMyCustomPlot::DrawTabDip_Kedou() { float flDepthScale,tempf,flVal; int i,j,n,nPointNum=0,tempi; - QRectF rt,rtRect; + //QRectF rt,rtRect; float x,y; float dgtord,dr; float flWidth[50]; @@ -12210,7 +12212,7 @@ void QMyCustomPlot::DrawDip_Kedou() float flDepthScale,tempf,flVal; int nPointNum=0,tempi; - QRectF rt,rtRect; + //QRectF rt,rtRect; float dgtord,dr; for(int i=0;i<50;i++) flWidth[i]=0; if(m_Value==0 || m_Value2==0) @@ -12218,7 +12220,10 @@ void QMyCustomPlot::DrawDip_Kedou() Refurbish(); } if ( m_Value==0 || m_Value2==0 ) + { + this->replot(); return ; + } dgtord=3.14159265/180.; @@ -12358,6 +12363,7 @@ void QMyCustomPlot::s_changeGanzhuangProperty(QString strUuid, QString strSlfNam void QMyCustomPlot::Draw_Ganzhuang() { + //this->clearGraphs(); this->clearItems(); // @@ -12375,7 +12381,7 @@ void QMyCustomPlot::Draw_Ganzhuang() this->m_csCurveDDIR = pInfo->m_pl_azimuthCurve; // 方位 曲线名 this->m_csCurveDANG = pInfo->m_pl_inclinationCurve;//倾角 this->m_csCurveGrad = pInfo->m_pl_GradCurve; // 可信度曲线 - //蝌蚪符号 + //杆状 this->m_nTailLen = pInfo->m_nTailLen; // 尾线长度 this->m_nTailWidth = pInfo->m_nTailWidth; // 尾线宽度 this->m_crTail = pInfo->m_crTail; // 尾线颜色 @@ -12386,6 +12392,8 @@ void QMyCustomPlot::Draw_Ganzhuang() this->m_flGrad1 = pInfo->m_flGrad1; //可信度1 this->m_flGrad2 = pInfo->m_flGrad2; //可信度2 + this->m_flStep = pInfo->m_flStep; // 深度间隔--读数据的间隔 + //读数据 this->ReadData(m_strSlfName, m_csCurveDDIR, 0, &m_Curve); this->ReadData(m_strSlfName, m_csCurveDANG, 1, &m_Curve2); @@ -12413,15 +12421,18 @@ void QMyCustomPlot::Draw_Ganzhuang() float flDepthScale,tempf,flVal; int nPointNum=0,tempi; - QRectF rt,rtRect; + //QRectF rt,rtRect; float dgtord,dr; for(int i=0;i<50;i++) flWidth[i]=0; - if(m_Value==0 || m_Value2==0) - { - Refurbish(); - } +// if(m_Value==0 || m_Value2==0) +// { +// Refurbish();//曲线名不一样,不能用 +// } if ( m_Value==0 || m_Value2==0 ) + { + this->replot(); return ; + } dgtord=3.14159265/180.; @@ -12430,7 +12441,7 @@ void QMyCustomPlot::Draw_Ganzhuang() while ( 1) { - dep = m_SDep + k * m_Rlev; + dep = m_SDep + k * m_flStep;//此处使用配置的间隔读取 m_Rlev if ( dep >m_EDep ) break; @@ -12502,3 +12513,140 @@ void QMyCustomPlot::Draw_Ganzhuang() } this->replot(); } + +//改变井眼垮塌矢量图属性 +void QMyCustomPlot::s_changeJyktProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName) +{ + if(m_strUuid == strUuid && + m_strSlfName == strSlfName && + m_strWellName == strWellName && + m_strTrackName == strTrackName && + m_strLineName == strLineName) + { + + } + else + { + return; + } + //绘制井眼垮塌矢量图 + Draw_Jykt(); +} + +void QMyCustomPlot::Draw_Jykt() +{ + //this->clearGraphs(); + this->clearItems(); + + // + FormInfo* pInfo = m_formTrack->getFormInfoByParameters(m_strUuid, m_strWellName, m_strTrackName, m_strLineName); + if (pInfo == NULL) + { + return; + } + + //----------------------------------- + this->m_Value=NULL; + this->m_Value2=NULL; + this->m_Value3=NULL; + // 曲线选择 + this->m_csCurveDDIR = pInfo->m_pl_azimuthCurve; // 方位 曲线名 + this->m_csCurveCAL = pInfo->m_pl_deltaCurve;//井径差曲线 + //蝌蚪符号 + this->m_nRadius = pInfo->m_nRadius; // 圆半径 + this->m_nCircleWidth = pInfo->m_nCircleWidth; // 圆线宽度 + this->m_nTailLen = pInfo->m_nTailLen; // 尾线长度 + this->m_nTailWidth = pInfo->m_nTailWidth; // 尾线宽度 + this->m_crCircle = pInfo->m_crCircle; // 圆线颜色 + this->m_crTail = pInfo->m_crTail; // 尾线颜色 + this->m_crPointFill=pInfo->m_crPointFill; //圆填充色 + + //读数据 + this->ReadData(m_strSlfName, m_csCurveCAL, 0, &m_Curve); + this->ReadData(m_strSlfName, m_csCurveDDIR, 1, &m_Curve2); + if ( m_Value==0 || m_Value2==0 ) + { + this->replot(); + return ; + } + + // + m_flStep = pInfo->m_flStep; // 深度间隔--读数据的间隔 + m_nOffset = pInfo->m_nOffset; // 角度偏移=0,主应力方向,=90,长轴方向 + + // + float vmax = pInfo->m_vmax; + float vmin = pInfo->m_vmin; + //this->setScaleX(vmin, vmax); + this->yAxis->setRange(vmin, vmax); + + //------------- + float flVal; + float flDep; + int i,j,iPoint=0,tempi; + //QRectF rt,rtRect; + float x,y,x1,y1,x2,y2; + float dang,ddir; + float dg,dy; + float dgtord; + float deps; + + // + dgtord=3.14159265/180.; + QPen pPenTail = QPen(m_crTail, m_nTailWidth);// + QPen pPenCircle = QPen(m_crCircle, m_nCircleWidth);// add for:圆线宽度单独使用 + QBrush brush2(m_crPointFill); + + // 注意映射方式 + float flVal1=0; + if (m_flStep <=0) m_flStep = 0.5;//add for:用户要输入0.5,当输入到0时,系统已经刷新,除0异常 [5/23/2019 16:35 hxb] + for (flDep = m_SDep; flDep < m_EDep; flDep += m_flStep) + { + y = -flDep;//起始深度 + + // 绘制圆 + i=(flDep-m_Curve.StartDepth)/m_Curve.DepLevel+0.5; + if(i<0) continue; + // + j=(flDep-m_Curve2.StartDepth)/m_Curve2.DepLevel+0.5; + if(j<0) continue; + + flVal1 = GetData(m_Curve2.RepCode, (char *)&m_Value2[j*m_Curve2.CodeLen]); + //角度小于0,不绘制 + if ( flVal1 <0) + { + continue; + } + + // + flVal = GetData(m_Curve.RepCode, (char *)&m_Value[i*m_Curve.CodeLen]); + x = flVal; + + //圆 + QCPItemEllipse *qcpItemEllipse = new QCPItemEllipse(this); + qcpItemEllipse->setPen(pPenCircle); + qcpItemEllipse->m_bCustom = true; + qcpItemEllipse->m_nRadius = m_nRadius; + qcpItemEllipse->topLeft->setCoords(y, x);//圆心位置 + qcpItemEllipse->bottomRight->setCoords(y, x);//圆心位置 + qcpItemEllipse->setBrush(brush2);//填充圆的颜色 + + //尾巴 + flVal=flVal1; + flVal+=m_nOffset; + if ( flVal >=180.)flVal -= 180; + float dr=flVal*dgtord; + + QCPItemLine *qcpItemLine = new QCPItemLine(this); + qcpItemLine->start->setCoords(y, x);//圆心位置 + qcpItemLine->end->setCoords(y, x);//圆心位置 + qcpItemLine->setPen(pPenTail); + qcpItemLine->m_bCustom = true; + qcpItemLine->m_nTailLen = m_nTailLen; //尾长 + qcpItemLine->m_nRadius = m_nRadius; //半径 + qcpItemLine->m_dr = dr; + + //break; + } + this->replot(); +} diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index d544d27..9307111 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -680,6 +680,9 @@ public slots: //改变杆状图属性 void s_changeGanzhuangProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); + //改变井眼垮塌矢量图属性 + void s_changeJyktProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); + public: //蝌蚪图重绘网格线 bool mKedou = false; @@ -709,6 +712,11 @@ public: float m_SDep,m_EDep,m_Rlev; int m_nSamples = 0; + //井眼垮塌矢量图 + QString m_csCurveCAL; + float m_flStep;// 增加深度间隔 + float m_nOffset; // 角度偏移=0,主应力方向,=90,长轴方向 + // 频率统计图 csCurveGrad曲线名 LeftVal3最小值 RightVal3最大值 nArc扇形 nR圆半径 crArc圆颜色 nArcLineWidth圆线宽度 bFill是否填充 void drawFgrq(bool bTableData, QString csCurveDDIR, QString csCurveDANG, QString csCurveGrad, double LeftVal3, double RightVal3, int nArc, double nR, QColor crArc, int nArcLineWidth, bool bFill, QColor crFill, int lineNumber, double lineHeight, int lineThickness, QColor lineColor, bool drawAnnotation, bool drawHistogram, @@ -754,6 +762,9 @@ public: //杆状图 void Draw_Ganzhuang(); + // + void Draw_Jykt(); + private: }; From f27fcd2bf27d58e647f91dfa50781c6f454d6aa2 Mon Sep 17 00:00:00 2001 From: "DESKTOP-450PEFP\\mainc" Date: Thu, 23 Apr 2026 09:05:24 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E6=B3=A2=E5=88=97=E7=9A=84=20=E5=B7=A6?= =?UTF-8?q?=E5=8F=B3=E5=88=BB=E5=BA=A6=E7=BB=98=E5=9B=BE=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logPlus/qmycustomplot.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 18a7c58..66128cc 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -642,7 +642,7 @@ QCPColorMap * QMyCustomPlot::updateWave() int ny = m_nSamples; m_colorMap->data()->setSize(nx, ny); // 我们希望彩色地图有nx*ny的数据点 - float f = 264 / 269.0f; + float f = 0.99;// 264 / 269.0f; m_colorMap->data()->setRange(QCPRange(0 - m_EDep, 0 - m_SDep), QCPRange(this->m_iX1, this->m_iX2*f)); for (int xIndex = 0; xIndex < nx; ++xIndex) @@ -5108,15 +5108,20 @@ void QMyCustomPlot::s_changeDrawProperty(QVariantList vlist) } else if ("左刻度" == strProperty) { - + if (m_colorMap) + { + m_iX1 = varVal.toFloat(); + float f = 264 / m_fScaleV; + m_colorMap->data()->setValueRange(QCPRange(m_iX1, m_iX2*f)); + } } else if ("右刻度" == strProperty) { if (m_colorMap) { - m_fScaleV = varVal.toFloat(); - float f = 264 / m_fScaleV; - m_colorMap->data()->setValueRange(QCPRange(m_fmin, m_fmax*f)); + m_fScaleV = varVal.toFloat(); + float f = 264 / m_fScaleV; + m_colorMap->data()->setValueRange(QCPRange(m_iX1, m_iX2*f)); } } else if ("最大振幅" == strProperty) From f62d24e4cec8a061ac6c8c7a2b3a1d4f03c7f391 Mon Sep 17 00:00:00 2001 From: crqiqi77 Date: Thu, 23 Apr 2026 09:10:28 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E8=A3=82=E7=BC=9D=20=E7=94=BB=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logPlus/PickFrac.cpp | 1189 +++++++++++++++++++++++++++++++------ logPlus/PickFrac.h | 213 +++++-- logPlus/formdraw.cpp | 1 + logPlus/qmycustomplot.cpp | 19 +- logPlus/qmycustomplot.h | 6 +- 5 files changed, 1182 insertions(+), 246 deletions(-) diff --git a/logPlus/PickFrac.cpp b/logPlus/PickFrac.cpp index da732f8..ef1f38c 100644 --- a/logPlus/PickFrac.cpp +++ b/logPlus/PickFrac.cpp @@ -1,247 +1,1048 @@ #include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include "MemRdWt.h" #include "PickFrac.h" +#include "qmycustomplot.h" #include "geometryutils.h" +// ==================== CPickFrac 实现 ==================== CPickFrac::CPickFrac(QMyCustomPlot *myCustomPlot, QString strSlfName, QString csCurve, int iMyWidth) + : m_myCustomPlot(myCustomPlot), m_iMyWidth(iMyWidth) { - m_myCustomPlot = myCustomPlot; - m_iMyWidth = iMyWidth; - - m_Name="Frac_Hole.Table"; - m_strDevi = "DEVI"; - m_strHazi = "HAZI"; - + m_currentSlfName = strSlfName; + m_currentTableName = csCurve.isEmpty() ? "Frac_Hole.Table" : csCurve; ReadFracDef(); - - for (int i = 0 ; i < iFracType ; i++) - { - m_bTypeDraw[i] = true; - } - - //支持框选------------------ + for (int i = 0; i < iFracType2; i++) m_bTypeDraw[i] = true; myCustomPlot->m_bDrawCore_PHYSICS = true; - ReadData(strSlfName, csCurve); - -// myCustomPlot->setSelectionRectMode(QCP::SelectionRectMode::srmSelect); -// myCustomPlot->graph(0)->setSelectable(QCP::SelectionType::stMultipleDataRanges);// stSingleData -// myCustomPlot->setInteractions(QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iMultiSelect); // 轴、图例、图表可以被选择,并且是多选的方式 - } -CPickFrac::~CPickFrac(void) +CPickFrac::~CPickFrac() { + qDeleteAll(m_items); m_FracDef.clear(); } +void CPickFrac::setDraggingEnabled(bool enabled) +{ + m_draggingEnabled = enabled; + if (!enabled) { + for (auto item : m_items) item->deactivate(); + } +} + void CPickFrac::ReadFracDef() { m_FracDef.clear(); - QString fracFilePath = GetConfPath() + "FRAC.CFG"; - - // FRAC_DEF_Crack fd; - char str[512],name[512]; - int r,g,b,id; - FILE *fp; - QString qs; - fp = fopen(fracFilePath.toStdString().c_str(),"r"); - if ( fp != nullptr ) - { - fgets(str,256,fp); // 跳过第一行 - while (!feof(fp)) - { - fgets(str,256,fp); - qs = str; + char str[512], name[512]; + int r, g, b; + FILE *fp = fopen(fracFilePath.toStdString().c_str(), "r"); + if (fp) { + fgets(str, 256, fp); + while (!feof(fp)) { + fgets(str, 256, fp); + QString qs = str; qs.trimmed(); - if (qs.length() < 8) break ; - //代码 名称 形状代码(1:正弦曲线 2:连线 3:封闭区域) 颜色(红 绿 蓝) 线宽度 - sscanf(str,"%d %s %d %d %d %d %d",&fd.iCode,name,&fd.iType,&r,&g,&b,&fd.nLineWidth); - fd.crColor = QColor(r,g,b);//RGB(r,g,b); + if (qs.length() < 8) break; + sscanf(str, "%d %s %d %d %d %d %d", &fd.iCode, name, &fd.iType, &r, &g, &b, &fd.nLineWidth); + fd.crColor = QColor(r, g, b); fd.csName = name; - fd.csName = fd.csName.trimmed();//.Trim(); + fd.csName = fd.csName.trimmed(); fd.bDraw = 0; m_FracDef.append(fd); - if ( feof(fp)) - break; + if (feof(fp)) break; } fclose(fp); - } - else - { - sprintf(name,"打开裂缝参数配置文件错误:%s!",str); + } else { + sprintf(name, "打开裂缝参数配置文件错误:%s!", str); QMessageBox::information(nullptr, "读取文件失败", name); } } void CPickFrac::ReadData(QString strSlfName, QString csCurve) { - if(strSlfName.isEmpty()) return; + if (strSlfName.isEmpty()) return; + if (csCurve == "AC" || csCurve.isEmpty()) csCurve = "Frac_Hole.Table"; - if(csCurve=="AC"||csCurve=="") - { - csCurve="Frac_Hole.Table"; + CMemRdWt mrw; + if (!mrw.Open(strSlfName.toStdString().c_str())) return; + + int iIndex = mrw.OpenTable(csCurve.toStdString().c_str()); + if (iIndex < 0) { mrw.Close(); return; } + + int nField = mrw.GetTableFieldCount(iIndex); + int nCount = mrw.GetTableRecordCount(iIndex); + for (int i = 0; i < nCount; ++i) { + FRAC_TABLE_Crack frac; + if (nField == 7) { + FRAC_TABLE_OLD_Crack fracold; + mrw.ReadTable(iIndex, i+1, &fracold); + frac.AorX = fracold.AorX; + frac.DEP = fracold.DEP; + frac.DIPorS = fracold.DIPorS; + frac.DIR = fracold.DIR; + frac.W = fracold.W; + frac.ID = fracold.ID; + frac.XETAorH = fracold.XETAorH; + frac.NUM = 0; + for (int j=0; j<16; ++j) frac.point[j].x = frac.point[j].y = 0; + } else { + mrw.ReadTable(iIndex, i+1, &frac); + } + + for (int j=0; jsetCrackCode(frac.ID); + connect(item, &DraggableCrackItem::dataChanged, this, &CPickFrac::saveToFile); + connect(item, &DraggableCrackItem::removeMe, this, &CPickFrac::onRemoveCrackItem); + m_items.append(item); + + if (iType == 1) { + double h = frac.AorX / 2.0; + double oy = -(frac.DEP + h); + double xScale = 360.0 / m_iMyWidth; + double endX = 360.0 / xScale; + item->setSineData(oy, h, frac.XETAorH, xScale, endX); + } + else if (iType == 2) { + QVector points; + int n = frac.NUM; + for (int j=0; jsetPolylineData(points); + } + else if (iType == 3) { + QVector points; + int n = frac.NUM; + for (int j=0; jsetClosedData(points); + } +} + +bool CPickFrac::eventFilter(QObject *watched, QEvent *event) +{ + return QObject::eventFilter(watched, event); +} + +bool CPickFrac::saveToFile() +{ + static bool isRunning = false; + if (isRunning) return false; + if (m_currentSlfName.isEmpty()) return false; + isRunning = true; + + CMemRdWt *logio = new CMemRdWt(); + if (!logio->Open(m_currentSlfName.toStdString().c_str(), CSlfIO::modeReadWrite)) { + delete logio; + QMessageBox::information(nullptr, "提示", "SLF文件打开失败,请检查!", QMessageBox::Yes); + isRunning = false; + return false; } - QString cs; - int nLineWidth=2; - int nField; - QColor crColor(255,0,0); - FRAC_TABLE_Crack frac; - FRAC_TABLE_OLD_Crack fracold; - CMemRdWt mrw; - char strFracTable[256]; - int i,j,iIndex,nCount,iType=1; + QString tableName = m_currentTableName; + int iIndex = logio->OpenTable(tableName.toStdString().c_str()); + if (iIndex < 0) { + delete logio; + QMessageBox::information(nullptr, "提示", QString("裂缝表 %1 不存在,无法保存!").arg(tableName), QMessageBox::Yes); + isRunning = false; + return false; + } - if (mrw.Open(strSlfName.toStdString().c_str()) ) // 打开井文件 - { - QString name(csCurve); - iIndex=mrw.OpenTable(name.toStdString().c_str()); - if(iIndex>=0) - { - nField=mrw.GetTableFieldCount(iIndex); - nCount=mrw.GetTableRecordCount(iIndex); - cs =""; - for(i=0;iSetTableRecordCount(iIndex, 0); + logio->CloseTable(iIndex); + delete logio; + isRunning = false; + return true; + } + + QMap sortedMap; + for (DraggableCrackItem *item : m_items) { + double depth = item->getDepthForSort(); + sortedMap[depth] = item; + } + logio->SetTableRecordCount(iIndex, sortedMap.size()); + + int recordIndex = 1; + for (auto it = sortedMap.begin(); it != sortedMap.end(); ++it) { + FRAC_TABLE_Crack fracData; + it.value()->getCurrentFracData(fracData); + logio->WriteTable(iIndex, recordIndex, &fracData); + recordIndex++; + } + + logio->CloseTable(iIndex); + delete logio; + isRunning = false; + return true; +} + +void CPickFrac::onRemoveCrackItem(DraggableCrackItem *item) +{ + if (!item) return; + if (m_items.removeOne(item)) { + disconnect(item, nullptr, this, nullptr); + // 延迟删除,确保当前事件完全结束 + QTimer::singleShot(0, item, &QObject::deleteLater); + saveToFile(); + m_myCustomPlot->replot(); + } +} + +// ==================== DraggableCrackItem 实现 ==================== +QPointer DraggableCrackItem::s_activeItem = nullptr; + +DraggableCrackItem::DraggableCrackItem(QCustomPlot *plot, Type type, const QColor &color, int lineWidth) + : QObject(plot), m_plot(plot), m_type(type), m_color(color), m_lineWidth(lineWidth) +{ + if (m_type == TypeA_Sine) { + m_curve = new QCPItemCurve(m_plot); + m_curve->setPen(QPen(m_color, m_lineWidth)); + m_curve->setLayer("overlay"); + auto createTracer = [this](double x, double y) -> QCPItemTracer* { + QCPItemTracer *t = new QCPItemTracer(m_plot); + t->setStyle(QCPItemTracer::tsSquare); + t->setSize(8); + t->setPen(QPen(Qt::black, 1)); + t->setBrush(QBrush(Qt::black)); + t->setSelectable(true); + t->setLayer("overlay"); + t->position->setCoords(x, y); + t->setVisible(false); + return t; + }; + m_tracer1 = createTracer(0,0); + m_tracer2 = createTracer(0,0); + m_plot->installEventFilter(this); + } + else if (m_type == TypeB_Polyline) { + m_plot->installEventFilter(this); + } + else if (m_type == TypeC_Closed) { + m_curveC = new QCPCurve(m_plot->xAxis, m_plot->yAxis); + m_curveC->setPen(QPen(m_color, m_lineWidth)); + m_curveC->setScatterStyle(QCPScatterStyle::ssCircle); + m_curveC->setLineStyle(QCPCurve::lsLine); + m_curveC->setLayer("overlay"); + m_plot->installEventFilter(this); + } +} + +DraggableCrackItem::~DraggableCrackItem() +{ + if (m_type == TypeA_Sine) { + if (m_tracer1) m_plot->removeItem(m_tracer1); + if (m_tracer2) m_plot->removeItem(m_tracer2); + if (m_curve) m_plot->removeItem(m_curve); + } else if (m_type == TypeB_Polyline) { + clearLines(); + } else if (m_type == TypeC_Closed) { + clearPolylineC(); + } + if (s_activeItem == this) s_activeItem = nullptr; +} + +void DraggableCrackItem::setVisible(bool visible) +{ + if (m_pendingDelete) return; + if (m_type == TypeA_Sine) { + if (m_curve) m_curve->setVisible(visible); + if (m_tracer1) m_tracer1->setVisible(visible && (s_activeItem == this)); + if (m_tracer2) m_tracer2->setVisible(visible && (s_activeItem == this)); + } else if (m_type == TypeB_Polyline) { + for (auto &item : m_lines) { + if (item.line) item.line->setVisible(visible); + bool show = visible && (s_activeItem == this); + if (item.startTracer) item.startTracer->setVisible(show); + if (item.endTracer) item.endTracer->setVisible(show); + } + } else if (m_type == TypeC_Closed) { + if (m_curveC) m_curveC->setVisible(visible); + bool show = visible && (s_activeItem == this); + for (auto label : m_labelsC) label->setVisible(show); + } + m_plot->replot(); +} + +void DraggableCrackItem::deactivate() +{ + if (m_type == TypeA_Sine) { + setTracerHighlight(m_tracer1, false); + setTracerHighlight(m_tracer2, false); + m_dragStateA = IdleA; + setDragPointsVisible(false); + } else if (m_type == TypeB_Polyline) { + m_dragStateB = IdleB; + m_draggedLineIndex = -1; + setDragPointsVisible(false); + } else if (m_type == TypeC_Closed) { + m_cDragging = false; + m_draggingPoint = false; + m_draggedPointIndex = -1; + setDragPointsVisible(false); + } + if (s_activeItem == this) s_activeItem = nullptr; + m_plot->replot(); +} + +void DraggableCrackItem::setDragPointsVisible(bool visible) +{ + if (m_type == TypeA_Sine) { + if (m_tracer1) m_tracer1->setVisible(visible); + if (m_tracer2) m_tracer2->setVisible(visible); + } else if (m_type == TypeB_Polyline) { + for (auto &item : m_lines) { + if (item.startTracer) item.startTracer->setVisible(visible); + if (item.endTracer) item.endTracer->setVisible(visible); + } + } else if (m_type == TypeC_Closed) { + for (auto label : m_labelsC) { + if (label) label->setVisible(visible); + } + } + m_plot->replot(); +} + +void DraggableCrackItem::startEditing() +{ + m_editingMode = true; + if (s_activeItem && s_activeItem != this) s_activeItem->deactivate(); + s_activeItem = this; + setDragPointsVisible(true); + if (m_type == TypeB_Polyline) { + clearLines(); + m_isAddingLine = false; + } else if (m_type == TypeC_Closed) { + clearPolylineC(); + m_cFinished = false; + } + m_plot->replot(); +} + +void DraggableCrackItem::finishEditing() +{ + if (!m_editingMode) return; + m_editingMode = false; + if (s_activeItem == this) { + deactivate(); + } + emit dataChanged(); +} + +// ---------- 模式A ---------- +void DraggableCrackItem::setSineData(double depth, double amplitude, double phase, double xScale, double width) +{ + m_depth = depth; + m_endX = width; + m_originalXETAorH = phase; + m_originalAorX = amplitude * 2.0; + m_orig_x1 = m_endX * 0.18; + m_orig_x2 = m_endX * 0.82; + m_orig_y1 = depth + amplitude; + m_orig_y2 = depth - amplitude; + m_orig_startX = 0; + m_orig_endX = m_endX; + m_orig_startDirX = m_endX * 0.3; + m_orig_endDirX = m_endX * 0.7; + updateCurveFromTargets(); + updateCurvePosition(); + updateTracers(); +} + +void DraggableCrackItem::updateCurveFromTargets() +{ + double t1 = m_orig_x1 / m_endX; + double t2 = m_orig_x2 / m_endX; + double u1 = 1 - t1, u2 = 1 - t2; + double P0x = 0, P0y = m_depth; + double P3x = m_endX, P3y = m_depth; + double P1x = m_orig_x1, P2x = m_orig_x2; + double a11 = 3 * u1 * u1 * t1; + double a12 = 3 * u1 * t1 * t1; + double b1 = m_orig_y1 - (u1*u1*u1 * P0y + t1*t1*t1 * P3y); + double a21 = 3 * u2 * u2 * t2; + double a22 = 3 * u2 * t2 * t2; + double b2 = m_orig_y2 - (u2*u2*u2 * P0y + t2*t2*t2 * P3y); + double det = a11 * a22 - a12 * a21; + if (fabs(det) > 1e-6) { + double P1y = (b1 * a22 - a12 * b2) / det; + double P2y = (a11 * b2 - b1 * a21) / det; + m_orig_startDirX = P1x; + m_orig_startDirY = P1y; + m_orig_endDirX = P2x; + m_orig_endDirY = P2y; + } +} + +void DraggableCrackItem::updateCurvePosition() +{ + if (!m_curve) return; + m_curve->start->setCoords(m_orig_startX + m_offsetXA, m_depth + m_offsetYA); + m_curve->end->setCoords(m_orig_endX + m_offsetXA, m_depth + m_offsetYA); + m_curve->startDir->setCoords(m_orig_startDirX + m_offsetXA, m_orig_startDirY + m_offsetYA); + m_curve->endDir->setCoords(m_orig_endDirX + m_offsetXA, m_orig_endDirY + m_offsetYA); +} + +void DraggableCrackItem::updateTracers() +{ + if (!m_tracer1 || !m_tracer2) return; + m_tracer1->position->setCoords(m_orig_x1 + m_offsetXA, m_orig_y1 + m_offsetYA); + m_tracer2->position->setCoords(m_orig_x2 + m_offsetXA, m_orig_y2 + m_offsetYA); +} + +void DraggableCrackItem::setTracerHighlight(QCPItemTracer *tracer, bool highlight) +{ + if (!tracer) return; + if (highlight) { + tracer->setPen(QPen(Qt::red, 2)); + tracer->setBrush(QBrush(Qt::red)); + } else { + tracer->setPen(QPen(Qt::black, 1)); + tracer->setBrush(QBrush(Qt::black)); + } + m_plot->replot(); +} + +// ---------- 模式B ---------- +void DraggableCrackItem::setPolylineData(const QVector &points, double scaleX, double flipY) +{ + clearLines(); + if (points.size() < 2) return; + auto createTracer = [this](double x, double y, const QColor &color) -> QCPItemTracer* { + QCPItemTracer *t = new QCPItemTracer(m_plot); + t->setStyle(QCPItemTracer::tsSquare); + t->setSize(10); + t->setPen(QPen(Qt::black, 1)); + t->setBrush(QBrush(color)); + t->setSelectable(true); + t->setLayer("overlay"); + t->position->setCoords(x, y); + t->setVisible(false); + return t; + }; + for (int i = 0; i < points.size() - 1; ++i) { + QPointF p1 = points[i]; + QPointF p2 = points[i+1]; + QCPItemLine *line = new QCPItemLine(m_plot); + line->setPen(QPen(m_color, m_lineWidth)); + line->setLayer("overlay"); + QCPItemTracer *startTracer = createTracer(p1.x(), p1.y(), Qt::black); + QCPItemTracer *endTracer = createTracer(p2.x(), p2.y(), Qt::black); + LineItem item; + item.startOrig = p1; + item.endOrig = p2; + item.line = line; + item.startTracer = startTracer; + item.endTracer = endTracer; + m_lines.append(item); + i++; + } + updateLinesPosition(); +} + +void DraggableCrackItem::updateLineEndpoints(LineItem &item) +{ + item.startTracer->position->setCoords(item.startOrig.x() + m_offsetXB, item.startOrig.y() + m_offsetYB); + item.endTracer->position->setCoords(item.endOrig.x() + m_offsetXB, item.endOrig.y() + m_offsetYB); +} + +void DraggableCrackItem::updateLinesPosition() +{ + for (auto &item : m_lines) { + item.line->start->setCoords(item.startOrig.x() + m_offsetXB, item.startOrig.y() + m_offsetYB); + item.line->end->setCoords(item.endOrig.x() + m_offsetXB, item.endOrig.y() + m_offsetYB); + updateLineEndpoints(item); + } +} + +void DraggableCrackItem::clearLines() +{ + for (auto &item : m_lines) { + if (item.line) { m_plot->removeItem(item.line); delete item.line; } + if (item.startTracer) { m_plot->removeItem(item.startTracer); delete item.startTracer; } + if (item.endTracer) { m_plot->removeItem(item.endTracer); delete item.endTracer; } + } + m_lines.clear(); + m_plot->replot(); +} + +// ---------- 模式C ---------- +void DraggableCrackItem::setClosedData(const QVector &points, double scaleX, double flipY) +{ + clearPolylineC(); + if (points.size() < 3) return; + m_pointsC = points; + for (int i = 0; i < m_pointsC.size(); ++i) { + QCPItemText *label = new QCPItemText(m_plot); + label->setText(" "); + label->setFont(QFont("Arial", 6, QFont::Bold)); + label->setColor(Qt::black); + label->setBrush(QBrush(Qt::black)); + label->setPen(QPen(Qt::black, 1)); + label->position->setCoords(m_pointsC[i].x(), m_pointsC[i].y()); + label->setPositionAlignment(Qt::AlignCenter); + label->setLayer("overlay"); + label->setVisible(false); + m_labelsC.append(label); + } + m_cFinished = true; + updatePolylineC(true); +} + +void DraggableCrackItem::updatePolylineC(bool closed) +{ + if (!m_curveC) return; + if (m_pointsC.isEmpty()) { + m_curveC->setData(QVector(), QVector()); + return; + } + QVector xs, ys; + for (const auto &p : m_pointsC) { + xs << p.x() + m_offsetXC; + ys << p.y() + m_offsetYC; + } + if (closed && m_pointsC.size() >= 3) { + xs << m_pointsC.first().x() + m_offsetXC; + ys << m_pointsC.first().y() + m_offsetYC; + } + m_curveC->setData(xs, ys); +} + +void DraggableCrackItem::clearPolylineC() +{ + for (auto label : m_labelsC) { + if (label) { + label->setParent(nullptr); + delete label; + } + } + m_labelsC.clear(); + m_pointsC.clear(); + if (m_curveC) m_curveC->setData(QVector(), QVector()); + m_offsetXC = m_offsetYC = 0.0; + m_cFinished = false; + m_cDragging = false; + m_draggingPoint = false; + m_draggedPointIndex = -1; + m_plot->replot(); +} + +// ---------- 保存辅助 ---------- +double DraggableCrackItem::getDepthForSort() const +{ + if (m_type == TypeA_Sine) + return m_depth + m_offsetYA; + else if (m_type == TypeB_Polyline && !m_lines.isEmpty()) + return m_lines.first().startOrig.y() + m_offsetYB; + else if (m_type == TypeC_Closed && !m_pointsC.isEmpty()) + return m_pointsC.first().y() + m_offsetYC; + return 0.0; +} + +void DraggableCrackItem::getCurrentFracData(FRAC_TABLE_Crack &data) const +{ + memset(&data, 0, sizeof(FRAC_TABLE_Crack)); + data.ID = m_crackCode; + + if (m_type == TypeA_Sine) { + double centerY = (m_orig_y1 + m_orig_y2) / 2.0 + m_offsetYA; + double halfHeight = (m_orig_y1 - m_orig_y2) / 2.0; + double savedDEP = -centerY - halfHeight; + double savedAorX = halfHeight * 2.0; + data.DEP = savedDEP; + data.AorX = savedAorX; + data.XETAorH = m_originalXETAorH; + data.NUM = 0; + } + else if (m_type == TypeB_Polyline) { + QVector allPoints; + for (const LineItem &item : m_lines) { + QPointF p1 = item.startOrig + QPointF(m_offsetXB, m_offsetYB); + QPointF p2 = item.endOrig + QPointF(m_offsetXB, m_offsetYB); + allPoints.append(p1); + allPoints.append(p2); + } + QVector uniquePoints; + for (const QPointF &p : allPoints) { + if (uniquePoints.isEmpty() || uniquePoints.last() != p) + uniquePoints.append(p); + } + data.NUM = uniquePoints.size(); + for (int i = 0; i < uniquePoints.size() && i < 16; ++i) { + data.point[i].x = uniquePoints[i].x() * 8.0f; + data.point[i].y = -uniquePoints[i].y(); + } + if (uniquePoints.size() > 0) + data.DEP = uniquePoints[0].y(); + } + else if (m_type == TypeC_Closed) { + QVector finalPoints; + for (const QPointF &p : m_pointsC) { + finalPoints.append(p + QPointF(m_offsetXC, m_offsetYC)); + } + data.NUM = finalPoints.size(); + for (int i = 0; i < finalPoints.size() && i < 16; ++i) { + data.point[i].x = finalPoints[i].x() * 8.0f; + data.point[i].y = -finalPoints[i].y(); + } + if (finalPoints.size() > 0) + data.DEP = finalPoints[0].y(); + } +} + +// ---------- 事件过滤器 ---------- +bool DraggableCrackItem::eventFilter(QObject *obj, QEvent *event) +{ + if (obj != m_plot) return false; + if (m_pendingDelete) return false; // 已标记删除,忽略所有事件 + + // 右键菜单处理 + if (event->type() == QEvent::ContextMenu) { + QContextMenuEvent *ce = static_cast(event); + if (s_activeItem == this) { + QMenu menu; + QAction *deleteAction = menu.addAction("删除裂缝"); + QAction *selectedAction = menu.exec(ce->globalPos()); + if (selectedAction == deleteAction) { + m_pendingDelete = true; + deactivate(); // 清空全局激活指针 + emit removeMe(this); + } + return true; + } + return false; + } + + QMouseEvent *me = static_cast(event); + + if (event->type() == QEvent::MouseButtonPress && me->button() == Qt::LeftButton) { + bool shiftPressed = (me->modifiers() & Qt::ShiftModifier); + + // ===== 模式B:添加线段(Shift) ===== + if (m_type == TypeB_Polyline && shiftPressed) { + if (!m_isAddingLine) { + double x = m_plot->xAxis->pixelToCoord(me->pos().x()); + double y = m_plot->yAxis->pixelToCoord(me->pos().y()); + m_tempPoint = QPointF(x - m_offsetXB, y - m_offsetYB); + m_isAddingLine = true; + return true; + } else { + double x = m_plot->xAxis->pixelToCoord(me->pos().x()); + double y = m_plot->yAxis->pixelToCoord(me->pos().y()); + QPointF p2(x - m_offsetXB, y - m_offsetYB); + QCPItemLine *line = new QCPItemLine(m_plot); + line->setPen(QPen(m_color, m_lineWidth)); + line->setLayer("overlay"); + auto createTracer = [this](double x, double y, const QColor &color) -> QCPItemTracer* { + QCPItemTracer *t = new QCPItemTracer(m_plot); + t->setStyle(QCPItemTracer::tsSquare); + t->setSize(10); + t->setPen(QPen(Qt::black, 1)); + t->setBrush(QBrush(color)); + t->setSelectable(true); + t->setLayer("overlay"); + t->position->setCoords(x + m_offsetXB, y + m_offsetYB); + t->setVisible(false); + return t; + }; + QCPItemTracer *startTracer = createTracer(m_tempPoint.x(), m_tempPoint.y(), Qt::black); + QCPItemTracer *endTracer = createTracer(p2.x(), p2.y(), Qt::black); + LineItem item; + item.startOrig = m_tempPoint; + item.endOrig = p2; + item.line = line; + item.startTracer = startTracer; + item.endTracer = endTracer; + m_lines.append(item); + updateLinesPosition(); + m_isAddingLine = false; + m_plot->replot(); + return true; + } + } + + // ===== 模式C:添加点(Shift,未完成) ===== + if (m_type == TypeC_Closed && shiftPressed && !m_cFinished) { + if (s_activeItem && s_activeItem != this) s_activeItem->deactivate(); + s_activeItem = this; + setDragPointsVisible(true); + double x = m_plot->xAxis->pixelToCoord(me->pos().x()); + double y = m_plot->yAxis->pixelToCoord(me->pos().y()); + QPointF pt(x - m_offsetXC, y - m_offsetYC); + m_pointsC.append(pt); + QCPItemText *label = new QCPItemText(m_plot); + label->setText(" "); + label->setFont(QFont("Arial", 6, QFont::Bold)); + label->setColor(Qt::black); + label->setBrush(QBrush(Qt::black)); + label->setPen(QPen(Qt::black, 1)); + label->position->setCoords(x, y); + label->setPositionAlignment(Qt::AlignCenter); + label->setLayer("overlay"); + label->setVisible(true); + m_labelsC.append(label); + updatePolylineC(false); + m_plot->replot(); + return true; + } + + // ===== 模式C:完成封闭(非Shift,未完成) ===== + if (m_type == TypeC_Closed && !shiftPressed && !m_cFinished) { + if (m_pointsC.size() >= 3) { + m_cFinished = true; + updatePolylineC(true); + m_plot->replot(); + if (m_editingMode) { + finishEditing(); } - else{ - // 扩充后的裂缝表 - mrw.ReadTable(iIndex,i+1,(void*)&frac); + } else { + clearPolylineC(); + } + if (s_activeItem == this) { + s_activeItem->deactivate(); + s_activeItem = nullptr; + } + return true; + } + + // ===== 编辑模式下,模式B:非Shift左键点击空白结束编辑 ===== + if (m_type == TypeB_Polyline && !shiftPressed && m_editingMode && !m_isAddingLine) { + finishEditing(); + return true; + } + + // ===== 模式A:拖拽点或曲线 ===== + if (m_type == TypeA_Sine && !shiftPressed) { + QPointF pixel = me->localPos(); + double d1 = m_tracer1->selectTest(pixel, false); + double d2 = m_tracer2->selectTest(pixel, false); + double curveDist = m_curve->selectTest(pixel, false); + if (d1 >= 0 && d1 < 15 || d2 >= 0 && d2 < 15 || (curveDist >= 0 && curveDist < 5)) { + if (s_activeItem && s_activeItem != this) s_activeItem->deactivate(); + s_activeItem = this; + setDragPointsVisible(true); + if (d1 >= 0 && d1 < 15) { + m_dragStateA = DraggingPoint1; + setTracerHighlight(m_tracer1, true); + } else if (d2 >= 0 && d2 < 15) { + m_dragStateA = DraggingPoint2; + setTracerHighlight(m_tracer2, true); + } else { + m_dragStateA = DraggingCurveA; + m_lastDragPixelA = pixel; } + return true; + } + } - for (j=0; jlocalPos(); + for (int i = 0; i < m_lines.size(); ++i) { + auto &item = m_lines[i]; + if (item.startTracer->selectTest(pixel, false) >= 0 && item.startTracer->selectTest(pixel, false) < 10) { + if (s_activeItem && s_activeItem != this) s_activeItem->deactivate(); + s_activeItem = this; + setDragPointsVisible(true); + m_dragStateB = DraggingStartPoint; + m_draggedLineIndex = i; + m_bDragStart = pixel; + return true; + } + if (item.endTracer->selectTest(pixel, false) >= 0 && item.endTracer->selectTest(pixel, false) < 10) { + if (s_activeItem && s_activeItem != this) s_activeItem->deactivate(); + s_activeItem = this; + setDragPointsVisible(true); + m_dragStateB = DraggingEndPoint; + m_draggedLineIndex = i; + m_bDragStart = pixel; + return true; + } + } + for (int i = 0; i < m_lines.size(); ++i) { + double dist = m_lines[i].line->selectTest(pixel, false); + if (dist >= 0 && dist < 3) { + if (s_activeItem && s_activeItem != this) s_activeItem->deactivate(); + s_activeItem = this; + setDragPointsVisible(true); + m_dragStateB = DraggingLineOverall; + m_bDragStart = pixel; + return true; + } + } + } - // - drawOne(frac, cs, iType, nLineWidth, crColor); - break; + // ===== 模式C:拖拽点或整体(已完成,非编辑模式) ===== + if (m_type == TypeC_Closed && !shiftPressed && m_cFinished && !m_editingMode) { + QPointF pixel = me->localPos(); + int hitPoint = -1; + for (int i = 0; i < m_labelsC.size(); ++i) { + if (m_labelsC[i]->selectTest(pixel, false) >= 0 && m_labelsC[i]->selectTest(pixel, false) < 10) { + hitPoint = i; + break; + } + } + if (hitPoint >= 0) { + if (s_activeItem && s_activeItem != this) s_activeItem->deactivate(); + s_activeItem = this; + setDragPointsVisible(true); + m_draggingPoint = true; + m_draggedPointIndex = hitPoint; + m_cDragStart = pixel; + return true; + } else { + double curveDist = m_curveC ? m_curveC->selectTest(pixel, false) : -1; + if (curveDist >= 0 && curveDist < 3) { + if (s_activeItem && s_activeItem != this) s_activeItem->deactivate(); + s_activeItem = this; + setDragPointsVisible(true); + m_cDragging = true; + m_cDragStart = pixel; + return true; + } else { + if (s_activeItem == this) { + s_activeItem->deactivate(); + s_activeItem = nullptr; } } } - mrw.CloseTable(iIndex); } - mrw.Close(); //关闭井文件 } + + // 鼠标移动 + if (event->type() == QEvent::MouseMove) { + if (s_activeItem != this) return false; + + if (m_type == TypeA_Sine) { + if (m_dragStateA == DraggingPoint1 || m_dragStateA == DraggingPoint2) { + double newY = m_plot->yAxis->pixelToCoord(me->localPos().y()); + double currentY = (m_dragStateA == DraggingPoint1) ? m_orig_y1 : m_orig_y2; + double deltaY = newY - (currentY + m_offsetYA); + double newOrigY = currentY + deltaY; + newOrigY = qBound(m_depth - 100, newOrigY, m_depth + 100); + if (m_dragStateA == DraggingPoint1) m_orig_y1 = newOrigY; + else m_orig_y2 = newOrigY; + updateCurveFromTargets(); + updateCurvePosition(); + updateTracers(); + m_plot->replot(); + return true; + } else if (m_dragStateA == DraggingCurveA) { + QPointF current = me->localPos(); + double oldX = m_plot->xAxis->pixelToCoord(m_lastDragPixelA.x()); + double newX = m_plot->xAxis->pixelToCoord(current.x()); + double oldY = m_plot->yAxis->pixelToCoord(m_lastDragPixelA.y()); + double newY = m_plot->yAxis->pixelToCoord(current.y()); + double dx = newX - oldX; + double dy = newY - oldY; + m_offsetXA += dx; + m_offsetYA += dy; + updateCurvePosition(); + updateTracers(); + m_plot->replot(); + m_lastDragPixelA = current; + return true; + } + } + else if (m_type == TypeB_Polyline && m_dragStateB != IdleB) { + QPointF current = me->localPos(); + double oldX = m_plot->xAxis->pixelToCoord(m_bDragStart.x()); + double newX = m_plot->xAxis->pixelToCoord(current.x()); + double oldY = m_plot->yAxis->pixelToCoord(m_bDragStart.y()); + double newY = m_plot->yAxis->pixelToCoord(current.y()); + double dx = newX - oldX; + double dy = newY - oldY; + if (m_dragStateB == DraggingLineOverall) { + m_offsetXB += dx; + m_offsetYB += dy; + updateLinesPosition(); + } else if (m_dragStateB == DraggingStartPoint || m_dragStateB == DraggingEndPoint) { + int idx = m_draggedLineIndex; + if (idx >= 0 && idx < m_lines.size()) { + LineItem &item = m_lines[idx]; + if (m_dragStateB == DraggingStartPoint) { + item.startOrig.rx() += dx; + item.startOrig.ry() += dy; + } else { + item.endOrig.rx() += dx; + item.endOrig.ry() += dy; + } + item.line->start->setCoords(item.startOrig.x() + m_offsetXB, item.startOrig.y() + m_offsetYB); + item.line->end->setCoords(item.endOrig.x() + m_offsetXB, item.endOrig.y() + m_offsetYB); + updateLineEndpoints(item); + } + } + m_plot->replot(); + m_bDragStart = current; + return true; + } + else if (m_type == TypeC_Closed) { + if (m_cDragging) { + QPointF current = me->localPos(); + double oldX = m_plot->xAxis->pixelToCoord(m_cDragStart.x()); + double newX = m_plot->xAxis->pixelToCoord(current.x()); + double oldY = m_plot->yAxis->pixelToCoord(m_cDragStart.y()); + double newY = m_plot->yAxis->pixelToCoord(current.y()); + double dx = newX - oldX; + double dy = newY - oldY; + m_offsetXC += dx; + m_offsetYC += dy; + for (int i = 0; i < m_pointsC.size(); ++i) { + m_labelsC[i]->position->setCoords(m_pointsC[i].x() + m_offsetXC, m_pointsC[i].y() + m_offsetYC); + } + updatePolylineC(true); + m_plot->replot(); + m_cDragStart = current; + return true; + } else if (m_draggingPoint) { + QPointF current = me->localPos(); + double oldX = m_plot->xAxis->pixelToCoord(m_cDragStart.x()); + double newX = m_plot->xAxis->pixelToCoord(current.x()); + double oldY = m_plot->yAxis->pixelToCoord(m_cDragStart.y()); + double newY = m_plot->yAxis->pixelToCoord(current.y()); + double dx = newX - oldX; + double dy = newY - oldY; + m_pointsC[m_draggedPointIndex].rx() += dx; + m_pointsC[m_draggedPointIndex].ry() += dy; + m_labelsC[m_draggedPointIndex]->position->setCoords(m_pointsC[m_draggedPointIndex].x() + m_offsetXC, + m_pointsC[m_draggedPointIndex].y() + m_offsetYC); + updatePolylineC(true); + m_plot->replot(); + m_cDragStart = current; + return true; + } + } + } + + // 鼠标释放:发射 dataChanged 信号(仅非编辑模式) + if (event->type() == QEvent::MouseButtonRelease && me->button() == Qt::LeftButton) { + if (s_activeItem == this && !m_editingMode) { + if (m_type == TypeA_Sine && m_dragStateA != IdleA) { + setTracerHighlight(m_tracer1, false); + setTracerHighlight(m_tracer2, false); + m_dragStateA = IdleA; + emit dataChanged(); + return true; + } else if (m_type == TypeB_Polyline && m_dragStateB != IdleB) { + m_dragStateB = IdleB; + m_draggedLineIndex = -1; + emit dataChanged(); + return true; + } else if (m_type == TypeC_Closed) { + if (m_cDragging) { + m_cDragging = false; + emit dataChanged(); + return true; + } else if (m_draggingPoint) { + m_draggingPoint = false; + m_draggedPointIndex = -1; + emit dataChanged(); + return true; + } + } + } + } + return false; } -// -void CPickFrac::drawOne(FRAC_TABLE_Crack frac, QString cs, int iType, int nLineWidth, QColor crColor) +// ==================== 新建裂缝 ==================== +bool CPickFrac::createNewCrack(int iType, double depth) { - int j,nPoint=360; - float x,y,h,oy; - float PI,xScale,xx; - PI=2.*3.14159265/(float)nPoint; - h = frac.AorX/2.0; - oy = -(frac.DEP+h); - - xScale=(float)(nPoint)/(float)(m_iMyWidth); - - QPen pPen(crColor, nLineWidth); - QVector xVec, yVec; - - switch ( iType ) - { - case 1: //正弦曲线 - nPoint = 360; - for(j=0; jxAxis->coordToPixel(tempValue) - - xVec.append(x); - yVec.append(y); - } -// for(j=0; jstart->setCoords(yVec[j], xVec[j]); -// qcpItemLine->end->setCoords(yVec[j+1], xVec[j+1]); -// qcpItemLine->setPen(pPen); -// } - - { - // - m_myCustomPlot->addGraph(); - QString strLineName = ""; - if(strLineName=="") - { - strLineName = QString("曲线 %1").arg(m_myCustomPlot->graphCount()); - } - m_myCustomPlot->graph()->setName(strLineName); - m_myCustomPlot->graph()->setData(xVec, yVec); - m_myCustomPlot->graph()->setLineStyle((QCPGraph::LineStyle)(QCPGraph::lsLine));//lsNone 曲线 lsLine - m_myCustomPlot->graph()->setScatterStyle(QCPScatterStyle((QCPScatterStyle::ScatterShape)(QCPScatterStyle::ssDot)));//ssNone点ssDot - // - QPen graphPen; - graphPen.setColor(crColor); - graphPen.setWidthF(nLineWidth); - graphPen.setStyle(Qt::SolidLine);//实线 - m_myCustomPlot->graph()->setPen(graphPen); + // 从配置文件中查找第一个匹配 iType 的定义,获取颜色和线宽 + FRAC_DEF_Crack def; + bool found = false; + for (const FRAC_DEF_Crack &d : m_FracDef) { + if (d.iType == iType) { + def = d; + found = true; + break; } - break; - case 2: //连线 - nPoint = frac.NUM; - for(j=0; jstart->setCoords(frac.point[j].x/8, -frac.point[j].y); - qcpItemLine->end->setCoords(frac.point[j+1].x/8, -frac.point[j+1].y); - qcpItemLine->setPen(pPen); - j++;//j+2 - } - break; - case 3: // 封闭区域 - nPoint = frac.NUM; - for(j=0; jstart->setCoords(frac.point[j].x / 8, -frac.point[j].y); - if(j>=(nPoint-1)) - { - qcpItemLine->end->setCoords(frac.point[0].x / 8, -frac.point[0].y); - } - else - { - qcpItemLine->end->setCoords(frac.point[j+1].x / 8, -frac.point[j+1].y); - } - qcpItemLine->setPen(pPen); - } - break; - case 4: //直线 - nPoint = frac.NUM; - if(nPoint>=2) - { - QCPItemStraightLine *qcpItemLine = new QCPItemStraightLine(m_myCustomPlot); - qcpItemLine->point1->setCoords(frac.point[0].x, -frac.point[0].y);//位置 - qcpItemLine->point2->setCoords(frac.point[1].x, -frac.point[1].y);//位置 - qcpItemLine->setPen(pPen); - } - break; } + if (!found) { + def.iType = iType; + def.crColor = QColor(255, 0, 0); + def.nLineWidth = 2; + } + + if (!m_myCustomPlot) return false; + double xMin = m_myCustomPlot->xAxis->range().lower; + double xMax = m_myCustomPlot->xAxis->range().upper; + double xCenter = (xMin + xMax) / 2.0; + double xWidth = xMax - xMin; + double yPos = -depth; + + DraggableCrackItem *item = nullptr; + + if (iType == 1) { + item = new DraggableCrackItem(m_myCustomPlot, DraggableCrackItem::TypeA_Sine, def.crColor, def.nLineWidth); + double amplitude = 0.5; + double phase = 0.0; + double width = xWidth * 0.8; + double xScale = 360.0 / width; + double centerY = -(depth + amplitude); + item->setSineData(centerY, amplitude, phase, xScale, width); + item->setCrackCode(def.iCode); + connect(item, &DraggableCrackItem::dataChanged, this, &CPickFrac::saveToFile); + connect(item, &DraggableCrackItem::removeMe, this, &CPickFrac::onRemoveCrackItem); + m_items.append(item); + bool saved = saveToFile(); + m_myCustomPlot->replot(); + return saved; + } + else if (iType == 2) { + item = new DraggableCrackItem(m_myCustomPlot, DraggableCrackItem::TypeB_Polyline, def.crColor, def.nLineWidth); + item->setCrackCode(def.iCode); + connect(item, &DraggableCrackItem::dataChanged, this, &CPickFrac::saveToFile); + connect(item, &DraggableCrackItem::removeMe, this, &CPickFrac::onRemoveCrackItem); + m_items.append(item); + item->startEditing(); + m_myCustomPlot->replot(); + return true; + } + else if (iType == 3) { + item = new DraggableCrackItem(m_myCustomPlot, DraggableCrackItem::TypeC_Closed, def.crColor, def.nLineWidth); + item->setCrackCode(def.iCode); + connect(item, &DraggableCrackItem::dataChanged, this, &CPickFrac::saveToFile); + connect(item, &DraggableCrackItem::removeMe, this, &CPickFrac::onRemoveCrackItem); + m_items.append(item); + item->startEditing(); + m_myCustomPlot->replot(); + return true; + } + return false; } diff --git a/logPlus/PickFrac.h b/logPlus/PickFrac.h index b96ed36..cc3819d 100644 --- a/logPlus/PickFrac.h +++ b/logPlus/PickFrac.h @@ -2,75 +2,190 @@ #define DrawFrac_H #include -#include "qmycustomplot.h" +#include +#include +#include +#include +#include -//裂缝 -//const int iFracType=15; +class QMyCustomPlot; +class QCustomPlot; +class QCPItemCurve; +class QCPItemTracer; +class QCPItemLine; +class QCPCurve; +class QCPItemText; -typedef struct tagPOINTF -{ - float x; - float y; -} POINTF; +static const int iFracType2 = 15; -typedef struct -{ - int iCode; //代码 - QString csName;// 名称 - int iType; //形状代码(1:正弦曲线 2:连线 3:封闭区域) - QColor crColor; //颜色(红 绿 蓝) - int nLineWidth;//线宽度 - int bDraw; // 是否显示 -}FRAC_DEF_Crack; +typedef struct tagPOINTF { float x; float y; } POINTF; -typedef struct -{ - float DEP; - float AorX; //XRMI_DYN_DipHeight - float XETAorH;//XRMI_DYN_Azimuth - float W; - float DIPorS;//XRMI_DYN_Dip_APP - float DIR;//XRMI_DYN_Azimuth - float TDIP; //真倾角 Dip_TRU - float TDIR; //真倾向 Azimuth - float ID;//裂缝代码,type - float NUM; - //float X[16],Y[16];//X0,Y0,X1,Y1,X2,Y2,X3,Y3,X4,Y4,X5,Y5,X6,Y6,X7,Y7,X8,Y8,X9,Y9; - POINTF point[16]; -}FRAC_TABLE_Crack; +typedef struct { + int iCode; + QString csName; + int iType; // 1:正弦曲线 2:连线 3:封闭区域 4:直线 + QColor crColor; + int nLineWidth; + int bDraw; +} FRAC_DEF_Crack; -typedef struct -{ +typedef struct { float DEP; float AorX; float XETAorH; float W; float DIPorS; float DIR; - float ID;//裂缝代码 -}FRAC_TABLE_OLD_Crack; + float TDIP; + float TDIR; + float ID; + float NUM; + POINTF point[16]; +} FRAC_TABLE_Crack; + +typedef struct { + float DEP; + float AorX; + float XETAorH; + float W; + float DIPorS; + float DIR; + float ID; +} FRAC_TABLE_OLD_Crack; + +class DraggableCrackItem; + +class CPickFrac : public QObject +{ + Q_OBJECT -class CPickFrac:public QObject -{ - Q_OBJECT public: CPickFrac(QMyCustomPlot *widget, QString strSlfName, QString csCurve, int iMyWidth); - virtual ~CPickFrac(void); + virtual ~CPickFrac(); + + void setDraggingEnabled(bool enabled); + QList getAllItems() const { return m_items; } + bool saveToFile(); + bool createNewCrack(int iType, double depth); // 根据形状类型创建 public: - QString m_Name; - QString m_strDevi, m_strHazi; - QList m_FracDef; - bool m_bTypeDraw[iFracType]; - QMyCustomPlot *m_myCustomPlot; - int m_iMyWidth=0; -public: + int m_iMyWidth = 0; + QList m_FracDef; + bool m_bTypeDraw[iFracType2]; + void ReadFracDef(); void ReadData(QString strSlfName, QString csCurve); - void drawOne(FRAC_TABLE_Crack frac, QString cs, int iType, int nLineWidth, QColor crColor); + void drawOne(FRAC_TABLE_Crack frac, int iType, int nLineWidth, QColor crColor); -public slots: +protected: + bool eventFilter(QObject *watched, QEvent *event) override; +private slots: + void onRemoveCrackItem(DraggableCrackItem *item); + +private: + QList m_items; + bool m_draggingEnabled = true; + QString m_currentSlfName; + QString m_currentTableName; }; + +// ========== 可拖拽裂缝项 ========== +class DraggableCrackItem : public QObject +{ + Q_OBJECT +public: + enum Type { TypeA_Sine, TypeB_Polyline, TypeC_Closed }; + DraggableCrackItem(QCustomPlot *plot, Type type, const QColor &color, int lineWidth); + ~DraggableCrackItem(); + + void setSineData(double depth, double amplitude, double phase, double xScale, double width); + void setPolylineData(const QVector &points, double scaleX = 1.0, double flipY = -1.0); + void setClosedData(const QVector &points, double scaleX = 1.0, double flipY = -1.0); + void setVisible(bool visible); + void deactivate(); + bool eventFilter(QObject *obj, QEvent *event) override; + + // 保存接口 + Type getType() const { return m_type; } + void setCrackCode(int code) { m_crackCode = code; } + int getCrackCode() const { return m_crackCode; } + double getDepthForSort() const; + void getCurrentFracData(FRAC_TABLE_Crack &data) const; + + // 编辑模式 + void startEditing(); + void finishEditing(); + + // 控制所有拖拽点的可见性 + void setDragPointsVisible(bool visible); + + // 获取当前激活的item(静态) + static DraggableCrackItem* getActiveItem() { return s_activeItem; } + +signals: + void dataChanged(); + void removeMe(DraggableCrackItem* item); + +private: + QCustomPlot *m_plot; + Type m_type; + QColor m_color; + int m_lineWidth; + int m_crackCode = 0; + double m_originalXETAorH = 0.0; + double m_originalAorX = 0.0; + + // 模式A + QCPItemCurve *m_curve = nullptr; + QCPItemTracer *m_tracer1 = nullptr, *m_tracer2 = nullptr; + double m_orig_x1, m_orig_x2, m_orig_y1, m_orig_y2; + double m_orig_startX, m_orig_endX, m_orig_startDirX, m_orig_startDirY, m_orig_endDirX, m_orig_endDirY; + double m_offsetXA = 0.0, m_offsetYA = 0.0; + double m_depth = 0.0, m_endX = 0.0; + enum DragStateA { IdleA, DraggingPoint1, DraggingPoint2, DraggingCurveA } m_dragStateA = IdleA; + QPointF m_lastDragPixelA; + + // 模式B + struct LineItem { + QCPItemLine *line; + QCPItemTracer *startTracer, *endTracer; + QPointF startOrig, endOrig; + }; + QList m_lines; + double m_offsetXB = 0.0, m_offsetYB = 0.0; + bool m_isAddingLine = false; + QPointF m_tempPoint; + enum DragStateB { IdleB, DraggingStartPoint, DraggingEndPoint, DraggingLineOverall } m_dragStateB = IdleB; + QPointF m_bDragStart; + int m_draggedLineIndex = -1; + + // 模式C + QCPCurve *m_curveC = nullptr; + QVector m_pointsC; + QVector m_labelsC; + double m_offsetXC = 0.0, m_offsetYC = 0.0; + bool m_cFinished = false, m_cDragging = false, m_draggingPoint = false; + int m_draggedPointIndex = -1; + QPointF m_cDragStart; + + // 编辑模式标志 + bool m_editingMode = false; + bool m_pendingDelete = false; // 标记是否即将删除 + + // 辅助函数 + void updateCurveFromTargets(); + void updateCurvePosition(); + void updateTracers(); + void setTracerHighlight(QCPItemTracer *tracer, bool highlight); + void updateLineEndpoints(LineItem &item); + void updateLinesPosition(); + void clearLines(); + void updatePolylineC(bool closed); + void clearPolylineC(); + + static QPointer s_activeItem; +}; + #endif diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index 9a79368..c0f6837 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -3995,6 +3995,7 @@ void FormDraw::s_addCrack(QString strUuid, QString strSlfName, QString strWellNa //注意,不对调XY轴 curv->m_bX2Y = false; CPickFrac *pickFrac = new CPickFrac(curv, strSlfName, strWaveName, iMyWidth); + curv->m_cPickFrac = pickFrac; // connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*))); diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 246040c..090493a 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -2189,8 +2189,23 @@ void QMyCustomPlot::addCrackObject() double depth = editDepth->text().toDouble(); QString type = cbbType->currentText(); QString showNames = ""; - auto curve = new TransparentDraggableCrackObject(this, strUuid, -depth, type, showNames); - m_mapDraggable_CrackObject[strUuid] = curve; + + if("高导缝" == type) + { + this->m_cPickFrac->createNewCrack(1 ,depth); + } + else if("网状缝" == type) + { + this->m_cPickFrac->createNewCrack(2 ,depth); + } + else if("孔洞" == type) + { + this->m_cPickFrac->createNewCrack(3 ,depth); + } +// auto curve = new CPickFrac(this, strUuid, -depth, type, showNames); + +// m_mapDraggable_CrackObject[strUuid] = curve; + // ========= 这里就是你要的结果!========= // qDebug() << "深度:" << depth << " 类型:" << type; } diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index 9307111..1f72d54 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -5,10 +5,12 @@ #include "LogIO.h" #include "QCPSizeHandleManager.h" #include "qtColorSchemeComboBox.h" +#include "PickFrac.h" #pragma execution_character_set("utf-8") -const int iFracType=15; +const int iFracType = 15; +class CPickFrac; // #define SideWallCoreWidth 1.2 @@ -765,6 +767,8 @@ public: // void Draw_Jykt(); + CPickFrac *m_cPickFrac; + private: }; From 30d7301cd6cdd57096c037272c5ae7ff3546933b Mon Sep 17 00:00:00 2001 From: crqiqi77 Date: Thu, 23 Apr 2026 09:38:17 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E8=A3=82=E7=BC=9D=20=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logPlus/PickFrac.cpp | 71 ++++++++++++++++++++++++++++++++++++-------- logPlus/PickFrac.h | 8 +++-- 2 files changed, 64 insertions(+), 15 deletions(-) diff --git a/logPlus/PickFrac.cpp b/logPlus/PickFrac.cpp index ef1f38c..3f9b6d9 100644 --- a/logPlus/PickFrac.cpp +++ b/logPlus/PickFrac.cpp @@ -183,6 +183,7 @@ bool CPickFrac::saveToFile() return false; } + // 如果没有裂缝,清空表记录 if (m_items.isEmpty()) { logio->SetTableRecordCount(iIndex, 0); logio->CloseTable(iIndex); @@ -191,6 +192,7 @@ bool CPickFrac::saveToFile() return true; } + // 按深度排序 QMap sortedMap; for (DraggableCrackItem *item : m_items) { double depth = item->getDepthForSort(); @@ -216,11 +218,46 @@ void CPickFrac::onRemoveCrackItem(DraggableCrackItem *item) { if (!item) return; if (m_items.removeOne(item)) { + // 立即从画布移除所有图形项 + item->cleanupFromPlot(); + // 失活并清空静态指针 + if (DraggableCrackItem::getActiveItem() == item) { + item->deactivate(); + } + // 断开信号 disconnect(item, nullptr, this, nullptr); - // 延迟删除,确保当前事件完全结束 - QTimer::singleShot(0, item, &QObject::deleteLater); - saveToFile(); + // 直接删除,不再延迟 + delete item; + // 强制重绘 m_myCustomPlot->replot(); + // 保存文件 + saveToFile(); + } +} + +void DraggableCrackItem::cleanupFromPlot() +{ + if (m_type == TypeA_Sine) { + if (m_curve) m_plot->removeItem(m_curve); + if (m_tracer1) m_plot->removeItem(m_tracer1); + if (m_tracer2) m_plot->removeItem(m_tracer2); + } else if (m_type == TypeB_Polyline) { + for (auto &item : m_lines) { + if (item.line) m_plot->removeItem(item.line); + if (item.startTracer) m_plot->removeItem(item.startTracer); + if (item.endTracer) m_plot->removeItem(item.endTracer); + } + m_lines.clear(); + } else if (m_type == TypeC_Closed) { + if (m_curveC) { + m_plot->removePlottable(m_curveC); + m_curveC = nullptr; + } + for (auto label : m_labelsC) { + if (label) m_plot->removeItem(label); + } + m_labelsC.clear(); + m_pointsC.clear(); } } @@ -316,12 +353,15 @@ void DraggableCrackItem::deactivate() m_draggedPointIndex = -1; setDragPointsVisible(false); } - if (s_activeItem == this) s_activeItem = nullptr; + if (s_activeItem == this) { + s_activeItem = nullptr; + } m_plot->replot(); } void DraggableCrackItem::setDragPointsVisible(bool visible) { + if (m_pendingDelete) return; if (m_type == TypeA_Sine) { if (m_tracer1) m_tracer1->setVisible(visible); if (m_tracer2) m_tracer2->setVisible(visible); @@ -340,6 +380,7 @@ void DraggableCrackItem::setDragPointsVisible(bool visible) void DraggableCrackItem::startEditing() { + if (m_pendingDelete) return; m_editingMode = true; if (s_activeItem && s_activeItem != this) s_activeItem->deactivate(); s_activeItem = this; @@ -470,7 +511,6 @@ void DraggableCrackItem::setPolylineData(const QVector &points, double item.startTracer = startTracer; item.endTracer = endTracer; m_lines.append(item); - i++; } updateLinesPosition(); } @@ -493,9 +533,9 @@ void DraggableCrackItem::updateLinesPosition() void DraggableCrackItem::clearLines() { for (auto &item : m_lines) { - if (item.line) { m_plot->removeItem(item.line); delete item.line; } - if (item.startTracer) { m_plot->removeItem(item.startTracer); delete item.startTracer; } - if (item.endTracer) { m_plot->removeItem(item.endTracer); delete item.endTracer; } + if (item.line) { m_plot->removeItem(item.line); } + if (item.startTracer) { m_plot->removeItem(item.startTracer); } + if (item.endTracer) { m_plot->removeItem(item.endTracer); } } m_lines.clear(); m_plot->replot(); @@ -547,8 +587,7 @@ void DraggableCrackItem::clearPolylineC() { for (auto label : m_labelsC) { if (label) { - label->setParent(nullptr); - delete label; + m_plot->removeItem(label); } } m_labelsC.clear(); @@ -640,10 +679,10 @@ bool DraggableCrackItem::eventFilter(QObject *obj, QEvent *event) QAction *selectedAction = menu.exec(ce->globalPos()); if (selectedAction == deleteAction) { m_pendingDelete = true; - deactivate(); // 清空全局激活指针 - emit removeMe(this); + deactivate(); // 清空全局激活指针 + emit removeMe(this); // 触发删除 } - return true; + return true; // 阻止事件继续传递 } return false; } @@ -976,6 +1015,12 @@ bool DraggableCrackItem::eventFilter(QObject *obj, QEvent *event) } } } + + if (s_activeItem == this) { + s_activeItem->deactivate(); + s_activeItem = nullptr; + return true; + } } return false; } diff --git a/logPlus/PickFrac.h b/logPlus/PickFrac.h index cc3819d..0cac56a 100644 --- a/logPlus/PickFrac.h +++ b/logPlus/PickFrac.h @@ -66,7 +66,7 @@ public: void setDraggingEnabled(bool enabled); QList getAllItems() const { return m_items; } bool saveToFile(); - bool createNewCrack(int iType, double depth); // 根据形状类型创建 + bool createNewCrack(int iType, double depth); public: QMyCustomPlot *m_myCustomPlot; @@ -124,6 +124,8 @@ public: // 获取当前激活的item(静态) static DraggableCrackItem* getActiveItem() { return s_activeItem; } + void cleanupFromPlot(); // 立即从画布移除所有图形项 + signals: void dataChanged(); void removeMe(DraggableCrackItem* item); @@ -172,7 +174,9 @@ private: // 编辑模式标志 bool m_editingMode = false; - bool m_pendingDelete = false; // 标记是否即将删除 + + // 删除安全标志 + bool m_pendingDelete = false; // 辅助函数 void updateCurveFromTargets(); From 137a2e15c350d1eb0c54fe0d4bd782b5932b3228 Mon Sep 17 00:00:00 2001 From: jiayulong Date: Thu, 23 Apr 2026 11:57:08 +0800 Subject: [PATCH 7/7] =?UTF-8?q?1.=E4=BA=95=E6=96=9C=E6=96=B9=E4=BD=8D?= =?UTF-8?q?=E5=9B=BE=E8=BF=BD=E5=8A=A0=E5=B1=9E=E6=80=A7=202.=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=BB=8Ejson=E5=8A=A0=E8=BD=BD=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CallManage/CallManage.h | 3 + logPlus/PropertyWidget.cpp | 122 +++++++++++++++++++- logPlus/PropertyWidget.h | 5 + logPlus/formdraw.cpp | 222 +++++++++++++++--------------------- logPlus/formdraw.h | 7 +- logPlus/forminfo.cpp | 92 +++++++++++++-- logPlus/forminfo.h | 8 +- logPlus/formtrack.cpp | 207 ++------------------------------- logPlus/formtrack.h | 9 +- logPlus/mainwindowcurve.cpp | 53 ++------- logPlus/qmycustomplot.cpp | 122 ++++++++++++++++++++ logPlus/qmycustomplot.h | 12 +- 12 files changed, 466 insertions(+), 396 deletions(-) diff --git a/CallManage/CallManage.h b/CallManage/CallManage.h index ca5c73e..0a4bd07 100644 --- a/CallManage/CallManage.h +++ b/CallManage/CallManage.h @@ -272,6 +272,9 @@ signals: //改变井眼垮塌矢量图属性 void sig_changeJyktProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); + //改变井斜方位图属性 + void sig_changeDenvProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); + // //void sig_addImageToPlot(QMyCustomPlot* customPlot, double left_Low, double right_Hight, QString imagePath); diff --git a/logPlus/PropertyWidget.cpp b/logPlus/PropertyWidget.cpp index a126f75..dfd9840 100644 --- a/logPlus/PropertyWidget.cpp +++ b/logPlus/PropertyWidget.cpp @@ -2385,6 +2385,13 @@ void PropertyWidget::SlotPropertyChanged( QtProperty *pProperty, const QVariant // changedJyktProperty(m_propertyData[pProperty], variant); } + else if (m_strCurrentProperty == Denv_Property)//井斜方位图 + { + //先处理通用属性 + CommonPropertyChanged(pProperty, variant); + // + changedDenvProperty(m_propertyData[pProperty], variant); + } } void PropertyWidget::SlotPropertyChanged(QtProperty *property, const int &val, bool islinestyle) @@ -3220,6 +3227,11 @@ void PropertyWidget::initProperty(FormInfo *formInfo) //井眼垮塌矢量图 this->initJyktProperty(formInfo); } + else if (m_strLineName == "XIEFANGWEI.LINE") + { + //井斜方位图 + this->initDenvProperty(formInfo); + } else { this->initTableProperty(formInfo); @@ -5582,12 +5594,12 @@ void PropertyWidget::initJyktProperty(FormInfo *formInfo) _CreateVariantPropertyItem("崩落设置", "显示单位", formInfo->m_strUnit, QVariant::String); // _CreateVariantPropertyItem("蝌蚪设置", "圆半径", formInfo->m_nRadius, QVariant::Double); + _CreateVariantPropertyItem("蝌蚪设置", "圆填充色", formInfo->m_crPointFill, QVariant::Color); _CreateVariantPropertyItem("蝌蚪设置", "圆线宽度", formInfo->m_nCircleWidth, QVariant::Double); + _CreateVariantPropertyItem("蝌蚪设置", "圆线颜色", formInfo->m_crCircle, QVariant::Color); _CreateVariantPropertyItem("蝌蚪设置", "尾线长度", formInfo->m_nTailLen, QVariant::Double); _CreateVariantPropertyItem("蝌蚪设置", "尾线宽度", formInfo->m_nTailWidth, QVariant::Double); - _CreateVariantPropertyItem("蝌蚪设置", "圆线颜色", formInfo->m_crCircle, QVariant::Color); _CreateVariantPropertyItem("蝌蚪设置", "尾线颜色", formInfo->m_crTail, QVariant::Color); - _CreateVariantPropertyItem("蝌蚪设置", "圆填充色", formInfo->m_crPointFill, QVariant::Color); m_strCurrentProperty = Jykt_Property; } @@ -5676,3 +5688,109 @@ void PropertyWidget::changedJyktProperty(QString strProperty, QVariant varVal) emit CallManage::getInstance()->sig_changeJyktProperty(m_formInfo->m_strUuid, m_formInfo->m_strSlfName, m_formInfo->m_strWellName, m_formInfo->m_strTrackName, m_formInfo->m_strLineName); } } + + +void PropertyWidget::initDenvProperty(FormInfo *formInfo) +{ + _CreateVariantPropertyItem("曲线图名", "显示名称", formInfo->m_strAliasName, QVariant::String); + _CreateVariantPropertyItem("井文件名", "井文件名称", m_strSlfName, QVariant::String); + // + _CreateVariantPropertyItem("曲线选择", "方位曲线", formInfo->m_pl_azimuthCurve, QVariant::String); + _CreateVariantPropertyItem("曲线选择", "井斜曲线", formInfo->m_pl_deviCurve, QVariant::String); + // + _CreateVariantPropertyItem("曲线单位", "显示单位", formInfo->m_strUnit, QVariant::String); + // + _CreateVariantPropertyItem("蝌蚪符号", "左刻度", formInfo->m_vmin, QVariant::Double); + _CreateVariantPropertyItem("蝌蚪符号", "右刻度", formInfo->m_vmax, QVariant::Double); + _CreateVariantPropertyItem("蝌蚪符号", "深度间隔", formInfo->m_flStep, QVariant::Double); + // + _CreateVariantPropertyItem("蝌蚪符号", "圆半径", formInfo->m_nRadius, QVariant::Double); + _CreateVariantPropertyItem("蝌蚪符号", "圆填充色", formInfo->m_crPointFill, QVariant::Color); + _CreateVariantPropertyItem("蝌蚪符号", "圆线宽度", formInfo->m_nCircleWidth, QVariant::Double); + _CreateVariantPropertyItem("蝌蚪符号", "圆线颜色", formInfo->m_crCircle, QVariant::Color); + _CreateVariantPropertyItem("蝌蚪符号", "尾线长度", formInfo->m_nTailLen, QVariant::Double); + _CreateVariantPropertyItem("蝌蚪符号", "尾线宽度", formInfo->m_nTailWidth, QVariant::Double); + _CreateVariantPropertyItem("蝌蚪符号", "尾线颜色", formInfo->m_crTail, QVariant::Color); + + m_strCurrentProperty = Denv_Property; +} + +void PropertyWidget::changedDenvProperty(QString strProperty, QVariant varVal) +{ + bool flag = false; + // 字体 + if ("方位曲线" == strProperty) + { + this->m_formInfo->m_pl_azimuthCurve = varVal.toString(); + flag = true; + } + else if ("井斜曲线" == strProperty) + { + this->m_formInfo->m_pl_deviCurve = varVal.toString(); + flag = true; + } + // 蝌蚪符号 + else if ("圆半径" == strProperty) + { + this->m_formInfo->m_nRadius = varVal.toDouble(); + flag = true; + } + else if ("圆线宽度" == strProperty) + { + this->m_formInfo->m_nCircleWidth = varVal.toDouble(); + flag = true; + } + else if ("尾线长度" == strProperty) + { + this->m_formInfo->m_nTailLen = varVal.toDouble(); + flag = true; + } + else if ("尾线宽度" == strProperty) + { + this->m_formInfo->m_nTailWidth = varVal.toDouble(); + flag = true; + } + else if ("圆线颜色" == strProperty) + { + this->m_formInfo->m_crCircle = varVal.value(); + flag = true; + } + else if ("尾线颜色" == strProperty) + { + this->m_formInfo->m_crTail = varVal.value(); + flag = true; + } + else if ("圆填充色" == strProperty) + { + this->m_formInfo->m_crPointFill = varVal.value(); + flag = true; + } + // + else if ("左刻度" == strProperty) + { + this->m_formInfo->m_vmin = varVal.toDouble(); + this->m_formInfo->repaint(); + flag = true; + } + else if ("右刻度" == strProperty) + { + this->m_formInfo->m_vmax = varVal.toDouble(); + this->m_formInfo->repaint(); + flag = true; + } + else if ("深度间隔" == strProperty) + { + this->m_formInfo->m_flStep = varVal.toDouble(); + flag = true; + } + else if ("显示单位" == strProperty) + { + this->m_formInfo->m_strUnit = varVal.toString(); + this->m_formInfo->repaint(); + } + + if(flag) + { + emit CallManage::getInstance()->sig_changeDenvProperty(m_formInfo->m_strUuid, m_formInfo->m_strSlfName, m_formInfo->m_strWellName, m_formInfo->m_strTrackName, m_formInfo->m_strLineName); + } +} diff --git a/logPlus/PropertyWidget.h b/logPlus/PropertyWidget.h index 8e461c9..85daec9 100644 --- a/logPlus/PropertyWidget.h +++ b/logPlus/PropertyWidget.h @@ -80,6 +80,7 @@ #define Kedou_Property "Kedou_Property" //蝌蚪图 #define Ganzhuang_Property "Ganzhuang_Property" //杆状图 #define Jykt_Property "Jykt_Property" //井眼垮塌矢量图 +#define Denv_Property "Denv_Property" //井斜方位图 #pragma execution_character_set("utf-8") @@ -272,6 +273,10 @@ public: void initJyktProperty(FormInfo *formInfo); void changedJyktProperty(QString strProName, QVariant val); + //井斜方位图 + void initDenvProperty(FormInfo *formInfo); + void changedDenvProperty(QString strProName, QVariant val); + public slots: void SlotPropertyChanged(QtProperty *property, const QVariant &variant); void SlotPropertyChanged(QtProperty *property, const int &val, bool islinestyle); diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index c0f6837..15341f2 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -536,10 +536,10 @@ void FormDraw::DisplayLines(QJsonArray linesArray) // 岩心照片 displayImageData(lineObjInfo); } - else if (strLineName == "FRAC_HOLE.TABLE" || strLineName == "GANZHUANG.LINE" || strLineName == "JINGYANKUATA.LINE") + else if (strLineName == "FRAC_HOLE.TABLE" || strLineName == "GANZHUANG.LINE" || strLineName == "JINGYANKUATA.LINE" || strLineName == "XIEFANGWEI.LINE") { - // 蝌蚪图、杆状图 - DisplayKedou_One(lineObjInfo); + // 蝌蚪图、杆状图、井眼垮塌矢量图、井斜方位图 + DisplayKedouAndOthers_One(lineObjInfo); } } else if (strType == "JiegutextObject") @@ -1127,7 +1127,7 @@ void FormDraw::DisplayTable_One(QJsonObject lineObjInfo) } //蝌蚪图 -void FormDraw::DisplayKedou_One(QJsonObject lineObjInfo) +void FormDraw::DisplayKedouAndOthers_One(QJsonObject lineObjInfo) { QString strSlfName = ""; QString strWellName = ""; @@ -1194,8 +1194,8 @@ void FormDraw::DisplayKedou_One(QJsonObject lineObjInfo) if (strLineName != "") { - //蝌蚪图、杆状、井眼垮塌矢量图 - this->addKedou(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName, lineObjInfo); + //蝌蚪图、杆状、井眼垮塌矢量图、井斜方位图 + this->addKedouAndOthers(m_strUuid, strSlfName, strWellName, m_strTrackName, strLineName, lineObjInfo); } } @@ -3018,10 +3018,10 @@ QMyCustomPlot* FormDraw::addTableLine(QString strUuid, QString strSlfName, QStri return curv; } -QMyCustomPlot* FormDraw::addKedou(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QJsonObject listOtherProperty) +QMyCustomPlot* FormDraw::addKedouAndOthers(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QJsonObject listOtherProperty) { - //蝌蚪、杆状、井眼垮塌矢量图 - if (strLineName == "FRAC_HOLE.TABLE" || strLineName == "GANZHUANG.LINE" || strLineName == "JINGYANKUATA.LINE") + //蝌蚪、杆状、井眼垮塌矢量图、井斜方位图 + if (strLineName == "FRAC_HOLE.TABLE" || strLineName == "GANZHUANG.LINE" || strLineName == "JINGYANKUATA.LINE" || strLineName == "XIEFANGWEI.LINE") { } else @@ -3100,7 +3100,22 @@ QMyCustomPlot* FormDraw::addKedou(QString strUuid, QString strSlfName, QString s // initJykt(curv, strSlfName, strLineName, strAliasName, newlineColor, listOtherProperty); } - + else if(strLineName == "XIEFANGWEI.LINE") + { + QString strAliasName = "井斜方位图"; + QColor newlineColor=QColor(0,0,0); + // 显示名称 + // 显示名称 + if (listOtherProperty.contains("AliasName")) + { + QJsonValue value = listOtherProperty.value("AliasName"); + if (value.isString()) { + strAliasName = value.toString(); + } + } + // + initDenv(curv, strSlfName, strLineName, strAliasName, newlineColor, listOtherProperty); + } connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*))); // m_listLineName.push_back(strLineName); @@ -3759,7 +3774,7 @@ void FormDraw::s_addGanZhuangTu(QString strUuid, QString strSlfName, QString str m_listLineName.push_back(strLineName); } - +//井眼垮塌矢量图 void FormDraw::s_addJykt(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW) { //井名&道名不一致 @@ -3785,8 +3800,8 @@ void FormDraw::s_addJykt(QString strUuid, QString strSlfName, QString strWellNam curv->initGeometry(m_strUuid, m_iScale, g_iOneWidth); curv->show(); - initJykt(curv, strSlfName, strLineName); - + //井眼垮塌矢量图 + initJykt(curv, strSlfName, strLineName); // connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*))); @@ -3795,6 +3810,7 @@ void FormDraw::s_addJykt(QString strUuid, QString strSlfName, QString strWellNam m_listLineName.push_back(strLineName); } +//井斜方位图 void FormDraw::s_addDenv(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, int nW) { //井名&道名不一致 @@ -3818,21 +3834,11 @@ void FormDraw::s_addDenv(QString strUuid, QString strSlfName, QString strWellNam curv->m_formTrack = m_formTrack; curv->setDepthY(m_iY1, m_iY2); curv->initGeometry(m_strUuid, m_iScale, g_iOneWidth); - curv->show(); //井斜方位图 - DrawDenv(curv, strSlfName); + initDenv(curv, strSlfName, strLineName); - //道-对象 - QString strAliasName = "井斜方位图"; - QString strUnit = "(°)"; - QColor newlineColor=QColor(0,0,0); - double width=2; - QString strScaleType = ""; - //道-对象 - m_formTrack->Add(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "DenvObject"); - // connect(curv, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(s_mouseWheel(QWheelEvent*))); // @@ -5111,7 +5117,7 @@ void FormDraw::initKedou(QMyCustomPlot *widget, QString strSlfName, QString strL double width=2; QString strScaleType = ""; //道-对象 - FormInfo* pInfo = m_formTrack->AddKedou(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject", listOtherProperty); + FormInfo* pInfo = m_formTrack->AddKedouAndOthers(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject", listOtherProperty); //蝌蚪图 widget->Draw_Kedou(); @@ -5164,13 +5170,12 @@ void FormDraw::initGanzhuang(QMyCustomPlot *widget, QString strSlfName, QString strUnit = listOtherProperty["Unit"].toString(); // 单位 } //道-对象 - FormInfo* pInfo = m_formTrack->AddGanzhuang(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject", listOtherProperty); + FormInfo* pInfo = m_formTrack->AddKedouAndOthers(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject", listOtherProperty); //杆状图 widget->Draw_Ganzhuang(); } - //井眼垮塌矢量图 void FormDraw::initJykt(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName, QColor newlineColor, QJsonObject listOtherProperty) { @@ -5223,12 +5228,70 @@ void FormDraw::initJykt(QMyCustomPlot *widget, QString strSlfName, QString strLi strUnit = listOtherProperty["Unit"].toString(); // 单位 } //道-对象 - FormInfo* pInfo = m_formTrack->AddJykt(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject", listOtherProperty); + FormInfo* pInfo = m_formTrack->AddKedouAndOthers(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject", listOtherProperty); //杆状图 widget->Draw_Jykt(); } +//井斜方位图 +void FormDraw::initDenv(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName, QColor newlineColor, QJsonObject listOtherProperty) +{ + //隐藏网格 + widget->xAxis->grid()->setVisible(false); + widget->yAxis->grid()->setVisible(false); + // + widget->m_bRowGridVisible = false; + widget->m_bColGridVisible = false; + + //------------------- + m_LeftVal = 0; + m_RightVal = 90; + if(!listOtherProperty.isEmpty()) + { + m_LeftVal = listOtherProperty["vmin"].toDouble(); + m_RightVal = listOtherProperty["vmax"].toDouble(); + } + + float vmax = m_RightVal; + float vmin = m_LeftVal; + widget->setScaleX(vmin, vmax); + 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->xAxis->setTicks(false); + widget->yAxis->setTicks(false); + widget->xAxis2->setTicks(false); + widget->yAxis2->setTicks(false); + widget->xAxis->setVisible(false); + widget->xAxis2->setVisible(false); + widget->yAxis->setVisible(false); + widget->yAxis2->setVisible(false); + + //----------------------------------- + QString strUnit = "(°)"; + double width=2; + QString strScaleType = ""; + if(!listOtherProperty.isEmpty()) + { + strUnit = listOtherProperty["Unit"].toString(); // 单位 + } + //道-对象 + FormInfo* pInfo = m_formTrack->AddKedouAndOthers(strSlfName, m_strWellName, m_strTrackName, strLineName, strAliasName, strUnit, newlineColor, width, m_RightVal, m_LeftVal, strScaleType, "tableObject", listOtherProperty); + + //杆状图 + widget->Draw_Denv(); +} + void FormDraw::initWords(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName, QColor newlineColor, QStringList listOtherProperty) { int iMyWidth = widget->axisRect(0)->width(); @@ -6603,109 +6666,6 @@ void FormDraw::CalcDipWidth(int nColumn,float *flWidth,float factor,int x1,int x } } -void FormDraw::DrawDenv(QMyCustomPlot *widget, QString strSlfName) -{ - //初始化数据 - m_csCurveAZIM=("AZIM"); - m_csCurveDEVI=("DEVI"); - - m_nCircleLineWidth = 2 ; - m_nTailWidth=2; - m_TailColor=qRgb(255,0,0); - m_crPointFillDenv=qRgb(0,0,0); - m_crCirCleColor = qRgb(0,0,255); - m_nRadius = 4; - m_nTailLen=8; - m_flStep=1; - - //读取曲线数据 - this->ReadData(strSlfName, m_csCurveAZIM, 0, &m_Curve); - this->ReadData(strSlfName, m_csCurveDEVI, 1, &m_Curve2); - - //------------------- - m_LeftVal = 0; - m_RightVal = 90; - - float vmax = m_RightVal; - float vmin = m_LeftVal; - widget->setScaleX(vmin, vmax); - 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->xAxis->setTicks(false); - widget->yAxis->setTicks(false); - widget->xAxis2->setTicks(false); - widget->yAxis2->setTicks(false); - widget->xAxis->setVisible(false); - widget->xAxis2->setVisible(false); - widget->yAxis->setVisible(false); - widget->yAxis2->setVisible(false); - - // - QPen pPen(m_TailColor,m_nTailWidth); - QPen pPen2(m_crCirCleColor,m_nCircleLineWidth); - QBrush cBrush(m_crPointFillDenv); - - float tempf,flVal; - int i,j,nPointNum=0,tempi; - QRectF rt,rtRect; - float x,y; - float dgtord,dr; - - if ( m_Value==0 || m_Value2==0 ) - return ; - - // 计算显示深度 - tempf = (m_EDep - m_SDep)/m_Rlev + 0.5; - nPointNum = tempf+1; - if ( nPointNum <= 1 ) return ; - dgtord=3.14159265/180.; - - QBrush brush2(QColor(qRgb(0,0,0))); - { - for (float dep=m_SDep; depsetPen(pPen2); - qcpItemEllipse->m_bCustom = true; - qcpItemEllipse->m_nRadius = m_nRadius; - qcpItemEllipse->topLeft->setCoords(y, x);//圆心位置 - qcpItemEllipse->bottomRight->setCoords(y, x);//圆心位置 - qcpItemEllipse->setBrush(cBrush);//填充圆的颜色 - - // - flVal = GetData(m_Curve.RepCode,(char *)&m_Value[i*m_Curve.CodeLen]); - dr=flVal*dgtord; - - QCPItemLine *qcpItemLine = new QCPItemLine(widget); - qcpItemLine->start->setCoords(y, x);//圆心位置 - qcpItemLine->end->setCoords(y, x);//圆心位置 - qcpItemLine->setPen(pPen); - qcpItemLine->m_bCustom = true; - qcpItemLine->m_nTailLen = m_nTailLen; //尾长 - qcpItemLine->m_nRadius = m_nRadius; //半径 - qcpItemLine->m_dr = dr; - } - } -} - //read config file: FRAC.CFG,save info into m_FracDef void FormDraw::ReadFracDef() diff --git a/logPlus/formdraw.h b/logPlus/formdraw.h index 43fc6c5..b085966 100644 --- a/logPlus/formdraw.h +++ b/logPlus/formdraw.h @@ -47,7 +47,7 @@ public: //表格:固井结论等 void DisplayTable_One(QJsonObject lineObjInfo); //蝌蚪图 - void DisplayKedou_One(QJsonObject lineObjInfo); + void DisplayKedouAndOthers_One(QJsonObject lineObjInfo); //气测/FMT/射孔/文本 void DisplayJiegutext_One(QJsonObject lineObjInfo); @@ -91,7 +91,7 @@ protected: QMyCustomPlot* addTableLine(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QStringList listOtherProperty={}); - QMyCustomPlot* addKedou(QString strUuid, QString strSlfName, QString strWellName, + QMyCustomPlot* addKedouAndOthers(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QJsonObject listOtherProperty={}); public slots: @@ -154,6 +154,8 @@ public: void initGanzhuang(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName = "杆状图", QColor newlineColor=QColor(0,0,0), QJsonObject listOtherProperty={}); //井眼垮塌矢量图 void initJykt(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName = "井眼崩落矢量图", QColor newlineColor=QColor(0,0,0), QJsonObject listOtherProperty={}); + //井斜方位图 + void initDenv(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QString strAliasName = "井斜方位图", QColor newlineColor=QColor(0,0,0), QJsonObject listOtherProperty={}); void ReadFracDef(); void ReadData(QString strSlfName, QString strLineName);//表格 @@ -161,7 +163,6 @@ public: void CalcDipWidth(int nColumn,float *flWidth,float factor,int x1,int x2,float flHoriRatio); void Refurbish(); - void DrawDenv(QMyCustomPlot *widget, QString strSlfName); int m_PointNum; // diff --git a/logPlus/forminfo.cpp b/logPlus/forminfo.cpp index 07fb488..cf1614c 100644 --- a/logPlus/forminfo.cpp +++ b/logPlus/forminfo.cpp @@ -330,6 +330,65 @@ void FormInfo::initProperty_Jykt(QJsonObject obj) } } +void FormInfo::initProperty_Denv(QJsonObject obj) +{ + if(obj.isEmpty()) + { + // 字体 + + // 曲线选择 + this->m_pl_azimuthCurve = "AZIM"; // 方位曲线 + this->m_pl_deviCurve = "DEVI"; // 井斜曲线 + + //蝌蚪符号 + this->m_nRadius = 6; // 圆半径 + this->m_nCircleWidth = 1; // 圆线宽度 + this->m_nTailLen = 10; // 尾线长度 + this->m_nTailWidth = 2; // 尾线宽度 + + // 显示控制 + this->m_vmin = 0; // 左刻度 + this->m_vmax = 90; // 右刻度 + this->m_flStep = 1; // 深度间隔 + // + this->m_strUnit = "(°)"; + } + else + { + QString strType = obj.value("Type").toString(); + if ("tableObject" == strType) + { + // 字体 + // 名称 + this->m_curveNameFont.fromString(obj["curveNameFont"].toString()); + // 单位 + this->m_strUnitFont.fromString(obj["m_strUnitFont"].toString()); + // 刻度 + this->m_pl_fontScale.fromString(obj["m_pl_fontScale"].toString()); + + // 曲线选择 + this->m_pl_azimuthCurve = obj["m_pl_azimuthCurve"].toString(); // 方位曲线 + this->m_pl_deviCurve = obj["m_pl_deviCurve"].toString(); // 井斜曲线 + + //蝌蚪符号 + this->m_nRadius = obj["m_nRadius"].toDouble(); // 圆半径 + this->m_nCircleWidth = obj["m_nCircleWidth"].toDouble();// 圆线宽度 + this->m_nTailLen = obj["m_nTailLen"].toDouble(); // 尾线长度 + this->m_nTailWidth = obj["m_nTailWidth"].toDouble(); // 尾线宽度 + this->m_crCircle.setNamedColor(obj["m_crCircle"].toString());// 圆线颜色 + this->m_crTail.setNamedColor(obj["m_crTail"].toString());// 尾线颜色 + this->m_crPointFill.setNamedColor(obj["m_crPointFill"].toString());// 圆填充色 + + // 刻度 + this->m_vmin = obj["vmin"].toDouble(); // 左刻度 + this->m_vmax = obj["vmax"].toDouble(); // 右刻度 + this->m_flStep = obj["m_flStep"].toDouble(); // 深度间隔 + // + this->m_strUnit = obj["Unit"].toString(); // 单位 + } + } +} + void FormInfo::initProperty(QJsonObject obj) { m_vmin = obj.value("vmin").toDouble(); @@ -697,6 +756,31 @@ QJsonObject FormInfo::makeJson() rootObj["Unit"] = m_strUnit; return rootObj; } + else if (m_strLineName == "XIEFANGWEI.LINE") + { + //井斜方位图 + // 字体 + rootObj["m_strUnitFont"] = this->m_strUnitFont.toString(); // 单位 + rootObj["m_pl_fontScale"] = this->m_pl_fontScale.toString(); // 刻度 + // 曲线选择 + rootObj["m_pl_azimuthCurve"] = this->m_pl_azimuthCurve; // 方位曲线 + rootObj["m_pl_deviCurve"] = this->m_pl_deviCurve; // 井斜曲线 + //蝌蚪符号 + rootObj["m_nRadius"] = this->m_nRadius; // 圆半径 + rootObj["m_nCircleWidth"] = this->m_nCircleWidth; // 圆线宽度 + rootObj["m_nTailLen"] = this->m_nTailLen; // 尾线长度 + rootObj["m_nTailWidth"] = this->m_nTailWidth; // 尾线宽度 + rootObj["m_crCircle"] = this->m_crCircle.name(); // 圆线颜色 + rootObj["m_crTail"] = this->m_crTail.name(); // 尾线颜色 + rootObj["m_crPointFill"] = this->m_crPointFill.name(); // 圆填充色 + // + rootObj["vmax"] = m_vmax;//右刻度 + rootObj["vmin"] = m_vmin;//左刻度 + rootObj["m_flStep"] = m_flStep;//深度间隔 + //单位 + rootObj["Unit"] = m_strUnit; + return rootObj; + } } else if (m_strType == "JiegutextObject") { @@ -1389,12 +1473,6 @@ void FormInfo::paintEvent(QPaintEvent* event) } } - if(m_strLineName=="井斜方位图") - { - painter.drawText(rect.left(), rect.top()+rect.height()/3, rect.width(), rect.height()/3, Qt::AlignCenter, m_strUnit); - 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)); - } - //蝌蚪图、杆状图 if(m_strLineName == "FRAC_HOLE.TABLE" || m_strLineName=="GANZHUANG.LINE") { @@ -1411,7 +1489,7 @@ void FormInfo::paintEvent(QPaintEvent* event) } //井眼垮塌矢量图 - if(m_strLineName=="JINGYANKUATA.LINE") + if(m_strLineName=="JINGYANKUATA.LINE" || m_strLineName=="XIEFANGWEI.LINE") { int nbay = rect.height() - 5; diff --git a/logPlus/forminfo.h b/logPlus/forminfo.h index b66a375..e928c14 100644 --- a/logPlus/forminfo.h +++ b/logPlus/forminfo.h @@ -29,6 +29,7 @@ public: void initProperty_Kedou(QJsonObject obj); void initProperty_Ganzhuang(QJsonObject obj); void initProperty_Jykt(QJsonObject obj); + void initProperty_Denv(QJsonObject obj); void paintClassify(QPainter &painter, int compassCenterY); private: @@ -380,8 +381,11 @@ public: //井眼垮塌矢量图 QString m_pl_deltaCurve = "CALM"; // 井径差曲线 - float m_flStep;// 增加深度间隔 - float m_nOffset; // 角度偏移=0,主应力方向,=90,长轴方向 + float m_flStep; // 增加深度间隔 + float m_nOffset; // 角度偏移=0,主应力方向,=90,长轴方向 + + //井斜方位图 + QString m_pl_deviCurve = "DEVI"; // 井斜曲线 public: void setLineWidth(double dWidth); diff --git a/logPlus/formtrack.cpp b/logPlus/formtrack.cpp index 10c1496..bd3d077 100644 --- a/logPlus/formtrack.cpp +++ b/logPlus/formtrack.cpp @@ -71,17 +71,6 @@ FormTrack::FormTrack(QWidget *parent, QString strSlfName, QString strWellName, Q // 深度 connect(this, SIGNAL(sig_AddDepth(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)), this, SLOT(s_addDepth(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString))); - // 杆状图 - connect(this, SIGNAL(sig_AddGanZhuangTu(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)), - this, SLOT(s_addGanZhuangTu(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString))); - - // 井眼垮塌矢量图 - connect(this, SIGNAL(sig_AddJykt(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)), - this, SLOT(s_addJykt(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString))); - - // 井斜方位图 - connect(this, SIGNAL(sig_AddDenv(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)), - this, SLOT(s_addDenv(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString))); //岩心图片 connect(this, SIGNAL(sig_AddYanXinImage(QString, QString, QString, QString, QString, QString, QColor, double, float, float, QString)), @@ -265,19 +254,7 @@ void FormTrack::Add(QString strSlfName, QString strWellName, QString strTrackNam else if(strType=="depthObject") { emit sig_AddDepth(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType); - } - else if(strType=="ganzhuangtuObject") - { - emit sig_AddGanZhuangTu(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType); - } - else if(strType=="JyktObject") - { - emit sig_AddJykt(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType); - } - else if(strType=="DenvObject") - { - emit sig_AddDenv(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType); - } + } // else if(strType=="yanxinImageObject") // { // emit sig_AddYanXinImage(strSlfName, strWellName, m_strTrackName, strLineName, strAliasName, strUnit, lineColor, dWidth, vmax, vmin, strScaleType); @@ -312,9 +289,10 @@ void FormTrack::Add(QString strSlfName, QString strWellName, QString strTrackNam } } -FormInfo* FormTrack::AddKedou(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty) +FormInfo* FormTrack::AddKedouAndOthers(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty) { - if(strLineName == "FRAC_HOLE.TABLE") + //蝌蚪图、杆状图、井眼垮塌矢量图、井斜方位图 + if(strLineName == "FRAC_HOLE.TABLE" || strLineName == "GANZHUANG.LINE" || strLineName == "JINGYANKUATA.LINE" || strLineName == "XIEFANGWEI.LINE") { } @@ -332,83 +310,22 @@ FormInfo* FormTrack::AddKedou(QString strSlfName, QString strWellName, QString s //曲线信息栏 FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor); formInfo->m_strUuid = m_strUuid; - formInfo->initProperty_Kedou(listOtherProperty); - formInfo->m_strAliasName = strAliasName; - formInfo->m_strUnit = strUnit; - formInfo->m_strScaleType = strScaleType; - formInfo->m_strType = "tableObject"; - formInfo->setLineWidth(dWidth); - formInfo->setVMax(vmax); - formInfo->setVMin(vmin); - formInfo->setFrontColor(QColor(0,0,0)); - formInfo->setBackColor(QColor(255,255,255)); - - //设置高度 - ui->tableWidget->setRowHeight(row, 100); - // - ui->tableWidget->setCellWidget(row, 0, formInfo); - return formInfo; -} - -FormInfo* FormTrack::AddGanzhuang(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty) -{ - if(strLineName == "GANZHUANG.LINE") + if(strLineName == "FRAC_HOLE.TABLE") { - + formInfo->initProperty_Kedou(listOtherProperty); } - else + else if(strLineName == "GANZHUANG.LINE") { - return nullptr; + formInfo->initProperty_Ganzhuang(listOtherProperty); } - - qDebug() << "FormTrack AddGanzhuang"; - - ui->tableWidget->m_strUuid = m_strUuid; - int row = ui->tableWidget->rowCount(); - ui->tableWidget->setRowCount(row + 1); - - //曲线信息栏 - FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor); - formInfo->m_strUuid = m_strUuid; - formInfo->initProperty_Ganzhuang(listOtherProperty); - formInfo->m_strAliasName = strAliasName; - formInfo->m_strUnit = strUnit; - formInfo->m_strScaleType = strScaleType; - formInfo->m_strType = "tableObject"; - formInfo->setLineWidth(dWidth); - formInfo->setVMax(vmax); - formInfo->setVMin(vmin); - formInfo->setFrontColor(QColor(0,0,0)); - formInfo->setBackColor(QColor(255,255,255)); - - //设置高度 - ui->tableWidget->setRowHeight(row, 100); - // - ui->tableWidget->setCellWidget(row, 0, formInfo); - return formInfo; -} - -FormInfo* FormTrack::AddJykt(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty) -{ - if(strLineName == "JINGYANKUATA.LINE") + else if(strLineName == "JINGYANKUATA.LINE") { - + formInfo->initProperty_Jykt(listOtherProperty); } - else + else if(strLineName == "XIEFANGWEI.LINE") { - return nullptr; + formInfo->initProperty_Denv(listOtherProperty); } - - qDebug() << "FormTrack AddJykt"; - - ui->tableWidget->m_strUuid = m_strUuid; - int row = ui->tableWidget->rowCount(); - ui->tableWidget->setRowCount(row + 1); - - //曲线信息栏 - FormInfo *formInfo = new FormInfo(this, strSlfName, strWellName, strTrackName, strLineName, lineColor); - formInfo->m_strUuid = m_strUuid; - formInfo->initProperty_Jykt(listOtherProperty); formInfo->m_strAliasName = strAliasName; formInfo->m_strUnit = strUnit; formInfo->m_strScaleType = strScaleType; @@ -1029,106 +946,6 @@ void FormTrack::s_addDepth(QString strSlfName, QString strWellName, QString strT ui->tableWidget->setCellWidget(row, 0, formInfo); } -void FormTrack::s_addGanZhuangTu(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType) -{ - qDebug() << "FormTrack s_addGanZhuangTu"; - - ui->tableWidget->m_strUuid = m_strUuid; - int row = ui->tableWidget->rowCount(); - ui->tableWidget->setRowCount(row + 1); - - //避免出现小滚动条 - //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->m_strUuid = m_strUuid; - formInfo->m_strAliasName = strAliasName; - formInfo->m_strUnit = strUnit; - formInfo->m_strScaleType = strScaleType; - formInfo->m_strType = "ganzhuangtuObject"; - formInfo->m_nJg = 2; - formInfo->setLineWidth(dWidth); - formInfo->setVMax(vmax); - formInfo->setVMin(vmin); - formInfo->setFrontColor(QColor(0,0,0)); - formInfo->setBackColor(QColor(255,255,255)); - //设置高度 - ui->tableWidget->setRowHeight(row, 100); - //单元格委托 - //ui->tableWidget->setItemDelegateForRow(row, m_delegate); - // - ui->tableWidget->setCellWidget(row, 0, formInfo); -} - -void FormTrack::s_addJykt(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType) -{ - qDebug() << "FormTrack s_addJykt"; - - ui->tableWidget->m_strUuid = m_strUuid; - int row = ui->tableWidget->rowCount(); - ui->tableWidget->setRowCount(row + 1); - - //避免出现小滚动条 - //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->m_strUuid = m_strUuid; - formInfo->m_strAliasName = strAliasName; - formInfo->m_strUnit = strUnit; - formInfo->m_strScaleType = strScaleType; - formInfo->m_strType = "JyktObject"; - formInfo->m_nJg = 2; - formInfo->setLineWidth(dWidth); - formInfo->setVMax(vmax); - formInfo->setVMin(vmin); - formInfo->setFrontColor(QColor(0,0,0)); - formInfo->setBackColor(QColor(255,255,255)); - //设置高度 - ui->tableWidget->setRowHeight(row, 100); - //单元格委托 - //ui->tableWidget->setItemDelegateForRow(row, m_delegate); - // - ui->tableWidget->setCellWidget(row, 0, formInfo); -} - - -void FormTrack::s_addDenv(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType) -{ - qDebug() << "FormTrack s_addDenv"; - - ui->tableWidget->m_strUuid = m_strUuid; - int row = ui->tableWidget->rowCount(); - ui->tableWidget->setRowCount(row + 1); - - //避免出现小滚动条 - //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->m_strUuid = m_strUuid; - formInfo->m_strAliasName = strAliasName; - formInfo->m_strUnit = strUnit; - formInfo->m_strScaleType = strScaleType; - formInfo->m_strType = "JyktObject"; - formInfo->m_nJg = 2; - formInfo->setLineWidth(dWidth); - formInfo->setVMax(vmax); - formInfo->setVMin(vmin); - formInfo->setFrontColor(QColor(0,0,0)); - formInfo->setBackColor(QColor(255,255,255)); - //设置高度 - ui->tableWidget->setRowHeight(row, 100); - //单元格委托 - //ui->tableWidget->setItemDelegateForRow(row, m_delegate); - // - ui->tableWidget->setCellWidget(row, 0, formInfo); -} - void FormTrack::s_addYanXinImage(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType) { qDebug() << "FormTrack s_addYanXinImage"; diff --git a/logPlus/formtrack.h b/logPlus/formtrack.h index 94649ed..14d606a 100644 --- a/logPlus/formtrack.h +++ b/logPlus/formtrack.h @@ -45,11 +45,7 @@ public: public: void Add(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QStringList listOtherProperty={}); //蝌蚪图 - FormInfo* AddKedou(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty={}); - //杆状图 - FormInfo* AddGanzhuang(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty={}); - //井眼垮塌矢量图 - FormInfo* AddJykt(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty={}); + FormInfo* AddKedouAndOthers(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType, QString strType, QJsonObject listOtherProperty={}); FormInfo* setDrawDt(QStringList listdt, QJsonObject obj); @@ -85,9 +81,6 @@ public slots: void s_delTableLine(QString strUuid, QString strWellName, QString strTrackName, QString strLineName); // 深度 void s_addDepth(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); - void s_addGanZhuangTu(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); - void s_addJykt(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); - void s_addDenv(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); void s_addYanXinImage(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); void s_addDrawImage(QString strSlfName, QString strWellName, QString strTrackName, QString strLineName, QString strAliasName, QString strUnit, QColor lineColor, double dWidth, float vmax, float vmin, QString strScaleType); void s_addSantuyibiao(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/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index acb86eb..b49ba47 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -3724,55 +3724,16 @@ void MainWindowCurve::s_Jykt() //井斜方位图 void MainWindowCurve::s_Denv() { -// QString strSlfName = ""; -// QString strLeft = m_leftWidgets->getLeftTreeString(); -// if(strLeft.length() > 0) -// { -// QStringList list = strLeft.split("#@@#");//QString字符串分割函数 -// if (list.size() > 3) -// { -// strSlfName = list[0]; -// } -// } - - if(ui->tableWidget_2->columnCount()==0) - { - return; - } - - int column = ui->tableWidget_2->currentColumn();//列编号从0开始 - if(column<0) - { - //当前没有选中井 - QMessageBox::warning(this, "提示", "当前没有选中井", "确定"); - return; - } - - if(column%2==0) - { - } - else - { - //空白列 - QMessageBox::warning(this, "提示", "当前没有选中井", "确定"); - return; - } - - QStringList sret = this->getSelectWell_New(); - if (sret.length() <= 0) - return; - QString strWellName = sret.at(0); - //直接从选中的井获取,data记录slf路径 - QString strSlfName = sret.at(1); - - int iWidth = ui->tableWidget_2->columnWidth(column); - int nW = 4; - //设置列宽 - ui->tableWidget_2->setColumnWidth(column, iWidth+nW*g_dPixelPerCm+8); + QStringList sret = this->insertCol(nW); + if (sret.length() <= 0) + return; + QString strWellName = sret.at(0); + //直接从选中的井获取,data记录slf路径 + QString strSlfName = sret.at(1); //新建道 - emit CallManage::getInstance()->sig_NewTrack(m_strUuid, strWellName, strSlfName, "井斜方位图", "DenvObject", nW); + emit CallManage::getInstance()->sig_NewTrack(m_strUuid, strWellName, strSlfName, "XIEFANGWEI.LINE", "DenvObject", nW); } //图像 成图 diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 0b26f55..bfee1d7 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -219,6 +219,8 @@ QMyCustomPlot::QMyCustomPlot(QWidget *parent, QString strSlfName, QString strWel connect(CallManage::getInstance(), SIGNAL(sig_changeGanzhuangProperty(QString, QString, QString, QString, QString)), this, SLOT(s_changeGanzhuangProperty(QString, QString, QString, QString, QString))); //改变井眼垮塌矢量图属性 connect(CallManage::getInstance(), SIGNAL(sig_changeJyktProperty(QString, QString, QString, QString, QString)), this, SLOT(s_changeJyktProperty(QString, QString, QString, QString, QString))); + //改变井斜方位图属性 + connect(CallManage::getInstance(), SIGNAL(sig_changeDenvProperty(QString, QString, QString, QString, QString)), this, SLOT(s_changeDenvProperty(QString, QString, QString, QString, QString))); } void QMyCustomPlot::initGeometry(QString strUuid, int nscale, double fW) @@ -12670,3 +12672,123 @@ void QMyCustomPlot::Draw_Jykt() } this->replot(); } + +//改变井斜方位图属性 +void QMyCustomPlot::s_changeDenvProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName) +{ + if(m_strUuid == strUuid && + m_strSlfName == strSlfName && + m_strWellName == strWellName && + m_strTrackName == strTrackName && + m_strLineName == strLineName) + { + + } + else + { + return; + } + //绘制井斜方位图 + Draw_Denv(); +} + +//井斜方位图 +void QMyCustomPlot::Draw_Denv() +{ + //this->clearGraphs(); + this->clearItems(); + + // + FormInfo* pInfo = m_formTrack->getFormInfoByParameters(m_strUuid, m_strWellName, m_strTrackName, m_strLineName); + if (pInfo == NULL) + { + return; + } + + //----------------------------------- + this->m_Value=NULL; + this->m_Value2=NULL; + this->m_Value3=NULL; + // 曲线选择 + this->m_csCurveAZIM = pInfo->m_pl_azimuthCurve; // 方位 曲线名 + this->m_csCurveDEVI = pInfo->m_pl_deviCurve; // 井斜曲线 + //蝌蚪符号 + this->m_nRadius = pInfo->m_nRadius; // 圆半径 + this->m_nCircleWidth = pInfo->m_nCircleWidth; // 圆线宽度 + this->m_nTailLen = pInfo->m_nTailLen; // 尾线长度 + this->m_nTailWidth = pInfo->m_nTailWidth; // 尾线宽度 + this->m_crCircle = pInfo->m_crCircle; // 圆线颜色 + this->m_crTail = pInfo->m_crTail; // 尾线颜色 + this->m_crPointFill=pInfo->m_crPointFill; //圆填充色 + + //读数据 + this->ReadData(m_strSlfName, m_csCurveAZIM, 0, &m_Curve); + this->ReadData(m_strSlfName, m_csCurveDEVI, 1, &m_Curve2); + if ( m_Value==0 || m_Value2==0 ) + { + this->replot(); + return ; + } + + // + m_flStep = pInfo->m_flStep; // 深度间隔--读数据的间隔 + + // + float vmax = pInfo->m_vmax; + float vmin = pInfo->m_vmin; + //this->setScaleX(vmin, vmax); + this->yAxis->setRange(vmin, vmax); + + // + QPen pPenTail(m_crTail,m_nTailWidth); + QPen pPenCircle(m_crCircle,m_nCircleWidth); + QBrush cBrush(m_crPointFill); + + float tempf,flVal; + int i,j,nPointNum=0,tempi; + QRectF rt,rtRect; + float x,y; + float dgtord,dr; + + // 计算显示深度 + tempf = (m_EDep - m_SDep)/m_Rlev + 0.5; + nPointNum = tempf+1; + if ( nPointNum <= 1 ) return ; + dgtord=3.14159265/180.; + + QBrush brush2(QColor(qRgb(0,0,0))); + { + for (float dep=m_SDep; depsetPen(pPenCircle); + qcpItemEllipse->m_bCustom = true; + qcpItemEllipse->m_nRadius = m_nRadius; + qcpItemEllipse->topLeft->setCoords(y, x);//圆心位置 + qcpItemEllipse->bottomRight->setCoords(y, x);//圆心位置 + qcpItemEllipse->setBrush(cBrush);//填充圆的颜色 + + // + flVal = GetData(m_Curve.RepCode,(char *)&m_Value[i*m_Curve.CodeLen]); + dr=flVal*dgtord; + + QCPItemLine *qcpItemLine = new QCPItemLine(this); + qcpItemLine->start->setCoords(y, x);//圆心位置 + qcpItemLine->end->setCoords(y, x);//圆心位置 + qcpItemLine->setPen(pPenTail); + qcpItemLine->m_bCustom = true; + qcpItemLine->m_nTailLen = m_nTailLen; //尾长 + qcpItemLine->m_nRadius = m_nRadius; //半径 + qcpItemLine->m_dr = dr; + } + } + this->replot(); +} diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index 1f72d54..14d2598 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -685,6 +685,9 @@ public slots: //改变井眼垮塌矢量图属性 void s_changeJyktProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); + //改变井斜方位图属性 + void s_changeDenvProperty(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); + public: //蝌蚪图重绘网格线 bool mKedou = false; @@ -745,7 +748,7 @@ public: void addQCPItemLine(QMyCustomPlot *widget, float cx, float cy, const QPointF& p1, const QPointF& p2, const QPen& wPen); - //蝌蚪 + //蝌蚪图 double m_pl_minInclination = 0; // 最小倾角 double m_pl_maxInclination = 90; // 最大倾角 float m_flGrad1,m_flGrad2; // 可信度 @@ -759,14 +762,19 @@ public: void DrawDip_Kedou(); void DrawTabDip_Kedou(); + //读取高导缝等配置 void ReadFracDef_gaodaofeng(); //杆状图 void Draw_Ganzhuang(); - // + //井眼垮塌矢量图 void Draw_Jykt(); + //井斜方位图 + QString m_csCurveAZIM,m_csCurveDEVI; // 方位曲线/井斜曲线 + void Draw_Denv(); + CPickFrac *m_cPickFrac; private: