logplus/DataOutput/src/Slf2FileDlg.cpp

1234 lines
46 KiB
C++
Raw Normal View History

2025-10-29 17:23:30 +08:00
#pragma warning(push,0)
// #include "Family.h"
#include <QMessageBox>
#include "TranSlf2Data.h"
#include "Slf2FileDlg.h"
#include "ui_SLf2File.h"
2025-10-29 17:23:30 +08:00
#include "CStringType.h"
#include "LogIO.h"
#include "qfileinfo.h"
#include "qfiledialog.h"
#include "geometryutils.h"
2025-10-29 17:23:30 +08:00
#include "SetOutDepParDlg.h"
#include <QApplication>
#include "CheckHeadView.h"
#include "NameMapDlg.h"
#pragma warning(pop)
// using namespace pai::ios::welllog;
BEGIN_OSGGRAPHICS_NAMESPACE
CSlf2FileDlg::CSlf2FileDlg(QWidget * parent, Qt::WindowFlags flags)
: QDialog(parent,flags)
,m_bFirstShowWellname(true)
{
QString Ext[10]={"TXT","TXT","LAS","XLS","Wis","XTF","LIS","WLD","dat","dlis"};
for(int i=0;i<9;i++)ExtName[i]=Ext[i];
m_pUI = new Ui_Slf2File();
m_pUI->setupUi(this);
m_pUI->tableWidget->setMouseTracking(true);
QObject::connect(m_pUI->okbtn, SIGNAL(clicked()), this, SLOT(slotSave()));
// QObject::connect(m_pUI->cancelbtn, SIGNAL(clicked()), this, SLOT(slotCancel()));
QObject::connect(m_pUI->checkBox_Curve, SIGNAL(clicked()), this, SLOT(slotCheckCurve()));
QObject::connect(m_pUI->checkBox_Wave, SIGNAL(clicked()), this, SLOT(slotCheckWave()));
QObject::connect(m_pUI->checkBox_Table, SIGNAL(clicked()), this, SLOT(slotCheckTable()));
QObject::connect(m_pUI->checkBox_Stream, SIGNAL(clicked()), this, SLOT(slotCheckPar()));
QObject::connect(m_pUI->checkBox_Other, SIGNAL(clicked()), this, SLOT(slotCheckOther()));
QObject::connect(m_pUI->lineEdit_OutDir, SIGNAL(textChanged( QString )),this,SLOT(slotChangeOutDir(QString)));
QObject::connect(m_pUI->checkBox_AllObject, SIGNAL(clicked()), this, SLOT(slotAllCheck()));
QObject::connect(m_pUI->buttonGroup, SIGNAL(buttonClicked (int)), this, SLOT(slotbuttonJudge(int)) );
QObject::connect(m_pUI->buttonGroup_2, SIGNAL(buttonClicked (int)), this, SLOT(slotbuttonJudge2(int)) );
QObject::connect(m_pUI->buttonGroup_4, SIGNAL(buttonClicked (int)), this, SLOT(slotbuttonJudge4(int)));
QObject::connect(m_pUI->pushButton_SetDir, SIGNAL(clicked()), this, SLOT(slotSetDir()) );
QObject::connect(m_pUI->tableWidget, SIGNAL(cellClicked(int,int)), this, SLOT(slotGetCell(int,int)));//改变选择井文件,刷新文件对象列表
QObject::connect(m_pUI->tableWidget_2, SIGNAL(cellClicked(int,int)), this, SLOT(slotGetCell2(int,int)));//交互定制模板时,点中最后一列时用列表框显示当前行包含数据对象文件列表
QObject::connect(m_pUI->pushButtonSetDepPar, SIGNAL(clicked()), this, SLOT(slotSetOutDepPar()) );
//whp 2019.12.28
QObject::connect(m_pUI->pushButton_SelAll, SIGNAL(clicked()), this, SLOT(slotSelAll()));
QObject::connect(m_pUI->pushButton_NotSelAll, SIGNAL(clicked()), this, SLOT(slotNotSelAll()));
QObject::connect(m_pUI->pushButton_ReSel, SIGNAL(clicked()), this, SLOT(slotReverseSel()));
QObject::connect(m_pUI->pushButton_NameMap, SIGNAL(clicked()), this, SLOT(slotNameMap()));
QString FormatName[10]={"LogPlus文本格式","Forward 文本格式","LAS格式","Excel格式","Forward Wis格式","XTF格式","LIS格式","胜利LPS格式","地质DAT格式","DLIS格式"};
//whp 2019.12.28暂且只放开前8个
for(int i=0;i<9;i++)m_pUI->comboBox->addItem(FormatName[i]);
m_pUI->buttonGroup->setId(m_pUI->radioButton_DepthUnit_M,0);
m_pUI->buttonGroup->setId(m_pUI->radioButton_DepthUnit_Feet,1);
m_pUI->buttonGroup_2->setId(m_pUI->radioButton_NoDir,0);
m_pUI->buttonGroup_2->setId(m_pUI->radioButton_ByDir,1);
m_pUI->buttonGroup_4->setId(m_pUI->radioButton_AllObj,0);
m_pUI->buttonGroup_4->setId(m_pUI->radioButton_Interactive,1);
m_pUI->buttonGroup_4->setId(m_pUI->radioButton_Manual,2);
m_pUI->radioButton_DepthUnit_M->setChecked(1);
m_pUI->radioButton_NoDir->setChecked(1);
m_pUI->radioButton_AllObj->setChecked(1);
m_pUI->comboBox->setMaxVisibleItems(8);
//m_pUI->comboBox->setCurrentIndex(0);
m_pUI->checkBox_AllObject->setCheckState(Qt::Unchecked);
m_pUI->checkBox_Curve->setCheckState(Qt::Checked);
m_pUI->checkBox_Wave->setCheckState(Qt::Unchecked);
// m_pUI->checkBox_Table->setCheckState(Qt::Unchecked);
m_pUI->checkBox_Stream->setCheckState(Qt::Unchecked);
m_RlevIsCheck=0;
m_EdepIsCheck=0;
m_SdepIsCheck=0;
m_CurveIsCheck=1;
m_WaveIsCheck=0;
m_TableIsCheck=0;
m_ParIsCheck=0;
m_OtherIsCheck=0;
m_AllIsCheck=0;
m_Rlev=0.125;
m_Sdep=-99999;
m_Edep=99999;
FormatType=0;
DirFlag=0;
UnitFlag=0;
OutFlag=0;
QFileInfo rFileInfo(::GetOutDataPath());
QString WellName = rFileInfo.completeBaseName()+"_";
QString PathName=rFileInfo.absolutePath()+"\/";
DirName=::GetOutDataPath();//GetProjectFolder();
ProjectDirName=::GetOutDataPath();//::GetProjectFolder();
m_pUI->lineEdit_OutDir->setText(DirName);//初始化输出路径
//m_pUI->tableWidget->setRowCount(10); //设置行数为10
m_pUI->tableWidget->setColumnCount(11); //设置列数为8
m_pUI->tableWidget->setWindowTitle("Well Information");
m_pUI->tableWidget->setColumnWidth(0,120);m_pUI->tableWidget->setColumnWidth(1,400);
for(int i=2;i<10;i++)m_pUI->tableWidget->setColumnWidth(i,72);
//m_pUI->tableWidget->resize(1200,300);//设置表格
2025-10-29 17:23:30 +08:00
//m_pUI->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
QStringList header;
header<<"Slf\n文件名"<<"输出路径\n及文件名"<<"输出\n起始深度"<<"输出\n终止深度"<<"输出\n采样间距"<<"最小\n起始深度"<<"最大\n起始深度"<<"最小\n结束深度"<<"最大\n结束深度"<<"最小\n采样间隔"<<"最大\n采样间隔";
m_pUI->tableWidget->setHorizontalHeaderLabels(header);
m_pUI->tableWidget->horizontalHeader()->resizeSections(QHeaderView::Stretch);
m_pUI->tableWidget->horizontalHeader()->setSectionResizeMode(1,QHeaderView::ResizeToContents);
#pragma region 表头重画为勾选
QVector<int> rVector;
rVector << 0;// <<2 ;
CheckHeadView* pCheckHeadView = new CheckHeadView(rVector,Qt::Horizontal,m_pUI->tableWidget);
auto pCheckBox=pCheckHeadView->GetCheckBox(0);
if(pCheckBox)
{
pCheckBox->setChecked(true);
}
m_pUI->tableWidget->setHorizontalHeader(pCheckHeadView);
connect(pCheckHeadView, SIGNAL(SignalStatus(int, bool)), this, SLOT(slotSelAllWell(int, bool)));
#pragma endregion 表头重画为勾选
// m_pUI->tableWidget_2->horizontalHeader()->resizeSections(QHeaderView::Stretch);
//设置颜色
QPalette pa;
pa.setColor(QPalette::WindowText,Qt::red);
m_pUI->label_4->setPalette(pa);
slotbuttonJudge4(0);
//changeFormattype();
m_pUI->lineEdit_OutObj->setText("GR AC RT RLS");
//m_pUI->lineEdit_OutObj->setEnabled(false);
m_pUI->lineEdit_OutObj->setStyleSheet("QLineEdit:!enabled {background: #e6e6e6}");
// m_pUI->lineEdit_OutDir->setStyleSheet("QLineEdit:!enabled {background: #e6e6e6}");
QObject::connect(m_pUI->comboBox, SIGNAL(currentIndexChanged(int)),this, SLOT(changeFormattype(int)));
m_pUI->comboBox->setCurrentIndex(0);
changeFormattype(0);
}
CSlf2FileDlg::~CSlf2FileDlg()
{
}
void CSlf2FileDlg::slotbuttonJudge(int id)
{
UnitFlag=id;
}
void CSlf2FileDlg::slotbuttonJudge2(int id)
{
DirFlag=id;
SetOutNameList();
}
void CSlf2FileDlg::slotbuttonJudge4(int id)
{
m_pUI->tableWidget_2->horizontalHeader()->resizeSections(QHeaderView::Stretch);
int oldId=OutFlag;
OutFlag=id;
if(OutFlag==2)m_pUI->lineEdit_OutObj->setEnabled(true);
else m_pUI->lineEdit_OutObj->setEnabled(false);
if(OutFlag==1)
{
//m_pUI->tableWidget_2->setEnabled(true);
m_pUI->pushButton_SelAll->setEnabled(true);
m_pUI->pushButton_NotSelAll->setEnabled(true);
m_pUI->pushButton_ReSel->setEnabled(true);
m_pUI->pushButton_NameMap->setEnabled(true);
}
else
{
//m_pUI->tableWidget_2->setEnabled(false);
m_pUI->pushButton_SelAll->setEnabled(false);
m_pUI->pushButton_NotSelAll->setEnabled(false);
m_pUI->pushButton_ReSel->setEnabled(false);
m_pUI->pushButton_NameMap->setEnabled(false);
}
//if(m_pUI->tableWidget->rowCount()>1)
{
if(oldId-id==1||oldId-id==-1)
{
SetObjectNameList();//0<->1,or 1<->2,多文件、单文件显示切换
}
}
}
void CSlf2FileDlg::SetDepInfo(QString wellname,int Row)
{
outsdep=99999,outedep=-99999,outrlev=0;
CLogIO mrw;
int op=mrw.Open(wellname.toStdString().c_str(),CSlfIO::modeRead);
if (!op)return;
int ObjectCount = mrw.GetObjectCount();
if (ObjectCount == 0)
{
mrw.Close();
return;
}
float minsdep=minedep=minrlev=99999,maxsdep=maxedep=maxrlev=-99999;
for(int i=0;i<ObjectCount;i++)
{
if(mrw.GetObjectStatus(i)==OBJECT_DISCARD||mrw.GetObjectStatus(i)==OBJECT_DELETE)continue;
char Name[200];
mrw.GetObjectName(i,Name);
if(strstr(Name,"%")==NULL)
{
if(mrw.GetObjectType(i)==CURVE_OBJECT)
{
int index=mrw.OpenCurve(Name);
Slf_CURVE pInfo;
mrw.GetCurveInfo(index,&pInfo);
if(minsdep>pInfo.StartDepth)minsdep=pInfo.StartDepth;
if(maxsdep<pInfo.StartDepth)maxsdep=pInfo.StartDepth;
if(minedep>pInfo.EndDepth)minedep=pInfo.EndDepth;
if(maxedep<pInfo.EndDepth)maxedep=pInfo.EndDepth;
if(minrlev>pInfo.DepLevel)minrlev=pInfo.DepLevel;
if(maxrlev<pInfo.DepLevel)maxrlev=pInfo.DepLevel;
}
else if(mrw.GetObjectType(i)==WAVE_OBJECT)
{
// int index=mrw.OpenCurve(Name);
int index=mrw.OpenWave(Name);
Slf_WAVE pInfo;
mrw.GetWaveInfo(index,&pInfo);
if(minsdep>pInfo.StartDepth)minsdep=pInfo.StartDepth;
if(maxsdep<pInfo.StartDepth)maxsdep=pInfo.StartDepth;
if(minedep>pInfo.EndDepth)minedep=pInfo.EndDepth;
if(maxedep<pInfo.EndDepth)maxedep=pInfo.EndDepth;
if(minrlev>pInfo.DepLevel)minrlev=pInfo.DepLevel;
if(maxrlev<pInfo.DepLevel)maxrlev=pInfo.DepLevel;
}
}
//pObjectEntry++;
}
//delete []pObjectEntry;
outsdep=minsdep;outedep=maxedep,outrlev=maxrlev;
mrw.Close();
m_pUI->tableWidget->setItem(Row,2,new QTableWidgetItem("original"/*QString("%1").arg(outsdep)*/));
m_pUI->tableWidget->setItem(Row,3,new QTableWidgetItem("original"/*QString("%1").arg(outedep)*/));
m_pUI->tableWidget->setItem(Row,4,new QTableWidgetItem("original"/*QString("%1").arg(outrlev)*/));
m_pUI->tableWidget->setItem(Row,5,new QTableWidgetItem(QString("%1").arg(minsdep)));
m_pUI->tableWidget->setItem(Row,6,new QTableWidgetItem(QString("%1").arg(maxsdep)));
m_pUI->tableWidget->setItem(Row,7,new QTableWidgetItem(QString("%1").arg(minedep)));
m_pUI->tableWidget->setItem(Row,8,new QTableWidgetItem(QString("%1").arg(maxedep)));
m_pUI->tableWidget->setItem(Row,9,new QTableWidgetItem(QString("%1").arg(minrlev)));
m_pUI->tableWidget->setItem(Row,10,new QTableWidgetItem(QString("%1").arg(maxrlev)));
m_pUI->tableWidget->item(Row,5)->setTextColor(QColor(100,100,100));
m_pUI->tableWidget->item(Row,6)->setTextColor(QColor(100,100,100));
m_pUI->tableWidget->item(Row,7)->setTextColor(QColor(100,100,100));
m_pUI->tableWidget->item(Row,8)->setTextColor(QColor(100,100,100));
m_pUI->tableWidget->item(Row,9)->setTextColor(QColor(100,100,100));
m_pUI->tableWidget->item(Row,10)->setTextColor(QColor(100,100,100));
for(int col=5;col<11;col++)m_pUI->tableWidget->item(Row, col)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
}
void CSlf2FileDlg::slotCheckCurve()
{
//m_CurveIsCheck=!m_CurveIsCheck;
changeFormattype(0);
//SetObjectNameList();
}
void CSlf2FileDlg::slotCheckWave()
{
//m_WaveIsCheck=!m_WaveIsCheck;
changeFormattype(0);
//SetObjectNameList();
}
void CSlf2FileDlg::slotCheckTable()
{
//m_TableIsCheck=!m_TableIsCheck;
changeFormattype(0);
//SetObjectNameList();
}
void CSlf2FileDlg::slotCheckPar()
{
// m_ParIsCheck=!m_ParIsCheck;
changeFormattype(0);
//SetObjectNameList();
}
void CSlf2FileDlg::slotCheckOther()
{
// m_OtherIsCheck=!m_OtherIsCheck;
changeFormattype(0);
//SetObjectNameList();
}
void CSlf2FileDlg::slotAllCheck()
{
//m_AllIsCheck=!m_AllIsCheck;
m_AllIsCheck=(m_pUI->checkBox_AllObject->checkState()==Qt::Unchecked)?0:1;
if(m_AllIsCheck)
{
m_pUI->checkBox_Curve->setCheckState(Qt::Checked);
m_pUI->checkBox_Wave->setCheckState(Qt::Checked);
m_pUI->checkBox_Table->setCheckState(Qt::Checked);
m_pUI->checkBox_Stream->setCheckState(Qt::Checked);
m_pUI->checkBox_Other->setCheckState(Qt::Checked);
m_pUI->checkBox_AllObject->setCheckState(Qt::Checked);
m_CurveIsCheck=1;m_WaveIsCheck=1;m_TableIsCheck=1;m_ParIsCheck=1;m_OtherIsCheck=1;
}else m_pUI->checkBox_AllObject->setCheckState(Qt::Unchecked);
changeFormattype(0);
}
void CSlf2FileDlg::SetOutNameList()
{
if(!m_pUI->tableWidget->rowCount())return;
int n=m_pUI->tableWidget->rowCount();
for(int i=0;i<m_pUI->tableWidget->rowCount();i++)
{
QString wellname=nameList.at(i);//m_pUI->tableWidget->item(i,0)->text();
QString outname;
if(DirFlag==0)outname=DirName+WellNamelist.at(i)+"."+ExtName[FormatType];//集中存放
else
{
outname=DirName+WellNamelist.at(i)+"/"+WellNamelist.at(i)+"."+ExtName[FormatType];//按井次存放
}
QDir dir(outname);
outname=dir.absolutePath();
for(int j=0;j<i;j++)
{
QString name=m_pUI->tableWidget->item(j,1)->text();
if(name==outname)
{
QFileInfo rFileInfo(outname);
QString WellName = rFileInfo.completeBaseName()+"_";
QString PathName=rFileInfo.absolutePath()+"\/";
QString slfname=nameList.at(i);
CLogIO mrw;
int op=mrw.Open(slfname.toStdString().c_str(),CSlfIO::modeRead);
Slf_FILE_MESSAGE mes;
mrw.GetFileMessage(mes);
mrw.Close();
outname=PathName+WellName+QString::fromLocal8Bit(mes.WellName)+"."+ExtName[FormatType];
break;
}
}
m_pUI->tableWidget->setItem(i,1,new QTableWidgetItem(outname));
if(m_bFirstShowWellname){
if(m_pUI->tableWidget->rowCount()==1)m_pUI->tableWidget->item(i,0)->setCheckState(Qt::Checked);
else m_pUI->tableWidget->item(i,0)->setCheckState(Qt::Unchecked);
}
m_pUI->tableWidget->item(i, 0)->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsSelectable|Qt::ItemIsEnabled);
}
m_bFirstShowWellname =false;
}
void CSlf2FileDlg::SetObjectNameList()//显示选中的井文件对象
{
//whp 2019.12.28
m_CurveIsCheck=(m_pUI->checkBox_Curve->checkState()==Qt::Unchecked)?0:1;
m_WaveIsCheck=(m_pUI->checkBox_Wave->checkState()==Qt::Unchecked)?0:1;
m_TableIsCheck=(m_pUI->checkBox_Table->checkState()==Qt::Unchecked)?0:1;
m_ParIsCheck=(m_pUI->checkBox_Stream->checkState()==Qt::Unchecked)?0:1;
m_OtherIsCheck=(m_pUI->checkBox_Other->checkState()==Qt::Unchecked)?0:1;
m_pUI->tableWidget_2->clear();
//对象名称列表
int ColNum=9;
if(OutFlag==1&&m_pUI->tableWidget->rowCount()>1) ColNum=8;
m_pUI->tableWidget_2->setColumnCount(ColNum); //设置列数
m_pUI->tableWidget_2->setWindowTitle("Object Information");
//for(int i=0;i<ColNum;i++)m_pUI->tableWidget_2->setColumnWidth(i,100);
QStringList header;
if(OutFlag==0||OutFlag==2||m_pUI->tableWidget->rowCount()==1)header<<"对象名称"<<"输出名称"<<"输出别名"<<"输出单位"<<"单位别名"<<"对象类型"<<"起始深度"<<"终止深度"<<"采样间隔";
else header<<"对象名称"<<"输出名称"<<"输出别名"<<"输出单位"<<"单位别名"<<"对象类型"<<"井次数"<<"井名/井次名";
m_pUI->tableWidget_2->setHorizontalHeaderLabels(header);
//m_pUI->tableWidget_2->horizontalHeader()->resizeSections(QHeaderView::Stretch);
if(OutFlag==1&&m_pUI->tableWidget->rowCount()>1)
{
//for(int nn=0;nn<ColNum-2;nn++)
//m_pUI->tableWidget_2->horizontalHeader()->setResizeMode(nn, QHeaderView::Stretch);//ResizeToContents);
//m_pUI->tableWidget_2->horizontalHeader()->setResizeMode(ColNum-1, QHeaderView::ResizeToContents);
//if(m_pUI->tableWidget_2->columnWidth(ColNum-1)<280)m_pUI->tableWidget_2->setColumnWidth(ColNum-1,280);
}
m_pUI->tableWidget_2->setRowCount(0);
m_pUI->tableWidget_2->clearContents();
int Row=0;
if(OutFlag==0||OutFlag==2||m_pUI->tableWidget->rowCount()==1)
{
if(OutFlag==1)m_pUI->tableWidget_2->setEditTriggers(QAbstractItemView::AllEditTriggers);
else m_pUI->tableWidget_2->setEditTriggers(QAbstractItemView::NoEditTriggers);//不能对表格内容进行修改
QString name=currentWellName;
int index=name.lastIndexOf("/");
int index1=name.lastIndexOf("\\");
if(index1>index) {
index=index1;
}
name=name.mid(index+1);
m_pUI->label_4->setText("当前选中文件"+name+"数据信息列表");
CLogIO mrw;
int op=mrw.Open(currentWellName.toStdString().c_str(),CSlfIO::modeRead);
if (!op)return;
int ObjectCount = mrw.GetObjectCount();
if (ObjectCount == 0)
{
mrw.Close();
return;
}
m_pUI->tableWidget_2->setRowCount(ObjectCount);
if(m_CurveIsCheck)//常规曲线
{
for(int i=0;i<ObjectCount;i++)
{
if(mrw.GetObjectStatus(i)==OBJECT_DISCARD||mrw.GetObjectStatus(i)==OBJECT_DELETE)continue;
char Name[200];
mrw.GetObjectName(i,Name);
if(strcmp(Name,"X")==0||strcmp(Name,"Y")==0||strcmp(Name,"Z")==0)continue;
if(mrw.GetObjectType(i)==CURVE_OBJECT)
{
int index=mrw.OpenCurve(Name);
Slf_CURVE curve;
mrw.GetCurveInfo(index,&curve);
m_pUI->tableWidget_2->setItem(Row,0,new QTableWidgetItem(QString(QLatin1String(curve.Name))));
m_pUI->tableWidget_2->setItem(Row,1,new QTableWidgetItem(QString(QLatin1String(curve.Name))));
m_pUI->tableWidget_2->setItem(Row,2,new QTableWidgetItem(QString::fromLocal8Bit(curve.AliasName)));
m_pUI->tableWidget_2->setItem(Row,3,new QTableWidgetItem(QString::fromLocal8Bit(curve.Unit)));
m_pUI->tableWidget_2->setItem(Row,4,new QTableWidgetItem(QString::fromLocal8Bit(curve.AliasUnit)));
m_pUI->tableWidget_2->setItem(Row,5,new QTableWidgetItem("常规曲线"));
m_pUI->tableWidget_2->setItem(Row,6,new QTableWidgetItem(QString("%1").arg(curve.StartDepth)));
m_pUI->tableWidget_2->setItem(Row,7,new QTableWidgetItem(QString("%1").arg(curve.EndDepth)));
m_pUI->tableWidget_2->setItem(Row,8,new QTableWidgetItem(QString("%1").arg(curve.DepLevel)));
//for(int m=0;m<9;m++)m_pUI->tableWidget_2->item(Row,m)->setFlags(m_pUI->tableWidget_2->item(Row,m)->flags()&(Qt::ItemIsEnabled));
//不起作用
m_pUI->tableWidget_2->item(Row,5)->setTextColor(QColor(100,100,100));
m_pUI->tableWidget_2->item(Row,6)->setTextColor(QColor(100,100,100));
m_pUI->tableWidget_2->item(Row,7)->setTextColor(QColor(100,100,100));
m_pUI->tableWidget_2->item(Row,8)->setTextColor(QColor(100,100,100));
// m_pUI->tableWidget_2->item(Row,5)->setBackgroundColor(QColor(255,0,0));
Row++;
}
}
}
if(m_WaveIsCheck)//阵列曲线
{
for(int i=0;i<ObjectCount;i++)
{
if(mrw.GetObjectStatus(i)==OBJECT_DISCARD||mrw.GetObjectStatus(i)==OBJECT_DELETE)continue;
char Name[200];
mrw.GetObjectName(i,Name);
if(mrw.GetObjectType(i)==WAVE_OBJECT)
{
int index=mrw.OpenWave(Name);
Slf_WAVE curve;
mrw.GetWaveInfo(index,&curve);
m_pUI->tableWidget_2->setItem(Row,0,new QTableWidgetItem(QString(QLatin1String(curve.Name))));
m_pUI->tableWidget_2->setItem(Row,1,new QTableWidgetItem(QString(QLatin1String(curve.Name))));
m_pUI->tableWidget_2->setItem(Row,2,new QTableWidgetItem(QString::fromLocal8Bit(curve.AliasName)));
m_pUI->tableWidget_2->setItem(Row,3,new QTableWidgetItem(QString::fromLocal8Bit(curve.Unit)));
m_pUI->tableWidget_2->setItem(Row,4,new QTableWidgetItem(QString::fromLocal8Bit(curve.AliasUnit)));
m_pUI->tableWidget_2->setItem(Row,5,new QTableWidgetItem("阵列曲线"));
m_pUI->tableWidget_2->setItem(Row,6,new QTableWidgetItem(QString("%1").arg(curve.StartDepth)));
m_pUI->tableWidget_2->setItem(Row,7,new QTableWidgetItem(QString("%1").arg(curve.EndDepth)));
m_pUI->tableWidget_2->setItem(Row,8,new QTableWidgetItem(QString("%1").arg(curve.DepLevel)));
Row++;
}
}
}
if(m_TableIsCheck)//数据表
{
for(int i=0;i<ObjectCount;i++)
{
if(mrw.GetObjectStatus(i)==OBJECT_DISCARD||mrw.GetObjectStatus(i)==OBJECT_DELETE)continue;
char Name[200];
mrw.GetObjectName(i,Name);
int Attribute=mrw.GetObjectType(i);
if(Attribute==0||Attribute>5)
{
char HZName[64];
Slf_OBJECT_ENTRY inf;
mrw.GetObjectEntry(i,&inf);
if(!mrw.IsWis) {
Slf_OBJECT_BASE_INF inf1;
mrw.GetSlfObjectBaseInf(i,&inf1);
strncpy(HZName,inf1.HZName,sizeof(HZName));
}
else {
strncpy(HZName,inf.Name,sizeof(HZName));
}
m_pUI->tableWidget_2->setItem(Row,0,new QTableWidgetItem(QString::fromLocal8Bit(Name)));
if(m_pUI->comboBox->currentText() == "胜利LPS格式" && (QString(Name) == "RESULT" || QString(Name) == "VRESULT"))
{
QComboBox *combox1 = new QComboBox();
combox1->addItem(QString(Name));
combox1->addItem(QString(Name) + "_CRA");
combox1->addItem(QString(Name) + "_PORP");
combox1->addItem(QString(Name) + "_PORTN");
m_pUI->tableWidget_2->setCellWidget(Row, 1, (QWidget*)combox1);
}
else m_pUI->tableWidget_2->setItem(Row,1,new QTableWidgetItem(QString::fromLocal8Bit(Name)));
m_pUI->tableWidget_2->setItem(Row,2,new QTableWidgetItem(QString::fromLocal8Bit(HZName)));
m_pUI->tableWidget_2->setItem(Row,3,new QTableWidgetItem(""));
m_pUI->tableWidget_2->setItem(Row,4,new QTableWidgetItem(""));
m_pUI->tableWidget_2->setItem(Row,5,new QTableWidgetItem("数据表"));
m_pUI->tableWidget_2->setItem(Row,6,new QTableWidgetItem(""));
m_pUI->tableWidget_2->setItem(Row,7,new QTableWidgetItem(""));
m_pUI->tableWidget_2->setItem(Row,8,new QTableWidgetItem(""));
Row++;
}
}
}
if(m_ParIsCheck)//参数
{
for(int i=0;i<ObjectCount;i++)
{
if(mrw.GetObjectStatus(i)==OBJECT_DISCARD||mrw.GetObjectStatus(i)==OBJECT_DELETE)continue;
char Name[200];
mrw.GetObjectName(i,Name);
if(mrw.GetObjectType(i)==CARD_OBJECT)
{
char HZName[64];
Slf_OBJECT_ENTRY inf;
mrw.GetObjectEntry(i,&inf);
if(!mrw.IsWis) {
Slf_OBJECT_BASE_INF inf1;
mrw.GetSlfObjectBaseInf(i,&inf1);
strncpy(HZName,inf1.HZName,sizeof(HZName));
}
else {
strncpy(HZName,inf.Name,sizeof(HZName));
}
m_pUI->tableWidget_2->setItem(Row,0,new QTableWidgetItem(QString::fromLocal8Bit(Name)));
m_pUI->tableWidget_2->setItem(Row,1,new QTableWidgetItem(QString::fromLocal8Bit(Name)));
m_pUI->tableWidget_2->setItem(Row,2,new QTableWidgetItem(QString::fromLocal8Bit(HZName)));
m_pUI->tableWidget_2->setItem(Row,3,new QTableWidgetItem(""));
m_pUI->tableWidget_2->setItem(Row,4,new QTableWidgetItem(""));
m_pUI->tableWidget_2->setItem(Row,5,new QTableWidgetItem("参数对象"));
m_pUI->tableWidget_2->setItem(Row,6,new QTableWidgetItem(""));
m_pUI->tableWidget_2->setItem(Row,7,new QTableWidgetItem(""));
m_pUI->tableWidget_2->setItem(Row,8,new QTableWidgetItem(""));
Row++;
}
}
}
if(m_OtherIsCheck)//Fmt Tdt
{
for(int i=0;i<ObjectCount;i++)
{
if(mrw.GetObjectStatus(i)==OBJECT_DISCARD||mrw.GetObjectStatus(i)==OBJECT_DELETE)continue;
int Attribute=mrw.GetObjectType(i);
if(Attribute==FMT_OBJECT||Attribute==TDT_OBJECT)
{
Slf_CHANNEL chinfo;
char Name[64];
char HZName[64];
Slf_OBJECT_ENTRY inf;
mrw.GetObjectEntry(i,&inf);
if(!mrw.IsWis) {
Slf_OBJECT_BASE_INF inf1;
mrw.GetSlfObjectBaseInf(i,&inf1);
strncpy(Name,inf1.Name,sizeof(Name));
strncpy(HZName,inf1.HZName,sizeof(HZName));
}
else {
strncpy(Name,inf.Name,sizeof(Name));
strncpy(HZName,inf.Name,sizeof(HZName));
}
m_pUI->tableWidget_2->setItem(Row,0,new QTableWidgetItem(QString::fromLocal8Bit(Name)));
m_pUI->tableWidget_2->setItem(Row,1,new QTableWidgetItem(QString::fromLocal8Bit(Name)));
m_pUI->tableWidget_2->setItem(Row,2,new QTableWidgetItem(QString::fromLocal8Bit(HZName)));
m_pUI->tableWidget_2->setItem(Row,3,new QTableWidgetItem(""));
m_pUI->tableWidget_2->setItem(Row,4,new QTableWidgetItem(""));
if(mrw.GetObjectType(i)==FMT_OBJECT)m_pUI->tableWidget_2->setItem(Row,5,new QTableWidgetItem("FMT曲线"));
else m_pUI->tableWidget_2->setItem(Row,5,new QTableWidgetItem("TDT曲线"));
m_pUI->tableWidget_2->setItem(Row,6,new QTableWidgetItem(""));
m_pUI->tableWidget_2->setItem(Row,7,new QTableWidgetItem(""));
m_pUI->tableWidget_2->setItem(Row,8,new QTableWidgetItem(""));
Row++;
}
}
}
if(OutFlag!=1)
{
for (int i=0;i<Row;i++)
{
m_pUI->tableWidget_2->item(i,5)->setTextAlignment(Qt::AlignHCenter);
m_pUI->tableWidget_2->item(i,0)->setCheckState(Qt::PartiallyChecked);//Checked);
m_pUI->tableWidget_2->item(i,0)->setFlags(m_pUI->tableWidget_2->item(i,0)->flags()&(Qt::ItemIsEnabled));//不让勾选
}
}
else
{
for (int i=0;i<Row;i++)
{ m_pUI->tableWidget_2->item(i,5)->setTextAlignment(Qt::AlignHCenter);
m_pUI->tableWidget_2->item(i,0)->setCheckState(Qt::Checked);
for (int j=5;j<m_pUI->tableWidget_2->columnCount();j++)m_pUI->tableWidget_2->item(i,j)->setFlags(m_pUI->tableWidget_2->item(i,j)->flags()&(Qt::ItemIsEnabled));//不让勾选
}
}
mrw.Close();
}
else//多井
{
m_pUI->label_4->setText("上述所有勾选文件数据信息列表");
int ObjectCount=CurveMap.size()+WaveMap.size()+TableMap.size()+ParMap.size()+OtherMap.size();
m_pUI->tableWidget_2->setRowCount(ObjectCount);
m_pUI->tableWidget_2->setEditTriggers(QAbstractItemView::AllEditTriggers);//能对表格内容进行修改
if(m_CurveIsCheck)AddWidgetLine(CurveMap,&Row,"常规曲线");
if(m_WaveIsCheck)AddWidgetLine(WaveMap,&Row,"二维曲线");
if(m_TableIsCheck)AddWidgetLine(TableMap,&Row,"数据表");
if(m_ParIsCheck)AddWidgetLine(ParMap,&Row,"参数卡");
if(m_OtherIsCheck)AddWidgetLine(OtherMap,&Row,"其他数据");
}
m_pUI->tableWidget_2->setRowCount(Row);
}
void CSlf2FileDlg::AddWidgetLine(QMap<QString,WellMap> CurveMap,int *iRow,QString TypeName)
{
int Row=*iRow;
for(auto rIter = CurveMap.begin();rIter!=CurveMap.end();++rIter)
{//"对象名称"<<"输出名称"<<"输出别名"<<"输出单位"<<"单位别名"<<"对象类型"<<"包含该数据的井_井次名";
m_pUI->tableWidget_2->setItem(Row,0,new QTableWidgetItem(rIter.key()));
m_pUI->tableWidget_2->setItem(Row,1,new QTableWidgetItem(rIter.key()));
m_pUI->tableWidget_2->setItem(Row,2,new QTableWidgetItem(rIter.key()));
m_pUI->tableWidget_2->setItem(Row,3,new QTableWidgetItem(""));
m_pUI->tableWidget_2->setItem(Row,4,new QTableWidgetItem(""));
m_pUI->tableWidget_2->setItem(Row,5,new QTableWidgetItem(TypeName));
m_pUI->tableWidget_2->item(Row,5)->setTextAlignment(Qt::AlignHCenter);
WellMap mMap=rIter.value();
//if(m_pUI->tableWidget->rowCount()>1)
{
//QApplication::processEvents();
// QComboBox *comboBox = new QComboBox();
QString str="";
int wellNum=0;
for(auto wIter = mMap.begin();wIter!=mMap.end();++wIter)
{
if(wIter.value())
{
// comboBox->addItem(wIter.key());
if(wellNum)str+=",";
str+=wIter.key();
wellNum++;
}
}
if(!wellNum)continue;
m_pUI->tableWidget_2->setItem(Row,6,new QTableWidgetItem(QString::number(wellNum)));
m_pUI->tableWidget_2->setItem(Row,7,new QTableWidgetItem(str));
//comboBox->setCurrentIndex(0);
//comboBox->setProperty("row",Row);
//comboBox->setProperty("col",7);
//m_pUI->tableWidget_2->setCellWidget(Row,7, comboBox );
}
/*else
{
auto wIter=mMap.begin();
m_pUI->tableWidget_2->setItem(Row,7,new QTableWidgetItem(wIter.key()));
m_pUI->tableWidget_2->setItem(Row,6,new QTableWidgetItem("1"));
}*/
m_pUI->tableWidget_2->item(Row,0)->setCheckState(Qt::Checked);
m_pUI->tableWidget_2->item(Row,5)->setFlags(m_pUI->tableWidget_2->item(Row,5)->flags()&(Qt::ItemIsEnabled));
m_pUI->tableWidget_2->item(Row,6)->setFlags(m_pUI->tableWidget_2->item(Row,6)->flags()&(Qt::ItemIsEnabled));
m_pUI->tableWidget_2->item(Row,7)->setFlags(m_pUI->tableWidget_2->item(Row,7)->flags()&(Qt::ItemIsEnabled));
Row++;
}
*iRow=Row;
}
void CSlf2FileDlg::changeFormattype(int)
{
/* if (!m_pUI->comboBox->isActiveWindow())
{
return;
}*/
FormatType=m_pUI->comboBox->currentIndex();
//SetOutNameList();
if(FormatType==4)//wis
{
m_pUI->checkBox_AllObject->setEnabled(true);
m_pUI->checkBox_Wave->setEnabled(1);
//m_pUI->checkBox_Table->setEnabled(1);
m_pUI->checkBox_Stream->setEnabled(1);
m_pUI->checkBox_Other->setEnabled(1);
}
else if(FormatType==7) //LPS
{
m_pUI->checkBox_AllObject->setEnabled(true);
m_pUI->checkBox_Wave->setEnabled(1);
//m_pUI->checkBox_Table->setEnabled(1);
m_pUI->checkBox_Stream->setEnabled(1);
m_pUI->checkBox_Other->setEnabled(0);
if(FormatType==1||FormatType==3)//forwardtxt、excel不输出波列
{
//m_pUI->checkBox_Curve->setCheckState(Qt::Checked);
m_pUI->checkBox_Wave->setCheckState(Qt::Unchecked);
m_pUI->checkBox_Wave->setEnabled(0);
}
else
{
m_pUI->checkBox_Wave->setEnabled(1);
}
}
else
{
m_pUI->checkBox_AllObject->setEnabled(false);
//m_pUI->checkBox_Table->setEnabled(0);
m_pUI->checkBox_Stream->setEnabled(0);
m_pUI->checkBox_Other->setEnabled(0);
//m_pUI->checkBox_Table->setCheckState(Qt::Unchecked);
m_pUI->checkBox_Stream->setCheckState(Qt::Unchecked);
m_pUI->checkBox_Other->setCheckState(Qt::Unchecked);
if(FormatType==1||FormatType==3)//forwardtxt、excel不输出波列
{
//m_pUI->checkBox_Curve->setCheckState(Qt::Checked);
m_pUI->checkBox_Wave->setCheckState(Qt::Unchecked);
m_pUI->checkBox_Wave->setEnabled(0);
}
else
{
m_pUI->checkBox_Wave->setEnabled(1);
}
}
m_CurveIsCheck=(m_pUI->checkBox_Curve->checkState()==Qt::Unchecked)?0:1;
m_WaveIsCheck=(m_pUI->checkBox_Wave->checkState()==Qt::Unchecked)?0:1;
m_TableIsCheck=(m_pUI->checkBox_Table->checkState()==Qt::Unchecked)?0:1;
m_ParIsCheck=(m_pUI->checkBox_Stream->checkState()==Qt::Unchecked)?0:1;
m_OtherIsCheck=(m_pUI->checkBox_Other->checkState()==Qt::Unchecked)?0:1;
if(!m_CurveIsCheck||!m_WaveIsCheck||!m_TableIsCheck||!m_ParIsCheck||!m_OtherIsCheck)
{
m_pUI->checkBox_AllObject->setCheckState(Qt::Unchecked);
}
//whp add 2020.5.25
for(int i=0;i<m_pUI->tableWidget->rowCount();i++)
{
QString wellname=nameList.at(i);//m_pUI->tableWidget->item(i,0)->text();
QString outname=m_pUI->tableWidget->item(i,1)->text();
int index=outname.lastIndexOf(".");
outname=outname.left(index+1)+ExtName[FormatType];
m_pUI->tableWidget->setItem(i,1,new QTableWidgetItem(outname));
}
//
SetObjectNameList();
//this->show();qApp->processEvents();
}
void CSlf2FileDlg::slotSave()
{
TypeName=m_pUI->comboBox->currentText();
execOutputWellLog(nameList);
// accept();
}
/**
*@brief
*/
void CSlf2FileDlg::slotCancel()
{
reject ();
}
void CSlf2FileDlg::outWellLogRound(const QStringList& nameList1,
const QStringList& curveList)
{
nameList=nameList1;
if(curveList.size() > 0)
{
m_pUI->lineEdit_OutObj->setText(curveList.join(" "));
m_pUI->radioButton_Manual->setChecked(1);
m_pUI->lineEdit_OutObj->setEnabled(true);
OutFlag=2;
}
m_pUI->tableWidget->setRowCount(nameList.size()); //设置行数为10
int size=nameList.size();
QString ExtName[10]={"TXT","TXT","LAS","XLS","Wis","XTF","LIS","WLD","dat","dlis"};
//int FormatType=m_pUI->comboBox->currentIndex();
float outsdep=0,outedep=0,outrlev=0;
for(int i=0;i<nameList.size();i++)
{
QString name=nameList[i];
int index=name.lastIndexOf("/");
int index1=name.lastIndexOf("\\");
if(index1>index) {
index=index1;
}
name=name.mid(index+1);
m_pUI->tableWidget->setItem(i,0,new QTableWidgetItem(name));//nameList.at(i)));
QString wellname=nameList.at(i);
SetDepInfo(wellname,i);
name=name.left(name.lastIndexOf("."));
WellNamelist.append(name);
}
#pragma region 多文件信息统计
#pragma endregion 多文件信息统计
FormatType=m_pUI->comboBox->currentIndex();
SetOutNameList();
currentWellName=nameList[0];
SetObjectNameList();
// execOutputWellLog(nameList);
}
void CSlf2FileDlg::execOutputWellLog(const QStringList& namelist)
{
BOOL m_RlevIsCheck=0;
BOOL m_EdepIsCheck=0;
BOOL m_SdepIsCheck=0;
BOOL m_CurveIsCheck=1;
BOOL m_WaveIsCheck=1;
BOOL m_TableIsCheck=1;
BOOL m_ParIsCheck=1;
BOOL m_OtherIsCheck=1;
float m_Rlev=0.125;
float m_Sdep=-99999;
float m_Edep=99999;
int FormatType=m_pUI->comboBox->currentIndex(); //输出格式
OUTOBJECTINF OutInf[1024];
bool IsCheck[6];//0-4输出对象选择开关IsCheck[5]输出深度选项开关0-公制1-英制
IsCheck[0]=m_pUI->checkBox_Curve->isChecked();
IsCheck[1]=m_pUI->checkBox_Wave->isChecked();
IsCheck[2]=m_pUI->checkBox_Table->isChecked();
IsCheck[3]=m_pUI->checkBox_Stream->isChecked();
IsCheck[4]=m_pUI->checkBox_Other->isChecked();
IsCheck[5]=UnitFlag;//输出深度选项开关0-公制1-英制
QStringList Outnamelist; //需要输出的slf名
QMap<QString,vector<QString> > OutFileInfVec;
vector<QString > temp;
temp.reserve(4);//outname,sdep,edep,rlev
for(int i = 0; i < namelist.size(); i++)
{
if(m_pUI->tableWidget->item(i,0)->checkState()==Qt::Checked) {
QString wellname=namelist.at(i);
if(wellname.isEmpty()) continue;
QString outname=m_pUI->tableWidget->item(i,1)->text();
Outnamelist.append(outname);
OutFileInfVec.insert(wellname, temp);
if(m_pUI->tableWidget->item(i,1))
OutFileInfVec.find(wellname).value().push_back(m_pUI->tableWidget->item(i,1)->text());//输出文件名
else
OutFileInfVec.find(wellname).value().push_back("temp");
// if(!m_pUI->tableWidget->item(i,4)) continue;
if(m_pUI->tableWidget->item(i,2) && m_pUI->tableWidget->item(i,2) != new QTableWidgetItem("original"))
OutFileInfVec.find(wellname).value().push_back(m_pUI->tableWidget->item(i,2)->text());//sdep
else
OutFileInfVec.find(wellname).value().push_back("-9999.0");
if(m_pUI->tableWidget->item(i,3) && m_pUI->tableWidget->item(i,3) != new QTableWidgetItem("original"))
OutFileInfVec.find(wellname).value().push_back(m_pUI->tableWidget->item(i,3)->text());//edep
else
OutFileInfVec.find(wellname).value().push_back("-9999");
if(m_pUI->tableWidget->item(i,4) && m_pUI->tableWidget->item(i,4) != new QTableWidgetItem("original"))
OutFileInfVec.find(wellname).value().push_back(m_pUI->tableWidget->item(i,4)->text());//rlev
else
OutFileInfVec.find(wellname).value().push_back("-9999");
}
}
int NumObject=0;//可以定制输出曲线曲线条数NumObject曲线信息OutInf
if(OutFlag==2)//手工定制
{
QString OutObjName=m_pUI->lineEdit_OutObj->text();
OutObjName.replace(","," ");
OutObjName=OutObjName.simplified();
QStringList OutObjNameList=OutObjName.split(" ");
NumObject=OutObjNameList.size();
for(int i=0;i<NumObject;i++)
{
sprintf(OutInf[i].Name,"%s",OutObjNameList[i].toStdString().c_str());
sprintf(OutInf[i].OutName,"%s",OutObjNameList[i].toStdString().c_str());
sprintf(OutInf[i].AliasName,"%s",OutObjNameList[i].toStdString().c_str());
strcpy(OutInf[i].Unit,"");
strcpy(OutInf[i].AliasUnit,"");
OutInf[i].ObjectType=-1;
}
}
else if(OutFlag==1)//交互定制,按井曲线信息框制定方案输出
{
NumObject=0;
int Row=m_pUI->tableWidget_2->rowCount();
char Name[256];
for(int i=0;i<Row;i++)
{
if(m_pUI->tableWidget_2->item(i, 0)->checkState()==Qt::Checked)
{
strcpy(OutInf[NumObject].Name,m_pUI->tableWidget_2->item(i, 0)->text().toStdString().c_str());
if(m_pUI->comboBox->currentText() == "胜利LPS格式" && (QString(OutInf[NumObject].Name) == "RESULT" || QString(OutInf[NumObject].Name) == "VRESULT"))
{
QWidget *widget = m_pUI->tableWidget_2->cellWidget(i, 1);
QComboBox *combox = (QComboBox*)widget;
strcpy(OutInf[NumObject].OutName, combox->currentText().toStdString().c_str());
}
else strcpy(OutInf[NumObject].OutName,m_pUI->tableWidget_2->item(i, 1)->text().toStdString().c_str());
strcpy(OutInf[NumObject].AliasName,m_pUI->tableWidget_2->item(i, 2)->text().toStdString().c_str());
strcpy(OutInf[NumObject].Unit,m_pUI->tableWidget_2->item(i, 3)->text().toStdString().c_str());
strcpy(OutInf[NumObject].AliasUnit,m_pUI->tableWidget_2->item(i, 4)->text().toStdString().c_str());
OutInf[NumObject].ObjectType=-1;
QString ss=m_pUI->tableWidget_2->item(i, 5)->text();
if(ss=="常规曲线")OutInf[NumObject].ObjectType=CURVE_OBJECT;
else if(ss=="阵列曲线")OutInf[NumObject].ObjectType=WAVE_OBJECT;
else if(ss=="参数对象")OutInf[NumObject].ObjectType=CARD_OBJECT;
else if(ss=="FMT曲线")OutInf[NumObject].ObjectType=FMT_OBJECT;
else if(ss=="TDT曲线")OutInf[NumObject].ObjectType=TDT_OBJECT;
else if(ss=="数据表")OutInf[NumObject].ObjectType=0;
if(OutInf[NumObject].ObjectType==-1)AfxMessageBox("对象类型不对");
NumObject++;
}
}
}
else {
int Row=m_pUI->tableWidget_2->rowCount();
char Name[256];
for(int i=0;i<Row;i++)
{
strcpy(OutInf[i].Name,m_pUI->tableWidget_2->item(i, 0)->text().toStdString().c_str());
if(m_pUI->comboBox->currentText() == "胜利LPS格式" && (QString(OutInf[i].Name) == "RESULT" || QString(OutInf[i].Name) == "VRESULT"))
{
QWidget *widget = m_pUI->tableWidget_2->cellWidget(i, 1);
QComboBox *combox = (QComboBox*)widget;
strcpy(OutInf[i].OutName, combox->currentText().toStdString().c_str());
}
else strcpy(OutInf[i].OutName,m_pUI->tableWidget_2->item(i, 1)->text().toStdString().c_str());
strcpy(OutInf[i].AliasName,m_pUI->tableWidget_2->item(i, 2)->text().toStdString().c_str());
QString UNIT=m_pUI->tableWidget_2->item(i, 3)->text();
strcpy(OutInf[i].Unit,UNIT.toStdString().c_str());
strcpy(OutInf[i].AliasUnit,m_pUI->tableWidget_2->item(i, 4)->text().toStdString().c_str());
OutInf[i].ObjectType=-1;
QString ss=m_pUI->tableWidget_2->item(i, 5)->text();
if(ss=="常规曲线")OutInf[i].ObjectType=CURVE_OBJECT;
else if(ss=="阵列曲线")OutInf[i].ObjectType=WAVE_OBJECT;
else if(ss=="参数对象")OutInf[i].ObjectType=CARD_OBJECT;
else if(ss=="FMT曲线")OutInf[i].ObjectType=FMT_OBJECT;
else if(ss=="TDT曲线")OutInf[i].ObjectType=TDT_OBJECT;
else if(ss=="数据表")OutInf[i].ObjectType=0;
if(OutInf[i].ObjectType==-1)AfxMessageBox("对象类型不对");
}
}
// 3 深度信息 输出曲线信息 曲线数 1
TranSlf2Data(FormatType,OutFileInfVec,OutInf,IsCheck,NumObject,OutFlag,m_pUI->checkBox->checkState());
OutFileInfVec.clear();
}
void CSlf2FileDlg::slotSetCurrentDir()//输出文件单独存放在当前slf文件目录
{
for(int i=0;i<m_pUI->tableWidget->rowCount();i++)
{
QString wellname=nameList.at(i);//m_pUI->tableWidget->item(i,0)->text();
QString outname=wellname.left(wellname.length()-3)+ExtName[FormatType];
m_pUI->tableWidget->setItem(i,1,new QTableWidgetItem(outname));
}
}
void CSlf2FileDlg::slotSetProjectDir()//输出文件集中存放在Project目录
{
}
void CSlf2FileDlg::slotSetOutDepPar()
{
CSetOutDepParDlg *pDlg=new CSetOutDepParDlg(NULL);
if(pDlg->exec()==QDialog::Accepted)
{
QString sdep=pDlg->m_pUI->lineEdit_2->text();
QString edep=pDlg->m_pUI->lineEdit_3->text();
QString rlev=pDlg->m_pUI->lineEdit_4->text();
for(int i=0;i<m_pUI->tableWidget->rowCount();i++)
{
if(sdep!="-9999.0")m_pUI->tableWidget->setItem(i,2,new QTableWidgetItem(sdep));
if(edep!="-9999.0")m_pUI->tableWidget->setItem(i,3,new QTableWidgetItem(edep));
if(rlev!="-9999.0")m_pUI->tableWidget->setItem(i,4,new QTableWidgetItem(rlev));
}
}
}
void CSlf2FileDlg::slotSetDir()//输出文件集中存放在用户指定的目录
{
QString path;
path=QFileDialog::getExistingDirectory(NULL,"选择目录",DirName,QFileDialog::ShowDirsOnly);
if(path.isEmpty()) return ;
DirName=path+"\\";
m_pUI->lineEdit_OutDir->setText(DirName);
SetOutNameList();
}
void CSlf2FileDlg::slotChangeOutDir(QString path)
{
if(path.isEmpty()) return ;
DirName=path+"\\";
SetOutNameList();
}
void CSlf2FileDlg::slotGetCell(int row,int column)
{
CurveMap.clear();
WaveMap.clear();
TableMap.clear();
ParMap.clear();
OtherMap.clear();
m_WellAndRound.clear();
for(int i=0;i<nameList.size();i++)
{
QString name=nameList[i];
CLogIO mrw;
int op=mrw.Open(name.toStdString().c_str(),CSlfIO::modeRead);
Slf_FILE_MESSAGE mes;
if (op)mrw.GetFileMessage(mes);
//保证m_WellAndRound大小和nameList一致
QString m_WellAndRoundName=QString::fromLocal8Bit(mes.WellName)+"/"+WellNamelist[i];
m_WellAndRound.append(m_WellAndRoundName);
if (!op)continue;
if(m_pUI->tableWidget->item(i,0)->checkState()==Qt::Checked){
int ObjectCount = mrw.GetObjectCount();
if (ObjectCount == 0)
{
mrw.Close();
continue;
}
WellMap mMap;
mMap.insert(m_WellAndRoundName,true);
for(int i=0;i<ObjectCount;i++)
{
if(mrw.GetObjectStatus(i)==OBJECT_DISCARD||mrw.GetObjectStatus(i)==OBJECT_DELETE)continue;
char Name[200];
mrw.GetObjectName(i,Name);
QString nn=QString(Name);
if(strstr(Name,"%")!=NULL)continue;
if(mrw.GetObjectType(i)==CURVE_OBJECT)
{
auto rFind = CurveMap.find(QString(Name));
if(rFind==CurveMap.end())CurveMap.insert(QString(Name),mMap);//没找到
else rFind.value().insert(m_WellAndRoundName,true);//rFind.key();//找到
}
else if(mrw.GetObjectType(i)==WAVE_OBJECT)
{
auto rFind = WaveMap.find(QString(Name));
if(rFind==WaveMap.end())WaveMap.insert(QString(Name),mMap);//没找到
else rFind.value().insert(m_WellAndRoundName,true);//rFind.key();//找到
}
else if(mrw.GetObjectType(i)==FMT_OBJECT||mrw.GetObjectType(i)==TDT_OBJECT)
{
auto rFind = OtherMap.find(QString(Name));
if(rFind==OtherMap.end())OtherMap.insert(QString(Name),mMap);//没找到
else rFind.value().insert(m_WellAndRoundName,true);//rFind.key();//找到
}
else if(mrw.GetObjectType(i)==CARD_OBJECT)
{
auto rFind = ParMap.find(QString(Name));
if(rFind==ParMap.end())ParMap.insert(QString(Name),mMap);//没找到
else rFind.value().insert(m_WellAndRoundName,true);//rFind.key();//找到
}
else
{
auto rFind = TableMap.find(QString(Name));
if(rFind==TableMap.end())TableMap.insert(QString(Name),mMap);//没找到
else rFind.value().insert(m_WellAndRoundName,true);//rFind.key();//找到
}
}
}
mrw.Close();
}
currentWellName=nameList.at(row);//m_pUI->tableWidget->item(row,0)->text();
if(column==0)
{
if(m_pUI->tableWidget->item(row,column)->checkState()==Qt::Unchecked)
{
CheckHeadView* pCheckHeadView=(CheckHeadView*)m_pUI->tableWidget->horizontalHeader();
auto pCheckBox=pCheckHeadView->GetCheckBox(0);
if(pCheckBox)
{
if(pCheckBox->checkState()==Qt::Checked)pCheckBox->setChecked(false);
}
}
for(auto rIter = CurveMap.begin();rIter!=CurveMap.end();++rIter)
{
WellMap& mMap=rIter.value();
for(auto wIter = mMap.begin();wIter!=mMap.end();++wIter)
{
QString a=m_WellAndRound[row],b=wIter.key();
if(m_WellAndRound[row]==wIter.key())
{
if(m_pUI->tableWidget->item(row,0)->checkState()==Qt::Checked)wIter.value()=true;
else wIter.value()=false;
break;
}
}
}
for(auto rIter = WaveMap.begin();rIter!=WaveMap.end();++rIter)
{
WellMap& mMap=rIter.value();
for(auto wIter = mMap.begin();wIter!=mMap.end();++wIter)
{
QString a=m_WellAndRound[row],b=wIter.key();
if(m_WellAndRound[row]==wIter.key())
{
if(m_pUI->tableWidget->item(row,0)->checkState()==Qt::Checked)wIter.value()=true;
else wIter.value()=false;
break;
}
}
}
for(auto rIter = TableMap.begin();rIter!=TableMap.end();++rIter)
{
WellMap& mMap=rIter.value();
for(auto wIter = mMap.begin();wIter!=mMap.end();++wIter)
{
QString a=m_WellAndRound[row],b=wIter.key();
if(m_WellAndRound[row]==wIter.key())
{
if(m_pUI->tableWidget->item(row,0)->checkState()==Qt::Checked)wIter.value()=true;
else wIter.value()=false;
break;
}
}
}
for(auto rIter = ParMap.begin();rIter!=ParMap.end();++rIter)
{
WellMap& mMap=rIter.value();
for(auto wIter = mMap.begin();wIter!=mMap.end();++wIter)
{
QString a=m_WellAndRound[row],b=wIter.key();
if(m_WellAndRound[row]==wIter.key())
{
if(m_pUI->tableWidget->item(row,0)->checkState()==Qt::Checked)wIter.value()=true;
else wIter.value()=false;
break;
}
}
}
for(auto rIter = OtherMap.begin();rIter!=OtherMap.end();++rIter)
{
WellMap& mMap=rIter.value();
for(auto wIter = mMap.begin();wIter!=mMap.end();++wIter)
{
QString a=m_WellAndRound[row],b=wIter.key();
if(m_WellAndRound[row]==wIter.key())
{
if(m_pUI->tableWidget->item(row,0)->checkState()==Qt::Checked)wIter.value()=true;
else wIter.value()=false;
break;
}
}
}
SetObjectNameList();
}
}
void CSlf2FileDlg::slotGetCell2(int row,int column)
{
if(column!=7)return;
if(OutFlag!=1||m_pUI->tableWidget_2->rowCount()<=1)return;
int num=m_pUI->tableWidget_2->item(row,column-1)->text().toInt();
if(num==1)return;
QString str=m_pUI->tableWidget_2->item(row,column)->text();
QStringList strlist=str.split(",");
QComboBox *comboBox = new QComboBox();
for(int i=0;i<strlist.count();i++)
{
comboBox->addItem(strlist.at(i));
}
comboBox->setProperty("row",row);
comboBox->setProperty("col",column);
comboBox->setCurrentIndex(0);
m_pUI->tableWidget_2->setCellWidget(row,column, comboBox );
}
void CSlf2FileDlg::slotSelAll()
{
for(int i=0;i<m_pUI->tableWidget_2->rowCount();i++)m_pUI->tableWidget_2->item(i,0)->setCheckState(Qt::Checked);
}
void CSlf2FileDlg::slotSelAllWell(int col,bool flag)
{
for(int i=0;i<m_pUI->tableWidget->rowCount();i++)
{
if(flag)m_pUI->tableWidget->item(i,0)->setCheckState(Qt::Checked);
else m_pUI->tableWidget->item(i,0)->setCheckState(Qt::Unchecked);
slotGetCell(i,0);
}
}
void CSlf2FileDlg::slotNotSelAll()
{
for(int i=0;i<m_pUI->tableWidget_2->rowCount();i++)m_pUI->tableWidget_2->item(i,0)->setCheckState(Qt::Unchecked);
}
void CSlf2FileDlg::slotReverseSel()
{
for(int i=0;i<m_pUI->tableWidget_2->rowCount();i++)
{
Qt::CheckState eState= m_pUI->tableWidget_2->item(i,0)->checkState();
if (eState==Qt::Checked)m_pUI->tableWidget_2->item(i,0)->setCheckState(Qt::Unchecked);
else m_pUI->tableWidget_2->item(i,0)->setCheckState(Qt::Checked);
}
}
void CSlf2FileDlg::slotNameMap()
{
NameMapDlg nmDlg;
if(nmDlg.exec() == QDialog::Accepted)
{
QMap<QString, QString> nameMap = nmDlg.getNameMap();
int rNum = m_pUI->tableWidget_2->rowCount();
for(int i = 0; i < rNum; i++)
{
if(m_pUI->tableWidget_2->item(i, 0) == NULL) continue;
QString strKey = m_pUI->tableWidget_2->item(i, 0)->text();
if(nameMap.find(strKey) != nameMap.end())
{
m_pUI->tableWidget_2->item(i, 1)->setText(nameMap[strKey].trimmed());
m_pUI->tableWidget_2->item(i, 2)->setText(nameMap[strKey].trimmed());
}
}
}
}
void CSlf2FileDlg::resizeEvent(QResizeEvent *pEvent)
{
QDialog::resizeEvent(pEvent);
m_pUI->tableWidget->horizontalHeader()->resizeSections(QHeaderView::Stretch);
m_pUI->tableWidget->horizontalHeader()->setSectionResizeMode(1,QHeaderView::ResizeToContents);
m_pUI->tableWidget_2->horizontalHeader()->resizeSections(QHeaderView::Stretch);
}
void CSlf2FileDlg::showEvent(QShowEvent * pEvent)
{
QDialog::showEvent(pEvent);
// if(m_bFirstShow)
{
m_pUI->tableWidget->horizontalHeader()->resizeSections(QHeaderView::Stretch);
m_pUI->tableWidget->horizontalHeader()->setSectionResizeMode(1,QHeaderView::ResizeToContents);
m_pUI->tableWidget_2->horizontalHeader()->resizeSections(QHeaderView::Stretch);
//m_bFirstShow =false;
}
}
END_OSGGRAPHICS_NAMESPACE