244 lines
8.5 KiB
C++
244 lines
8.5 KiB
C++
#include "selectlinedialog.h"
|
|
#include "ui_selectlinedialog.h"
|
|
#include <QFile>
|
|
#include <QDebug>
|
|
#include <QTextStream>
|
|
#include "LogIO.h"
|
|
|
|
QString g_SelectLine_filePath = "";
|
|
|
|
SelectLineDialog::SelectLineDialog(QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::SelectLineDialog)
|
|
{
|
|
ui->setupUi(this);
|
|
loadStyle(":/qrc/qss/flatgray.css");
|
|
|
|
g_SelectLine_filePath = "";
|
|
//
|
|
connect(ui->ok, SIGNAL(clicked()), this, SLOT(slotOkClicked()));
|
|
connect(ui->cancel, SIGNAL(clicked()), this, SLOT(slotCancelClicked()));
|
|
}
|
|
|
|
SelectLineDialog::~SelectLineDialog()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
|
|
void SelectLineDialog::loadStyle(const QString &qssFile)
|
|
{
|
|
//加载样式表
|
|
QString qss;
|
|
QFile file(qssFile);
|
|
if (file.open(QFile::ReadOnly)) {
|
|
//用QTextStream读取样式文件不用区分文件编码 带bom也行
|
|
QStringList list;
|
|
QTextStream in(&file);
|
|
//in.setCodec("utf-8");
|
|
while (!in.atEnd()) {
|
|
QString line;
|
|
in >> line;
|
|
list << line;
|
|
}
|
|
|
|
file.close();
|
|
qss = list.join("\n");
|
|
QString paletteColor = qss.mid(20, 7);
|
|
this->setPalette(QPalette(paletteColor));
|
|
//用时主要在下面这句
|
|
this->setStyleSheet(qss);
|
|
}
|
|
}
|
|
|
|
void SelectLineDialog::setInfo(QString fileFull, QString strWellName, QString strType)
|
|
{
|
|
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();
|
|
for(int i = 0; i< nSlfCount; 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);
|
|
|
|
QString strCurveName = QString::fromLocal8Bit(curvename);
|
|
if(curvetype>CARD_OBJECT || 0 == curvetype)
|
|
{
|
|
qDebug() << "strCurveName: " << strCurveName;
|
|
//表格数据
|
|
if (strCurveName == "GUJING1_RESULT" || strCurveName == "GUJING2_RESULT" || strCurveName == "GUJING3_RESULT")
|
|
{
|
|
//固井
|
|
if(strType=="gujingObject")
|
|
{
|
|
//下拉列表
|
|
ui->comboBox->addItem(strCurveName);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//气测/FMT/射孔/文本(去掉固井曲线)
|
|
if(strType=="JiegutextObject")
|
|
{
|
|
//下拉列表
|
|
ui->comboBox->addItem(strCurveName);
|
|
}
|
|
}
|
|
}
|
|
else if(CURVE_OBJECT == curvetype)
|
|
{
|
|
//曲线
|
|
if(strType!="curveObject")
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//判断曲线有效性
|
|
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(__isnan(temp)||!__finite(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;
|
|
}
|
|
|
|
//下拉列表
|
|
ui->comboBox->addItem(strCurveName);
|
|
}
|
|
else if(CARD_OBJECT == curvetype)
|
|
{
|
|
//参数卡-》树图
|
|
|
|
}
|
|
else if(WAVE_OBJECT == curvetype)
|
|
{
|
|
//波列
|
|
|
|
//多臂井径
|
|
if(strType=="MCalsObject")
|
|
{
|
|
//下拉列表
|
|
ui->comboBox->addItem(strCurveName);
|
|
}
|
|
|
|
}
|
|
else if(TDT_OBJECT == curvetype)
|
|
{
|
|
//TDT-》树图
|
|
|
|
}
|
|
}
|
|
delete []curvename;
|
|
delete []aliasname;
|
|
delete logio;
|
|
//delete []pEntry;
|
|
}
|
|
}
|
|
|
|
//
|
|
void SelectLineDialog::slotOkClicked()
|
|
{
|
|
// g_SelectWellIndex = ui->comboBox->currentIndex();
|
|
|
|
QString strLine = ui->comboBox->currentText();
|
|
if(strLine=="")
|
|
{
|
|
return;
|
|
}
|
|
|
|
g_SelectLine_filePath = strLine;
|
|
//关闭
|
|
accept(); // 让 QDialog::exec() 返回 QDialog::Accepted
|
|
//QDialog::close();
|
|
}
|
|
|
|
//
|
|
void SelectLineDialog::slotCancelClicked()
|
|
{
|
|
reject(); // 让 QDialog::exec() 返回 QDialog::Rejected
|
|
//QDialog::close();
|
|
}
|