1883 lines
50 KiB
C++
1883 lines
50 KiB
C++
#pragma warning( push ,0)
|
||
#include <cassert>
|
||
#include <algorithm>
|
||
#include <QDebug>
|
||
#include <QCoreApplication>
|
||
#include "LogIO.h"
|
||
#include "ObjWelllog.h"
|
||
// #include "ObjWell.h"
|
||
// #include "ObjWelllogRound.h"
|
||
// #include "ObjWellTrack.h"
|
||
// #include "ObjWellLogTrack.h"
|
||
// #include "FamilyAliases.h"
|
||
// #include "Family.h"
|
||
#include "MemRdWt.h"
|
||
#include "BaseFun.h"
|
||
// #include "ObjectEvent.h"
|
||
#include "ObjectID.h"
|
||
#pragma warning( pop )
|
||
|
||
BEGIN_OSGDATAMODEL_NAMESPACE;
|
||
CObjWellLog::CObjWellLog(bool visible)
|
||
{
|
||
// SetFlagEnable(PaiObject::VisibibleOnTree, visible);
|
||
m_fPropertMin = 200;
|
||
m_fPropertMax = 100;
|
||
m_DepthOffset = 0;
|
||
// SetIconName("icon/Log.png");
|
||
m_BottomDepth=0.0;
|
||
m_TopDepth=0.0;
|
||
SetName("AC");
|
||
m_ShiftTopDepth=-9999.0;
|
||
m_ShiftBottomDepth=-9999.0;
|
||
m_ObjectType=0;
|
||
m_Rlev=0.125;
|
||
m_ChangeNo=0;
|
||
m_pObjWell=NULL;
|
||
m_strValue[0]=0;
|
||
isRun=0;
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
// connect( (const QObject*)( &GetObjectEvent() ),SIGNAL(RefreshData(QString,QString,QObject*)),this,SLOT(slotRefreshData(QString ,QString,QObject*)));
|
||
// connect( (const QObject*)( &GetObjectEvent() ),SIGNAL(DeAttchData(QString,QString)),this,SLOT(slotDeAttchData(QString ,QString)));
|
||
}
|
||
CObjWellLog::CObjWellLog()
|
||
{
|
||
m_fPropertMin = 0;
|
||
m_fPropertMax = 100;
|
||
m_DepthOffset = 0;
|
||
// SetIconName("icon/Log.png");
|
||
m_BottomDepth=0.0;
|
||
m_TopDepth=0.0;
|
||
m_ShiftTopDepth=-9999.0;
|
||
m_ShiftBottomDepth=-9999.0;
|
||
SetName("AC");
|
||
m_ObjectType=0;
|
||
m_Rlev=0.125;
|
||
m_ChangeNo=0;
|
||
m_pObjWell=NULL;
|
||
isRun=false;
|
||
isLoad=false;
|
||
isUsing = false;
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
// connect( (const QObject*)( &GetObjectEvent() ),
|
||
// SIGNAL(RefreshData(QString,QString,QObject*)),
|
||
// this,SLOT(slotRefreshData(QString ,QString,QObject*)));
|
||
// connect( (const QObject*)( &GetObjectEvent() ),SIGNAL(DeAttchData(QString,QString)),this,SLOT(slotDeAttchData(QString ,QString)));
|
||
}
|
||
void CObjWellLog::slotRefreshData(QString slf,QString curname,QObject*re)
|
||
{
|
||
// if(re==this) {
|
||
// return;
|
||
// }
|
||
// QString slf1=m_SlfFileName;
|
||
// slf1.replace("\\","/");
|
||
// QString slf2=slf;
|
||
// slf2.replace("\\","/");
|
||
// slf1.toUpper();
|
||
// slf2.toUpper();
|
||
// if(slf1==slf2) {
|
||
// if(!curname.isEmpty()) {
|
||
// if(GetName()==curname&&isRun) {
|
||
// // isLoad=false;
|
||
// GetValidMDProperty(m_vMD,m_vProperty,-99999,-99999);
|
||
// // LoadFromSLF();
|
||
// }
|
||
// return;
|
||
// }
|
||
// else {
|
||
// if(isRun) {
|
||
// // isLoad=false;
|
||
// GetValidMDProperty(m_vMD,m_vProperty,-99999,-99999);
|
||
// // LoadFromSLF();
|
||
// }
|
||
// }
|
||
// }
|
||
}
|
||
void CObjWellLog::slotDeAttchData(QString slf,QString curname)
|
||
{
|
||
QString slf1=m_SlfFileName;
|
||
slf1.replace("\\","/");
|
||
QString slf2=slf;
|
||
slf2.replace("\\","/");
|
||
slf1.toUpper();
|
||
slf2.toUpper();
|
||
if(slf1==slf2) {
|
||
if(!curname.isEmpty()) {
|
||
if(GetName()==curname&&isRun) {
|
||
QString name=GetSlfFileName()+GetName();
|
||
if(IsMappingMem(name.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
m_vMD.clear();
|
||
m_vProperty.clear();
|
||
m_vMDShifting.clear();
|
||
}
|
||
isLoad=false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
CObjWellLogTrack *CObjWellLog::GetWellLogTrack()
|
||
{
|
||
// PaiObject *pPai=GetPaiObject();
|
||
// while(pPai) {
|
||
// CObjWellLogTrack *pTWellLogTrack=dynamic_cast<CObjWellLogTrack *>(pPai);
|
||
// if(pTWellLogTrack) {
|
||
// return pTWellLogTrack;
|
||
// }
|
||
// pPai=pPai->GetParent();
|
||
// }
|
||
return NULL;
|
||
}
|
||
CObjWellTrack *CObjWellLog::GetWellTrack()
|
||
{
|
||
// PaiObject *pPai=GetPaiObject();
|
||
// while(pPai) {
|
||
// CObjWellTrack *pTWellTrack=dynamic_cast<CObjWellTrack *>(pPai);
|
||
// if(pTWellTrack) {
|
||
// return pTWellTrack;
|
||
// }
|
||
// else {
|
||
// CObjWellLogTrack *pTWellLogTrack=dynamic_cast<CObjWellLogTrack *>(pPai);
|
||
// if(pTWellLogTrack) {
|
||
// CObjWellTrack *pTWellTrack=dynamic_cast<CObjWellTrack *>(pTWellLogTrack->GetWellTrack());
|
||
// if(pTWellTrack) {
|
||
// return pTWellTrack;
|
||
// }
|
||
// }
|
||
// }
|
||
// pPai=pPai->GetParent();
|
||
// }
|
||
return NULL;
|
||
}
|
||
|
||
QString CObjWellLog::GetDescription()
|
||
{
|
||
//if(!isRun)
|
||
{
|
||
CLogIO *logio=new CLogIO();
|
||
QString slfFileName=GetSlfFileName();
|
||
if(slfFileName.isEmpty()) return "";
|
||
if(!logio->Open(slfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
delete logio;
|
||
return "";
|
||
}
|
||
QString name=GetName();
|
||
int i=logio->OpenCurve(name.toStdString().c_str());
|
||
if(i<0) {
|
||
delete logio;
|
||
return "";
|
||
}
|
||
logio->GetCurveInfo(i,&acurveinfo);
|
||
if(acurveinfo.DepLevel!=0&&acurveinfo.EndDepth-acurveinfo.StartDepth>0)
|
||
{
|
||
if(acurveinfo.MaxValue==acurveinfo.MinValue||acurveinfo.MaxValue==-99999||acurveinfo.MaxValue==-9999||acurveinfo.MinValue==999999||acurveinfo.MinValue==999999||acurveinfo.MinValue==99999||acurveinfo.MinValue==99999||acurveinfo.MinValue==-9999)
|
||
{
|
||
MyDataTypeEnum vVdl;
|
||
DWORD count=(acurveinfo.EndDepth-acurveinfo.StartDepth)/acurveinfo.DepLevel+1.5;
|
||
DWORD len=count*acurveinfo.CodeLen;
|
||
acurveinfo.MinValue=99999999;
|
||
acurveinfo.MaxValue=-99999999;
|
||
if(acurveinfo.CodeLen==8) acurveinfo.MinValue=99999999;
|
||
vVdl.vchar=new char[len];
|
||
len=logio->ReadCurve(i, acurveinfo.StartDepth,count,(void *)vVdl.vchar);
|
||
if(!len) {
|
||
delete vVdl.vchar;
|
||
delete logio;
|
||
return "data error!";
|
||
}
|
||
for(int kk=0;kk<count;kk=kk+10)
|
||
{
|
||
float buf[200];
|
||
buf[0]=0;
|
||
float temp=logio->GetData(acurveinfo.RepCode,&vVdl.vchar[kk*acurveinfo.CodeLen],buf);
|
||
if(temp==-9999.0||temp==-999.25||temp==-99999.0) continue;
|
||
#ifdef WIN32
|
||
if(_isnan(temp)||!_finite(temp)) continue;
|
||
#else
|
||
if(__isnan(temp)||!__finite(temp)) continue;
|
||
#endif // WIN32
|
||
|
||
if(acurveinfo.MaxValue<temp) acurveinfo.MaxValue=temp;
|
||
if(acurveinfo.MinValue>temp) acurveinfo.MinValue=temp;
|
||
}
|
||
logio->SetCurveInfo(i,&acurveinfo);
|
||
delete vVdl.vchar;
|
||
}
|
||
}
|
||
logio->CloseCurve(i);
|
||
delete logio;
|
||
}
|
||
if(acurveinfo.RepCode<1) acurveinfo.RepCode=1;
|
||
if(acurveinfo.RepCode>12) acurveinfo.RepCode=12;
|
||
QString result="";
|
||
result.append("对象类型:曲线\n");
|
||
result.append("曲线名:").append(acurveinfo.Name).append("\n");
|
||
result.append("曲线别名:").append(QString::fromStdString(acurveinfo.AliasName)).append("\n");
|
||
result.append("本地数据文件:").append(GetSlfFileName()).append("\n");
|
||
result.append("顶深:").append(QString::number(acurveinfo.StartDepth)).append("\n");
|
||
result.append("底深:").append(QString::number(acurveinfo.EndDepth)).append("\n");
|
||
result.append("采样间隔:").append(QString::number(acurveinfo.DepLevel)).append("\n");
|
||
result.append("数据类型:").append(Rep_STR[acurveinfo.RepCode-1]).append("\n");
|
||
result.append("字节长度:").append(QString::number(acurveinfo.CodeLen)).append("\n");
|
||
result.append("最小值:").append(QString::number(acurveinfo.MinValue)).append("\n");
|
||
result.append("最大值:").append(QString::number(acurveinfo.MaxValue)).append("\n");
|
||
result.append("单位:").append(QString::fromStdString(acurveinfo.Unit)).append("\n");
|
||
return result;
|
||
}
|
||
|
||
double CObjWellLog::GetRlev()
|
||
{
|
||
if(m_Rlev==0) m_Rlev=0.125;
|
||
return m_Rlev;
|
||
}
|
||
void CObjWellLog::SetRlev(float rlev)
|
||
{
|
||
m_Rlev=rlev;
|
||
}
|
||
double CObjWellLog::GetShiftOffset()
|
||
{
|
||
return m_DepthOffset;
|
||
}
|
||
void CObjWellLog::SetShiftOffset(double DepthOffset)
|
||
{
|
||
m_DepthOffset=DepthOffset;
|
||
}
|
||
|
||
float CObjWellLog::GetPropertyMin()
|
||
{
|
||
return m_fPropertMin;
|
||
}
|
||
|
||
// pai::ios::welllog::WelllogCurve & CObjWellLog::GetLogCurve()
|
||
// {
|
||
// return m_logCurve;
|
||
// }
|
||
|
||
float CObjWellLog::GetPropertyMax()
|
||
{
|
||
return m_fPropertMax;
|
||
}
|
||
|
||
void CObjWellLog::ReCalculateMinMax()
|
||
{
|
||
_CalculateMinMax(true);
|
||
}
|
||
void CObjWellLog::_CalculateMinMax(bool force)
|
||
{
|
||
if( m_fPropertMin < m_fPropertMax && force == false) return;
|
||
|
||
if(!m_vMD.size()) {
|
||
return;
|
||
}
|
||
if( m_vProperty.size() )
|
||
{
|
||
double val=0;
|
||
int size=m_vProperty.size();
|
||
m_fPropertMin =99999999999.0;
|
||
m_fPropertMax =-99999999999.0;
|
||
for(int i=0;i<size;i++) {
|
||
val=GetData(i);
|
||
if(val==-9999||val==-999.25||val==-99999) continue;
|
||
if(m_fPropertMin>val) m_fPropertMin=val;//m_vProperty.m_vProperty[i];
|
||
if(m_fPropertMax<val) m_fPropertMax=val;//m_vProperty.m_vProperty[i];
|
||
}
|
||
if(m_fPropertMin ==99999999999.0) m_fPropertMin=1;
|
||
if(m_fPropertMax ==-99999999999.0) m_fPropertMin=100;
|
||
acurveinfo.MaxValue=m_fPropertMax;
|
||
acurveinfo.MinValue=m_fPropertMin;
|
||
}
|
||
}
|
||
|
||
CObjWellLog::~CObjWellLog()
|
||
{
|
||
m_vMD.clear();
|
||
m_vMDShifting.clear();
|
||
m_vProperty.clear();
|
||
QString name=m_SlfFileName+GetName();
|
||
if(IsMappingMem(name.toStdString().c_str()))
|
||
{
|
||
{
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
}
|
||
}
|
||
|
||
void CObjWellLog::SetSlfFileName( QString filePath )
|
||
{
|
||
m_SlfFileName = filePath;
|
||
// QList<PaiObject*> wellLogTracks;
|
||
// this->GetChildren(wellLogTracks);
|
||
// for(int j=0;j<wellLogTracks.size();j++) {
|
||
// if(wellLogTracks[j]==this) continue;
|
||
// CObjWellLog* tempWellLog= dynamic_cast<CObjWellLog*>(wellLogTracks[j]);
|
||
// if(tempWellLog) {
|
||
// tempWellLog->SetSlfFileName(filePath);
|
||
// }
|
||
// }
|
||
}
|
||
|
||
QString CObjWellLog::GetSlfFileName()
|
||
{
|
||
return m_SlfFileName;
|
||
}
|
||
|
||
QUuid CObjWellLog::GetTypeID()const
|
||
{
|
||
return GetClassID_WellLog();
|
||
}
|
||
|
||
void CObjWellLog::SetBelongID()
|
||
{
|
||
// pai::objectmodel::PaiObject* paiWelllogRound = this->GetForebear(GetClassID_WellLogRound());
|
||
// if(paiWelllogRound)
|
||
// {
|
||
// pai::datamodel::CObjWelllogRound *currentWelllogRound= dynamic_cast<pai::datamodel::CObjWelllogRound*>(paiWelllogRound);
|
||
// if(currentWelllogRound)
|
||
// {
|
||
// pai::ios::welllog::DataObject* dbWelllogRound = currentWelllogRound->GetDbObject();
|
||
// if(dbWelllogRound)
|
||
// {
|
||
// m_logCurve.SetDataBelongID(dbWelllogRound->GetDataID());
|
||
// }
|
||
// }
|
||
// }
|
||
}
|
||
|
||
void CObjWellLog::SetShiftBottomDepth( double bottomDepth )
|
||
{
|
||
m_ShiftBottomDepth=bottomDepth;
|
||
}
|
||
|
||
void CObjWellLog::SetShiftTopDepth( double topDepth )
|
||
{
|
||
m_ShiftTopDepth=topDepth;
|
||
}
|
||
|
||
void CObjWellLog::SetBottomDepth( double bottomDepth )
|
||
{
|
||
m_BottomDepth=bottomDepth;
|
||
}
|
||
|
||
void CObjWellLog::SetTopDepth( double topDepth )
|
||
{
|
||
m_TopDepth=topDepth;
|
||
}
|
||
|
||
void CObjWellLog::SetpropertyMin( float Propertymin )
|
||
{
|
||
m_fPropertMin= Propertymin;
|
||
}
|
||
|
||
void CObjWellLog::SetpropertyMax( float Propertymax )
|
||
{
|
||
m_fPropertMax=Propertymax;
|
||
}
|
||
|
||
// bool CObjWellLog::Serialize( CObjectArchive &ar )
|
||
// {
|
||
// if(ar.IsStoring())
|
||
// {
|
||
// BEGIN_WRITE_OBJECT( ar,1 );
|
||
|
||
// BEGIN_WRITE_BLOCK( ar, 1);
|
||
// ar << HasFlag(PaiObject::VisibibleOnTree);
|
||
// ar <<m_SlfFileName;
|
||
// CBaseObjectImpl::Serialize( ar );
|
||
// ar <<m_fPropertMin;
|
||
// ar <<m_fPropertMax;
|
||
// ar <<m_TopDepth;
|
||
// ar <<m_BottomDepth;
|
||
|
||
// ar <<QString::fromStdString(m_logCurve.GetCurveAlias());
|
||
// ar <<QString::fromStdString(m_logCurve.GetFamilyType());
|
||
// ar <<QString::fromStdString(m_logCurve.GetUnit());
|
||
// ar <<m_logCurve.GetSampleInterval();
|
||
// END_WRITE_BLOCK( ar, 1 );
|
||
|
||
// END_WRITE_OBJECT( ar );
|
||
// }
|
||
// else
|
||
// {
|
||
// BEGIN_READ_OBJECT( ar,1 );
|
||
|
||
// BEGIN_READ_BLOCK( 1 );
|
||
// bool visible = true;
|
||
// ar >> visible;
|
||
// SetFlagEnable(PaiObject::VisibibleOnTree, visible);
|
||
// ar >>m_SlfFileName;
|
||
|
||
// CBaseObjectImpl::Serialize( ar );
|
||
// ar >>m_fPropertMin;
|
||
// ar >>m_fPropertMax;
|
||
// ar >>m_TopDepth;
|
||
// ar >>m_BottomDepth;
|
||
|
||
// QString strtmp;
|
||
|
||
// ar >>strtmp;m_logCurve.SetCurveAlias(strtmp.toStdString());
|
||
// ar >>strtmp;m_logCurve.SetFamilyType(strtmp.toStdString());
|
||
// ar >>strtmp;m_logCurve.SetUnit(strtmp.toStdString());
|
||
// float tmpfloat;
|
||
// ar >>tmpfloat;m_logCurve.SetSampleInterval(tmpfloat);
|
||
|
||
// END_READ_BLOCK( 1 );
|
||
|
||
// END_READ_OBJECT( ar );
|
||
// }
|
||
// return true;
|
||
// }
|
||
void CObjWellLog::GetValidMDProperty( PFLOATPROPERTY &vMD,PFLOATPROPERTY &vProperty,float sdep,float edep)
|
||
{
|
||
if(m_SlfFileName=="") return;
|
||
if(sdep>=edep){
|
||
if(sdep!=-99999) return;
|
||
}
|
||
isRun=true;
|
||
QString name=m_SlfFileName+GetName();
|
||
if(key!=name) {
|
||
vMD.SetSize(0);
|
||
vMD.m_vProperty=0;
|
||
vProperty.SetSize(0);
|
||
vProperty.m_vProperty=NULL;
|
||
if(IsMappingMem(key.toStdString().c_str()))
|
||
{
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
key="";
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
delete logio;
|
||
return;
|
||
}
|
||
int curveindex=logio->OpenCurve(GetName().toStdString().c_str());
|
||
if(curveindex<0)
|
||
{
|
||
delete logio;
|
||
return;
|
||
}
|
||
Slf_CURVE acurveinfo;
|
||
logio->GetCurveInfo(curveindex,&acurveinfo);
|
||
if(acurveinfo.DepLevel==0) {
|
||
acurveinfo.DepLevel=0.125;
|
||
logio->DiscardObject(curveindex);
|
||
delete logio;
|
||
return;
|
||
}
|
||
m_ObjectType=CURVE_OBJECT;
|
||
int samplenum=(acurveinfo.EndDepth-acurveinfo.StartDepth)/acurveinfo.DepLevel+1.5;
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
key=name;
|
||
MappingMem(&m_Handle,(LPSTR*)&m_SharedMemory,3*sizeof(float)+sizeof(int)+acurveinfo.CodeLen*(samplenum+1),name.toStdString().c_str());
|
||
if(!m_Handle||!m_SharedMemory) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
key="";
|
||
return;
|
||
}
|
||
float *buffer=(float*)m_SharedMemory;
|
||
buffer[0]=acurveinfo.StartDepth;
|
||
buffer[1]=acurveinfo.EndDepth;
|
||
buffer[2]=acurveinfo.DepLevel;
|
||
((int *)buffer)[3]=samplenum;
|
||
logio->ReadCurve(curveindex,acurveinfo.StartDepth,samplenum,(void *)&buffer[4]);
|
||
if(acurveinfo.MaxValue==acurveinfo.MinValue||acurveinfo.MaxValue==-99999||acurveinfo.MaxValue==-9999||acurveinfo.MinValue==999999||acurveinfo.MinValue==999999||acurveinfo.MinValue==99999||acurveinfo.MinValue==99999||acurveinfo.MinValue==-9999)
|
||
{
|
||
if(acurveinfo.MaxValue==acurveinfo.MinValue||acurveinfo.MaxValue==-99999||acurveinfo.MaxValue==-9999||acurveinfo.MinValue==999999||acurveinfo.MinValue==999999||acurveinfo.MinValue==99999||acurveinfo.MinValue==99999||acurveinfo.MinValue==-9999)
|
||
{
|
||
ReCalculateMinMax();
|
||
acurveinfo.MaxValue=m_fPropertMax;
|
||
acurveinfo.MinValue=m_fPropertMin;
|
||
logio->SetCurveInfo(curveindex,&acurveinfo);
|
||
}
|
||
}
|
||
delete logio;
|
||
}
|
||
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
if(IsMappingMem(name.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
delete logio;
|
||
vMD.SetSize(0);
|
||
vMD.m_vProperty=0;
|
||
vProperty.SetSize(0);
|
||
vProperty.m_vProperty=NULL;
|
||
key="";
|
||
return;
|
||
}
|
||
int curveindex=logio->OpenCurve((char *)GetName().toStdString().c_str());
|
||
if(curveindex<0) {
|
||
if(IsMappingMem(name.toStdString().c_str()))
|
||
{
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
delete logio;
|
||
vMD.SetSize(0);
|
||
vMD.m_vProperty=0;
|
||
vProperty.SetSize(0);
|
||
vProperty.m_vProperty=NULL;
|
||
key="";
|
||
return;
|
||
}
|
||
logio->GetCurveInfo(curveindex,&acurveinfo);
|
||
delete logio;
|
||
vMD.clear();
|
||
vProperty.clear();
|
||
vMD.SetSize(3);
|
||
int samplenum=(acurveinfo.EndDepth-acurveinfo.StartDepth)/acurveinfo.DepLevel+1.5;
|
||
if(!m_SharedMemory)
|
||
{
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
int len=3*sizeof(float)+sizeof(int)+acurveinfo.CodeLen*(samplenum+1);
|
||
MappingMem(&m_Handle,(LPSTR*)&m_SharedMemory,len,key.toStdString().c_str());
|
||
}
|
||
else {
|
||
vMD.m_vProperty=(float *)m_SharedMemory;
|
||
if(m_vMD.m_vProperty)
|
||
{
|
||
int samplenum1=(m_vMD.m_vProperty[1]-m_vMD.m_vProperty[0])/m_vMD.m_vProperty[2]+1.5;
|
||
if(samplenum1==samplenum){
|
||
m_vMD.m_vProperty[0]=acurveinfo.StartDepth;
|
||
m_vMD.m_vProperty[1]=acurveinfo.EndDepth;
|
||
m_vMD.m_vProperty[2]=acurveinfo.DepLevel;
|
||
}
|
||
else {
|
||
isLoad=false;
|
||
LoadFromSLF();
|
||
vMD.m_vProperty=(float *)m_SharedMemory;
|
||
m_vProperty.m_vProperty=&m_vMD.m_vProperty[4];
|
||
}
|
||
}
|
||
}
|
||
if(!vMD.m_vProperty) {
|
||
vMD.SetSize(0);
|
||
vProperty.SetSize(0);
|
||
vProperty.m_vProperty=NULL;
|
||
if(IsMappingMem(name.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
key="";
|
||
return;
|
||
}
|
||
int size=((int *)m_SharedMemory)[3];
|
||
vProperty.SetSize(size);
|
||
vProperty.m_vProperty=&vMD.m_vProperty[4];
|
||
if(m_vMD.size()>0){
|
||
m_TopDepth=m_vMD.m_vProperty[0];
|
||
m_BottomDepth=m_vMD.m_vProperty[1];
|
||
m_Rlev=m_vMD.m_vProperty[2];
|
||
}
|
||
}
|
||
|
||
void CObjWellLog::MoveShift()
|
||
{
|
||
MoveShift(m_ShiftTopDepth,m_ShiftBottomDepth,m_DepthOffset);
|
||
}
|
||
void CObjWellLog::EShiftDepth(int count,float *sdeps,float *edeps)
|
||
{
|
||
if(m_SlfFileName=="") return;
|
||
CMemRdWt * logio=new CMemRdWt();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
delete logio;
|
||
//AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!");
|
||
return;
|
||
}
|
||
|
||
int curveindex=logio->FindObjectName((char*)GetName().toStdString().c_str());
|
||
if(curveindex<0)
|
||
{
|
||
delete logio;
|
||
return;
|
||
}
|
||
CString szBuffer1="";
|
||
CString szBuffer="";
|
||
for(int i=0;i<count;i++)
|
||
{
|
||
szBuffer1.Format("%10.3f %10.3f\r\n",sdeps[i],edeps[i]);
|
||
szBuffer+=szBuffer1;
|
||
}
|
||
WriteShiftMessage(*logio,szBuffer,GetName());
|
||
logio->EShiftDepth((char*)GetName().toStdString().c_str(),2,sdeps,edeps);
|
||
delete logio;
|
||
if(isRun) {
|
||
isLoad=false;
|
||
LoadFromSLF();
|
||
}
|
||
}
|
||
void CObjWellLog::MoveShift(float sdep,float edep,float delta)
|
||
{
|
||
if(sdep>=edep&&delta==0) return;
|
||
if(m_SlfFileName=="") return;
|
||
CMemRdWt * logio=new CMemRdWt();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
delete logio;
|
||
//AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!");
|
||
return;
|
||
}
|
||
|
||
int curveindex=logio->FindObjectName((char*)GetName().toStdString().c_str());
|
||
if(curveindex<0)
|
||
{
|
||
delete logio;
|
||
return;
|
||
}
|
||
CString szBuffer="";
|
||
|
||
if(sdep==edep&&sdep==-9999.0) {
|
||
szBuffer=QString::number(delta,'f',3)+"\r\n";
|
||
WriteShiftMessage(*logio,szBuffer,GetName());
|
||
logio->CorrectObjectDepth(curveindex,delta);
|
||
delete logio;
|
||
if(isRun) {
|
||
isLoad=false;
|
||
LoadFromSLF();
|
||
}
|
||
return;
|
||
}
|
||
curveindex=logio->OpenChannel(GetName().toStdString().c_str());
|
||
if(curveindex>-1) {
|
||
szBuffer.Format("%10.3f %10.3f %10.3f\r\n",sdep,edep,delta);
|
||
WriteShiftMessage(*logio,szBuffer,GetName());
|
||
logio->MoveDepth(curveindex,sdep,edep,delta);
|
||
}
|
||
else {
|
||
int ObjectType=logio->GetObjectType(GetName().toStdString().c_str());
|
||
float sdeps[2],edeps[2];
|
||
sdeps[0]=sdep;
|
||
edeps[0]=sdep+delta;
|
||
sdeps[1]=edep;
|
||
edeps[1]=edep+delta;
|
||
szBuffer.Format("%10.3f %10.3f\r\n%10.3f %10.3f\r\n",sdeps[0],edeps[0],sdeps[1],edeps[1]);
|
||
WriteShiftMessage(*logio,szBuffer,GetName());
|
||
if(ObjectType >CARD_OBJECT||ObjectType==0)
|
||
{
|
||
int index=logio->OpenTable(GetName().toStdString().c_str());
|
||
if(index>-1)
|
||
{
|
||
logio->EShiftTableDepth((char*)GetName().toStdString().c_str(),2,sdeps,edeps);
|
||
}
|
||
}
|
||
else if(ObjectType==CARD_OBJECT) {
|
||
logio->EshiftStreamDepth((char *)GetName().toStdString().c_str(),2,sdeps,edeps);
|
||
}
|
||
}
|
||
delete logio;
|
||
if(isRun) {
|
||
isLoad=false;
|
||
LoadFromSLF();
|
||
}
|
||
}
|
||
|
||
void CObjWellLog::GetZoneMDProperty( FLOATPROPERTY &vMD,FLOATPROPERTY &vProperty ,float sdep,float edep)
|
||
{
|
||
if(!m_vMD.size()) {
|
||
GetValidMDProperty(m_vMD,m_vProperty,-99999,99999);
|
||
}
|
||
if(m_vMD.size()<3) return;
|
||
if(edep==99999) edep=m_vMD.m_vProperty[1];
|
||
if(sdep==-99999) sdep=m_vMD.m_vProperty[0];
|
||
int size=(edep-sdep)/m_vMD.m_vProperty[2]+1.5;
|
||
vProperty.SetSize(size);
|
||
int j=(sdep-m_vMD.m_vProperty[0])/m_vMD.m_vProperty[2];
|
||
int i=0;
|
||
if(j<0) {
|
||
i=(m_vMD.m_vProperty[0]-sdep)/m_vMD.m_vProperty[2];
|
||
j=0;
|
||
}
|
||
if(j>=m_vProperty.size()) return;
|
||
if(edep>m_vMD.m_vProperty[1]) edep=m_vMD.m_vProperty[1];
|
||
int jj=(edep-m_vMD.m_vProperty[0])/m_vMD.m_vProperty[2];
|
||
if(jj<=0) return;
|
||
|
||
vMD.SetSize(3);
|
||
vMD.m_vProperty[0]=sdep;
|
||
vMD.m_vProperty[1]=edep;
|
||
vMD.m_vProperty[2]=m_vMD.m_vProperty[2];
|
||
if(acurveinfo.RepCode==REPR_FLOAT) {
|
||
memmove(&vProperty.m_vProperty[i],&m_vProperty.m_vProperty[j],sizeof(float)*(jj-j));
|
||
}
|
||
else {
|
||
for(int k=j;k<jj;k++) {
|
||
vProperty.m_vProperty[k]=GetData(k-j+i);
|
||
}
|
||
}
|
||
}
|
||
|
||
double CObjWellLog::GetData(int repCode,char *buffer,int repLen)
|
||
{
|
||
double yy=-99999;
|
||
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
|
||
if(repLen>=200) repLen=199;
|
||
if(repLen>0) {
|
||
memmove(m_strValue,buffer,repLen);
|
||
m_strValue[repLen]=0;
|
||
}
|
||
else m_strValue[0]=0;
|
||
break;
|
||
}
|
||
return yy;
|
||
}
|
||
void CObjWellLog::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;
|
||
}
|
||
double CObjWellLog::GetData(float dep,char *buffer)
|
||
{
|
||
if(dep>=acurveinfo.StartDepth&&dep<=acurveinfo.EndDepth) {
|
||
int i=(dep-acurveinfo.StartDepth)/acurveinfo.DepLevel+0.5;
|
||
double yy=GetData(i,buffer);
|
||
return yy;
|
||
}
|
||
else {
|
||
if(acurveinfo.RepCode==REPR_STRING&&buffer) buffer[0]=0;
|
||
return -9999;
|
||
}
|
||
}
|
||
|
||
double CObjWellLog::GetData(int i,char *buffer)
|
||
{
|
||
if(!m_vProperty.size()) return -9999;
|
||
if(!m_vProperty.m_vProperty) return -9999;
|
||
double yy=-9999;
|
||
if(m_vProperty.size()>i) {
|
||
yy=GetData(acurveinfo.RepCode,(char *)&((char *)m_vProperty.m_vProperty)[i*acurveinfo.CodeLen],acurveinfo.CodeLen);
|
||
}
|
||
if(acurveinfo.RepCode==REPR_STRING&&buffer) strcpy(buffer,m_strValue);
|
||
return yy;
|
||
}
|
||
void CObjWellLog::SetData(float dep,float *value)
|
||
{
|
||
if(dep>=acurveinfo.StartDepth&&dep<=acurveinfo.EndDepth) {
|
||
int i=(dep-acurveinfo.StartDepth)/acurveinfo.DepLevel+0.5;
|
||
SetData(i,value);
|
||
}
|
||
}
|
||
void CObjWellLog::SetData(float dep,float value)
|
||
{
|
||
if(dep>=acurveinfo.StartDepth&&dep<=acurveinfo.EndDepth) {
|
||
int i=(dep-acurveinfo.StartDepth)/acurveinfo.DepLevel+0.5;
|
||
SetData(i,&value);
|
||
}
|
||
}
|
||
void CObjWellLog::SetData(int i,float *value)
|
||
{
|
||
if(!m_vProperty.m_vProperty) return;
|
||
if(acurveinfo.RepCode!=REPR_STRING) {
|
||
double val=*value;
|
||
SetData(acurveinfo.RepCode,&((char *)m_vProperty.m_vProperty)[i*acurveinfo.CodeLen],val);
|
||
}
|
||
else {
|
||
memmove(&((char *)m_vProperty.m_vProperty)[i*acurveinfo.CodeLen],value,acurveinfo.CodeLen);
|
||
}
|
||
}
|
||
|
||
void CObjWellLog::GetMDProperty(FLOATPROPERTY &vMD,FLOATPROPERTY &vProperty)
|
||
{
|
||
if(!m_vMD.size()) {
|
||
GetValidMDProperty(m_vMD,m_vProperty,-99999,99999);
|
||
}
|
||
if(m_vMD.size()<3) return;
|
||
vMD.SetSize(m_vMD.size());
|
||
vProperty.SetSize(m_vProperty.size());
|
||
if(acurveinfo.RepCode==REPR_FLOAT) {
|
||
memmove(vProperty.m_vProperty,m_vProperty.m_vProperty,sizeof(float)*m_vProperty.size());
|
||
}
|
||
else {
|
||
for(int k=0;k<vProperty.size();k++) {
|
||
vProperty.m_vProperty[k]=GetData(k);
|
||
}
|
||
}
|
||
memmove(vMD.m_vProperty,m_vMD.m_vProperty,sizeof(float)*m_vMD.size());
|
||
return;
|
||
}
|
||
|
||
CObjWell *CObjWellLog::GetWell()
|
||
{
|
||
// if(m_pObjWell) return m_pObjWell;
|
||
// PaiObject *pParent = GetParent();
|
||
// while( pParent )
|
||
// {
|
||
// CObjWell *pWell = dynamic_cast<CObjWell *>( pParent );
|
||
// if( pWell ) {
|
||
// m_pObjWell=pWell;
|
||
// return pWell;
|
||
// }
|
||
// pParent = pParent->GetParent();
|
||
// }
|
||
|
||
return NULL;
|
||
}
|
||
CObjWelllogRound *CObjWellLog::GetWelllogRound()
|
||
{
|
||
// PaiObject *pParent = GetParent();
|
||
// while( pParent )
|
||
// {
|
||
// CObjWelllogRound *pWellRound = dynamic_cast<CObjWelllogRound *>( pParent );
|
||
// if( pWellRound ) return pWellRound;
|
||
|
||
// pParent = pParent->GetParent();
|
||
// }
|
||
|
||
return NULL;
|
||
}
|
||
|
||
double CObjWellLog::GetShiftTopDepth()
|
||
{
|
||
return m_ShiftTopDepth;
|
||
}
|
||
|
||
double CObjWellLog::GetShiftBottomDepth()
|
||
{
|
||
return m_ShiftBottomDepth;
|
||
}
|
||
|
||
double CObjWellLog::GetTopDepth()
|
||
{
|
||
return m_TopDepth;
|
||
}
|
||
|
||
double CObjWellLog::GetBottomDepth()
|
||
{
|
||
return m_BottomDepth;
|
||
}
|
||
|
||
PFLOATPROPERTY &CObjWellLog::GetProperty( )
|
||
{
|
||
if(!m_vProperty.size())
|
||
{
|
||
m_vMD.clear();
|
||
m_vProperty.clear();
|
||
GetValidMDProperty(m_vMD,m_vProperty,-99999.0,99999.0);
|
||
}
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
if(IsMappingMem(key.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
key="";
|
||
}
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
m_TopDepth=0;
|
||
m_BottomDepth=0;
|
||
return m_vProperty;
|
||
}
|
||
QString name=m_SlfFileName+GetName();
|
||
int index=logio->FindObjectName((char *)GetName().toStdString().c_str());
|
||
if(index<0) {
|
||
if(IsMappingMem(name.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
key="";
|
||
}
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
m_TopDepth=0;
|
||
m_BottomDepth=0;
|
||
return m_vProperty;
|
||
}
|
||
delete logio;
|
||
if(!IsMappingMem(name.toStdString().c_str())) {
|
||
isLoad=false;
|
||
LoadFromSLF();
|
||
}
|
||
if(m_vMD.size()>0&&m_TopDepth!=m_vMD.m_vProperty[0]){
|
||
m_TopDepth=m_vMD.m_vProperty[0];
|
||
m_BottomDepth=m_vMD.m_vProperty[1];
|
||
m_Rlev=m_vMD.m_vProperty[2];
|
||
}
|
||
return m_vProperty;
|
||
}
|
||
|
||
PFLOATPROPERTY &CObjWellLog::GetMD( )
|
||
{
|
||
if(!m_vMD.size()) {
|
||
GetValidMDProperty(m_vMD,m_vProperty,-99999.0,99999.0);
|
||
}
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
if(IsMappingMem(key.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
key="";
|
||
}
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
m_TopDepth=0;
|
||
m_BottomDepth=0;
|
||
return m_vProperty;
|
||
}
|
||
QString name=m_SlfFileName+GetName();
|
||
int index=logio->FindObjectName((char *)GetName().toStdString().c_str());
|
||
if(index<0) {
|
||
if(IsMappingMem(name.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
key="";
|
||
}
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
m_TopDepth=0;
|
||
m_BottomDepth=0;
|
||
return m_vProperty;
|
||
}
|
||
logio->GetCurveInfo(index,&acurveinfo);
|
||
delete logio;
|
||
if(!IsMappingMem(name.toStdString().c_str())) {
|
||
isLoad=false;
|
||
LoadFromSLF();
|
||
}
|
||
if(m_vMD.size()>0&&m_TopDepth!=m_vMD.m_vProperty[0]){
|
||
m_TopDepth=m_vMD.m_vProperty[0];
|
||
m_BottomDepth=m_vMD.m_vProperty[1];
|
||
m_Rlev=m_vMD.m_vProperty[2];
|
||
}
|
||
return m_vMD;
|
||
}
|
||
void CObjWellLog::SetProperty(PFLOATPROPERTY *vMD,PFLOATPROPERTY *vProperty )
|
||
{
|
||
if(m_vProperty.m_vProperty!=vProperty->m_vProperty) {
|
||
if(m_vProperty.size()!=vProperty->size())
|
||
{
|
||
m_vProperty.SetSize(vProperty->size());
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
MappingMem(&m_Handle,(LPSTR*)&m_SharedMemory,vMD->size()*sizeof(float)+sizeof(int)+(vProperty->size()+1)*sizeof(float),key.toStdString().c_str());
|
||
}
|
||
m_vProperty.m_vProperty=&((float*)m_SharedMemory)[4];
|
||
memmove(m_vProperty.m_vProperty,vProperty->m_vProperty,sizeof(float)*vProperty->size());
|
||
}
|
||
SetMD(vMD);
|
||
// SetModified(true,false);
|
||
SaveToSLF();
|
||
}
|
||
void CObjWellLog::SetProperty(PFLOATPROPERTY *vMD,FLOATPROPERTY *vProperty )
|
||
{
|
||
if(m_vProperty.m_vProperty!=vProperty->m_vProperty) {
|
||
if(m_vProperty.size()!=vProperty->size())
|
||
{
|
||
m_vProperty.SetSize(vProperty->size());
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
MappingMem(&m_Handle,(LPSTR*)&m_SharedMemory,vMD->size()*sizeof(float)+sizeof(int)+(vProperty->size()+1)*sizeof(float),key.toStdString().c_str());
|
||
}
|
||
m_vProperty.m_vProperty=&((float*)m_SharedMemory)[4];
|
||
memmove(m_vProperty.m_vProperty,vProperty->m_vProperty,sizeof(float)*vProperty->size());
|
||
}
|
||
SetMD(vMD);
|
||
// SetModified(true,false);
|
||
SaveToSLF();
|
||
}
|
||
|
||
void CObjWellLog::SetMD(PFLOATPROPERTY *vMD )
|
||
{
|
||
if(m_vMD.m_vProperty!=vMD->m_vProperty) {
|
||
if(m_vMD.m_vProperty) {
|
||
memmove(m_vMD.m_vProperty,vMD->m_vProperty,sizeof(float)*vMD->size());
|
||
}
|
||
}
|
||
}
|
||
|
||
void CObjWellLog::SetProperty(FLOATPROPERTY *vMD,FLOATPROPERTY *vProperty )
|
||
{
|
||
if(m_vProperty.m_vProperty!=vProperty->m_vProperty) {
|
||
if(m_vProperty.size()!=vProperty->size())
|
||
{
|
||
m_vProperty.SetSize(vProperty->size());
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
MappingMem(&m_Handle,(LPSTR*)&m_SharedMemory,vMD->size()*sizeof(float)+sizeof(int)+(vProperty->size()+1)*sizeof(float),key.toStdString().c_str());
|
||
}
|
||
m_vProperty.m_vProperty=&((float*)m_SharedMemory)[4];
|
||
memmove(m_vProperty.m_vProperty,vProperty->m_vProperty,sizeof(float)*vProperty->size());
|
||
}
|
||
SetMD(vMD);
|
||
// SetModified(true,false);
|
||
SaveToSLF();
|
||
}
|
||
|
||
void CObjWellLog::SetMD(FLOATPROPERTY *vMD )
|
||
{
|
||
if(m_vMD.m_vProperty!=vMD->m_vProperty) {
|
||
if(m_vMD.m_vProperty) {
|
||
memmove(m_vMD.m_vProperty,vMD->m_vProperty,sizeof(float)*vMD->size());
|
||
}
|
||
}
|
||
}
|
||
|
||
pai::ios::welllog::DataObject *CObjWellLog::GetDbObject()
|
||
{
|
||
// if(m_SlfFileName==""){
|
||
// SetBelongID();
|
||
// return &m_logCurve;
|
||
// }
|
||
// else //slf文件存储的情况下,不存到数据库
|
||
return NULL;
|
||
}
|
||
|
||
QVariant CObjWellLog::GetTemplateKey()
|
||
{
|
||
QVariant val;
|
||
return val;
|
||
//TODO
|
||
//增加了一级分类,templatekey需要增加这个
|
||
// QVariant val=CBaseObject::GetTemplateKey();
|
||
// QString sTemplateKey=val.toString();
|
||
// int i=sTemplateKey.lastIndexOf("/");
|
||
// if(i<0) {
|
||
// /* QString left;
|
||
// QString curvename=GetName();
|
||
// if(i>-1) left=sTemplateKey.left(i)+"/"+curvename;
|
||
// else left=sTemplateKey+"/"+curvename;
|
||
// SetTemplateKey(left);
|
||
// val=left;
|
||
// */
|
||
// QString categoryName="";
|
||
// if(!GetParent()) return categoryName;
|
||
// if(GetParent()->GetTypeID()!=GetClassID_Well()&&GetParent()->GetTypeID()!=GetClassID_WellLogRound()) categoryName=this->GetParent()->GetName();
|
||
// if(categoryName!="") categoryName=categoryName.append("/");
|
||
// if(GetGhostName()!="") categoryName=categoryName+GetGhostName();
|
||
// else categoryName=categoryName+GetName();
|
||
// SetTemplateKey(categoryName);
|
||
// val=categoryName;
|
||
// }
|
||
// return val;
|
||
}
|
||
|
||
CBaseObject *CObjWellLog::CloneObject()
|
||
{
|
||
// CBaseObject * result=CBaseObject::CloneObject();
|
||
// CObjWellLog * pCopyedWellLog = dynamic_cast<CObjWellLog*>(result);
|
||
// if(pCopyedWellLog) pCopyedWellLog->SetWell(m_pObjWell);
|
||
// return pCopyedWellLog;
|
||
return NULL;
|
||
}
|
||
|
||
QStringList CObjWellLog::GetColumnHeadList()
|
||
{
|
||
QStringList strlist;
|
||
strlist<<"深度值"<<"属性值";
|
||
return strlist;
|
||
}
|
||
|
||
//从slf加载数据
|
||
bool CObjWellLog::LoadFromSLF()
|
||
{
|
||
if(m_SlfFileName=="") {
|
||
if(!key.isEmpty()&&IsMappingMem(key.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
key="";
|
||
}
|
||
return true;
|
||
}
|
||
isRun=true;
|
||
if(!key.isEmpty()&&IsMappingMem(key.toStdString().c_str()))
|
||
{
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
key="";
|
||
}
|
||
QString name=m_SlfFileName+GetName();
|
||
if(IsMappingMem(name.toStdString().c_str()))
|
||
{
|
||
// GetObjectEvent().OnDeAttchData(m_SlfFileName,GetName());
|
||
}
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
return false;
|
||
}
|
||
|
||
int curveindex=logio->OpenCurve(GetName().toStdString().c_str());
|
||
if(curveindex<0)
|
||
{
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
return false;
|
||
}
|
||
m_ObjectType=CURVE_OBJECT;
|
||
logio->GetCurveInfo(curveindex,&acurveinfo);
|
||
int samplenum=(acurveinfo.EndDepth-acurveinfo.StartDepth)/acurveinfo.DepLevel+1.5;
|
||
if(acurveinfo.DepLevel==0) {
|
||
acurveinfo.DepLevel=0.125;
|
||
logio->DiscardObject(curveindex);
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
return false;
|
||
}
|
||
key=name;
|
||
int len=3*sizeof(float)+sizeof(int)+acurveinfo.CodeLen*(samplenum+1);
|
||
MappingMem(&m_Handle,(LPSTR*)&m_SharedMemory,len,key.toStdString().c_str());
|
||
if(!m_Handle||!m_SharedMemory) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
MappingMem(&m_Handle,(LPSTR*)&m_SharedMemory,3*sizeof(float)+sizeof(int)+acurveinfo.CodeLen*(samplenum+1),key.toStdString().c_str());
|
||
if(!m_Handle||!m_SharedMemory) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
return false;
|
||
}
|
||
}
|
||
float *buffer=(float*)m_SharedMemory;
|
||
buffer[0]=acurveinfo.StartDepth;
|
||
buffer[1]=acurveinfo.EndDepth;
|
||
buffer[2]=acurveinfo.DepLevel;
|
||
((int *)buffer)[3]=samplenum;
|
||
logio->ReadCurve(curveindex,acurveinfo.StartDepth,samplenum,(void*)&buffer[4]);
|
||
logio->Clear();
|
||
delete logio;
|
||
m_vMD.SetSize(3);
|
||
m_vMD.m_vProperty=(float *)m_SharedMemory;
|
||
int size=((int *)m_SharedMemory)[3];
|
||
m_vProperty.SetSize(size);
|
||
m_vProperty.m_vProperty=&m_vMD.m_vProperty[4];
|
||
|
||
if(m_vMD.size()>0){
|
||
m_TopDepth=m_vMD.m_vProperty[0];
|
||
m_BottomDepth=m_vMD.m_vProperty[1];
|
||
m_Rlev=m_vMD.m_vProperty[2];
|
||
}
|
||
m_ShiftTopDepth=-9999;
|
||
m_ShiftBottomDepth=-9999;
|
||
m_DepthOffset=0;
|
||
isLoad=true;
|
||
// SetModified(false,false);
|
||
// GetObjectEvent().OnRefreshData(GetSlfFileName(),GetName(),this);
|
||
return true;
|
||
}
|
||
|
||
//从slf加载数据
|
||
int CObjWellLog::IsObjectExist(QString name)
|
||
{
|
||
if(m_SlfFileName=="") return true;
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
delete logio;
|
||
//AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!");
|
||
return false;
|
||
}
|
||
|
||
int curveindex=logio->FindObjectName((char *)name.toStdString().c_str());
|
||
delete logio;
|
||
return curveindex;
|
||
}
|
||
bool CObjWellLog::DeleteData(float Stdep,float Endep)
|
||
{
|
||
SetModify(true);
|
||
SaveToSLF();
|
||
if(m_SlfFileName=="") return true;
|
||
isRun=true;
|
||
isLoad=false;
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
if(!key.isEmpty()&&IsMappingMem(key.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
return false;
|
||
}
|
||
int curveindex=logio->OpenCurve(GetName().toStdString().c_str());
|
||
if(curveindex<0)
|
||
{
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
if(!key.isEmpty()&&IsMappingMem(key.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
return false;
|
||
}
|
||
m_ObjectType=CURVE_OBJECT;
|
||
logio->GetCurveInfo(curveindex,&acurveinfo);
|
||
acurveinfo.StartDepth=Stdep;
|
||
acurveinfo.EndDepth=Endep;
|
||
int samplenum=(acurveinfo.EndDepth-acurveinfo.StartDepth)/acurveinfo.DepLevel+1.5;
|
||
QString name=m_SlfFileName+GetName();
|
||
if(acurveinfo.DepLevel==0) {
|
||
acurveinfo.DepLevel=0.125;
|
||
logio->DiscardObject(curveindex);
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
if(!key.isEmpty()&&IsMappingMem(key.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
return false;
|
||
}
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
if(IsMappingMem(key.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
MappingMem(&m_Handle,(LPSTR*)&m_SharedMemory,3*sizeof(float)+sizeof(int)+acurveinfo.CodeLen*(samplenum+1),key.toStdString().c_str());
|
||
if(!m_Handle||!m_SharedMemory) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
MappingMem(&m_Handle,(LPSTR*)&m_SharedMemory,3*sizeof(float)+sizeof(int)+acurveinfo.CodeLen*(samplenum+1),key.toStdString().c_str());
|
||
if(!m_Handle||!m_SharedMemory) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
return false;
|
||
}
|
||
}
|
||
float *buffer=(float*)m_SharedMemory;
|
||
buffer[0]=acurveinfo.StartDepth;
|
||
buffer[1]=acurveinfo.EndDepth;
|
||
buffer[2]=acurveinfo.DepLevel;
|
||
((int *)buffer)[3]=samplenum;
|
||
logio->ReadCurve(curveindex,acurveinfo.StartDepth,samplenum,(void*)&buffer[4]);
|
||
logio->CloseCurve(curveindex);
|
||
logio->DiscardObject(curveindex);
|
||
curveindex=logio->CreateCurve(&acurveinfo);
|
||
if(curveindex>-1) logio->WriteCurve(curveindex,acurveinfo.StartDepth,samplenum,(void*)&buffer[4]);
|
||
logio->Clear();
|
||
delete logio;
|
||
m_vMD.SetSize(3);
|
||
m_vMD.m_vProperty=(float *)m_SharedMemory;
|
||
int size=((int *)m_SharedMemory)[3];
|
||
m_vProperty.SetSize(size);
|
||
m_vProperty.m_vProperty=&m_vMD.m_vProperty[4];
|
||
|
||
if(m_vMD.size()>0){
|
||
m_TopDepth=m_vMD.m_vProperty[0];
|
||
m_BottomDepth=m_vMD.m_vProperty[1];
|
||
m_Rlev=m_vMD.m_vProperty[2];
|
||
}
|
||
isLoad=true;
|
||
// SetModified(false,false);
|
||
return true;
|
||
}
|
||
|
||
bool CObjWellLog::ExpendData(bool ishead,float Depth)
|
||
{
|
||
// SetModify(true);
|
||
// SaveToSLF();
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
if(m_SlfFileName=="") {
|
||
if(!key.isEmpty()&&IsMappingMem(key.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
return true;
|
||
}
|
||
isLoad=false;
|
||
isRun=true;
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
if(!key.isEmpty()&&IsMappingMem(key.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
int curveindex=logio->OpenCurve(GetName().toStdString().c_str());
|
||
if(curveindex<0)
|
||
{
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
if(!key.isEmpty()&&IsMappingMem(key.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
return false;
|
||
}
|
||
m_ObjectType=CURVE_OBJECT;
|
||
logio->GetCurveInfo(curveindex,&acurveinfo);
|
||
if(ishead) acurveinfo.StartDepth=Depth;
|
||
else acurveinfo.EndDepth=Depth;
|
||
if(acurveinfo.EndDepth<acurveinfo.StartDepth) {
|
||
AfxMessageBox("起始深度〉结束深度,错误!");
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
if(!key.isEmpty()&&IsMappingMem(key.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
return false;
|
||
}
|
||
if(acurveinfo.DepLevel==0) {
|
||
acurveinfo.DepLevel=0.125;
|
||
logio->DiscardObject(curveindex);
|
||
delete logio;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
if(!key.isEmpty()&&IsMappingMem(key.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
return false;
|
||
}
|
||
int samplenum=(acurveinfo.EndDepth-acurveinfo.StartDepth)/acurveinfo.DepLevel+1.5;
|
||
QString name=m_SlfFileName+GetName();
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
if(IsMappingMem(key.toStdString().c_str())) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
}
|
||
// GetObjectEvent().OnDeAttchData(GetSlfFileName(),GetName());
|
||
while(IsMappingMem(key.toStdString().c_str())) {
|
||
QCoreApplication::processEvents();
|
||
}
|
||
key=name;
|
||
MappingMem(&m_Handle,(LPSTR*)&m_SharedMemory,3*sizeof(float)+sizeof(int)+acurveinfo.CodeLen*samplenum,key.toStdString().c_str());
|
||
if(!m_Handle||!m_SharedMemory) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
MappingMem(&m_Handle,(LPSTR*)&m_SharedMemory,3*sizeof(float)+sizeof(int)+acurveinfo.CodeLen*(samplenum+1),key.toStdString().c_str());
|
||
if(!m_Handle||!m_SharedMemory) {
|
||
CloseView(m_Handle,m_SharedMemory);
|
||
m_SharedMemory=NULL;
|
||
m_Handle=NULL;
|
||
m_vMD.SetSize(0);
|
||
m_vMD.m_vProperty=0;
|
||
m_vProperty.SetSize(0);
|
||
m_vProperty.m_vProperty=NULL;
|
||
return false;
|
||
}
|
||
}
|
||
float *buffer=(float*)m_SharedMemory;
|
||
buffer[0]=acurveinfo.StartDepth;
|
||
buffer[1]=acurveinfo.EndDepth;
|
||
buffer[2]=acurveinfo.DepLevel;
|
||
((int *)buffer)[3]=samplenum;
|
||
logio->ReadCurve(curveindex,acurveinfo.StartDepth,samplenum,(void*)&buffer[4]);
|
||
logio->Clear();
|
||
delete logio;
|
||
m_vMD.SetSize(3);
|
||
m_vMD.m_vProperty=(float *)m_SharedMemory;
|
||
int size=((int *)m_SharedMemory)[3];
|
||
m_vProperty.SetSize(size);
|
||
m_vProperty.m_vProperty=&m_vMD.m_vProperty[4];
|
||
|
||
if(m_vMD.size()>0){
|
||
m_TopDepth=m_vMD.m_vProperty[0];
|
||
m_BottomDepth=m_vMD.m_vProperty[1];
|
||
m_Rlev=m_vMD.m_vProperty[2];
|
||
}
|
||
// SetModified(false,false);
|
||
isLoad=true;
|
||
return true;
|
||
}
|
||
//数据变化后写入slf数据
|
||
bool CObjWellLog::SaveToSLF()
|
||
{
|
||
bool m=false;//HasModified();
|
||
if(!m) return false;
|
||
int samplenum=m_vProperty.size();
|
||
if(!m_vMD.size()) return false;
|
||
if(samplenum<=0) return false;
|
||
if(m_SlfFileName=="") return true;
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeRead))
|
||
{
|
||
delete logio;
|
||
//AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!");
|
||
return false;
|
||
}
|
||
|
||
int curveindex=logio->OpenCurve(GetName().toStdString().c_str());
|
||
if(curveindex<0)
|
||
{
|
||
delete logio;
|
||
return false;
|
||
}
|
||
if(samplenum)logio->WriteCurve(curveindex,m_vMD.m_vProperty[0],samplenum,(void*)(&m_vProperty.m_vProperty[0]));
|
||
delete logio;
|
||
//qDebug()<<QString::fromStdString(GenTimeStamp())<<"数据写完成:"+GetName();
|
||
// SetModified(false,false);
|
||
return true;
|
||
}
|
||
|
||
bool CObjWellLog::DeleteFromSLF()
|
||
{
|
||
if(m_SlfFileName=="") return true;
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeReadWrite))
|
||
{
|
||
delete logio;
|
||
//AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!");
|
||
return false;
|
||
};
|
||
short curvetype=logio->GetObjectType(GetName().toStdString().c_str());
|
||
if(curvetype==CURVE_OBJECT||curvetype==WAVE_OBJECT)
|
||
{
|
||
Slf_CURVE info;
|
||
int index=-1;
|
||
if(curvetype==CURVE_OBJECT) index=logio->OpenCurve(GetName().toStdString().c_str());
|
||
else index=logio->OpenWave(GetName().toStdString().c_str());
|
||
logio->GetCurveInfo(index,&info);
|
||
unsigned char cs[4]={0xcd,0xcd,0xcd,0xcd};
|
||
unsigned char cs1[4]={0x0,204,204,204};
|
||
unsigned char cs2[4]={204,204,204,204};
|
||
float va=*(float*)&cs;
|
||
float va1=*(float*)&cs1;
|
||
float va2=*(float*)&cs2;
|
||
if(info.DepLevel==0||info.DepLevel==va||info.DepLevel==va1||info.DepLevel==va2||
|
||
info.StartDepth==va||info.EndDepth==va1||info.EndDepth==va2)
|
||
{
|
||
logio->DeleteObject(GetName().toStdString().c_str());
|
||
delete logio;
|
||
return true;
|
||
}
|
||
}
|
||
logio->DiscardObject(GetName().toStdString().c_str());
|
||
delete logio;
|
||
//TODO 删掉克隆的对象
|
||
}
|
||
|
||
//将内存数据清空
|
||
void CObjWellLog::clearData()
|
||
{
|
||
FLOATPROPERTY nulldata;
|
||
SetMD(&nulldata);
|
||
SetProperty(&nulldata,&nulldata);
|
||
}
|
||
void CObjWellLog::ChangeDepth(double DepthOffset)
|
||
{
|
||
//1.修改内存数据
|
||
if(m_vMD.size()) {
|
||
m_vMD.m_vProperty[0]+=DepthOffset;
|
||
m_vMD.m_vProperty[1]+=DepthOffset;
|
||
}
|
||
m_TopDepth+=DepthOffset;
|
||
m_BottomDepth+=DepthOffset;
|
||
}
|
||
void CObjWellLog::ApplyShiftDepth()
|
||
{
|
||
//1.修改内存数据
|
||
ChangeDepth(m_DepthOffset);
|
||
if(m_SlfFileName=="") return ;
|
||
CMemRdWt * logio=new CMemRdWt();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeReadWrite))
|
||
{
|
||
delete logio;
|
||
//AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!");
|
||
return ;
|
||
};
|
||
bool isok=0;
|
||
//TODO 目前对于表格类,参数卡类不支持,会崩溃
|
||
int curveindex=logio->FindObjectName((char *)GetName().toStdString().c_str());
|
||
if(curveindex>=0) {
|
||
CString szBuffer="";
|
||
szBuffer=QString::number(m_DepthOffset,'f',3)+"\r\n";
|
||
WriteShiftMessage(*logio,szBuffer,GetName());
|
||
logio->CorrectObjectDepth(curveindex,m_DepthOffset);
|
||
isok=1;
|
||
}
|
||
logio->GetCurveInfo(curveindex,&acurveinfo);
|
||
delete logio;
|
||
m_DepthOffset = 0;
|
||
if(isRun&&isok) {
|
||
isLoad=false;
|
||
LoadFromSLF();
|
||
}
|
||
}
|
||
void CObjWellLog::loadInfo()
|
||
{
|
||
if(m_SlfFileName=="") return ;
|
||
CMemRdWt * logio=new CMemRdWt();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeReadWrite))
|
||
{
|
||
delete logio;
|
||
//AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!");
|
||
return ;
|
||
};
|
||
int curveindex=logio->FindObjectName((char *)GetName().toStdString().c_str());
|
||
if(curveindex>=0) {
|
||
logio->GetCurveInfo(curveindex,&acurveinfo);
|
||
}
|
||
delete logio;
|
||
}
|
||
void CObjWellLog::AddShiftDepth(double shiftdepth)
|
||
{
|
||
m_DepthOffset += shiftdepth;
|
||
}
|
||
bool CObjWellLog::CloneInSlfFile(QString newname)
|
||
{
|
||
if(m_SlfFileName=="") return false;
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeReadWrite))
|
||
{
|
||
delete logio;
|
||
//AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!");
|
||
return false;
|
||
};
|
||
char* curvename=new char[65];
|
||
curvename[64]='\0';
|
||
strcpy(curvename,GetName().toStdString().c_str());
|
||
char* newcurvename=new char[65];
|
||
newcurvename[64]='\0';
|
||
strcpy(newcurvename,newname.toStdString().c_str());
|
||
logio->CopyObject(curvename,newcurvename,true);
|
||
delete[] curvename;
|
||
delete[] newcurvename;
|
||
delete logio;
|
||
}
|
||
bool CObjWellLog::CopyToSLFFile(QString targetSLFFileName,bool deleteFromSrc,char*newCurveName)
|
||
{
|
||
if(m_SlfFileName=="") return false;
|
||
CLogIO a_cslfio;
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(targetSLFFileName.toStdString().c_str(),CSlfIO::modeReadWrite))
|
||
{
|
||
delete logio;
|
||
//AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!");
|
||
return false;
|
||
};
|
||
if(!a_cslfio.Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeReadWrite))
|
||
{
|
||
//AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!");
|
||
delete logio;
|
||
return false;
|
||
};
|
||
char* curvename=new char[65];
|
||
curvename[64]='\0';
|
||
strcpy(curvename,GetName().toStdString().c_str());
|
||
if(newCurveName) logio->CopyFromFile(a_cslfio,curvename,newCurveName);
|
||
else logio->CopyFromFile(a_cslfio,curvename);
|
||
delete[] curvename;
|
||
delete logio;
|
||
if(deleteFromSrc) DeleteFromSLF();
|
||
}
|
||
|
||
void CObjWellLog::SetName(const QString & name)
|
||
{
|
||
QString oldn=GetName();
|
||
if(oldn.compare(name,Qt::CaseInsensitive)==0) return;
|
||
m_name = name;
|
||
// PaiObject::SetName(name);
|
||
if(isRun) {
|
||
isLoad=false;
|
||
LoadFromSLF();
|
||
}
|
||
}
|
||
bool CObjWellLog::RenName(const QString & name)
|
||
{
|
||
if(isUsing)
|
||
return false;
|
||
|
||
//将SLF中的对象重命名
|
||
if(m_SlfFileName!="")
|
||
{
|
||
CSlfIO a_cslfio;
|
||
if(!a_cslfio.Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeReadWrite))
|
||
{
|
||
m_name = name;
|
||
// PaiObject::SetName(name);
|
||
if(isRun) {
|
||
isLoad=false;
|
||
LoadFromSLF();
|
||
}
|
||
return true;
|
||
};
|
||
if(a_cslfio.RenameObject(GetName().toStdString().c_str(),name.toStdString().c_str()))
|
||
{
|
||
a_cslfio.Close();
|
||
m_name = name;
|
||
// PaiObject::SetName(name);
|
||
if(isRun){
|
||
isLoad=false;
|
||
LoadFromSLF();
|
||
}
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
void CObjWellLog::ReSample(double newDelta)
|
||
{
|
||
if(m_SlfFileName=="") return ;
|
||
CLogIO * logio=new CLogIO();
|
||
if(!logio->Open(m_SlfFileName.toStdString().c_str(),CSlfIO::modeReadWrite))
|
||
{
|
||
delete logio;
|
||
//AppendConsole(pai::log::PAI_ERROR,"SLF文件打开失败,请检查!");
|
||
return ;
|
||
};
|
||
bool isok=0;
|
||
int curveindex=logio->OpenChannel(GetName().toStdString().c_str());
|
||
if(curveindex>=0) {
|
||
logio->ChannelResamples(curveindex,newDelta);
|
||
isok=1;
|
||
}
|
||
delete logio;
|
||
m_Rlev=newDelta;
|
||
if(isRun&&isok) {
|
||
isLoad=false;
|
||
LoadFromSLF();
|
||
}
|
||
}
|
||
//TODO 重构void ImportDataDialog::AutoMatchFamily(WelllogCurve* acurve)
|
||
void CObjWellLog::AutoMatchFamily()
|
||
{
|
||
return;
|
||
// static std::vector<FamilyAliases> familyaliases;
|
||
// if(familyaliases.size()<=0){
|
||
// FamilyAliases aAlias;
|
||
// aAlias.GetFamilyAliases(familyaliases);
|
||
// }
|
||
// for(int i=0;i<familyaliases.size();i++)
|
||
// {
|
||
// //第一步拿名字匹配
|
||
// if(familyaliases[i].GetAlias()==GetName().toStdString())
|
||
// {
|
||
// InitCurveNameAndUnitByFamily(familyaliases[i].GetFamilyType());
|
||
// return ;
|
||
// }
|
||
// //如果不行,通过别名列表来正则表达式匹配
|
||
// else
|
||
// {
|
||
// QString aliasrule=QString::fromStdString(familyaliases[i].GetChoiceList());
|
||
// QStringList aliasrules=aliasrule.split(",");
|
||
// for(int j=0;j<aliasrules.size();j++)
|
||
// {
|
||
// if(aliasrules[j]=="") continue;
|
||
// QRegExp rx(aliasrules[j]);
|
||
// rx.setPatternSyntax(QRegExp::Wildcard);
|
||
// if(rx.exactMatch(GetName()) )
|
||
// {
|
||
// InitCurveNameAndUnitByFamily(familyaliases[i].GetFamilyType());
|
||
// return ;
|
||
// }
|
||
// }
|
||
// }
|
||
// }
|
||
}
|
||
|
||
void CObjWellLog::InitCurveNameAndUnitByFamily(std::string familyType)
|
||
{
|
||
return;
|
||
// if(familyType!=""){
|
||
// m_logCurve.SetFamilyType(familyType);
|
||
// Family aFamily;
|
||
// aFamily.GetFamilyByFamilyType(familyType);
|
||
// m_logCurve.SetUnit(aFamily.GetUnit());
|
||
// }
|
||
}
|
||
template <typename T>
|
||
void AddToWellRound(QString objname,T *aclass,char* ID,int Type)
|
||
{
|
||
// CObjWelllogRound *pWelllogRound=dynamic_cast<CObjWelllogRound*>(aclass->GetWelllogRound());
|
||
// if(pWelllogRound) {
|
||
// PaiObject*pBase=pWelllogRound->GetObjectByName(objname,ID);
|
||
// if(!dynamic_cast<T *>(pBase)){
|
||
// CObjWellLog * acurve=new T();
|
||
// if(acurve) {
|
||
// acurve->m_ObjectType=Type;
|
||
// acurve->SetName(objname);
|
||
// acurve->SetAliasName(objname);
|
||
// acurve->SetSlfFileName(pWelllogRound->GetSlfFileName());
|
||
// acurve->SetWell(pWelllogRound->GetWell());
|
||
// pWelllogRound->AddChild(acurve);
|
||
// }
|
||
// }
|
||
// }
|
||
}
|
||
// BEGIN_REGISTER_OBJECT(CObjWellLog)
|
||
// QUuid(GetClassID_WellLog())
|
||
// END_REGISTER_OBJECT( CObjWellLog );
|
||
|
||
END_OSGDATAMODEL_NAMESPACE
|