logplus/logPlus/chooseShiftCurvesDlg.cpp

438 lines
15 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.

#pragma warning( push , 0 )
#include <QList>
#include "ui_chooseShiftCurves.h"
#include <QStandardItemModel>
#include <QDialog>
#include "chooseShiftCurvesDlg.h"
#include <QFileDialog>
#include "DataImport.h"
#include "ObjWelllog.h"
#include <QPushButton>
#include <QGridLayout>
#include <QLineEdit>
#include <QGroupBox>
#include <QHeaderView>
#include <QDebug>
#include "selectwelldialog.h"
///////////////////////////////////////////////////////////////
/// 表格的列,方便代码维护和修改
#ifndef T_ALL_COLUMN_COUNT_
/// 表格共有几列
#define T_ALL_COLUMN_COUNT_ 2
/// 是否选中对应的列
#define T_COLUMN_IS_CHECK_ 0
/// 井名称对应列
#define T_COLUMN_NAME_ 1
/// 表格共有几列
#define T_ALL_COLUMN_COUNT_ 3
/// 是否选中对应的列
#define T_COLUMN_IS_CHECK_ 0
/// 井名称对应列
#define T_COLUMN_NAME_ 1
/// 井东西方向坐标对应的列
#define T_COLUMN_OUTNAME_ 2
#endif
#pragma warning( pop )
extern QString g_prjname;
extern int g_SelectWellIndex;
QList<SelectTableItem> g_pShiftCurves;
CchooseShiftCurvesDlg::CchooseShiftCurvesDlg(QList<SelectTableItem> exnames, bool isHaveCurve)
:m_pDialog( NULL )
{
m_Names = exnames;
m_isHaveCurve = isHaveCurve;
m_pTableModel = NULL;
m_pDialog = new Ui_chooseShiftCurves();
m_pDialog->setupUi( this );
connect( m_pDialog->btn_Ok,SIGNAL(clicked()),this,SLOT(slotOnOkBtnClicked()) );
m_pDialog->btn_Ok->setIcon(QIcon( ::GetImagePath() + "icon/OK.png" ));
connect( m_pDialog->btn_Cancel,SIGNAL(clicked()),this,SLOT(slotOnCancelBtnClicked()));
m_pDialog->btn_Cancel->setIcon(QIcon( ::GetImagePath() + "icon/Cancel.png" ));
connect( m_pDialog->pushButton_3,SIGNAL(clicked()),this,SLOT(slotSelectAllClicked()));
connect( m_pDialog->pushButton_4,SIGNAL(clicked()),this,SLOT(slotCancelSelectClicked()));
connect( m_pDialog->pushButton_5,SIGNAL(clicked()),this,SLOT(slotSelectWellClicked()));
}
CchooseShiftCurvesDlg::~CchooseShiftCurvesDlg()
{
}
void CchooseShiftCurvesDlg::Init(QList<SelectTableItem> ShiftCurves)
{
g_pShiftCurves = ShiftCurves;
m_pTableModel = new QStandardItemModel();
m_pTableModel->setHorizontalHeaderItem(0, new QStandardItem("序号"));
m_pTableModel->setHorizontalHeaderItem(1, new QStandardItem("曲线名"));
m_pTableModel->setHorizontalHeaderItem(2, new QStandardItem("类型"));
m_pTableModel->setHorizontalHeaderItem(3, new QStandardItem("起始深度"));
m_pTableModel->setHorizontalHeaderItem(4, new QStandardItem("终止深度"));
m_pDialog->tableView->setModel(m_pTableModel);
}
void CchooseShiftCurvesDlg::slotOnOkBtnClicked()
{
g_pShiftCurves.clear();
int nRowCount = m_pTableModel->rowCount();
for(int i = 0; i < nRowCount; i++)
{
if(m_pTableModel->item(i,T_COLUMN_IS_CHECK_)->checkState()==Qt::Checked) {
SelectTableItem tmpCurve;
tmpCurve.m_iTableType=0;
tmpCurve.m_strUuid = "";
tmpCurve.m_strWellName = m_strWellName;
tmpCurve.m_strSlfName=m_strSlfName;
tmpCurve.m_strTrackName="";
tmpCurve.m_strLineName=m_pTableModel->item(i,T_COLUMN_NAME_)->text();
tmpCurve.m_strFormInfoType="";
int curvetype = m_pTableModel->item(i,T_COLUMN_NAME_)->data().toInt();
if(curvetype>CARD_OBJECT || 0 == curvetype)
{
//表格数据
tmpCurve.m_strFormInfoType = "tableObject";
}
else if(CURVE_OBJECT == curvetype)
{
//曲线
tmpCurve.m_strFormInfoType = "curveObject";
}
else if(CARD_OBJECT == curvetype)
{
//参数卡
}
else if(WAVE_OBJECT == curvetype)
{
//波列
tmpCurve.m_strFormInfoType = "waveObject";
}
else if(TDT_OBJECT == curvetype)
{
//TDT-》树图
}
g_pShiftCurves.append(tmpCurve);
}
}
this->accept();
}
void CchooseShiftCurvesDlg::slotOnCancelBtnClicked()
{
this->reject();
}
void CchooseShiftCurvesDlg::slotSelectAllClicked()
{
for(int i = 0; i < m_pTableModel->rowCount(); i++)
{
m_pTableModel->item(i,T_COLUMN_IS_CHECK_)->setCheckState( Qt::Checked );
}
}
void CchooseShiftCurvesDlg::slotSelectWellClicked()
{
QStringList listSlf;
QStringList listWell;
//直方图获取当前工程下的slf
QVector<QString> vecSlfList;
QVector<QString> vecWellList;
bool bRet = getAllSlf(g_prjname, vecSlfList, vecWellList);
if(bRet)
{
for(int i=0; i<vecWellList.size(); i++)
{
listWell.append(vecWellList[i]);
listSlf.append(vecSlfList[i]);
}
}
if(listWell.size()<=0)
{
QMessageBox::warning(this, "提示", "没有可选择井", "确定");
return;
}
// 创建对话框
SelectWellDialog *dlg = new SelectWellDialog(nullptr);
dlg->setInfo(listWell, listSlf);
//
dlg->setAttribute(Qt::WA_DeleteOnClose);//关闭时,自动删除窗口对象
int result = dlg->exec();//模态对话框
if (result == QDialog::Accepted) {
// 处理用户点击了确定按钮的逻辑
qDebug() << "Accepted=";
SetTableView(listWell[g_SelectWellIndex], listSlf[g_SelectWellIndex]);
}
else if (result == QDialog::Rejected) {
// 处理用户点击了取消按钮的逻辑
qDebug() << "Rejected=";
}
else {
// 处理其他情况的逻辑
qDebug() << "other=";
}
// CQtDataTreeDialog dialog;
// dialog.exec();
// SetTableView(listWell[g_SelectWellIndex], listSlf[g_SelectWellIndex]);
}
void CchooseShiftCurvesDlg::SetTableView(QString strWellName, QString fileFull)
{
m_strSlfName = fileFull;
m_strWellName = strWellName;
if(!m_pTableModel) return;
//先清空
m_pTableModel->clear();
CLogIO * logio=new CLogIO();
if(!logio->Open(fileFull.toStdString().c_str(),CSlfIO::modeRead))
{
delete logio;
QString aa=fileFull+"文件打开失败,请检查!";
qDebug() << aa;
//AppendConsole(pai::log::PAI_ERROR,aa);
return;
}
else
{
Slf_FILE_MESSAGE mssage;
logio->GetFileMessage(mssage);
if(strWellName != QString(QString::fromLocal8Bit(mssage.WellName)))
{
delete logio;
return;
}
char* curvename=new char[65];
curvename[64]='\0';
char* aliasname=new char[65];
aliasname[64]='\0';
//
int nSlfCount = logio->GetObjectCount();
//
int iCount = nSlfCount;
if(m_Names.size()>0)
{
QString slf=m_Names[0].m_strSlfName;
slf.replace("\\","/");
QString slf1=fileFull;
slf1.replace("\\","/");
if(slf1.compare(slf,Qt::CaseInsensitive)==0)
{
if(m_Names[0].m_strWellName == strWellName)
{
iCount = nSlfCount-m_Names.size();
}
}
}
m_pTableModel->setRowCount(iCount);
int iIndex = 0;
for(int i = 0; i< nSlfCount; i++)
{
float sdep=0, edep=0;
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);
QString strCurveName = QString::fromLocal8Bit(curvename);
if(curvetype>CARD_OBJECT || 0 == curvetype)
{
qDebug() << "strCurveName: " << strCurveName;
//表格数据
}
else if(CURVE_OBJECT == curvetype)
{
//曲线
//判断曲线有效性
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);
#ifdef WIN32
if(_isnan(temp)||!_finite(temp)) continue;
#else
if(qIsNaN(temp)||!qIsFinite(temp)) continue;
#endif // WIN32
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;
}
//下拉列表
int ret=0;
if(iCount != nSlfCount)//同一口井,且已经选择校正曲线
{
for(int iLoop=0; iLoop<m_Names.size(); iLoop++)
{
if(strCurveName.compare(m_Names[iLoop].m_strLineName, Qt::CaseInsensitive)==0)
{
ret=1;
break;
}
}
}
if(ret) continue;
sdep = acurveinfo.StartDepth;
edep = acurveinfo.EndDepth;
}
else if(CARD_OBJECT == curvetype)
{
}
else if(WAVE_OBJECT == curvetype)
{
//波列
Slf_WAVE _wave;
logio->GetWaveInfo(i, &_wave);
sdep = _wave.StartDepth;
edep = _wave.EndDepth;
}
else if(TDT_OBJECT == curvetype)
{
//TDT-》树图
}
//组织表格数据---------------------------
QStandardItem* item = new QStandardItem();
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
item->setCheckState(Qt::Unchecked);
char buf[100];
sprintf(buf,"%d",iIndex+1);
item->setText(buf);
m_pTableModel->setItem(iIndex,T_COLUMN_IS_CHECK_,item);
item = new QStandardItem();
item->setText(strCurveName);
item->setData(qVariantFromValue(curvetype));
item->setEditable(false);
m_pTableModel->setItem(iIndex,T_COLUMN_NAME_,item);
item = new QStandardItem();
if(curvetype==CURVE_OBJECT) item->setText("曲线");
else if(curvetype==WAVE_OBJECT) item->setText("波列");
else if(curvetype==TABLEE_OBJECT) item->setText("表格");
else item->setText("");
m_pTableModel->setItem(iIndex,T_COLUMN_OUTNAME_,item);
item = new QStandardItem();
if(curvetype==CURVE_OBJECT || curvetype==WAVE_OBJECT) {
char buf[200];
sprintf(buf,"%g",sdep);//pLog->GetTopDepth()
item->setText(buf);
}
else item->setText("");
m_pTableModel->setItem(iIndex,T_COLUMN_OUTNAME_+1,item);
item = new QStandardItem();
if(curvetype==CURVE_OBJECT || curvetype==WAVE_OBJECT) {
char buf[200];
sprintf(buf,"%g",edep);//pLog->GetBottomDepth()
item->setText(buf);
}
else item->setText("");
m_pTableModel->setItem(iIndex,T_COLUMN_OUTNAME_+2,item);
if(g_pShiftCurves.size()>0) {
int countTmp=g_pShiftCurves.size();
for(int j=0;j<countTmp;j++) {
QString slf=g_pShiftCurves[j].m_strSlfName;
slf.replace("\\","/");
QString slf1=fileFull;
slf1.replace("\\","/");
if(slf1.compare(slf,Qt::CaseInsensitive)==0){
if(g_pShiftCurves[j].m_strLineName.compare(strCurveName,Qt::CaseInsensitive)==0) {
m_pTableModel->item(iIndex, T_COLUMN_IS_CHECK_)->setCheckState( Qt::Checked );
break;
}
}
}
}
//编号
iIndex++;
}
delete []curvename;
delete []aliasname;
delete logio;
//delete []pEntry;
}
}
void CchooseShiftCurvesDlg::slotCancelSelectClicked()
{
for(int i = 0; i < m_pTableModel->rowCount(); i++)
{
m_pTableModel->item(i,T_COLUMN_IS_CHECK_)->setCheckState( Qt::Unchecked );
}
}