添加测井信息表,表格内容复制黏贴添加行删除行等右键操作

This commit is contained in:
zhaolei 2025-11-20 15:13:47 +08:00
parent 7fbc11fef7
commit 323769671a
8 changed files with 497 additions and 389 deletions

View File

@ -39,6 +39,7 @@ signals:
void sig_ShowCurve(QString strSlfName, QString strName);//曲线数据查看
void sig_ShowTable(QString strSlfName, QString strName);//表格数据查看
void sig_WelllogInformation(QString strSlfName, QString strName);//编辑测井信息
void sig_NewTrack(QString strUuid, QString strWellName, QString strSlfName, QString strLineName, QString strType);//新建道
void sig_NewTrack_No_Line(QString strUuid, QString strWellName, QString strTrackName);//新建空白道,没有曲线

View File

@ -3,6 +3,7 @@
#include <QObject>
#include <QDir>
#include <QCoreApplication>
#pragma execution_character_set("utf-8")
char* GetDescription(LAYER_DATA &m_Result,char *buf)
{
buf[0]=0;
@ -2866,8 +2867,8 @@ int CLogIO::SetTableFieldData(int index,int FieldNo,char *buf,int Rec)
if(field[i].Reserved&&!IsChange) {
int flag=0;
if(field[i].Reserved>0&&field[i].Reserved<=m_MenuNumber)
{
if(isalpha(buf[0])||(buf[0]&0x80&&buf[1]&0x80)) {
{
if(/*isalpha(buf[0])||*/(buf[0]&0x80&&buf[1]&0x80)) {
float ind=GetReservedIndex(buf,field[i].Reserved);
if(ind>-1) {
SetData(field[FieldNo].RepCode,&Buffer[len],(float *)&ind);

View File

@ -519,19 +519,19 @@ bool WellLogTableDialogNew::event(QEvent *evt)
}
bool isEvent=QDialog::event(evt);
// if(evt->type()==QEvent::Paint)
// {
// m_gridData->CommitToSave();
if(evt->type()==QEvent::Paint)
{
m_gridData->CommitToSave();
// }else if(evt->type()==QEvent::ContextMenu)
// {
// QPoint point= m_pUI->tableWidget->mapFromGlobal(QCursor::pos());
// if(m_pUI->tableWidget->rect().contains(point))
// {
// // emit m_pUI->tableWidget->cus//->customContextMenuRequested(QCursor::pos());
// m_gridData->reqCustomComtextMenu(QCursor::pos());
// }
// }
}else if(evt->type()==QEvent::ContextMenu)
{
QPoint point= m_pUI->tableWidget->mapFromGlobal(QCursor::pos());
if(m_pUI->tableWidget->rect().contains(point))
{
// emit m_pUI->tableWidget->cus//->customContextMenuRequested(QCursor::pos());
m_gridData->reqCustomComtextMenu(QCursor::pos());
}
}
return isEvent;
}
void WellLogTableDialogNew::slotSave()
@ -560,144 +560,144 @@ void WellLogTableDialogNew::slotSave()
// m_pWell->SetZ( &vZ );
// }
// else if(m_rendererType == 2 && m_pWellLogs.size())
// {
// bool flag=false;
// CLogIO *logio=new CLogIO;
// if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeReadWrite)) {
// delete logio;
// return;
// }
// else if(m_rendererType == 2 && m_pWellLogs.size())
{
bool flag=false;
CLogIO *logio=new CLogIO;
if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeReadWrite)) {
delete logio;
return;
}
// int index=logio->OpenCurve(m_pWellLogs[0]->GetName().toStdString().c_str());
// if(index>-1) {
// flag=1;
// }
// if(index>-1) logio->CloseCurve(index);
// delete logio;
// CCurveLineLog* pCurveLineLog=dynamic_cast<CCurveLineLog*>(m_pWellLogs[0]);
// if (NULL != pCurveLineLog)//initWellLogData 曲线、井眼轨迹下级数据
// {
// flag=true;
// pCurveLineLog->ClearLines();
// for(int index=0; index<rowCount; index++)
// {
// if(m_pUI->tableWidget->item(index,0)) {
// float depth = m_pUI->tableWidget->item(index,0)->text().toFloat();
// pCurveLineLog->AddLine(depth, depth);
// }
// }
// emit signalSave();
// return;
// }
// if(flag)
// {//initMultWellLogData
// CLogIO *logio=new CLogIO;
// if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeReadWrite)) {
// delete logio;
// return;
// }
// int count=rowCount;
// for(int j=0;j<m_pWellLogs.size();j++)
// {
// int index=logio->OpenCurve(m_pWellLogs[j]->GetName().toStdString().c_str());
// if(index>-1)
// {
// float *data=new float[rowCount+1];
// float sdep=0;
// for(int i=0; i<rowCount; i++)
// {
// if(!m_pUI->tableWidget->item(i,0)) {
// count=i;
// break;
// }
// if(i==0)
// {
// QString topDepth = m_pUI->tableWidget->item(i,0)->text();
// sdep=topDepth.toFloat();
// }
// QString values ="-9999";
// if(m_pUI->tableWidget->item(i,j+1)) values=m_pUI->tableWidget->item(i,j+1)->text();
// data[i]=values.toFloat();
// }
// logio->WriteCurve(index,sdep,count,data);
// delete data;
// logio->CloseCurve(index);
// }
// m_pWellLogs[j]->isLoad=false;
// m_pWellLogs[j]->LoadFromSLF();
// }
// delete logio;
// GetObjectEvent().OnDeAttchData(m_pWellLogs[0]->GetSlfFileName(),m_pWellLogs[0]->GetName());
// GetObjectEvent().OnRefreshData(m_pWellLogs[0]->GetSlfFileName(),m_pWellLogs[0]->GetName(),this);
int index=logio->OpenCurve(m_pWellLogs[0]->GetName().toStdString().c_str());
if(index>-1) {
flag=1;
}
if(index>-1) logio->CloseCurve(index);
delete logio;
// CCurveLineLog* pCurveLineLog=dynamic_cast<CCurveLineLog*>(m_pWellLogs[0]);
// if (NULL != pCurveLineLog)//initWellLogData 曲线、井眼轨迹下级数据
// {
// flag=true;
// pCurveLineLog->ClearLines();
// for(int index=0; index<rowCount; index++)
// {
// if(m_pUI->tableWidget->item(index,0)) {
// float depth = m_pUI->tableWidget->item(index,0)->text().toFloat();
// pCurveLineLog->AddLine(depth, depth);
// }
// }
// emit signalSave();
// return;
// }
if(flag)
{//initMultWellLogData
CLogIO *logio=new CLogIO;
if(!logio->Open(m_pWellLogs[0]->GetSlfFileName().toStdString().c_str(),CLogIO::modeReadWrite)) {
delete logio;
return;
}
int count=rowCount;
for(int j=0;j<m_pWellLogs.size();j++)
{
int index=logio->OpenCurve(m_pWellLogs[j]->GetName().toStdString().c_str());
if(index>-1)
{
float *data=new float[rowCount+1];
float sdep=0;
for(int i=0; i<rowCount; i++)
{
if(!m_pUI->tableWidget->item(i,0)) {
count=i;
break;
}
if(i==0)
{
QString topDepth = m_pUI->tableWidget->item(i,0)->text();
sdep=topDepth.toFloat();
}
QString values ="-9999";
if(m_pUI->tableWidget->item(i,j+1)) values=m_pUI->tableWidget->item(i,j+1)->text();
data[i]=values.toFloat();
}
logio->WriteCurve(index,sdep,count,data);
delete data;
logio->CloseCurve(index);
}
m_pWellLogs[j]->isLoad=false;
m_pWellLogs[j]->LoadFromSLF();
}
delete logio;
// GetObjectEvent().OnDeAttchData(m_pWellLogs[0]->GetSlfFileName(),m_pWellLogs[0]->GetName());
// GetObjectEvent().OnRefreshData(m_pWellLogs[0]->GetSlfFileName(),m_pWellLogs[0]->GetName(),this);
// m_gridData->ReFreshDisplayCurve();
// }
// else //initTableWellLogData
// {
// flag=true;
// 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);
m_gridData->ReFreshDisplayCurve();
}
else //initTableWellLogData
{
flag=true;
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);
// int rowCount = m_pUI->tableWidget->rowCount();
// int count = 0;
// int n = 0;
// bool allNoneRow = true; //全空列标记
// for(int row = rowCount - 1; row >= 0; row--) //遍历行
// {
// for(int j = 0; j < fc; j++) //遍历列
// {
// if(!m_pUI->tableWidget->item(row, j))
// continue;
int rowCount = m_pUI->tableWidget->rowCount();
int count = 0;
int n = 0;
bool allNoneRow = true; //全空列标记
for(int row = rowCount - 1; row >= 0; row--) //遍历行
{
for(int j = 0; j < fc; j++) //遍历列
{
if(!m_pUI->tableWidget->item(row, j))
continue;
// if(m_pUI->tableWidget->item(row, j)->text() != "")
// allNoneRow = false;
// }
// if(allNoneRow)
// {
// rowCount--;
// continue;
// }
if(m_pUI->tableWidget->item(row, j)->text() != "")
allNoneRow = false;
}
if(allNoneRow)
{
rowCount--;
continue;
}
// for(int j = 0; j < fc; j++) //遍历列
// {
// QString mColumn = "0";
// if(m_pUI->tableWidget->item(row, j))
// mColumn = m_pUI->tableWidget->item(row, j)->text();
for(int j = 0; j < fc; j++) //遍历列
{
QString mColumn = "0";
if(m_pUI->tableWidget->item(row, j))
mColumn = m_pUI->tableWidget->item(row, j)->text();
// char buf[513];
// if(field[j].RepCode == 6 || field[j].Reserved)
// {
// strcpy(buf, mColumn.toStdString().c_str());
// logio->SetTableFieldData(iIndex, j, buf, row + 1);
// }
// else
// {
// float val = mColumn.toFloat();
// logio->SetTableFieldData(iIndex, j, (char *)&val, row + 1);
// }
// }
// }
char buf[513];
if(field[j].RepCode == 6 || field[j].Reserved)
{
strcpy(buf, mColumn.toStdString().c_str());
logio->SetTableFieldData(iIndex, j, buf, row + 1);
}
else
{
float val = mColumn.toFloat();
logio->SetTableFieldData(iIndex, j, (char *)&val, row + 1);
}
}
}
// logio->SetTableRecordCount(iIndex, rowCount);
// logio->CloseTable(iIndex);
// delete[] field;
// }
// logio->Close();
// delete logio;
// GetObjectEvent().OnDeAttchData(m_pWellLogs[0]->GetSlfFileName(),m_pWellLogs[0]->GetName());
// GetObjectEvent().OnRefreshData(m_pWellLogs[0]->GetSlfFileName(),m_pWellLogs[0]->GetName(),this);
// }
// }
logio->SetTableRecordCount(iIndex, rowCount);
logio->CloseTable(iIndex);
delete[] field;
}
logio->Close();
delete logio;
// GetObjectEvent().OnDeAttchData(m_pWellLogs[0]->GetSlfFileName(),m_pWellLogs[0]->GetName());
// GetObjectEvent().OnRefreshData(m_pWellLogs[0]->GetSlfFileName(),m_pWellLogs[0]->GetName(),this);
}
}
}
QMessageBox::about(NULL, "提示", "保存成功");
//QDialog::accept();

View File

@ -4,7 +4,7 @@
#include <QMimeData>
#include <QClipboard>
#include <qtablewidget.h>
// #include "ObjWellLogTABLE.h"
#include "ObjWellLogTABLE.h"
// #include "ObjDiscreteWellLog.h"
// #include "BaseDialog.h"
#include "DepthProgress.h"
@ -92,145 +92,145 @@ void AssetCopy::onCopyData()
}
void AssetCopy::onCopyLinesData()
{
// if(!m_pWellLogs.size()) return;
// m_isParse=false;
// if(NULL == m_menu || NULL == m_menu->parent()) return;
// QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
// if(NULL == m_table)
// return;
// //if(m_table->isVisible())
if(!m_pWellLogs.size()) return;
m_isParse=false;
if(NULL == m_menu || NULL == m_menu->parent()) return;
QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
if(NULL == m_table)
return;
//if(m_table->isVisible())
// QList<QTableWidgetItem*> selItems=m_table->selectedItems();
// QList<QTableWidgetSelectionRange> selRanges=m_table->selectedRanges();
QList<QTableWidgetItem*> selItems=m_table->selectedItems();
QList<QTableWidgetSelectionRange> selRanges=m_table->selectedRanges();
// CObjWellLogWavefile *pWaveValue=NULL;
// pWaveValue=dynamic_cast<CObjWellLogWavefile *>(m_pWellLogs[0]);
// CObjWellLogTABLE *pTableValue=NULL;
// pTableValue=dynamic_cast<CObjWellLogTABLE *>(m_pWellLogs[0]);
// if(selItems.size()>0)
// {
// QTableWidgetSelectionRange copyRange=selRanges.value(0);
CObjWellLogTABLE *pTableValue=NULL;
pTableValue=dynamic_cast<CObjWellLogTABLE *>(m_pWellLogs[0]);
if(selItems.size()>0)
{
QTableWidgetSelectionRange copyRange=selRanges.value(0);
// int top = m_verScrolValue+copyRange.topRow();
// int bottom = m_verScrolValue+copyRange.bottomRow();
// int left = 0;//copyRange.leftColumn();
// int right = m_horScrolValue+m_table->columnCount();
int top = m_verScrolValue+copyRange.topRow();
int bottom = m_verScrolValue+copyRange.bottomRow();
int left = 0;//copyRange.leftColumn();
int right = m_horScrolValue+m_table->columnCount();
// if(pWaveValue) right =pWaveValue->waveinfo.TimeSamples;
// else if(!pTableValue) right=m_pWellLogs.size();
// char buffer[200];
// QString szClipText;
// float stdep=999999;
// for(int i = 0; i < m_pWellLogs.size(); i++) {
// if(m_pWellLogs[i]->acurveinfo.StartDepth<stdep)
// stdep = m_pWellLogs[i]->acurveinfo.StartDepth;
// }
// double dep=0;
// int nCurrentRow = m_table->currentRow();
/* if(pWaveValue) right =pWaveValue->waveinfo.TimeSamples;
else */if(!pTableValue) right=m_pWellLogs.size();
char buffer[200];
QString szClipText;
float stdep=999999;
for(int i = 0; i < m_pWellLogs.size(); i++) {
if(m_pWellLogs[i]->acurveinfo.StartDepth<stdep)
stdep = m_pWellLogs[i]->acurveinfo.StartDepth;
}
double dep=0;
int nCurrentRow = m_table->currentRow();
// for(int nRow = top;nRow <= bottom; nRow++)
// {
// if(!pTableValue)
// dep=stdep+nRow*m_pWellLogs[0]->acurveinfo.DepLevel;
for(int nRow = top;nRow <= bottom; nRow++)
{
if(!pTableValue)
dep=stdep+nRow*m_pWellLogs[0]->acurveinfo.DepLevel;
// for(int nCol = left;nCol < right; nCol++)
// {
// QString szTmp;
// if(nCol==0||pTableValue) {
// auto pItem = m_table->item(nRow,nCol);
// if(pItem)
// szTmp = pItem->text();
// else
// szTmp=toString(dep,'f',5,0);
// }
// else {
// if(pWaveValue) szTmp=toString(pWaveValue->GetData((float)dep,nCol-1,buffer),'f',DECIMALPLACESNUM,0);
// else szTmp=toString(m_pWellLogs[nCol-1]->GetData((float)dep),'f',DECIMALPLACESNUM,0);
// }
// szClipText.append(szTmp);
// szClipText.append("\t");
// }
// szClipText.chop(1);
// szClipText.append("\n");
// }
for(int nCol = left;nCol < right; nCol++)
{
QString szTmp;
if(nCol==0||pTableValue) {
auto pItem = m_table->item(nRow,nCol);
if(pItem)
szTmp = pItem->text();
else
szTmp=toString(dep,'f',5,0);
}
else {
/* if(pWaveValue) szTmp=toString(pWaveValue->GetData((float)dep,nCol-1,buffer),'f',DECIMALPLACESNUM,0);
else */szTmp=toString(m_pWellLogs[nCol-1]->GetData((float)dep),'f',DECIMALPLACESNUM,0);
}
szClipText.append(szTmp);
szClipText.append("\t");
}
szClipText.chop(1);
szClipText.append("\n");
}
// QClipboard* clip=QApplication::clipboard();
// clip->setText(szClipText);
QClipboard* clip=QApplication::clipboard();
clip->setText(szClipText);
// }
}
}
void AssetCopy::onCopyColnumsData()
{
// if(!m_pWellLogs.size()) return;
// m_isParse=false;
// if(NULL == m_menu || NULL == m_menu->parent())
// return;
if(!m_pWellLogs.size()) return;
m_isParse=false;
if(NULL == m_menu || NULL == m_menu->parent())
return;
// QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
// if(NULL == m_table)
// return;
// //if(m_table->isVisible())
QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
if(NULL == m_table)
return;
//if(m_table->isVisible())
// CObjWellLogWavefile *pWaveValue=NULL;
// pWaveValue=dynamic_cast<CObjWellLogWavefile *>(m_pWellLogs[0]);
// CObjWellLogTABLE *pTableValue=NULL;
CObjWellLogTABLE *pTableValue=NULL;
// CObjDiscreteWellLog *pTableValue1=NULL;
// pTableValue=dynamic_cast<CObjWellLogTABLE *>(m_pWellLogs[0]);
pTableValue=dynamic_cast<CObjWellLogTABLE *>(m_pWellLogs[0]);
// pTableValue1=dynamic_cast<CObjDiscreteWellLog *>(m_pWellLogs[0]);
// QList<QTableWidgetItem*> selItems=m_table->selectedItems();
// QList<QTableWidgetSelectionRange> selRanges=m_table->selectedRanges();
// float stdep=999999;
// for(int i=0;i<m_pWellLogs.size();i++) {
// if(m_pWellLogs[i]->acurveinfo.StartDepth<stdep) stdep=m_pWellLogs[i]->acurveinfo.StartDepth;
// }
// if(selItems.size()>0)
// {
// QTableWidgetSelectionRange copyRange=selRanges.value(0);
QList<QTableWidgetItem*> selItems=m_table->selectedItems();
QList<QTableWidgetSelectionRange> selRanges=m_table->selectedRanges();
float stdep=999999;
for(int i=0;i<m_pWellLogs.size();i++) {
if(m_pWellLogs[i]->acurveinfo.StartDepth<stdep) stdep=m_pWellLogs[i]->acurveinfo.StartDepth;
}
if(selItems.size()>0)
{
QTableWidgetSelectionRange copyRange=selRanges.value(0);
// int top = 0;//copyRange.topRow();
// int bottom = m_table->rowCount();//copyRange.bottomRow();
// int left = m_horScrolValue+copyRange.leftColumn();
// int right =m_horScrolValue+copyRange.rightColumn();
int top = 0;//copyRange.topRow();
int bottom = m_table->rowCount();//copyRange.bottomRow();
int left = m_horScrolValue+copyRange.leftColumn();
int right =m_horScrolValue+copyRange.rightColumn();
// if(!pTableValue&&!pTableValue1&&!pWaveValue)
// {
// bottom=(m_pWellLogs[0]->acurveinfo.EndDepth-m_pWellLogs[0]->acurveinfo.StartDepth)/m_pWellLogs[0]->acurveinfo.DepLevel+0.5;
// }
// else if(pWaveValue) {
// bottom=(pWaveValue->waveinfo.EndDepth-pWaveValue->waveinfo.StartDepth)/pWaveValue->waveinfo.DepLevel+0.5;
// }
// QString szClipText;
// char buffer[200];
// QString szTmp;
// float dep=0;
// for(int nRow = top;nRow <=bottom;nRow++)
// {
// if(!pTableValue&&!pTableValue1)dep=stdep+nRow*m_pWellLogs[0]->acurveinfo.DepLevel;
// for(int nCol = left;nCol <=right;nCol++)
// {
// if(nCol==0||pTableValue||pTableValue1) {
// auto pItem = m_table->item(nRow,nCol);
// if(pItem)
// szTmp = pItem->text();
// else if(nCol==0) {
// float val=szTmp.toFloat();
// sprintf(buffer,"%8.3f",val+m_pWellLogs[0]->acurveinfo.DepLevel);
// szTmp =buffer ;
// }
// }
// else {
// if(pWaveValue) szTmp=toString(pWaveValue->GetData(dep,nCol-1,buffer),'f',0);
// else szTmp=toString(m_pWellLogs[nCol-1]->GetData(dep),'f',DECIMALPLACESNUM,0);
// }
// szClipText.append(szTmp);
// szClipText.append("\t");
// }
// szClipText.chop(1);
// szClipText.append("\n");
// }
// QClipboard* clip=QApplication::clipboard();
// clip->setText(szClipText);
// }
if(!pTableValue/*&&!pTableValue1&&!pWaveValue*/)
{
bottom=(m_pWellLogs[0]->acurveinfo.EndDepth-m_pWellLogs[0]->acurveinfo.StartDepth)/m_pWellLogs[0]->acurveinfo.DepLevel+0.5;
}
// else if(pWaveValue) {
// bottom=(pWaveValue->waveinfo.EndDepth-pWaveValue->waveinfo.StartDepth)/pWaveValue->waveinfo.DepLevel+0.5;
// }
QString szClipText;
char buffer[200];
QString szTmp;
float dep=0;
for(int nRow = top;nRow <=bottom;nRow++)
{
if(!pTableValue/*&&!pTableValue1*/)dep=stdep+nRow*m_pWellLogs[0]->acurveinfo.DepLevel;
for(int nCol = left;nCol <=right;nCol++)
{
if(nCol==0||pTableValue/*||pTableValue1*/) {
auto pItem = m_table->item(nRow,nCol);
if(pItem)
szTmp = pItem->text();
else if(nCol==0) {
float val=szTmp.toFloat();
sprintf(buffer,"%8.3f",val+m_pWellLogs[0]->acurveinfo.DepLevel);
szTmp =buffer ;
}
}
else {
/* if(pWaveValue) szTmp=toString(pWaveValue->GetData(dep,nCol-1,buffer),'f',0);
else */szTmp=toString(m_pWellLogs[nCol-1]->GetData(dep),'f',DECIMALPLACESNUM,0);
}
szClipText.append(szTmp);
szClipText.append("\t");
}
szClipText.chop(1);
szClipText.append("\n");
}
QClipboard* clip=QApplication::clipboard();
clip->setText(szClipText);
}
}
void AssetCopy::cacheGridData(const QTableWidgetSelectionRange& m_selectionRange)
@ -513,161 +513,161 @@ void AssetCopy::reqCustomComtextMenu(const QPoint &pos)
void AssetCopy::onParseData()
{
// if(type == D_MultWellLogData)
// {
// int choose = QMessageBox::question(NULL, tr("提示"),
// QString(tr("该数据格式下,粘贴后将直接存储,是否粘贴?")),
// QMessageBox::Yes | QMessageBox::No);
// if(choose == QMessageBox::No)
// return;
// }
if(type == D_MultWellLogData)
{
int choose = QMessageBox::question(NULL, tr("提示"),
QString(tr("该数据格式下,粘贴后将直接存储,是否粘贴?")),
QMessageBox::Yes | QMessageBox::No);
if(choose == QMessageBox::No)
return;
}
// if(!m_pWellLogs.size()) return;
// if(NULL == m_menu || NULL == m_menu->parent())
// return;
if(!m_pWellLogs.size()) return;
if(NULL == m_menu || NULL == m_menu->parent())
return;
// QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
// if(NULL == m_table)
// return;
QTableWidget *m_table=qobject_cast<QTableWidget*>(m_menu->parent());
if(NULL == m_table)
return;
// QClipboard* pClip = QApplication::clipboard();
// QString szText = pClip->text();
QClipboard* pClip = QApplication::clipboard();
QString szText = pClip->text();
// if(szText.isEmpty())
// return;
if(szText.isEmpty())
return;
// int nSpace = 0;
// int nDou=0;
// int nTab =0;
int nSpace = 0;
int nDou=0;
int nTab =0;
// DepthProgress MyDepthProgress2;
// MyDepthProgress2.CreatProgress(0, szText.size(), "粘贴内容检查中...");
DepthProgress MyDepthProgress2;
MyDepthProgress2.CreatProgress(0, szText.size(), "粘贴内容检查中...");
// for(int nIndex =0;nIndex<szText.size();++nIndex)
// {
// if(szText[nIndex]=='\t')
// {
// nTab++;
// }
// else if(szText[nIndex]==' ')
// {
// nSpace++;
// }
// else if(szText[nIndex]==',')
// {
// nDou++;
// }
for(int nIndex =0;nIndex<szText.size();++nIndex)
{
if(szText[nIndex]=='\t')
{
nTab++;
}
else if(szText[nIndex]==' ')
{
nSpace++;
}
else if(szText[nIndex]==',')
{
nDou++;
}
// MyDepthProgress2.SetDepth(nIndex);
// }
MyDepthProgress2.SetDepth(nIndex);
}
// int nMax = nSpace>nDou ? nSpace : nDou;
// nMax = nMax>nTab ? nMax : nTab;
int nMax = nSpace>nDou ? nSpace : nDou;
nMax = nMax>nTab ? nMax : nTab;
// char rFlag;
// if(nMax==nTab)
// {
// rFlag ='\t';
// }
// else if(nMax==nSpace)
// {
// rFlag =' ';
// }
// else if(nMax==nDou)
// {
// rFlag =',';
// }
// m_table->clearSelection();
// QStringList rSplitList = szText.split('\n');
// if(rSplitList.size()&&rSplitList[rSplitList.size()-1]=="") rSplitList.removeAt(rSplitList.size()-1);
char rFlag;
if(nMax==nTab)
{
rFlag ='\t';
}
else if(nMax==nSpace)
{
rFlag =' ';
}
else if(nMax==nDou)
{
rFlag =',';
}
m_table->clearSelection();
QStringList rSplitList = szText.split('\n');
if(rSplitList.size()&&rSplitList[rSplitList.size()-1]=="") rSplitList.removeAt(rSplitList.size()-1);
// CObjWellLogWavefile *pWaveValue=NULL;
// pWaveValue=dynamic_cast<CObjWellLogWavefile *>(m_pWellLogs[0]);
// CObjWellLogTABLE *pTableValue=NULL;
// pTableValue=dynamic_cast<CObjWellLogTABLE *>(m_pWellLogs[0]);
CObjWellLogTABLE *pTableValue=NULL;
pTableValue=dynamic_cast<CObjWellLogTABLE *>(m_pWellLogs[0]);
// CObjDiscreteWellLog *pTableValue1=NULL;
// pTableValue1=dynamic_cast<CObjDiscreteWellLog *>(m_pWellLogs[0]);
// float stdep=999999;
float stdep=999999;
// for(int i=0;i<m_pWellLogs.size();i++) {
// if(m_pWellLogs[i]->acurveinfo.StartDepth<stdep) stdep=m_pWellLogs[i]->acurveinfo.StartDepth;
// }
// float dep=0;
for(int i=0;i<m_pWellLogs.size();i++) {
if(m_pWellLogs[i]->acurveinfo.StartDepth<stdep) stdep=m_pWellLogs[i]->acurveinfo.StartDepth;
}
float dep=0;
// //起始行
// int nCurrentRow = m_table->currentRow();
//起始行
int nCurrentRow = m_table->currentRow();
// //纵向扩充表格
// MyDepthProgress2.CreatProgress(0, rSplitList.size(), "表格建设中...");
// MyDepthProgress2.SetDepth(0);
// for(int cTemp = nCurrentRow; cTemp < (nCurrentRow + rSplitList.size()); cTemp++){
// if(cTemp >= m_table->rowCount())
// needANewLine(cTemp);
//纵向扩充表格
MyDepthProgress2.CreatProgress(0, rSplitList.size(), "表格建设中...");
MyDepthProgress2.SetDepth(0);
for(int cTemp = nCurrentRow; cTemp < (nCurrentRow + rSplitList.size()); cTemp++){
if(cTemp >= m_table->rowCount())
needANewLine(cTemp);
// MyDepthProgress2.SetDepth(cTemp - nCurrentRow);
// }
MyDepthProgress2.SetDepth(cTemp - nCurrentRow);
}
// //进度条
// int curprogre = 0;
// MyDepthProgress2.CreatProgress(0, rSplitList.size(), "数据归位...");
// MyDepthProgress2.SetDepth(0);
//进度条
int curprogre = 0;
MyDepthProgress2.CreatProgress(0, rSplitList.size(), "数据归位...");
MyDepthProgress2.SetDepth(0);
// for(int nRow = 0; nRow < rSplitList.size(); ++nRow)
// {
// if(!pTableValue)
// dep = stdep + (m_verScrolValue + nCurrentRow) * m_pWellLogs[0]->acurveinfo.DepLevel;
for(int nRow = 0; nRow < rSplitList.size(); ++nRow)
{
if(!pTableValue)
dep = stdep + (m_verScrolValue + nCurrentRow) * m_pWellLogs[0]->acurveinfo.DepLevel;
// //起始列
// int nCurrentColumn = m_table->currentColumn();
//起始列
int nCurrentColumn = m_table->currentColumn();
// QStringList rColumnList = rSplitList[nRow].split(rFlag);
QStringList rColumnList = rSplitList[nRow].split(rFlag);
// for(int nCol = 0; nCol < rColumnList.size(); nCol++)
// {
// if(pTableValue||pTableValue1) {
// //空替换
// if(rColumnList[nCol].isEmpty() ) rColumnList[nCol] = "";
// auto pItem = m_table->item(nCurrentRow, nCurrentColumn);
for(int nCol = 0; nCol < rColumnList.size(); nCol++)
{
if(pTableValue/*||pTableValue1*/) {
//空替换
if(rColumnList[nCol].isEmpty() ) rColumnList[nCol] = "";
auto pItem = m_table->item(nCurrentRow, nCurrentColumn);
// //写值
// if(pItem)
// pItem->setText(rColumnList[nCol]);
// else
// {
// QTableWidgetItem* pItem = new QTableWidgetItem;
// pItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate);
// pItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);//对齐
// if(nCurrentColumn == 0) pItem->setFlags(pItem->flags() & (~Qt::ItemIsEditable));
// pItem->setFont(QFont("Times",10));
//写值
if(pItem)
pItem->setText(rColumnList[nCol]);
else
{
QTableWidgetItem* pItem = new QTableWidgetItem;
pItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate);
pItem->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter);//对齐
if(nCurrentColumn == 0) pItem->setFlags(pItem->flags() & (~Qt::ItemIsEditable));
pItem->setFont(QFont("Times",10));
// m_table->setItem(nCurrentRow, nCurrentColumn, pItem);
m_table->setItem(nCurrentRow, nCurrentColumn, pItem);
// pItem->setText(rColumnList[nCol]);
// }
pItem->setText(rColumnList[nCol]);
}
// }
// else if(nCurrentColumn){
// float val=rColumnList[nCol].toFloat();
// if(pWaveValue) pWaveValue->SetData(dep,m_horScrolValue+nCurrentColumn-1,&val);
// else m_pWellLogs[m_horScrolValue+nCurrentColumn-1]->SetData(dep,&val);
// }
}
else if(nCurrentColumn){
float val=rColumnList[nCol].toFloat();
/* if(pWaveValue) pWaveValue->SetData(dep,m_horScrolValue+nCurrentColumn-1,&val);
else */m_pWellLogs[m_horScrolValue+nCurrentColumn-1]->SetData(dep,&val);
}
// nCurrentColumn++;
nCurrentColumn++;
// MyDepthProgress2.SetDepth(++curprogre);
// }
// nCurrentRow++;
// }
MyDepthProgress2.SetDepth(++curprogre);
}
nCurrentRow++;
}
// if(!pTableValue)
// for(int i=0;i<m_pWellLogs.size();i++)
// {
// m_pWellLogs[i]->SetModify(true);
// m_pWellLogs[i]->SaveToSLF();
// }
if(!pTableValue)
for(int i=0;i<m_pWellLogs.size();i++)
{
m_pWellLogs[i]->SetModify(true);
m_pWellLogs[i]->SaveToSLF();
}
// emit saveToTempModel();
emit saveToTempModel();
/*
CBaseDialog *pTableDialog=(CBaseDialog*)(m_table->parent());

View File

@ -80,6 +80,9 @@ MainWindow::MainWindow(QWidget *parent) :
//关联信号槽,数据查看
connect(CallManage::getInstance(), SIGNAL(sig_ShowTable(QString, QString)), this, SLOT(s_ShowTable(QString, QString)));
//关联信号槽,测井信息表数据查看
connect(CallManage::getInstance(), SIGNAL(sig_WelllogInformation(QString, QString)), this, SLOT(s_WelllogInformation(QString, QString)));
}
MainWindow::~MainWindow()
@ -479,3 +482,78 @@ void MainWindow::s_ShowTable(QString strSlfName, QString strName)
m_centerWidgets->m_pTabBar->setCurrentIndex(iCount-1);
}
}
//编辑测井信息
void MainWindow::s_WelllogInformation(QString strSlfName, QString strName)
{
if(m_centerWidgets)
{
// pai::gui::WellLogInformation* pWellLogInformation=new pai::gui::WellLogInformation;
// pWellLogInformation->exec();
// pWellLogInformation->SetWelllogRound(pWelllogRound);
CLogIO * pLogio=new CLogIO();
if(!pLogio->Open(strSlfName.toStdString().c_str(),CSlfIO::modeReadWrite))
{
QMessageBox::information(nullptr,QString::fromLocal8Bit("提示"),QString::fromLocal8Bit("存储失败!"));
delete pLogio;
return;
}
// pWellLogInformation->CreateTable(pLogio);
QString wellname;QString path;
GetWellNameAndPath(strSlfName, wellname, path);
// m_centerWidgets->addTab(pWellLogInformation, wellname + ":测井信息" );
// int iCount = m_centerWidgets->count();
// m_centerWidgets->m_pTabBar->setCurrentIndex(iCount-1);
int nTableFlag =pLogio->OpenTable("wellloginformation");
if(nTableFlag!=-1)
{
s_ShowTable(strSlfName, "wellloginformation");
return;
}
QString szColumnName;
szColumnName+=("缩写");szColumnName+=",";
szColumnName+=("");szColumnName+=",";
szColumnName+=("单位");szColumnName+=",";
szColumnName+=("中文名");szColumnName+=",";
QString szDataType;
szDataType+="6,6,6,6";
QString szSize;
szSize+="64,128,64,128";
QString szRemark;
szRemark+="0,0,0,0";
nTableFlag =pLogio->Open_Set_Table("wellloginformation",
TABLEE_OBJECT,
4,
// szColumnName.toLocal8Bit().data(),
szColumnName.toStdString().c_str(),
szSize.toLocal8Bit().data(),
szDataType.toLocal8Bit().data(),
szRemark.toLocal8Bit().data());
int nTableColumn=pLogio->GetTableFieldCount(nTableFlag);
Slf_TABLE_FIELD *pFieldInfo=new Slf_TABLE_FIELD[nTableColumn+1];
pLogio->GetTableFieldInfo(nTableFlag,pFieldInfo);
char pArr[100];
strcpy(pArr, "WN");
pLogio->SetTableFieldData(nTableFlag,0,pArr,1);//缩写
strcpy(pArr, wellname.toStdString().c_str());
pLogio->SetTableFieldData(nTableFlag,1,pArr,1);//单位
strcpy(pArr, "NONE");
pLogio->SetTableFieldData(nTableFlag,2,pArr,1);//井名
strcpy(pArr, "井名");
pLogio->SetTableFieldData(nTableFlag,3,pArr,1);
s_ShowTable(strSlfName, "wellloginformation");
}
}

View File

@ -88,6 +88,7 @@ public slots:
void s_ShowCurve(QString strSlfName, QString strName);//曲线数据查看
void s_ShowTable(QString strSlfName, QString strName);//表格数据查看
void s_WelllogInformation(QString strSlfName, QString strName);//编辑测井信息
};

View File

@ -600,7 +600,10 @@ void QtProjectWidgets::initMenu()
_menuWellName = new QMenu(ui->treeWidget);
initWellNameTreeMenu(_menuWellName, ui->treeWidget);
_menuSlfName = new QMenu(ui->treeWidget);
initSlfNameTreeMenu(_menuSlfName, ui->treeWidget);
// //评估方案-右键菜单
// _menuEvaluate = new QMenu(ui->treeWidget);
// initEvaluateTreeMenu(_menuEvaluate, ui->treeWidget);
@ -665,6 +668,15 @@ void QtProjectWidgets::initWellNameTreeMenu(QMenu *menu, QTreeWidget *treeWidget
menu->addAction(action_New);
}
//初始化根节点(井次名称)-右键菜单
void QtProjectWidgets::initSlfNameTreeMenu(QMenu *menu, QTreeWidget *treeWidget)
{
QAction* action_New = new QAction("编辑测井信息", treeWidget);
action_New->setIcon(QIcon(":/image/u174.png")); // 设置图标
connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onWelllogInformation()));
menu->addAction(action_New);
}
//新建项目
void QtProjectWidgets::onNewProject(bool checked)
{
@ -725,6 +737,12 @@ void QtProjectWidgets::onShowTable(bool checked)
emit CallManage::getInstance()->sig_ShowTable(m_strSlfName, m_strCurveObjectName);
}
//编辑测井信息
void QtProjectWidgets::onWelllogInformation()
{
emit CallManage::getInstance()->sig_WelllogInformation(m_strSlfName, m_strCurveObjectName);
}
void QtProjectWidgets::onEditWelllogRound()
{
QTreeWidgetItem *wellItem = *ui->treeWidget->selectedItems().begin();
@ -865,7 +883,12 @@ void QtProjectWidgets::onItemClicked(QTreeWidgetItem* item, int index)
//根节点(项目名称)-右键菜单
popMenu = _menuWellName;
}
else if (strTreeTag == "wellItem")
{
//根节点(项目名称)-右键菜单
popMenu = _menuSlfName;
m_strSlfName = item->data(0, Qt::UserRole+1).toString();
}
//
if (qApp->mouseButtons() == Qt::RightButton) // 只针对鼠标右键,弹出菜单

View File

@ -44,6 +44,7 @@ public slots:
void onImportSingleWellLogData();
void onImportSlfTable();
void onOutWellLogRound();
void onWelllogInformation(); //编辑测井信息
public:
//初始化树图控件
void initTreeWidget(QString fullPath, QString strProjectName);
@ -53,7 +54,8 @@ public:
QMenu *_menuRoot;
QMenu *_menuCurveObject;//曲线对象(AC、BS...)
QMenu *_menuTableObject;//表格对象
QMenu *_menuWellName;
QMenu *_menuWellName; //井名
QMenu *_menuSlfName; //井次
//根节点(项目名称)-右键菜单
QAction* m_action_New;
@ -82,6 +84,8 @@ public:
void initTableObjectTreeMenu(QMenu *menu, QTreeWidget *treeWidget);
//初始化根节点(井名称)-右键菜单
void initWellNameTreeMenu(QMenu *menu, QTreeWidget *treeWidget);
//初始化根节点(井次名称)-右键菜单
void initSlfNameTreeMenu(QMenu *menu, QTreeWidget *treeWidget);
private:
};