#pragma warning( push , 0 ) #include #include "ui_chooseShiftCurves.h" #include #include #include "chooseShiftCurvesDlg.h" #include #include "DataImport.h" #include "ObjWelllog.h" #include #include #include #include #include #include #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 g_pShiftCurves; CchooseShiftCurvesDlg::CchooseShiftCurvesDlg(QList 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 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 vecSlfList; QVector vecWellList; bool bRet = getAllSlf(g_prjname, vecSlfList, vecWellList); if(bRet) { for(int i=0; isetInfo(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;kkGetData(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.MaxValuetemp) 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; iLoopGetWaveInfo(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;jitem(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 ); } }