#include "ui_importdataDialog.h" #include "ImportdataDialog.h" #include "InterIConvertor.h" #include "IConvertor.h" //#include "ObjWelllogRound.h" #include //#include "DataImport.h" #include "CStringType.h" #include "MyWelllogRound.h" #include "tishidialog.h" #include "ui_interfaceWidget.h" //#include "ObjectEvent.h" #include "MemRdWt.h" BEGIN_OSGGRAPHICS_NAMESPACE; ImportDataDialog::ImportDataDialog(QWidget *parent,QString wellname,QString wellroundname): QDialog(parent),m_FilePath(""),m_ExistSameWellName(false),m_ExistSameWellRoundName(false) { m_CurrentWellName=wellname; m_CurrentWellRoundName=wellroundname; m_pImportDataUI=new Ui::ImportData(); m_pImportDataUI->setupUi(this); m_pImportDataUI->tabWidget->removeTab(1); m_pImportDataUI->tabWidget->removeTab(0); connect(m_pImportDataUI->pushButton_2, SIGNAL(clicked()), this, SLOT(AcceptOK())); connect(m_pImportDataUI->pushButton, SIGNAL(clicked()), this, SLOT(reject())); //whp add 2019.10.12 connect(m_pImportDataUI->pushButton_3, SIGNAL(clicked()), this, SLOT(SelAll())); connect(m_pImportDataUI->pushButton_4, SIGNAL(clicked()), this, SLOT(NotSelAll())); connect(m_pImportDataUI->pushButton_5, SIGNAL(clicked()), this, SLOT(ReverseSel())); setAttribute( Qt::WA_DeleteOnClose ,true ); setWindowTitle("Import Well-Logging-Data"); m_pImportDataUI->pushButton_2->setIcon(QIcon( ::GetImagePath() + "icon/Import.png")); m_pImportDataUI->pushButton->setIcon(QIcon( ::GetImagePath() + "icon/Exit.png")); } ImportDataDialog::~ImportDataDialog() { std::map::iterator itor=m_TabInterWidget.begin(); for (;itor!=m_TabInterWidget.end();itor++) { InterfaceWidget *pIterWidget=itor->second; if (pIterWidget) { delete pIterWidget; pIterWidget=NULL; } } m_TabInterWidget.clear(); if (m_pImportDataUI) { delete m_pImportDataUI; m_pImportDataUI=NULL; } } void ImportDataDialog::DisplayFileInformationAreaData( const QVectorConvertorVector,const QString filePath ) { m_vConvertorVector.clear(); m_vConvertorVector=ConvertorVector; std::map&mapBuilderType = IConvertor::GetFatory().m_map; std::map::iterator itor = mapBuilderType.begin(); m_FilePath=filePath; for (int i=0;itabWidget->addTab(tabWidget,QString()); QHBoxLayout *Mainlayout=new QHBoxLayout(tabWidget); QHBoxLayout *ScondLayout=new QHBoxLayout(); Mainlayout->addLayout(ScondLayout); ScondLayout->addWidget(pInterfaceWidget); m_pImportDataUI->tabWidget->setTabText(i,ConvertorVector[i]->GetConvertorTypeName()); pInterfaceWidget->GetDataPreviewArea()->setText(ConvertorVector[i]->GetFileContent(filePath)); FamilyDelegate* familyDelegate=new FamilyDelegate(this); pInterfaceWidget->GetDataSelectAreaWidget()->setItemDelegateForColumn(2,familyDelegate); pInterfaceWidget->m_pConvertor=ConvertorVector[i]; QStringList fileHead=ConvertorVector[i]->GetListHead(); if(fileHead.isEmpty()) fileHead<<"原始名称"<<"原始单位"<<"曲线类别"<<"输出名称"<<"输出单位"; ConvertorVector[i]->m_ColumnCount=fileHead.size(); DisplaySelectAreaData(pInterfaceWidget,fileHead,ConvertorVector[i]); //初始化井和井次信息界面 InitWell(pInterfaceWidget,ConvertorVector[i]); InitWellLogRound(pInterfaceWidget,ConvertorVector[i]); } } void ImportDataDialog::InitWell(InterfaceWidget *pInterfaceWidget,IConvertor*pConvertor) { MyWelllogRound *wellinfo=pConvertor->GetWellLogRoundInfo(); //无井代码 if(m_CurrentWellName!="") pInterfaceWidget->GetWellNameLineEdit()->insert(m_CurrentWellName); else { QString tempWellName=QString::fromStdString(wellinfo->GetWellName());//whp add 2020.7.15 tempWellName=tempWellName.simplified(); //whp change 2020.3.3 井名提取应该不含".zh"之类的后缀,应该取文件的基本名 //文件名中有一个以上的“."时,如3Oq.ZH.716,需要井名和文件名区分开,比如a.zh.716和a.wj.716同时解编,井名都取最前面的a,井次名分别为a.zh和a.wj //pInterfaceWidget->GetWellNameLineEdit()->insert(QString::fromStdString(wellinfo->GetName())); if(tempWellName=="") { QFileInfo temDir(QString::fromStdString(wellinfo->GetName())); tempWellName=temDir.baseName(); } pInterfaceWidget->GetWellNameLineEdit()->insert(tempWellName); } pInterfaceWidget->GetWellCompanyNameLineEdit()->insert(QString::fromStdString(wellinfo->GetCompanyName())); pInterfaceWidget->GetWellAreaNameLineEdit()->insert(QString::fromStdString(wellinfo->GetAreaName())); // pInterfaceWidget->GetWellCodeLineEdit()->insert("井代码"); pInterfaceWidget->GetXCodeLineEdit()->setText(QString::number(wellinfo->GetXCode(), 'f', 4)); pInterfaceWidget->GetYCodeLineEdit()->setText(QString::number(wellinfo->GetYCode(), 'f', 4)); pInterfaceWidget->GetAslLineEdit()->setText(QString::number(wellinfo->GetAsl(), 'f', 4)); pInterfaceWidget->GetBslLineEdit()->setText(QString::number(wellinfo->GetBsl(), 'f', 4)); pInterfaceWidget->GetCWMethodLineEdit()->insert(QString::fromStdString(wellinfo->GetCWMethod())); pInterfaceWidget->GetBit1ProgLineEdit()->insert(QString::fromStdString(wellinfo->GetBit1Prog())); pInterfaceWidget->GetBit2ProgLineEdit()->insert(QString::fromStdString(wellinfo->GetBit2Prog())); pInterfaceWidget->GetBit3ProgLineEdit()->insert(QString::fromStdString(wellinfo->GetBit3Prog())); pInterfaceWidget->GetBit4ProgLineEdit()->insert(QString::fromStdString(wellinfo->GetBit4Prog())); pInterfaceWidget->GetBit5ProgLineEdit()->insert(QString::fromStdString(wellinfo->GetBit5Prog())); pInterfaceWidget->GetCas1ProgLineEdit()->insert(QString::fromStdString(wellinfo->GetCas1Prog())); pInterfaceWidget->GetCas2ProgLineEdit()->insert(QString::fromStdString(wellinfo->GetCas2Prog())); pInterfaceWidget->GetCas3ProgLineEdit()->insert(QString::fromStdString(wellinfo->GetCas3Prog())); pInterfaceWidget->GetCas4ProgLineEdit()->insert(QString::fromStdString(wellinfo->GetCas4Prog())); pInterfaceWidget->GetCas5ProgLineEdit()->insert(QString::fromStdString(wellinfo->GetCas5Prog())); pInterfaceWidget->GetCas1ShotLineEdit()->setText(QString::number(wellinfo->GetCas1Shot(), 'f', 4)); pInterfaceWidget->GetCas2ShotLineEdit()->setText(QString::number(wellinfo->GetCas2Shot(), 'f', 4)); pInterfaceWidget->GetSC1SDepLineEdit()->setText(QString::number(wellinfo->GetSC1SDep(), 'f', 4)); pInterfaceWidget->GetSC1EDepLineEdit()->setText(QString::number(wellinfo->GetSC1EDep(), 'f', 4)); pInterfaceWidget->GetSC2SDepLineEdit()->setText(QString::number(wellinfo->GetSC2SDep(), 'f', 4)); pInterfaceWidget->GetSC2EDepLineEdit()->setText(QString::number(wellinfo->GetSC2EDep(), 'f', 4)); pInterfaceWidget->GetWellTypeComboBox()->addItem(QString::fromStdString("直井")); pInterfaceWidget->GetWellTypeComboBox()->addItem(QString::fromStdString("斜井")); QDate SDrilltime; SDrilltime=QDate::currentDate(); pInterfaceWidget->GerSDrillDateEdit()->setDate(SDrilltime); pInterfaceWidget ->GerSDrillDateEdit()->setDisplayFormat("yyyy年 MM月 dd日"); QDate EDrilltime; EDrilltime=QDate::currentDate(); pInterfaceWidget->GerEDrillDateEdit()->setDate(EDrilltime); pInterfaceWidget ->GerEDrillDateEdit()->setDisplayFormat("yyyy年 MM月 dd日"); QDate Completetime; Completetime=QDate::currentDate(); pInterfaceWidget->GerCompleteDateEdit()->setDate(Completetime); pInterfaceWidget ->GerCompleteDateEdit()->setDisplayFormat("yyyy年 MM月 dd日"); } void ImportDataDialog::InitWellLogRound(InterfaceWidget *pInterfaceWidget,IConvertor*pConvertor) { MyWelllogRound *welllogRound=pConvertor->GetWellLogRoundInfo(); //无测井剖面 if(m_CurrentWellRoundName!="") pInterfaceWidget->GetWellRoundNameLineEdit()->insert(m_CurrentWellRoundName); else pInterfaceWidget->GetWellRoundNameLineEdit()->insert(QString::fromStdString(welllogRound->GetName())); pInterfaceWidget->GetCompanyNameLineEdit()->insert(QString::fromStdString(welllogRound->GetCompanyName())); pInterfaceWidget->GetTeamLineEdit()->insert(QString::fromStdString(welllogRound->GetTeam())); pInterfaceWidget->GetOperatorLineEdit()->insert(QString::fromStdString(welllogRound->GetOperator())); pInterfaceWidget->GetMudViscosityLineEdit()->insert(QString::number(welllogRound->GetMudViscosity(), 'f', 4)); pInterfaceWidget->GetRemarkTextEdit()->setText(QString::fromStdString(welllogRound->GetRemark())); pInterfaceWidget->GetWaterLossLineEdit()->setText(QString::number(welllogRound->GetWaterLoss(), 'f', 4)); pInterfaceWidget->GetDensityLineEdit()->setText(QString::number(welllogRound->GetDensity(), 'f', 4)); pInterfaceWidget->GetResiLineEdit()->setText(QString::number(welllogRound->GetResi(), 'f', 4)); pInterfaceWidget->GetTempLineEdit()->setText(QString::number(welllogRound->GetTemp(), 'f', 4)); pInterfaceWidget->GetINTLogLineEdit()->insert(QString::fromStdString(welllogRound->GetINTLog())); pInterfaceWidget->GetTempBotLineEdit()->setText(QString::number(welllogRound->GetTempBot(), 'f', 4)); pInterfaceWidget->GetNITINTLineEdit()->insert(QString::fromStdString(welllogRound->GetNITINT())); pInterfaceWidget->GetIntProgLineEdit()->insert(QString::fromStdString(welllogRound->GetIntProg())); pInterfaceWidget->GetInteDressLineEdit()->insert(QString::fromStdString(welllogRound->GetInteDress())); pInterfaceWidget->GetAuditLineEdit()->insert(QString::fromStdString(welllogRound->GetAudit())); pInterfaceWidget->GetEditTopDepth()->setText("-99999."); pInterfaceWidget->GetEditBottomDepth()->setText("-99999."); QString temp_topDepth = (welllogRound->GetTopDepth() > -9999) ? QString::number(welllogRound->GetTopDepth(),'f',6) : "-99999."; QString temp_botDepth = (welllogRound->GetBottomDepth() > -9999) ? QString::number(welllogRound->GetBottomDepth(),'f',6) : "-99999."; pInterfaceWidget->GetEditFileSDepth()->setText(temp_topDepth); pInterfaceWidget->GetEditFileEDepth()->setText(temp_botDepth); QDateTime time; if (welllogRound->GetDate()=="") { time=QDateTime::currentDateTime(); } else { time =QDateTime::fromString(QString::fromStdString(welllogRound->GetDate()), "yyyy-MM-dd"); } pInterfaceWidget->GerDateEdit()->setDateTime (time); pInterfaceWidget ->GerDateEdit()->setDisplayFormat("yyyy年 MM月 dd日"); ComboxFromConfigFile(pInterfaceWidget->GetSerialComboBox(),"serial"); ComboxFromConfigFile(pInterfaceWidget->GetItemComboBox(),"wellItem"); ComboxFromConfigFile(pInterfaceWidget->GetMudTypeComboBox(),"mudType"); } // CObjWell * ImportDataDialog::GetWellBaseName( IConvertor *pConvertor,const std::string strWellName ) // { // CObjWell *pWell(NULL); // { // QString strName=QString::fromStdString(strWellName); // if (!GetProject()) // { // if(!CProjectCommand::NewProject(true)) return NULL; // } // if( GetProject() ) // { // pWell = dynamic_cast( GetProject()->GetObjectByName(strName)); // if (pWell) // { // //pWell->SetDBWell(pConvertor->GetWellInfo()); // m_ExistSameWellName=true; // } // } // if( !pWell ) // { // pWell = new CObjWell(); // pWell->SetName( strName ); // pWell->SetDBWell(*(pConvertor->GetWellInfo())); // if( GetProject() ) // { // GetProject()->GetWellsFolder(true)->AddChild( pWell ); // } // } // } // return pWell; // } void ImportDataDialog::UpdateWell(InterfaceWidget *pInterfaceWidget,IConvertor *pConvertor) { if (!pInterfaceWidget||!pConvertor) return ; //井代码接口暂时没有 // pai::ios::welllog::Well &wellInfo=pConvertor->GetWellInfo(); InterIConvertor*pIC=dynamic_cast(pConvertor); MyWelllogRound* wellInfo=pConvertor->GetWellLogRoundInfo(); QString wellname=pInterfaceWidget->GetWellNameLineEdit()->text(); wellname=wellname.toUpper(); if(pIC) strcpy(pIC->FILE_MESSAGE.WellName,wellname.toStdString().c_str()); wellInfo->SetWellName(wellname.toStdString()); wellInfo->SetName(wellname.toStdString()); // wellInfo->SetCompanyName((pInterfaceWidget->GetWellCompanyNameLineEdit()->text()).toStdString()); wellInfo->SetAreaName((pInterfaceWidget->GetWellAreaNameLineEdit()->text()).toStdString()); // wellInfo->SetWellCode((pInterfaceWidget->GetWellCodeLineEdit()->text()).toStdString()); wellInfo->SetCWMethod((pInterfaceWidget->GetCWMethodLineEdit()->text()).toStdString()); wellInfo->SetXCode((pInterfaceWidget->GetXCodeLineEdit()->text()).toFloat()); wellInfo->SetYCode((pInterfaceWidget->GetYCodeLineEdit()->text()).toFloat()); wellInfo->SetAsl((pInterfaceWidget->GetAslLineEdit()->text()).toFloat()); wellInfo->SetBsl((pInterfaceWidget->GetBslLineEdit()->text()).toFloat()); wellInfo->SetBit1Prog((pInterfaceWidget->GetBit1ProgLineEdit()->text()).toStdString()); wellInfo->SetBit2Prog((pInterfaceWidget->GetBit2ProgLineEdit()->text()).toStdString()); wellInfo->SetBit3Prog((pInterfaceWidget->GetBit3ProgLineEdit()->text()).toStdString()); wellInfo->SetBit4Prog((pInterfaceWidget->GetBit4ProgLineEdit()->text()).toStdString()); wellInfo->SetBit5Prog((pInterfaceWidget->GetBit5ProgLineEdit()->text()).toStdString()); wellInfo->SetCas1Prog((pInterfaceWidget->GetCas1ProgLineEdit()->text()).toStdString()); wellInfo->SetCas2Prog((pInterfaceWidget->GetCas2ProgLineEdit()->text()).toStdString()); wellInfo->SetCas3Prog((pInterfaceWidget->GetCas3ProgLineEdit()->text()).toStdString()); wellInfo->SetCas4Prog((pInterfaceWidget->GetCas4ProgLineEdit()->text()).toStdString()); wellInfo->SetCas5Prog((pInterfaceWidget->GetCas5ProgLineEdit()->text()).toStdString()); wellInfo->SetCas1Shot((pInterfaceWidget->GetCas1ShotLineEdit()->text()).toFloat()); wellInfo->SetCas2Shot((pInterfaceWidget->GetCas2ShotLineEdit()->text()).toFloat()); wellInfo->SetSC1SDep((pInterfaceWidget->GetSC1SDepLineEdit()->text()).toFloat()); wellInfo->SetSC1EDep((pInterfaceWidget->GetSC1EDepLineEdit()->text()).toFloat()); wellInfo->SetSC2SDep((pInterfaceWidget->GetSC2SDepLineEdit()->text()).toFloat()); wellInfo->SetSC2EDep((pInterfaceWidget->GetSC2EDepLineEdit()->text()).toFloat()); wellInfo->SetSDrillDate(pInterfaceWidget->GerSDrillDateEdit()->date().toString("yyyy年-MM月-dd日").toStdString()); wellInfo->SetEDrillDate(pInterfaceWidget->GerEDrillDateEdit()->date().toString("yyyy年-MM月-dd日").toStdString()); wellInfo->SetCompleteDate(pInterfaceWidget->GerCompleteDateEdit()->date().toString("yyyy年-MM月-dd日").toStdString()); wellInfo->SetWellType((pInterfaceWidget->GetWellTypeComboBox()->currentText()).toInt()); } void ImportDataDialog::UpdateWellLogRound(InterfaceWidget *pInterfaceWidget,IConvertor *pConvertor) { if (!pInterfaceWidget||!pConvertor) return ; //剖面接口暂时没有 MyWelllogRound *wellRound=pConvertor->GetWellLogRoundInfo(); wellRound->SetCompanyName((pInterfaceWidget->GetCompanyNameLineEdit()->text()).toStdString()); wellRound->SetTeam((pInterfaceWidget->GetTeamLineEdit()->text()).toStdString()); wellRound->SetOperator((pInterfaceWidget->GetOperatorLineEdit()->text()).toStdString()); wellRound->SetMudViscosity((pInterfaceWidget->GetMudViscosityLineEdit()->text()).toFloat()); wellRound->SetRemark(pInterfaceWidget->GetRemarkTextEdit()->toPlainText().toStdString()); wellRound->SetWaterLoss((pInterfaceWidget->GetWaterLossLineEdit()->text()).toFloat()); wellRound->SetDensity((pInterfaceWidget->GetDensityLineEdit()->text()).toFloat()); wellRound->SetResi((pInterfaceWidget->GetResiLineEdit()->text()).toFloat()); wellRound->SetTemp((pInterfaceWidget->GetTempLineEdit()->text()).toFloat()); wellRound->SetINTLog((pInterfaceWidget->GetINTLogLineEdit()->text()).toStdString()); wellRound->SetTempBot((pInterfaceWidget->GetTempBotLineEdit()->text()).toFloat()); wellRound->SetNITINT((pInterfaceWidget->GetNITINTLineEdit()->text()).toStdString()); wellRound->SetIntProg((pInterfaceWidget->GetIntProgLineEdit()->text()).toStdString()); wellRound->SetInteDress((pInterfaceWidget->GetInteDressLineEdit()->text()).toStdString()); wellRound->SetAudit((pInterfaceWidget->GetAuditLineEdit()->text()).toStdString()); wellRound->SetMudType((pInterfaceWidget->GetMudTypeComboBox()->currentText()).toStdString()); wellRound->SetItem((pInterfaceWidget->GetItemComboBox()->currentText()).toStdString()); wellRound->SetSerial((pInterfaceWidget->GetSerialComboBox()->currentText()).toStdString()); wellRound->SetDate(pInterfaceWidget->GerDateEdit()->date().toString("yyyy年-MM月-dd日").toStdString()); } void ImportDataDialog::AcceptOK() { //whp del 2020.3.16 for 当井名不合理时,提示用户,然后回到解编界面,让用户修改,修改完后,再加载 //disconnect(m_pImportDataUI->pushButton_2, SIGNAL(clicked()), 0,0); m_ExistSameWellRoundName=false;//TODO 多模块可同时解析一个文件时,需要处理 InterfaceWidget *pCurrentInterfaceWidget(NULL); std::map< QWidget*,InterfaceWidget* >::iterator itor = m_TabInterWidget.find( m_pImportDataUI->tabWidget->currentWidget() ); int index=m_pImportDataUI->tabWidget->currentIndex(); if( itor != m_TabInterWidget.end() ) { pCurrentInterfaceWidget=itor->second; } if (!pCurrentInterfaceWidget) return ; //whp add 2020.3.16 QString wellname=pCurrentInterfaceWidget->GetWellNameLineEdit()->text(); if(wellname=="") { QMessageBox::warning(NULL,"提示","井名不能为空"); return ; } if(!IsValidWellName(wellname)) { QMessageBox::warning(NULL,"提示","'"+wellname+"'不符合井名命名规则");return ; } // //std::map >::iterator it=m_ConvertorWellLog.find(m_vConvertorVector[index]); //更新井次和井信息 UpdateWell(pCurrentInterfaceWidget,m_vConvertorVector[index]); UpdateWellLogRound(pCurrentInterfaceWidget,m_vConvertorVector[index]); std::string wellLogRoundName=m_vConvertorVector[index]->GetWellLogRoundInfo()->GetWellName(); if(/*!wellName.length()||*/!wellLogRoundName.length()) { QMessageBox::about(NULL,"提示","井次名和井名不可为空!"); return ; } WellCurve wc=((InterIConvertor *)m_vConvertorVector[index])->GetWellCurves(); if(SelectAndDeleteWellLog(wc.Curve_Num,pCurrentInterfaceWidget,m_vConvertorVector[index]->m_ColumnCount,m_vConvertorVector[index])) return; //释放未被选取的解编器内存 QDialog::accept(); // ::GetObjectEvent().OnRefreshData(wellname,""); } //whp add 2019.10.12 void ImportDataDialog::SelAll() { InterfaceWidget *pCurrentInterfaceWidget(NULL); std::map< QWidget*,InterfaceWidget* >::iterator itor = m_TabInterWidget.find( m_pImportDataUI->tabWidget->currentWidget() ); int index=m_pImportDataUI->tabWidget->currentIndex(); if( itor != m_TabInterWidget.end() ) { pCurrentInterfaceWidget=itor->second; } if (!pCurrentInterfaceWidget) return ; QTableWidget *tableWidget=pCurrentInterfaceWidget->GetDataSelectAreaWidget(); int iRow=tableWidget->rowCount(); for (int i=0;iitem(i,0)->setCheckState(Qt::Checked); } } void ImportDataDialog::NotSelAll() { InterfaceWidget *pCurrentInterfaceWidget(NULL); std::map< QWidget*,InterfaceWidget* >::iterator itor = m_TabInterWidget.find( m_pImportDataUI->tabWidget->currentWidget() ); int index=m_pImportDataUI->tabWidget->currentIndex(); if( itor != m_TabInterWidget.end() ) { pCurrentInterfaceWidget=itor->second; } if (!pCurrentInterfaceWidget) return ; QTableWidget *tableWidget=pCurrentInterfaceWidget->GetDataSelectAreaWidget(); int iRow=tableWidget->rowCount(); for (int i=0;iitem(i,0)->setCheckState(Qt::Unchecked); } } void ImportDataDialog::ReverseSel() { InterfaceWidget *pCurrentInterfaceWidget(NULL); std::map< QWidget*,InterfaceWidget* >::iterator itor = m_TabInterWidget.find( m_pImportDataUI->tabWidget->currentWidget() ); int index=m_pImportDataUI->tabWidget->currentIndex(); if( itor != m_TabInterWidget.end() ) { pCurrentInterfaceWidget=itor->second; } if (!pCurrentInterfaceWidget) return ; QTableWidget *tableWidget=pCurrentInterfaceWidget->GetDataSelectAreaWidget(); int iRow=tableWidget->rowCount(); for (int i=0;iitem(i,0)->checkState(); if (eState==Qt::Checked)tableWidget->item(i,0)->setCheckState(Qt::Unchecked); else tableWidget->item(i,0)->setCheckState(Qt::Checked); } } void ImportDataDialog::DisplaySelectAreaData( InterfaceWidget *pInterface,const QStringList fileHead,IConvertor *pConvertor) { int iRow(0),iOrder(0); vector CurveNames=((InterIConvertor*)pConvertor)->GetCurveNames(); vector CurveUnits=((InterIConvertor*)pConvertor)->GetCurveUnits(); WellCurve WellCurves= ((InterIConvertor*)pConvertor)->GetWellCurves(); //pConvertor->GetWellLogList(m_FilePath); iRow=WellCurves.Curve_Num;//m_ConvertorWellLog[pConvertor].size(); pInterface->GetDataSelectAreaWidget()->setColumnCount(fileHead.size()); pInterface->GetDataSelectAreaWidget()->setRowCount(iRow); for (int i=0;iGetDataSelectAreaWidget()->setColumnWidth(i,150); if(i==1) pInterface->GetDataSelectAreaWidget()->setColumnWidth(i,80); if(i==2) pInterface->GetDataSelectAreaWidget()->setColumnWidth(i,80); if(i==3) pInterface->GetDataSelectAreaWidget()->setColumnWidth(i,150); if (i==4) { pInterface->GetDataSelectAreaWidget()->setColumnWidth(i,80); } pInterface->GetDataSelectAreaWidget()->horizontalHeader()->setStretchLastSection(true); } //pInterface->m_pInterfaceUI->widget->setFixedWidth(560); pInterface->GetDataSelectAreaWidget()->setHorizontalHeaderLabels(fileHead); QHeaderView* headerView = pInterface->GetDataSelectAreaWidget()->verticalHeader(); //headerView->setHidden(true); pInterface->GetDataSelectAreaWidget()->setAlternatingRowColors(true); pInterface->GetDataSelectAreaWidget()->setSelectionBehavior(QAbstractItemView::SelectRows); for (int i=0;isetCheckState(Qt::Checked); //加入复选框 head->setFlags(head->flags() ^ Qt::ItemIsEditable); head->setText(CurveNames[i]);//曲线名 pInterface->GetDataSelectAreaWidget()->setItem(i,0,head); //插入该Item QString unit=QString::fromLocal8Bit(CurveUnits[i]); pInterface->GetDataSelectAreaWidget()->setItem(i,1,new QTableWidgetItem(unit));//导入曲线单位 pInterface->GetDataSelectAreaWidget()->setItem(i,2,new QTableWidgetItem(""));//family));// pInterface->GetDataSelectAreaWidget()->setItem(i,3,new QTableWidgetItem(CurveNames[i]));//导入曲线名 pInterface->GetDataSelectAreaWidget()->setItem(i,4,new QTableWidgetItem(unit));//导入曲线单位 //whp add 2019.8.1 for 设置输入曲线单位列为只读 auto rFlags = pInterface->GetDataSelectAreaWidget()->item(i,1)->flags(); pInterface->GetDataSelectAreaWidget()->item(i,1)->setFlags(rFlags & (~Qt::ItemIsEditable)); iOrder++; } } bool ImportDataDialog::IsHaveSameCurve(int NumLog,vector &OutCurveNo,vector &OutCurve) { QString str,mes=""; int SameNameCurveNum=0; QStringList ExistName; for(int i=0;i=0)continue; int no=0; str="\r\n第"+QString::number(i+1)+"条和第"; for(int j=i+1;j=0)) { if(no>0)str+="、"; str+=QString::number(j+1); no++; } } if(no==0)continue; ExistName.append(QString(QLatin1String(OutCurve[i]))); SameNameCurveNum++; if(SameNameCurveNum<30) mes+=str+"条输出曲线名字为"+QString(QLatin1String(OutCurve[i])); else if(SameNameCurveNum==30) mes+="\n重名>=30条..."; } if(SameNameCurveNum>0) { /*str=CString("您所选择的解编曲线中存在下列同名曲线,请修改同名曲线,然后再解编\r\n\r\n")+mes; AfxMessageBox(str); return 1;*/ QString inf="您所选择的解编曲线中存在下列同名曲线:\r\n\r\n"+mes+"\r\n\r\n是否对同名曲线进行解编?"; QMessageBox box(QMessageBox::Warning,"提示",mes); box.setStandardButtons (QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel); box.setButtonText (QMessageBox::Yes,QString("自动重命名")); box.setButtonText (QMessageBox::No,QString("跳过同名曲线")); box.setButtonText (QMessageBox::Cancel,QString("返回、修改")); int ret=box.exec(); if(ret==QMessageBox::Cancel)return 1; QStringList OutCurveList; for(int i=0;i=0) { int no=1; for(int j=i+1;j& OutCurveNo,vector& OutCurve) // { //1-有输出曲线,需要继续输出,0-经跳过功能后,没有曲线要输出了,-1退回原界面 // CMemRdWt *logio=new CMemRdWt(); // if(!logio->Open(filename.toStdString().c_str(),CSlfIO::modeRead)) // { // delete logio; // return 1; // } // CString str,mes=""; // vector ExistCurveNo; // vector ExistCurve; // int ExistCurveNum=0; // for(int i=0;iFindObjectName(OutCurve[i],-1,-1,OBJECT_NORMAL); // if(logio->FindObjectName(OutCurve[i],-1,-1,OBJECT_NORMAL)<0)continue; // ExistCurve.push_back(OutCurve[i]); // ExistCurveNo.push_back(i); // } // if(ExistCurve.size()==0) // { // delete logio; // return 1; // } // TiShiDialog *dlg=new TiShiDialog(NULL); // dlg->init(ExistCurve); // if(dlg->exec()==Accepted) // { // if(dlg->flag==0)//跳过 // { // for(int i=0;iflag==1)//替换 // { // for(int i=0;iDiscardObject(ExistCurve[i]); // } // } // else if(dlg->flag==3)//另存 // { // QStringList OutCurveList; // for(int i=0;iGetObjectCount();i++) // { // char name[64]; // if(logio->GetObjectStatus(i)!=OBJECT_NORMAL)continue; // logio->GetObjectName(i,name); // OutCurveList.append(QString(name)); // } // for(int i=0;itoStdString()->c_str()); // delete temp; // } // } // delete logio; // delete dlg; // } // else // { // delete logio; // delete dlg; // return -1; // } // for(int i=0;i=0) return 1; // } // return 0; // } bool ImportDataDialog::SelectAndDeleteWellLog(int iRow,InterfaceWidget *pCurrentInterfaceWidget,int ColumnCount,IConvertor *pConvertor) { InterIConvertor*tpConvertor=dynamic_cast(pConvertor); if(!tpConvertor) return true; QString outputfilename=GenerateSlfFileName(pCurrentInterfaceWidget); if(outputfilename=="") { QMessageBox::about(NULL,"提示","请先输入井名!"); return 1; } vector OutCurveNo; vector OutCurve; vector strChineseName; vector strUnit; QLineEdit *edittop=pCurrentInterfaceWidget->GetEditTopDepth(); QLineEdit *editbottom=pCurrentInterfaceWidget->GetEditBottomDepth(); QTableWidget *tableWidget=pCurrentInterfaceWidget->GetDataSelectAreaWidget(); iRow=tableWidget->rowCount(); for (int i=0;iitem(i,0)) { char *curvename = new char[10]; strcpy(curvename, "ERROR"); OutCurve.push_back(curvename); strChineseName.push_back(curvename); char *curveunit = new char[10]; strcpy(curveunit,""); strUnit.push_back(curveunit); OutCurveNo.push_back(-1); continue; } eState=tableWidget->item(i,0)->checkState(); if (eState==Qt::Checked) { //修改曲线单位 OutCurveNo.push_back(i); } else OutCurveNo.push_back(-1); QString tstr=tableWidget->item(i,3)->text(); char *curvename = new char[strlen(tstr.toStdString().c_str())+10]; strcpy(curvename,tstr.toStdString().c_str()); OutCurve.push_back(curvename); strChineseName.push_back(curvename); tstr=tableWidget->item(i,4)->text(); char *curveunit = new char[strlen(tstr.toStdString().c_str())+10]; strcpy(curveunit,tstr.toStdString().c_str()); strUnit.push_back(curveunit); } if(tpConvertor->m_TableName.isEmpty()&&IsHaveSameCurve(iRow,OutCurveNo,OutCurve)){ for(int i=0;im_TableName.isEmpty()) { //HaveOut=CheckExistCurve(outputfilename,iRow,OutCurveNo,OutCurve); } else { vector OutCurveNo; vector OutCurve; OutCurveNo.push_back(0); char *buf=new char[strlen(tpConvertor->m_TableName.toStdString().c_str())+1]; strcpy(buf,tpConvertor->m_TableName.toStdString().c_str()); OutCurve.push_back(buf); // HaveOut=CheckExistCurve(outputfilename,1,OutCurveNo,OutCurve); delete buf; } if(HaveOut==0){ for(int i=0;iGetXCodeLineEdit(); QLineEdit * yEdit=pCurrentInterfaceWidget->GetYCodeLineEdit(); int l=strlen(outfile)+1; strcpy(&outfile[l],xEdit->text().toStdString().c_str());//x坐标 l+=strlen(&outfile[l])+1; strcpy(&outfile[l],yEdit->text().toStdString().c_str());//y坐标 QString top=edittop->text(); l+=strlen(&outfile[l])+1; strcpy(&outfile[l],top.toStdString().c_str());//y坐标 QString bottom=editbottom->text(); l+=strlen(&outfile[l])+1; strcpy(&outfile[l],bottom.toStdString().c_str());//y坐标 //TODO l+=strlen(&outfile[l])+1; *(int*)&outfile[l]=iRow; if(((InterIConvertor*)(pCurrentInterfaceWidget->m_pConvertor))->Transfer(logfilename,outfile,&OutCurveNo[0],&OutCurve[0],&strChineseName[0],&strUnit[0],iRow)) { MyWelllogRound *wellRound=pCurrentInterfaceWidget->m_pConvertor->GetWellLogRoundInfo(); if(wellRound) { ((InterIConvertor*)(pCurrentInterfaceWidget->m_pConvertor))->InitWellInfo(outfile); wellRound->SaveMeesge(outfile); } //CDataImport::ChangetoSlf(outfile,NULL); } for(int i=0;iGetWellNameLineEdit()->text(); if(wellname.isEmpty()) return ""; wellname=wellname.toUpper(); QString filename=pCurrentInterfaceWidget->GetWellRoundNameLineEdit()->text(); if(filename.isEmpty()) filename=wellname; filename=filename.toUpper(); // //CObjProject *pPrj=::GetProject(); // if(!m_CurrentWellRoundName.isEmpty()) { // int ret=QMessageBox::No; // if(m_CurrentWellRoundName.compare(filename,Qt::CaseInsensitive)!=0) // { // ret=QMessageBox::warning(NULL,"提示","输入文件名与选中的井次名不一致,您确信要创建新井名?",QMessageBox::Yes,QMessageBox::No); // } // if(ret==QMessageBox::No) { // CObjWelllogRound *pWR=dynamic_cast(pPrj->GetObjectByName(m_CurrentWellRoundName,GetClassID_WellLogRound())); // if(pWR) // { // QString welln=pWR->GetSlfFileName(); // if(!welln.isEmpty()) return welln; // } // } // } // PaiObject *pObj=pPrj->GetObjectByName(wellname,GetClassID_Well()); // CObjWell *pWell=dynamic_cast(pObj); // if(pWell) { // QString slf=pWell->GetWellMessageFileName(); // QString welln,path; // GetWellNameAndPath(slf,welln,path); // welln=path+"\\"+filename; // welln+=".slf"; // filename=welln; // return welln; // } /* //Type(GetClassID_WellsFolder()); QList childs; pObj->GetChildren(childs); int wellnum=childs.count(); foreach(PaiObject *pChild,childs) { CObjWell *pWell=dynamic_cast(pChild); if(pWell) { QString well=pWell->GetName().toUpper(); if(well==wellname) { QList childsRound; pChild->GetChildren(childsRound); foreach(PaiObject *pChildRound,childsRound) { CObjWelllogRound *pWellRound=dynamic_cast(pChildRound); if(pWellRound) { QString file=pWellRound->GetName().toUpper(); if(file==filename) { QString outname=pWellRound->GetSlfFileName(); return outname; } } } } } } #pragma endregion 检查该井名文件名是否存在 */ // QString strWellName=""; // CObjProject *pProject = ::GetProject(); // if(pProject != NULL) // { // strWellName = pProject->GetName(); // } // QString dir=::GetLogdataPath(); // QDir w; // if(!strWellName.isEmpty()) { // dir=dir+strWellName; // w.mkdir(dir); // dir+=QDir::separator(); // } // dir+="#"+wellname; // bool a=w.mkdir(dir); // QFileInfo temDir(filename); // QString tempWellName=temDir.completeBaseName(); // QString ss=dir+QDir::separator()+tempWellName+".slf"; // return ss; // "D:/LogPlus/LogData/例子2/#JPH-307-1/JPH-307-1.slf"; // QString wellSlfFile = "D:/LogPlus/LogData/"; // wellSlfFile +=m_projectname + "/"+"#"+wellname + "/" + filename +".slf"; QString wellSlfFile = GetLogdataPath() +m_projectname + "/"+"#"+wellname + "/" + filename +".slf"; return wellSlfFile; } END_OSGGRAPHICS_NAMESPACE;