From 6513750e759534dc1cbd9adc16d9442bdb4040f2 Mon Sep 17 00:00:00 2001 From: zhaolei <353719554@qq.com> Date: Thu, 5 Mar 2026 09:29:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DataMgr/src/CopyObjectDlg.cpp | 765 ++++++++++++++++++++++++++++++++++ DataMgr/src/CopyObjectDlg.h | 70 ++++ 2 files changed, 835 insertions(+) create mode 100644 DataMgr/src/CopyObjectDlg.cpp create mode 100644 DataMgr/src/CopyObjectDlg.h diff --git a/DataMgr/src/CopyObjectDlg.cpp b/DataMgr/src/CopyObjectDlg.cpp new file mode 100644 index 0000000..a573d2d --- /dev/null +++ b/DataMgr/src/CopyObjectDlg.cpp @@ -0,0 +1,765 @@ +#pragma warning(push,0) +// #include "Family.h" +#include +#include +#include "CopyObjectDlg.h" +#include "CStringType.h" +#include "DataHelper.h" +#include "LogIO.h" +// #include "ObjProject.h" +#include "ObjectID.h" +#include "ObjWell.h" +#include "ObjWelllogRound.h" +// #include "DataTree.h" +#pragma warning(pop) +using namespace pai::ios::welllog; +BEGIN_OSGGRAPHICS_NAMESPACE + CCopyObjectDlg::CCopyObjectDlg(QWidget * parent, Qt::WindowFlags flags) + : QDialog(parent,flags) +{ + m_pUI = new Ui_CopyObject(); + m_pUI->setupUi(this); + m_pUI->lineEdit_Sdep->setText("-9999.");; + m_pUI->lineEdit_Edep->setText("-9999."); + m_pUI->comboBox_Mode->addItem("替换"); + m_pUI->comboBox_Mode->addItem("合并"); + m_pUI->comboBox_Mode->addItem("另存");//放弃 + m_pUI->comboBox_Mode->setCurrentIndex(0); + connect(m_pUI->pushButtonCopy,SIGNAL(clicked()),this,SLOT(slotCopy())); + connect(m_pUI->comboBoxWell_Source, SIGNAL(currentIndexChanged(int)),this, SLOT(slotChangeSourceWell(int))); + connect(m_pUI->comboBoxRound_Source, SIGNAL(currentIndexChanged(int)),this, SLOT(slotChangeSourceRound(int))); + connect(m_pUI->comboBoxWell_Dest, SIGNAL(currentIndexChanged(int)),this, SLOT(slotChangeDestWell(int))); + connect(m_pUI->comboBoxRound_Dest, SIGNAL(currentIndexChanged(int)),this, SLOT(slotChangeDestRound(int))); + connect(m_pUI->checkBox_Curve, SIGNAL(clicked()), this, SLOT(slotCheckCurve())); + connect(m_pUI->checkBox_Wave, SIGNAL(clicked()), this, SLOT(slotCheckWave())); + connect(m_pUI->checkBox_Table, SIGNAL(clicked()), this, SLOT(slotCheckTable())); + connect(m_pUI->checkBox_Stream, SIGNAL(clicked()), this, SLOT(slotCheckPar())); + connect(m_pUI->checkBox_Other, SIGNAL(clicked()), this, SLOT(slotCheckOther())); + connect(m_pUI->pushButton_SelAll, SIGNAL(clicked()), this, SLOT(slotSelAll())); + connect(m_pUI->pushButton_NotSelAll, SIGNAL(clicked()), this, SLOT(slotNotSelAll())); + connect(m_pUI->pushButton_ReSel, SIGNAL(clicked()), this, SLOT(slotReverseSel())); + m_pUI->checkBox_Curve->setCheckState(Qt::Checked); + m_pUI->checkBox_Wave->setCheckState(Qt::Checked); + m_pUI->checkBox_Table->setCheckState(Qt::Checked); + m_pUI->checkBox_Stream->setCheckState(Qt::Checked); + m_pUI->checkBox_Other->setCheckState(Qt::Checked); +} +void CCopyObjectDlg::Init() +{ + first=1; + WellNameList=DataHelper::GetAllWellName(); + m_pUI->comboBoxWell_Source->addItems(WellNameList); + if(WellName==""&&WellNameList.size())WellName=WellNameList.at(0); + WellRoundNameList=DataHelper::GetAllWellRoundName(WellName,WellRoundFileNameList); + if(WellRoundFileName=="")WellRoundFileName=WellRoundFileNameList.at(0); + m_pUI->comboBoxRound_Source->addItems(WellRoundNameList); + // + WellRoundNameList2=WellRoundNameList; + WellRoundFileNameList2=WellRoundFileNameList; + m_pUI->comboBoxWell_Dest->addItems(WellNameList); + m_pUI->comboBoxRound_Dest->addItems(WellRoundNameList2); + // + for(int i=0;icomboBoxWell_Source->setCurrentIndex(i); + m_pUI->comboBoxWell_Dest->setCurrentIndex(i); + for(int j=0;jcomboBoxRound_Source->setCurrentIndex(j); + m_pUI->comboBoxRound_Dest->setCurrentIndex(j); + break; + } + } + break; + } + } + QStringList header; + header<<"对象名称"<<"对象类型"<<"起始深度"<<"终止深度"<<"拷贝名称"; + m_pUI->tableWidget_Source->setColumnCount(5); + m_pUI->tableWidget_Source->setHorizontalHeaderLabels(header); + m_pUI->tableWidget_Source->horizontalHeader()->setStretchLastSection(true); + //m_pUI->tableWidget_Source->horizontalHeader()->resizeSections(QHeaderView::Stretch); + m_pUI->tableWidget_Source->setColumnWidth(0,120); + for(int i=1;i<5;i++)m_pUI->tableWidget_Source->setColumnWidth(i,80); + /*m_pUI->tableWidget_Source->setColumnWidth(1,100); + m_pUI->tableWidget_Source->setColumnWidth(2,100); + m_pUI->tableWidget_Source->setColumnWidth(3,80);*/ + // + m_pUI->tableWidget_Dest->setColumnCount(4); + m_pUI->tableWidget_Dest->setHorizontalHeaderLabels(header); + m_pUI->tableWidget_Dest->horizontalHeader()->setStretchLastSection(true); + m_pUI->tableWidget_Dest->setColumnWidth(0,120); + m_pUI->tableWidget_Dest->setColumnWidth(1,100); + m_pUI->tableWidget_Dest->setColumnWidth(2,100); + m_pUI->tableWidget_Dest->setColumnWidth(3,80); + first=0; +} +void CCopyObjectDlg::slotChangeSourceWell(int item) +{ + if(first)return; + if(WellNameList.size())WellName=WellNameList.at(item); + WellRoundNameList=DataHelper::GetAllWellRoundName(WellName,WellRoundFileNameList); + //WellRoundFileName=WellRoundFileNameList.at(0); + disconnect(m_pUI->comboBoxRound_Source, SIGNAL(currentIndexChanged(int)),this, SLOT(slotChangeSourceRound(int))); + m_pUI->comboBoxRound_Source->clear(); + connect(m_pUI->comboBoxRound_Source, SIGNAL(currentIndexChanged(int)),this, SLOT(slotChangeSourceRound(int))); + m_pUI->comboBoxRound_Source->addItems(WellRoundNameList); + m_pUI->comboBoxRound_Source->setCurrentIndex(0); +} +void CCopyObjectDlg::slotChangeSourceRound(int item) +{ + QString FileName=WellRoundFileNameList.at(item); + CLogIO *mrw=new CLogIO(); + if(!mrw->Open(FileName.toStdString().c_str(),CSlfIO::modeReadWrite)) + { + delete mrw; + QMessageBox::warning(NULL,"提示","打开文件"+FileName+"错误"); + return ; + } + int ObjectNumber=mrw->GetObjectCount(); + Curve_Info.clear(); + Wave_Info.clear(); + ParName.clear(); + TableName.clear(); + OtherName.clear(); + char Name[200]; + for(int i=0;iGetObjectStatus(i)!=OBJECT_NORMAL)continue; + mrw->GetObjectName(i,Name); + if(strcmp(Name,"井基本信息")==0)continue; + short Attribute,SubAttribute; + Attribute=mrw->GetObjectType(i); + if(Attribute==CURVE_OBJECT) + { + Slf_CURVE cInfo; + int index=mrw->OpenCurve(Name); + if(index<0) { + continue; + } + mrw->GetCurveInfo(index,&cInfo); + Curve_Info.push_back(cInfo); + mrw->CloseCurve(index); + } + else if(Attribute==WAVE_OBJECT) + { + Slf_WAVE cInfo; + int index=mrw->OpenWave(Name); + if(index<0) { + continue; + } + mrw->GetWaveInfo(index,&cInfo); + Wave_Info.push_back(cInfo); + mrw->CloseWave(index); + } + else if(Attribute==CARD_OBJECT)ParName.append(QString::fromLocal8Bit(Name)); + else if(Attribute==FMT_OBJECT||Attribute==TDT_OBJECT)OtherName.append(QString::fromLocal8Bit(Name)); + else TableName.append(QString::fromLocal8Bit(Name)); + } + delete mrw; + RefurbishSource(); +} +void CCopyObjectDlg::RefurbishSource() +{ + m_pUI->tableWidget_Source->clearContents(); + int RowCount=0; + if(m_pUI->checkBox_Curve->checkState()==Qt::Checked)RowCount+=Curve_Info.size(); + if(m_pUI->checkBox_Wave->checkState()==Qt::Checked)RowCount+=Wave_Info.size(); + if(m_pUI->checkBox_Table->checkState()==Qt::Checked)RowCount+=TableName.size(); + if(m_pUI->checkBox_Stream->checkState()==Qt::Checked)RowCount+=ParName.size(); + if(m_pUI->checkBox_Other->checkState()==Qt::Checked)RowCount+=OtherName.size(); + m_pUI->tableWidget_Source->setColumnCount(5); + m_pUI->tableWidget_Source->setRowCount(RowCount); + int row=0; + if(m_pUI->checkBox_Curve->checkState()==Qt::Checked) + { + for(int i=0;itableWidget_Source->setItem(i,0,new QTableWidgetItem(QString(QLatin1String(Curve_Info[i].Name)))); + m_pUI->tableWidget_Source->setItem(i,1,new QTableWidgetItem(QString("常规曲线"))); + m_pUI->tableWidget_Source->setItem(i,2,new QTableWidgetItem(QString::number(Curve_Info[i].StartDepth))); + m_pUI->tableWidget_Source->setItem(i,3,new QTableWidgetItem(QString::number(Curve_Info[i].EndDepth))); + m_pUI->tableWidget_Source->setItem(i,4,new QTableWidgetItem(QString(QLatin1String(Curve_Info[i].Name)))); + m_pUI->tableWidget_Source->item(i,0)->setCheckState(Qt::Checked); + } + row+=Curve_Info.size(); + } + if(m_pUI->checkBox_Wave->checkState()==Qt::Checked) + { + for(int i=0;itableWidget_Source->setItem(row+i,0,new QTableWidgetItem(QString(QLatin1String(Wave_Info[i].Name)))); + m_pUI->tableWidget_Source->setItem(row+i,1,new QTableWidgetItem(QString("波列曲线"))); + m_pUI->tableWidget_Source->setItem(row+i,2,new QTableWidgetItem(QString::number(Wave_Info[i].StartDepth))); + m_pUI->tableWidget_Source->setItem(row+i,3,new QTableWidgetItem(QString::number(Wave_Info[i].EndDepth))); + m_pUI->tableWidget_Source->item(row+i,0)->setCheckState(Qt::Checked); + } + row+=Wave_Info.size(); + } + if(m_pUI->checkBox_Table->checkState()==Qt::Checked) + { + for(int i=0;itableWidget_Source->setItem(row+i,0,new QTableWidgetItem(TableName.at(i))); + m_pUI->tableWidget_Source->setItem(row+i,1,new QTableWidgetItem(QString("数据表"))); + m_pUI->tableWidget_Source->item(row+i,0)->setCheckState(Qt::Checked); + } + row+=TableName.size(); + } + if(m_pUI->checkBox_Stream->checkState()==Qt::Checked) + { + for(int i=0;itableWidget_Source->setItem(row+i,0,new QTableWidgetItem(ParName.at(i))); + m_pUI->tableWidget_Source->setItem(row+i,1,new QTableWidgetItem(QString("参数对象"))); + m_pUI->tableWidget_Source->item(row+i,0)->setCheckState(Qt::Checked); + } + row+=ParName.size(); + } + if(m_pUI->checkBox_Other->checkState()==Qt::Checked) + { + for(int i=0;itableWidget_Source->setItem(row+i,0,new QTableWidgetItem(OtherName.at(i))); + m_pUI->tableWidget_Source->setItem(row+i,1,new QTableWidgetItem(QString("其他数据"))); + m_pUI->tableWidget_Source->item(row+i,0)->setCheckState(Qt::Checked); + } + } +} +void CCopyObjectDlg::slotSelAll() +{ + for(int i=0;itableWidget_Source->rowCount();i++)m_pUI->tableWidget_Source->item(i,0)->setCheckState(Qt::Checked); +} +void CCopyObjectDlg::slotNotSelAll() +{ + for(int i=0;itableWidget_Source->rowCount();i++)m_pUI->tableWidget_Source->item(i,0)->setCheckState(Qt::Unchecked); +} +void CCopyObjectDlg::slotReverseSel() +{ + for(int i=0;itableWidget_Source->rowCount();i++) + { + Qt::CheckState eState= m_pUI->tableWidget_Source->item(i,0)->checkState(); + if (eState==Qt::Checked)m_pUI->tableWidget_Source->item(i,0)->setCheckState(Qt::Unchecked); + else m_pUI->tableWidget_Source->item(i,0)->setCheckState(Qt::Checked); + } +} +//dest +void CCopyObjectDlg::slotChangeDestWell(int item) +{ + if(first)return; + WellName=WellNameList.at(item); + WellRoundNameList2=DataHelper::GetAllWellRoundName(WellName,WellRoundFileNameList2); + //WellRoundFileName=WellRoundFileNameList.at(0); + disconnect(m_pUI->comboBoxRound_Dest, SIGNAL(currentIndexChanged(int)),this, SLOT(slotChangeDestRound(int))); + m_pUI->comboBoxRound_Dest->clear(); + connect(m_pUI->comboBoxRound_Dest, SIGNAL(currentIndexChanged(int)),this, SLOT(slotChangeDestRound(int))); + m_pUI->comboBoxRound_Dest->addItems(WellRoundNameList2); + m_pUI->comboBoxRound_Dest->setCurrentIndex(0); +} +void CCopyObjectDlg::slotChangeDestRound(int item) +{ + QString FileName=WellRoundFileNameList2.at(item); + CLogIO *mrw=new CLogIO(); + if(!mrw->Open(FileName.toStdString().c_str(),CSlfIO::modeReadWrite)) + { + delete mrw; + QMessageBox::warning(NULL,"提示","打开文件"+FileName+"错误"); + return ; + } + int ObjectNumber=mrw->GetObjectCount(); + Curve_Info2.clear(); + Wave_Info2.clear(); + ParName2.clear(); + TableName2.clear(); + OtherName2.clear(); + char Name[200]; + for(int i=0;iGetObjectStatus(i)!=OBJECT_NORMAL)continue; + mrw->GetObjectName(i,Name); + if(strcmp(Name,"井基本信息")==0)continue; + short Attribute,SubAttribute; + Attribute=mrw->GetObjectType(i); + if(Attribute==CURVE_OBJECT) + { + Slf_CURVE cInfo; + int index=mrw->OpenCurve(Name); + if(index<0) { + continue; + } + mrw->GetCurveInfo(index,&cInfo); + Curve_Info2.push_back(cInfo); + } + else if(Attribute==WAVE_OBJECT) + { + Slf_WAVE cInfo; + int index=mrw->OpenWave(Name); + mrw->GetWaveInfo(index,&cInfo); + Wave_Info2.push_back(cInfo); + } + else if(Attribute==CARD_OBJECT)ParName2.append(QString::fromLocal8Bit(Name)); + else if(Attribute==FMT_OBJECT||Attribute==TDT_OBJECT)OtherName2.append(QString::fromLocal8Bit(Name)); + else TableName2.append(QString::fromLocal8Bit(Name)); + } + delete mrw; + RefurbishDest(); +} +void CCopyObjectDlg::RefurbishDest() +{ + m_pUI->tableWidget_Dest->clearContents(); + int RowCount=0; + if(m_pUI->checkBox_Curve->checkState()==Qt::Checked)RowCount+=Curve_Info2.size(); + if(m_pUI->checkBox_Wave->checkState()==Qt::Checked)RowCount+=Wave_Info2.size(); + if(m_pUI->checkBox_Table->checkState()==Qt::Checked)RowCount+=TableName2.size(); + if(m_pUI->checkBox_Stream->checkState()==Qt::Checked)RowCount+=ParName2.size(); + if(m_pUI->checkBox_Other->checkState()==Qt::Checked)RowCount+=OtherName2.size(); + m_pUI->tableWidget_Dest->setColumnCount(4); + m_pUI->tableWidget_Dest->setRowCount(RowCount); + int row=0; + if(m_pUI->checkBox_Curve->checkState()==Qt::Checked) + { + for(int i=0;itableWidget_Dest->setItem(i,0,new QTableWidgetItem(QString(QLatin1String(Curve_Info2[i].Name)))); + m_pUI->tableWidget_Dest->setItem(i,1,new QTableWidgetItem(QString("常规曲线"))); + m_pUI->tableWidget_Dest->setItem(i,2,new QTableWidgetItem(QString::number(Curve_Info2[i].StartDepth))); + m_pUI->tableWidget_Dest->setItem(i,3,new QTableWidgetItem(QString::number(Curve_Info2[i].EndDepth))); + //m_pUI->tableWidget_Dest->item(i,0)->setCheckState(Qt::Checked); + } + row+=Curve_Info2.size(); + } + if(m_pUI->checkBox_Wave->checkState()==Qt::Checked) + { + for(int i=0;itableWidget_Dest->setItem(row+i,0,new QTableWidgetItem(QString(QLatin1String(Wave_Info2[i].Name)))); + m_pUI->tableWidget_Dest->setItem(row+i,1,new QTableWidgetItem(QString("波列曲线"))); + m_pUI->tableWidget_Dest->setItem(row+i,2,new QTableWidgetItem(QString::number(Wave_Info2[i].StartDepth))); + m_pUI->tableWidget_Dest->setItem(row+i,3,new QTableWidgetItem(QString::number(Wave_Info2[i].EndDepth))); + //m_pUI->tableWidget_Dest->item(row+i,0)->setCheckState(Qt::Checked); + } + row+=Wave_Info2.size(); + } + if(m_pUI->checkBox_Table->checkState()==Qt::Checked) + { + for(int i=0;itableWidget_Dest->setItem(row+i,0,new QTableWidgetItem(TableName2.at(i))); + m_pUI->tableWidget_Dest->setItem(row+i,1,new QTableWidgetItem(QString("数据表"))); + //m_pUI->tableWidget_Dest->item(row+i,0)->setCheckState(Qt::Checked); + } + row+=TableName2.size(); + } + if(m_pUI->checkBox_Stream->checkState()==Qt::Checked) + { + for(int i=0;itableWidget_Dest->setItem(row+i,0,new QTableWidgetItem(ParName2.at(i))); + m_pUI->tableWidget_Dest->setItem(row+i,1,new QTableWidgetItem(QString("参数对象"))); + //m_pUI->tableWidget_Dest->item(row+i,0)->setCheckState(Qt::Checked); + } + row+=ParName2.size(); + } + if(m_pUI->checkBox_Other->checkState()==Qt::Checked) + { + for(int i=0;itableWidget_Dest->setItem(row+i,0,new QTableWidgetItem(OtherName2.at(i))); + m_pUI->tableWidget_Dest->setItem(row+i,1,new QTableWidgetItem(QString("其他数据"))); + //m_pUI->tableWidget_Dest->item(row+i,0)->setCheckState(Qt::Checked); + } + } +} + + + +void CCopyObjectDlg::slotCheckCurve(){RefurbishSource();RefurbishDest();} +void CCopyObjectDlg::slotCheckWave(){RefurbishSource();RefurbishDest();} +void CCopyObjectDlg::slotCheckTable(){RefurbishSource();RefurbishDest();} +void CCopyObjectDlg::slotCheckPar(){RefurbishSource();RefurbishDest();} +void CCopyObjectDlg::slotCheckOther(){RefurbishSource();;RefurbishDest();} +void CCopyObjectDlg::slotCopy() +{ + int roundItem=m_pUI->comboBoxRound_Dest->currentIndex(); + bool ok; + float sdep=m_pUI->lineEdit_Sdep->text().toFloat(&ok); + if(!ok){ + QMessageBox::warning(NULL,"提示","拷贝深度范围不正确:起始深度必须是数值\r\n请修改后再执行拷贝"); + return ; + } + float edep=m_pUI->lineEdit_Edep->text().toFloat(&ok); + if(!ok){ + QMessageBox::warning(NULL,"提示","拷贝深度范围不正确:终止深度必须是数值\r\n请修改后再执行拷贝"); + return ; + } + if(edep!=-9999.&&edepcomboBoxRound_Source->currentIndex()); + QString DestFile=WellRoundFileNameList2.at(m_pUI->comboBoxRound_Dest->currentIndex()); + CLogIO *mrw=new CLogIO(); + mrw->Open(SourceFile.toStdString().c_str(),CSlfIO::modeRead); + CLogIO *mrw2=new CLogIO(); + mrw2->Open(DestFile.toStdString().c_str(),CSlfIO::modeReadWrite); + int mode=m_pUI->comboBox_Mode->currentIndex(); + + QString sName,TypeName,sNewName; + char Name[64],NewName[64]; + for(int i=0;itableWidget_Source->rowCount();i++) + { + if(m_pUI->tableWidget_Source->item(i,0)->checkState()==Qt::Unchecked)continue; + sName=m_pUI->tableWidget_Source->item(i,0)->text(); + + int len=strlen(sName.toStdString().c_str()); + strncpy(Name,sName.toStdString().c_str(),len); + Name[len]=0; + if(m_pUI->tableWidget_Source->item(i,4)) { + sNewName=m_pUI->tableWidget_Source->item(i,4)->text(); + } + else sNewName=Name; + len=strlen(sNewName.toStdString().c_str()); + strncpy(NewName,sNewName.toStdString().c_str(),len); + NewName[len]=0; + if(m_pUI->tableWidget_Source->item(i,1)) { + TypeName=m_pUI->tableWidget_Source->item(i,1)->text(); + } + else TypeName=""; + int index=mrw2->FindObjectName(NewName); + if(index>=0) + { + if(mode==0)//替换 + { + mrw2->DiscardObject(NewName); + index=-1; + } + else if(mode==2)//另存 //continue;//放弃 + { + QString name=sNewName+"_"; + for(int j=0;j<100;j++) + { + sNewName=name+QString::number(j+1); + len=strlen(sNewName.toStdString().c_str()); + strncpy(NewName,sNewName.toStdString().c_str(),len); + NewName[len]=0; + index=mrw2->FindObjectName(NewName); + if(index<0)break; + } + } + } + if(index<0) + { + if(TypeName=="数据表"||TypeName=="参数对象"||TypeName=="其他数据") + { + bool ok=mrw2->CopyFromFile((CSlfIO &)(*mrw),Name,NewName); + int h=0; + } + else if(TypeName=="常规曲线") + { + Slf_CURVE Info; + int ind1=mrw->OpenCurve(Name); + if(ind1<0) { + continue; + } + mrw->GetCurveInfo(ind1,&Info); + if(sdep==-9999&&edep==-9999)/* + ||(sdep<=Info.StartDepth&&edep>=Info.EndDepth))*/ + {//全井段拷贝 + mrw->CloseCurve(ind1); + mrw2->CopyFromFile((CSlfIO &)(*mrw),Name,NewName); + } + else + { + //分段拷贝 + Info.StartDepth=sdep;Info.EndDepth=edep; + strcpy(Info.Name,NewName); + strcpy(Info.AliasName,NewName); + int ind2=mrw2->OpenCurve(&Info); + if(ind2<0) + { + mrw->CloseCurve(ind1); + QMessageBox::warning(NULL,"提示","目标文件中产生曲线"+sName+"失败\r\n该曲线不能进行拷贝"); + continue ; + } + DWORD count=(edep-sdep)/Info.DepLevel+1.5; + MyDataTypeEnum vVdl; + vVdl.vchar=new char[count*Info.CodeLen]; + mrw->ReadCurve(ind1,sdep,count,(void *)vVdl.vchar); + mrw2->WriteCurve(ind2,sdep,count,(void *)vVdl.vchar); + mrw->CloseCurve(ind1); + mrw2->CloseCurve(ind2); + } + } + else if(TypeName=="波列曲线") + { + Slf_WAVE Info; + int ind1=mrw->OpenWave(Name); + mrw->GetWaveInfo(ind1,&Info); + if(sdep==-9999&&edep==-9999) + /*||(sdep<=Info.StartDepth&&edep>=Info.EndDepth))*/ + {//全井段拷贝 + mrw->CloseWave(ind1); + mrw2->CopyFromFile((CSlfIO &)(*mrw),Name,NewName); + } + else + { + //分段拷贝 + float outsdep=sdep/*Info.StartDepth*/,outedep=edep/*Info.EndDepth*/; + if(sdep>outsdep)outsdep=sdep; + if(sdep>outsdep&&sdepoutsdep&&edepOpenWave(&Info); + if(ind2<0) + { + mrw->CloseWave(ind1); + QMessageBox::warning(NULL,"提示","目标文件中产生波列曲线"+sName+"失败\r\n该波列曲线不能进行拷贝"); + continue ; + } + DWORD count=(outedep-outsdep)/Info.DepLevel+1.5; + MyDataTypeEnum vVdl; + vVdl.vchar=new char[count*Info.CodeLen*Info.ArrayNum*Info.TimeSamples]; + mrw->ReadWave(ind1,outsdep,count,(void *)vVdl.vchar); + mrw2->WriteWave(ind2,outsdep,count,(void *)vVdl.vchar); + mrw->CloseWave(ind1); + mrw2->CloseWave(ind2); + } + } + } + else//合并 + { + if(TypeName=="常规曲线") + { + Slf_CURVE Info,Info2; + int ind1=mrw->OpenCurve(Name); + if(index<0) { + continue; + } + mrw->GetCurveInfo(ind1,&Info); + float outsdep=0,outedep=0; + if(sdep==-9999&&edep==-9999) + { + outsdep=Info.StartDepth,outedep=Info.EndDepth; +// if(sdep>outsdep&&sdepoutsdep&&edepoutsdep&&sdepoutsdep&&edepOpenCurve(NewName); + if(ind2<0) + { + mrw->CloseCurve(ind1); + QMessageBox::warning(NULL,"提示","目标文件中打开曲线"+sNewName+"失败\r\n该曲线不能进行拷贝"); + continue ; + } + mrw2->GetCurveInfo(ind2,&Info2); + DWORD count=(outedep-outsdep)/Info2.DepLevel+1.5; + float *val; + val=new float[count]; + if(Info.DepLevel==Info2.DepLevel) + { + mrw->ReadCurve(ind1,outsdep,count,&val[0]); + mrw2->WriteCurve(ind2,outsdep,count,&val[0]); + } + else + { + for(int m=0;mReadCurve(ind1,outsdep+Info2.DepLevel,1,&val[m]); + mrw2->WriteCurve(ind2,outsdep+Info2.DepLevel,count,&val[0]); + } + delete []val; + mrw->CloseCurve(ind1); + mrw2->CloseCurve(ind2); + } + else if(TypeName=="波列曲线") + { + Slf_WAVE Info,Info2; + int ind1=mrw->OpenWave(Name); + mrw->GetWaveInfo(ind1,&Info); + float outsdep=0,outedep=0; + if(sdep==-9999&&edep==-9999) + { + outsdep=Info.StartDepth,outedep=Info.EndDepth; + // if(sdep>outsdep&&sdepoutsdep&&edepoutsdep&&sdepoutsdep&&edepoutsdep&&sdepoutsdep&&edepOpenWave(NewName); + if(ind2<0) + { + mrw->CloseWave(ind1); + QMessageBox::warning(NULL,"提示","目标文件中打开波列曲线"+sNewName+"失败\r\n该波列曲线不能进行拷贝"); + continue ; + } + mrw2->GetWaveInfo(ind2,&Info2); + if(Info.ArrayNum*Info.TimeSamples!=Info2.ArrayNum*Info2.TimeSamples) + { + mrw->CloseWave(ind1); + mrw2->CloseWave(ind2); + QMessageBox::warning(NULL,"提示","源文件中的波列曲线"+sName+"和目标文件中的曲线维数不同\r\n不能进行拷贝"); + continue ; + } + DWORD count=(outedep-outsdep)/Info2.DepLevel+1.5; + float *val; + val=new float[count*Info.ArrayNum*Info.TimeSamples]; + if(Info.DepLevel==Info2.DepLevel) + { + mrw->ReadWave(ind1,outsdep,count,&val[0]); + mrw2->WriteWave(ind2,outsdep,count,&val[0]); + } + else + { + for(int m=0;mReadWave(ind1,outsdep+Info2.DepLevel,1,&val[m*Info.TimeSamples]); + mrw2->WriteWave(ind2,outsdep+Info2.DepLevel,count,&val[0]); + } + mrw->CloseWave(ind1); + mrw2->CloseWave(ind2); + delete []val; + } + else if(TypeName=="参数对象") + { + int ind1=mrw->OpenStream(Name); + int ind2=mrw2->OpenStream(NewName); + if(ind2<0) + { + QMessageBox::warning(NULL,"提示","目标文件中打开参数对象"+sNewName+"失败\r\n该对象不能进行拷贝"); + continue ; + } + DWORD len=mrw->GetSlfStreamLength(ind1); + DWORD len2=mrw2->GetSlfStreamLength(ind2); + char *buf=new char[len+len2+1]; + DWORD bytes; + mrw2->ReadStream(ind2,len2,&bytes,buf); + mrw->ReadStream(ind1,len,&bytes,&buf[len2]); + mrw2->SetStreamLength(ind2,len+len2); + mrw2->WriteStream(ind2,len+len2,&bytes,buf); + mrw->CloseStream(ind1); + mrw2->CloseStream(ind2); + } + else//FMT\TDT\数据表 + { + int ind1=mrw->OpenTable(Name); + int ind2=mrw2->OpenTable(NewName); + if(ind2<0) + { + mrw->CloseTable(ind1); + QMessageBox::warning(NULL,"提示","目标文件中打开"+sNewName+"失败\r\n该对象不能进行拷贝"); + continue ; + } + int len1=mrw->GetTableRecordLength(ind1); + int len2=mrw2->GetTableRecordLength(ind2); + int count1=mrw->GetTableFieldCount(ind1); + int count2=mrw2->GetTableFieldCount(ind2); + if(len1!=len2||count1!=count2) + { + mrw->CloseTable(ind1); + mrw2->CloseTable(ind2); + QMessageBox::warning(NULL,"提示","目标文件中"+sNewName+"表结构和源文件不同\r\n该对象不能进行拷贝"); + continue ; + } + Slf_TABLE_FIELD *FieldInfo=new Slf_TABLE_FIELD[count1+1]; + mrw->GetTableFieldInfo(ind1,FieldInfo); + int rec=mrw->GetTableRecordCount(ind1); + int rec2=mrw2->GetTableRecordCount(ind2); + char *buf1=new char[len1]; + char *buf2=new char[len1]; + char **buffer=new char *[rec2]; + for(int n=0;nReadTable(ind2,m+1,&buffer[m][0]); + } + int mm=0; + for(int m=0;mReadTable(ind1,m+1,buf1); + int IsEqual=true; + bool IsExist=0; + for(int n=0;nWriteTable(ind2,mm+1+rec2,buf1); + mm++; + } + delete buf1;delete buf2; delete FieldInfo; + for(int n=0;nCloseTable(ind1); + mrw2->CloseTable(ind2); + } + } + } + delete mrw; + delete mrw2; + slotChangeDestRound(roundItem); + // //刷新树 + // QString m_wellName=m_pUI->comboBoxWell_Dest->currentText(); + // PaiObject *pObject=GetProject()->GetObjectByName( m_wellName,GetClassID_Well()); + // CObjWell *pWell = dynamic_cast( pObject ); + // if(pWell) { + // QString m_wellRoundName=m_pUI->comboBoxRound_Dest->currentText(); + // QString pr=m_wellRoundName; + // CObjWelllogRound* pWelllogRound=dynamic_cast( pWell->GetObjectByName(pr,GetClassID_WellLogRound())); + // if(pWelllogRound) { + // CDataTree::SetTree(pWelllogRound->GetSlfFileName(),pWell,pWelllogRound,NULL,1); + // for(int i=0;itableWidget_Source->rowCount();i++) + // { + // if(m_pUI->tableWidget_Source->item(i,0)->checkState()==Qt::Unchecked)continue; + // sName=m_pUI->tableWidget_Source->item(i,0)->text(); + // CObjWellLog *mLog=dynamic_cast( pWelllogRound->GetObjectByName(sName)); + // if(mLog&&mLog->IsLoaded()){ + // mLog->isLoad=false; + // mLog->LoadFromSLF(); + // } + // } + // } + // } +} + +END_OSGGRAPHICS_NAMESPACE diff --git a/DataMgr/src/CopyObjectDlg.h b/DataMgr/src/CopyObjectDlg.h new file mode 100644 index 0000000..0032b35 --- /dev/null +++ b/DataMgr/src/CopyObjectDlg.h @@ -0,0 +1,70 @@ +#ifndef COPYOBJECTDLG_H +#define COPYOBJECTDLG_H + +#pragma warning(push,0) +#include +#include +#include "ConsoleOutputWidget.h" +#include "ui_CopyObject.h" +#include "memrdwt.h" +#include "OSGFramework.h" +#pragma warning(pop) +//extern char *DataTypea[]; +//extern int DataLengtha[]; +BEGIN_OSGGRAPHICS_NAMESPACE +/** + * @brief 表格选择列自定义委托 + */ +class CCopyObjectDlg : public QDialog +{ + Q_OBJECT + +public: + CCopyObjectDlg(QWidget * parent=0, Qt::WindowFlags flags=0); + ~CCopyObjectDlg() + { + if(m_pUI) delete m_pUI; + } + Ui_CopyObject *m_pUI; + void Init(); + void RefurbishSource(); + void RefurbishDest(); +private slots: + /** + *@brief 拷贝对象槽函数 + */ + void slotCopy(); + void slotChangeSourceWell(int); + void slotChangeSourceRound(int); + void slotChangeDestWell(int); + void slotChangeDestRound(int); + void slotCheckCurve(); + void slotCheckWave(); + void slotCheckTable(); + void slotCheckPar(); + void slotCheckOther(); + void slotSelAll(); + void slotNotSelAll(); + void slotReverseSel(); +public: + int curitemType; + QString WellName,WellRoundName,WellRoundFileName; + QStringList WellNameList,WellRoundNameList,WellRoundFileNameList; + bool first; + std::vector Curve_Info; + std::vector Wave_Info; + QStringList ParName;//参数流对象名称 + QStringList TableName; + QStringList OtherName; + //Dest + std::vector Curve_Info2; + std::vector Wave_Info2; + QStringList WellRoundNameList2,WellRoundFileNameList2; + QStringList ParName2; + QStringList TableName2; + QStringList OtherName2; +}; + +END_OSGGRAPHICS_NAMESPACE; + +#endif