添加单位转换,添加转换为结论表格
This commit is contained in:
parent
2e9fa08261
commit
6d145e625e
|
|
@ -17,7 +17,7 @@
|
|||
#include "CurvePropertyEdit.h"
|
||||
#include "cdialog.h"//"MyListDlg.h"
|
||||
#include "CurveComputerDlg.h"
|
||||
// #include "UnitConvertDlg.h"
|
||||
#include "UnitConvertDlg.h"
|
||||
#include "StatisticsDlg.h"
|
||||
#include "Statistics2Dlg.h"
|
||||
#include "CurveComputePage.h"
|
||||
|
|
@ -31,6 +31,7 @@
|
|||
#include "BaseFun.h"
|
||||
#include "DepthProgress.h"
|
||||
#include "geometryutils.h"
|
||||
#include "CallGlobalManage.h"
|
||||
extern DEFAULTTABLE *DefauleTable;//[DefTabNum];
|
||||
extern int DefTabNum;
|
||||
//extern char *DataTypea[];
|
||||
|
|
@ -1019,7 +1020,7 @@ QString CDataManagger::Curve2ResultTable(const QString& wellname,const QString&
|
|||
}
|
||||
logio->SetTableRecordCount(iIndex, Num);
|
||||
for(int j = 0; j < Num; j++) {
|
||||
//memset(&m_Result,0,sizeof(LAYER_DATA));
|
||||
memset(&m_Result,0,sizeof(LAYER_DATA));
|
||||
m_Result.Order = j+1;
|
||||
m_Result.EndDepth=layerEDEP[j];
|
||||
m_Result.StartDepth=layerSDEP[j];
|
||||
|
|
@ -1037,6 +1038,9 @@ QString CDataManagger::Curve2ResultTable(const QString& wellname,const QString&
|
|||
delete []layerEDEP;
|
||||
delete []layerRESULT;
|
||||
delete []vVdl;
|
||||
QStringList listObject;
|
||||
listObject.append(newTableName);
|
||||
emit CallGlobalManage::getInstance()->sig_Notice_AddObject("DataMgr", wellname,listObject);
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
@ -1251,52 +1255,52 @@ QString CDataManagger::CreateNewTable(const QString& wellname)
|
|||
// pDlg=NULL;
|
||||
// return Curvename;
|
||||
// }
|
||||
// //单位转换
|
||||
// void CDataManagger::UnitConvert(const QString& FileName)//,CObjWelllogRound* pround)
|
||||
// {
|
||||
// CMemRdWt *mrw=new CMemRdWt();
|
||||
// if(!mrw->Open(FileName.toStdString().c_str(),CSlfIO::modeReadWrite))
|
||||
// {
|
||||
// delete mrw;
|
||||
// QMessageBox::warning(NULL,"提示","打开文件"+FileName+"错误\r\n");
|
||||
// return ;
|
||||
// }
|
||||
// int ObjectNumber=mrw->GetObjectCount();
|
||||
// int CurveCount=0,WaveCount=0;
|
||||
// char Name[200];
|
||||
// for(int i=0;i<ObjectNumber;i++)
|
||||
// {
|
||||
// if(mrw->GetObjectStatus(i)!=OBJECT_NORMAL)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// mrw->GetObjectName(i,Name);
|
||||
// short Attribute,SubAttribute;
|
||||
// Attribute=mrw->GetObjectType(i);
|
||||
// if(Attribute==CURVE_OBJECT)
|
||||
// {
|
||||
// CurveCount++;
|
||||
// }
|
||||
// else if(Attribute==WAVE_OBJECT)
|
||||
// {
|
||||
// WaveCount++;
|
||||
// }
|
||||
// }
|
||||
// delete mrw;
|
||||
// if(CurveCount+WaveCount==0)
|
||||
// {
|
||||
// QMessageBox::warning(NULL,"提示","您所选择的文件中没有曲线存在\r\n");
|
||||
// return;
|
||||
// }
|
||||
// CUnitConvertDlg *pDlg=new CUnitConvertDlg();
|
||||
// pDlg->FileName=FileName;
|
||||
// //pDlg->pround=pround;
|
||||
// pDlg->init();
|
||||
// pDlg->exec();
|
||||
// delete pDlg;
|
||||
// pDlg=NULL;
|
||||
// pai::graphics::CDataImport::ChangetoSlf(FileName,NULL);
|
||||
// }
|
||||
//单位转换
|
||||
void CDataManagger::UnitConvert(const QString& FileName)//,CObjWelllogRound* pround)
|
||||
{
|
||||
CMemRdWt *mrw=new CMemRdWt();
|
||||
if(!mrw->Open(FileName.toStdString().c_str(),CSlfIO::modeReadWrite))
|
||||
{
|
||||
delete mrw;
|
||||
QMessageBox::warning(NULL,"提示","打开文件"+FileName+"错误\r\n");
|
||||
return ;
|
||||
}
|
||||
int ObjectNumber=mrw->GetObjectCount();
|
||||
int CurveCount=0,WaveCount=0;
|
||||
char Name[200];
|
||||
for(int i=0;i<ObjectNumber;i++)
|
||||
{
|
||||
if(mrw->GetObjectStatus(i)!=OBJECT_NORMAL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
mrw->GetObjectName(i,Name);
|
||||
short Attribute,SubAttribute;
|
||||
Attribute=mrw->GetObjectType(i);
|
||||
if(Attribute==CURVE_OBJECT)
|
||||
{
|
||||
CurveCount++;
|
||||
}
|
||||
else if(Attribute==WAVE_OBJECT)
|
||||
{
|
||||
WaveCount++;
|
||||
}
|
||||
}
|
||||
delete mrw;
|
||||
if(CurveCount+WaveCount==0)
|
||||
{
|
||||
QMessageBox::warning(NULL,"提示","您所选择的文件中没有曲线存在\r\n");
|
||||
return;
|
||||
}
|
||||
CUnitConvertDlg *pDlg=new CUnitConvertDlg();
|
||||
pDlg->FileName=FileName;
|
||||
//pDlg->pround=pround;
|
||||
pDlg->init();
|
||||
pDlg->exec();
|
||||
delete pDlg;
|
||||
pDlg=NULL;
|
||||
/*pai::graphics::*/CDataImport::ChangetoSlf(FileName,NULL);
|
||||
}
|
||||
//whp add 2020.4.14 合成阵列曲线
|
||||
QString CDataManagger::WaveCompose(const QString& FileName,const QStringList& CurveNameList)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ FORMS += \
|
|||
UI/Statistics.ui \
|
||||
UI/Statistics2.ui \
|
||||
UI/TiShi.ui \
|
||||
UI/UnitConvert.ui \
|
||||
UI/WaveCompose.ui \
|
||||
UI/cdialog.ui \
|
||||
UI/doubleeditview.ui \
|
||||
|
|
@ -92,6 +93,7 @@ HEADERS += \
|
|||
Statistics2Dlg.h \
|
||||
StatisticsDlg.h \
|
||||
TiShiDlg.h\
|
||||
UnitConvertDlg.h \
|
||||
WaveComposeDlg.h \
|
||||
cdialog.h \
|
||||
dataslothelper.h \
|
||||
|
|
@ -121,6 +123,7 @@ SOURCES += \
|
|||
Statistics2Dlg.cpp \
|
||||
StatisticsDlg.cpp \
|
||||
TiShiDlg.cpp\
|
||||
UnitConvertDlg.cpp \
|
||||
WaveComposeDlg.cpp \
|
||||
cdialog.cpp \
|
||||
dataslothelper.cpp \
|
||||
|
|
|
|||
431
DataMgr/src/UnitConvertDlg.cpp
Normal file
431
DataMgr/src/UnitConvertDlg.cpp
Normal file
|
|
@ -0,0 +1,431 @@
|
|||
#pragma warning(push,0)
|
||||
// #include "Family.h"
|
||||
#include <QMessageBox>
|
||||
#include "UnitConvertDlg.h"
|
||||
#include "ui_UnitConvert.h"
|
||||
#include "CStringType.h"
|
||||
#include "GeometryUtils.h"
|
||||
#include <QTextStream>
|
||||
#include "DataImport.h"
|
||||
// #include "ObjProject.h"
|
||||
#pragma warning(pop)
|
||||
using namespace pai::ios::welllog;
|
||||
BEGIN_OSGGRAPHICS_NAMESPACE
|
||||
CUnitConvertDlg::CUnitConvertDlg(QWidget * parent, Qt::WindowFlags flags)
|
||||
: QDialog(parent,flags)
|
||||
{
|
||||
m_pUI = new Ui_UnitConvert();
|
||||
m_pUI->setupUi(this);
|
||||
QObject::connect(m_pUI->okbtn, SIGNAL(clicked()), this, SLOT(slotSave()));
|
||||
QObject::connect(m_pUI->cancelbtn, SIGNAL(clicked()), this, SLOT(slotCancel()));
|
||||
QObject::connect(m_pUI->buttonGroup, SIGNAL(buttonClicked (int)), this, SLOT(slotbuttonJudge(int)) );
|
||||
QObject::connect(m_pUI->comboBoxDataType, SIGNAL(currentIndexChanged(int)),this, SLOT(slotChangeUnitType()));
|
||||
QObject::connect(m_pUI->comboBoxConvertType, SIGNAL(currentIndexChanged(int)),this, SLOT(slotChangeConvertType()));
|
||||
QObject::connect(m_pUI->checkBox, SIGNAL(clicked()), this, SLOT(slotCheckChangeValue()));
|
||||
QObject::connect(m_pUI->checkBox_Curve, SIGNAL(clicked()), this, SLOT(slotCheckCurve()));
|
||||
QObject::connect(m_pUI->checkBox_Wave, SIGNAL(clicked()), this, SLOT(slotCheckWave()));
|
||||
QObject::connect(m_pUI->pushButton_SelAll, SIGNAL(clicked()), this, SLOT(slotSelAll()));
|
||||
QObject::connect(m_pUI->pushButton_NotSelAll, SIGNAL(clicked()), this, SLOT(slotNotSelAll()));
|
||||
QObject::connect(m_pUI->pushButton_ReSel, SIGNAL(clicked()), this, SLOT(slotReverseSel()));
|
||||
|
||||
m_pUI->buttonGroup->setId(m_pUI->radioButton,0);
|
||||
m_pUI->buttonGroup->setId(m_pUI->radioButton_2,1);
|
||||
m_pUI->radioButton->setChecked(1);
|
||||
m_pUI->tableWidget->setColumnCount(6);
|
||||
QStringList header;
|
||||
header<<"曲线名称"<<"曲线单位"<<"起始深度"<<"结束深度"<<"采样间隔"<<"深度单位";
|
||||
m_pUI->tableWidget->setHorizontalHeaderLabels(header);
|
||||
|
||||
m_pUI->tableWidget->horizontalHeader()->setStretchLastSection(true);
|
||||
m_pUI->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
//m_pUI->tableWidget->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents);
|
||||
//m_pUI->tableWidget->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents);
|
||||
CurveCheck=1;WaveCheck=1;
|
||||
CurrentType=-1;
|
||||
}
|
||||
|
||||
void CUnitConvertDlg::slotSave()
|
||||
{
|
||||
SelCurve.clear();
|
||||
if(CurrentType<0||CurrentType>=UnitTypeNum)
|
||||
{
|
||||
QMessageBox::warning(this,"提示","请选择单位类型");return;
|
||||
}
|
||||
if(CurrentConvert<0||CurrentConvert>=UnitType.find(UnitTypeName.at(CurrentType)).value())
|
||||
{
|
||||
QMessageBox::warning(this,"提示","请选择转换类型");return;
|
||||
}
|
||||
iConvertFlag=m_pUI->buttonGroup->checkedId();
|
||||
float muti=1.,adding=0.;
|
||||
if(m_pUI->checkBox->checkState()==Qt::Unchecked)
|
||||
{
|
||||
muti=m_pUI->lineEditMul->text().toFloat();
|
||||
adding=m_pUI->lineEditAdd->text().toFloat();
|
||||
}
|
||||
QString strUnit=m_pUI->lineEditName->text();
|
||||
QString strUnitAlias=m_pUI->lineEditAlias->text();
|
||||
CMemRdWt *mrw=new CMemRdWt();
|
||||
mrw->Open(FileName.toStdString().c_str(),CSlfIO::modeReadWrite);
|
||||
for(int i=0;i<m_pUI->tableWidget->rowCount();i++)
|
||||
{
|
||||
Qt::CheckState eState= m_pUI->tableWidget->item(i,0)->checkState();
|
||||
if (eState==Qt::Unchecked)continue;
|
||||
QString cvname = m_pUI->tableWidget->item(i,0)->text();
|
||||
SelCurve.append(cvname);////2020.8.2 for刷新数据查看
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
int index = mrw->FindObjectIndex( cvname.toStdString().c_str() );
|
||||
short Attribute,SubAttribute;
|
||||
mrw->GetObjectAttribute( index , &Attribute , &SubAttribute );
|
||||
if ( SubAttribute == CURVE_OBJECT )//0x0001
|
||||
{
|
||||
Slf_CURVE curveInfo;
|
||||
mrw->GetCurveInfo( index , &curveInfo );
|
||||
if (iConvertFlag == CONVERT_CURVE_UNIT)
|
||||
{
|
||||
strcpy( curveInfo.Unit , strUnit.toStdString().c_str() );//Reset curve unit
|
||||
strcpy( curveInfo.AliasUnit , strUnitAlias.toStdString().c_str() );
|
||||
mrw->SetCurveInfo( index ,&curveInfo ) ;
|
||||
float *oldData,*newData;
|
||||
//whp change 2018.10.15 保证读写一致
|
||||
int iPointNum = ( curveInfo.EndDepth - curveInfo.StartDepth ) / curveInfo.DepLevel + 1.5;//0.5 ;
|
||||
oldData = new float[iPointNum];
|
||||
newData = new float[iPointNum];
|
||||
mrw->ReadCurve( index , curveInfo.StartDepth , iPointNum ,oldData );
|
||||
for (int m= 0 ; m < iPointNum ; m ++ )
|
||||
{
|
||||
newData[m] = muti * oldData[m] + adding ;
|
||||
}
|
||||
mrw->WriteCurve( index , curveInfo.StartDepth , iPointNum ,newData );
|
||||
mrw->CloseCurve(index);
|
||||
delete oldData ;
|
||||
delete newData ;
|
||||
m_pUI->tableWidget->item(i,1)->setText(strUnit);
|
||||
}
|
||||
else// Depth unit convert
|
||||
{
|
||||
strcpy( curveInfo.DepthUnit , strUnit.toStdString().c_str() );//reset depth unit
|
||||
strcpy( curveInfo.DepthHZUnit , strUnitAlias.toStdString().c_str() );
|
||||
mrw->SetCurveInfo( index ,&curveInfo ) ;
|
||||
//whp change 2018.10.15 保证读写一致
|
||||
int iPointNum = ( curveInfo.EndDepth - curveInfo.StartDepth ) / curveInfo.DepLevel + 1.5;//0.5 ;
|
||||
Slf_OBJECT_FIELD curveFieldInfo[2];// = new Slf_OBJECT_FIELD[2];
|
||||
mrw->GetSlfTableFieldInfo(index,&curveFieldInfo[0]);
|
||||
curveFieldInfo[0].Start=curveFieldInfo[0].Start*muti+adding;
|
||||
curveFieldInfo[0].Rlev=curveFieldInfo[0].Rlev*muti+adding;
|
||||
curveFieldInfo[0].End=m_pUI->tableWidget->item(i,3)->text().toFloat()*muti+adding;//curveFieldInfo[0].Start+iPointNum*curveFieldInfo[0].Rlev;//curveInfo.EndDepth;
|
||||
mrw->SetSlfTableFieldInfo(index,&curveFieldInfo[0]);
|
||||
mrw->CloseCurve(index);
|
||||
m_pUI->tableWidget->item(i,2)->setText(QString::number(curveFieldInfo[0].Start));
|
||||
m_pUI->tableWidget->item(i,3)->setText(QString::number(curveFieldInfo[0].End));
|
||||
m_pUI->tableWidget->item(i,4)->setText(QString::number(curveFieldInfo[0].Rlev));
|
||||
m_pUI->tableWidget->item(i,5)->setText(strUnit);
|
||||
}
|
||||
}
|
||||
else//WAVE_OBJECT 0x0002
|
||||
{
|
||||
Slf_WAVE waveInfo;
|
||||
mrw->GetWaveInfo(index , &waveInfo );
|
||||
if (iConvertFlag == CONVERT_CURVE_UNIT)
|
||||
{
|
||||
strcpy_s( waveInfo.Unit , 32 , strUnit.toStdString().c_str() );
|
||||
strcpy_s( waveInfo.AliasUnit , 32 , strUnitAlias.toStdString().c_str() );
|
||||
mrw->SetWaveInfo( index ,&waveInfo ) ;
|
||||
//float **oldValue,**newValue;
|
||||
//whp change 2018.10.15 保证读写一致
|
||||
int iPointNum = ( waveInfo.EndDepth - waveInfo.StartDepth ) / waveInfo.DepLevel + 1.5;//0.5 ;
|
||||
int iSamplesNum = waveInfo.TimeSamples*waveInfo.ArrayNum;
|
||||
//allocate space
|
||||
/* oldValue = new float*[ iPointNum ] ;
|
||||
newValue = new float*[ iPointNum ];
|
||||
|
||||
for ( i = 0 ; i < iPointNum ; i ++ )
|
||||
{
|
||||
oldValue[i] = new float [ iSamplesNum +1 ] ;
|
||||
newValue[i] = new float [ iSamplesNum +1 ] ;
|
||||
} */
|
||||
float *oldValue=new float [ iSamplesNum +1 ],*newValue=new float [ iSamplesNum +1 ];
|
||||
//operate data
|
||||
//进度提示
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// ::GetProgressBar()->setVisible(true);
|
||||
// ::GetProgressBar()->setRange(0,iPointNum);
|
||||
for ( int m = 0 ; m < iPointNum ; m ++ )
|
||||
{
|
||||
// ::GetProgressBar()->setValue(m+1);
|
||||
//read
|
||||
mrw->ReadWave( index , waveInfo.StartDepth + waveInfo.DepLevel * m , 1 , &oldValue[0] );//&oldValue[i][0] );
|
||||
//calcuate using coefficient :muti and adding
|
||||
for ( int j = 0 ;j < iSamplesNum ; j ++ )
|
||||
{
|
||||
newValue[j] = muti * oldValue[j] + adding ;//newValue[i][j] = muti * oldValue[i][j] + adding ;
|
||||
}
|
||||
//write back
|
||||
mrw->WriteWave( index , waveInfo.StartDepth + waveInfo.DepLevel * m , 1 ,&newValue[0] );//&newValue[i][0] );
|
||||
}
|
||||
mrw->CloseWave(index);
|
||||
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
|
||||
// ::GetProgressBar()->setVisible(false);
|
||||
|
||||
//free space
|
||||
/* for ( i = 0; i < iPointNum ; i ++ )
|
||||
{
|
||||
delete oldValue[i];
|
||||
delete newValue[i];
|
||||
}*/
|
||||
delete []oldValue ;
|
||||
delete []newValue ;
|
||||
m_pUI->tableWidget->item(i,1)->setText(strUnit);
|
||||
}
|
||||
else//Depth unit convert
|
||||
{
|
||||
strcpy_s( waveInfo.DepthUnit , 32 , strUnit.toStdString().c_str() );//reset depth unit
|
||||
strcpy_s( waveInfo.DepthHZUnit , 32 , strUnitAlias.toStdString().c_str() );//reset depth unit
|
||||
mrw->SetWaveInfo( index ,&waveInfo ) ;
|
||||
//whp change 2018.10.15 保证读写一致
|
||||
int iPointNum = ( waveInfo.EndDepth - waveInfo.StartDepth ) / waveInfo.DepLevel + 1.5;//0.5 ;
|
||||
|
||||
Slf_OBJECT_FIELD waveFieldInfo[3];// = new Slf_OBJECT_FIELD [3];
|
||||
mrw->GetSlfTableFieldInfo(index,&waveFieldInfo[0]);
|
||||
waveFieldInfo[0].Start=waveFieldInfo[0].Start*muti+adding;
|
||||
waveFieldInfo[0].Rlev=waveFieldInfo[0].Rlev*muti+adding;
|
||||
waveFieldInfo[0].End=m_pUI->tableWidget->item(i,3)->text().toFloat()*muti+adding;//waveFieldInfo[0].Start+iPointNum*waveFieldInfo[0].Rlev;//waveInfo.EndDepth;
|
||||
mrw->SetSlfTableFieldInfo(index,&waveFieldInfo[0]);
|
||||
|
||||
mrw->CloseWave(index);
|
||||
m_pUI->tableWidget->item(i,2)->setText(QString::number(waveFieldInfo[0].Start));
|
||||
m_pUI->tableWidget->item(i,3)->setText(QString::number(waveFieldInfo[0].End));
|
||||
m_pUI->tableWidget->item(i,4)->setText(QString::number(waveFieldInfo[0].Rlev));
|
||||
m_pUI->tableWidget->item(i,5)->setText(strUnit);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete mrw;
|
||||
QMessageBox::warning(this,"提示","转换完成!");
|
||||
}
|
||||
/**
|
||||
*@brief 取消槽函数
|
||||
*/
|
||||
void CUnitConvertDlg::slotCancel()
|
||||
{
|
||||
MapUnit.clear();
|
||||
UnitType.clear();
|
||||
reject ();
|
||||
}
|
||||
void CUnitConvertDlg::init()
|
||||
{
|
||||
m_pUI->checkBox_Curve->setCheckState(Qt::Checked);
|
||||
m_pUI->checkBox_Wave->setCheckState(Qt::Checked);
|
||||
CMemRdWt *mrw=new CMemRdWt();
|
||||
mrw->Open(FileName.toStdString().c_str(),CSlfIO::modeReadWrite);
|
||||
int ObjectNumber=mrw->GetObjectCount();
|
||||
int CurveCount=0,WaveCount=0;
|
||||
char Name[200];
|
||||
for(int i=0;i<ObjectNumber;i++)
|
||||
{
|
||||
if(mrw->GetObjectStatus(i)!=OBJECT_NORMAL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
mrw->GetObjectName(i,Name);
|
||||
short Attribute,SubAttribute;
|
||||
Attribute=mrw->GetObjectType(i);
|
||||
if(Attribute==CURVE_OBJECT)
|
||||
{
|
||||
//CUR_INFO mInfo;
|
||||
Slf_CURVE cInfo;
|
||||
int index=mrw->OpenCurve(Name);
|
||||
if(index<0) continue;
|
||||
mrw->GetCurveInfo(index,&cInfo);
|
||||
/*mInfo.name=QString(QLatin1String(Name));
|
||||
mInfo.strCurveUnit=QString(QLatin1String(cInfo.Unit));
|
||||
mInfo.strDepthUnit=QString(QLatin1String(cInfo.DepthUnit));
|
||||
mInfo.sdep=cInfo.StartDepth;
|
||||
mInfo.edep=cInfo.EndDepth;
|
||||
mInfo.DepInterval=cInfo.DepLevel;
|
||||
Curve_Info.push_back()*/
|
||||
Curve_Info.push_back(cInfo);
|
||||
}
|
||||
else if(Attribute==WAVE_OBJECT)
|
||||
{
|
||||
Slf_WAVE cInfo;
|
||||
int index=mrw->OpenWave(Name);
|
||||
if(index>-1) {
|
||||
mrw->GetWaveInfo(index,&cInfo);
|
||||
Wave_Info.push_back(cInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
delete mrw;
|
||||
ReadConfig();
|
||||
for(int i=0;i<UnitTypeName.size();i++)
|
||||
m_pUI->comboBoxDataType->addItem(UnitTypeName[i]);
|
||||
RebrushList();
|
||||
|
||||
}
|
||||
void CUnitConvertDlg::ReadConfig()
|
||||
{
|
||||
QString ConfigName = ::GetConfPath()+"UnitConvert.ini";
|
||||
QFile InFile(ConfigName);
|
||||
if( !InFile.open(QIODevice::ReadOnly ) )
|
||||
{
|
||||
QMessageBox::warning(NULL,"提示","打开单位转换配置文件"+ConfigName+"错误");
|
||||
return ;
|
||||
}
|
||||
QTextStream textstream( &InFile );
|
||||
QString line;
|
||||
while(!textstream.atEnd())
|
||||
{
|
||||
line=textstream.readLine();
|
||||
if(line.indexOf("<BEGIN>")>=0)break;
|
||||
}
|
||||
line=textstream.readLine();
|
||||
line=line.right(line.length()-line.indexOf("=")-1);
|
||||
UnitTypeNum=line.toInt();
|
||||
for(int i=0;i<UnitTypeNum;i++)
|
||||
{
|
||||
line=textstream.readLine();
|
||||
QStringList StrList=line.split(" ");
|
||||
UnitTypeName.append(StrList[1]);
|
||||
int ItemNum=StrList.at(2).toInt();
|
||||
UnitType.insert(StrList[1],ItemNum);
|
||||
vector<ConvertUnit> temp;
|
||||
temp.reserve(ItemNum);
|
||||
MapUnit.insert(StrList[1],temp);
|
||||
}
|
||||
QString name;
|
||||
while(!textstream.atEnd())
|
||||
{
|
||||
line=textstream.readLine();
|
||||
if(line.indexOf("<END>")>=0)break;
|
||||
if(line.indexOf("#")>=0)
|
||||
{
|
||||
line.replace("#","");
|
||||
line.replace(" ","");
|
||||
name=line;
|
||||
continue;
|
||||
}
|
||||
if(line.indexOf("==")>=0)
|
||||
{
|
||||
while(line.indexOf(" ")>-1)line.replace(" "," ");
|
||||
while(line.indexOf(" ")>-1)line.replace(" "," ");
|
||||
line=line.trimmed();
|
||||
QStringList StrList=line.split(" ");
|
||||
ConvertUnit mUnit;
|
||||
mUnit.No=StrList.at(0).toInt();
|
||||
mUnit.Type=StrList.at(1);
|
||||
mUnit.NewUnit=StrList.at(2);
|
||||
mUnit.UnitAlias=StrList.at(3);
|
||||
mUnit.MutiCoefficient=StrList.at(4);//.toFloat();
|
||||
mUnit.AddingCoefficient=StrList.at(5);//.toFloat();
|
||||
MapUnit.find(name).value().push_back(mUnit);
|
||||
}
|
||||
}
|
||||
}
|
||||
void CUnitConvertDlg::slotCheckCurve()
|
||||
{
|
||||
CurveCheck=!CurveCheck;
|
||||
RebrushList();
|
||||
}
|
||||
void CUnitConvertDlg::slotCheckWave()
|
||||
{
|
||||
WaveCheck=!WaveCheck;
|
||||
RebrushList();
|
||||
}
|
||||
void CUnitConvertDlg::slotSelAll()
|
||||
{
|
||||
for(int i=0;i<m_pUI->tableWidget->rowCount();i++)m_pUI->tableWidget->item(i,0)->setCheckState(Qt::Checked);
|
||||
}
|
||||
void CUnitConvertDlg::slotNotSelAll()
|
||||
{
|
||||
for(int i=0;i<m_pUI->tableWidget->rowCount();i++)m_pUI->tableWidget->item(i,0)->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
void CUnitConvertDlg::slotReverseSel()
|
||||
{
|
||||
for(int i=0;i<m_pUI->tableWidget->rowCount();i++)
|
||||
{
|
||||
Qt::CheckState eState= m_pUI->tableWidget->item(i,0)->checkState();
|
||||
if (eState==Qt::Checked)m_pUI->tableWidget->item(i,0)->setCheckState(Qt::Unchecked);
|
||||
else m_pUI->tableWidget->item(i,0)->setCheckState(Qt::Checked);
|
||||
}
|
||||
}
|
||||
void CUnitConvertDlg::slotCheckChangeValue()//仅改变单位名称,不做数值转换
|
||||
{
|
||||
slotChangeConvertType();
|
||||
}
|
||||
void CUnitConvertDlg::slotbuttonJudge(int id)
|
||||
{
|
||||
iConvertFlag=id;
|
||||
if(iConvertFlag==CONVERT_DEPTH_UNIT)
|
||||
{
|
||||
for(int i=0;i<UnitTypeNum;i++)
|
||||
{
|
||||
if(UnitTypeName[i]=="Length")
|
||||
{
|
||||
m_pUI->comboBoxDataType->setCurrentIndex(i);
|
||||
m_pUI->comboBoxDataType->setEnabled(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else m_pUI->comboBoxDataType->setEnabled(1);
|
||||
}
|
||||
void CUnitConvertDlg::slotChangeUnitType()
|
||||
{
|
||||
CurrentType=m_pUI->comboBoxDataType->currentIndex();
|
||||
m_pUI->comboBoxConvertType->clear();
|
||||
std::vector<ConvertUnit> mUnit=MapUnit.find(UnitTypeName.at(CurrentType)).value();
|
||||
for(int i=0;i<UnitType.find(UnitTypeName.at(CurrentType)).value();i++)
|
||||
{
|
||||
m_pUI->comboBoxConvertType->addItem(mUnit[i].Type);
|
||||
}
|
||||
}
|
||||
void CUnitConvertDlg::slotChangeConvertType()
|
||||
{
|
||||
CurrentConvert=m_pUI->comboBoxConvertType->currentIndex();
|
||||
if(CurrentConvert<0)return;
|
||||
std::vector<ConvertUnit> mUnit=MapUnit.find(UnitTypeName.at(CurrentType)).value();
|
||||
CurrentUnit=mUnit.at(CurrentConvert);
|
||||
m_pUI->lineEditName->setText(CurrentUnit.NewUnit);
|
||||
m_pUI->lineEditAlias->setText(CurrentUnit.UnitAlias);
|
||||
m_pUI->lineEditMul->setText(CurrentUnit.MutiCoefficient);//QString::number(CurrentUnit.MutiCoefficient));
|
||||
m_pUI->lineEditAdd->setText(CurrentUnit.AddingCoefficient);
|
||||
if(m_pUI->checkBox->checkState()==Qt::Checked)m_pUI->lineEditMode->setText("NewValue=1.0*OldValue+0.0");
|
||||
else
|
||||
{
|
||||
if(CurrentUnit.AddingCoefficient.indexOf("-")>=0)m_pUI->lineEditMode->setText("NewValue="+CurrentUnit.MutiCoefficient+"*OldValue"+CurrentUnit.AddingCoefficient);
|
||||
else m_pUI->lineEditMode->setText("NewValue="+CurrentUnit.MutiCoefficient+"*OldValue+"+CurrentUnit.AddingCoefficient);
|
||||
}
|
||||
}
|
||||
void CUnitConvertDlg::RebrushList()
|
||||
{
|
||||
m_pUI->tableWidget->clearContents();//clear();whp change 2020.3.6
|
||||
int row=CurveCheck*Curve_Info.size()+WaveCheck*Wave_Info.size();
|
||||
m_pUI->tableWidget->setRowCount(row);
|
||||
if(CurveCheck)
|
||||
{
|
||||
for(int i=0;i<Curve_Info.size();i++)
|
||||
{
|
||||
m_pUI->tableWidget->setItem(i,0,new QTableWidgetItem(QString(QLatin1String(Curve_Info[i].Name))));
|
||||
m_pUI->tableWidget->setItem(i,1,new QTableWidgetItem(QString(QLatin1String(Curve_Info[i].Unit))));
|
||||
m_pUI->tableWidget->setItem(i,2,new QTableWidgetItem(QString::number(Curve_Info[i].StartDepth)));
|
||||
m_pUI->tableWidget->setItem(i,3,new QTableWidgetItem(QString::number(Curve_Info[i].EndDepth)));
|
||||
m_pUI->tableWidget->setItem(i,4,new QTableWidgetItem(QString::number(Curve_Info[i].DepLevel)));
|
||||
m_pUI->tableWidget->setItem(i,5,new QTableWidgetItem(QString(QLatin1String(Curve_Info[i].DepthUnit))));
|
||||
m_pUI->tableWidget->item(i,0)->setCheckState(Qt::Checked);
|
||||
}
|
||||
}
|
||||
if(WaveCheck)
|
||||
{
|
||||
for(int i=0;i<Wave_Info.size();i++)
|
||||
{
|
||||
m_pUI->tableWidget->setItem(i+CurveCheck*Curve_Info.size(),0,new QTableWidgetItem(QString(QLatin1String(Wave_Info[i].Name))));
|
||||
m_pUI->tableWidget->setItem(i+CurveCheck*Curve_Info.size(),1,new QTableWidgetItem(QString(QLatin1String(Wave_Info[i].Unit))));
|
||||
m_pUI->tableWidget->setItem(i+CurveCheck*Curve_Info.size(),2,new QTableWidgetItem(QString::number(Wave_Info[i].StartDepth)));
|
||||
m_pUI->tableWidget->setItem(i+CurveCheck*Curve_Info.size(),3,new QTableWidgetItem(QString::number(Wave_Info[i].EndDepth)));
|
||||
m_pUI->tableWidget->setItem(i+CurveCheck*Curve_Info.size(),4,new QTableWidgetItem(QString::number(Wave_Info[i].DepLevel)));
|
||||
m_pUI->tableWidget->setItem(i+CurveCheck*Curve_Info.size(),5,new QTableWidgetItem(QString(QLatin1String(Wave_Info[i].DepthUnit))));
|
||||
m_pUI->tableWidget->item(i+CurveCheck*Curve_Info.size(),0)->setCheckState(Qt::Checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
END_OSGGRAPHICS_NAMESPACE
|
||||
90
DataMgr/src/UnitConvertDlg.h
Normal file
90
DataMgr/src/UnitConvertDlg.h
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
|
||||
#pragma warning(push,0)
|
||||
#include <cassert>
|
||||
#include <QDialog>
|
||||
// #include "ConsoleOutputWidget.h"
|
||||
#include "OSGFramework.h"
|
||||
#include "ui_UnitConvert.h"
|
||||
#include "objwelllogRound.h"
|
||||
#include "memrdwt.h"
|
||||
#pragma warning(pop)
|
||||
|
||||
BEGIN_OSGGRAPHICS_NAMESPACE
|
||||
/**
|
||||
* @brief 表格选择列自定义委托
|
||||
*/
|
||||
#define CONVERT_CURVE_UNIT 0
|
||||
#define CONVERT_DEPTH_UNIT 1
|
||||
struct ConvertUnit
|
||||
{
|
||||
int No;
|
||||
QString Type;
|
||||
QString NewUnit;
|
||||
QString UnitAlias;
|
||||
QString MutiCoefficient;
|
||||
QString AddingCoefficient;
|
||||
};
|
||||
/*
|
||||
struct CUR_INFO
|
||||
{
|
||||
QString name;
|
||||
QString strCurveUnit;
|
||||
float sdep,edep;
|
||||
float DepInterval;
|
||||
QString strDepthUnit;
|
||||
};*/
|
||||
class CUnitConvertDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CUnitConvertDlg(QWidget * parent=0, Qt::WindowFlags flags=0);
|
||||
~CUnitConvertDlg()
|
||||
{
|
||||
if(m_pUI) delete m_pUI;
|
||||
}
|
||||
Ui_UnitConvert *m_pUI;
|
||||
private slots:
|
||||
/**
|
||||
*@brief 保存槽函数
|
||||
*/
|
||||
void slotSave();
|
||||
|
||||
/**
|
||||
*@brief 取消槽函数
|
||||
*/
|
||||
void slotCancel();
|
||||
void slotChangeUnitType();
|
||||
void slotChangeConvertType();
|
||||
void slotbuttonJudge(int);
|
||||
void slotCheckChangeValue();//仅改变单位名称,不做数值转换
|
||||
void slotCheckCurve();
|
||||
void slotCheckWave();
|
||||
void slotSelAll();
|
||||
void slotNotSelAll();
|
||||
void slotReverseSel();
|
||||
public:
|
||||
|
||||
//std::vector<ConvertUnit> m_VConvertUnit;
|
||||
QMap<QString,vector<ConvertUnit> > MapUnit;
|
||||
//std::vector<CUR_INFO> Curve_Info;
|
||||
//std::vector<CUR_INFO> Wave_Info;
|
||||
std::vector<Slf_CURVE> Curve_Info;
|
||||
std::vector<Slf_WAVE> Wave_Info;
|
||||
QString FileName;
|
||||
bool CurveCheck,WaveCheck;
|
||||
int UnitTypeNum;
|
||||
QStringList UnitTypeName;
|
||||
QMap<QString,int>UnitType;//单位类型名 单位个数
|
||||
int CurrentType;
|
||||
int CurrentConvert;
|
||||
int iConvertFlag;
|
||||
ConvertUnit CurrentUnit;
|
||||
void init();
|
||||
void ReadConfig();
|
||||
void RebrushList();
|
||||
QStringList SelCurve;
|
||||
//CObjWelllogRound* pround;
|
||||
};
|
||||
|
||||
END_OSGGRAPHICS_NAMESPACE;
|
||||
|
|
@ -865,6 +865,11 @@ void QtProjectWidgets::initCurveObjectTreeMenu(QMenu *menu, QTreeWidget *treeWid
|
|||
connect(m_action_DepthResample, SIGNAL(triggered(bool)), this, SLOT(onDepthResample(bool)));
|
||||
menu->addAction(m_action_DepthResample);
|
||||
|
||||
QAction* action_Curve2Table = new QAction("转换为结论表格", treeWidget);
|
||||
action_Curve2Table->setIcon(QIcon(GetImagePath() + "icon/Sheet.png")); // 设置图标
|
||||
connect(action_Curve2Table, SIGNAL(triggered(bool)), this, SLOT(onCurve2Table(bool)));
|
||||
menu->addAction(action_Curve2Table);
|
||||
|
||||
QAction* action_WaveCompose = new QAction("合成阵列曲线", treeWidget);
|
||||
action_WaveCompose->setIcon(QIcon(GetImagePath() + "icon/RigidDepthShifting.png"));
|
||||
connect(action_WaveCompose, SIGNAL(triggered()), this, SLOT(onWaveCompose()));
|
||||
|
|
@ -1058,6 +1063,16 @@ void QtProjectWidgets::initSlfNameTreeMenu(QMenu *menu, QTreeWidget *treeWidget)
|
|||
connect(action_DepthShift, SIGNAL(triggered(bool)), this, SLOT(onDepthShift_Well(bool)));
|
||||
menu->addAction(action_DepthShift);
|
||||
|
||||
m_action_DepthResample = new QAction("深度重采样", treeWidget);
|
||||
m_action_DepthResample->setIcon(QIcon(GetImagePath() + "icon/AddToTrack.png")); // 设置图标
|
||||
connect(m_action_DepthResample, SIGNAL(triggered(bool)), this, SLOT(onDepthResample(bool)));
|
||||
menu->addAction(m_action_DepthResample);
|
||||
|
||||
action_New = new QAction("单位转换", treeWidget);
|
||||
// action_New->setIcon(QIcon(GetImagePath() + "icon/Correction.png")); // 设置图标
|
||||
connect(action_New, SIGNAL(triggered(bool)), this, SLOT(onUnitConvert()));
|
||||
menu->addAction(action_New);
|
||||
|
||||
QAction* action_Delete = new QAction("删除", treeWidget);
|
||||
action_Delete->setIcon(QIcon(GetImagePath() + "icon/Delete.png")); // 设置图标":/image/u174.png"
|
||||
connect(action_Delete, SIGNAL(triggered()), this, SLOT(onDeleteObject()));
|
||||
|
|
@ -1446,6 +1461,35 @@ void QtProjectWidgets::onDepthResample(bool checked)
|
|||
// }
|
||||
}
|
||||
|
||||
//转换为结论表格
|
||||
void QtProjectWidgets::onCurve2Table(bool checked)
|
||||
{
|
||||
if (ui->treeWidget->selectedItems().count()!=1)
|
||||
return;
|
||||
QTreeWidgetItem *pItem = *ui->treeWidget->selectedItems().begin();
|
||||
QString strTreeTag = pItem->data(0, Qt::UserRole).toString();
|
||||
if (strTreeTag == "curveObject")
|
||||
{
|
||||
QString strSlfName = pItem->data(0, Qt::UserRole+1).toString();
|
||||
if (!strSlfName.contains(".slf"))
|
||||
return;
|
||||
|
||||
CObjWellLog* pround= new CObjWellLog();
|
||||
pround->SetSlfFileName(strSlfName);
|
||||
pround->SetName(pItem->text(0));
|
||||
if(pround&&pround->GetSlfFileName()!="")
|
||||
{
|
||||
QString curveName=pround->GetName();
|
||||
QString FileName=pround->GetSlfFileName();
|
||||
if (NULL == magr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
QString tranResult = magr->Curve2ResultTable(FileName,curveName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//合成阵列曲线
|
||||
void QtProjectWidgets::onWaveCompose(bool checked)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ public slots:
|
|||
void ApplyShiftDepth(QString strSlfName, QString strLineName, double DepthOffset);
|
||||
void onDepthShift(bool checked = false); //深度移动
|
||||
void onDepthResample(bool checked = false); //深度重采样
|
||||
void onCurve2Table(bool checked = false); //转换为结论表格
|
||||
void onWaveCompose(bool checked = false); //合成阵列曲线
|
||||
void onInfoEdit(bool checked = false); //属性
|
||||
|
||||
|
|
@ -74,6 +75,7 @@ public slots:
|
|||
void onCopyObject(); //数据对象拷贝
|
||||
//井次
|
||||
void onWelllogInformation(); //编辑测井信息
|
||||
void onUnitConvert(); //单位转换
|
||||
void onDepthShift_Well(bool checked = false); //深度移动
|
||||
//表格数据 根节点
|
||||
void onCreateNewTable(); //创建新表
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user