3577 lines
83 KiB
C++
3577 lines
83 KiB
C++
// #include <Windows.h>
|
|
#include "../include/griddataadapter.h"
|
|
#include "WellLogTableDialogNew.h"
|
|
#include <QScrollBar>
|
|
#include <QDebug>
|
|
#include <QThreadPool>
|
|
#include <QMutexLocker>
|
|
#include <QPainter>
|
|
#include <QRegExp>
|
|
#include <QRegExpValidator>
|
|
#include <QFileDialog>
|
|
#include <QScrollArea>
|
|
#include <QTabWidget>
|
|
#include <QSpacerItem>
|
|
#include <QTimer>
|
|
#include <QAbstractItemView>
|
|
#include <QRgb>
|
|
#include <QApplication>
|
|
#include <QClipboard>
|
|
#include "TipPop.h"
|
|
// #include "ObjProject.h"
|
|
// #include "DataTree.h"
|
|
// #include <qtconcurrentrun.h>
|
|
// #include "ObjWellLogWavefile.h"
|
|
#include "DataManagger.h"
|
|
#include "assetcopy.h"
|
|
// #include <Windows.h>
|
|
// #include <WinUser.h>
|
|
#include "ObjectID.h"
|
|
|
|
//QtConcurrent
|
|
#define FLOATPREC 4
|
|
|
|
Slf_WAVE WaveInfo;
|
|
Slf_TDT TDT;
|
|
Slf_FMT FMT;
|
|
//定义表格的行高
|
|
//#define DefRowHeight 25
|
|
//列宽
|
|
//#define DefColWidth 100
|
|
//表格显示小数点后位数f
|
|
#define DECIMALPLACESNUM 8
|
|
|
|
#define DefSelection_Color "lightblue"
|
|
|
|
#define DefBgSelection_Color "lightgray"
|
|
|
|
#define CurveViewVerRange 200
|
|
|
|
|
|
WellLogHeaderView::WellLogHeaderView(Qt::Orientation orientation, QWidget *parent ):
|
|
QHeaderView(orientation,parent)
|
|
{
|
|
m_logicalIndex=-1;
|
|
}
|
|
WellLogHeaderView::~WellLogHeaderView()
|
|
{
|
|
|
|
}
|
|
|
|
void WellLogHeaderView::mouseReleaseEvent(QMouseEvent *evt)
|
|
{
|
|
QHeaderView::mouseReleaseEvent(evt);
|
|
QPoint point=evt->pos();
|
|
m_logicalIndex=QHeaderView::logicalIndexAt(point);
|
|
|
|
//this->update();
|
|
emit signalClickedSectionLogicalIndex(m_logicalIndex);
|
|
|
|
}
|
|
void WellLogHeaderView::paintEvent(QPaintEvent *pevt)
|
|
{
|
|
|
|
QHeaderView::paintEvent(pevt);
|
|
QPainter painter;
|
|
painter.begin(this);
|
|
painter.save();
|
|
QPen pen=QPen(QColor(213,239,255),1);
|
|
painter.setPen(pen);
|
|
//painter.setBrush();
|
|
QRect bgRect=rect();
|
|
painter.drawRect(bgRect);
|
|
painter.restore();
|
|
painter.end();
|
|
|
|
}
|
|
|
|
void WellLogHeaderView::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const
|
|
{
|
|
QVariant value=model()->headerData(logicalIndex,Qt::Horizontal,Qt::DisplayRole);
|
|
QModelIndex mindex= model()->index(0,0);
|
|
|
|
painter->save();
|
|
QHeaderView::paintSection(painter,rect,logicalIndex);
|
|
painter->restore();
|
|
|
|
|
|
|
|
QBrush bgBrush=QColor(qRgb(231,231,231));
|
|
|
|
if(logicalIndex == m_logicalIndex && logicalIndex >0 )
|
|
{
|
|
bgBrush=QColor(qRgb(213,213,213));
|
|
|
|
}
|
|
|
|
painter->save();
|
|
|
|
painter->fillRect(rect,bgBrush);
|
|
painter->restore();
|
|
|
|
if(value.isValid())
|
|
{
|
|
painter->drawText(rect,Qt::AlignHCenter|Qt::AlignVCenter,value.value<QString>());
|
|
}
|
|
}
|
|
|
|
//void WellLogHeaderView::setSelectionChecked(const QModelIndex &index)
|
|
//{
|
|
// QRect selectionRect=QHeaderView::visualRect(index);
|
|
// setSelection(selectionRect,QItemSelectionModel::ToggleCurrent);
|
|
//
|
|
//}
|
|
|
|
GridDataAdapter::GridDataAdapter(QTableWidget* table,
|
|
QScrollBar *horizontalScrollBar,
|
|
QScrollBar *verticalScrollBar,
|
|
QObject* parent)
|
|
: QObject(parent)
|
|
,m_verScrolValue(0)
|
|
,m_horScrolValue(0)
|
|
,m_pageRow(1)
|
|
,m_pageCol(0)
|
|
,m_tmodel(NULL)
|
|
// ,m_pWell(NULL)
|
|
,m_mgr(NULL)
|
|
,ifItemWidth(true)
|
|
,m_nVerScrollValue(0)
|
|
,m_pAssetCopy(new AssetCopy(this))
|
|
,DefRowHeight(20)
|
|
,DefColWidth(180)
|
|
,canLoadFromSLF(true)
|
|
,haveDoubleClicked(false)
|
|
,VerScrollUp(false)
|
|
,VerScrollChanged(true)
|
|
{
|
|
initColWH();
|
|
|
|
qRegisterMetaType<DataPair>("DataPair");
|
|
resetEditRange();
|
|
m_horScrolBar=horizontalScrollBar;
|
|
m_verScrolBar=verticalScrollBar;
|
|
m_table=table;
|
|
|
|
m_table->installEventFilter(this);
|
|
connect(m_verScrolBar,SIGNAL(valueChanged(int)),this,SLOT(slotVerScrollValueChange(int)));
|
|
connect(m_horScrolBar,SIGNAL(valueChanged(int)),this,SLOT(slotHorScrollValueChange(int)));
|
|
|
|
connect(m_verScrolBar,SIGNAL(sliderPressed()),this,SLOT(slotVerScrollBarPressed()));
|
|
connect(m_verScrolBar,SIGNAL(sliderReleased()),this,SLOT(slotVerScrollBarReleased()));
|
|
connect(m_horScrolBar,SIGNAL(sliderPressed()),this,SLOT(slotHorScrollBarPressed()));
|
|
connect(m_horScrolBar,SIGNAL(sliderReleased()),this,SLOT(slotHorScrollBarReleased()));
|
|
|
|
m_table->verticalScrollBar()->setVisible(true);
|
|
m_table->horizontalScrollBar()->setVisible(true);
|
|
m_table->horizontalHeader()->setSortIndicatorShown(false);
|
|
m_table->setGridStyle(Qt::PenStyle::SolidLine);
|
|
m_table->setHorizontalHeader(new WellLogHeaderView(Qt::Horizontal, m_table));
|
|
|
|
m_dtype = D_NONE;
|
|
m_tmodel = new TableModel();
|
|
if(NULL == m_mgr)
|
|
{
|
|
m_mgr = new CDataManagger();
|
|
}
|
|
vP = NULL;
|
|
m_dataRowCount = 0;
|
|
m_dataColCount = 0;
|
|
recordcount = 0;
|
|
m_switch = false;
|
|
m_table->setMouseTracking(true);
|
|
m_table->horizontalHeader()->setMouseTracking(true);
|
|
WellLogHeaderView *wellHeader=dynamic_cast<WellLogHeaderView*>( m_table->horizontalHeader());
|
|
|
|
connect(wellHeader, SIGNAL(signalClickedSectionLogicalIndex(int)), this, SLOT(slotSectionClicked(int)));
|
|
connect(&watcher, SIGNAL(finished()), this, SLOT(slotScrollChangeComplete()));
|
|
|
|
connect(m_table, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(slotCellDoubleClicked(int, int)));
|
|
connect(m_table, SIGNAL(cellClicked(int, int)), this, SLOT(slotCellClicked(int, int)));
|
|
connect(m_table, SIGNAL(cellChanged(int,int)), this, SLOT(itemChange_SLOT(int, int)));
|
|
|
|
connect(this, SIGNAL(signalCommitToSave()), this, SLOT(slotCommitToSave()));
|
|
hideWellLogView();
|
|
|
|
m_popTip = new TipPop();
|
|
|
|
m_menu = new QMenu(m_table);
|
|
|
|
}
|
|
|
|
void GridDataAdapter::slotSectionClicked(int logincIndex)
|
|
{
|
|
if(logincIndex==0)
|
|
{
|
|
return;
|
|
}
|
|
m_table->horizontalHeader()->setFocus();
|
|
bindWellLogData(logincIndex-1);
|
|
}
|
|
|
|
void GridDataAdapter::slotCellDoubleClicked(int row,int col)
|
|
{
|
|
if(NULL == m_table)
|
|
return;
|
|
|
|
QTableWidgetItem* item = m_table->item(row,col);
|
|
if(NULL == item)
|
|
return;
|
|
|
|
haveDoubleClicked = true;
|
|
|
|
m_cellText = item->text();
|
|
m_editRange = QTableWidgetSelectionRange(row,col,row,col);
|
|
}
|
|
|
|
void GridDataAdapter::slotCellClicked(int row,int col)
|
|
{
|
|
if(NULL == m_table)
|
|
return;
|
|
|
|
QTableWidgetItem* itemDepth = m_table->item(row,0);
|
|
QTableWidgetItem* itemValue = m_table->item(row,1);
|
|
if(NULL == itemDepth || NULL == itemValue)
|
|
return;
|
|
QString m_depthText = itemDepth->text();
|
|
QString m_valueText = itemValue->text();
|
|
float m_depthV = m_depthText.toFloat();
|
|
float m_valueV = m_valueText.toFloat();
|
|
|
|
switch(m_dtype)
|
|
{
|
|
case D_WellData:
|
|
break;
|
|
case D_WellLogData: //常规
|
|
{
|
|
// QWidget* parent=qobject_cast<QWidget*>(m_table->parent());
|
|
// QWidget* pvPage=parent->findChild<QWidget*>("curvePreViewPage");
|
|
// int value = (m_EDep-m_depthV)*100/(m_EDep-m_SDep)+1;
|
|
// if(value >= 0 && value <= 100 && pvPage != NULL)
|
|
// m_mgr->CallDisplayCurveVerChange(0,fileName,curveName,pvPage,value,m_depthV);
|
|
}
|
|
break;
|
|
case D_MultWellLogData:
|
|
break;
|
|
case D_TDTWellLogData:
|
|
haveDoubleClicked = false;
|
|
break;
|
|
case D_FMTWellLogData:
|
|
haveDoubleClicked = false;
|
|
break;
|
|
case D_TableWellLogData:
|
|
{
|
|
haveDoubleClicked = false;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void GridDataAdapter::itemChange_SLOT(int rowP, int colP)
|
|
{
|
|
if(haveDoubleClicked)
|
|
{
|
|
refreshTempModel();
|
|
haveDoubleClicked = false;
|
|
}
|
|
}
|
|
|
|
void GridDataAdapter::resetEditRange()
|
|
{
|
|
m_editRange=QTableWidgetSelectionRange(-1,-1,-1,-1);
|
|
|
|
|
|
}
|
|
GridDataAdapter::~GridDataAdapter()
|
|
{
|
|
for(int i = 0; i < m_pWellLogs.size(); i++){
|
|
m_pWellLogs[i]->isUsing = false;
|
|
}
|
|
|
|
qDeleteAll(m_pageItems);
|
|
clearBuffer();
|
|
//delete m_pAssetCopy;
|
|
delete m_tmodel;
|
|
m_tmodel=NULL;
|
|
m_table=NULL;
|
|
if(NULL != vP)
|
|
{
|
|
delete vP;
|
|
vP=NULL;
|
|
}
|
|
if(NULL != m_mgr)
|
|
{
|
|
delete m_mgr;
|
|
m_mgr=NULL;
|
|
}
|
|
if(NULL != m_popTip)
|
|
{
|
|
delete m_popTip;
|
|
m_popTip=NULL;
|
|
}
|
|
if(NULL != m_menu)
|
|
{
|
|
delete m_menu;
|
|
m_menu = NULL;
|
|
}
|
|
if(!ifItemWidth){
|
|
delete []itemWidth;
|
|
itemWidth = NULL;
|
|
}
|
|
}
|
|
|
|
int GridDataAdapter::dataRowCount()
|
|
{
|
|
return m_dataRowCount;
|
|
|
|
}
|
|
|
|
int GridDataAdapter::dataColCount()
|
|
{
|
|
return m_dataColCount;
|
|
}
|
|
|
|
|
|
|
|
void GridDataAdapter::setModelData(const QList< QList<DataPair> >& model )
|
|
{
|
|
|
|
m_tmodel->setModelData(model);
|
|
|
|
}
|
|
void GridDataAdapter::setTableHeaderData(const QStringList &headerLst)
|
|
{
|
|
m_tmodel->setTableHeaderData(headerLst);
|
|
}
|
|
//清空
|
|
void GridDataAdapter::clearBuffer()
|
|
{
|
|
m_tmodel->clearBuffer();
|
|
}
|
|
|
|
void GridDataAdapter::initColWH()
|
|
{
|
|
int nScreenW = 2560;//GetSystemMetrics(SM_CXSCREEN);//2560;//
|
|
int nScreenH = 1440;//GetSystemMetrics(SM_CYSCREEN);//1440;//
|
|
|
|
// QScreen *screen = QGuiApplication::screen();
|
|
// int width = screen->geometry().width();
|
|
// int height = screen->geometry().height();
|
|
if(nScreenW > 0 && nScreenH > 0){
|
|
int wNew = nScreenW/50;
|
|
int hNew = nScreenH/20;
|
|
DefRowHeight = (hNew > DefRowHeight) ? hNew:DefRowHeight;
|
|
DefColWidth = (wNew > DefColWidth) ? wNew:DefColWidth;
|
|
}
|
|
return;
|
|
}
|
|
|
|
//构建表格页显示项
|
|
void GridDataAdapter::buildItemList()
|
|
{
|
|
if(NULL == m_table)
|
|
{
|
|
return;
|
|
}
|
|
|
|
for(int i=0;i<m_pageRow;i++)
|
|
{
|
|
for(int j=0;j<m_pageCol;j++)
|
|
{
|
|
if(NULL==m_table->item(i,j))
|
|
{
|
|
QTableWidgetItem* item=new QTableWidgetItem();
|
|
item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate);
|
|
//if(j == 0)
|
|
// item->setFlags(item->flags() & (~Qt::ItemIsEditable));
|
|
item->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);//对齐
|
|
item->setFont(QFont("Times",10));
|
|
m_table->setItem(i,j,item);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//更新缓存数据并刷新视图
|
|
void GridDataAdapter::updateTableView()
|
|
{
|
|
|
|
if(NULL == m_table)
|
|
{
|
|
return;
|
|
}
|
|
|
|
m_pAssetCopy->setVerScrollValue(m_verScrolValue);
|
|
m_pAssetCopy->setHorScrollValue(m_horScrolValue);
|
|
|
|
int rcount=m_verScrolValue+m_pageRow;
|
|
int ccount=m_horScrolValue+m_pageCol;
|
|
//补充单页数据
|
|
int rowCount=m_verScrolBar->maximum()+m_pageRow;
|
|
int colCount=m_horScrolBar->maximum()+m_pageCol;
|
|
if(m_dtype==D_TableWellLogData||
|
|
m_dtype==D_TDTWellLogData||
|
|
m_dtype==D_FMTWellLogData)
|
|
rcount = m_table->rowCount();
|
|
if(rcount>rowCount)
|
|
{
|
|
rcount=rowCount;
|
|
}
|
|
if(ccount>colCount)
|
|
{
|
|
ccount=colCount;
|
|
}
|
|
int index=0;
|
|
DataPair dpair;
|
|
|
|
QTableWidgetItem* Item=NULL;
|
|
|
|
if(rcount < m_table->rowCount())
|
|
{
|
|
for(int i=0;i<m_pageRow;i++)
|
|
{
|
|
for(int j=0;j<m_pageCol;j++)
|
|
{
|
|
Item=m_table->item(i,j);
|
|
if(NULL != Item)
|
|
{
|
|
Item->setData(Qt::DisplayRole,QVariant());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//update
|
|
|
|
|
|
m_table->setHorizontalHeaderLabels(m_tmodel->tableHeaderData());
|
|
|
|
for(int i=m_verScrolValue; i < rcount; i++)
|
|
{
|
|
for(int j=m_horScrolValue;j < ccount;j++)
|
|
{
|
|
QModelIndex ind=m_tmodel->index(i-m_verScrolValue,j-m_horScrolValue);
|
|
|
|
QVariant mdata;
|
|
if(ind.isValid())
|
|
mdata = m_tmodel->data(ind,Qt::DisplayRole);
|
|
dpair=mdata.value<DataPair>();
|
|
|
|
Item = m_table->item(i-m_verScrolValue, j-m_horScrolValue);
|
|
if(NULL != Item)
|
|
{
|
|
Item->setData(Qt::DisplayRole,dpair.value);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
//绑定数据并初始数据
|
|
void GridDataAdapter::bindData()
|
|
{
|
|
|
|
m_pageRow=0;
|
|
m_pageCol=0;
|
|
m_dataRowCount=0;
|
|
m_dataColCount=0;
|
|
|
|
if(canLoadFromSLF)
|
|
calcuPageRowsCols();
|
|
if(NULL == m_table)
|
|
{
|
|
return;
|
|
}
|
|
//获取数据
|
|
switch(m_dtype)
|
|
{
|
|
case D_WellData:
|
|
{
|
|
updateWellData();
|
|
}
|
|
break;
|
|
case D_WellLogData:
|
|
{
|
|
updatetWellLogData();
|
|
attachWellLogView();
|
|
}
|
|
break;
|
|
case D_MultWellLogData:
|
|
{
|
|
updatetMultWellLogData();
|
|
attachWellLogView();//whp add 2020.5.11 for 波列数据编辑和管理
|
|
}
|
|
break;
|
|
case D_FMTWellLogData:
|
|
{
|
|
if(canLoadFromSLF)
|
|
updatetFMTWellLogData();
|
|
canLoadFromSLF = false;
|
|
m_horScrolBar->setVisible(false);
|
|
m_verScrolBar->setVisible(false);
|
|
}
|
|
break;
|
|
case D_TDTWellLogData:
|
|
{
|
|
if(canLoadFromSLF)
|
|
updatetTDTWellLogData();
|
|
canLoadFromSLF = false;
|
|
m_horScrolBar->setVisible(false);
|
|
m_verScrolBar->setVisible(false);
|
|
}
|
|
break;
|
|
case D_TableWellLogData:
|
|
{
|
|
if(canLoadFromSLF)
|
|
updatetTableWellLogData();
|
|
canLoadFromSLF = false;
|
|
m_horScrolBar->setVisible(false);
|
|
m_verScrolBar->setVisible(false);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
buildItemList();
|
|
//刷新视图
|
|
updateTableView();
|
|
|
|
m_verScrolBar->setValue(m_nVerScrollValue);
|
|
}
|
|
|
|
void GridDataAdapter::switchLogView(bool isSwitch)
|
|
{
|
|
m_switch=isSwitch;
|
|
|
|
}
|
|
//附加曲线统计、属性编辑、计算
|
|
void GridDataAdapter::attachWellLogView()
|
|
{
|
|
if(NULL == m_mgr)
|
|
{
|
|
return;
|
|
}
|
|
if(!m_pWellLogs.size()) return;
|
|
if(m_pWellLogs.size() > 1)
|
|
{
|
|
if(!m_switch ) return;
|
|
}else
|
|
{
|
|
// m_table->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
|
|
}
|
|
|
|
bindWellLogData(0);
|
|
}
|
|
|
|
void GridDataAdapter::bindWellLogData(int wellLogIndex)
|
|
{
|
|
// if(wellLogIndex>=m_pWellLogs.size()) return;
|
|
// if(m_horScrolValue /*+wellLogIndex*/ >= m_nSamples/*m_pWellLogs.size()*/) {
|
|
// m_horScrolValue=m_nSamples/*m_pWellLogs.size()-wellLogIndex*/-1;
|
|
// if(m_horScrolValue<0) m_horScrolValue=0;
|
|
// }
|
|
// if(wellLogIndex > m_pWellLogs.size()){
|
|
// wellLogIndex = m_pWellLogs.size() - 1;
|
|
// }
|
|
// int index=/*m_horScrolValue+*/wellLogIndex;
|
|
// if(index<0) return;
|
|
// CObjWellLogTABLE* pTable = dynamic_cast<CObjWellLogTABLE*>(m_pWellLogs[index]);
|
|
// if(pTable) return;
|
|
// CObjWellLog* pround = dynamic_cast<CObjWellLog*>(m_pWellLogs[index]);
|
|
// if(pround && pround->GetSlfFileName()!="")
|
|
// {
|
|
// CString TypeName=pround->GetParent()->GetName();
|
|
// int Type=0;
|
|
// //if(TypeName=="波列数据")Type=1;
|
|
// if(m_pWellLogs[0]->GetTypeID()==GetClassID_WellLogWavefile())Type=1;//whp add 2020.5.11 for 波列数据编辑和管理
|
|
// QString CurveName=pround->GetName();
|
|
// curveName = CurveName;
|
|
// QString FileName=pround->GetSlfFileName();
|
|
// fileName = FileName;
|
|
// QWidget* parent=qobject_cast<QWidget*>(m_table->parent());
|
|
// if(NULL == parent)
|
|
// {
|
|
// return;
|
|
// }
|
|
// QWidget* sPage=parent->findChild<QWidget*>("statisticsPage");
|
|
// QWidget* pPage=parent->findChild<QWidget*>("protoprtyPage");
|
|
// QWidget* cPage=parent->findChild<QWidget*>("computePage");
|
|
// QWidget* pvPage=parent->findChild<QWidget*>("curvePreViewPage");
|
|
// QTabWidget* tabWidget=parent->findChild<QTabWidget*>("tabWidget");
|
|
// if(NULL != sPage && NULL != pPage && NULL != cPage && NULL != pvPage)
|
|
// {
|
|
// if(NULL != tabWidget)
|
|
// {
|
|
// if(Type==0)
|
|
// {
|
|
// tabWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
|
|
// //tabWidget->setMinimumWidth(0);
|
|
// //tabWidget->setMaximumWidth(16777215);
|
|
// }
|
|
// else
|
|
// {
|
|
// tabWidget->setSizePolicy(QSizePolicy::Fixed/*Preferred*/,QSizePolicy::Expanding);//whp add 2020.5.11 for 波列数据编辑和管理
|
|
// //tabWidget->setMinimumWidth(1216);
|
|
// //tabWidget->setMaximumWidth(1216);
|
|
// }
|
|
// QScrollArea* sScrollArea=tabWidget->findChild<QScrollArea*>("sScrollArea");
|
|
// QScrollArea* pScrollArea=tabWidget->findChild<QScrollArea*>("pScrollArea");
|
|
// QScrollArea* cScrollArea=tabWidget->findChild<QScrollArea*>("cscrollArea");
|
|
// QScrollArea* curveScrollArea=tabWidget->findChild<QScrollArea*>("curveScrollArea");
|
|
// if(NULL != sScrollArea)
|
|
// {
|
|
// sScrollArea->setWidget(sPage);
|
|
// }
|
|
|
|
// if(NULL != pScrollArea)
|
|
// {
|
|
// pScrollArea->setWidget(pPage);
|
|
// }
|
|
|
|
// if(NULL != cScrollArea)
|
|
// {
|
|
// if(Type==0)cScrollArea->setWidget(cPage);
|
|
// }
|
|
|
|
// if(NULL != curveScrollArea)
|
|
// {
|
|
// curveScrollArea->setWidget(pvPage);
|
|
// }
|
|
|
|
// sPage->show();
|
|
// pPage->show();
|
|
// pvPage->show();
|
|
// if(Type==0)
|
|
// {
|
|
// cPage->show();//whp change 2020.5.11 for 波列数据编辑和管理 波列曲线不计算
|
|
// }
|
|
|
|
// tabWidget->show();
|
|
// //调用
|
|
// m_mgr->DataStatistics(Type,FileName,CurveName,sPage);
|
|
// m_mgr->CurvePropertyEdit(Type,FileName,CurveName,pPage);
|
|
// m_mgr->CallDisplayWaveOrCurve(Type,FileName,CurveName,pvPage);
|
|
// if(Type==0)
|
|
// {
|
|
// m_mgr->CurveCompute(FileName,QStringList()<<CurveName,cPage);
|
|
// }
|
|
// }
|
|
|
|
// }
|
|
// }
|
|
}
|
|
|
|
|
|
//刷新
|
|
void GridDataAdapter::ReFreshWindow(int type)
|
|
{
|
|
switch(type)
|
|
{
|
|
case D_WellData:
|
|
{
|
|
updateWellData();
|
|
}
|
|
break;
|
|
case D_WellLogData:
|
|
{
|
|
for(int i=0;i<m_pWellLogs.size();i++) {
|
|
m_pWellLogs[i]->isLoad=false;
|
|
m_pWellLogs[i]->LoadFromSLF();
|
|
}
|
|
updatetWellLogData();
|
|
}
|
|
|
|
break;
|
|
case D_MultWellLogData:
|
|
{
|
|
// m_pWave->isLoad=false;
|
|
// m_pWave->LoadFromSLF();
|
|
// updatetMultWellLogData();
|
|
}
|
|
break;
|
|
case D_TableWellLogData:
|
|
{
|
|
updatetTableWellLogData();
|
|
}
|
|
break;
|
|
case D_TDTWellLogData:
|
|
{
|
|
updatetTDTWellLogData();
|
|
}
|
|
break;
|
|
case D_FMTWellLogData:
|
|
{
|
|
updatetFMTWellLogData();
|
|
}
|
|
break;
|
|
}
|
|
updateTableView();
|
|
}
|
|
|
|
|
|
|
|
void GridDataAdapter::slotScrollChangeComplete()
|
|
{
|
|
{
|
|
QMutexLocker locker(&m_mutex);
|
|
updateTableView();
|
|
}
|
|
|
|
}
|
|
|
|
void GridDataAdapter::calcuPageRowsCols()
|
|
{
|
|
hideWellLogView();
|
|
|
|
QRect tableRect=m_table->rect();//窗口范围
|
|
|
|
if(m_pWellLogs.size() > 1&& m_pWellLogs[0]->GetTypeID()==GetClassID_WellLog() )
|
|
{
|
|
if(m_switch)
|
|
{
|
|
if(0 == m_middleWidth)
|
|
{
|
|
m_middleWidth=tableRect.width();
|
|
}
|
|
tableRect.setWidth(m_middleWidth);
|
|
|
|
}else
|
|
{
|
|
if(0 == m_gridWidth)
|
|
{
|
|
m_gridWidth=tableRect.width();
|
|
}
|
|
tableRect.setWidth(m_gridWidth);
|
|
}
|
|
|
|
}
|
|
|
|
else if(m_pWellLogs[0]->GetTypeID()==GetClassID_WellLogWavefile())
|
|
{
|
|
if(m_switch)
|
|
{
|
|
if(0==m_middleWidth)
|
|
{
|
|
m_middleWidth =tableRect.width();
|
|
}
|
|
tableRect.setWidth(m_middleWidth);
|
|
}
|
|
else
|
|
{
|
|
if(0==m_middleWidth)
|
|
{
|
|
m_gridWidth =tableRect.width();
|
|
}
|
|
tableRect.setWidth(m_gridWidth);
|
|
}
|
|
}
|
|
if(tableRect.isEmpty())
|
|
{
|
|
return;
|
|
}
|
|
int tableWidth=tableRect.width();
|
|
int tableHeight=tableRect.height() - 3*DefRowHeight;
|
|
if(tableHeight < 0) tableHeight = 1;
|
|
|
|
|
|
m_pageRow = (tableHeight % DefRowHeight == 0) ? (tableHeight / DefRowHeight) : (tableHeight / DefRowHeight + 1);
|
|
|
|
if(m_pWellLogs[0]->GetTypeID()==GetClassID_WellLogWavefile())
|
|
m_pageCol=(tableWidth%DefColWidth==0)?(tableWidth/DefColWidth):(tableWidth/DefColWidth);
|
|
else if(m_pWellLogs[0]->GetTypeID()==GetClassID_WellLogTDT()){
|
|
m_pageCol=TDT.TotalLogNumber*3;
|
|
}
|
|
else if(m_pWellLogs[0]->GetTypeID()==GetClassID_WellLogFMT()){
|
|
m_pageCol=FMT.TotalPointNum;
|
|
}
|
|
else {
|
|
m_pageCol = m_pWellLogs.size() + 1;
|
|
//m_pageCol = (tableWidth%DefColWidth==0)?(tableWidth/DefColWidth):(tableWidth/DefColWidth+1);
|
|
}
|
|
|
|
|
|
|
|
if(m_dtype == D_TableWellLogData||
|
|
m_dtype==D_TDTWellLogData||
|
|
m_dtype==D_FMTWellLogData){
|
|
m_pageRow = recordcount/*(m_pageRow > recordcount) ? m_pageRow : recordcount + m_pageRow*/;
|
|
m_pageCol = m_TitleField.size()-1;
|
|
}
|
|
|
|
m_table->setRowCount(m_pageRow);
|
|
m_table->setColumnCount(m_pageCol);
|
|
|
|
for(int i = 0; i < m_pageRow; i++)
|
|
m_table->setRowHeight(i, DefRowHeight);
|
|
if(m_dtype != D_TableWellLogData&&
|
|
m_dtype!=D_TDTWellLogData&&
|
|
m_dtype!=D_FMTWellLogData)
|
|
m_table->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
|
for(int i = 0; i < m_pageCol; i++)
|
|
m_table->setColumnWidth(i,DefColWidth);
|
|
|
|
if(m_dtype == D_TableWellLogData||
|
|
m_dtype == D_TDTWellLogData||
|
|
m_dtype == D_FMTWellLogData)
|
|
{
|
|
m_table->horizontalHeader()->setDefaultSectionSize(DefColWidth);
|
|
}
|
|
else if(m_pageCol * DefColWidth <= tableWidth)
|
|
m_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
else
|
|
{
|
|
m_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
|
m_table->horizontalHeader()->setDefaultSectionSize(DefColWidth);
|
|
}
|
|
|
|
}
|
|
void GridDataAdapter::hideWellLogView()
|
|
{
|
|
QWidget* parent=qobject_cast<QWidget*>(m_table->parent());
|
|
if(NULL == parent)
|
|
{
|
|
return;
|
|
}
|
|
QWidget* sPage=parent->findChild<QWidget*>("statisticsPage");
|
|
QWidget* pPage=parent->findChild<QWidget*>("protoprtyPage");
|
|
QWidget* cPage=parent->findChild<QWidget*>("computePage");
|
|
QWidget* pvPage=parent->findChild<QWidget*>("curvePreViewPage");
|
|
QTabWidget* tabWidget=parent->findChild<QTabWidget*>("tabWidget");
|
|
|
|
if(NULL != sPage && NULL != pPage)
|
|
{
|
|
if(NULL != tabWidget)
|
|
{
|
|
sPage->hide();
|
|
pPage->hide();
|
|
cPage->hide();
|
|
pvPage->hide();
|
|
tabWidget->hide();
|
|
|
|
}
|
|
|
|
}
|
|
m_table->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
|
|
}
|
|
/////////////////////////////begin==TableModel////////////////////////////////////////////
|
|
|
|
TableModel::TableModel(QObject* parent)
|
|
:QAbstractTableModel(parent)
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
void TableModel::clearBuffer()
|
|
{
|
|
m_dataBuffer.clear();
|
|
}
|
|
|
|
int TableModel::rowCount(const QModelIndex &parent) const
|
|
{
|
|
return m_dataBuffer.size();
|
|
}
|
|
|
|
int TableModel::columnCount(const QModelIndex &parent) const
|
|
{
|
|
if(m_dataBuffer.size()>0)
|
|
return m_dataBuffer.value(0).size();
|
|
else
|
|
return 0;
|
|
|
|
}
|
|
|
|
QVariant TableModel::data(const QModelIndex &index, int role) const
|
|
{
|
|
if(!index.isValid()||role!=Qt::DisplayRole)
|
|
{
|
|
return QVariant();
|
|
}
|
|
|
|
int row=index.row();
|
|
int col=index.column();
|
|
QList<DataPair> colData=m_dataBuffer.value(row);
|
|
|
|
if(col>= colData.size()|| col<0)
|
|
{
|
|
return QVariant();
|
|
}
|
|
DataPair dp= colData.value(col);
|
|
return QVariant::fromValue(dp);
|
|
|
|
}
|
|
|
|
QStringList TableModel::tableHeaderData()
|
|
{
|
|
return m_headerData;
|
|
}
|
|
|
|
void TableModel::setTableHeaderData(const QStringList &headerLst)
|
|
{
|
|
m_headerData.clear();
|
|
m_headerData=headerLst;
|
|
}
|
|
void TableModel::clearHeader()
|
|
{
|
|
m_headerData.clear();
|
|
}
|
|
void TableModel::setModelData(const QList< QList<DataPair> >& model )
|
|
{
|
|
|
|
m_dataBuffer=model;
|
|
|
|
}
|
|
|
|
//////////////////end==TableModel///////////////////////////////////////////////////////
|
|
|
|
//初始化井眼轨迹
|
|
void GridDataAdapter::initWellData(DType type,pai::datamodel::CObjWell* pwell)
|
|
{
|
|
m_pWell=pwell;
|
|
m_dtype=type;
|
|
}
|
|
//单元格是否更改
|
|
bool GridDataAdapter::isCellChanged()
|
|
{
|
|
bool editSingleModify= m_editRange.rowCount()==m_editRange.columnCount();
|
|
|
|
editSingleModify &= m_editRange.rowCount()==1;
|
|
QTableWidgetItem* item=NULL;
|
|
bool isParse=m_pAssetCopy->isParse();
|
|
if(isParse)
|
|
{
|
|
return isParse;
|
|
}
|
|
if(editSingleModify)
|
|
{
|
|
item=m_table->item(m_editRange.topRow(),m_editRange.leftColumn());
|
|
if(NULL == item)
|
|
{
|
|
return false;
|
|
}
|
|
if(item->text()==m_cellText)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
//发起保存
|
|
void GridDataAdapter::CommitToSave()
|
|
{
|
|
emit signalCommitToSave();
|
|
}
|
|
|
|
//排序
|
|
void BubbleSort(int *a, int n)
|
|
{
|
|
int i, j;
|
|
for (i = 1; i < n; i++)
|
|
for (j = 0; j <= n - 1 - i; j++)
|
|
if (a[j] > a[j + 1])
|
|
swap(a[j], a[j + 1]);
|
|
}
|
|
|
|
void GridDataAdapter::calNewPageRow()
|
|
{
|
|
|
|
m_pageRow = m_table->rowCount();
|
|
int rowCount = m_pageRow;
|
|
int count=rowCount;
|
|
|
|
for(int row = 0; row < rowCount; row++)
|
|
{
|
|
if(!m_table->item(row,0)) {
|
|
count = row;
|
|
break;
|
|
}
|
|
/*
|
|
else{
|
|
if(m_table->item(row,0)->text() == ""){
|
|
count = row;
|
|
break;
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
recordcount = count;
|
|
}
|
|
|
|
void GridDataAdapter::sortSequence_SLOT()
|
|
{
|
|
if(m_table->horizontalHeaderItem(0)->text() != "NO")
|
|
{
|
|
QMessageBox::about(NULL, "提示", "无法修改该表序列!");
|
|
return;
|
|
}
|
|
|
|
for(int rTemp = 0; rTemp < m_table->rowCount(); rTemp++)
|
|
{
|
|
m_table->item(rTemp, 0)->setText(QString("%1").arg(rTemp + 1));
|
|
}
|
|
|
|
refreshTempModel();
|
|
}
|
|
|
|
void GridDataAdapter::sortCompute_SLOT()
|
|
{
|
|
// if(!m_pWellLogs.size()) return;
|
|
// QList<QTableWidgetItem*> selItems = m_table->selectedItems();
|
|
|
|
// if(selItems.size() > 0){
|
|
// int curRow = m_table->column(selItems.at(0));
|
|
// CDataTree *pDatatree=(CDataTree *)::GetProject()->m_pDataTree;
|
|
// pDatatree->magr->CurveCompute(m_pWellLogs,curRow);
|
|
// }
|
|
}
|
|
|
|
void GridDataAdapter::onDeleteLinesData()
|
|
{
|
|
if(NULL == m_menu || NULL == m_table)
|
|
return;
|
|
|
|
//删除操作不再直接执行保存
|
|
|
|
QList<QTableWidgetItem*> selItems = m_table->selectedItems();
|
|
QList<QTableWidgetSelectionRange> selRanges = m_table->selectedRanges();
|
|
|
|
if(selItems.size() > 0){
|
|
calNewPageRow();
|
|
|
|
int *drow = new int[selItems.size()];
|
|
int drowNum = 0;
|
|
for(int ri = 0; ri < selItems.size(); ri++)
|
|
drow[ri] = -1;
|
|
|
|
for(int i = 0; i < selItems.size(); i++){
|
|
int curRow = m_table->row(selItems.at(i));
|
|
if(curRow == -1 || curRow + 1 > m_pageRow)
|
|
continue;
|
|
|
|
int ri = 0;
|
|
for(ri; ri < selItems.size(); ri++)
|
|
if(drow[ri] == curRow)
|
|
break;
|
|
if(ri == selItems.size()){
|
|
drow[drowNum++] = curRow;
|
|
}
|
|
}
|
|
|
|
BubbleSort(drow, drowNum);
|
|
|
|
QList<QList<DataPair>> data;
|
|
for(int nRow = 0; nRow < m_pageRow; nRow++)
|
|
{
|
|
bool f = false;
|
|
for(int i = 0; i < drowNum; i++){
|
|
if(nRow == drow[i])
|
|
f = true;
|
|
}
|
|
if(f) continue;
|
|
|
|
if(nRow >= recordcount)
|
|
break;
|
|
|
|
QList<DataPair> lstData;
|
|
for(int nCol = 0; nCol < m_table->columnCount(); nCol++)
|
|
{
|
|
QString Qbug = m_table->item(nRow, nCol)->text();
|
|
|
|
lstData<<DataPair(Qbug);
|
|
}
|
|
data<<lstData;
|
|
}
|
|
setModelData(data);
|
|
|
|
for(int i = 0; i < drowNum; i++){
|
|
recordcount--;
|
|
}
|
|
|
|
m_table->setRowCount(recordcount);
|
|
|
|
delete []drow;
|
|
}
|
|
|
|
//updatetTableWellLogData();
|
|
m_pageRow = recordcount;
|
|
m_pageCol = m_table->columnCount();
|
|
updateTableView();
|
|
}
|
|
|
|
void GridDataAdapter::addALine_SLOT()
|
|
{
|
|
if(NULL == m_menu || NULL == m_table) return;
|
|
|
|
QList<QTableWidgetSelectionRange> selRanges = m_table->selectedRanges();
|
|
|
|
QTableWidgetSelectionRange copyRange = selRanges.value(0);
|
|
int X = copyRange.topRow() + 1;
|
|
|
|
addALine(X);
|
|
}
|
|
|
|
void GridDataAdapter::addALine_SLOT(int X)
|
|
{
|
|
addALine(X);
|
|
}
|
|
|
|
void GridDataAdapter::addALine(int X)
|
|
{
|
|
m_table->insertRow(X);
|
|
m_table->setRowHeight(X, m_table->rowHeight(0));
|
|
|
|
for(int nCol = 0; nCol < m_table->columnCount(); nCol++){
|
|
QTableWidgetItem* pItem = new QTableWidgetItem;
|
|
pItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate);
|
|
pItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
|
|
//if(nCol == 0)
|
|
//pItem->setFlags(pItem->flags() & (~Qt::ItemIsEditable));
|
|
pItem->setFont(QFont("Times", 10));
|
|
pItem->setText("");
|
|
|
|
m_table->setItem(X, nCol, pItem);
|
|
}
|
|
|
|
m_pageRow++;
|
|
recordcount++;
|
|
m_pageCol = m_table->columnCount();
|
|
|
|
refreshTempModel();
|
|
|
|
//updateTableView();
|
|
}
|
|
|
|
void GridDataAdapter::refreshTempModel_SLOT()
|
|
{
|
|
refreshTempModel();
|
|
}
|
|
|
|
void GridDataAdapter::refreshTempModel()
|
|
{
|
|
QList<QList<DataPair>> data;
|
|
for(int nRow = 0; nRow < m_table->rowCount(); nRow++)
|
|
{
|
|
QList<DataPair> lstData;
|
|
for(int nCol = 0; nCol < m_table->columnCount(); nCol++)
|
|
{
|
|
if(!m_table->item(nRow, nCol)) continue;
|
|
QString iText = m_table->item(nRow, nCol)->text();
|
|
lstData << DataPair(iText);
|
|
}
|
|
data<<lstData;
|
|
}
|
|
setModelData(data);
|
|
|
|
m_pageRow = m_table->rowCount();
|
|
recordcount = m_pageRow;
|
|
m_pageCol = m_table->columnCount();
|
|
}
|
|
|
|
int GridDataAdapter::getRecordCount()
|
|
{
|
|
return recordcount;
|
|
}
|
|
|
|
//右键菜单
|
|
void GridDataAdapter::addActonMenu(int type){
|
|
if(m_menu == NULL)
|
|
return;
|
|
|
|
if(type == 2) //表格数据 的 菜单
|
|
{
|
|
m_pAssetCopy->initPopMenu(m_table, m_menu);
|
|
connect(m_pAssetCopy, SIGNAL(signalParseData(const QTableWidgetSelectionRange&)), this, SLOT(onParseData(const QTableWidgetSelectionRange&)));
|
|
connect(m_pAssetCopy, SIGNAL(saveToTempModel()), this, SLOT(refreshTempModel_SLOT()));
|
|
connect(m_pAssetCopy, SIGNAL(needANewLine(int)), this, SLOT(addALine_SLOT(int)));
|
|
|
|
QIcon icon = QIcon(::GetImagePath() + "/UIMake/addLine.png");
|
|
QAction* action = m_menu->addAction(icon, "插入一行");
|
|
connect(action, SIGNAL(triggered()), this, SLOT(addALine_SLOT()));
|
|
|
|
icon = QIcon(::GetImagePath() + "/UIMake/delete.png");
|
|
action = m_menu->addAction(icon, "删除选中行");
|
|
connect(action, SIGNAL(triggered()), this, SLOT(onDeleteLinesData()));
|
|
|
|
icon = QIcon(::GetImagePath() + "/UIMake/sortCol.png");
|
|
action = m_menu->addAction(icon, "整理序列数");
|
|
connect(action, SIGNAL(triggered()), this,SLOT(sortSequence_SLOT()));
|
|
|
|
icon = QIcon(::GetImagePath() + "/icon/AddToTrack.png");
|
|
action = m_menu->addAction(icon, "计算");
|
|
connect(action, SIGNAL(triggered()), this,SLOT(sortCompute_SLOT()));
|
|
}
|
|
}
|
|
|
|
void GridDataAdapter::reqCustomComtextMenu(const QPoint &pos)
|
|
{
|
|
m_pAssetCopy->reqCustomComtextMenu(pos);
|
|
}
|
|
void GridDataAdapter::onParseData(const QTableWidgetSelectionRange &parseRange)
|
|
{
|
|
m_editRange=parseRange;
|
|
slotCommitToSave();
|
|
}
|
|
//保存
|
|
void GridDataAdapter::slotCommitToSave()
|
|
{
|
|
if(m_editRange.topRow()<0
|
|
|| NULL == m_table
|
|
|| !isCellChanged())
|
|
{
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
bool isExtract=false;
|
|
switch(m_dtype)
|
|
{
|
|
//保存井眼轨迹
|
|
case D_WellData:
|
|
{
|
|
QList<QList<double> > editWellData;
|
|
QList<int> modifyRows;
|
|
extractWellData(editWellData,modifyRows,isExtract);
|
|
if(isExtract)
|
|
{
|
|
saveWellData(editWellData,modifyRows);
|
|
}
|
|
}
|
|
break;
|
|
//保存曲线数据
|
|
case D_WellLogData:
|
|
{
|
|
QList<QList<float> > editWellLogData;
|
|
extractWellLogData(editWellLogData,isExtract);
|
|
if(isExtract)
|
|
{
|
|
saveWellLogData(editWellLogData);
|
|
}
|
|
}
|
|
break;
|
|
//保存多维曲线数据
|
|
case D_MultWellLogData:
|
|
{
|
|
saveMultWellLogData(isExtract);
|
|
}
|
|
|
|
break;
|
|
//保存表格
|
|
case D_TableWellLogData:
|
|
{
|
|
//saveTableWellLogData(isExtract);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
|
|
}
|
|
resetEditRange();
|
|
if(!isExtract && m_dtype != D_TableWellLogData)
|
|
{
|
|
QMessageBox::information(m_table,"提示","保存失败!");
|
|
}
|
|
}
|
|
|
|
//提取井眼轨迹
|
|
void GridDataAdapter::extractWellData(QList<QList<double> > &editData,QList<int> &modifyRows ,bool &isScuccess)
|
|
{
|
|
int sRow=m_editRange.topRow();
|
|
int eRow=m_editRange.bottomRow();
|
|
int sCol=m_editRange.leftColumn();
|
|
int eCol=m_editRange.rightColumn();
|
|
QList<double> wellXYZ;
|
|
QString textValue;
|
|
bool isMatch=true;
|
|
for(int i=sRow;i<=eRow;i++)
|
|
{
|
|
getWellData(i,2,wellXYZ,isMatch);
|
|
getWellData(i,3,wellXYZ,isMatch);
|
|
getWellData(i,4,wellXYZ,isMatch);
|
|
modifyRows<<i+m_verScrolBar->value();
|
|
if(!isMatch)
|
|
{
|
|
break;
|
|
}
|
|
editData<<wellXYZ;
|
|
}
|
|
isScuccess=isMatch;
|
|
|
|
}
|
|
//获取井眼轨迹数据
|
|
void GridDataAdapter::getWellData(int row,int col,QList<double>& wellXYZ,bool& covSuccss)
|
|
{
|
|
QTableWidgetItem* item=m_table->item(row,col);
|
|
QString textValue;
|
|
QRegExp rx("[0-9.0-9]*");
|
|
if(NULL != item)
|
|
{
|
|
textValue=item->text();
|
|
covSuccss=rx.exactMatch(textValue);
|
|
if(!covSuccss)
|
|
{
|
|
return;
|
|
}
|
|
wellXYZ<<textValue.toDouble();
|
|
}
|
|
}
|
|
void GridDataAdapter::ReFreshDisplayCurve(){
|
|
switch(m_dtype)
|
|
{
|
|
case D_WellData:
|
|
break;
|
|
case D_WellLogData: //常规
|
|
// {
|
|
// QWidget* parent=qobject_cast<QWidget*>(m_table->parent());
|
|
// QWidget* pvPage=parent->findChild<QWidget*>("curvePreViewPage");
|
|
// if(pvPage!=NULL)
|
|
// m_mgr->CallDisplayWaveOrCurve(0,fileName,curveName,pvPage);
|
|
// }
|
|
break;
|
|
case D_MultWellLogData:
|
|
break;
|
|
case D_TableWellLogData:
|
|
break;
|
|
case D_TDTWellLogData:
|
|
break;
|
|
case D_FMTWellLogData:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
//井眼轨迹
|
|
void GridDataAdapter::updateWellData()
|
|
{
|
|
// QMutexLocker locker(&m_mutex);
|
|
// if(NULL == m_pWell)
|
|
// {
|
|
// return;
|
|
// }
|
|
|
|
|
|
// m_pWell->LoadXYZ();
|
|
// DOUBLEPROPERTY& vX = m_pWell->GetX();
|
|
// DOUBLEPROPERTY& vY = m_pWell->GetY();
|
|
// DOUBLEPROPERTY& vZ = m_pWell->GetZ();
|
|
// float sdep=m_pWell->GetStartDep();
|
|
// float rlev=m_pWell->GetRlev();
|
|
// m_TitleField.clear();
|
|
// m_TitleField<<"No" << "depth" << "X" << "Y" << "Z" <<" ";
|
|
// clearBuffer();
|
|
// setColCount(m_TitleField.size());
|
|
|
|
// if(m_pageCol!=m_TitleField.size())
|
|
// {
|
|
// fillDefaultTitle(m_TitleField,m_pageCol);
|
|
// }
|
|
|
|
|
|
// setTableHeaderData(m_TitleField);
|
|
|
|
|
|
// QList<QList<DataPair> > data;
|
|
// if( (vX.empty() == false) && (vX.size() == vY.size()) && (vY.size()== vZ.size()) )
|
|
// {
|
|
// vector<double>::size_type tempVxSize = vX.size();
|
|
// setRowCount((int)tempVxSize);
|
|
// if(m_pageCol>m_TitleField.size())
|
|
// {
|
|
// m_pageCol=m_TitleField.size();
|
|
// }
|
|
|
|
// if(m_pageRow>tempVxSize)
|
|
// {
|
|
// m_pageRow=tempVxSize;
|
|
// }
|
|
// //calcuItemCount(m_pageRow,m_pageCol);
|
|
// QList<DataPair> lstData;
|
|
// int maxRecord=m_verScrolValue+m_pageRow;
|
|
// if(maxRecord>tempVxSize)
|
|
// {
|
|
// maxRecord=tempVxSize;
|
|
// }
|
|
// QString no,dept,x,y,z;
|
|
// m_pAssetCopy->setVerScrollValue(m_verScrolValue);
|
|
// m_pAssetCopy->setHorScrollValue(m_horScrolValue);
|
|
|
|
// for(vector<double>::size_type ix = m_verScrolValue; ix < maxRecord; ++ix)
|
|
// {
|
|
// lstData.clear();
|
|
// double ixa=ix;
|
|
// no=toString(ixa,'d',0,0);
|
|
// dept=toString(sdep+ix*rlev,'f',5,0);
|
|
// if( (vX.size() > ix) && (vY.size() > ix) && (vZ.size() > ix) )
|
|
// {
|
|
// x=toString(vX.m_vProperty[ix],'f',DECIMALPLACESNUM,0);
|
|
// y=toString(vY.m_vProperty[ix],'f',DECIMALPLACESNUM,0);
|
|
// z=toString(vZ.m_vProperty[ix],'f',DECIMALPLACESNUM,0);
|
|
|
|
// }else
|
|
// {
|
|
// x=QString("-9999.000");
|
|
// y=x;
|
|
// z=x;
|
|
|
|
// }
|
|
// lstData<<DataPair(no);
|
|
// lstData<<DataPair(dept);
|
|
// lstData<<DataPair(x);
|
|
// lstData<<DataPair(y);
|
|
// lstData<<DataPair(z);
|
|
// data<<lstData;
|
|
// }
|
|
// }
|
|
// setModelData(data);
|
|
// m_pWell->ClearXYZ();
|
|
}
|
|
|
|
//井眼轨迹
|
|
void GridDataAdapter::saveWellData(QList<QList<double> > data,QList<int> modifyRows)
|
|
{
|
|
// m_pWell->LoadXYZ();
|
|
// DOUBLEPROPERTY& vX = m_pWell->GetX();
|
|
// DOUBLEPROPERTY& vY = m_pWell->GetY();
|
|
// DOUBLEPROPERTY& vZ = m_pWell->GetZ();
|
|
|
|
// // DOUBLEPROPERTY vX(rowCount),vY(rowCount),vZ(rowCount);
|
|
// for(int i = 0; i < modifyRows.size(); i++)
|
|
// {
|
|
// double xColumn =data.value(i).value(0); //m_pUI->tableWidget->item(rows[i], 2)->text();
|
|
// double yColumn =data.value(i).value(1); //m_pUI->tableWidget->item(rows[i], 3)->text();
|
|
// double zColumn =data.value(i).value(2); // m_pUI->tableWidget->item(rows[i], 4)->text();
|
|
// vX.m_vProperty[modifyRows[i]] = xColumn;
|
|
// vY.m_vProperty[modifyRows[i]] = yColumn;
|
|
// vZ.m_vProperty[modifyRows[i]] = zColumn;
|
|
// }
|
|
// m_pWell->SetX( &vX );
|
|
// m_pWell->SetY( &vY );
|
|
// m_pWell->SetZ( &vZ );
|
|
|
|
// m_pWell->ClearXYZ();
|
|
}
|
|
//导出井眼轨迹
|
|
void GridDataAdapter::exportWellData(FILE *fp, DepthProgress& process)
|
|
{
|
|
// if(NULL == m_pWell)
|
|
// {
|
|
// return;
|
|
// }
|
|
|
|
// m_pWell->LoadXYZ();
|
|
// DOUBLEPROPERTY& vX = m_pWell->GetX();
|
|
// DOUBLEPROPERTY& vY = m_pWell->GetY();
|
|
// DOUBLEPROPERTY& vZ = m_pWell->GetZ();
|
|
// float sdep=m_pWell->GetStartDep();
|
|
// float rlev=m_pWell->GetRlev();
|
|
|
|
// if( (vX.empty() == false) && (vX.size() == vY.size()) && (vY.size()== vZ.size()) )
|
|
// {
|
|
// vector<double>::size_type tempVxSize = vX.size();
|
|
// QString conTents;
|
|
// process.CreatProgress(0,tempVxSize,"正在导出数据...");
|
|
|
|
// for(vector<double>::size_type ix = 0; ix < tempVxSize; ++ix)
|
|
// {
|
|
// conTents="";
|
|
// QStringList colList;
|
|
// double ixa=ix;
|
|
// colList<<toString(ixa,'d',0,0)
|
|
// <<toString(sdep+ix*rlev,'f',5,0)
|
|
// <<toString(vX.m_vProperty[ix],'f',DECIMALPLACESNUM,0)
|
|
// <<toString(vY.m_vProperty[ix],'f',DECIMALPLACESNUM,0)
|
|
// <<toString(vZ.m_vProperty[ix],'f',DECIMALPLACESNUM,0);
|
|
|
|
// for(int j=0;j<colList.size();j++)
|
|
// {
|
|
// QString str=colList.value(j);
|
|
// str.replace(","," ");
|
|
// if(j ==colList.size()-1)
|
|
// {
|
|
// conTents += str ;
|
|
// }
|
|
// else
|
|
// {
|
|
// conTents += str + " ";
|
|
// }
|
|
// }
|
|
|
|
// fprintf(fp,"%s\n",conTents.toStdString().c_str());
|
|
// process.SetDepth(ix+1);
|
|
// }
|
|
|
|
// }
|
|
// m_pWell->ClearXYZ();
|
|
}
|
|
|
|
//初始化曲线
|
|
void GridDataAdapter::initWellLogData(DType type,QList<CObjWellLog*> WellLogs)
|
|
{
|
|
m_pWellLogs=WellLogs;
|
|
m_pAssetCopy->SetWellLogs(type,WellLogs);
|
|
if(!m_pWellLogs.size()) return;
|
|
|
|
for(int i = 0; i < m_pWellLogs.size(); i++){
|
|
m_pWellLogs[i]->isUsing = true;
|
|
}
|
|
|
|
m_dtype=type;
|
|
vP=new PFLOATPROPERTY *[m_pWellLogs.size()];
|
|
for(int i=0;i<m_pWellLogs.size();i++) {
|
|
m_pWellLogs[i]->isLoad=false;
|
|
m_pWellLogs[i]->LoadFromSLF();
|
|
vP[i]=&m_pWellLogs[i]->GetProperty();
|
|
}
|
|
m_TitleField.clear();
|
|
QString depthUnit=m_pWellLogs[0]->GetDepthUnit();
|
|
if(m_pWellLogs[0]->GetDepthUnit()=="m"&&depthUnit!="m"&&depthUnit!="米") depthUnit="";
|
|
else if(m_pWellLogs[0]->GetDepthUnit()=="ft"&&depthUnit!="ft"&&depthUnit!="英尺") depthUnit="";
|
|
if(depthUnit.isEmpty()) m_pWellLogs[0]->GetDepthAliasUnit();
|
|
if(depthUnit.isEmpty()) depthUnit="米";
|
|
|
|
m_TitleField << "MD\n"+depthUnit;
|
|
|
|
double nStart =m_pWellLogs[0]->GetTopDepth();
|
|
double nEnd =m_pWellLogs[0]->GetBottomDepth();
|
|
for(int i=1;i<m_pWellLogs.size();i++)
|
|
{
|
|
if(nStart>m_pWellLogs[i]->GetTopDepth()) nStart=m_pWellLogs[i]->GetTopDepth();
|
|
if(nEnd<m_pWellLogs[i]->GetBottomDepth()) nEnd=m_pWellLogs[i]->GetBottomDepth();
|
|
}
|
|
m_SDep = nStart;
|
|
m_EDep = nEnd;
|
|
WellLogTableDialogNew* parent=qobject_cast<WellLogTableDialogNew*>(m_table->parent());
|
|
if(NULL == parent)
|
|
{
|
|
return;
|
|
}
|
|
QTabWidget* tabWidget=parent->findChild<QTabWidget*>("tabWidget");
|
|
for(int i=0;i<m_pWellLogs.size();i++)
|
|
{
|
|
QString m_Unit=m_pWellLogs[i]->GetUnit();
|
|
if(m_Unit.isEmpty()) m_Unit=m_pWellLogs[i]->GetAliasUnit();
|
|
if(m_Unit.isEmpty())
|
|
{
|
|
char strTmp[16] = "CurveFamily.ini";
|
|
QStringList cs=GetSimilarCurves(m_pWellLogs[i]->GetName(),strTmp,false);
|
|
if(cs.size()>3) {
|
|
m_Unit=cs[3];
|
|
}
|
|
}
|
|
int pos=0,pos1=0;
|
|
if((pos=m_Unit.indexOf("^"))>-1&&(pos1=m_Unit.indexOf("^",pos+1))>-1) {
|
|
QStringList fh=GetSimilarCurves(m_Unit.mid(pos,pos1-pos+1));
|
|
if(fh.size())m_Unit.replace(m_Unit.mid(pos,pos1-pos+1),fh[0]);
|
|
}
|
|
pos=0,pos1=0;
|
|
if((pos=m_Unit.indexOf("!"))>-1&&(pos1=m_Unit.indexOf("!",pos+1))>-1) {
|
|
QStringList fh=GetSimilarCurves(m_Unit.mid(pos,pos1-pos+1));
|
|
if(fh.size())m_Unit.replace(m_Unit.mid(pos,pos1-pos+1),fh[0]);
|
|
}
|
|
|
|
|
|
m_TitleField <<m_pWellLogs[i]->GetName() +"\n"+m_Unit;
|
|
}
|
|
|
|
PFLOATPROPERTY &vM=m_pWellLogs[0]->GetMD();
|
|
if(vM.size()<1) return ;
|
|
m_TitleField << " ";
|
|
//luol 20200302
|
|
clearBuffer();
|
|
|
|
//setColCount(m_TitleField.size());
|
|
|
|
|
|
}
|
|
//提取曲线数据
|
|
void GridDataAdapter::extractWellLogData(QList<QList<float> > &editData ,bool &isScuccess)
|
|
{
|
|
int sRow=m_editRange.topRow();
|
|
int eRow=m_editRange.bottomRow();
|
|
int sCol=m_editRange.leftColumn();
|
|
int eCol=m_editRange.rightColumn();
|
|
QString textValue;
|
|
bool isMatch=true;
|
|
QRegExp rx("-?[0-9.0-9]*");
|
|
QTableWidgetItem* item=NULL;
|
|
for(int i=sRow;i<=eRow;i++)
|
|
{
|
|
QList<float> rowList;
|
|
for(int j=sCol;j<=eCol;j++)
|
|
{
|
|
if(m_pAssetCopy->isParse())
|
|
{
|
|
textValue=m_pAssetCopy->itemParseText(i,j);
|
|
isScuccess=rx.exactMatch(textValue);
|
|
if(!isScuccess)
|
|
{
|
|
break;
|
|
}
|
|
rowList<<textValue.toFloat();
|
|
}else
|
|
{
|
|
item=m_table->item(i,j);
|
|
|
|
if(NULL != item)
|
|
{
|
|
textValue=item->text();
|
|
isScuccess=rx.exactMatch(textValue);
|
|
if(!isScuccess)
|
|
{
|
|
break;
|
|
}
|
|
rowList<<textValue.toFloat();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if(!isScuccess)
|
|
{
|
|
break;
|
|
}
|
|
editData<<rowList;
|
|
|
|
}
|
|
m_pAssetCopy->restParse();
|
|
|
|
}
|
|
//保存曲线
|
|
void GridDataAdapter::saveWellLogData(QList<QList<float> > depthList)
|
|
{
|
|
int sRow=m_editRange.topRow();
|
|
int eRow=m_editRange.bottomRow();
|
|
int sCol=m_editRange.leftColumn();
|
|
int eCol=m_editRange.rightColumn();
|
|
PFLOATPROPERTY &vM=m_pWellLogs[0]->GetMD();
|
|
double nStart =m_pWellLogs[0]->GetTopDepth();
|
|
double nEnd =m_pWellLogs[0]->GetBottomDepth();
|
|
for(int i=1;i<m_pWellLogs.size();i++)
|
|
{
|
|
if(nStart>m_pWellLogs[i]->GetTopDepth()) nStart=m_pWellLogs[i]->GetTopDepth();
|
|
if(nEnd<m_pWellLogs[i]->GetBottomDepth()) nEnd=m_pWellLogs[i]->GetBottomDepth();
|
|
}
|
|
int col,row,pos,cindex;
|
|
float dep,val;
|
|
col=row=pos=cindex=0;
|
|
dep=val=0;
|
|
QList <int > cindexs;
|
|
for(int i=sRow;i<=eRow;i++)
|
|
{
|
|
dep=nStart+(i+m_verScrolValue)*vM.m_vProperty[2];
|
|
col=0;
|
|
for(int j=sCol;j<=eCol;j++)
|
|
{
|
|
//屏蔽深度修改
|
|
if(0==j)
|
|
{
|
|
continue;
|
|
}
|
|
cindex=j+m_horScrolValue-1;
|
|
//单曲线类型更新
|
|
if(1==m_pWellLogs.size())
|
|
{
|
|
cindex=0;
|
|
}//else 多曲线更新
|
|
if(cindexs.indexOf(cindex)<=0)
|
|
cindexs.append(cindex);
|
|
|
|
val=depthList.value(row).value(col);
|
|
m_pWellLogs[cindex]->SetData(i+m_verScrolValue,&val);
|
|
// vP[cindex]->m_vProperty[i+m_verScrolValue]=val;
|
|
col++;
|
|
}
|
|
row++;
|
|
}
|
|
for(int i=0;i<cindexs.size();i++)
|
|
{
|
|
m_pWellLogs[cindexs[i]]->SaveToSLF();
|
|
}
|
|
}
|
|
//刷新曲线
|
|
void GridDataAdapter::updatetWellLogData()
|
|
{
|
|
|
|
QMutexLocker locker(&m_mutex);
|
|
if(VerScrollUp && !VerScrollChanged) return;
|
|
|
|
PFLOATPROPERTY &vM = m_pWellLogs[0]->GetMD();
|
|
if(vM.size() < 1) return ;
|
|
m_Rlev = vM.m_vProperty[2];
|
|
|
|
double nStart = m_pWellLogs[0]->GetTopDepth();
|
|
double nEnd = m_pWellLogs[0]->GetBottomDepth();
|
|
for(int i=1;i<m_pWellLogs.size();i++)
|
|
{
|
|
if(nStart > m_pWellLogs[i]->GetTopDepth())
|
|
nStart = m_pWellLogs[i]->GetTopDepth();
|
|
if(nEnd < m_pWellLogs[i]->GetBottomDepth())
|
|
nEnd = m_pWellLogs[i]->GetBottomDepth();
|
|
}
|
|
|
|
m_PointNum = (nEnd - nStart) / m_Rlev;
|
|
int horScrollOffset = m_horScrolValue;
|
|
if(m_horScrolValue > 0)
|
|
{
|
|
horScrollOffset--;
|
|
}
|
|
char buffer[200];
|
|
buffer[0] = 0;
|
|
if(!vP||!vP[0]) return;
|
|
if(vP[0]->empty() == false)
|
|
{
|
|
vector<double>::size_type tempVxSize = vP[0]->size();
|
|
m_PointNum = vP[0]->size();
|
|
setColCount(m_TitleField.size());
|
|
setRowCount(tempVxSize);
|
|
QStringList tempFields;
|
|
int pageCol=m_pageCol;
|
|
|
|
if(m_pageCol>m_TitleField.size())
|
|
{
|
|
m_pageCol=m_TitleField.size();
|
|
}
|
|
if(m_pageRow>tempVxSize)
|
|
{
|
|
m_pageRow=tempVxSize;
|
|
}
|
|
for(int i=0;i<m_pageCol;i++)
|
|
{
|
|
if(m_horScrolValue + i >= m_TitleField.size())
|
|
{
|
|
break;
|
|
}
|
|
tempFields << m_TitleField[m_horScrolValue + i];
|
|
}
|
|
if(pageCol != m_pageCol)
|
|
{
|
|
fillDefaultTitle(tempFields,pageCol);
|
|
}
|
|
setTableHeaderData(tempFields);
|
|
|
|
|
|
float val=0;
|
|
double dep=0;
|
|
int pos=0;
|
|
int rowSize=0;
|
|
QList<QList<DataPair> > data;
|
|
|
|
int maxRowRecord = m_verScrolValue + m_pageRow;
|
|
int maxColRecord = m_horScrolValue + m_pageCol;
|
|
if(maxRowRecord > tempVxSize)
|
|
{
|
|
maxRowRecord = tempVxSize;
|
|
}
|
|
if(maxColRecord > m_pWellLogs.size())
|
|
{
|
|
maxColRecord = m_pWellLogs.size();
|
|
}
|
|
data.reserve(maxRowRecord - m_verScrolValue);
|
|
m_pAssetCopy->setVerScrollValue(m_verScrolValue);
|
|
m_pAssetCopy->setHorScrollValue(m_horScrolValue);
|
|
for(vector<double>::size_type ix = m_verScrolValue; ix < maxRowRecord; ix++)
|
|
{
|
|
dep = nStart + ix * vM.m_vProperty[2];
|
|
QList<DataPair> lstData;
|
|
//lstData.reserve(maxColRecord-m_horScrolValue);
|
|
if(m_horScrolValue == 0)
|
|
{
|
|
lstData<<DataPair(toString(dep, 'f', 5, 0), Qt::ItemIsEditable);
|
|
}
|
|
else
|
|
{
|
|
if(horScrollOffset >= 0 && horScrollOffset < m_pWellLogs.size())
|
|
{
|
|
if(vP && vP[horScrollOffset])
|
|
{
|
|
rowSize = vP[horScrollOffset]->m_size;
|
|
pos = (dep - m_pWellLogs[horScrollOffset]->GetTopDepth()) / m_pWellLogs[horScrollOffset]->GetRlev() + 0.5;
|
|
if(pos >= 0 && pos < rowSize)
|
|
{
|
|
val = m_pWellLogs[horScrollOffset]->GetData(pos, buffer);
|
|
//val=vP[horScrollOffset]->m_vProperty[pos];
|
|
}
|
|
else
|
|
{
|
|
buffer[0] = 0;
|
|
val = -9999;
|
|
}
|
|
|
|
if(m_pWellLogs[horScrollOffset]->acurveinfo.RepCode != REPR_STRING)
|
|
lstData<<DataPair(toString(val, 'f', FLOATPREC, 0,false));
|
|
else
|
|
lstData<<DataPair(toString(buffer));
|
|
}
|
|
}
|
|
}
|
|
|
|
for(int i = m_horScrolValue; i < maxColRecord; i++)
|
|
{
|
|
if(!vP || !vP[i]) continue;
|
|
pos = (dep - m_pWellLogs[i]->GetTopDepth()) / m_pWellLogs[i]->GetRlev()+0.5;
|
|
rowSize = vP[i]->m_size;
|
|
if(pos >= 0 && pos < vP[i]->size())
|
|
{
|
|
val = m_pWellLogs[i]->GetData(pos, buffer);
|
|
}
|
|
else
|
|
{
|
|
buffer[0] = 0;
|
|
val = -9999;
|
|
}
|
|
if(m_pWellLogs[i]->acurveinfo.RepCode != REPR_STRING)
|
|
lstData << DataPair(toString(val, 'f', FLOATPREC, 0,false));
|
|
else
|
|
lstData << DataPair(buffer);
|
|
}
|
|
data<<lstData;
|
|
}
|
|
if(VerScrollUp && !VerScrollChanged) return;
|
|
setModelData(data);
|
|
|
|
//updateTableView();
|
|
|
|
VerScrollChanged = false;
|
|
}
|
|
}
|
|
|
|
void GridDataAdapter::fillDefaultTitle(QStringList& fields,
|
|
int pageCol)
|
|
{
|
|
int clearSize=pageCol>fields.size()?pageCol-fields.size():0;
|
|
for(int i=0;i<clearSize;i++)
|
|
{
|
|
fields<<"";
|
|
}
|
|
fields<<""<<""<<"";
|
|
}
|
|
//导出曲线
|
|
void GridDataAdapter::exportWellLogData(FILE *fp, DepthProgress& progress)
|
|
{
|
|
if(!m_pWellLogs.size()) return;
|
|
PFLOATPROPERTY &vM=m_pWellLogs[0]->GetMD();
|
|
if(vM.size()<1) return ;
|
|
char buffer[200];
|
|
if(!vP||!vP[0]) return;
|
|
if(!vP[0]->empty())
|
|
{
|
|
float val=0;
|
|
int maxColRecord=m_TitleField.size();
|
|
vector<double>::size_type tempVxSize = vP[0]->size();
|
|
QString conTents;
|
|
progress.CreatProgress(0,tempVxSize,"正在导出数据...");
|
|
if(maxColRecord>m_pWellLogs.size())
|
|
{
|
|
maxColRecord=m_pWellLogs.size();
|
|
}
|
|
for(vector<double>::size_type ix = 0; ix !=tempVxSize; ix++)
|
|
{
|
|
conTents="";
|
|
for(int i=0;i<maxColRecord;i++)
|
|
{
|
|
int rowSize=vP[i]->m_size;
|
|
if(ix<rowSize)
|
|
{
|
|
val=m_pWellLogs[i]->GetData((int)ix,buffer);
|
|
// vP[i]->m_vProperty[ix];
|
|
}else
|
|
{
|
|
buffer[0]=0;
|
|
val=-9999;
|
|
}
|
|
QString str=buffer;
|
|
if(m_pWellLogs[i]->acurveinfo.RepCode!=REPR_STRING) str= toString(val,'f',DECIMALPLACESNUM,0,false);
|
|
str.replace(","," ");
|
|
if(i ==maxColRecord-1)
|
|
{
|
|
conTents += str ;
|
|
}
|
|
else
|
|
{
|
|
conTents += str + " ";
|
|
}
|
|
}
|
|
fprintf(fp,"%s\n",conTents.toStdString().c_str());
|
|
progress.SetDepth(ix+1);
|
|
}
|
|
}
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////
|
|
void GridDataAdapter::initMultWellLogData(DType type,QList<CObjWellLog*> WellLogs)
|
|
{
|
|
// m_pWellLogs=WellLogs;
|
|
|
|
// for(int i = 0; i < m_pWellLogs.size(); i++){
|
|
// m_pWellLogs[i]->isUsing = true;
|
|
// }
|
|
|
|
// m_pAssetCopy->SetWellLogs(type,WellLogs);
|
|
// m_pWave=(CObjWellLogWavefile *)m_pWellLogs[0];
|
|
// if(!m_pWave)return;
|
|
// m_pWave->isLoad=false;
|
|
// m_pWave->LoadFromSLF();
|
|
// m_MutiVM=&m_pWave->GetProperty();
|
|
// WaveInfo=m_pWave->waveinfo;
|
|
// m_dtype=type;
|
|
// m_SDep = WaveInfo.StartDepth;
|
|
// m_EDep = WaveInfo.EndDepth;
|
|
// m_Rlev = WaveInfo.DepLevel;
|
|
// m_RepCode = WaveInfo.RepCode;
|
|
// m_CodeLen = WaveInfo.CodeLen;
|
|
// m_SamplePoint = WaveInfo.SamplePoint;
|
|
// m_nSamples = WaveInfo.SamplePoint*WaveInfo.ArrayNum;
|
|
// m_flRlev2 = WaveInfo.TimeLevel;
|
|
// m_PointNum = (float)(fabs((m_EDep-m_SDep)/m_Rlev+1.5));
|
|
// m_TitleField.clear();
|
|
// QString depthUnit=m_pWellLogs[0]->GetDepthUnit();
|
|
// if(m_pWellLogs[0]->GetDepthUnit()=="m"&&depthUnit!="m"&&depthUnit!="米") depthUnit="";
|
|
// else if(m_pWellLogs[0]->GetDepthUnit()=="ft"&&depthUnit!="ft"&&depthUnit!="英尺") depthUnit="";
|
|
// if(depthUnit.isEmpty()) depthUnit=m_pWellLogs[0]->GetDepthAliasUnit();
|
|
// if(depthUnit.isEmpty()) depthUnit="米";
|
|
// m_TitleField << "MD\n"+depthUnit;
|
|
// char buf[100];
|
|
// for(int j=0;j<WaveInfo.ArrayNum;j++) {
|
|
// for(int i=0;i<WaveInfo.SamplePoint;i++){
|
|
// sprintf(buf,"A:%d D:%d",j+1,i+1);
|
|
// m_TitleField << buf;//+"\n";
|
|
// }
|
|
// }
|
|
// m_TitleField << " " ;
|
|
|
|
}
|
|
//////////////////////////////////////////////////////////
|
|
void GridDataAdapter::initTDTWellLogData(DType type,QList<CObjWellLog*> WellLogs)
|
|
{
|
|
m_pWellLogs=WellLogs;
|
|
|
|
for(int i = 0; i < m_pWellLogs.size(); i++){
|
|
m_pWellLogs[i]->isUsing = true;
|
|
}
|
|
|
|
m_dtype=type;
|
|
m_pAssetCopy->SetWellLogs(type,WellLogs);
|
|
m_TitleField.clear();
|
|
int a=0;
|
|
//获得表格头
|
|
CLogIO *logio=new CLogIO;
|
|
if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeRead)) {
|
|
delete logio;
|
|
return ;
|
|
}
|
|
char name[100];
|
|
strcpy(name,m_pWellLogs[0]->GetName().toStdString().c_str());
|
|
int iIndex=logio->OpenTDT(name);
|
|
if (iIndex >=0)
|
|
{
|
|
a=1;
|
|
logio->GetTDTInfo(iIndex,&TDT);
|
|
|
|
int fc=3*TDT.TotalLogNumber;
|
|
if(fc<1) {
|
|
delete logio;
|
|
return;
|
|
}
|
|
for(int j=0;j<fc/3;j++) {
|
|
QString fieldName;
|
|
QString unit=TDT.DepthUnit;
|
|
fieldName="MD_"+QString::number(j);
|
|
fieldName+="\n"+unit;
|
|
m_TitleField.push_back(fieldName);
|
|
unit=TDT.TimeUnit;
|
|
fieldName="TIME_"+QString::number(j);
|
|
fieldName+="\n"+unit;
|
|
m_TitleField.push_back(fieldName);
|
|
unit=TDT.Unit;
|
|
fieldName="VALUE_"+QString::number(j);
|
|
fieldName+="\n"+unit;
|
|
m_TitleField.push_back(fieldName);
|
|
}
|
|
m_TitleField.push_back(" ");
|
|
recordcount=TDT.MaxLogSamples;
|
|
{
|
|
clearBuffer();
|
|
setRowCount(recordcount);
|
|
setColCount(m_TitleField.size());
|
|
}
|
|
}
|
|
logio->CloseTDT(iIndex);
|
|
delete logio;
|
|
}
|
|
//////////////////////////////////////////////////////////
|
|
void GridDataAdapter::initFMTWellLogData(DType type,QList<CObjWellLog*> WellLogs)
|
|
{
|
|
// m_pWellLogs=WellLogs;
|
|
|
|
// for(int i = 0; i < m_pWellLogs.size(); i++){
|
|
// m_pWellLogs[i]->isUsing = true;
|
|
// }
|
|
|
|
// m_pAssetCopy->SetWellLogs(type,WellLogs);
|
|
// m_pWave=(CObjWellLogWavefile *)m_pWellLogs[0];
|
|
// if(!m_pWave)return;
|
|
// m_pWave->isLoad=false;
|
|
// m_pWave->LoadFromSLF();
|
|
// m_MutiVM=&m_pWave->GetProperty();
|
|
// WaveInfo=m_pWave->waveinfo;
|
|
// m_dtype=type;
|
|
// m_SDep = WaveInfo.StartDepth;
|
|
// m_EDep = WaveInfo.EndDepth;
|
|
// m_Rlev = WaveInfo.DepLevel;
|
|
// m_RepCode = WaveInfo.RepCode;
|
|
// m_CodeLen = WaveInfo.CodeLen;
|
|
// m_SamplePoint = WaveInfo.SamplePoint;
|
|
// m_nSamples = WaveInfo.SamplePoint*WaveInfo.ArrayNum;
|
|
// m_flRlev2 = WaveInfo.TimeLevel;
|
|
// m_PointNum = (float)(fabs((m_EDep-m_SDep)/m_Rlev+1.5));
|
|
// m_TitleField.clear();
|
|
// QString depthUnit=m_pWellLogs[0]->GetDepthUnit();
|
|
// if(m_pWellLogs[0]->GetDepthUnit()=="m"&&depthUnit!="m"&&depthUnit!="米") depthUnit="";
|
|
// else if(m_pWellLogs[0]->GetDepthUnit()=="ft"&&depthUnit!="ft"&&depthUnit!="英尺") depthUnit="";
|
|
// if(depthUnit.isEmpty()) depthUnit=m_pWellLogs[0]->GetDepthAliasUnit();
|
|
// if(depthUnit.isEmpty()) depthUnit="米";
|
|
// m_TitleField << "MD\n"+depthUnit;
|
|
// char buf[100];
|
|
// for(int j=0;j<WaveInfo.ArrayNum;j++) {
|
|
// for(int i=0;i<WaveInfo.SamplePoint;i++){
|
|
// sprintf(buf,"A:%d D:%d",j+1,i+1);
|
|
// m_TitleField << buf;//+"\n";
|
|
// }
|
|
// }
|
|
// m_TitleField << " " ;
|
|
|
|
}
|
|
|
|
void GridDataAdapter::saveMultWellLogData(bool &isScuccess)
|
|
{
|
|
// FLOATPROPERTY vM;
|
|
// vM.SetSize(3);
|
|
// vM.m_vProperty[0]=m_SDep;
|
|
// vM.m_vProperty[1]=m_EDep;
|
|
// vM.m_vProperty[2]=m_Rlev;
|
|
// QString filePath=/*m_pWellLogs[0]*/m_pWave->GetSlfFileName();
|
|
// CLogIO * logio=new CLogIO();
|
|
// if(!logio->Open(filePath.toStdString().c_str(),CSlfIO::modeReadWrite))
|
|
// {
|
|
// delete logio;
|
|
// return;
|
|
// }
|
|
|
|
// int iIndex = logio->OpenWave(m_pWave->GetName().toStdString().c_str());
|
|
// if (iIndex >= 0)
|
|
// {
|
|
// int row,col,pos;
|
|
// row=0;
|
|
// col=pos=row;
|
|
// float value,dep;
|
|
// value=dep=0;
|
|
// int actRow=0;
|
|
// int actCol=0;
|
|
// char *vchar=(char*)m_MutiVM->m_vProperty;
|
|
|
|
// int sRow=m_editRange.topRow();
|
|
// int eRow=m_editRange.bottomRow();
|
|
// int sCol=m_editRange.leftColumn();
|
|
// int eCol=m_editRange.rightColumn();
|
|
// QList<QList<float> > editlist;
|
|
// extractMultWellLogData(editlist,isScuccess);
|
|
// for(int i=sRow;i<=eRow;i++)
|
|
// {
|
|
// actRow=m_verScrolValue+i;
|
|
// col=0;
|
|
// for(int j=sCol;j<=eCol;j++)
|
|
// {
|
|
// actCol=m_horScrolValue+j;
|
|
// if(isScuccess)
|
|
// {
|
|
// pos=actRow*m_nSamples+(actCol-1);
|
|
// value=editlist.value(row).value(col);
|
|
// setData(m_RepCode,(char*)&vchar[pos*m_CodeLen],value);
|
|
// DWORD result=logio->WriteWave(iIndex,m_SDep,m_PointNum,(void*)m_MutiVM->m_vProperty);
|
|
|
|
|
|
// }
|
|
// col++;
|
|
// }
|
|
// row++;
|
|
// }
|
|
// logio->CloseWave(iIndex);
|
|
// }
|
|
// delete logio;
|
|
}
|
|
|
|
//void GridDataAdapter::extractMultWellLogData(int &row,int &col,float &value,bool &isScuccess)
|
|
void GridDataAdapter::extractMultWellLogData(QList<QList<float> > &editData,bool &isScuccess)
|
|
{
|
|
int sRow=m_editRange.topRow();
|
|
int eRow=m_editRange.bottomRow();
|
|
int sCol=m_editRange.leftColumn();
|
|
int eCol=m_editRange.rightColumn();
|
|
QString textValue;
|
|
bool isMatch=true;
|
|
QRegExp rx("[0-9.0-9]*");
|
|
QTableWidgetItem* item=NULL;
|
|
//需要更新行数
|
|
FLOATPROPERTY vM;
|
|
vM.SetSize(3);
|
|
vM.m_vProperty[0]=m_SDep;
|
|
vM.m_vProperty[1]=m_EDep;
|
|
vM.m_vProperty[2]=m_Rlev;
|
|
if(m_PointNum>0)
|
|
{
|
|
|
|
for(int i=sRow;i<=eRow;i++)
|
|
{
|
|
QList<float> rowList;
|
|
for(int j=sCol;j<=eCol;j++)
|
|
{
|
|
if(m_pAssetCopy->isParse())
|
|
{
|
|
textValue=m_pAssetCopy->itemParseText(i,j);
|
|
isScuccess=rx.exactMatch(textValue);
|
|
if(!isScuccess)
|
|
{
|
|
break;
|
|
}
|
|
rowList<<textValue.toFloat();
|
|
}else
|
|
{
|
|
item=m_table->item(i,j);
|
|
|
|
if(NULL != item)
|
|
{
|
|
textValue=item->text();
|
|
isScuccess=rx.exactMatch(textValue);
|
|
if(!isScuccess)
|
|
{
|
|
break;
|
|
}
|
|
rowList<<textValue.toFloat();
|
|
}
|
|
}
|
|
|
|
}
|
|
if(!isScuccess)
|
|
{
|
|
break;
|
|
}
|
|
editData<<rowList;
|
|
}
|
|
|
|
}
|
|
m_pAssetCopy->restParse();
|
|
}
|
|
void GridDataAdapter::setData(int repCode,char *buffer,double yy)
|
|
{
|
|
if(!buffer)
|
|
{
|
|
return;
|
|
}
|
|
switch(repCode)
|
|
{
|
|
case REPR_INT: //0
|
|
(*((int*)buffer))=(int)yy;
|
|
break;
|
|
case REPR_SHORT: //1
|
|
(*((short *)buffer))=(short)yy;
|
|
break;
|
|
case REPR_LONG://2
|
|
(*((long *)buffer))=(long)yy;
|
|
break;
|
|
case REPR_FLOAT://3
|
|
(*((float *)buffer))=yy;
|
|
break;
|
|
case REPR_DOUBLE://4
|
|
(*((double *)buffer))=(double)yy;
|
|
break;
|
|
case REPR_CHAR://5
|
|
(*((char *)buffer))=(char)yy;
|
|
break;
|
|
case REPR_UCHAR://6
|
|
(*((unsigned char *)buffer))=(unsigned char)yy;
|
|
break;
|
|
case REPR_USHORT://7
|
|
(*((unsigned short *)buffer))=(unsigned short)yy;
|
|
break;
|
|
case REPR_UINT://8
|
|
(*((unsigned int *)buffer))=(unsigned int)yy;
|
|
break;
|
|
case REPR_ULONG://9
|
|
(*((unsigned long *)buffer))=(unsigned long )yy;
|
|
break;
|
|
case REPR_STRING://10
|
|
// *yy=-99999;
|
|
break;
|
|
}
|
|
return;
|
|
}
|
|
|
|
float GridDataAdapter::getData(int repCode,char *buffer)
|
|
{
|
|
float yy;
|
|
if(!buffer)
|
|
{
|
|
return 0;
|
|
}
|
|
switch(repCode)
|
|
{
|
|
case REPR_INT: //0
|
|
yy=(double)(*((int*)buffer));
|
|
break;
|
|
case REPR_SHORT: //1
|
|
yy=(double)(*((short *)buffer));
|
|
break;
|
|
case REPR_LONG://2
|
|
yy=(double)(*((long *)buffer));
|
|
break;
|
|
case REPR_FLOAT://3
|
|
yy=(double)(*((float *)buffer));
|
|
break;
|
|
case REPR_DOUBLE://4
|
|
yy=(double)(*((double *)buffer));
|
|
break;
|
|
case REPR_CHAR://5
|
|
yy=(double)(*((char *)buffer));
|
|
break;
|
|
case REPR_UCHAR://6
|
|
yy=(double)(*((unsigned char *)buffer));
|
|
break;
|
|
case REPR_USHORT://7
|
|
yy=(double)(*((unsigned short *)buffer));
|
|
break;
|
|
case REPR_UINT://8
|
|
yy=(double)(*((unsigned int *)buffer));
|
|
break;
|
|
case REPR_ULONG://9
|
|
yy=(double)(*((unsigned long *)buffer));
|
|
break;
|
|
case REPR_STRING://10
|
|
yy=-99999;
|
|
break; }
|
|
return yy;
|
|
}
|
|
void GridDataAdapter::updatetMultWellLogData()
|
|
{
|
|
QMutexLocker locker(&m_mutex);
|
|
FLOATPROPERTY vM;
|
|
vM.SetSize(3);
|
|
vM.m_vProperty[0]=m_SDep;
|
|
vM.m_vProperty[1]=m_EDep;
|
|
vM.m_vProperty[2]=m_Rlev;
|
|
int pageCol=m_pageCol;
|
|
if(m_pageCol>m_TitleField.size())
|
|
{
|
|
m_pageCol=m_TitleField.size();
|
|
}
|
|
|
|
QStringList tempFields;
|
|
for(int i=0;i<m_pageCol;i++)
|
|
{
|
|
if(m_horScrolValue+i >= m_TitleField.size())
|
|
{
|
|
break;
|
|
}
|
|
tempFields<<m_TitleField[m_horScrolValue+i];//自水平滑块位置起获取一页的列标
|
|
}
|
|
if(pageCol != m_pageCol)
|
|
{
|
|
fillDefaultTitle(tempFields,pageCol);
|
|
}
|
|
|
|
|
|
setTableHeaderData(tempFields);
|
|
|
|
|
|
//luol 20200302
|
|
clearBuffer();
|
|
setColCount(m_TitleField.size());
|
|
int horScrollOffset=m_horScrolValue;
|
|
if(m_horScrolValue>0)
|
|
{
|
|
horScrollOffset--;
|
|
}
|
|
if(m_PointNum>0)
|
|
{
|
|
vector<double>::size_type tempVxSize = m_PointNum;
|
|
if(m_pageRow>tempVxSize)
|
|
{
|
|
m_pageRow=tempVxSize;
|
|
}
|
|
setRowCount(tempVxSize);
|
|
|
|
float val=0;
|
|
double dep=0;
|
|
int pos=0;
|
|
char *vchar=(char*)m_MutiVM->m_vProperty; //m_MutiVM已在initMultWellLogData()中获取曲线信息
|
|
QList<QList<DataPair> > data;
|
|
int maxRowRecord=m_verScrolValue+m_pageRow;
|
|
int maxColRecord=m_horScrolValue+m_pageCol;
|
|
if(maxRowRecord>tempVxSize)
|
|
{
|
|
maxRowRecord=tempVxSize;
|
|
}
|
|
if(maxColRecord>m_nSamples)
|
|
{
|
|
maxColRecord=m_nSamples;
|
|
}
|
|
m_pAssetCopy->setVerScrollValue(m_verScrolValue);
|
|
m_pAssetCopy->setHorScrollValue(m_horScrolValue);
|
|
for(vector<double>::size_type ix = m_verScrolValue; ix < maxRowRecord; ++ix)
|
|
{
|
|
dep=vM.m_vProperty[0]+ix*vM.m_vProperty[2];//cur depth
|
|
QList<DataPair> lstData;
|
|
if(m_horScrolValue==0) //The first col is depthValue
|
|
{
|
|
lstData<<DataPair(toString(dep,'f',5,0),Qt::ItemIsEditable);
|
|
}
|
|
else
|
|
{
|
|
pos=ix*m_nSamples+horScrollOffset;
|
|
if(ix<m_MutiVM->size()) val =getData(m_RepCode,(char*)&vchar[pos*m_CodeLen]);
|
|
else val=-9999;
|
|
lstData<<DataPair(toString(val,'f',DECIMALPLACESNUM,0,false));
|
|
}
|
|
|
|
for(int i=m_horScrolValue;i<maxColRecord;i++) {
|
|
pos=ix*m_nSamples+i;//该行该单元格数值存储位置
|
|
if(ix<m_MutiVM->size()) val =getData(m_RepCode,(char*)&vchar[pos*m_CodeLen]);
|
|
else val=-9999;
|
|
lstData<<DataPair(toString(val,'f',FLOATPREC,0,false));
|
|
}
|
|
data<<lstData;
|
|
}
|
|
|
|
setModelData(data);
|
|
/*
|
|
if(!ifItemWidth)
|
|
for(int i = 0; i < m_pageCol; i++)
|
|
m_table->setColumnWidth(i, itemWidth[m_horScrolValue + i]);
|
|
*/
|
|
}
|
|
}
|
|
void GridDataAdapter::updatetTDTWellLogData()
|
|
{
|
|
QMutexLocker locker(&m_mutex);
|
|
QStringList tempFields;
|
|
|
|
if(m_pageCol>m_TitleField.size())
|
|
{
|
|
m_pageCol=m_TitleField.size();
|
|
}
|
|
|
|
if(m_pageRow > recordcount)
|
|
{
|
|
m_pageRow=recordcount;
|
|
}
|
|
|
|
for(int i=0;i<m_pageCol;i++)
|
|
{
|
|
if(/*m_horScrolValue+*/ i >= m_TitleField.size())
|
|
{
|
|
break;
|
|
}
|
|
|
|
tempFields<<m_TitleField[/*m_horScrolValue+*/i];
|
|
}
|
|
|
|
{
|
|
clearBuffer();
|
|
setRowCount(recordcount);
|
|
setColCount(m_TitleField.size());
|
|
}
|
|
|
|
|
|
setTableHeaderData(tempFields);
|
|
|
|
int maxRowRecord=m_pageRow;
|
|
int maxColRecord=m_pageCol;
|
|
if(maxRowRecord>recordcount)
|
|
{
|
|
maxRowRecord=recordcount;
|
|
}
|
|
if(maxColRecord>m_TitleField.size())
|
|
{
|
|
maxColRecord=m_TitleField.size();
|
|
}
|
|
|
|
//获得表格头
|
|
CLogIO *logio=new CLogIO;
|
|
if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeRead)) {
|
|
delete logio;
|
|
return ;
|
|
}
|
|
char name[100];
|
|
strcpy(name,m_pWellLogs[0]->GetName().toStdString().c_str());
|
|
int iIndex=logio->OpenTDT(name);
|
|
if (iIndex >=0)
|
|
{
|
|
logio->GetTDTInfo(iIndex,&TDT);
|
|
TDT_DATA**pTDT=new TDT_DATA*[TDT.TotalLogNumber];
|
|
int *num=new int[TDT.TotalLogNumber];
|
|
for(int i=0;i<TDT.TotalLogNumber;i++)
|
|
{
|
|
pTDT[i]=new TDT_DATA[TDT.MaxLogSamples];
|
|
unsigned int t=0;
|
|
num[i]=logio->ReadTDT(iIndex,i+1,&t,pTDT[i]);
|
|
}
|
|
int fc=TDT.TotalLogNumber*3;
|
|
//读取数据
|
|
char buf[513];
|
|
memset(buf,0,513);
|
|
//int c=m_TitleField.size();
|
|
QList<QList<DataPair> > data;
|
|
for(int rowindex=/*m_verScrolValue*/ 0;rowindex<maxRowRecord;rowindex++)
|
|
{
|
|
QList<DataPair> lstData;
|
|
for(int columnindex=/*m_horScrolValue*/ 0 ;columnindex<maxColRecord/3;columnindex++)
|
|
{
|
|
if(rowindex<num[columnindex]-1){
|
|
sprintf(buf,"%g",pTDT[columnindex][rowindex].Depth);
|
|
lstData<<DataPair(buf);
|
|
sprintf(buf,"%g",pTDT[columnindex][rowindex].Time);
|
|
lstData<<DataPair(buf);
|
|
sprintf(buf,"%g",pTDT[columnindex][rowindex].Value);
|
|
lstData<<DataPair(buf);
|
|
}
|
|
else {
|
|
buf[0]=0;
|
|
lstData<<DataPair(buf);
|
|
lstData<<DataPair(buf);
|
|
lstData<<DataPair(buf);
|
|
}
|
|
}
|
|
data<<lstData;
|
|
}
|
|
setModelData(data);
|
|
for(int i=0;i<TDT.TotalLogNumber;i++) {
|
|
delete[]pTDT[i];
|
|
pTDT[i]=NULL;
|
|
}
|
|
delete pTDT;
|
|
delete num;
|
|
}
|
|
logio->CloseTDT(iIndex);
|
|
delete logio;
|
|
|
|
if(!ifItemWidth)
|
|
for(int i = 0; i < m_pageCol; i++)
|
|
m_table->setColumnWidth(i, itemWidth[/*m_horScrolValue*/ + i]);
|
|
}
|
|
void GridDataAdapter::updatetFMTWellLogData()
|
|
{
|
|
QMutexLocker locker(&m_mutex);
|
|
FLOATPROPERTY vM;
|
|
vM.SetSize(3);
|
|
vM.m_vProperty[0]=m_SDep;
|
|
vM.m_vProperty[1]=m_EDep;
|
|
vM.m_vProperty[2]=m_Rlev;
|
|
int pageCol=m_pageCol;
|
|
if(m_pageCol>m_TitleField.size())
|
|
{
|
|
m_pageCol=m_TitleField.size();
|
|
}
|
|
|
|
QStringList tempFields;
|
|
for(int i=0;i<m_pageCol;i++)
|
|
{
|
|
if(m_horScrolValue+i >= m_TitleField.size())
|
|
{
|
|
break;
|
|
}
|
|
tempFields<<m_TitleField[m_horScrolValue+i];//自水平滑块位置起获取一页的列标
|
|
}
|
|
if(pageCol != m_pageCol)
|
|
{
|
|
fillDefaultTitle(tempFields,pageCol);
|
|
}
|
|
|
|
|
|
setTableHeaderData(tempFields);
|
|
|
|
|
|
//luol 20200302
|
|
clearBuffer();
|
|
setColCount(m_TitleField.size());
|
|
int horScrollOffset=m_horScrolValue;
|
|
if(m_horScrolValue>0)
|
|
{
|
|
horScrollOffset--;
|
|
}
|
|
if(m_PointNum>0)
|
|
{
|
|
vector<double>::size_type tempVxSize = m_PointNum;
|
|
if(m_pageRow>tempVxSize)
|
|
{
|
|
m_pageRow=tempVxSize;
|
|
}
|
|
setRowCount(tempVxSize);
|
|
|
|
float val=0;
|
|
double dep=0;
|
|
int pos=0;
|
|
char *vchar=(char*)m_MutiVM->m_vProperty; //m_MutiVM已在initMultWellLogData()中获取曲线信息
|
|
QList<QList<DataPair> > data;
|
|
int maxRowRecord=m_verScrolValue+m_pageRow;
|
|
int maxColRecord=m_horScrolValue+m_pageCol;
|
|
if(maxRowRecord>tempVxSize)
|
|
{
|
|
maxRowRecord=tempVxSize;
|
|
}
|
|
if(maxColRecord>m_nSamples)
|
|
{
|
|
maxColRecord=m_nSamples;
|
|
}
|
|
m_pAssetCopy->setVerScrollValue(m_verScrolValue);
|
|
m_pAssetCopy->setHorScrollValue(m_horScrolValue);
|
|
for(vector<double>::size_type ix = m_verScrolValue; ix < maxRowRecord; ++ix)
|
|
{
|
|
dep=vM.m_vProperty[0]+ix*vM.m_vProperty[2];//cur depth
|
|
QList<DataPair> lstData;
|
|
if(m_horScrolValue==0) //The first col is depthValue
|
|
{
|
|
lstData<<DataPair(toString(dep,'f',5,0),Qt::ItemIsEditable);
|
|
}
|
|
else
|
|
{
|
|
pos=ix*m_nSamples+horScrollOffset;
|
|
if(ix<m_MutiVM->size()) val =getData(m_RepCode,(char*)&vchar[pos*m_CodeLen]);
|
|
else val=-9999;
|
|
lstData<<DataPair(toString(val,'f',DECIMALPLACESNUM,0,false));
|
|
}
|
|
|
|
for(int i=m_horScrolValue;i<maxColRecord;i++) {
|
|
pos=ix*m_nSamples+i;//该行该单元格数值存储位置
|
|
if(ix<m_MutiVM->size()) val =getData(m_RepCode,(char*)&vchar[pos*m_CodeLen]);
|
|
else val=-9999;
|
|
lstData<<DataPair(toString(val,'f',FLOATPREC,0,false));
|
|
}
|
|
data<<lstData;
|
|
}
|
|
setModelData(data);
|
|
}
|
|
}
|
|
|
|
void GridDataAdapter::exportMultWellLogData(FILE *fp, DepthProgress& process)
|
|
{
|
|
|
|
if(m_PointNum>0)
|
|
{
|
|
vector<double>::size_type tempVxSize = m_PointNum;
|
|
float val=0;
|
|
int pos=0;
|
|
QString conTents;
|
|
process.CreatProgress(0,tempVxSize,"正在导出数据...");
|
|
char *vchar=(char*)m_MutiVM->m_vProperty;
|
|
for(vector<double>::size_type ix = 0; ix < tempVxSize; ++ix)
|
|
{
|
|
conTents.clear();
|
|
for(int i=0;i<m_nSamples;i++) {
|
|
pos=ix*m_nSamples+i;
|
|
val=getData(m_RepCode,(char*)&vchar[pos*m_CodeLen]);
|
|
QString str=toString(val,'f',FLOATPREC,0,false);
|
|
str.replace(","," ");
|
|
if(i ==m_nSamples-1)
|
|
{
|
|
conTents += str ;
|
|
}
|
|
else
|
|
{
|
|
conTents += str + " ";
|
|
}
|
|
}
|
|
fprintf(fp,"%s\n",conTents.toStdString().c_str());
|
|
process.SetDepth(ix+1);
|
|
}
|
|
}
|
|
}
|
|
|
|
void GridDataAdapter::initTableWellLogData(DType type,QList<CObjWellLog*> WellLogs)
|
|
{
|
|
m_pWellLogs=WellLogs;
|
|
|
|
for(int i = 0; i < m_pWellLogs.size(); i++){
|
|
m_pWellLogs[i]->isUsing = true;
|
|
}
|
|
|
|
m_dtype=type;
|
|
m_pAssetCopy->SetWellLogs(type,WellLogs);
|
|
m_TitleField.clear();
|
|
int a=0;
|
|
//获得表格头
|
|
CLogIO *logio=new CLogIO;
|
|
if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeRead)) {
|
|
delete logio;
|
|
return ;
|
|
}
|
|
char name[100];
|
|
strcpy(name,m_pWellLogs[0]->GetName().toStdString().c_str());
|
|
int iIndex=logio->OpenTable(name);
|
|
if (iIndex >=0)
|
|
{
|
|
a=1;
|
|
int fc=logio->GetTableFieldCount(iIndex);
|
|
if(fc<1) {
|
|
delete logio;
|
|
return;
|
|
}
|
|
Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[fc+1];
|
|
logio->GetTableFieldInfo(iIndex,field);
|
|
for(int j=0;j<fc;j++) {
|
|
QString fieldName;
|
|
QString unit=field[j].HZUnit;
|
|
if(unit.isEmpty()) unit=field[j].Unit;
|
|
if(unit.isEmpty())
|
|
{
|
|
char strTmp[16] = "CurveFamily.ini";
|
|
QStringList cs=GetSimilarCurves(field[j].Name,strTmp,false);
|
|
if(cs.size()>3) {
|
|
unit=cs[3];
|
|
}
|
|
}
|
|
fieldName=field[j].Name;
|
|
|
|
int pos=0,pos1=0;
|
|
if((pos=unit.indexOf("^"))>-1&&(pos1=unit.indexOf("^",pos+1))>-1) {
|
|
QStringList fh=GetSimilarCurves(unit.mid(pos,pos1-pos+1));
|
|
if(fh.size())unit.replace(unit.mid(pos,pos1-pos+1),fh[0]);
|
|
}
|
|
pos=0,pos1=0;
|
|
if((pos=unit.indexOf("!"))>-1&&(pos1=unit.indexOf("!",pos+1))>-1) {
|
|
QStringList fh=GetSimilarCurves(unit.mid(pos,pos1-pos+1));
|
|
if(fh.size())unit.replace(unit.mid(pos,pos1-pos+1),fh[0]);
|
|
}
|
|
|
|
fieldName+="\n"+unit;
|
|
m_TitleField.push_back(fieldName);
|
|
}
|
|
m_TitleField.push_back(" ");
|
|
delete[] field;
|
|
recordcount=logio->GetTableRecordCount(iIndex);
|
|
{
|
|
clearBuffer();
|
|
setRowCount(recordcount);
|
|
setColCount(m_TitleField.size());
|
|
|
|
}
|
|
}
|
|
logio->CloseTable(iIndex);
|
|
delete logio;
|
|
}
|
|
|
|
QString digDec(QString cs)
|
|
{
|
|
int index=cs.indexOf(".");
|
|
if(index >= 0) {
|
|
QStringList css=cs.split('e');
|
|
if(css.size() > 1)
|
|
cs = css[0];
|
|
|
|
int len = cs.length();
|
|
int j=0;
|
|
for(int i = len - 1; i >= index; i--) {
|
|
if(cs.at(i)=='0') j++;
|
|
else{
|
|
if(cs.at(i) == '.') /*j++*/j = len - (index + 1) - DECIMALPLACESNUM;//暂时都保留3位
|
|
else j = len - (index + 1) - DECIMALPLACESNUM;
|
|
break;
|
|
}
|
|
}
|
|
cs = cs.left(len - j);
|
|
if(css.size() > 1) {
|
|
css[0] = cs;
|
|
cs = css.join("e");
|
|
}
|
|
}
|
|
return cs;
|
|
}
|
|
//刷新表格数据
|
|
void GridDataAdapter::updatetTableWellLogData()
|
|
{
|
|
|
|
QMutexLocker locker(&m_mutex);
|
|
QStringList tempFields;
|
|
|
|
if(m_pageCol>m_TitleField.size())
|
|
{
|
|
m_pageCol=m_TitleField.size();
|
|
}
|
|
|
|
if(m_pageRow > recordcount)
|
|
{
|
|
m_pageRow=recordcount;
|
|
}
|
|
|
|
for(int i=0;i<m_pageCol;i++)
|
|
{
|
|
if(/*m_horScrolValue+*/ i >= m_TitleField.size())
|
|
{
|
|
break;
|
|
}
|
|
|
|
tempFields<<m_TitleField[/*m_horScrolValue+*/i];
|
|
}
|
|
|
|
{
|
|
clearBuffer();
|
|
setRowCount(recordcount);
|
|
setColCount(m_TitleField.size());
|
|
}
|
|
|
|
|
|
setTableHeaderData(tempFields);
|
|
|
|
int maxRowRecord=m_pageRow;
|
|
int maxColRecord=m_pageCol;
|
|
if(maxRowRecord>recordcount)
|
|
{
|
|
maxRowRecord=recordcount;
|
|
}
|
|
if(maxColRecord>m_TitleField.size())
|
|
{
|
|
maxColRecord=m_TitleField.size();
|
|
}
|
|
|
|
//获得表格头
|
|
CLogIO *logio=new CLogIO;
|
|
if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeRead)) {
|
|
delete logio;
|
|
return ;
|
|
}
|
|
char name[100];
|
|
strcpy(name,m_pWellLogs[0]->GetName().toStdString().c_str());
|
|
int iIndex=logio->OpenTable(name);
|
|
if (iIndex >=0)
|
|
{
|
|
int fc=logio->GetTableFieldCount(iIndex);
|
|
//读取数据
|
|
char buf[513];
|
|
memset(buf,0,513);
|
|
//int c=m_TitleField.size();
|
|
QList<QList<DataPair> > data;
|
|
for(int rowindex=/*m_verScrolValue*/ 0;rowindex<maxRowRecord;rowindex++)
|
|
{
|
|
QList<DataPair> lstData;
|
|
for(int columnindex=/*m_horScrolValue*/ 0 ;columnindex<maxColRecord;columnindex++)
|
|
{
|
|
int ty=-1;
|
|
if(columnindex<fc) {
|
|
ty=logio->GetTableFieldData(iIndex,columnindex,buf,rowindex+1,true);
|
|
}
|
|
else strcpy(buf,"");
|
|
if(strlen(buf)>512) buf[512]=0;
|
|
if(ty==0) {
|
|
strcpy(buf,"");
|
|
lstData<<DataPair(buf);
|
|
}
|
|
else if(ty!=6) {
|
|
QString Qbug = digDec(/*QString::fromLocal8Bit*/(buf));
|
|
lstData<<DataPair(Qbug);
|
|
}
|
|
else lstData<<DataPair(buf);
|
|
}
|
|
data<<lstData;
|
|
}
|
|
|
|
setModelData(data);
|
|
|
|
}
|
|
logio->CloseTable(iIndex);
|
|
delete logio;
|
|
|
|
if(!ifItemWidth)
|
|
for(int i = 0; i < m_pageCol; i++)
|
|
m_table->setColumnWidth(i, itemWidth[/*m_horScrolValue*/ + i]);
|
|
}
|
|
//保存表格数据
|
|
void GridDataAdapter::saveTableWellLogData(bool &isScuccess)
|
|
{
|
|
int sRow=m_editRange.topRow();
|
|
int eRow=m_editRange.bottomRow();
|
|
int sCol=m_editRange.leftColumn();
|
|
int eCol=m_editRange.rightColumn();
|
|
int actRow=0;
|
|
int actCol=0;
|
|
QString textValue;
|
|
//QRegExp rx("[0-9.0-9]*");
|
|
|
|
CLogIO *logio=new CLogIO;
|
|
if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeReadWrite)) {
|
|
delete logio;
|
|
return;
|
|
}
|
|
int iIndex=logio->OpenTable(m_pWellLogs[0]->GetName().toStdString().c_str());
|
|
if (iIndex >=0)
|
|
{
|
|
|
|
int fc=logio->GetTableFieldCount(iIndex);
|
|
Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[fc+1];
|
|
logio->GetTableFieldInfo(iIndex,field);
|
|
for(int r=sRow;r<=eRow;r++)
|
|
{
|
|
actRow=m_verScrolValue+r;
|
|
for(int c=sCol;c<=eCol;c++)
|
|
{
|
|
actCol=m_horScrolValue+c;
|
|
QTableWidgetItem* item= m_table->item(r, c);
|
|
//QString mColumn ="";
|
|
char buf[513];
|
|
if(NULL != item)
|
|
{
|
|
isScuccess=true;
|
|
textValue=item->text();
|
|
|
|
if(field[actCol].RepCode==6||field[actCol].Reserved) {
|
|
strcpy(buf,textValue.toStdString().c_str());
|
|
logio->SetTableFieldData(iIndex,actCol,buf,actRow+1);
|
|
}
|
|
else {
|
|
float val=textValue.toFloat();
|
|
logio->SetTableFieldData(iIndex,actCol,(char *)&val,actRow+1);
|
|
}
|
|
}else
|
|
{
|
|
isScuccess=false;
|
|
}
|
|
}
|
|
}
|
|
|
|
logio->CloseTable(iIndex);
|
|
delete[] field;
|
|
}
|
|
delete logio;
|
|
}
|
|
|
|
void GridDataAdapter::importWellLogData(QFile &importFile, DepthProgress& process)
|
|
{
|
|
int columns=0;
|
|
int rows=0;
|
|
int cindex=0;
|
|
QString textValue;
|
|
QString strLine="";
|
|
PFLOATPROPERTY &vM=m_pWellLogs[0]->GetMD();
|
|
|
|
//获取行列及数据
|
|
getRowsColumnsByHeader(importFile,rows,columns,strLine);
|
|
QStringList colContents=strLine.split(" ",QString::KeepEmptyParts);
|
|
if(colContents.size() != columns)
|
|
{
|
|
colContents.removeLast();
|
|
}
|
|
|
|
if(colContents.size() != columns)
|
|
{
|
|
return;
|
|
}
|
|
float val=0;
|
|
process.CreatProgress(0,rows,"正在导入数据...");
|
|
for(int i=0;i<rows;i++)
|
|
{
|
|
for(int j=0;j<columns;j++)
|
|
{
|
|
cindex=j;
|
|
if(1==m_pWellLogs.size())
|
|
{
|
|
cindex=0;
|
|
}//else 多曲线更新
|
|
textValue=colContents.value(cindex);
|
|
if(textValue.isEmpty())
|
|
{
|
|
textValue="0.00";
|
|
}
|
|
val=textValue.toFloat();
|
|
m_pWellLogs[cindex]->SetData(i,&val);
|
|
}
|
|
process.SetDepth(i+1);
|
|
if(i+1 != rows)
|
|
{
|
|
strLine=importFile.readLine();
|
|
colContents=strLine.split(" ",QString::KeepEmptyParts);
|
|
if(colContents.size() != columns)
|
|
{
|
|
colContents.removeLast();
|
|
}
|
|
}
|
|
}
|
|
for(int i=0;i<m_pWellLogs.size();i++) m_pWellLogs[i]->SaveToSLF();
|
|
}
|
|
|
|
void GridDataAdapter::importTableWellLogData(QFile &importFile)
|
|
{
|
|
CLogIO *logio=new CLogIO;
|
|
if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeReadWrite)) {
|
|
delete logio;
|
|
return;
|
|
}
|
|
int iIndex=logio->OpenTable(m_pWellLogs[0]->GetName().toStdString().c_str());
|
|
if (iIndex >=0)
|
|
{
|
|
int fc=logio->GetTableFieldCount(iIndex);
|
|
Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[fc+1];
|
|
logio->GetTableFieldInfo(iIndex,field);
|
|
if(!importFile.seek(0))
|
|
{
|
|
delete logio;
|
|
return;
|
|
}
|
|
int rows;
|
|
int columns;
|
|
QString textValue;
|
|
QString strLine="";
|
|
//获取行列及数据
|
|
|
|
if(!getRowsColumnsByHeader(importFile,rows,columns,strLine)) {
|
|
delete logio;
|
|
return;
|
|
}
|
|
QStringList colContents=strLine.split(" ",QString::KeepEmptyParts);
|
|
colContents.removeLast();
|
|
rows=0;
|
|
while(!importFile.atEnd())
|
|
{
|
|
strLine=importFile.readLine();
|
|
colContents=strLine.split("\t",QString::KeepEmptyParts);
|
|
rows++;
|
|
for(int c=0;c<columns;c++)
|
|
{
|
|
char buf[513];
|
|
textValue=colContents[c];
|
|
if(field[c].RepCode==6||field[c].Reserved)
|
|
{
|
|
strcpy(buf,textValue.toStdString().c_str());
|
|
logio->SetTableFieldData(iIndex,c,buf,rows);
|
|
}
|
|
else
|
|
{
|
|
float val=textValue.toFloat();
|
|
logio->SetTableFieldData(iIndex,c,(char *)&val,rows);
|
|
}
|
|
}
|
|
}
|
|
logio->CloseTable(iIndex);
|
|
delete[] field;
|
|
}
|
|
delete logio;
|
|
}
|
|
|
|
void GridDataAdapter::exportTableWellLogData(FILE *fp, DepthProgress& process)
|
|
{
|
|
//获得表格头
|
|
CLogIO *logio=new CLogIO;
|
|
if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeRead)) {
|
|
delete logio;
|
|
return ;
|
|
}
|
|
char name[100];
|
|
strcpy(name,m_pWellLogs[0]->GetName().toStdString().c_str());
|
|
int iIndex=logio->OpenTable(name);
|
|
if (iIndex >=0)
|
|
{
|
|
int fc=logio->GetTableFieldCount(iIndex);
|
|
Slf_TABLE_FIELD*pFiled=new Slf_TABLE_FIELD[fc+1];
|
|
logio->GetTableFieldInfo(iIndex,pFiled);
|
|
|
|
for(int columnindex=0;columnindex<fc;columnindex++)
|
|
{
|
|
if(columnindex==fc-1) fprintf(fp,"%s\n",pFiled[columnindex].HZName);
|
|
else fprintf(fp,"%s ",pFiled[columnindex].HZName);
|
|
}
|
|
for(int columnindex=0;columnindex<fc;columnindex++)
|
|
{
|
|
if(columnindex==fc-1) fprintf(fp,"%s\n",pFiled[columnindex].Unit);
|
|
else fprintf(fp,"%s ",pFiled[columnindex].Unit);
|
|
}
|
|
//读取数据
|
|
char buf[513];
|
|
memset(buf,0,513);
|
|
QString conTents;
|
|
process.CreatProgress(0,recordcount,"正在导出数据...");
|
|
for(int rowindex=0;rowindex<recordcount;rowindex++)
|
|
{
|
|
conTents="";
|
|
for(int columnindex=0;columnindex<m_TitleField.size()-1;columnindex++)
|
|
{
|
|
if(columnindex<fc)
|
|
{
|
|
int type=logio->GetTableFieldData(iIndex,columnindex,rowindex+1,buf);
|
|
if(pFiled[columnindex].RepCode==6)
|
|
{
|
|
if(strlen(buf)>512)
|
|
{
|
|
buf[512]=0;
|
|
}
|
|
}
|
|
if(type!=6&&type<sizeof(RepSize)+1) {
|
|
float yy=*(float*)buf;
|
|
sprintf(buf,"%g",yy);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
strcpy(buf,"0");
|
|
}
|
|
|
|
if(strlen(buf)>512)
|
|
{
|
|
buf[512]=0;
|
|
}
|
|
|
|
QString str(buf);
|
|
if(columnindex ==m_TitleField.size()-1)
|
|
{
|
|
conTents += str ;
|
|
}
|
|
else
|
|
{
|
|
conTents += str + "\t";
|
|
}
|
|
}
|
|
fprintf(fp,"%s\n",conTents.toStdString().c_str());
|
|
process.SetDepth(rowindex+1);
|
|
}
|
|
delete pFiled;
|
|
}
|
|
logio->CloseTable(iIndex);
|
|
delete logio;
|
|
}
|
|
|
|
bool GridDataAdapter::dataInfoHeader(CLogIO *logio,QStringList &fieldList,QString &wellName,int &rowCount)
|
|
{
|
|
int wellLogSize= m_pWellLogs.size();
|
|
char name[100];
|
|
QByteArray buffer;
|
|
buffer.resize(100);
|
|
QStringList tempFields;
|
|
QString fieldName,fieldType,fieldStr;
|
|
for(int i=0;i<wellLogSize;i++)
|
|
{
|
|
strcpy(name,m_pWellLogs[i]->GetName().toStdString().c_str());
|
|
if(!logio->Open(m_pWellLogs[i]->GetSlfFileName().toStdString().c_str(),CLogIO::modeRead)) {
|
|
return false;
|
|
}
|
|
int iIndex=logio->OpenTable(name);
|
|
|
|
//导出头信息
|
|
if (iIndex >=0)
|
|
{
|
|
Slf_FILE_MESSAGE mssage;
|
|
logio->GetFileMessage(mssage);
|
|
wellName=mssage.WellName;
|
|
if(m_dtype != D_MultWellLogData)
|
|
{
|
|
int fc=logio->GetTableFieldCount(iIndex);
|
|
Slf_TABLE_FIELD *field=new Slf_TABLE_FIELD[fc+1];
|
|
logio->GetTableFieldInfo(iIndex,field);
|
|
const char *Rep_STR[]={
|
|
"INT","SHORT","LONG","FLOAT","DOUBLE","STRING","CHAR","UCHAR","USHORT","UINT","ULONG"
|
|
};
|
|
for(int i=0;i<fc;i++)
|
|
{
|
|
QString unit=field[i].HZUnit;
|
|
if(unit.isEmpty()) unit=field[i].Unit;
|
|
if(unit.isEmpty())
|
|
{
|
|
char strTmp[16] = "CurveFamily.ini";
|
|
QStringList cs=GetSimilarCurves(field[i].Name,strTmp,false);
|
|
if(cs.size()>3) {
|
|
unit=cs[3];
|
|
}
|
|
}
|
|
int pos=0,pos1=0;
|
|
if((pos=unit.indexOf("^"))>-1&&(pos1=unit.indexOf("^",pos+1))>-1) {
|
|
QStringList fh=GetSimilarCurves(unit.mid(pos,pos1-pos+1));
|
|
if(fh.size())unit.replace(unit.mid(pos,pos1-pos+1),fh[0]);
|
|
}
|
|
pos=0,pos1=0;
|
|
if((pos=unit.indexOf("!"))>-1&&(pos1=unit.indexOf("!",pos+1))>-1) {
|
|
QStringList fh=GetSimilarCurves(unit.mid(pos,pos1-pos+1));
|
|
if(fh.size())unit.replace(unit.mid(pos,pos1-pos+1),fh[0]);
|
|
}
|
|
fieldName=field[i].Name;
|
|
fieldList<<fieldName+"\n"+unit;
|
|
}
|
|
delete[] field;
|
|
}else
|
|
{
|
|
QStringList tempList=m_TitleField;
|
|
tempList.removeFirst();
|
|
tempList.removeLast();
|
|
for(int f=0;f<tempList.size();f++)
|
|
{
|
|
fieldStr=QString(tempList.value(f));
|
|
if(!f) fieldList<<fieldStr;
|
|
else fieldList<<"\t"<<fieldStr;
|
|
}
|
|
}
|
|
}
|
|
logio->CloseTable(iIndex);
|
|
logio->Close();
|
|
}
|
|
//获取行数
|
|
switch(m_dtype)
|
|
{
|
|
case D_WellData:
|
|
|
|
|
|
// if(NULL != m_pWell)
|
|
// {
|
|
// m_pWell->LoadXYZ();
|
|
// DOUBLEPROPERTY& vX = m_pWell->GetX();
|
|
// DOUBLEPROPERTY& vY = m_pWell->GetY();
|
|
// DOUBLEPROPERTY& vZ = m_pWell->GetZ();
|
|
|
|
// if( (vX.empty() == false) && (vX.size() == vY.size()) && (vY.size()== vZ.size()) )
|
|
// {
|
|
// rowCount= vX.size();
|
|
// }
|
|
// m_pWell->ClearXYZ();
|
|
// }
|
|
|
|
break;
|
|
case D_WellLogData:
|
|
{
|
|
PFLOATPROPERTY &vM=m_pWellLogs[0]->GetMD();
|
|
if(vM.size()>0) {
|
|
if(vP[0]->empty() == false)
|
|
{
|
|
rowCount = vP[0]->size();
|
|
}
|
|
}
|
|
|
|
}
|
|
break;
|
|
case D_MultWellLogData:
|
|
{
|
|
if(m_PointNum>0)
|
|
{
|
|
rowCount = m_PointNum;
|
|
}
|
|
|
|
}
|
|
break;
|
|
case D_TableWellLogData:
|
|
{
|
|
rowCount=recordcount;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//导出数据
|
|
bool GridDataAdapter::tableToCSVFile()
|
|
{
|
|
char name[100];
|
|
int wellLogSize= m_pWellLogs.size();
|
|
if(wellLogSize==0)
|
|
{
|
|
return false;
|
|
}
|
|
bool isMultCure=wellLogSize>1;
|
|
|
|
QString filename=m_pWellLogs[0]->GetSlfFileName().toStdString().c_str();
|
|
int a=filename.lastIndexOf("\\");
|
|
int b=filename.lastIndexOf("/");
|
|
if(b>a) a=b;
|
|
if(a>-1) filename=filename.mid(a+1);
|
|
a=filename.lastIndexOf(".");
|
|
if(a>-1) filename=filename.left(a);
|
|
QString logdata="";
|
|
if(isMultCure)
|
|
{
|
|
strcpy(name,filename.toStdString().c_str());
|
|
logdata=GetOutDataPath()+filename+".txt";
|
|
}else
|
|
{
|
|
strcpy(name,m_pWellLogs[0]->GetName().toStdString().c_str());
|
|
logdata=GetOutDataPath()+"\\"+filename+"_"+name+".txt";
|
|
}
|
|
|
|
CLogIO *logio=new CLogIO;
|
|
QStringList fieldList;
|
|
QString wellName="";
|
|
int rowCount=0;
|
|
QString dirFile = QFileDialog::getSaveFileName(m_table, ("Export File"),logdata, ("txt File(*.txt)"));
|
|
FILE *fp=fopen(dirFile.toStdString().c_str(),"wt");
|
|
|
|
if(!fp)
|
|
{
|
|
delete logio;
|
|
return false;
|
|
}
|
|
dataInfoHeader(logio,fieldList,wellName,rowCount);
|
|
|
|
for(int i=0;i<fieldList.size();i++) {
|
|
QStringList STRS=fieldList[i].split("\n");
|
|
if(i==fieldList.size()-1) fprintf(fp,"%s\n",STRS[0].toStdString().c_str());
|
|
else fprintf(fp,"%s\t",STRS[0].toStdString().c_str());
|
|
}
|
|
fieldList.clear();
|
|
delete logio;
|
|
|
|
DepthProgress progress;
|
|
//分类导出
|
|
switch(m_dtype)
|
|
{
|
|
case D_WellData:
|
|
{
|
|
exportWellData(fp,progress);
|
|
}
|
|
break;
|
|
case D_WellLogData:
|
|
{
|
|
exportWellLogData(fp,progress);
|
|
}
|
|
break;
|
|
case D_MultWellLogData:
|
|
{
|
|
exportMultWellLogData(fp,progress);
|
|
}
|
|
break;
|
|
case D_TableWellLogData:
|
|
{
|
|
exportTableWellLogData(fp,progress);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
progress.DelProgress();
|
|
|
|
fclose(fp);
|
|
|
|
QMessageBox::about(NULL, "提示", "导出成功!");
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
bool GridDataAdapter::getRowsColumnsByHeader(QFile &importFile,int &rows,int &columns,QString &contentLine)
|
|
{
|
|
if(!importFile.isOpen()
|
|
|| !importFile.seek(0)
|
|
)
|
|
{
|
|
return 0;
|
|
}
|
|
QString strLine=importFile.readLine();
|
|
if(strLine.indexOf("\t")<0) {
|
|
AfxMessageBox("数据需要用制表符分割!");
|
|
return 0;
|
|
}
|
|
while(strLine.isEmpty())
|
|
{
|
|
if(importFile.atEnd()) break;
|
|
strLine=importFile.readLine();
|
|
}
|
|
QString strValue="";
|
|
int cols=0;//没有包含深度列
|
|
cols=strLine.split("\t").size();
|
|
contentLine=strLine;
|
|
columns=cols;
|
|
return 1;
|
|
}
|
|
//导入数据
|
|
bool GridDataAdapter::importToFile()
|
|
{
|
|
QString fileName = QFileDialog::getOpenFileName(m_table, ("Open File"),GetOutDataPath(), ("csv File(*.csv *.txt)"));
|
|
QString data;
|
|
QFile importedCSV(fileName);
|
|
QStringList rowOfData;
|
|
QStringList rowData;
|
|
QStringList rowHeaderData;
|
|
data.clear();
|
|
rowOfData.clear();
|
|
rowData.clear();
|
|
int rowCount,columnCount;
|
|
|
|
columnCount=0;
|
|
rowCount=0;
|
|
bool ret = importedCSV.open(QFile::ReadOnly);
|
|
if(!ret)
|
|
{
|
|
return ret;
|
|
}
|
|
DepthProgress progress;
|
|
switch(m_dtype)
|
|
{
|
|
//导入井眼轨迹
|
|
case D_WellData:
|
|
{
|
|
}
|
|
break;
|
|
//导入曲线数据
|
|
case D_WellLogData:
|
|
{
|
|
importWellLogData(importedCSV,progress);
|
|
updatetWellLogData();
|
|
updateTableView();
|
|
}
|
|
break;
|
|
//导入多维曲线数据
|
|
case D_MultWellLogData:
|
|
{
|
|
// saveMultWellLogData(isExtract);
|
|
}
|
|
break;
|
|
//导入表格数据
|
|
case D_TableWellLogData:
|
|
{
|
|
importTableWellLogData(importedCSV);
|
|
updatetTableWellLogData();
|
|
updateTableView();
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
progress.DelProgress();
|
|
importedCSV.close();
|
|
QMessageBox::about(NULL, "提示", "导入成功!");
|
|
return true;
|
|
}
|
|
|
|
////////////////////////垂直滚动条滑块点击释放
|
|
void GridDataAdapter::slotVerScrollBarPressed()
|
|
{
|
|
VerScrollUp = false;
|
|
|
|
if(m_pageRow<1) m_pageRow=1;
|
|
|
|
if(m_dtype == D_TableWellLogData||
|
|
m_dtype==D_TDTWellLogData||
|
|
m_dtype==D_FMTWellLogData)
|
|
return;
|
|
m_popTip->show();
|
|
|
|
float m_popTipValue;
|
|
int m_verScrolValueNew;
|
|
if(m_SDep > 0 && m_Rlev > 0){
|
|
if(m_PointNum > 0){
|
|
m_verScrolValueNew = m_verScrolValue + m_pageRow * m_verScrolValue / m_PointNum;
|
|
m_popTipValue = m_SDep + m_verScrolValueNew * m_Rlev;
|
|
m_popTipValue = float(int(m_popTipValue * 10)) / 10;
|
|
}
|
|
else{
|
|
m_popTipValue = m_SDep + m_verScrolValue * m_Rlev;
|
|
m_popTipValue = float(int(m_popTipValue * 10)) / 10;
|
|
}
|
|
m_popTip->moveCursorPoint(m_popTipValue);
|
|
}
|
|
else{
|
|
int offset= m_verScrolValue % m_pageRow;
|
|
QTableWidgetItem *item= m_table->item(offset,0);
|
|
|
|
if(NULL != item)
|
|
{
|
|
m_popTip->moveCursorPoint(item->text().toFloat());
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void GridDataAdapter::slotVerScrollBarReleased()
|
|
{
|
|
if(m_dtype == D_TableWellLogData||
|
|
m_dtype==D_TDTWellLogData||
|
|
m_dtype==D_FMTWellLogData)
|
|
return;
|
|
m_popTip->hide();
|
|
|
|
VerScrollUp = true;
|
|
}
|
|
|
|
void GridDataAdapter::slotHorScrollBarPressed()
|
|
{
|
|
VerScrollUp = false;
|
|
}
|
|
|
|
void GridDataAdapter::slotHorScrollBarReleased()
|
|
{
|
|
VerScrollUp = true;
|
|
}
|
|
|
|
void GridDataAdapter::setRowCount(int rowCount)
|
|
{
|
|
if(NULL != m_table)
|
|
{
|
|
//qDebug()<<rowCount-m_pageRow;
|
|
m_verScrolBar->setRange(0,rowCount-m_pageRow);
|
|
}
|
|
}
|
|
|
|
void GridDataAdapter::setColCount(int colCount)
|
|
{
|
|
if(NULL != m_table)
|
|
{
|
|
m_horScrolBar->setRange(0,colCount-m_pageCol+1);
|
|
}
|
|
}
|
|
|
|
void GridDataAdapter::slotVerScrollValueChange(int nValue)
|
|
{
|
|
if(NULL == m_table)
|
|
return;
|
|
if(m_table->isVisible())
|
|
m_nVerScrollValue = nValue;
|
|
m_pAssetCopy->setVerScrollValue(nValue);
|
|
m_verScrolValue=nValue;
|
|
valueChange();
|
|
|
|
if(m_dtype == D_TableWellLogData||
|
|
m_dtype==D_TDTWellLogData||
|
|
m_dtype==D_FMTWellLogData)
|
|
return;
|
|
float m_popTipValue;
|
|
int m_verScrolValueNew;
|
|
if(m_SDep > 0 && m_Rlev > 0){
|
|
if(m_PointNum > 0){
|
|
m_verScrolValueNew = m_verScrolValue + m_pageRow * m_verScrolValue / m_PointNum;
|
|
m_popTipValue = m_SDep + m_verScrolValueNew * m_Rlev;
|
|
m_popTipValue = float(int(m_popTipValue * 10)) / 10;
|
|
}
|
|
else{
|
|
m_popTipValue = m_SDep + m_verScrolValue * m_Rlev;
|
|
m_popTipValue = float(int(m_popTipValue * 10)) / 10;
|
|
}
|
|
m_popTip->moveCursorPoint(m_popTipValue);
|
|
|
|
if(m_dtype == D_WellLogData){
|
|
// //20210111 GZL add 联动
|
|
// QWidget* parent=qobject_cast<QWidget*>(m_table->parent());
|
|
// QWidget* pvPage=parent->findChild<QWidget*>("curvePreViewPage");
|
|
// int value = (m_EDep-m_popTipValue)*CurveViewVerRange/(m_EDep-m_SDep)+1;
|
|
// if(value >= 0 && value <= CurveViewVerRange){
|
|
// m_mgr->CallDisplayCurveVerChange(0,fileName,curveName,pvPage,value,m_popTipValue);
|
|
|
|
// m_mgr->sendTableP2Mgr(pvPage, m_verScrolBar, m_table);
|
|
// }
|
|
|
|
// //updateTableView();
|
|
}
|
|
}
|
|
else{
|
|
int offset= m_verScrolValue % m_pageRow;
|
|
QTableWidgetItem *item= m_table->item(offset,0);
|
|
if(NULL != item)
|
|
{
|
|
m_popTip->moveCursorPoint(item->text().toFloat());
|
|
}
|
|
}
|
|
/*
|
|
if(m_pageRow<1) m_pageRow=1;
|
|
int offset= nValue % m_pageRow;
|
|
QTableWidgetItem *item=m_table->item(offset,0);
|
|
if(item!=NULL)
|
|
m_popTip->moveCursorPoint(item->text().toFloat());
|
|
*/
|
|
}
|
|
|
|
void GridDataAdapter::slotHorScrollValueChange(int nValue)
|
|
{
|
|
QMutexLocker locker(&m_mutex);
|
|
if(NULL == m_table)
|
|
return;
|
|
|
|
if(ifItemWidth){
|
|
itemWidth = new int[m_TitleField.size()+1];
|
|
for(int i = 0; i < m_TitleField.size(); i++)
|
|
itemWidth[i] = DefColWidth;
|
|
ifItemWidth = false;
|
|
}
|
|
for(int i = 0; i < m_pageCol; i++)
|
|
itemWidth[m_horScrolValue + i] = m_table->columnWidth(i);
|
|
|
|
m_horScrolValue=nValue;
|
|
m_pAssetCopy->setHorScrollValue(nValue);
|
|
valueChange();
|
|
}
|
|
|
|
//滚动刷新
|
|
void GridDataAdapter::valueChange()
|
|
{
|
|
if(NULL == m_table)
|
|
return;
|
|
|
|
VerScrollChanged = true;
|
|
QFuture<void> future;
|
|
m_pComplete=NULL;
|
|
switch(m_dtype)
|
|
{
|
|
case D_WellData:
|
|
{
|
|
m_pComplete=&GridDataAdapter::updateWellData;
|
|
}
|
|
break;
|
|
case D_WellLogData:
|
|
{
|
|
m_pComplete=&GridDataAdapter::updatetWellLogData;
|
|
}
|
|
break;
|
|
case D_MultWellLogData:
|
|
{
|
|
m_pComplete=&GridDataAdapter::updatetMultWellLogData;
|
|
}
|
|
break;
|
|
case D_TableWellLogData:
|
|
{
|
|
m_pComplete=&GridDataAdapter::updatetTableWellLogData;
|
|
}
|
|
break;
|
|
case D_TDTWellLogData:
|
|
{
|
|
m_pComplete=&GridDataAdapter::updatetTDTWellLogData;
|
|
}
|
|
break;
|
|
case D_FMTWellLogData:
|
|
{
|
|
m_pComplete=&GridDataAdapter::updatetFMTWellLogData;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
// if(NULL != m_pComplete)
|
|
// {
|
|
// future= QtConcurrent::run(this,m_pComplete);
|
|
// watcher.setFuture(future);
|
|
// }
|
|
|
|
}
|
|
|
|
bool GridDataAdapter::eventFilter(QObject *pSender, QEvent * pEvent)
|
|
{
|
|
if(m_table == pSender)
|
|
{
|
|
if(pEvent->type()==QEvent::KeyPress)
|
|
{
|
|
QKeyEvent* pKeyEvent =(QKeyEvent*)pEvent;
|
|
|
|
if((pKeyEvent->modifiers()&Qt::ControlModifier)!=0 && pKeyEvent->key()==Qt::Key_C)
|
|
{
|
|
m_pAssetCopy->onCopyData();
|
|
return true;
|
|
}
|
|
else if((pKeyEvent->modifiers()&Qt::ControlModifier)!=0 && pKeyEvent->key()==Qt::Key_V)
|
|
{
|
|
m_pAssetCopy->onParseData();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
}
|
|
return false;
|
|
}
|