From e5c0c52a0cdd632f425610efd8d407f6c5b3b4a9 Mon Sep 17 00:00:00 2001 From: crqiqi77 Date: Mon, 30 Mar 2026 16:58:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B2=A9=E5=BF=83=E5=88=86=E6=9E=90=20?= =?UTF-8?q?=E5=B2=A9=E5=BF=83=E7=85=A7=E7=89=87=20=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=20=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logPlus/TransparentDraggableCorePhysics.cpp | 6 +- logPlus/formdraw.cpp | 280 +++++++++----------- logPlus/formdraw.h | 2 +- logPlus/qmycustomplot.cpp | 225 +++++++++++++++- logPlus/qmycustomplot.h | 2 + 5 files changed, 354 insertions(+), 161 deletions(-) diff --git a/logPlus/TransparentDraggableCorePhysics.cpp b/logPlus/TransparentDraggableCorePhysics.cpp index 3312fc5..28165a7 100644 --- a/logPlus/TransparentDraggableCorePhysics.cpp +++ b/logPlus/TransparentDraggableCorePhysics.cpp @@ -49,8 +49,8 @@ void TransparentDraggableCorePhysics::setRange(double left_Low, double right_Hig } } m_lY1 = lY1; - // lY2除以实际左到右刻度数值 -// lY2 = lY2 / (getCpRightScale() - getCpLeftScale()) * 100; + + double minV = getCpLeftScale(); double maxV = getCpRightScale(); @@ -59,7 +59,7 @@ void TransparentDraggableCorePhysics::setRange(double left_Low, double right_Hig int scaleType = getCpScaleType(); // 0=线性 1=对数 2=倾角 if (scaleType == 0) { - // 线性(原来的公式) + // 线性(原来的公式) // lY2除以实际左到右刻度数值 finalValue = (value - minV) / (maxV - minV) * 100.0; } else if (scaleType == 1) diff --git a/logPlus/formdraw.cpp b/logPlus/formdraw.cpp index f4a00cc..df03f79 100644 --- a/logPlus/formdraw.cpp +++ b/logPlus/formdraw.cpp @@ -5492,7 +5492,7 @@ void FormDraw::initIMAGE_DATA(QMyCustomPlot *widget, QString strSlfName, QString widget->xAxis2->setTicks(false); widget->yAxis2->setTicks(false); // - LoadFromIMAGE_SLF(widget, strSlfName, strLineName); + widget->LoadFromIMAGE_SLF(strSlfName, strLineName); //显示文本 QString strAliasName = "岩心图片"; if(stringList.size() >= 1) @@ -5509,61 +5509,61 @@ void FormDraw::initIMAGE_DATA(QMyCustomPlot *widget, QString strSlfName, QString m_RightVal, m_LeftVal, strScaleType, "tableObject", stringList);//yanxinImageObject } -bool FormDraw::LoadFromIMAGE_SLF(QMyCustomPlot *widget, QString strSlfName, QString strLineName) -{ - { - QString ss=strSlfName; - CMemRdWt *logio=new CMemRdWt(); - if(ss==""||!logio->Open(ss.toStdString().c_str(),CSlfIO::modeRead)) - { - delete logio; - // QMessageBox::information(NULL,"提示","SLF文件打开失败,请检查!!",QMessageBox::Yes); - return false; - } - int iIndex=logio->OpenTable(strLineName.toStdString().c_str()); - if(iIndex>-1) { - int len=logio->GetTableRecordLength(iIndex); - if(lenOpen(ss.toStdString().c_str(),CSlfIO::modeRead)) +// { +// delete logio; +// // QMessageBox::information(NULL,"提示","SLF文件打开失败,请检查!!",QMessageBox::Yes); +// return false; +// } +// int iIndex=logio->OpenTable(strLineName.toStdString().c_str()); +// if(iIndex>-1) { +// int len=logio->GetTableRecordLength(iIndex); +// if(lenGetTableRecordCount(iIndex); - for(int i=0;iReadTable(iIndex,i+1,m_Result); - // WelllogItem* item=AddItem(m_Result->StartDepth,m_Result->EndDepth); - // if(!item) continue; - // OGWordsResultItem* pResult = dynamic_cast(item); - //logio->GetTableFieldData(iIndex,(char*)FieldName.toStdString().c_str(),m_Result->Image,i+1); +// int count=logio->GetTableRecordCount(iIndex); +// for(int i=0;iReadTable(iIndex,i+1,m_Result); +// // WelllogItem* item=AddItem(m_Result->StartDepth,m_Result->EndDepth); +// // if(!item) continue; +// // OGWordsResultItem* pResult = dynamic_cast(item); +// //logio->GetTableFieldData(iIndex,(char*)FieldName.toStdString().c_str(),m_Result->Image,i+1); - // SetCharacters(m_Result->Words); +// // SetCharacters(m_Result->Words); - // fontColor=QColor(0,0,0,255); - // backgroundColor=QColor(255,255,255,255); - // wordfont.setFamily("黑体"); - // wordfont.setPointSize(10); +// // fontColor=QColor(0,0,0,255); +// // backgroundColor=QColor(255,255,255,255); +// // wordfont.setFamily("黑体"); +// // wordfont.setPointSize(10); - //显示图片Image - QString filename=QString::fromLocal8Bit(m_Result->Image); - int pos=filename.lastIndexOf("\\"); - int pos1=filename.lastIndexOf("/"); - if(pos1>pos) pos=pos1; - if(filename.lastIndexOf(".")>-1) { - int aa=filename.lastIndexOf("."); - if(aaaddImageToPlot(-m_Result->EndDepth, -m_Result->StartDepth, filename, static_cast(m_Result->Left), static_cast(m_Result->Width)); - } - logio->CloseTable(iIndex); - delete buf; - } - delete logio; - } - return true; -} +// //显示图片Image +// QString filename=QString::fromLocal8Bit(m_Result->Image); +// int pos=filename.lastIndexOf("\\"); +// int pos1=filename.lastIndexOf("/"); +// if(pos1>pos) pos=pos1; +// if(filename.lastIndexOf(".")>-1) { +// int aa=filename.lastIndexOf("."); +// if(aaaddImageToPlot(-m_Result->EndDepth, -m_Result->StartDepth, filename, static_cast(m_Result->Left), static_cast(m_Result->Width)); +// } +// logio->CloseTable(iIndex); +// delete buf; +// } +// delete logio; +// } +// return true; +//} //解释结论 void FormDraw::initResult(QMyCustomPlot *widget, QString strSlfName, QString strLineName) @@ -6961,107 +6961,90 @@ void FormDraw::initCorePhysics(QMyCustomPlot *widget, QString strSlfName, QStrin widget->xAxis2->setTicks(false); widget->yAxis2->setTicks(false); -// widget->yAxis2->setTickLabels(true); -// widget->yAxis2->setTickLabelSide(QCPAxis::lsInside); -// widget->yAxis2->setRange(0, 100); -// // 设置刻度 -// // 创建文本刻度 Ticker -// QSharedPointer textTicker(new QCPAxisTickerText); -// double minVal = widget->yAxis2->range().lower; -// double maxVal = widget->yAxis2->range().upper; -// int value = 2; -// // 计算步长:(最大值 - 最小值) / 等分数 -// double step = (maxVal - minVal) / value; -// // 生成刻度 -// for (int i = 0; i <= value; ++i) { -// double value = minVal + step * i; -// // 取整显示(34.0 显示为 "34") -// QString label = QString::number(qRound(value)); -// textTicker->addTick(value, label); -// } -// // 应用 Ticker -// widget->yAxis2->setTicker(textTicker); - - - // 加载slf文件 开始 QVector x, y; - Slf_CORE_PHYSICS *m_pResult=NULL; - CMemRdWt *logio=new CMemRdWt(); - if(strSlfName==""||!logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead)) - { - delete logio; - // QMessageBox::information(NULL,"提示","SLF文件打开失败,请检查!!",QMessageBox::Yes); - return; - } - int iIndex=logio->OpenTable(strLineName.toStdString().c_str()); - if(iIndex>-1) { - int FieldNo=0; - int count=logio->GetTableRecordCount(iIndex); - QString FieldName = "AC"; +// // 加载slf文件 开始 +// QVector x, y; +// Slf_CORE_PHYSICS *m_pResult=NULL; +// CMemRdWt *logio=new CMemRdWt(); +// if(strSlfName==""||!logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead)) +// { +// delete logio; +// // QMessageBox::information(NULL,"提示","SLF文件打开失败,请检查!!",QMessageBox::Yes); +// return; +// } +// int iIndex=logio->OpenTable(strLineName.toStdString().c_str()); +// if(iIndex>-1) { +// int FieldNo=0; +// int count=logio->GetTableRecordCount(iIndex); - if(!FieldName.isEmpty()) { - static int err=0; - FieldNo=logio->GetTableFieldNo(iIndex,(char *)FieldName.toStdString().c_str()); - if(FieldNo<0) { - if(!err)QMessageBox::information(nullptr, "提示", "岩心试验数据模块初始加载数据不成功,因为隐含"+FieldName+"字段在实际数据表中不存在,稍后请您重新选择有效字段!"); - err++; - delete logio; - return; - } - else err=0; - } - else { - delete logio; - return; - } - int len=logio->GetTableRecordLength(iIndex); - m_pResult=(Slf_CORE_PHYSICS *)new char[len+1]; - char buf[100]; - for(int i=0;iGetTableFieldData(iIndex,1,buf,i+1); - sscanf(buf,"%f",&m_pResult->Depth); - logio->GetTableFieldData(iIndex,2,buf,i+1); - sscanf(buf,"%f",&m_pResult->CorrDepth); - // logio->ReadTable(iIndex,i+1,m_pResult); +// QString FieldName = "AC"; - int Order = m_pResult->Order; - float depth = m_pResult->Depth; - float CorrDepth = m_pResult->CorrDepth; - float CoreValue = m_pResult->CoreValue; - logio->GetTableFieldData(iIndex,FieldNo,buf,i+1); +// if(!FieldName.isEmpty()) { +// static int err=0; +// FieldNo=logio->GetTableFieldNo(iIndex,(char *)FieldName.toStdString().c_str()); +// if(FieldNo<0) { +// if(!err)QMessageBox::information(nullptr, "提示", "岩心试验数据模块初始加载数据不成功,因为隐含"+FieldName+"字段在实际数据表中不存在,稍后请您重新选择有效字段!"); +// err++; +// delete logio; +// return; +// } +// else err=0; +// } +// else { +// delete logio; +// return; +// } +// int len=logio->GetTableRecordLength(iIndex); +// m_pResult=(Slf_CORE_PHYSICS *)new char[len+1]; +// char buf[100]; +// for(int i=0;iGetTableFieldData(iIndex,1,buf,i+1); +// sscanf(buf,"%f",&m_pResult->Depth); +// logio->GetTableFieldData(iIndex,2,buf,i+1); +// sscanf(buf,"%f",&m_pResult->CorrDepth); +// // logio->ReadTable(iIndex,i+1,m_pResult); - CoreValue=0; - sscanf(buf,"%f",&CoreValue); - // +// int Order = m_pResult->Order; +// float depth = m_pResult->Depth; +// float CorrDepth = m_pResult->CorrDepth; +// float CoreValue = m_pResult->CoreValue; +// logio->GetTableFieldData(iIndex,FieldNo,buf,i+1); - if(i==0) - { - //最大值,最小值默认采用第一个有效值 - //vmax = vmin = CoreValue; +// CoreValue=0; +// sscanf(buf,"%f",&CoreValue); +// // - //默认采用0-100范围 - if(vmaxCoreValue)vmin=CoreValue; - } - else - { - // - if(vmaxCoreValue)vmin=CoreValue; - } - // - x.append(-CorrDepth); - y.append(CoreValue); - // 已经加载了slf文件内容 显示界面上 - widget->addCorePhysicsWithParam(Order, static_cast(-depth), static_cast(-CorrDepth), static_cast(-CoreValue)); - } - logio->CloseTable(iIndex); - delete m_pResult; - } - delete logio; - // 加载slf文件结束 +// if(i==0) +// { +// //最大值,最小值默认采用第一个有效值 +// //vmax = vmin = CoreValue; + +// //默认采用0-100范围 +// if(vmaxCoreValue)vmin=CoreValue; +// } +// else +// { +// // +// if(vmaxCoreValue)vmin=CoreValue; +// } +// // +// x.append(-CorrDepth); +// y.append(CoreValue); +// // 已经加载了slf文件内容 显示界面上 +// widget->addCorePhysicsWithParam(Order, static_cast(-depth), static_cast(-CorrDepth), static_cast(-CoreValue)); +// } +// logio->CloseTable(iIndex); +// delete m_pResult; +// } +// delete logio; +// // 加载slf文件结束 + + // 加载slf文件 + widget->loadFromSLFCorePhysics(strSlfName, strLineName); QString strAliasName = "岩心实验数据"; QString strUnit = ""; @@ -7077,15 +7060,6 @@ void FormDraw::initCorePhysics(QMyCustomPlot *widget, QString strSlfName, QStrin addRandomGraph(widget, x, y, strSlfName, strLineName, strAliasName, strUnit, newLeftScale, newRightScale, strScaleType, lineColor, width, lineStyle, stringList); -// if(stringList.size() >= 1) -// { - -// } -// else -// { -// addRandomGraph(widget, x, y, strSlfName, strLineName, strAliasName, strUnit); -// } - //支持框选------------------ // widget->setSelectionRectMode(QCP::SelectionRectMode::srmSelect); widget->graph(0)->setSelectable(QCP::SelectionType::stMultipleDataRanges);// stSingleData diff --git a/logPlus/formdraw.h b/logPlus/formdraw.h index df788ec..5dfb59a 100644 --- a/logPlus/formdraw.h +++ b/logPlus/formdraw.h @@ -229,7 +229,7 @@ public: //岩心图片数据 void initIMAGE_DATA(QMyCustomPlot *widget, QString strSlfName, QString strLineName, QStringList listOtherProperty={}); - bool LoadFromIMAGE_SLF(QMyCustomPlot *widget, QString strSlfName, QString strLineName); +// bool LoadFromIMAGE_SLF(QMyCustomPlot *widget, QString strSlfName, QString strLineName); //深度 void initDepth(QMyCustomPlot *widget); diff --git a/logPlus/qmycustomplot.cpp b/logPlus/qmycustomplot.cpp index 3697218..6ab268e 100644 --- a/logPlus/qmycustomplot.cpp +++ b/logPlus/qmycustomplot.cpp @@ -1917,8 +1917,47 @@ void QMyCustomPlot::addItemsImage(){ //属性清空 PropertyService()->InitCurrentViewInfo(); } -void QMyCustomPlot::deleteItemsImage(){} -void QMyCustomPlot::refreshItemsImage(){} +void QMyCustomPlot::deleteItemsImage() +{ + if(QMessageBox::information(NULL,QObject::tr("提示"),QObject::tr("该功能将清除当前组件展示的全部信息,清除后无法恢复,但会备份到对应的\"_BAK\"中,确定清除吗?"),QMessageBox::Yes|QMessageBox::No)!=QMessageBox::Yes) return; + QString obj = m_strLineName + "BAK"; + CopyToSLFFile(m_strSlfName, false, (char *)obj.toStdString().c_str()); + AddTableToWellRound(); + + //删除对象 + TransparentDraggableImage *pDraggableRect =NULL; + QMap::Iterator it = m_mapDraggable_Image.begin(); + while( it != m_mapDraggable_Image.end() ) + { + pDraggableRect = (TransparentDraggableImage*)it.value(); + it++; + pDraggableRect->deleteRect(); + } + this->replot(); + + //保存 + SaveToSLFImage(); + //属性清空 + PropertyService()->InitCurrentViewInfo(); +} +void QMyCustomPlot::refreshItemsImage() +{ + //删除对象 + TransparentDraggableImage *pDraggableRect =NULL; + QMap::Iterator it = m_mapDraggable_Image.begin(); + while( it != m_mapDraggable_Image.end() ) + { + pDraggableRect = (TransparentDraggableImage*)it.value(); + it++; + pDraggableRect->deleteRect(); + } + + //重新加载 + this->LoadFromIMAGE_SLF(m_strSlfName, m_strLineName); + this->replot(); + //属性清空 + PropertyService()->InitCurrentViewInfo(); +} // 增加 void QMyCustomPlot::addCorePhysics() @@ -1952,10 +1991,46 @@ void QMyCustomPlot::pasteCorePhysics() {} //全部清空 void QMyCustomPlot::deleteCorePhysics() -{} +{ + if(QMessageBox::information(NULL,QObject::tr("提示"),QObject::tr("该功能将清除当前组件展示的全部信息,清除后无法恢复,但会备份到对应的\"_BAK\"中,确定清除吗?"),QMessageBox::Yes|QMessageBox::No)!=QMessageBox::Yes) return; + QString obj = m_strLineName + "BAK"; + CopyToSLFFile(m_strSlfName, false, (char *)obj.toStdString().c_str()); + AddTableToWellRound(); + + //删除对象 + TransparentDraggableCorePhysics *pDraggableRect =NULL; + QMap::Iterator it = m_mapDraggable_CorePhysics.begin(); + while( it != m_mapDraggable_CorePhysics.end() ) + { + pDraggableRect = (TransparentDraggableCorePhysics*)it.value(); + it++; + pDraggableRect->deleteRect(); + } + this->replot(); + + //保存 + saveToSLFCorePhysics(); + //属性清空 + PropertyService()->InitCurrentViewInfo(); +} //刷新数据 void QMyCustomPlot::refreshCorePhysics() -{} +{ + //删除对象 + TransparentDraggableCorePhysics *pDraggableRect =NULL; + QMap::Iterator it = m_mapDraggable_CorePhysics.begin(); + while( it != m_mapDraggable_CorePhysics.end() ) + { + pDraggableRect = (TransparentDraggableCorePhysics*)it.value(); + it++; + pDraggableRect->deleteRect(); + } + //重新加载 + this->loadFromSLFCorePhysics(m_strSlfName, m_strLineName); + this->replot(); + //属性清空 + PropertyService()->InitCurrentViewInfo(); +} //右键--添加录井剖面 void QMyCustomPlot::onEditGeoLith() @@ -3600,6 +3675,148 @@ void QMyCustomPlot::RefreshItems_GeoLith() PropertyService()->InitCurrentViewInfo(); } +bool QMyCustomPlot::LoadFromIMAGE_SLF(QString strSlfName, QString strLineName) +{ + { + QString ss=strSlfName; + CMemRdWt *logio=new CMemRdWt(); + if(ss==""||!logio->Open(ss.toStdString().c_str(),CSlfIO::modeRead)) + { + delete logio; + // QMessageBox::information(NULL,"提示","SLF文件打开失败,请检查!!",QMessageBox::Yes); + return false; + } + int iIndex=logio->OpenTable(strLineName.toStdString().c_str()); + if(iIndex>-1) { + int len=logio->GetTableRecordLength(iIndex); + if(lenGetTableRecordCount(iIndex); + for(int i=0;iReadTable(iIndex,i+1,m_Result); + // WelllogItem* item=AddItem(m_Result->StartDepth,m_Result->EndDepth); + // if(!item) continue; + // OGWordsResultItem* pResult = dynamic_cast(item); + //logio->GetTableFieldData(iIndex,(char*)FieldName.toStdString().c_str(),m_Result->Image,i+1); + + + // SetCharacters(m_Result->Words); + + // fontColor=QColor(0,0,0,255); + // backgroundColor=QColor(255,255,255,255); + // wordfont.setFamily("黑体"); + // wordfont.setPointSize(10); + + //显示图片Image + QString filename=QString::fromLocal8Bit(m_Result->Image); + int pos=filename.lastIndexOf("\\"); + int pos1=filename.lastIndexOf("/"); + if(pos1>pos) pos=pos1; + if(filename.lastIndexOf(".")>-1) { + int aa=filename.lastIndexOf("."); + if(aaaddImageToPlot(-m_Result->EndDepth, -m_Result->StartDepth, filename, static_cast(m_Result->Left), static_cast(m_Result->Width)); + } + logio->CloseTable(iIndex); + delete buf; + } + delete logio; + } + return true; +} + +bool QMyCustomPlot::loadFromSLFCorePhysics(QString strSlfName, QString strLineName) +{ + float vmax = 100; + float vmin = 0; + // 加载slf文件 开始 + QVector x, y; + Slf_CORE_PHYSICS *m_pResult=NULL; + CMemRdWt *logio=new CMemRdWt(); + if(strSlfName==""||!logio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeRead)) + { + delete logio; + // QMessageBox::information(NULL,"提示","SLF文件打开失败,请检查!!",QMessageBox::Yes); + return false; + } + int iIndex=logio->OpenTable(strLineName.toStdString().c_str()); + if(iIndex>-1) { + int FieldNo=0; + int count=logio->GetTableRecordCount(iIndex); + + QString FieldName = "AC"; + + if(!FieldName.isEmpty()) { + static int err=0; + FieldNo=logio->GetTableFieldNo(iIndex,(char *)FieldName.toStdString().c_str()); + if(FieldNo<0) { + if(!err)QMessageBox::information(nullptr, "提示", "岩心试验数据模块初始加载数据不成功,因为隐含"+FieldName+"字段在实际数据表中不存在,稍后请您重新选择有效字段!"); + err++; + delete logio; + return false; + } + else err=0; + } + else { + delete logio; + return false; + } + int len=logio->GetTableRecordLength(iIndex); + m_pResult=(Slf_CORE_PHYSICS *)new char[len+1]; + char buf[100]; + for(int i=0;iGetTableFieldData(iIndex,1,buf,i+1); + sscanf(buf,"%f",&m_pResult->Depth); + logio->GetTableFieldData(iIndex,2,buf,i+1); + sscanf(buf,"%f",&m_pResult->CorrDepth); + // logio->ReadTable(iIndex,i+1,m_pResult); + + int Order = m_pResult->Order; + float depth = m_pResult->Depth; + float CorrDepth = m_pResult->CorrDepth; + float CoreValue = m_pResult->CoreValue; + logio->GetTableFieldData(iIndex,FieldNo,buf,i+1); + + CoreValue=0; + sscanf(buf,"%f",&CoreValue); + // + + if(i==0) + { + //最大值,最小值默认采用第一个有效值 + //vmax = vmin = CoreValue; + + //默认采用0-100范围 + if(vmaxCoreValue)vmin=CoreValue; + } + else + { + // + if(vmaxCoreValue)vmin=CoreValue; + } + // + x.append(-CorrDepth); + y.append(CoreValue); + // 已经加载了slf文件内容 显示界面上 + this->addCorePhysicsWithParam(Order, static_cast(-depth), static_cast(-CorrDepth), static_cast(-CoreValue)); + } + logio->CloseTable(iIndex); + delete m_pResult; + } + delete logio; + // 加载slf文件结束 + + return true; +} + bool QMyCustomPlot::LoadFromSLF_SwallCore(QString strSlfName, QString strLineName) { WALLCORE_DATA m_Result; diff --git a/logPlus/qmycustomplot.h b/logPlus/qmycustomplot.h index 7d17e2b..7ea8367 100644 --- a/logPlus/qmycustomplot.h +++ b/logPlus/qmycustomplot.h @@ -227,10 +227,12 @@ public: // 岩心图片 QMap zoneOrderImage; bool SaveToSLFImage(); + bool LoadFromIMAGE_SLF(QString strSlfName, QString strLineName); // 岩心分析 QMap zoneOrderCorePhysics; bool saveToSLFCorePhysics(); + bool loadFromSLFCorePhysics(QString strSlfName, QString strLineName); //井壁取心 QStringList liths_SWallCore;