logplus/logPlus/DataImport.cpp

2099 lines
84 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

///////////////////////
///
/// wangwei change part:ImportWellTrajectorys() for add read wis、slftable、dev
#pragma warning( push ,0)
#include <QDialog.h>
#include <string.h>
#include <vector>
#include <QInputDialog>
// #include "BaseFun.h"
#include <iostream>
#include "MemRdWt.h"
#include <QtCore>
// #include "ObjGeoLayerData.h"
#include "DepthProgress.h"
#include <QLibrary>
// #include "ObjectEvent.h"
// #include "VecSceneManager.h"
#include "ConvertorManager.h"
// #include "ObjDiscreteWellLog.h"
#include "DataImport.h"
#include "geometryutils.h"
// #include "CoreImageConfigDialog.h"
#include "ObjWell.h"
#include "ObjWelllog.h"
// #include "ObjWellTrajectory.h"
// #include "ObjBitmap.h"
// #include "ObjCrossplot.h"
// #include "VecDisplayObjectCommand.h"
// #include "ObjProject.h"
#include "ConvertorManager.h"
#include "IConvertor.h"
#include "ImportdataDialog.h"
// #include "ObjWellLogTrack.h"
#include "ObjWelllogRound.h"
// #include "ObjWellTrack.h"
#include "ConsoleOutputWidget.h"
// #include "ObjGeostratums.h"
#include "ObjWelllogWavefile.h"
// #include "ObjWelllogBIN.h"
#include "ObjWelllogINP.h"
// #include "ObjWelllogFMT.h"
// #include "ObjWelllogTDT.h"
#include "ObjWelllogTABLE.h"
#include "InterIConvertor.h"
#include <QTextStream>//2020.2.20 whp add
// #include "DataTree.h"
// #include "VecWindowCommand.h"
// #include "cdialog.h"//whp add 2020.3.17
#include "tishidialog.h"
// #include "Log.h"
#pragma warning( pop )
// void OSGFRAMEWORK_EXPORT AppendConsole(pai::log::Priority priority,const QString &output);
// BEGIN_OSGGRAPHICS_NAMESPACE;
extern QString g_prjname;
int CDataImport::flag1=-1;
int CDataImport::m_flag=-1;
int CDataImport::flag_check=0;
bool CDataImport::m_bImportByFolder = false;
void CreateWellFile(CLogIO *logio,Slf_FILE_MESSAGE &mssage,QString wellFile,CObjWell *pWell)
{
if(logio) {
CLogIO * logiowell=new CLogIO();
Slf_FILE_MESSAGE ms=mssage;
strcpy(ms.Item,"井基本信息");
logiowell->Open(wellFile.toStdString().c_str(),CSlfIO::modeWrite);
logiowell->SetFileMessage(ms);
QStringList azims=GetSimilarCurves("AZIM");
int iAZIM=-1;
QString AZIM;
foreach(QString cname,azims)
{
iAZIM=logio->FindObjectName((char *)cname.toStdString().c_str());
if(iAZIM>-1) {
AZIM=cname;
break;
}
}
int iDev=-1;
QStringList devis=GetSimilarCurves("DEVI");
QString DEV;
foreach(QString cname,devis)
{
iDev=logio->FindObjectName((char *)cname.toStdString().c_str());
if(iDev>-1) {
DEV=cname;
break;
}
}
// if(logio->FindObjectIndex("井基本信息")>-1) {
// logiowell->CopyFromFile((CSlfIO &)(*logio),"井基本信息");
// }
if(iAZIM>-1)logiowell->CopyFromFile((CSlfIO &)(*logio),(char *)AZIM.toStdString().c_str());
if(iDev>-1)logiowell->CopyFromFile((CSlfIO &)(*logio),(char *)DEV.toStdString().c_str());
delete logiowell;
if(iDev>-1&&iAZIM>-1) {
pWell->ComputeTrajectory(pWell,wellFile);
}
}
}
// CObjWell * CDataImport::GetWellByName( QString strWellName )
// {
// //得到或创建well
// CObjWell *pWell = NULL;
// if( GetProject() )
// {
// PaiObject *pP=GetProject()->GetObjectByName( strWellName,GetClassID_Well());
// pWell = dynamic_cast<CObjWell *>(pP);
// }
// if( !pWell )
// {
// pWell = new CObjWell();
// pWell->SetName( strWellName );
// if( GetProject() )
// {
// GetProject()->GetWellsFolder(true)->AddChild( pWell );
// }
// }
// return pWell;
// }
// void CDataImport::AddWellNode(CVecSceneManager *pSceneManager,CObjWell *pWell,CObjWell *pWellInsertPos )
// {
// if( !pWell ) return;
// QUuid ID = pWellInsertPos ? pWellInsertPos->GetID(): QUuid();
// pSceneManager->AddObject( pWell,&ID );
// QList<PaiObject*>listChild;
// pWell->GetChildren( listChild);
// for( long i = 0 ; i < listChild.size();++i )
// {
// AddWellLogNode( pSceneManager,dynamic_cast<CObjWellLog*>( listChild[i] ),NULL );
// }
// }
// void CDataImport::AddWellLogNode(CVecSceneManager * pSceneManager,CObjWellLog *pWellLog,CObjWellLog *pWellLogInsertPos )
// {
// QUuid ID = pWellLogInsertPos ? pWellLogInsertPos->GetID() : QUuid();
// pSceneManager->AddObject( pWellLog,&ID );
// }
int CDataImport::chakan(QList<CObjWell *> &wells,QString path,QStringList &wellfs,int &num,bool GetNum,DiDepthProgress *DepthProgress,char *pSuffix)
{
QDir dir(path);
foreach(QFileInfo mfi ,dir.entryInfoList())
{
if(mfi.isFile())
{
if(pSuffix) {
if(mfi.fileName().lastIndexOf(pSuffix,-1,Qt::CaseInsensitive)==-1) continue;
}
else {
if(mfi.fileName().endsWith(".well",Qt::CaseInsensitive)) continue;
}
num++;
if(IsInvalidString(mfi.fileName())) {
wellfs.append(mfi.absoluteFilePath());
continue;
}
if(GetNum) continue;
QString aa= mfi.completeBaseName()+"导入中";
DepthProgress->SetShowName(aa.toStdString().c_str(),0);
DepthProgress->SetDepth(num,0);
CObjWell *pWell=ChangetoSlf(mfi.absoluteFilePath(),DepthProgress);
if(!pSuffix) {
if(pWell) wells.push_back(pWell);
else wellfs.append(mfi.absoluteFilePath());
}
}else
{
if(mfi.fileName()=="." || mfi.fileName() == "..")continue;
chakan(wells,mfi.absoluteFilePath(),wellfs,num,GetNum,DepthProgress,pSuffix);
}
}
return num;
}
QList<CObjWell *> CDataImport::ImportWellTrajectorys(bool IsDir)
{
CDataImport::flag_check=0;
CDataImport::flag1=-1;
CDataImport::m_flag=-1;
QList<CObjWell *> wells;
QString path;
if(IsDir)
{
static QString path1=::GetDataPath();
path1=QFileDialog::getExistingDirectory(NULL,"选择目录",path1,QFileDialog::ShowDirsOnly);
if(path1.isEmpty()) return wells;
path=path1;
}
else {
ConvertorManager::GetInstance().LoadAllConvertorPlugin();
ConvertorManager &pManager=ConvertorManager::GetInstance();
pManager.all=0;
QVector<QString>vSuffix=pManager.GetSupportFileExtensions();
QString fileSuffix("数据文件(");
for (int i=0;i<vSuffix.size();i++)
{
QString sSuffix="*.";
sSuffix.append(vSuffix[i]);
fileSuffix.append(sSuffix);
fileSuffix.append(" ");
}
QString sSuffix="*.";
sSuffix.append("slf");
fileSuffix.append(sSuffix);
fileSuffix.append(" ");
sSuffix="*.";
sSuffix.append("well");
fileSuffix.append(sSuffix);
fileSuffix.append(" ");
fileSuffix.append(")");
QStringList listFiles;
listFiles=GetFileNames("数据目录",fileSuffix);
if(listFiles.size()<1) return wells;
path=listFiles[0];
}
int num=0;
QStringList wellfs;
wells=ImportWells(path,wellfs,&num);
// CObjProject *pPrj=::GetProject();
// if(pPrj) {
// PaiObject *pObj=pPrj->GetObjectByType(GetClassID_WellsFolder());
// if(pObj) {
// CBaseObject * pBaseObject = dynamic_cast<CBaseObject*>(pObj);
// if(pBaseObject) {
// CDataTree *pDatatree=(CDataTree *)::GetProject()->m_pDataTree;
// if(pDatatree) {
// QTreeWidgetItem* pItem=pDatatree->GetTreeItem(pBaseObject);
// pDatatree->ClickObjectCommand(pItem);
// }
// pBaseObject->SetCheckState(Qt::Checked);
// CVecWindow *pWindow=CVecWindowCommand::GetCurrentWindow();
// CVecDisplayObjectCommand::ClickObjectCommand( pBaseObject->GetPaiObject(),pWindow);
// }
// }
// }
QStringList lpsFile;
if(wellfs.size())
{
for(int nIndex =0;nIndex<wellfs.size();++nIndex)//for(int n=0;n<wellfs.size();n++)
{
QString us=wellfs[nIndex];//rIter;
QFileInfo currentfile(us.toUpper());
//us=currentfile.suffix();
if(currentfile.suffix()=="IRD"||currentfile.suffix()=="PLT"||
currentfile.suffix()=="I1D"||currentfile.suffix()=="D1D"||
currentfile.suffix()=="I2D"||currentfile.suffix()=="D2D")
{
lpsFile.append(us);//wellfs[n]);
wellfs.removeAt(nIndex);
--nIndex;
}
}
}
if(wellfs.size())
{
// //whp change 2020.3.17
// CDialog* m_dialog=new CDialog();
// m_dialog->setMessage("成功导入"+QString::number(wells.size())+"个井次文件,"+QString::number(wellfs.size())+"个文件无法识别:\r\n"+wellfs.join("\r\n"));
// m_dialog->setTitle("提示");
// m_dialog->exec();
// delete m_dialog;
}
else {
// AfxMessageBox(QString::number(num)+"个文件全部导入成功!");
QMessageBox::information(NULL, "提示",QString::number(num)+"个文件全部导入成功!");
}
QList<CObjWell *> wells1;
return wells1;
}
QList<CObjWell *> CDataImport::ImportWells(QString path,QStringList &wellfs,int *pNum,bool IsTran)
{
char szTemp[64];
strcpy(szTemp, ".well");
ImportWells(path,wellfs,szTemp,NULL,IsTran);
wellfs.clear();
return ImportWells(path,wellfs,(char*)NULL,pNum,IsTran);
}
QString GetWellFileFromDir(QString path,QString &WellName,char *pSuffix)
{
QDir dir(path);
foreach(QFileInfo mfi ,dir.entryInfoList())
{
if(mfi.isFile())
{
QString tem=mfi.absoluteFilePath();
if(tem.endsWith(pSuffix,Qt::CaseInsensitive)) {
CLogIO tf;
if(tf.Open(tem.toStdString().c_str(),CSlfIO::OpenFlags::modeRead)) {
Slf_FILE_MESSAGE mess;
tf.GetFileMessage(mess);
WellName=mess.WellName;
return tem;
}
}
}
else
{
if(mfi.fileName()=="." || mfi.fileName() == "..")continue;
QString tt=GetWellFileFromDir(mfi.absoluteFilePath(),WellName,pSuffix);
if(tt.isEmpty()) return tt;
}
}
return "";
}
QString GetWellFileFromCurrentDir(QString path,QString WellName,char *pSuffix)
{
QDir dir(path);
foreach(QFileInfo mfi ,dir.entryInfoList())
{
if(mfi.isFile())
{
QString tem=mfi.absoluteFilePath();
if(tem.endsWith(pSuffix,Qt::CaseInsensitive)) {
return tem;
}
}
else
{
if(mfi.fileName()=="." || mfi.fileName() == "..")continue;
QString tt=GetWellFileFromCurrentDir(mfi.absoluteFilePath(),WellName,pSuffix);
if(tt.isEmpty()) return tt;
}
}
return "";
}
QList<CObjWell *> CDataImport::ImportWells(QString path,QStringList &wellfs,char *pSuffix,int *pNum,bool IsTran)
{
//////////////////////////
// FIRST is dir
QList<CObjWell *> wells;
if(path.isEmpty()) return wells;
int num=0;
QStringList listFiles;
QFileInfo mfi(path);
if(!mfi.isDir()) {
if(!mfi.isFile()) return wells;
listFiles.append(path);
if(pSuffix) {
CObjWell *pWell=NULL;
foreach(QString filename,listFiles)
{
QString WellName;
if(filename.endsWith(".slf",Qt::CaseInsensitive))
{
QString wellname1,path1;
GetWellNameAndPath(filename,wellname1,path1);
QString path2=GetLogdataPath();
if(path1.indexOf(path2)<0) {
int a=1;
}
CLogIO tem;
if(tem.Open(filename.toStdString().c_str(),CSlfIO::OpenFlags::modeRead)){
Slf_FILE_MESSAGE mess;
tem.GetFileMessage(mess);
WellName=mess.WellName;
}
}
if(WellName.isEmpty()) continue;
QString wellname,path1;
GetWellNameAndPath(filename,wellname,path1);
QString stem=path1+"\\";
stem+=wellname;
stem+=pSuffix;
QDir ft(stem);
if(ft.exists()) {
pWell=ChangetoSlf(stem,NULL,IsTran);
continue;
}
path1=GetWellFileFromDir(filename,WellName,pSuffix);
if(path1.isEmpty()) continue;
pWell=ChangetoSlf(path1,NULL,IsTran);
}
return wells;
}
num=listFiles.size();
}
else {
QString fileSuffix("数据文件(");
ConvertorManager &pManager=ConvertorManager::GetInstance();
pManager.all=0;
if(pSuffix) {
QString sSuffix="*.";
sSuffix+=pSuffix;
fileSuffix.append(sSuffix);
}
else {
ConvertorManager::GetInstance().LoadAllConvertorPlugin();
QVector<QString>vSuffix=pManager.GetSupportFileExtensions();
for (int i=0;i<vSuffix.size();i++)
{
QString sSuffix="*.";
sSuffix.append(vSuffix[i]);
fileSuffix.append(sSuffix);
fileSuffix.append(" ");
}
QString sSuffix="*.";
sSuffix.append("slf");
fileSuffix.append(sSuffix);
fileSuffix.append(" ");
}
fileSuffix.append(")");
//取当前当前目录内容
QDir dir(path);
dir.setFilter(QDir::Dirs |QDir::NoDotAndDotDot |QDir::Files | QDir::NoSymLinks);
QFileInfoList list = dir.entryInfoList();
int file_count = list.count();
if(file_count <= 0)//判断目录是否为空,空目录返回
{
return wells;
}
//取当前目录内容,符合后缀文件
QStringList string_list;
for(int i=0; i<list.size();i++)
{
QFileInfo file_info = list.at(i);
if(file_info.isDir()) {
QString absolute_file_path = file_info.absoluteFilePath();
if(absolute_file_path.at(absolute_file_path.length()-1)==' ') {
dir.rmdir(absolute_file_path);
continue;
}
listFiles.append(absolute_file_path);
}
else {
QString suffix = file_info.suffix();
suffix=suffix.toLower();
QString absolute_file_path = file_info.absoluteFilePath();
if(fileSuffix.indexOf(suffix,0,Qt::CaseInsensitive)>=0)
{
listFiles.append(absolute_file_path);
}
else {
if(!pSuffix)wellfs.append(absolute_file_path);
}
}
}
if(listFiles.size()<1) return wells;
num=chakan(wells,path,wellfs,num,true,NULL,pSuffix);
if(num<1) return wells;
}
DiDepthProgress DepthProgress;
int progress=0;
QString sname="批量加载数据...";//
if(pSuffix) sname="遍历工区井..";
DepthProgress.CreatProgress(0,num,sname.toStdString().c_str());
foreach( QString wellFile,listFiles )
{
QFileInfo w(wellFile);
if(w.isDir()) {
chakan(wells,wellFile,wellfs,progress,0,&DepthProgress,pSuffix);
}
else {
sname=w.completeBaseName()+"数据导入中";
DepthProgress.SetShowName(sname.toStdString().c_str(),0);
DepthProgress.SetDepth(progress++,0);
CObjWell *pWell=ChangetoSlf(wellFile,&DepthProgress,IsTran);
if(!pSuffix) {
if(pWell) {
wells.push_back(pWell);
}
else wellfs.append(wellFile);
}
}
}
DepthProgress.DelProgress();
if(pNum) *pNum=num;
return wells;
}
void CDataImport::LoadLayers(QStringList &listFiles)
{
// CObjProject *pProj=::GetProject();
// if(!pProj) return;
// if(!listFiles.size())
// {
// QString path=GetLogdataPath();//GetProjectFolder()
// if(pProj) path=path+pProj->GetName();
// QDir dir(path);
// if(!dir.exists())
// {
// return;
// }
// dir.setFilter(QDir::NoDotAndDotDot |QDir::Files | QDir::NoSymLinks);
// QFileInfoList list = dir.entryInfoList();
// int file_count = list.count();
// if(file_count <= 0)
// {
// return;
// }
// QStringList fileSuffix;
// fileSuffix.append("Layer");
// QStringList string_list;
// listFiles.clear();
// for(int i=0; i<list.size();i++)
// {
// QFileInfo file_info = list.at(i);
// QString suffix = file_info.suffix();
// if(fileSuffix.indexOf(suffix)>=0)
// {
// QString absolute_file_path = file_info.absoluteFilePath();
// listFiles.append(absolute_file_path);
// }
// }
// }
// CBaseObject *pOSGObject =pProj->GetFolderObjectByClassID(GetClassID_GeoModelFolder(),true);
// PaiObject * pParentObject= pOSGObject->GetPaiObject();
// QList<PaiObject*>lists;
// pParentObject->GetChildren(lists);
// for(int i=0;i<lists.size();i++)
// {
// CObjGeoLayerData * pGeoLayerObj=dynamic_cast<CObjGeoLayerData *>(lists[i]);
// pParentObject->RemoveChild(pGeoLayerObj,true);
// }
// foreach( QString wellFile,listFiles ) {
// CObjGeoLayerData * pGeoLayerObj=new CObjGeoLayerData;
// QString sectionName,path0;
// GetWellNameAndPath(wellFile,sectionName,path0);
// if(!sectionName.isEmpty())pGeoLayerObj->SetName(sectionName);
// else pGeoLayerObj->SetName(wellFile);
// pParentObject->AddChild(pGeoLayerObj);
// }
}
void CDataImport::ImporttoTree(QString slfFileName,CLogIO *logio1,CObjWell *pWell,CObjWelllogRound* pWelllogRound,char *curvename)
{
// // if(!pWelllogRound) return;
// CLogIO *logio=logio1;
// if(!logio) {
// logio=new CLogIO();
// if(!logio->Open(slfFileName.toStdString().c_str(),CSlfIO::modeRead))
// {
// delete logio;
// AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败请检查");
// return;
// }
// }
// int i=logio->FindObjectName(curvename);
// if(i<0) {
// if(!logio1){
// delete logio;
// }
// return;
// }
// char aliasname[65];
// aliasname[64]='\0';
// logio->GetObjectName(i,curvename,NULL,aliasname);
// CObjWellLog * acurve;
// if(pWelllogRound) acurve=dynamic_cast<CObjWellLog *>(pWelllogRound->GetObjectByName(curvename));
// else acurve=dynamic_cast<CObjWellLog *>(pWell->GetObjectByName(curvename));
// if(dynamic_cast<CObjDiscreteWellLog*>(acurve)) acurve=NULL;
// short curvetype=logio->GetObjectType(i);
// short Attribute=0,SubAttribute=0;
// logio->GetObjectAttribute(i,&Attribute,&SubAttribute);
// if(acurve) {
// PaiObject *pP=acurve->GetParent();
// if(dynamic_cast<CObjWellTrack*>(pP)||
// dynamic_cast<CObjWellLogTrack*>(pP)
// ) acurve=NULL;
// else{
// CDataTree *pTree=dynamic_cast<CDataTree *>(::GetProject()->m_pDataTree);
// if(pTree&&pTree->GetTreeItem(acurve))
// {
// if(!logio1){
// delete logio;
// }
// return;
// }
// }
// }
// PaiObject*pPai=NULL;
// if(curvetype==CURVE_OBJECT)
// {
// Slf_CURVE acurveinfo;
// logio->GetCurveInfo(i,&acurveinfo);
// int curveindex=logio->OpenCurve(curvename);
// if(curveindex<0)
// {
// if(!logio1){
// delete logio;
// }
// return;
// }
// CObjWellLog * acurve=NULL;
// QStringList cnames=GetSimilarCurves("Trajectory");
// if(!pWelllogRound&&cnames.contains(curvename)) {
// acurve=(CObjWellLog *) new CObjWellTrajectory();
// }
// else {
// acurve=new CObjWellLog();
// acurve->acurveinfo=acurveinfo;
// }
// acurve->m_ObjectType=CURVE_OBJECT;
// acurve->SetSlfFileName(slfFileName);
// acurve->SetName(QString::fromStdString(curvename));
// acurve->SetAliasName(QString::fromStdString(aliasname));
// acurve->SetUnit(QString::fromStdString(acurveinfo.Unit));
// acurve->SetAliasUnit(QString::fromStdString(acurveinfo.AliasUnit));
// acurve->SetDepthUnit(QString::fromStdString(acurveinfo.DepthUnit));
// acurve->SetDepthAliasUnit(QString::fromStdString(acurveinfo.DepthHZUnit));
// acurve->SetpropertyMin(acurveinfo.MinValue);
// acurve->SetpropertyMax(acurveinfo.MaxValue);
// acurve->SetRlev(acurveinfo.DepLevel);
// acurve->SetTopDepth(acurveinfo.StartDepth);
// acurve->SetBottomDepth(acurveinfo.EndDepth);
// acurve->GetLogCurve().SetCurveAlias(acurveinfo.AliasName);
// acurve->GetLogCurve().SetUnit(acurveinfo.Unit);
// acurve->GetLogCurve().SetSampleInterval(acurveinfo.DepLevel);
// acurve->AutoMatchFamily();
// if(pWelllogRound)pWelllogRound->AddChild(acurve);
// else pWell->AddChild(acurve);
// pPai=acurve;
// }
// else if(curvetype==WAVE_OBJECT)
// {
// Slf_WAVE acurveinfo;
// logio->GetWaveInfo(i,&acurveinfo);
// CObjWellLog * acurve=new CObjWellLogWavefile();
// acurve->m_ObjectType=WAVE_OBJECT;
// acurve->SetName(QString::fromStdString(curvename));
// acurve->SetAliasName(QString::fromStdString(aliasname));
// acurve->SetUnit(QString::fromStdString(acurveinfo.Unit));
// acurve->SetAliasUnit(QString::fromStdString(acurveinfo.AliasUnit));
// acurve->SetDepthUnit(QString::fromStdString(acurveinfo.DepthUnit));
// acurve->SetDepthAliasUnit(QString::fromStdString(acurveinfo.DepthHZUnit));
// acurve->SetSlfFileName(slfFileName);
// acurve->SetTopDepth(acurveinfo.StartDepth);
// acurve->SetBottomDepth(acurveinfo.EndDepth);
// acurve->SetRlev(acurveinfo.DepLevel);
// acurve->GetLogCurve().SetSampleInterval(acurveinfo.DepLevel);
// if(pWelllogRound)pWelllogRound->AddChild(acurve);
// else pWell->AddChild(acurve);
// pPai=acurve;
// }
// else if(curvetype==CARD_OBJECT)
// {
// if(SubAttribute==PARA_OBJECT) {
// CObjWellLog * acurve=new CObjWellLogINP();
// acurve->m_ObjectType=CARD_OBJECT;
// acurve->SetName(QString::fromStdString(curvename));
// acurve->SetAliasName(QString::fromStdString(aliasname));
// acurve->SetSlfFileName(slfFileName);
// if(pWelllogRound)pWelllogRound->AddChild(acurve);
// else pWell->AddChild(acurve);
// }
// else {
// CObjWellLog * acurve=new CObjWellLogBIN();
// acurve->m_ObjectType=CARD_OBJECT;
// acurve->SetName(QString::fromStdString(curvename));
// acurve->SetAliasName(QString::fromStdString(aliasname));
// acurve->SetSlfFileName(slfFileName);
// if(pWelllogRound)pWelllogRound->AddChild(acurve);
// else pWell->AddChild(acurve);
// }
// pPai=acurve;
// }
// else if(curvetype==FMT_OBJECT)
// {
// CObjWellLog * acurve=new CObjWellLogFMT();
// acurve->m_ObjectType=FMT_OBJECT;
// acurve->SetName(QString::fromStdString(curvename));
// acurve->SetAliasName(QString::fromStdString(aliasname));
// acurve->SetSlfFileName(slfFileName);
// if(pWelllogRound)pWelllogRound->AddChild(acurve);
// else pWell->AddChild(acurve);
// pPai=acurve;
// }
// else if(curvetype==TDT_OBJECT)
// {
// CObjWellLog * acurve=new CObjWellLogTDT();
// acurve->m_ObjectType=TDT_OBJECT;
// acurve->SetName(QString::fromStdString(curvename));
// acurve->SetAliasName(QString::fromStdString(aliasname));
// acurve->SetSlfFileName(slfFileName);
// if(pWelllogRound)pWelllogRound->AddChild(acurve);
// else pWell->AddChild(acurve);
// pPai=acurve;
// }
// else if(curvetype>CARD_OBJECT||curvetype==0)
// {
// if(pWelllogRound&&strcmp(curvename,"井基本信息")==0) return;
// CObjWellLog * acurve=new CObjWellLogTABLE();
// acurve->m_ObjectType=TABLEE_OBJECT;
// acurve->SetName(QString::fromStdString(curvename));
// acurve->SetAliasName(QString::fromStdString(aliasname));
// acurve->SetSlfFileName(slfFileName);
// if(pWelllogRound)pWelllogRound->AddChild(acurve);
// else pWell->AddChild(acurve);
// pPai=acurve;
// }
// CObjWellLog *pLog=dynamic_cast<CObjWellLog *>(pPai);
// if(pLog) pLog->SetWell(pWell);
// if(!logio1){
// delete logio;
// }
// return;
}
CObjWell *CDataImport::ChangetoSlf(QString wellFile1,DiDepthProgress *pDepthProgress)
{
return ChangetoSlf(wellFile1,pDepthProgress,true);
}
CObjWell *CDataImport::ChangetoSlf(QString wellFile1,DiDepthProgress *pDepthProgress,bool IsTran)
{
static QString temp = ::GetConfPath()+"data.ini";
QSettings settings(temp,QSettings::IniFormat,0);
settings.setIniCodec(QTextCodec::codecForName("UTF-8"));
QStringList serials=settings.value("wellType",0).toStringList();
CObjWell *pWell(NULL);
if(pDepthProgress) pDepthProgress->DelProgress(1);
QString filename=wellFile1;
QString slffilename=filename;
///////////////////
//识别是否为系统格式,否则启动转换模块转换为系统格式
if(!filename.endsWith(".slf",Qt::CaseInsensitive)&&
!filename.endsWith(".well",Qt::CaseInsensitive)&&IsTran)
{
QString logdata=GetLogdataPath()+g_prjname/*::GetProject()->GetName()*/;
logdata.replace('\\','/');
logdata.replace("//","/");
filename.replace("//","/");
filename.replace("\\","/");
if(filename.indexOf(logdata,0,Qt::CaseInsensitive)>-1) return pWell;
ConvertorManager &pManager=ConvertorManager::GetInstance();
//按目录加载原始数据时解编入口
QString slfName=ConvertorWellLogFiles(pManager,filename,pDepthProgress);
if(slfName!=""&&slfName!="abandoned"){//2020.3.19 放弃加载的文件名如何加入到提示中
pWell=ChangetoSlf(slfName,pDepthProgress);//whp add 2019.12.12
}
return pWell;
}
else {
QString wellname1,path1;
GetWellNameAndPath(filename,wellname1,path1);
QString prjname = g_prjname;
// if(GetProject()) prjname=GetProject()->GetName();
QString path2="LogData\\"+prjname;
QString path3="LogData/"+prjname;
path1=path1.replace("\\\\","\\");
path1=path1.replace("//","/");
int a=path1.indexOf(path2,0,Qt::CaseInsensitive);
int b=path1.indexOf(path3,0,Qt::CaseInsensitive);
if(a<0&&b<0) {
QFile dd;
path2=GetLogdataPath();
path2+=prjname+"\\#"+wellname1;
CreateDir((char *)path2.toStdString().c_str());
path2+="\\"+wellname1+".slf";
dd.copy(filename,path2);
slffilename=path2;
filename=path2;
}
int iX=-1,iY=-1,iZ=-1;
CObjWelllogRound* pWelllogRound=NULL;
///从文件内部读取井名
CLogIO * logio=new CLogIO();
if(!logio->Open(slffilename.toStdString().c_str(),CSlfIO::modeRead))
{
delete logio;
QString aa=slffilename+"文件打开失败,请检查!";
// AppendConsole(pai::log::PAI_ERROR,aa);
return pWell;
}
//说明从项目或者井节点发起attachSLF,需要读取slf获得井名和井次信息
QString wellname="";
QString wellRoundname="";
Slf_FILE_MESSAGE mssage;
logio->GetFileMessage(mssage);
wellname=mssage.WellName;
wellname=wellname.toUpper();
//辨别井名是否有效,无效则采用文件名
QFileInfo fileInfo(filename);
QString strWellName = fileInfo.completeBaseName();
strWellName=strWellName.toUpper();
if (wellname.isEmpty()||wellname.length()>64||wellname.indexOf('&')>-1)
{
wellname=strWellName.toStdString().c_str();
int len=strlen(strWellName.toStdString().c_str());
if(len>sizeof(mssage.WellName)) len=sizeof(mssage.WellName);
strncpy(mssage.WellName,strWellName.toStdString().c_str(),len);
mssage.WellName[len]=0;
logio->SetFileMessage(mssage);
}
wellname=wellname.toUpper();
// if(!GetProject() ) {
// delete logio;
// return NULL;
// }
// //挂接到树
// PaiObject *pObject=GetProject()->GetObjectByName( wellname,2);//GetClassID_Well());
// pWell = dynamic_cast<CObjWell *>( pObject );
// if(!pWell) {
// CObjWellTrack *pWellTrack = dynamic_cast<CObjWellTrack *>( pObject);
// if(pWellTrack&&pWellTrack->GetWelllogRound()) {
// pWell=pWellTrack->GetWelllogRound()->GetWell();
// }
// }
if(!pWell) {
// pWell = CDataImport::GetWellByName(wellname);
// CDataTree *pTree=(CDataTree *)GetDataTree();
// if(pTree) {
// PaiObject *pJ=GetProject()->GetObjectByType(GetClassID_WellsFolder());
// QTreeWidgetItem* pItemF=pTree->GetTreeItem(dynamic_cast<CBaseObject *>(pJ));
// QTreeWidgetItem* pItem=pTree->GetTreeItem(pWell );
// QTreeWidgetItem* pItemF1=NULL;
// if(pItem)pItemF1=pItem->parent();
// if(pItemF1!=pItemF) {
// if(pItemF1)pItemF1->removeChild(pItem);
// if(pItemF)pItemF->addChild(pItem);
// }
// }
// if(!pWell) {
// delete logio;
// return NULL;
// }
if( !pWell )
{
pWell = new CObjWell();
pWell->SetName( strWellName );
}
QString welln;
if(filename.endsWith(".slf",Qt::CaseInsensitive))
{
QString dirpath=GetLogdataPath()+g_prjname/*GetProject()->GetName()*/;
char szTemp[64];
strcpy(szTemp, ".well");
welln=GetWellFileFromDir(dirpath,wellname, szTemp);
if(welln.isEmpty()||(!pWell->GetName().isEmpty()&&wellname!=pWell->GetName())) {
wellname=pWell->GetName();
int index=filename.lastIndexOf("\\");
int index1=filename.lastIndexOf("/");
if(index1>index) index=index1;
welln=GetWellFileFromCurrentDir(filename.left(index+1),wellname,szTemp);
if(welln.isEmpty()) {
welln=filename.left(index+1)+wellname+".well";
CreateWellFile(logio,mssage,welln,pWell);
// CDataTree::SetTree(welln,pWell,NULL,(DepthProgress *)pDepthProgress,1);
}
}
}
else if(filename.endsWith(".well",Qt::CaseInsensitive))welln=filename;
pWell->SetWellFileName(welln);
}
wellRoundname=strWellName;
//查找是否已经存在该井和井次
int isrefress=0;
if(!filename.endsWith(".well",Qt::CaseInsensitive)) {
pWelllogRound=dynamic_cast<CObjWelllogRound*>( pWell->GetObjectByName(wellRoundname,GetClassID_WellLogRound()));
if(pWelllogRound)
{
QString cs=pWelllogRound->GetSlfFileName();
cs.replace('\\','/');
cs.replace("//","/");
QString cs1=filename;
cs1.replace('\\','/');
cs1.replace("//","/");
if(cs1.compare(cs,Qt::CaseInsensitive)!=0) {
QString cs2=cs+"\n";
cs2+=cs1+"为同一井次文件!\n";
cs2+="按重名文件加载!";
// AppendConsole(pai::log::PAI_ERROR,cs2);
wellRoundname+="_重名文件";
strcpy(mssage.Item,wellRoundname.toStdString().c_str());
pWelllogRound=NULL;//return 0;
}
}
if(!pWelllogRound)
{
// pWelllogRound=new CObjWelllogRound();
// pWelllogRound->SetWell(pWell);
// pWell->AddChild(pWelllogRound);
// pWell->SetCurrentObjWellRound(pWelllogRound);
if(strstr(mssage.Item,"常规")) {
strncpy(mssage.Item,wellRoundname.toStdString().c_str(),sizeof(mssage.Item));
mssage.Item[strlen(wellRoundname.toStdString().c_str())]=0;
}
if(strlen(mssage.Item)) {
wellRoundname=mssage.Item;
}
else {
int len=strlen(wellRoundname.toStdString().c_str());
if(len>sizeof(mssage.Item)) len=sizeof(mssage.Item);
strncpy(mssage.Item,wellRoundname.toStdString().c_str(),len);
mssage.Item[len]=0;
logio->SetFileMessage(mssage);
}
// wellRoundname=wellRoundname.toUpper();
// pWelllogRound->SetName(wellRoundname);
// pWelllogRound->SetSlfFileName(filename);
}
else {
isrefress=true;
}
}
QString temp = ::GetConfPath()+"data.ini";
QSettings settings(temp,QSettings::IniFormat,0);
settings.setIniCodec(QTextCodec::codecForName("UTF-8"));
QStringList serials=settings.value("wellType",0).toStringList();
int type=serials.indexOf(mssage.WellType);
if(type>-1) pWell->SetWellSymbol("well" + QString::number(type) + ".png");
//else isrefress=true;
float Altitude=mssage.Altitude;
float X_COORDINATE=mssage.Xcoor;
float Y_COORDINATE=mssage.Ycoor;//井斜x,y坐标
WellHead &mWellHead=pWell->GetWellHead();
if(mssage.Kelly==9999999) mssage.Kelly=0;
if(mssage.Kelly==-9999) mssage.Kelly=0;
if(mssage.Kelly==-99999) mssage.Kelly=0;
if(mssage.azca) mWellHead.azca=mssage.azca;
if(mssage.Kelly)mWellHead.dEle=ConvertDataByFloat(mssage.Kelly).toFloat();
if(mssage.WellName[0])mWellHead.wellName=mssage.WellName;
if(X_COORDINATE)mWellHead.x=X_COORDINATE;
if(Y_COORDINATE)mWellHead.y=Y_COORDINATE;
if(Altitude)mWellHead.earthEle=Altitude;
if(mssage.X0)mWellHead.dxe=mssage.X0;
if(mssage.Y0)mWellHead.dyn=mssage.Y0;
if(mssage.TVD)mWellHead.tvd=mssage.TVD;
Slf_CURVE acurveinfo;
memset(&acurveinfo,0,sizeof(Slf_CURVE));
int curveCount=logio->GetObjectCount();
if(isrefress) {
logio->DiscardObject("X");
logio->DiscardObject("Y");
logio->DiscardObject("Z");
logio->DiscardObject("TVD");
}
iX=logio->OpenCurve("X");
iY=logio->OpenCurve("Y");
iZ=logio->OpenCurve("Z");
if(iX>-1) logio->GetCurveInfo(iX,&acurveinfo);
mWellHead.depth=acurveinfo.StartDepth;
if(mWellHead.tvd==0&&acurveinfo.StartDepth!=0)mWellHead.tvd=acurveinfo.StartDepth;
mWellHead.z=mWellHead.earthEle-mWellHead.tvd+mWellHead.dEle;
mWellHead.startDepth=acurveinfo.StartDepth;
mWellHead.endDepth=acurveinfo.EndDepth;
mWellHead.rlev=acurveinfo.DepLevel;
int iDepth=-1;
iDepth=logio->OpenCurve("TVD");
if(iX>=0&&iY>=0&&iZ>=0&&iDepth>=0) {
logio->GetCurveInfo(iX,&acurveinfo);
if(acurveinfo.DepLevel==0) {
logio->DiscardObject(iX);
logio->DiscardObject(iY);
logio->DiscardObject(iZ);
logio->DiscardObject(iDepth);
delete logio;
pWell->ComputeTrajectory(pWell,filename);
} else {
delete logio;
pWell->SetDepth(pWell);
}
}
else {
delete logio;
pWell->ComputeTrajectory(pWell,slffilename);
}
logio=new CLogIO();
if(!logio->Open(slffilename.toStdString().c_str(),CSlfIO::modeRead))
{
delete logio;
QString aa=slffilename+"文件打开失败,请检查!";
// AppendConsole(pai::log::PAI_ERROR,aa);
return pWell;
}
curveCount=logio->GetObjectCount();
char* curvename=new char[65];
curvename[64]='\0';
char* aliasname=new char[65];
aliasname[64]='\0';
for(int i=0;i<curveCount;i++) {
logio->GetObjectName(i,curvename,NULL,aliasname);
if(!logio->IsObject(i)) {
logio->DiscardObject(i);
continue;
};
if(logio->GetObjectStatus(i)!=OBJECT_NORMAL) continue;
short curvetype=logio->GetObjectType(i);
short Attribute=0,SubAttribute=0;
logio->GetObjectAttribute(i,&Attribute,&SubAttribute);
if(curvetype==CURVE_OBJECT)
{
Slf_CURVE acurveinfo;
logio->GetCurveInfo(i,&acurveinfo);
if(acurveinfo.DepLevel!=0&&(acurveinfo.EndDepth-acurveinfo.StartDepth>0))
{
if(acurveinfo.MaxValue==acurveinfo.MinValue||acurveinfo.MaxValue==-99999||acurveinfo.MaxValue==-9999||acurveinfo.MinValue==999999||acurveinfo.MinValue==999999||acurveinfo.MinValue==99999||acurveinfo.MinValue==99999||acurveinfo.MinValue==-9999){
int curveindex=logio->OpenSlfTable(i,-1);
if(curveindex>-1)
{
MyDataTypeEnum vVdl;
DWORD count=(acurveinfo.EndDepth-acurveinfo.StartDepth)/acurveinfo.DepLevel+1.5;
DWORD len=count*acurveinfo.CodeLen;
acurveinfo.MinValue=99999999;
acurveinfo.MaxValue=-99999999;
if(acurveinfo.CodeLen==8) acurveinfo.MinValue=99999999;
vVdl.vchar=new char[len];
len=logio->ReadCurve(curveindex, acurveinfo.StartDepth,count,(void *)vVdl.vchar);
if(!len) {
QString cs;
char buf[1000];
sprintf(buf,"%s %f-%f",acurveinfo.Name,acurveinfo.StartDepth,acurveinfo.EndDepth);
cs=buf;
int flag = QMessageBox::warning(NULL,"提示",QString(cs+"\n曲线信息异常!删除该曲线可能需要较长时间,建议复制正常曲线等信息到新文件,然后删除此文件。是否此时直接将该曲线删除?"),QMessageBox::Yes,QMessageBox::No);
if(flag==QMessageBox::Yes) logio->DiscardObject(i);
delete vVdl.vchar;
continue;
}
for(int kk=0;kk<count;kk=kk+10)
{
float buf[200];
buf[0]=0;
float temp=logio->GetData(acurveinfo.RepCode,&vVdl.vchar[kk*acurveinfo.CodeLen],buf);
if(_isnan(temp)||!_finite(temp)) continue;
if(acurveinfo.MaxValue<temp) if(temp!=-9999.0&&temp!=-999.25&&temp!=-99999.0)acurveinfo.MaxValue=temp;
if(acurveinfo.MinValue>temp) if(temp!=-9999.0&&temp!=-999.25&&temp!=-99999.0)acurveinfo.MinValue=temp;
}
logio->SetCurveInfo(curveindex,&acurveinfo);
delete vVdl.vchar;
}
}
}
else if(acurveinfo.DepLevel==0||acurveinfo.StartDepth<-100000||acurveinfo.StartDepth>100000)
{
QString cs;
char buf[1000];
sprintf(buf,"%s %f-%f",acurveinfo.Name,acurveinfo.StartDepth,acurveinfo.EndDepth);
cs=buf;
int flag = QMessageBox::warning(NULL,"提示",QString(cs+"\n曲线信息异常!删除该曲线可能需要较长时间,建议复制正常曲线等信息到新文件,然后删除此文件。是否此时直接将该曲线删除?"),QMessageBox::Yes,QMessageBox::No);
if(flag==QMessageBox::Yes) logio->DiscardObject(i);
continue;
}
}
}
delete []curvename;
delete []aliasname;
DepthProgress *pd=new DepthProgress;
pd->CreatProgress(0,2,"正在整理数据...");
pd->SetDepth(1);
delete logio;
delete pd;
/////////////////////
pai::ios::welllog::Well& topwell=pWell->GetDBWell();
topwell.SetTopDepth(pWell->GetTopWellLogDepth());
topwell.SetBottomDepth(pWell->GetBottomWellLogDepth());
if(X_COORDINATE)topwell.SetXCode(X_COORDINATE);
if(Y_COORDINATE)topwell.SetYCode(Y_COORDINATE);
if(mssage.Altitude)topwell.SetAsl(mssage.Altitude);
if(mssage.Kelly)topwell.SetBsl(ConvertDataByFloat(mssage.Kelly).toFloat());
// topwell.SetItem(mssage.Item);
/////////////
topwell.LoadMeesge(filename);
// if(pWelllogRound&&pWelllogRound->GetChildrenCount()>2) {
// isrefress=1;
// }
// if(isrefress) {
// QString slfFileName=filename;
// CDataTree::SetTree(slfFileName,pWell,pWelllogRound,(DepthProgress *)pDepthProgress,1);
// }
}
return pWell;
return NULL;
}
void CDataImport::ImportCoreImage()
{
// QStringList listFiles=GetFileNames("选择文件","图片文件(*.jpg)");
// CObjCoreImage* pCoreImage = new CObjCoreImage();
// std::vector<CoreImage>vCoreImage;
// foreach( QString imageFile,listFiles )
// {
// //得到或创建well
// QFileInfo fileInfo(imageFile);
// QString strWellName = fileInfo.completeBaseName();
// CoreImage coreImage;
// LinePro linePro;
// linePro.lineColor = QColor(Qt::black);
// linePro.lineWidth = 1;
// linePro.lineStyle = Qt::SolidLine;
// coreImage.m_imageFile = imageFile;
// coreImage.m_startDepth = 0;
// coreImage.m_endDDepth = 0;
// coreImage.m_leftDepth = 0;
// coreImage.m_rightDepth = 0;
// coreImage.m_border = linePro ;
// //pCoreImage->m_childrenItems.push_back(coreImage);
// vCoreImage.push_back(coreImage);
// }
// pCoreImage->SetImageObjects( vCoreImage );
// if(listFiles.size() > 0)
// {
// pai::gui::CoreImageConfigDialog* pDialog = new pai::gui::CoreImageConfigDialog();
// pDialog->SetCoreImages( pCoreImage );
// if(pDialog->exec() == QDialog::Accepted)
// {
// //TODO这里要找到当前曲线不可写死
// CObjWell *pWell = CDataImport::GetWellByName( "A10" );
// pWell->AddChild( pCoreImage );
// }
// }
}
void CDataImport::ImportBitmaps()
{
// QStringList listFiles=GetFileNames("选择文件","图片文件(*.jpg)");
// qsrand(qrand());
// foreach( QString imageFile,listFiles )
// {
// // create Image object
// int nWidth = qBound( 0,qrand(),1000 );
// int nHeight = nWidth ;
// CObjBitmap *pImageObject = new CObjBitmap( QRectF( qBound( 0,qrand(),1000 ),qBound( 0,qrand(),1000 ),
// nWidth,nHeight ),imageFile );
// // set name
// QFileInfo fileInfo( imageFile );
// pImageObject->SetName( fileInfo.completeBaseName() );
// // add to project
// if( ::GetProject() )
// {
// ::GetProject()->AddChild( pImageObject );
// }
// }
}
void CDataImport::ImportConvertorWellLogFiles(QString wellname,QString wellroundname)
{
// AppendConsole(pai::log::PAI_INFO,QObject::tr("解编模块启动中..."));
// ConvertorManager &pManager=ConvertorManager::GetInstance();
// QVector<QString>vSuffix=pManager.GetSupportFileExtensions();
// // if (vSuffix.empty())
// // return;
// QString fileSuffix("数据文件(");
// for (int i=0;i<vSuffix.size();i++)
// {
// QString sSuffix="*.";
// sSuffix.append(vSuffix[i]);
// fileSuffix.append(sSuffix);
// fileSuffix.append(" ");
// }
// QString sSuffix="*.";
// sSuffix.append("slf");
// fileSuffix.append(sSuffix);
// fileSuffix.append(" ");
// //whp del 2020.5.17 for test wis转换
// /* sSuffix="*.";
// sSuffix.append("wis");
// fileSuffix.append(sSuffix);
// fileSuffix.append(" ");*/
// //whp add 2019.12.09 for .well
// sSuffix="*.";
// sSuffix.append("well");
// fileSuffix.append(sSuffix);
// fileSuffix.append(" ");
// fileSuffix.append(")");
// //选择一文件
// QStringList listFiles=GetFileNames("选择数据文件",fileSuffix,QFileDialog::ExistingFiles);
// int FileNum=listFiles.size();//whp 2019.12.08 test
// if (listFiles.empty()) return ;
// AppendConsole(pai::log::PAI_INFO,QObject::tr("解编模块自动检测开始..."));
// DiDepthProgress DepthProgress;
// if(listFiles.size()>1) {
// DepthProgress.CreatProgress(0,listFiles.size(),"数据加载",0);
// int progress=0;
// char aa[1000];
// //whp change 2019.12.08 for 输出成功加载的文件个数
// int errNum=0,okNum=0,abandonedNum=0;//2020.3.19 放弃加载;
// QStringList errFile,abandonedFile;//2020.3.19
// //whp add 2020.3.19
// CDataImport::flag1=-1;
// CDataImport::m_flag=-1;
// CDataImport::flag_check=0;//
// foreach(QString iFile,listFiles ) {
// progress++;
// sprintf(aa,"待加载数据文件%d个,当前正在加载:%s",listFiles.size(),iFile.toStdString().c_str());
// DepthProgress.SetShowName(aa,0);
// DepthProgress.SetDepth(progress,0);
// //多个测井数据加载时解编入口
// QString slfName=ConvertorWellLogFiles(pManager,iFile,&DepthProgress);
// if(slfName=="")
// {
// errNum++;
// errFile.append(iFile);
// }
// else if(slfName=="abandoned")//2020.3.19 放弃加载
// {
// abandonedNum++;
// abandonedFile.append(iFile);
// }
// else
// {
// CObjWell* pWell=ChangetoSlf(slfName,&DepthProgress);//whp add 2019.12.12
// if(!pWell) {
// errNum++;
// errFile+=iFile;
// errFile+="\r\n";
// }
// }
// }
// DepthProgress.DelProgress();
// CObjProject *pPrj=::GetProject();
// if(pPrj) {
// PaiObject *pObj=pPrj->GetObjectByType(GetClassID_WellsFolder());
// if(pObj) {
// CBaseObject * pBaseObject = dynamic_cast<CBaseObject*>(pObj);
// if(pBaseObject) {
// CDataTree *pDatatree=(CDataTree *)::GetProject()->m_pDataTree;
// if(pDatatree) {
// QTreeWidgetItem* pItem=pDatatree->GetTreeItem(pBaseObject);
// pDatatree->ClickObjectCommand(pItem);
// }
// pBaseObject->SetCheckState(Qt::Checked);
// CVecWindow *pWindow=CVecWindowCommand::GetCurrentWindow();
// CVecDisplayObjectCommand::ClickObjectCommand( pBaseObject->GetPaiObject(),pWindow);
// }
// }
// }
// //2020.3.17需要修改
// QString mes="";
// if(errNum||abandonedNum)
// {
// mes="成功导入"+QString::number(listFiles.size()-errNum-abandonedNum)+"个文件;";
// if(abandonedNum) mes+="放弃导入"+QString::number(abandonedNum)+"个数据文件;";
// if(errNum)mes+="\r\n"+QString::number(errNum)+"个数据文件无法识别:\r\n"+errFile.join("\r\n");
// CDialog* m_dialog=new CDialog();
// m_dialog->setMessage(mes);
// m_dialog->setTitle("提示");
// m_dialog->exec();
// delete m_dialog;
// }
// else {
// mes=QString::number(listFiles.size())+"个文件全部导入成功!";
// QMessageBox::about(NULL,"提示",mes);
// }
// }
// else {
// DepthProgress.CreatProgress(0,1,"数据加载",0);
// DepthProgress.SetDepth(1,0);
// QString us=listFiles[0].toLower();
// QFileInfo currentfile(us);
// us=currentfile.suffix();
// // if(us.indexOf("slf")>-1||us.indexOf("wis")>-1) {
// //whp add 2019.12.09 for .well
// if(us.indexOf("slf")>-1||us.indexOf("well")>-1) {
// ChangetoSlf(listFiles[0]);
// QString message=listFiles[0]+"解编结束";
// AppendConsole(pai::log::PAI_INFO,QObject::tr(message.toStdString().c_str()));
// return;
// }
// DepthProgress.SetShowName("类型识别",0);
// QVector<IConvertor*> vConvertor=pManager.GetSupportConvertors(listFiles[0],&DepthProgress);
// // if (vConvertor.empty()) return ;
// if (vConvertor.empty())
// {
// QMessageBox::information(NULL,"无法识别的文件",listFiles[0]);
// return ;
// }
// ImportDataDialog *pDialog = new ImportDataDialog(NULL,wellname,wellroundname);
// pDialog->DisplayFileInformationAreaData(vConvertor,listFiles[0]);
// ::GetObjectEvent().OnActiveConvertorWindow( pDialog );
// }
// AppendConsole(pai::log::PAI_INFO,QObject::tr("解编模块解编结束"));
}
//whp change 2019.12.08 for 输出成功加载的文件个数
//void
//bool
//whp add 2020.2.28 for 检查井名文件名是否存在,若存在,获取井次全路径文件名
QString CDataImport::GetOutName(QString wellname,QString filename)
{
// CObjProject *pPrj=::GetProject();
// PaiObject *pObj=pPrj->GetObjectByType(GetClassID_WellsFolder());
// QList<PaiObject *> childs;
// pObj->GetChildren(childs);
// int wellnum=childs.count();
// foreach(PaiObject *pChild,childs)
// {
// CObjWell *pWell=dynamic_cast<CObjWell*>(pChild);
// if(pWell)
// {
// QString well=pWell->GetName().toUpper();
// if(well==wellname.toUpper())
// {
// QList<PaiObject *> childsRound;
// pChild->GetChildren(childsRound);
// foreach(PaiObject *pChildRound,childsRound)
// {
// CObjWelllogRound *pWellRound=dynamic_cast<CObjWelllogRound*>(pChildRound);
// if(pWellRound)
// {
// QString file=pWellRound->GetName().toUpper();
// if(file==filename.toUpper())
// {
// QString outname=pWellRound->GetSlfFileName();
// return outname;
// }
// }
// }
// }
// }
// }
return "";
}
////whp change 2020.2.28 for 检查井名、文件名是否存在,若存在,使用已存在的输出路径(主要针对更名后的井文件)
QString CDataImport::ConvertorWellLogFiles(ConvertorManager &pManager,QString wellname,DiDepthProgress *DepthProgress)
{
QString iFile=wellname;
QString us1=iFile.toLower();
QFileInfo currentfile(us1);
QString us=currentfile.suffix();
//whp add 2019.12.09 for .well
if(us.indexOf("slf")>-1||us.indexOf("well")>-1) {
//ChangetoSlf(iFile,DepthProgress);
//return 1;
return iFile;//whp change 2019.12.12
}
QVector<IConvertor*> vConvertor=pManager.GetSupportConvertors(iFile,DepthProgress);
if(vConvertor.size()>1) {
QString s=iFile+"解编模块不唯一,无法批量解编!";
// AppendConsole(pai::log::PAI_INFO,s);
return "";//0;//whp change 2019.12.12
}
if(vConvertor.size()==0) {
QString s=iFile+"无法识别数据类型,无法解编!";
// AppendConsole(pai::log::PAI_INFO,s);
return "";//0;//whp change 2019.12.12
}
InterIConvertor *v=(InterIConvertor *)vConvertor[0];
QList<CObjWellLog*> ObjWellLogs= v->GetWellLogList(iFile);
int c=ObjWellLogs.size();
for(int i=0;i<c;i++) {
CObjWellLog *pWellLog=ObjWellLogs[i];
delete pWellLog;
pWellLog=NULL;
}
Well* well=v->GetWellInfo();
MyWelllogRound* r=v->GetWellLogRoundInfo();
QString WellName=well->GetName().c_str();//取的谁的名字?跟踪遇见的都是空
// if(WellName==""){//应用当前选中井名
// QAction* ImportConvertorWellLogDataAct= ::GetGlobalCommand().GetAction(GetCmdID_ImportConvertorWellLogData(),true) ;
// WellName = ImportConvertorWellLogDataAct->property("CurrentWellName").value<QString>();
// }
//whp change 2020.2.18 for 汉字井名转换有乱码
if(WellName=="") WellName=QString(QString::fromLocal8Bit(v->FILE_MESSAGE.WellName)); //QLatin1String(v->FILE_MESSAGE.WellName);//for 带有井名信息的原始数据如ASCII
//该语句不可用发现clis文件中的井名
//add end
if(WellName=="") WellName=r->GetName().c_str();
QString strWellName;
// CObjProject *pProject = ::GetProject();
// if(pProject != NULL)
// {
// strWellName = pProject->GetName();
// }
strWellName = g_prjname;
QString dir0,dir=::GetLogdataPath();//whp add 2020.2.19 for 非法井名,无法产生井目录
QDir w;
if(!strWellName.isEmpty()) {
dir=dir+strWellName;
bool ok=w.mkdir(dir);
dir+=QDir::separator();
}
QString tempWellName;
QString filename=r->GetName().c_str();
if(filename=="") filename=WellName;
//whp add 2020.3.3 删除井名中的空格
WellName.replace(" ","");
WellName=WellName.toUpper();
//whp add 2020.3.3 删除".zh"之类的后缀之类的后缀
QFileInfo temDir(WellName);
WellName=temDir.baseName();
//////
char *pmessage=v->GetfileMessage();
if(pmessage) {
char *p=pmessage;
p+=strlen(p)+1;
if(strlen(p)>0&&strlen(p)<20) {
p+=strlen(p)+1;
p+=strlen(p)+1;
tempWellName=p;
}
else tempWellName="";
}
//whp change 2020.2.18 for 文件名中有一个以上的“."时如3Oq.ZH.716
//QFileInfo temDir(filename);
//if(tempWellName=="") tempWellName=temDir.completeBaseName();
if(tempWellName=="") tempWellName=filename;
QString outputfilename=GetOutName(WellName,tempWellName);
if(outputfilename=="")
{
dir0=dir;//whp add 2020.2.19 for 非法井名,无法产生井目录
dir+="#"+WellName;
bool ok=w.mkdir(dir);
//whp add 2020.2.19 for 非法井名,无法产生井目录
QDir mdir(dir);
if(mdir.exists())ok=1;
if(!ok)
{
dir=dir0;
QFileInfo temDir(iFile);
WellName=temDir.completeBaseName();
outputfilename=GetOutName(WellName,tempWellName);
if(outputfilename=="")
{
dir+="#"+WellName;
ok=w.mkdir(dir);
if(!ok)
{
QString mes="解编"+iFile+"文件时,产生井文件目录失败:\r\n井文件目录:"+dir;
QMessageBox::about(NULL, QObject::tr("警告"), mes);
return "";
}
outputfilename=dir;
outputfilename+=QDir::separator();
outputfilename+=tempWellName;
outputfilename+=".slf";
}
}
else outputfilename=dir+QDir::separator()+tempWellName+".slf";
}
char *outfile = new char[outputfilename.toStdString().size()+200];
strcpy(outfile, outputfilename.toStdString().c_str());
/* //whp add 2019.12.10 for 如果文件存在,提示是否覆盖
QFileInfo mfi(outfile);
//2020.3.19
if(mfi.isFile())
{
if(CDataImport::flag_check)//&&CDataImport::flag1!=-1)
{
if(CDataImport::flag1==QMessageBox::Cancel)return "abandoned";//放弃加载
else if(CDataImport::flag1==QMessageBox::No){
QDir ss;ss.remove(outfile);
}
}
else //if(mfi.isFile())
{//whp change 2020.2.28
QMessageBox box(QMessageBox::Warning,"提示","输出文件"+QString::fromLocal8Bit(outfile)+"已存在!");
//box.setStandardButtons (QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel|QMessageBox::YesAll|QMessageBox::NoAll|QMessageBox::Apply);
box.setStandardButtons (QMessageBox::Yes|QMessageBox::Cancel|QMessageBox::YesAll|QMessageBox::Apply);
box.setButtonText (QMessageBox::Yes,QString("覆盖当前"));//\r\n已存在文件"));
// box.setButtonText (QMessageBox::No,QString("重建\r\n当前文件"));
box.setButtonText (QMessageBox::YesAll,QString("覆盖所有"));//\r\n已存在文件"));
// box.setButtonText (QMessageBox::NoAll,QString("全部\r\n执行重建"));
box.setButtonText (QMessageBox::Cancel,QString("放弃当前"));//\r\n文件解编"));
box.setButtonText (QMessageBox::Apply,QString("放弃所有"));//\r\n已存在文件解编"));
int ret=box.exec();
if(ret==QMessageBox::YesAll||ret==QMessageBox::Yes) CDataImport::flag1 =QMessageBox::Yes;
//if(ret==QMessageBox::NoAll||ret==QMessageBox::No) CDataImport::flag1 =QMessageBox::No;
if(ret==QMessageBox::Cancel||ret==QMessageBox::Apply) CDataImport::flag1 =QMessageBox::Cancel;
//if(ret==QMessageBox::NoAll||ret==QMessageBox::YesAll||ret==QMessageBox::Apply) CDataImport::flag_check=1;
if(ret==QMessageBox::YesAll||ret==QMessageBox::Apply) CDataImport::flag_check=1;
if(CDataImport::flag1==QMessageBox::Cancel)return "abandoned";//放弃加载
//else if(CDataImport::flag1==QMessageBox::No)QDir ss;ss.remove(outfile);
}
}
//add end*/
char *logfilename = new char[iFile.toStdString().size()+1];
strcpy(logfilename, iFile.toStdString().c_str());
int l=strlen(outfile)+1;
double x=well->GetXCode();
strcpy(&outfile[l],QString::number(x).toStdString().c_str());//x坐标
double y=well->GetYCode();
l+=strlen(&outfile[l])+1;
strcpy(&outfile[l],QString::number(y).toStdString().c_str());//y坐标
QString top="-99999.";//QString::number(r->GetTopDepth());
l+=strlen(&outfile[l])+1;
strcpy(&outfile[l],top.toStdString().c_str());//y坐标
QString bottom="-99999.";//QString::number(r->GetBottomDepth());
l+=strlen(&outfile[l])+1;
strcpy(&outfile[l],bottom.toStdString().c_str());//y坐标
l+=strlen(&outfile[l])+1;
int iRow=v->GetWellCurves().Curve_Num;
*(int *)&outfile[l]=iRow;
//TODO
vector<int> OutCurveNo;
vector<char*> OutCurve=v->GetCurveNames();
vector<char*> strChineseName=v->GetCurveNames();
vector<char*> strUnit=v->GetCurveUnits();
for(int i=0;i<OutCurve.size();i++) {
OutCurveNo.push_back(i);
}
CMemRdWt *logio=new CMemRdWt();
QString qss=outfile;
//whp add 2020.7.16 for 按导入对象提示
//如果文件存在,检查输出对象是否存在
QFileInfo mfi(outfile);
if(mfi.isFile())//
{
vector<int> ExistCurveNo;
vector<char*> ExistCurve;
int ExistCurveNum=0;
logio->Open(qss.toStdString().c_str(),CSlfIO::modeRead);
for(int i=0;i<iRow;i++)
{
int nn=logio->FindObjectName(OutCurve[i]);
if(logio->FindObjectName(OutCurve[i],-1,-1,OBJECT_NORMAL)<0)continue;
ExistCurve.push_back(OutCurve[i]);
ExistCurveNo.push_back(i);
}
if(ExistCurve.size()>0)//输出对象是否存在
{
if(!CDataImport::flag_check)
{
QString name=qss;
int index=name.lastIndexOf("/");
int index1=name.lastIndexOf("\\");
if(index1>index)index=index1;
name=name.mid(index+1);
name=name.left(name.lastIndexOf("."));
Slf_FILE_MESSAGE mes;
logio->GetFileMessage(mes);
QString m_WellAndRound=QString::fromLocal8Bit(mes.WellName)+""+name;
TiShiDialog *dlg=new TiShiDialog(NULL);
dlg->init(ExistCurve,m_WellAndRound);//qss);
if(dlg->exec()==QDialog::Accepted)
{
CDataImport::flag1=dlg->flag;
CDataImport::m_flag=dlg->flag;
CDataImport::flag_check=dlg->check;
}
}
int mflag=CDataImport::m_flag;
if(mflag==0)//跳过
{
for(int i=0;i<ExistCurve.size();i++)
{
int nn=ExistCurveNo[i];
OutCurveNo[ExistCurveNo[i]]=-1;
}
}
else if(mflag==1)//替换
{
for(int i=0;i<ExistCurve.size();i++)
{
logio->DiscardObject(ExistCurve[i]);
}
}
else if(mflag==3)//另存
{
QStringList OutCurveList;
for(int i=0;i<logio->GetObjectCount();i++)
{
char name[64];
if(logio->GetObjectStatus(i)!=OBJECT_NORMAL)continue;
logio->GetObjectName(i,name);
OutCurveList.append(QString(name));
}
for(int i=0;i<ExistCurve.size();i++)
{
QString name1,name=QString(ExistCurve[i])+"_";
for(int j=0;j<100;j++)
{
name1=name+QString::number(j+1);
if(OutCurveList.indexOf(name1)<0)break;
}
char *temp = new char[name1.toStdString().size()+1];
strcpy(temp, name1.toStdString().c_str());
strcpy(OutCurve[ExistCurveNo[i]],temp);
delete temp;
}
}
if(mflag=0&&ExistCurve.size()==iRow)
{
delete logio;
return "abandoned";//放弃加载
}
}
logio->Close();
}
// bool CheckExistCurve(QString outputfilename,int NumLog,vector<int>& OutCurveNo,vector<char*>& OutCurve);
if(logio->Open(qss.toStdString().c_str(),CSlfIO::modeRead))
{
Slf_FILE_MESSAGE FILE_MESSAGE=v->FILE_MESSAGE;
logio->GetFileMessage(v->FILE_MESSAGE);
if(v->FILE_MESSAGE.Xcoor!=FILE_MESSAGE.Xcoor) {
if(FILE_MESSAGE.Xcoor!=0) v->FILE_MESSAGE.Xcoor=FILE_MESSAGE.Xcoor;
}
if(v->FILE_MESSAGE.Ycoor!=FILE_MESSAGE.Ycoor) {
if(FILE_MESSAGE.Ycoor!=0) v->FILE_MESSAGE.Ycoor=FILE_MESSAGE.Ycoor;
}
if(v->FILE_MESSAGE.Altitude!=FILE_MESSAGE.Altitude) {
if(FILE_MESSAGE.Altitude!=0) v->FILE_MESSAGE.Altitude=FILE_MESSAGE.Altitude;
}
if(v->FILE_MESSAGE.Kelly!=FILE_MESSAGE.Kelly) {
if(FILE_MESSAGE.Kelly!=0) v->FILE_MESSAGE.Kelly=FILE_MESSAGE.Kelly;
}
if(v->FILE_MESSAGE.TVD!=FILE_MESSAGE.TVD) {
if(FILE_MESSAGE.TVD!=0) v->FILE_MESSAGE.TVD=FILE_MESSAGE.TVD;
}
if(v->FILE_MESSAGE.X0!=FILE_MESSAGE.X0) {
if(FILE_MESSAGE.X0!=0) v->FILE_MESSAGE.X0=FILE_MESSAGE.X0;
}
if(v->FILE_MESSAGE.Y0!=FILE_MESSAGE.Y0) {
if(FILE_MESSAGE.Y0!=0) v->FILE_MESSAGE.Y0=FILE_MESSAGE.Y0;
}
if(v->FILE_MESSAGE.Z0!=FILE_MESSAGE.Z0) {
if(FILE_MESSAGE.Z0!=0) v->FILE_MESSAGE.Z0=FILE_MESSAGE.Z0;
}
int indexSTable=-1;
int indexDTable=-1;
if(logio->FindObjectIndex("井基本信息")>-1) {
WELL_STATIC_INFO WellStaticInfo=v->WellStaticInfo;
indexSTable=logio->OpenSTATIC("井基本信息");
logio->ReadTable(indexSTable,1,&v->WellStaticInfo);//inf);
if(v->WellStaticInfo.XCoor!=WellStaticInfo.XCoor) {
if(WellStaticInfo.XCoor!=0) v->WellStaticInfo.XCoor=WellStaticInfo.XCoor;
}
if(v->WellStaticInfo.YCoor!=WellStaticInfo.YCoor) {
if(WellStaticInfo.YCoor!=0) v->WellStaticInfo.YCoor=WellStaticInfo.YCoor;
}
if(v->WellStaticInfo.As1!=WellStaticInfo.As1) {
if(WellStaticInfo.As1!=0) v->WellStaticInfo.As1=WellStaticInfo.As1;
}
if(v->WellStaticInfo.Bs1!=WellStaticInfo.Bs1) {
if(WellStaticInfo.Bs1!=0) v->WellStaticInfo.Bs1=WellStaticInfo.Bs1;
}
logio->CloseTable(indexSTable);
}
if(logio->FindObjectIndex("测井信息")>-1) {
WELL_DYNAMIC_INFO WellDynamicInfo;
indexDTable=logio->OpenDYNAMIC("测井信息");
logio->ReadTable(indexDTable,1,&v->WellDynamicInfo);//inf);
logio->CloseTable(indexDTable);
}
}
delete logio;
//v->Transfer(logfilename,outfile,&OutCurveNo[0],&OutCurve[0],&strChineseName[0],&strUnit[0],iRow);
//whp change 2019.12.10 for写入井名
if(v->Transfer(logfilename,outfile,&OutCurveNo[0],&OutCurve[0],&strChineseName[0],&strUnit[0],iRow))
{
CLogIO * logio=new CLogIO();
logio->Open(outfile,CSlfIO::modeReadWrite);
Slf_FILE_MESSAGE mssage;
logio->GetFileMessage(mssage);
strcpy(mssage.WellName,WellName.toStdString().c_str());
logio->SetFileMessage(mssage);
delete logio;
}
else return "";//whp add 2019.12.12
//whp change 2020.2.18 for 汉字井名转换有乱码
QString slfname=QString(QString::fromLocal8Bit(outfile));//QString(QLatin1String(outfile));
delete []logfilename;
delete []outfile;
//return 1;////whp add 2019.12.08 for 输出成功加载的文件个数
return slfname;//whp change 2019.12.12
}
QStringList CDataImport::GetFileNames(const QString &caption , const QString &filter,QFileDialog::FileMode filemode )
{
static QString path=::GetDataPath();
QStringList sts=QFileDialog::getOpenFileNames(NULL,caption,path,filter);
if(sts.size()) path=sts[0];
return sts;
// QFileDialog * fileDlg=new QFileDialog();
// fileDlg->setFileMode(filemode);
// QStringList listFiles;
// if(fileDlg->exec()==QFileDialog::Accepted)
// {
// listFiles=fileDlg->selectedFiles();
// }
// delete fileDlg;
// return listFiles;
}
void CDataImport::OutPutWellXYCoordinate()
{
// //井名 磁偏角 南北(小) 东西(大) 测量深度 地面海拔 补心高 TVD 东西位移 南北位移
// //a 0 4394427.9 19308473.9 0 1446.9 0 0 0 0
// //b 0 4394427.9 19308473.9 0 1446.9 0 0 0 0
// //c 0 4398164.3 19306076.3 0 1436.5 0 0 0 0
// //d 0 4398270.1 19311098.4 0 1437.5 0 0 0 0
// //e 0 4392057.3 19305209.1 0 1461.3 0 0 0 0
// QString strFileName =QFileDialog::getSaveFileName( NULL,"导出工区井坐标为TXT",::GetOutDataPath(),"文件(*.txt)");
// FILE *fp=fopen(strFileName.toStdString().c_str(),"wt");
// if(!fp) return;
// fprintf(fp,"磁偏角 南北(小) 东西(大) 测量深度 地面海拔 补心高 TVD 东西位移 南北位移\m");
// int flag=0;
// CObjProject *pPrj=::GetProject();
// if(!pPrj) return;
// PaiObject *pObj=pPrj->GetObjectByType(GetClassID_WellsFolder());
// if(!pObj) return;
// QList<PaiObject *> childs;
// pObj->GetChildren(childs);
// std::vector<QString> wellnames;
// foreach(PaiObject *pChild,childs) {
// CObjWell *pWell=dynamic_cast<CObjWell*>(pChild);
// if(pWell)
// {
// QString ss=pWell->GetWellFileName();
// QString wellname,path;
// GetWellNameAndPath(ss,wellname,path);
// WellHead &hd=pWell->GetWellHead();
// fprintf(fp,"%s\t%10.3f\t%10.3f\t%10.3f\t%10.3f\t%10.3f\t%10.3f\t%10.3f\t%10.3f\t%10.3f\t\n",
// hd.wellName.toStdString().c_str(),
// //井名 磁偏角 南北(小) 东西(大) 测量深度 地面海拔 补心高 TVD 东西位移 南北位移
// hd.azca,
// hd.x,
// hd.y,
// hd.depth,
// hd.earthEle,
// hd.dEle,
// hd.tvd,
// hd._HorizBoreXE,
// hd._HorizBoreYN);
// }
// }
// fclose(fp);
// QMessageBox::warning(NULL,"提示",QString("井位信息保存完成!"));
}
void CDataImport::ImportWellXYCoordinate()
{
// //井名 磁偏角 南北(小) 东西(大) 测量深度 地面海拔 补心高 TVD 东西位移 南北位移
// //a 0 4394427.9 19308473.9 0 1446.9 0 0 0 0
// //b 0 4394427.9 19308473.9 0 1446.9 0 0 0 0
// //c 0 4398164.3 19306076.3 0 1436.5 0 0 0 0
// //d 0 4398270.1 19311098.4 0 1437.5 0 0 0 0
// //e 0 4392057.3 19305209.1 0 1461.3 0 0 0 0
// QStringList listFiles=GetFileNames("选择工区井井位信息","数据文件(*.prn;*.txt)");
// if(!listFiles.size())
// {
// return;
// }
// int flag=0;
// foreach(QString strFileName, listFiles)
// {
// QFile file(strFileName);
// if (!file.open(QIODevice::ReadOnly ))
// {
// continue;
// }
// flag=0;
// QTextStream in(&file);
// QString lineString = in.readLine();
// QStringList LineStringList = lineString.split(",");
// if(LineStringList.size()==1) LineStringList = lineString.split(" ");
// if(LineStringList.size()==1) LineStringList = lineString.split(" ");
// LineStringList.removeAll("");
// LineStringList.removeAll(" ");
// for (int i=0;i<LineStringList.size();i++)
// {
// while(LineStringList[i].indexOf("\t")>-1) LineStringList[i]=LineStringList[i].replace("\t","");
// LineStringList[i]=LineStringList[i].trimmed();
// }
// QString strWellName=LineStringList[0];
// if(strWellName.indexOf("wellname",0,Qt::CaseInsensitive)>=0||
// strWellName.indexOf("井名",0,Qt::CaseInsensitive)>=0
// ) {
// flag=1;
// }
// while ( !in.atEnd() )
// {
// lineString = in.readLine();
// if(lineString.isEmpty()) continue;
// LineStringList = lineString.split(",");
// if(LineStringList.size()==1) LineStringList = lineString.split(" ");
// if(LineStringList.size()==1) LineStringList = lineString.split(" ");
// LineStringList.removeAll("");
// LineStringList.removeAll(" ");
// for (int i=0;i<LineStringList.size();i++)
// {
// while(LineStringList[i].indexOf("\t")>-1) LineStringList[i]=LineStringList[i].replace("\t","");
// LineStringList[i]=LineStringList[i].trimmed();
// }
// if(LineStringList.size()<1) continue;
// LineStringList.replaceInStrings("-9999.0","0");
// LineStringList.replaceInStrings("-9999","0");
// if(flag) {
// CObjWell * pWell = CDataImport::GetWellByName(LineStringList[0]);
// if(!pWell) continue;
// //井名 磁偏角 南北(小) 东西(大) 测量深度 地面海拔 补心高 TVD 东西位移 南北位移
// // 0 1 2 3 4 5 6 7 8 9
// WellHead &wh=pWell->GetWellHead();
// if(LineStringList.size()>1)wh.azca=LineStringList[1].toDouble();
// if(LineStringList.size()>2)wh.y=LineStringList[2].toDouble();
// if(LineStringList.size()>3)wh.x=LineStringList[3].toDouble();
// if(LineStringList.size()>4)wh.depth=LineStringList[4].toDouble();
// if(LineStringList.size()>5)wh.earthEle=LineStringList[5].toDouble();
// if(LineStringList.size()>6){
// wh.dEle=LineStringList[6].toDouble();
// if(wh.dEle==-9999) wh.dEle=0;
// }
// if(LineStringList.size()>7)wh.tvd=LineStringList[7].toDouble();
// if(LineStringList.size()>8)wh.dyn=LineStringList[8].toDouble();
// if(LineStringList.size()>9)wh.dxe=LineStringList[9].toDouble();
// wh.z=wh.earthEle-wh.tvd+wh.dEle;
// if(pWell->GetWellFileName().isEmpty()) {
// QString fi=GetLogdataPath()+GetProject()->GetName()+"\\#"+LineStringList[0];
// CreateDir((char *)fi.toStdString().c_str());
// fi+="\\"+LineStringList[0]+".slf";
// pWell->SetWellFileName(fi);
// }
// pWell->SaveWellHead(pWell->GetWellFileName());
// QList<PaiObject*> wellroundchildren;
// int count=pWell->GetAllWellRound(wellroundchildren);
// for(int i=0;i<count;i++) {
// CObjWelllogRound *pWR=dynamic_cast<CObjWelllogRound *>(wellroundchildren[i]);
// pWell->SaveWellHead(pWR->GetSlfFileName());
// }
// }
// else {
// }
// }
// }
// AfxMessageBox("导入完成!");
}
void CDataImport::ImportGeoStraData()
{
// QStringList listFiles=GetFileNames("选择工区层位数据","数据文件(*.prn;*.txt)");
// if(listFiles.size()<1) return;
// int flag=0;
// std::vector<QString> wellNameVec;
// QList<QString> layerNameVec;
// std::vector<float> topDetphVec;
// std::vector<float> bottomDepthVec;
// foreach(QString strFileName, listFiles)
// {
// QFile file(strFileName);
// if (!file.open(QIODevice::ReadOnly ))
// {
// continue;
// }
// flag=0;
// QTextStream in(&file);
// QString lineString = in.readLine();
// QStringList LineStringList = lineString.split(",");
// if(LineStringList.size()==1) LineStringList = lineString.split(" ");
// if(LineStringList.size()==1) LineStringList = lineString.split(" ");
// LineStringList.removeAll("");
// LineStringList.removeAll(" ");
// for (int i=0;i<LineStringList.size();i++)
// {
// while(LineStringList[i].indexOf("\t")>-1) LineStringList[i]=LineStringList[i].replace("\t","");
// LineStringList[i]=LineStringList[i].trimmed();
// }
// if(LineStringList.size()<1) continue;
// QString strWellName = LineStringList[0] ;
// if(strWellName.indexOf("wellname",0,Qt::CaseInsensitive)>=0||
// strWellName.indexOf("井名",0,Qt::CaseInsensitive)>=0
// ) {
// flag=1;
// for(int i=1;i<LineStringList.size();i++) {
// if(i<2&&layerNameVec.indexOf(LineStringList[i])>-1) {
// flag=2;
// continue;
// }
// layerNameVec.push_back(LineStringList[i]);
// }
// }
// while ( !in.atEnd() )
// {
// lineString = in.readLine();
// LineStringList = lineString.split(",");
// if(LineStringList.size()==1) LineStringList = lineString.split(" ");
// if(LineStringList.size()==1) LineStringList = lineString.split(" ");
// LineStringList.removeAll(" ");
// LineStringList.removeAll("");
// for (int i=0;i<LineStringList.size();i++)
// {
// while(LineStringList[i].indexOf("\t")>-1) LineStringList[i]=LineStringList[i].replace("\t","");
// LineStringList[i]=LineStringList[i].trimmed();
// }
// if(LineStringList.size()<1) continue;
// if(flag) {
// wellNameVec.push_back(LineStringList[0]);
// if(flag==1) {
// for(int i=2;i<LineStringList.size();i++) {
// topDetphVec.push_back(LineStringList[i-1].toFloat());
// bottomDepthVec.push_back(LineStringList[i].toFloat());
// }
// }
// else {
// for(int i=1;i<layerNameVec.size()*2;i+=2) {
// if(LineStringList.size()<=i) continue;
// topDetphVec.push_back(LineStringList[i].toFloat());
// bottomDepthVec.push_back(LineStringList[i+1].toFloat());
// }
// }
// }
// else {
// wellNameVec.push_back(LineStringList[0]);
// layerNameVec.push_back(LineStringList[1]);
// topDetphVec.push_back(LineStringList[2].toFloat());
// bottomDepthVec.push_back(LineStringList[3].toFloat());
// }
// }
// }
// for(int i=0;i<wellNameVec.size();i++)
// {
// CObjWell * pWell = CDataImport::GetWellByName(wellNameVec[i]);
// if(!pWell) continue;
// if(pWell->GetWellFileName().isEmpty()) {
// QString fi=GetLogdataPath()+GetProject()->GetName()+"\\#"+wellNameVec[i];
// CreateDir((char *)fi.toStdString().c_str());
// fi+="\\"+wellNameVec[i]+".slf";
// pWell->SetWellFileName(fi);
// }
// CObjGeostratums* pGeostratum = dynamic_cast<CObjGeostratums*>(pWell->GetObjectByType(GetClassID_OGGeostratums(), 2));
// if(!pGeostratum) {
// pGeostratum = new CObjGeostratums();
// pGeostratum->SetName("LAYER_DATA");
// pWell->AddChild( pGeostratum );
// }
// if (flag1==QMessageBox::Yes) {
// pGeostratum->ClearItems();
// }
// pGeostratum->SetSlfFileName(pWell->GetWellFileName());
// int index = 0;
// if(flag) {
// int size=layerNameVec.size()-1;
// if(flag==2) size=layerNameVec.size();
// for(int j=0;j<size;j++) {
// float top=topDetphVec[i*(size)+j];
// float bottom=bottomDepthVec[i*(size)+j];
// if(top==-9999||bottom==-9999) continue;
// pai::datamodel::WelllogItem* pItem =pGeostratum->GetItemByName(layerNameVec[j]);
// if(!pItem) {
// pItem = pGeostratum->AddItem(top,bottom);
// OGGeostratumItem * pGeoItem = dynamic_cast<OGGeostratumItem*>(pItem);
// if(pGeoItem) {
// pGeoItem->SetName(layerNameVec[j]);
// pGeoItem->SetDEST(layerNameVec[j]);
// pGeoItem->SetSDEP(top);
// pGeoItem->SetEDEP(bottom);
// }
// }
// else {
// OGGeostratumItem * pGeoItem = dynamic_cast<OGGeostratumItem*>(pItem);
// {
// pGeoItem->SetTopDepth(top);
// pGeoItem->SetBottomDepth(bottom);
// pGeoItem->SetSDEP(top);
// pGeoItem->SetEDEP(bottom);
// pGeoItem->SetDEST(layerNameVec[j]);
// }
// }
// }
// }
// else {
// if(topDetphVec[i]==-9999||bottomDepthVec[i]==-9999) continue;
// pai::datamodel::WelllogItem* pItem =pGeostratum->GetItemByName(layerNameVec[i]);
// if(!pItem) {
// pItem = pGeostratum->AddItem(topDetphVec[i],bottomDepthVec[i]);
// OGGeostratumItem * pGeoItem = dynamic_cast<OGGeostratumItem*>(pItem);
// pGeoItem->SetName(layerNameVec[i]);
// pGeoItem->SetDEST(layerNameVec[i]);
// pGeoItem->SetSDEP(topDetphVec[i]);
// pGeoItem->SetEDEP(bottomDepthVec[i]);
// }
// else {
// OGGeostratumItem * pGeoItem = dynamic_cast<OGGeostratumItem*>(pItem);
// pGeoItem->SetTopDepth(topDetphVec[i]);
// pGeoItem->SetBottomDepth(bottomDepthVec[i]);
// pGeoItem->SetSDEP(topDetphVec[i]);
// pGeoItem->SetEDEP(bottomDepthVec[i]);
// pGeoItem->SetDEST(layerNameVec[i]);
// }
// }
// pGeostratum->SaveToSLF();
// }
// AfxMessageBox("导入分层完成!");
}
void CDataImport::OutPutGeoStraData()
{
// QString strFileName =QFileDialog::getSaveFileName( NULL,"输出层位数据为TXT",::GetOutDataPath(),
// "文件(*.txt)");
// int flag=0;
// std::vector<QString> wellNameVec;
// std::vector<QString> layerNameVec;
// std::vector<float> topDetphVec;
// std::vector<float> bottomDepthVec;
// CObjProject *pPrj=::GetProject();
// if(!pPrj) return;
// PaiObject *pObj=pPrj->GetObjectByType(GetClassID_WellsFolder());
// if(!pObj) return;
// QList<PaiObject *> childs;
// pObj->GetChildren(childs);
// QStringList LayerNameVec;
// std::vector<QStringList>LayerNameVecS;
// std::vector<std::vector<float>> TopDepthVecS;
// std::vector<std::vector<float>> BottomDepthVecS;
// std::vector<QString> wellnames;
// foreach(PaiObject *pChild,childs) {
// CObjWell *pWell=dynamic_cast<CObjWell*>(pChild);
// if(pWell) {
// QString ss=pWell->GetWellFileName();
// if(!ss.isEmpty()) {
// QString name="LAYER_DATA";
// LAYER_DATA m_Result;
// CLogIO *logio=new CLogIO();
// if(!logio->Open(ss.toStdString().c_str(),CSlfIO::modeRead))
// {
// delete logio;
// return;
// }
// int iIndex=logio->OpenTable(name.toStdString().c_str());
// if (iIndex >=0)
// {
// wellnames.push_back(pWell->GetName());
// QStringList layerNameVec;
// std::vector<float> TopDepthVec;
// std::vector<float> BottomDepthVec;
// int count=logio->GetTableRecordCount(iIndex);
// for(int j=0;j<count;j++) {
// memset(&m_Result,0,sizeof(LAYER_DATA));
// logio->ReadTable(iIndex,j+1,&m_Result);
// char buf[490];
// GetDescription(m_Result,buf);
// if(!strlen(buf)) continue;
// if(!LayerNameVec.contains(buf)) LayerNameVec.append(buf);
// layerNameVec.append(buf);
// TopDepthVec.push_back(m_Result.StartDepth);
// BottomDepthVec.push_back(m_Result.EndDepth);
// }
// LayerNameVecS.push_back(layerNameVec);
// TopDepthVecS.push_back(TopDepthVec);
// BottomDepthVecS.push_back(BottomDepthVec);
// }
// delete logio;
// }
// }
// }
// FILE *fp=fopen(strFileName.toStdString().c_str(),"wt");
// if(!fp) return;
// fprintf(fp,"%s","wellname\t");
// for(int j=0;j<LayerNameVec.size();j++) {
// fprintf(fp,"%s\t%s",LayerNameVec[j].toStdString().c_str(),LayerNameVec[j].toStdString().c_str());
// if(j!=LayerNameVec.size()-1) fprintf(fp,"%s","\t");
// else fprintf(fp,"%s","\n");
// }
// for(int i=0;i<wellnames.size();i++) {
// fprintf(fp,"%s\t",wellnames[i].toStdString().c_str());
// for(int j=0;j<LayerNameVec.size();j++) {
// int pos=LayerNameVecS[i].indexOf(LayerNameVec[j]);
// if(pos>-1) {
// // if(j!=LayerNameVec.size())
// fprintf(fp,"%10.3f\t%10.3f",TopDepthVecS[i][pos],BottomDepthVecS[i][pos]);
// // else fprintf(fp,"%10.3f",BottomDepthVecS[i][pos]);
// }
// else fprintf(fp,"%10.3f\t%10.3f",-9999.0,-9999.0);
// if(j!=LayerNameVec.size()-1) fprintf(fp,"%s","\t");
// else fprintf(fp,"%s","\n");
// }
// }
// fclose(fp);
// QMessageBox::warning(NULL,"提示",QString("分层数据保存完成!"));
}
// END_OSGGRAPHICS_NAMESPACE