1.曲线拼接功能完善 2.曲线框选编辑功能开发

This commit is contained in:
jiayulong 2026-01-30 17:37:58 +08:00
parent 65df667235
commit deb9e026d6
5 changed files with 272 additions and 133 deletions

View File

@ -798,6 +798,35 @@ bool getAllSlf(QString prjname, QVector<QString> &vecSlfList, QVector<QString> &
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";

View File

@ -201,6 +201,7 @@ QString DoubleToString(double dValue, int nDecimal,int *pReallyDecimal);
void SetSystemExisting(bool exiting);
bool SystemExiting();
bool getAllSlf(QString prjname, QVector<QString> &vecSlfList, QVector<QString> &vecWellList);//直方图获取当前工程下的slf
int GetCurvInfo(QString strSlfName, QString strLineName, double &sdep, double &edep, double &rlev);//获取曲线顶深、底深、间隔
bool getAliasNameFromIni(QString CurveName, QString &strAliasName, QString &strUnit);//曲线别名,单位
/**
* @brief

View File

@ -1611,139 +1611,164 @@ void MainWindowCurve::s_Merge_List(QString strUuid, QList<double> 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<SelectTableItem> ShiftCurvesAll;
// ShiftCurvesAll.append(m_RightCurve);
// ShiftCurvesAll.append(m_ShiftCurves);
// if(ShiftCurvesAll.size()<1) {
// AfxMessageBox("缺少目标曲线或目标曲线无效!");
// return;
// }
QList<SelectTableItem> 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<QString> names1,names2;
// names1.append(name1);
// names2.append(name2);
// for(int i=0;i<m_ShiftCurves.size();i++){
// names1.append(m_ShiftCurves.at(i).m_strLineName);
// names2.append(m_ShiftCurves.at(i).m_strLineName);
// }
// int ind1,ind2;
// QStringList ERRORS;
// int j=0;
// for(int i=0;i<names1.size();i++)
// {
// Slf_CHANNEL m_Channel1;
// Slf_CHANNEL m_Channel2;
// ind1=mrw1.OpenChannel(names1[i].toStdString().c_str());
// ind2=mrw2.OpenChannel(names2[i].toStdString().c_str());
// if(ind1<0||ind2<0) {
// CString cs;
// if(ind1<0) {
// ERRORS.append(names1[i]+" ");
// // cs.Format("源曲线不存在%s",name1.toStdString().c_str());
// }
// else if(ind2<0) {
// ERRORS.append(names2[i]+" ");
// // cs.Format("目标曲线不存在%s",name2.toStdString().c_str());
// }
// else {
// ERRORS.append(names1[i]+" "+names2[i]);
// // cs.Format("源曲线、目标曲线不存在!");
// }
// continue;
// }
QList<QString> names1,names2;
names1.append(name1);
names2.append(name2);
for(int i=0;i<m_ShiftCurves.size();i++){
names1.append(m_ShiftCurves.at(i).m_strLineName);
names2.append(m_ShiftCurves.at(i).m_strLineName);
}
int ind1,ind2;
QStringList ERRORS;
int j=0;
for(int i=0;i<names1.size();i++)
{
Slf_CHANNEL m_Channel1;
Slf_CHANNEL m_Channel2;
ind1=mrw1.OpenChannel(names1[i].toStdString().c_str());
ind2=mrw2.OpenChannel(names2[i].toStdString().c_str());
if(ind1<0||ind2<0) {
CString cs;
if(ind1<0) {
ERRORS.append(names1[i]+" ");
// cs.Format("源曲线不存在%s",name1.toStdString().c_str());
}
else if(ind2<0) {
ERRORS.append(names2[i]+" ");
// cs.Format("目标曲线不存在%s",name2.toStdString().c_str());
}
else {
ERRORS.append(names1[i]+" "+names2[i]);
// cs.Format("源曲线、目标曲线不存在!");
}
continue;
}
// mrw1.GetChannelInfo(ind1,&m_Channel1);
// mrw2.GetChannelInfo(ind2,&m_Channel2);
// if(ind1&&SourEdep==0) SourEdep=m_Channel1.DimInfo[0].StartVal+m_Channel1.DimInfo[0].Samples*m_Channel1.DimInfo[0].Delta;
// mrw1.AddInCurve((char *)names1[i].toStdString().c_str());
// mrw2.AddInCurve((char *)names2[i].toStdString().c_str());
// mrw1.CopyCurve(mrw2,SourSdep,SourEdep,DectSdep,j,j);
// j++;
// }
// mrw2.Close();
// mrw1.Save();
// mrw1.Close();
// if(flag) {
// QDir aa;
// aa.remove(filename2);
// }
mrw1.GetChannelInfo(ind1,&m_Channel1);
mrw2.GetChannelInfo(ind2,&m_Channel2);
if(ind1&&SourEdep==0) SourEdep=m_Channel1.DimInfo[0].StartVal+m_Channel1.DimInfo[0].Samples*m_Channel1.DimInfo[0].Delta;
mrw1.AddInCurve((char *)names1[i].toStdString().c_str());
mrw2.AddInCurve((char *)names2[i].toStdString().c_str());
mrw1.CopyCurve(mrw2,SourSdep,SourEdep,DectSdep,j,j);
j++;
}
mrw2.Close();
mrw1.Save();
mrw1.Close();
if(flag) {
QDir aa;
aa.remove(filename2);
}
//Plot重新加载数据
emit CallManage::getInstance()->sig_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);

View File

@ -348,12 +348,16 @@ void QMyCustomPlot::s_LineClicked(int index)
void QMyCustomPlot::contextMenuEvent(QContextMenuEvent *event)
{
m_event = event;
//
//曲线
if(m_addRandomGraph)
{
QMenu menu(this);
menu.addAction("添加分段线", this, &QMyCustomPlot::onAddShiftLine);
menu.addAction("清除当前分段线", this, &QMyCustomPlot::onDelSelectShiftLine);
menu.addAction("清除全部分段线", this, &QMyCustomPlot::onDelAllShiftLine);
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<double> x, QVector<double> y, QString
{
//AppendConsole(PAI_INFO, "FormDraw addRandomGraph");
m_addRandomGraph=true;
m_x.append(x);
m_y.append(y);

View File

@ -68,6 +68,7 @@ public:
QVector<double> m_y;
int m_iCurNum=0;
int m_iSplitNum=2000; //2000000; //2000;
bool m_addRandomGraph=false;//当前是否绘制曲线 true:是。
QMap<QString, QObject*> m_mapDraggable_Rect;
QMap<QString, QObject*> 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);