From deb9e026d6aeda59482220db0ad7fe49c0e17ce7 Mon Sep 17 00:00:00 2001 From: jiayulong <22806282@qq.com> Date: Fri, 30 Jan 2026 17:37:58 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=9B=B2=E7=BA=BF=E6=8B=BC=E6=8E=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=AE=8C=E5=96=84=202.=E6=9B=B2=E7=BA=BF=E6=A1=86?= =?UTF-8?q?=E9=80=89=E7=BC=96=E8=BE=91=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/geometryutils.cpp | 29 ++++ common/geometryutils.h | 1 + logPlus/mainwindowcurve.cpp | 282 ++++++++++++++++++++---------------- logPlus/qmycustomplot.cpp | 89 +++++++++++- logPlus/qmycustomplot.h | 4 + 5 files changed, 272 insertions(+), 133 deletions(-) diff --git a/common/geometryutils.cpp b/common/geometryutils.cpp index e657263..df7e653 100644 --- a/common/geometryutils.cpp +++ b/common/geometryutils.cpp @@ -798,6 +798,35 @@ bool getAllSlf(QString prjname, QVector &vecSlfList, QVector & return true; } +int GetCurvInfo(QString strSlfName, QString strLineName, double &sdep, double &edep, double &rlev) +{ + //初始化 + sdep = 0; + edep = 0; + rlev = 0; + + // + CLogIO *logio=new CLogIO(); + logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead); + // + int index=logio->OpenCurve(strLineName.toStdString().c_str()); + if(index<0) { + delete logio; + return -1; + } + + Slf_CURVE curveinfo; + logio->GetCurveInfo(index,&curveinfo); + // + sdep=curveinfo.StartDepth; + edep=curveinfo.EndDepth; + rlev=curveinfo.DepLevel; + logio->CloseCurve(index); + delete logio; + + return 1; +} + bool getAliasNameFromIni(QString CurveName, QString &strAliasName, QString &strUnit) { QString curveFamilyFilePath = ::GetConfPath() + "CurveFamily_New.ini"; diff --git a/common/geometryutils.h b/common/geometryutils.h index efcc053..250b346 100644 --- a/common/geometryutils.h +++ b/common/geometryutils.h @@ -201,6 +201,7 @@ QString DoubleToString(double dValue, int nDecimal,int *pReallyDecimal); void SetSystemExisting(bool exiting); bool SystemExiting(); bool getAllSlf(QString prjname, QVector &vecSlfList, QVector &vecWellList);//直方图,获取当前工程下的slf +int GetCurvInfo(QString strSlfName, QString strLineName, double &sdep, double &edep, double &rlev);//获取曲线顶深、底深、间隔 bool getAliasNameFromIni(QString CurveName, QString &strAliasName, QString &strUnit);//曲线别名,单位 /** * @brief 获取系统缺省的系统颜色 diff --git a/logPlus/mainwindowcurve.cpp b/logPlus/mainwindowcurve.cpp index 33cd11c..08f6561 100644 --- a/logPlus/mainwindowcurve.cpp +++ b/logPlus/mainwindowcurve.cpp @@ -1611,139 +1611,164 @@ void MainWindowCurve::s_Merge_List(QString strUuid, QList left_Low_List, return; } -// float SourSdep=0; -// float SourEdep=0; -// float DectSdep=0; -// if(pointnum==1) { -// QMessageBox box(QMessageBox::Warning,"提示","拼接深度点仅有1个,请您选择拼接部位"); -// box.setStandardButtons (QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel); -// box.setButtonText(QMessageBox::Yes,QString("拼接上段")); -// box.setButtonText(QMessageBox::No,QString("拼接下段")); -// box.setButtonText(QMessageBox::Cancel,QString("放弃")); -// int flag=box.exec();//QMessageBox::information(NULL,"敬告",pwelllog->GetName()+mess,QMessageBox::Yes,QMessageBox::No,QMessageBox::Cancel); + float SourSdep=0; + float SourEdep=0; + float DectSdep=0; + if(pointnum==1) { + QMessageBox box(QMessageBox::Warning,"提示","拼接深度点仅有1个,请您选择拼接部位"); + box.setStandardButtons (QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel); + box.setButtonText(QMessageBox::Yes,QString("拼接上段")); + box.setButtonText(QMessageBox::No,QString("拼接下段")); + box.setButtonText(QMessageBox::Cancel,QString("放弃")); + int flag=box.exec();//QMessageBox::information(NULL,"敬告",pwelllog->GetName()+mess,QMessageBox::Yes,QMessageBox::No,QMessageBox::Cancel); -// if(flag==QMessageBox::Yes) { -// SourSdep=m_RightCurve->GetTopDepth(); -// SourEdep=m_mergeLineList[0]->GetLeftDepth(); -// DectSdep=SourSdep; -// } -// else if(flag==QMessageBox::No) { -// DectSdep=m_mergeLineList[0]->GetLeftDepth(); -// SourEdep=m_RightCurve->GetBottomDepth(); -// SourSdep=m_mergeLineList[0]->GetRightDepth(); -// } -// else return; -// } -// else if(pointnum==2) { -// SourSdep=m_mergeLineList[0]->GetLeftDepth()+m_RightCurve->GetShiftOffset(); -// SourEdep=m_mergeLineList[1]->GetLeftDepth()+m_RightCurve->GetShiftOffset(); -// DectSdep=m_mergeLineList[0]->GetLeftDepth(); -// } + double sdep_right = 0; + double edep_right = 0; + double rlev_right = 0; + //获取曲线顶深、底深、间隔 + int iRet = GetCurvInfo(m_RightCurve.m_strSlfName, m_RightCurve.m_strLineName, sdep_right, edep_right, rlev_right); + if(iRet!=1) + { + QMessageBox::warning(this, "提示", "曲线深度读取失败,无法拼接!"); + return; + } + if(flag==QMessageBox::Yes) { + SourSdep=sdep_right; + SourEdep=m_mergeLineList[0]->GetLeftDepth(); + DectSdep=SourSdep; + } + else if(flag==QMessageBox::No) { + DectSdep=m_mergeLineList[0]->GetLeftDepth(); + SourEdep=edep_right; + SourSdep=m_mergeLineList[0]->GetRightDepth(); + } + else return; + } + else if(pointnum==2) { + SourSdep=m_mergeLineList[0]->GetLeftDepth();//+m_RightCurve->GetShiftOffset(); + SourEdep=m_mergeLineList[1]->GetLeftDepth();//+m_RightCurve->GetShiftOffset(); + DectSdep=m_mergeLineList[0]->GetLeftDepth(); + } -// QString name1=m_LeftCurve.m_strLineName; -// QString name2=m_RightCurve.m_strLineName; + QString name1=m_LeftCurve.m_strLineName; + QString name2=m_RightCurve.m_strLineName; -// QList ShiftCurvesAll; -// ShiftCurvesAll.append(m_RightCurve); -// ShiftCurvesAll.append(m_ShiftCurves); -// if(ShiftCurvesAll.size()<1) { -// AfxMessageBox("缺少目标曲线或目标曲线无效!"); -// return; -// } + QList ShiftCurvesAll; + ShiftCurvesAll.append(m_RightCurve); + ShiftCurvesAll.append(m_ShiftCurves); + if(ShiftCurvesAll.size()<1) { + QMessageBox::warning(this, "提示", "缺少目标曲线或目标曲线无效!"); + return; + } -// int size=(SourEdep-SourSdep)/m_LeftCurve->m_Rlev+1.5; -// QString filename2=m_RightCurve.m_strSlfName; -// QString filename1=m_LeftCurve.m_strSlfName; -// CMemRdWt mrw1; -// CMemRdWt mrw2; + double sdep_left = 0; + double edep_left = 0; + double rlev_left = 0; + //获取曲线顶深、底深、间隔 + int iRet = GetCurvInfo(m_LeftCurve.m_strSlfName, m_LeftCurve.m_strLineName, sdep_left, edep_left, rlev_left); + if(iRet!=1) + { + QMessageBox::warning(this, "提示", "曲线深度读取失败,无法拼接!"); + return; + } + int size=(SourEdep-SourSdep)/rlev_left+1.5; + QString filename1=m_LeftCurve.m_strSlfName; + QString filename2=m_RightCurve.m_strSlfName; + CMemRdWt mrw1; + CMemRdWt mrw2; -// struct INC_STRU Inc={0},Inc1={0}; -// struct INP_STRU Inp,Inp1; -// struct HD_STRU Hd={99999.0,-99999.0,0}; -// struct HD_STRU Hd1={99999.0,-99999.0,0}; -// int flag=0; -// if(filename1==filename2) { -// CMemRdWt mrw4; -// if(mrw4.Open(filename1.toStdString().c_str())) { -// CMemRdWt mrw3; -// QDir aa; -// filename2=::GetLogdataPath()+"temp\\temp001"; -// aa.remove(filename2); -// if(mrw3.Open(filename2.toStdString().c_str(),CMemRdWt::modeCreate,1024,1024,0,mrw4.IsWis)) { -// mrw3.CopyFromFile(mrw4,(char *)name2.toStdString().c_str()); -// mrw3.Save(); -// mrw3.Close(); -// flag=1; -// } -// mrw1.Close(); -// } -// } -// if (!mrw1.Open(filename1.toStdString().c_str())) { -// if(flag) { -// QDir aa; -// aa.remove(filename2); -// } -// return; -// } -// if (!mrw2.Open(filename2.toStdString().c_str())) { -// mrw1.Close(); -// if(flag) { -// QDir aa; -// aa.remove(filename2); -// } -// return; -// } -// mrw1.SetStruct(&Inc,NULL,&Inp,NULL,NULL,NULL,&Hd,NULL); -// mrw2.SetStruct(&Inc1,NULL,&Inp1,NULL,NULL,NULL,&Hd1,NULL); + struct INC_STRU Inc={0},Inc1={0}; + struct INP_STRU Inp,Inp1; + struct HD_STRU Hd={99999.0,-99999.0,0}; + struct HD_STRU Hd1={99999.0,-99999.0,0}; + int flag=0; + if(filename1==filename2) { + CMemRdWt mrw4; + if(mrw4.Open(filename1.toStdString().c_str())) { + CMemRdWt mrw3; + QDir aa; + filename2=::GetLogdataPath()+"temp\\temp001"; + aa.remove(filename2); + if(mrw3.Open(filename2.toStdString().c_str(),CMemRdWt::modeCreate,1024,1024,0,mrw4.IsWis)) { + mrw3.CopyFromFile(mrw4,(char *)name2.toStdString().c_str()); + mrw3.Save(); + mrw3.Close(); + flag=1; + } + mrw1.Close(); + } + } + if (!mrw1.Open(filename1.toStdString().c_str())) { + if(flag) { + QDir aa; + aa.remove(filename2); + } + return; + } + if (!mrw2.Open(filename2.toStdString().c_str())) { + mrw1.Close(); + if(flag) { + QDir aa; + aa.remove(filename2); + } + return; + } + mrw1.SetStruct(&Inc,NULL,&Inp,NULL,NULL,NULL,&Hd,NULL); + mrw2.SetStruct(&Inc1,NULL,&Inp1,NULL,NULL,NULL,&Hd1,NULL); -// QList names1,names2; -// names1.append(name1); -// names2.append(name2); -// for(int i=0;i names1,names2; + names1.append(name1); + names2.append(name2); + for(int i=0;isig_ReloadPlot(m_strUuid, filename1, name1); + + if(ERRORS.size())QMessageBox::warning(this, "提示", "目标曲线不存在:"+ERRORS.join(" ")); } //清除全部曲线设置 @@ -1753,6 +1778,11 @@ void MainWindowCurve::s_ClearAllSetCurve() //当前有标准曲线 if(m_LeftCurve.m_iTableType==3 && m_LeftCurve.m_strFormInfoType=="curveObject") { + //----------------------- + //通知界面,清除全部分段线 + emit CallManage::getInstance()->sig_DelAllShiftLineFromPlot(m_strUuid, m_LeftCurve.m_strSlfName, m_LeftCurve.m_strWellName, m_LeftCurve.m_strTrackName, m_LeftCurve.m_strLineName); + //----------------------- + //修改当前曲线选择状态 iSelect=0未知 emit CallManage::getInstance()->sig_ChangeLineStatus(m_strUuid, m_LeftCurve.m_strSlfName, m_LeftCurve.m_strWellName, m_LeftCurve.m_strTrackName, m_LeftCurve.m_strLineName, 0, m_bMerge); diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 3f2ea15..64d6254 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -348,12 +348,16 @@ void QMyCustomPlot::s_LineClicked(int index) void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event) { m_event = event; - // - QMenu menu(this); - - menu.addAction("添加分段线", this, &QMyCustomPlot::onAddShiftLine); - menu.addAction("清除当前分段线", this, &QMyCustomPlot::onDelSelectShiftLine); - menu.addAction("清除全部分段线", this, &QMyCustomPlot::onDelAllShiftLine); + //曲线 + if(m_addRandomGraph) + { + QMenu menu(this); + menu.addAction(QIcon(::GetImagePath() + "icon/ZonePoint.png"), "添加分段线", this, &QMyCustomPlot::onAddShiftLine); + menu.addAction(QIcon(::GetImagePath() + "icon/ClearZonePoint.png"), "清除当前分段线", this, &QMyCustomPlot::onDelSelectShiftLine); + menu.addAction(QIcon(::GetImagePath() + "icon/ClearZone.png"), "清除全部分段线", this, &QMyCustomPlot::onDelAllShiftLine); + menu.addAction(QIcon(::GetImagePath() + "curve.png"), "开始编辑曲线", this, &QMyCustomPlot::onEditLine); + menu.exec(event->globalPos()); + } // QAction *resetAction = menu.addAction("添加框图"); // connect(resetAction, &QAction::triggered, this, &QMyCustomPlot::onAddRect); @@ -363,7 +367,6 @@ void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event) // menu.addAction("删除选中曲线", this, SLOT(removeSelectedGraph())); // } - menu.exec(event->globalPos()); } //右键--添加分段线 @@ -390,6 +393,76 @@ void QMyCustomPlot::onDelAllShiftLine() emit CallManage::getInstance()->sig_DelAllShiftLine(m_strUuid); } +//右键--编辑曲线 +void QMyCustomPlot::onEditLine() +{ + this->setInteractions(QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables | QCP::iMultiSelect); // 轴、图例、图表可以被选择,并且是多选的方式 + this->setSelectionRectMode(QCP::srmCustom); // 鼠标框选 + + for (int i=0; i < this->graphCount(); ++i) { + QCPGraph *graph = this->graph(i); + graph->setSelectable(QCP::stDataRange); + break; + } + + connect(this->selectionRect(), &QCPSelectionRect::accepted, [this](){ + if(this->m_bDrawRect == false) + { + this->m_bDrawRect = true; + return; + } + // 当选择完成时,获取矩形范围并放大 + QRectF rect = this->selectionRect()->rect(); // 获取选择的矩形区域(像素坐标) + + // 转换为坐标轴范围 + double top = rect.top(); + double bottom = rect.bottom(); + + double right_Hight = this->xAxis->pixelToCoord(top); + double left_Low = this->xAxis->pixelToCoord(bottom); + + if(right_Hight-left_Low>5) + { + //添加图形 + //emit CallManage::getInstance()->sig_addImageToPlot(customPlot, left_Low, right_Hight, ":/image/file.png"); + this->addImageToPlot(left_Low, right_Hight, ":/image/file.png"); + } + }); + + // 连接QCustomPlot的信号,selectionChangedByUser表明是由鼠标点击进行的选择 + // 这里主要就是同步图表和图例的显示 +// connect(this, &QMyCustomPlot::selectionChangedByUser, [this](){ +// for (int i=0; i < this->graphCount(); ++i) { +// QCPGraph *graph = this->graph(i); +// QCPPlottableLegendItem *item = this->legend->itemWithPlottable(graph); + +// if (item->selected() && !graph->selected()) +// { +// graph->setSelection(QCPDataSelection(graph->data()->dataRange())); // 当图例项被选择时,选择图表全部的数据 +// } +// else if (graph->selected()) +// { +// item->setSelected(true); + +// QCPDataSelection selection = this->graph(i)->selection(); +// // 遍历选中的数据范围 +// for (int j = 0; j < selection.dataRangeCount(); ++j) +// { +// QCPDataRange dataRange = selection.dataRange(j); +// double left_Low = this->graph(i)->data()->at(dataRange.begin())->key; +// double right_Hight = this->graph(i)->data()->at(dataRange.end())->key; +// if(right_Hight-left_Low>1) +// { +// //添加图形 +// //emit CallManage::getInstance()->sig_addImageToPlot(customPlot, left_Low, right_Hight, ":/image/file.png"); +// this->addImageToPlot(left_Low, right_Hight, ":/image/file.png"); +// } +// } +// } +// } +// }); +} + void QMyCustomPlot::onAddRect() { double right_Hight = xAxis->pixelToCoord(m_event->pos().y());//x轴展示深度 @@ -1669,6 +1742,8 @@ void QMyCustomPlot::addRandomGraph(QVector x, QVector y, QString { //AppendConsole(PAI_INFO, "FormDraw addRandomGraph"); + m_addRandomGraph=true; + m_x.append(x); m_y.append(y); diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index a828b16..b6e0602 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -68,6 +68,7 @@ public: QVector m_y; int m_iCurNum=0; int m_iSplitNum=2000; //2000000; //2000; + bool m_addRandomGraph=false;//当前是否绘制曲线 true:是。 QMap m_mapDraggable_Rect; QMap m_mapDraggable_Result; @@ -158,6 +159,9 @@ public slots: //清除全部分段线 void s_DelAllShiftLineFromPlot(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName); + //右键--编辑曲线 + void onEditLine(); + //执行校正 void s_RuncorFromPlot(QString strUuid, QString strSlfName, QString strWellName, QString strTrackName, QString strLineName);