You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kev/Drawer/Module/GeoSigmaDraw/WellAndSection/WellObjectAttributesXml.cpp

1130 lines
29 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "stdafx.h"
//#include "nlohmann\json.hpp"
#include "WellObjectAttributesXml.h"
#include "DrawOperator/Encoding.h"
#include "DrawOperator/KXmlParse.h"
#include "MultiWellSectionLib/SectionWellObj.h"
#include "MultiWellSectionLib/BendObj.h"
#include "MultiWellSectionLib/FaultObj.h"
#include "MultiWellSectionLib/WellSection.h"
#include "WellPoleDoc.h"
#include "WellPoleView.h"
#include "./WellSection/MultiWellSectionDoc.h"
#include "./WellSection/MultiWellSectionlView.h"
#include "./WellPoleLib/WellMarkNamesList.h"
CString GetGdfFontStr( GDFLOGFONTEXT &gdffont)
{
CPublicFunction& pf = *AfxGetPublicFunction();
CString strW, strH, strSpace, strClr, str;
pf.FloatToString(strW, gdffont.m_dWidth);
pf.FloatToString(strH, gdffont.m_dHeight);
pf.FloatToString(strSpace, gdffont.m_dTextSpace);
strClr = pf.ColorRefToHex(gdffont.m_color);
str.Format("W=\"%s\" H=\"%s\" B=\"%d\" I=\"%d\" U=\"%d\" S=\"%d\" PF=\"%s\" FN=\"%s\" C=\"%s\" SP=\"%d\"",
strW, strH, gdffont.m_logFont.lfWeight, gdffont.m_logFont.lfItalic, gdffont.m_logFont.lfUnderline
, gdffont.m_logFont.lfStrikeOut, strSpace, gdffont.m_logFont.lfFaceName, strClr, gdffont.m_nScript);
return str;
}
CString GetGdfPenStr(GDFLOGPENEXT& pen)
{
CPublicFunction& pf = *AfxGetPublicFunction();
CString str,strClr,strbSolid;
if (pen.m_bSolid)
strbSolid = "TRUE";
else
strbSolid = "FALSE";
strClr = pf.ColorRefToHex(pen.m_color);
str.Format("Width=\"%lf\" Solid=\"%s\" Color=\"%s\" Style=\"%s\"",
TransformPixelToPound(pen.m_dWidth),strbSolid, strClr, pen.m_style);
return str;
}
//"±êÌâ×ÖÌå": "W=\"20\" H=\"20\" U=\"0\" I=\"0\" B=\"0\" S=\"0\" PF=\"\" FN=\"ËÎÌå\" C=\"#FF0000\" SP=\"0\"",
void SetStrValueToGdfFont(CString strValue , GDFLOGFONTEXT &gdffont)
{
CPublicFunction& pf = *AfxGetPublicFunction();
CString str, strKey, val;
CStringArray strArr;
MakeStrToArr1(strValue, strArr, " ");
for (int ii = 0; ii < strArr.GetSize(); ii++)
{
str = strArr[ii];
int pos = str.Find("=");
if (pos <1)
{
continue;
}
strKey = str.Left(pos + 1);
val = str.Right(str.GetLength() - (pos + 1));
if (strKey == "W")
{
gdffont.m_dWidth = atoi(val);
gdffont.m_logFont.lfWidth = long(gdffont.m_dWidth + 0.5);
}
else if (strKey == "H")
{
gdffont.m_dHeight = atoi(val);
gdffont.m_logFont.lfHeight = long(gdffont.m_dHeight + 0.5);
}
else if (strKey == "U")
gdffont.m_logFont.lfUnderline = atoi(val);
else if (strKey == "I")
gdffont.m_logFont.lfItalic = atoi(val);
else if (strKey == "B")
gdffont.m_logFont.lfWeight = atoi(val);
else if (strKey == "S")
gdffont.m_logFont.lfStrikeOut = atoi(val);
else if (strKey == "PF")
{
}
else if (strKey == "FN")
strcpy(gdffont.m_logFont.lfFaceName, val.GetBuffer());
else if (strKey == "C")
{
gdffont.m_color = pf.HexToColorRef(val);
}
else if (strKey == "SP")
{
gdffont.m_nScript = atoi(val);
}
}
}
//"Color=\"#FF00FF\" Solid=\"FALSE\" Width=\"0.00\" Style=\"Single4\"",
void SetStrValueToGdfPen(CString strValue, GDFLOGPENEXT& gdfpen)
{
CPublicFunction& pf = *AfxGetPublicFunction();
CString str, strKey, val;
CStringArray strArr;
MakeStrToArr1(strValue, strArr, " ");
for (int ii = 0; ii < strArr.GetSize(); ii++)
{
str = strArr[ii];
int pos = str.Find("=");
if (pos < 1)
{
continue;
}
strKey = str.Left(pos + 1);
val = str.Right(str.GetLength() - (pos + 1));
if (strKey == "Width")
gdfpen.m_dWidth = atof(val);//°õתÏñËØ
else if (strKey == "Style")
gdfpen.m_style = val;
else if (strKey == "Color")
{
gdfpen.m_color = pf.HexToColorRef(val);
}
else if (strKey == "Solid")
{
val.MakeUpper();
if (val == "TRUE")
{
gdfpen.m_bSolid = TRUE;
if (gdfpen.m_pHowToViewCurve)
delete gdfpen.m_pHowToViewCurve;
gdfpen.m_pHowToViewCurve = NULL;
}
else
{
gdfpen.m_bSolid = FALSE;
if (AfxGetGlobalWellXy())
{
//ÇúÏßÐÞÊÎ
CString cmd;
cmd.Format("%s\\%s", LIB_CURVE_TYPE, gdfpen.m_style);//ÇúÏßÏßÐÍ
CLayer* pLayer = AfxGetGlobalWellXy()->FindLayer(cmd);
if (pLayer)
{
if (pLayer->HowToViewCurve)
{
gdfpen.m_pHowToViewCurve = new CHowToViewCurve();
*gdfpen.m_pHowToViewCurve = *(pLayer->HowToViewCurve);
gdfpen.m_pHowToViewCurve->SetColor(gdfpen.m_color);
}
}
}
}
}
}
}
CWellObjectAttributesXml::CWellObjectAttributesXml()
{
}
BOOL CWellObjectAttributesXml::GetWellObjectAttributes(ULONGLONG objHandle, int type, int ttype, CString& strXml)
{
BOOL b = FALSE;
try
{
CWellBaseObj* pWellBase = (CWellBaseObj*)objHandle;
if (type == KEP_WELL)
{
CWellPole* pWell = dynamic_cast<CWellPole*>(pWellBase);
b = CWellObjectAttributesXml::GetWellAttributes(pWell, strXml);
}
else if (type == KEP_TRACK)
{
if (ttype == Track_Group)
{
CTrackGroup* pTrackGroup = dynamic_cast<CTrackGroup*>(pWellBase);
if (pTrackGroup == NULL) return b;
b = CWellObjectAttributesXml::GetGroupTrackAttributes(pTrackGroup, strXml);
}
else
{
CTrackObj* pTrack = dynamic_cast<CTrackObj*>(pWellBase);
if (pTrack == NULL) return b;
b = CWellObjectAttributesXml::GetTrackAttributes(pTrack, strXml);
}
}
else if (type == KEP_TRACKINDATA)
{
b = CWellObjectAttributesXml::GetInTrackDataAttributes(pWellBase,ttype, strXml);
}
else if (type == KEP_SECTIONBEND)
{
CBendObj* pBend = dynamic_cast<CBendObj*>(pWellBase);
b = CWellObjectAttributesXml::GetSectionBendAttributes(pBend, strXml);
}
else if (type == KEP_SECTIONFAULT)
{
CFaultObj *pFault = dynamic_cast<CFaultObj*>(pWellBase);
b = CWellObjectAttributesXml::GetSectionFaultAttributes(pFault, strXml);
}
else if (type == KEP_WELLSECTION)
{
CWellSection *pSection = dynamic_cast<CWellSection*>(pWellBase);
b = CWellObjectAttributesXml::GetWellSectionAttributes(pSection, strXml);
}
if (b)
{
}
}
catch (std::exception e)
{
return FALSE;
}
return b;
}
void CWellObjectAttributesXml::SaveUndoRedoAction(CSigmaView* pView)
{
CWellPoleView *pWellView = dynamic_cast<CWellPoleView*>(pView);
CMultiWellSectionView *pSectionView = dynamic_cast<CMultiWellSectionView*>(pView);
if (pWellView)
{
pWellView->SaveUndoRedoAction();
}
else if (pSectionView)
{
pSectionView->SaveUndoRedoAction();
}
}
BOOL CWellObjectAttributesXml::SetWellObjectAttributes(CSigmaView* pView, ULONGLONG objHandle, int type, int ttype, CString& strXml)
{
BOOL b = FALSE;
try
{
CWellBaseObj* pWellBase = (CWellBaseObj*)objHandle;
if (type == KEP_WELL)
{
CWellPole* pWell = dynamic_cast<CWellPole*>(pWellBase);
b = CWellObjectAttributesXml::SetWellAttributes(pView,pWell, strXml);
}
else if (type == KEP_TRACK)
{
if (ttype == Track_Group)
{
CTrackGroup* pTrackGroup = dynamic_cast<CTrackGroup*>(pWellBase);
if (pTrackGroup == NULL) return b;
b = CWellObjectAttributesXml::SetGroupTrackAttributes(pView,pTrackGroup, strXml);
}
else
{
CTrackObj* pTrack = dynamic_cast<CTrackObj*>(pWellBase);
if (pTrack == NULL) return b;
b = CWellObjectAttributesXml::SetTrackAttributes(pView,pTrack, strXml);
}
}
else if (type == KEP_TRACKINDATA)
{
b = CWellObjectAttributesXml::SetInTrackDataAttributes(pView,pWellBase,ttype, strXml);
}
else if (type == KEP_SECTIONBEND)
{
CBendObj* pBend = dynamic_cast<CBendObj*>(pWellBase);
b = CWellObjectAttributesXml::SetSectionBendAttributes(pView,pBend, strXml);
}
else if (type == KEP_SECTIONFAULT)
{
CFaultObj *pFault = dynamic_cast<CFaultObj*>(pWellBase);
b = CWellObjectAttributesXml::SetSectionFaultAttributes(pView,pFault, strXml);
}
else if (type == KEP_WELLSECTION)
{
CWellSection *pSection = dynamic_cast<CWellSection*>(pWellBase);
b = CWellObjectAttributesXml::SetWellSectionAttributes(pView,pSection, strXml);
}
}
catch (std::exception e)
{
return FALSE;
}
return b;
}
BOOL CWellObjectAttributesXml::GetWellAttributes(CWellPole* pWell, CString& strXml)
{
CPublicFunction& pf = *AfxGetPublicFunction();
BOOL b = FALSE;
if (pWell)
{
if (pWell->IsSectionWell())
{
CSectionWellObj* pSectionWell = (CSectionWellObj*)pWell;
int ver = 2;
CMemFile file;
pf.WritePCG_Head(file, ver);
int nBaseTabNum = 1;
pSectionWell->WritePCG_WellTraces(file, 1,FALSE);
//pf.WritePCG_Head(file, ver);
//int nBaseTabNum = 1;
//pWell->WritePCG_Head(file, nBaseTabNum); //pcgÎļþÖÐ Í·²¿·Ö
//pWell->WritePCG_PrintTemplate(file, nBaseTabNum); //pcgÎļþÖÐ ´òÓ¡Ä£°å
////WritePCG_Symbols(fw,ver,nBaseTabNum); //pcgÎļþÖÐ ·ûºÅ²¿·Ö
//pWell->WritePCG_Styles(file, nBaseTabNum); //pcgÎļþÖÐ Ñùʽ²¿·Ö
pf.WritePCG_Tail(file, ver);
ULONG fl = file.GetLength();
file.SeekToBegin();
LPTSTR pbuf = strXml.GetBuffer(fl + 1);
file.Read(pbuf, fl);
strXml.ReleaseBuffer(fl);
file.Close();
}
else
{
int ver = 2;
CMemFile file;
pf.WritePCG_Head(file, ver);
int nBaseTabNum = 1;
pWell->WritePCG_Head(file, nBaseTabNum); //pcgÎļþÖÐ Í·²¿·Ö
pWell->WritePCG_PrintTemplate(file, nBaseTabNum); //pcgÎļþÖÐ ´òÓ¡Ä£°å
//WritePCG_Symbols(fw,ver,nBaseTabNum); //pcgÎļþÖÐ ·ûºÅ²¿·Ö
pWell->WritePCG_Styles(file, nBaseTabNum); //pcgÎļþÖÐ Ñùʽ²¿·Ö
pf.WritePCG_Tail(file, ver);
ULONG fl = file.GetLength();
file.SeekToBegin();
LPTSTR pbuf = strXml.GetBuffer(fl + 1);
file.Read(pbuf, fl);
strXml.ReleaseBuffer(fl);
file.Close();
}
b = TRUE;
}
return b;
}
BOOL CWellObjectAttributesXml::SetWellAttributes(CSigmaView* pView, CWellPole* pWell, CString& strXml)
{
BOOL b = FALSE;
if (pWell)
{
CWellPoleView* pWellView = dynamic_cast<CWellPoleView*>(pView);
CMultiWellSectionView* pSectionView = dynamic_cast<CMultiWellSectionView*>(pView);
CKXmlParse xp;
if (xp.SetXmlFileBuffer(strXml.GetBuffer(), strXml.GetLength()))
{
if (pWellView)
{
CWellObjectAttributesXml::SaveUndoRedoAction(pView);
double oldSdep = pWell->m_dSdep;
double oldEdep = pWell->m_dEdep;
double oldRatio = pWell->m_fProportion;
int wellType = pWell->GetWellType();
pWell->ReadPCG(xp, 2);
pWell->SetSpace(pWell->m_fMajorSpace, pWell->m_fMinorSpace);
//pWell->SetFontTrack(pWell->m_fontTrack);
pWell->SetFontHeadMark(pWell->m_fontHeadMark); //µÀ¿Ì¶È×ÖÌå
pWell->SetPenTrack(pWell->m_penTrack); //µÀ±ß¿òÏß
pWell->SetPenGrid(pWell->m_penGridMajor, pWell->m_penGridMinor);//Ö÷´Î¿Ì¶ÈÏß
if (pWell->m_dEdep < pWell->m_dSdep)
{//¶¥Éî´óÓÚµ×Éî´íÎ󣬾ͻָ´¾ÉÓеÄÉî¶È
pWell->m_dSdep = oldSdep;
pWell->m_dEdep = oldEdep;
}
if (fabs(oldSdep - pWell->m_dSdep) > 0.000001 || fabs(oldEdep - pWell->m_dEdep) > 0.000001)
{//ÉèÖþ®Éî¶È¶Î²ÎÊý£¬¼°¶ÁÈ¡ÇúÏßÊý¾Ý
pWell->SetIntervalTop(0, pWell->m_dSdep);
pWell->SetIntervalBottom(pWell->GetIntervalVec()->size() - 1, pWell->m_dEdep);
pWell->ReadCurveData();
}
if (pWell->GetWellType() != wellType)
{
if (pWell->GetWellType() == Well_Straight)
{
if(!pWell->IsVerticalPole())
pWell->CalculateSize(pWell->GetAnchorPoint());
else
{
pWell->ComputeTrajectory();
pWell->CalculateSize(pWell->GetAnchorPoint());
}
}
else if(pWell->GetWellType() == Well_Incline)
{
pWell->ComputeTrajectory();
if (fabs(pWell->GetProjectionAngle()) < 0.00001)
{
double angle = pWell->ComputeProjectAngle(); // GetWellProjecttionAngle(pWell);
pWell->SetProjectionAngle(angle); //ÉèÖÃͶӰ½Ç¶È
pWell->SetLevelProportion(pWell->m_fProportion);
pWell->CalculateSize(pWell->GetAnchorPoint());
}
}
}
else
{
if (pWell->GetWellType() == Well_Incline)
{
if (fabs(oldSdep - pWell->m_dSdep) > 0.000001 || fabs(oldEdep - pWell->m_dEdep) > 0.000001
|| fabs(oldRatio - pWell->m_fProportion) > 0.000001)
{
pWell->ComputeTrajectory();
double angle = pWell->ComputeProjectAngle(); //GetWellProjecttionAngle(pWell);
pWell->SetProjectionAngle(pWell->GetProjectionAngle()); //ÉèÖÃͶӰ½Ç¶È
pWell->SetLevelProportion(pWell->m_fProportion);
pWell->CalculateSize(pWell->GetAnchorPoint());
}
}
}
if (fabs(oldSdep - pWell->m_dSdep) > 0.000001 || fabs(oldEdep - pWell->m_dEdep) > 0.000001
|| fabs(oldRatio - pWell->m_fProportion) > 0.000001)
{
double dDelDepth = pWell->m_dSdep - oldSdep;
pWell->ResetChildPosition(pWell->m_fProportion, pWell->m_fProportion, dDelDepth);
}
}
else if (pSectionView)
{
CWellObjectAttributesXml::SaveUndoRedoAction(pView);
CSectionWellObj* pSectionWell = (CSectionWellObj*)pWell;
double sdep = pSectionWell->m_dSdep;
double edep = pSectionWell->m_dEdep;
double flevel = pSectionWell->m_fLevel;
while (xp.ReadBeginSection())
{
if (xp.IsKey("/Well"))
break;
if (!xp.IsKey("Well"))
continue;
pSectionWell->ReadPCG_Well(xp, 2);
}
pSectionWell->SetSpace(pWell->m_fMajorSpace, pWell->m_fMinorSpace);
//pWell->SetFontTrack(pWell->m_fontTrack);
pSectionWell->SetFontHeadMark(pWell->m_fontHeadMark); //µÀ¿Ì¶È×ÖÌå
pSectionWell->SetPenTrack(pWell->m_penTrack); //µÀ±ß¿òÏß
pSectionWell->SetPenGrid(pWell->m_penGridMajor, pWell->m_penGridMinor);//Ö÷´Î¿Ì¶ÈÏß
CWellSection* pSection = (CWellSection*)pSectionWell->GetParent();
if (fabs(sdep - pSectionWell->m_dSdep) > 0.001)
{
if ( pWell->m_dEdep < pWell->m_dSdep)
{
pWell->m_dSdep = pWell->m_dEdep - 5;
}
pWell->SetIntervalTop(0, pWell->m_dSdep);
pWell->m_HeadRect.top -= pWell->HeightToScreenCY(pWell->GetIntervalTop(0) - sdep);
pSectionView->ReSetWell(pWell);
pSection->ComputeControls(pWell, 0);
}
if (fabs(edep - pSectionWell->m_dEdep) > 0.001)
{
if (pWell->m_dEdep < pWell->m_dSdep)
{
pWell->m_dEdep = pWell->m_dSdep + 5;
}
pWell->SetIntervalBottom(pWell->GetIntervalVec()->size() - 1, pWell->m_dEdep);
pSectionView->ReSetWell(pWell);
pSection->ComputeControls(pWell, 0);
}
if (fabs(flevel - pSectionWell->m_fLevel) > 0.001)
{
double fdelta = pWell->m_fLevel - flevel;
fdelta = pSection->HeightToScreenCY(fdelta);
CRect8 oldRect = pWell->GetRect();
oldRect.OffsetRect(0, fdelta);
pWell->m_delta = CPoint2D(0, fdelta);
pWell->MoveTo(oldRect);
pSectionView->ReSetWell(pWell);
pSection->ComputeControls(pWell, 0);
}
}
b = TRUE;
}
}
return b;
}
BOOL CWellObjectAttributesXml::GetInTrackDataAttributes(CWellBaseObj* pDataBase, int inTrackType, CString& strXml)
{
CPublicFunction& pf = *AfxGetPublicFunction();
BOOL b = FALSE;
if (pDataBase->IsTrackChildTopEnd())
{
CInTrackDepthSegment *pInTrackSeg = (CInTrackDepthSegment*)pDataBase;
int ver = 2;
CMemFile file;
pf.WritePCG_Head(file, ver);
int nBaseTabNum = 1;
pInTrackSeg->WritePCG_SelfData(file, nBaseTabNum);
CString str;
CWellPole* pWell = pInTrackSeg->GetWell();
BOOL bv = FALSE;
if (pWell->m_InclinedWellList.size() > 0)
{
bv = 1;
}
double vtopdep = pWell->GetVDepth(pInTrackSeg->m_fSdep);
double vbottomdep = pWell->GetVDepth(pInTrackSeg->m_fEdep);
str.Format("<VerticalDepth IsVertical=\"%d\" vtop=\"%.2f\" vbottom=\"%.2f\" />",bv,vtopdep,vbottomdep); //À©³ä²ÎÊý½ÚµãÓÃÀ´´«µÝһЩÉèÖòÎÊý£¬±¾Éí²»ÊǶÔÏóµÄpcg¶¨Ò岿·Ö£¬Ö»ÊǽøÐд«ÊäһЩ²ÎÊýÓÃÀ´Ö±½ÓÉèÖÃÊý¾Ý¶ÔÏó
pf.WriteLine(file, str);
pf.WritePCG_Tail(file, ver);
ULONG fl = file.GetLength();
file.SeekToBegin();
LPTSTR pbuf = strXml.GetBuffer(fl + 1);
file.Read(pbuf, fl);
strXml.ReleaseBuffer(fl);
file.Close();
b = TRUE;
}
return b;
}
BOOL CWellObjectAttributesXml::SetInTrackDataAttributes(CSigmaView* pView, CWellBaseObj* pDataBase, int inTrackType, CString& strXml)
{
BOOL b = FALSE;
CKXmlParse xp;
if (pDataBase->IsTrackChildTopEnd() && xp.SetXmlFileBuffer(strXml.GetBuffer(), strXml.GetLength()))
{
CInTrackDepthSegment *pInTrackSeg = (CInTrackDepthSegment*)pDataBase;
int ver = 2;
while (xp.ReadBeginSection() > 0)
{
if (xp.IsKey("/Pcg") )
break;
if (xp.ReadBeginSection() > 0)
{
CWellObjectAttributesXml::SaveUndoRedoAction(pView);
CTrackObj* pTrack = (CTrackObj*)pDataBase->GetParent();
pInTrackSeg->ReadPCG_SelfData(xp, ver, pTrack);
b = TRUE;
CWellPole* pWell = (CWellPole*)pTrack->GetWell();
if (pWell->GetParent() != NULL)
{
CWellBaseObj* pBase = (CWellBaseObj*)pWell->GetParent();
if (pBase->GetType() == KEP_WELLSECTION)
{
CWellSection *pWellSection = (CWellSection*)pBase;
POSITION pos = pWellSection->m_BendList.GetHeadPosition();
while (pos)
{
CBendObj *pBend = (CBendObj*)pWellSection->m_BendList.GetNext(pos);
if (pBend->m_pLayerLeft == pInTrackSeg || pBend->m_pLayerRight == pInTrackSeg)
pBend->ComputeBend();
}
}
}
if (pWell->GetWellType() == Well_Incline)
{
pInTrackSeg->CalcInclinedBorder();
}
break;
}
}
}
return b;
}
BOOL CWellObjectAttributesXml::GetGroupTrackAttributes(CTrackGroup* pTrack, CString& strXml)
{
CPublicFunction& pf = *AfxGetPublicFunction();
BOOL b = FALSE;
int ver = 2;
CMemFile file;
pf.WritePCG_Head(file, ver);
int nBaseTabNum = 1;
CTrackGroup parentTrack; //TrackGroupÊÇǶÌ×дpcg£¬Ã¿¸ötrackgroupµÄ×ÔÉí²¿·ÖÔÚ¸¸Ç×µÀÖпªÊ¼Ð´
CXy* pPxy = pTrack->GetParentXY();
CWellBaseObj* pParent = pTrack->GetParent();
parentTrack.SetParent(pTrack->GetWell());
parentTrack.AddTrack(pTrack);
parentTrack.WritePCG_WellTemp(file, nBaseTabNum);
parentTrack.RemoveTrack(pTrack);
pTrack->SetParentXY(pPxy);
pTrack->SetParent(pParent);
pf.WritePCG_Tail(file, ver);
ULONG fl = file.GetLength();
file.SeekToBegin();
LPTSTR pbuf = strXml.GetBuffer(fl + 1);
file.Read(pbuf, fl);
strXml.ReleaseBuffer(fl);
file.Close();
b = TRUE;
return b;
}
BOOL CWellObjectAttributesXml::SetGroupTrackAttributes(CSigmaView* pView, CTrackGroup* pTrack, CString& strXml)
{
BOOL b = FALSE;
CKXmlParse xp;
if (xp.SetXmlFileBuffer(strXml.GetBuffer(), strXml.GetLength()))
{
int ver = 2;
int traceTotalCount = 0;
CWellPole* pWell = pTrack->GetWell();
PCG_WELLTEMPCOL *pWellCol = new PCG_WELLTEMPCOL;
while (xp.ReadBeginSection() > 0)
{
if (xp.IsKey("/Pcg") || xp.IsKey("/WellColumn"))
break;
if (xp.IsKey("WellColumn"))
{
if (pWell->ReadPCG_WellColumn(xp, ver, pWellCol, traceTotalCount) == 1)
{
b = TRUE;
pTrack->m_strTitle = pWellCol->combName;
pTrack->m_font = pWellCol->logfont;
//pTrack->m_font = pWellCol->
delete pWellCol;
}
}
}
}
return b;
}
BOOL CWellObjectAttributesXml::GetTrackAttributes(CTrackObj* pTrack, CString& strXml)
{
CPublicFunction& pf = *AfxGetPublicFunction();
BOOL b = FALSE;
int ver = 2;
CMemFile file;
pf.WritePCG_Head(file, ver);
int nBaseTabNum = 1;
pTrack->WritePCG_Trace(file, nBaseTabNum);
CString str,strPara;
if (pTrack->GetTrackType() == Track_Result)
{
str.Format("<ExtendedData type=\"trackResult\" >"); //À©³ä²ÎÊý½ÚµãÓÃÀ´´«µÝһЩÉèÖòÎÊý£¬±¾Éí²»ÊǶÔÏóµÄpcg¶¨Ò岿·Ö£¬Ö»ÊǽøÐд«ÊäһЩ²ÎÊýÓÃÀ´Ö±½ÓÉèÖÃÊý¾Ý¶ÔÏó
pf.WriteLine(file, str);
str.Format("<Data SandRenderType=\"\" ShowMarkType=\"\" />");
pf.WriteLine(file, str);
str.Format("</ExtendedData>");
pf.WriteLine(file, str);
}
pf.WritePCG_Tail(file, ver);
ULONG fl = file.GetLength();
file.SeekToBegin();
LPTSTR pbuf = strXml.GetBuffer(fl + 1);
file.Read(pbuf, fl);
strXml.ReleaseBuffer(fl);
file.Close();
b = TRUE;
return b;
}
BOOL CWellObjectAttributesXml::SetTrackAttributes(CSigmaView* pView, CTrackObj* pTrack, CString& strXml)
{
BOOL b = FALSE;
CPublicFunction& pf = *AfxGetPublicFunction();
CKXmlParse xp;
CWellPole* pWell = pTrack->GetWell();
PCG_TRACECOL traceCol;
int ver = 2;
if (xp.SetXmlFileBuffer(strXml.GetBuffer(), strXml.GetLength()))
{
CString strOldDataSource = pTrack->m_dataSourceID;
CString strOldCol = pTrack->m_dataColID;
GDFLOGPENEXT oldChildPen = pTrack->m_penChild;
GDFLOGFONTEXT oldChildFont = pTrack->m_fontChild;
while (xp.ReadBeginSection() > 0)
{
if (xp.IsKey("/Pcg") || xp.IsKey("/WellTrack"))
break;
//if (!xp.IsKey("WellTrack") && !xp.IsKey("WellTrace"))
// continue;
if (xp.IsKey("WellTrack") || xp.IsKey("WellTrace"))
{
if (pWell->ReadPCG_Traces_GetTraceProps(xp, traceCol) == 0)
break;
CWellObjectAttributesXml::SaveUndoRedoAction(pView);
pTrack->ReadPCG_Trace(xp, ver, traceCol);
pTrack->m_strTrackName = traceCol.name;
if (traceCol.width >= 0)
pTrack->m_dTrackWidth = pWell->ScreenCXToWidth(traceCol.width);
pTrack->SetFlagBrush(traceCol.backFill);
pTrack->m_brush.m_color = traceCol.backColor;
if (pTrack->GetTrackType() == Track_Curve)
{
CTrackCurve* pCurveTrack = (CTrackCurve*)pTrack;
pCurveTrack->CheckLogLeftRightValue();
}
pTrack->SetPenChild(pTrack->m_penChild);
pTrack->SetFontChild(pTrack->m_fontChild);
pTrack->afterCalculateSize(); //Ö÷ÒªÊÇÇúÏßµÀÓÃÓÚ¼ÆËãÌî³äÇúÏß
b = TRUE;
}
if (xp.IsKey("ExtendedData"))
{
CString strType;
CString tkey, tval;
for (int i = 0; i < xp.m_valArray.size(); i++)
{
if (!xp.ParaseKeyValue(i, tkey, tval))
{
return 0;
}
if (xp.IsKey(tkey, "type"))
{
strType = tval;
}
}
while (xp.ReadBeginSection() > 0)
{
if (xp.IsKey("/Pcg") || xp.IsKey("/ExtendedData"))
break;
if (xp.IsKey("Data"))
{
if (strType == "trackResult")
{
CTrackResult* pTrackResult = (CTrackResult*)pTrack;
for (int i = 0; i < xp.m_valArray.size(); i++)
{
if (!xp.ParaseKeyValue(i, tkey, tval))
{
return 0;
}
if (xp.IsKey(tkey, "SandRenderType"))
{
if (!tval.IsEmpty())
{
WELLOBJLIST::iterator it = pTrackResult->GetChildren().begin();
for (; it != pTrackResult->GetChildren().end(); it++)
{
if ((*it)->GetType() == KEP_RESULT)
{
CInTrackResult* pResult = (CInTrackResult*)(*it);
if (tval == "Standard")
{
pResult->SetShowRenderBrief(FALSE);
}
else if (tval == "Brief")
{
pResult->SetShowRenderBrief(TRUE);
}
}
}
}
}
if (xp.IsKey(tkey, "ShowMarkType"))
{
if (!tval.IsEmpty())
{
WELLOBJLIST::iterator it = pTrackResult->GetChildren().begin();
for (; it != pTrackResult->GetChildren().end(); it++)
{
if ((*it)->GetType() == KEP_RESULT)
{
CInTrackResult* pResult = (CInTrackResult*)(*it);
if (tval == "Name")
{
pResult->SetShowName(TRUE);
}
else if (tval == "PureThickness")
{
pResult->SetShowPureThickness(TRUE);
}
else if (tval == "Thickness")
{
pResult->SetShowThickness(TRUE);
}
else if (tval == "ResultName")
{
pResult->SetShowResult(TRUE);
}
//else if (tval == "")
//{
// pResult->DisableShowMark();
//}
}
}
}
}
}
}
}
}
}
}
if (b)
{
if(strOldDataSource != pTrack->m_dataSourceID || strOldCol != pTrack->m_dataColID)
pTrack->SetDataRefID(pTrack->m_dataSourceID, pTrack->m_dataColID);
pWell->CalculateSize(pWell->GetAnchorPoint());
}
}
return b;
}
BOOL CWellObjectAttributesXml::GetSectionBendAttributes( CBendObj* pBend, CString& strXml)
{
BOOL b = FALSE;
CPublicFunction& pf = *AfxGetPublicFunction();
int ver = 2;
CMemFile file;
pf.WritePCG_Head(file, ver);
int nBaseTabNum = 1;
pBend->WriteDML_PCG(file, 2);
pf.WritePCG_Tail(file, ver);
ULONG fl = file.GetLength();
file.SeekToBegin();
LPTSTR pbuf = strXml.GetBuffer(fl + 1);
file.Read(pbuf, fl);
strXml.ReleaseBuffer(fl);
file.Close();
b = TRUE;
return b;
}
BOOL CWellObjectAttributesXml::SetSectionBendAttributes(CSigmaView* pView, CBendObj* pBend, CString& strXml)
{
BOOL b = FALSE;
CKXmlParse xp;
if (xp.SetXmlFileBuffer(strXml.GetBuffer(), strXml.GetLength()))
{
int ver = 2;
CString strOldStyle = pBend->m_strLineBreakStyle;
CString key, val;
while (xp.ReadBeginSection() > 0)
{
if (xp.IsKey("/Pcg"))
break;
if (xp.ReadBeginSection() > 0)
{
for (int i = 0; i < xp.m_valArray.size(); i++)
{
if (!xp.ParaseKeyValue(i, key, val))
{
return FALSE;
}
if (xp.IsKey(key, "StyleName"))
{
pBend->m_strLineBreakStyle = val;
}
}
CWellObjectAttributesXml::SaveUndoRedoAction(pView);
pBend->ReadPCG_BendProperties(xp, 2);
if (pBend->m_strLineBreakStyle != strOldStyle)
{
if (pBend->m_strLineBreakStyle == "ȱʡÑùʽ")
{
pBend->SetBendStyle(pBend->m_strLineBreakStyle);
}
else
{
if (pBend->m_pLayerRight != NULL )
{
if (AfxGetGlobalWellMarkNamesList()->IsPinoutPattern(pBend->m_strLineBreakStyle) == FALSE)
pBend->SetBendStyle(pBend->m_strLineBreakStyle);
else
pBend->m_strLineBreakStyle = strOldStyle; //ÊǼâÃðÁ¬²ã£¬¶Ô·Ç¼âµãÃð²ãλ²»Æð×÷Óá£
}
else
{
if (AfxGetGlobalWellMarkNamesList()->IsPinoutPattern(pBend->m_strLineBreakStyle) == TRUE)
pBend->SetBendStyle(pBend->m_strLineBreakStyle);
else
pBend->m_strLineBreakStyle = strOldStyle; //ÊǼâÃðÁ¬²ã£¬¶Ô·Ç¼âµãÃð²ãλ²»Æð×÷Óá£
}
}
}
pBend->ComputeBend();
b = TRUE;
break;
}
}
}
return b;
}
BOOL CWellObjectAttributesXml::GetSectionFaultAttributes(CFaultObj* pFault, CString& strXml)
{
BOOL b = FALSE;
CPublicFunction& pf = *AfxGetPublicFunction();
int ver = 2;
CMemFile file;
pf.WritePCG_Head(file, ver);
int nBaseTabNum = 1;
pFault->WritePCG(file, 2);
pf.WritePCG_Tail(file, ver);
ULONG fl = file.GetLength();
file.SeekToBegin();
LPTSTR pbuf = strXml.GetBuffer(fl + 1);
file.Read(pbuf, fl);
strXml.ReleaseBuffer(fl);
file.Close();
b = TRUE;
return b;
}
BOOL CWellObjectAttributesXml::SetSectionFaultAttributes(CSigmaView* pView, CFaultObj* pFault, CString& strXml)
{
BOOL b = FALSE;
CKXmlParse xp;
if (xp.SetXmlFileBuffer(strXml.GetBuffer(), strXml.GetLength()))
{
int ver = 2;
while (xp.ReadBeginSection() > 0)
{
if (xp.IsKey("/Pcg"))
break;
if (xp.ReadBeginSection() > 0)
{
if (xp.IsKey("Fault"))
{
//BOOL bsp = pFault->IsBSPline();
CWellObjectAttributesXml::SaveUndoRedoAction(pView);
CWellSection *pParent = (CWellSection*)pFault->GetParent();
pFault->ReadPCG_FaultProperties(xp, ver, pParent->GetRect());
if (pParent->m_bResForm)
{//¾­¹ý¹Û²ì£¬ÕâÑùµ÷ÕûÊÊÓÃ
pFault->m_fLeftThrow = pFault->m_fLeftThrow / 2;
pFault->m_fRightThrow = pFault->m_fRightThrow / 2;
}
pFault->ComputedFaultCurvePoints(pFault->IsBSPline());
pParent->ReBuildBends(pFault);
b = TRUE;
break;
}
}
}
}
return b;
}
BOOL CWellObjectAttributesXml::GetWellSectionAttributes(CWellSection* pSection, CString& strXml)
{
BOOL b = FALSE;
CPublicFunction& pf = *AfxGetPublicFunction();
int ver = 2;
CMemFile file;
pf.WritePCG_Head(file, ver);
int nBaseTabNum = 1;
//pFault->WritePCG(file, 2);
pSection->WritePCG_Sections(file, 2);
pf.WritePCG_Tail(file, ver);
ULONG fl = file.GetLength();
file.SeekToBegin();
LPTSTR pbuf = strXml.GetBuffer(fl + 1);
file.Read(pbuf, fl);
strXml.ReleaseBuffer(fl);
file.Close();
b = TRUE;
return b;
}
BOOL CWellObjectAttributesXml::SetWellSectionAttributes(CSigmaView* pView, CWellSection* pSection, CString& strXml)
{
BOOL b = FALSE;
CKXmlParse xp;
if (xp.SetXmlFileBuffer(strXml.GetBuffer(), strXml.GetLength()))
{
int ver = 2;
while (xp.ReadBeginSection() > 0)
{
if (xp.IsKey("/Pcg"))
break;
if (xp.ReadBeginSection() > 0)
{
CWellObjectAttributesXml::SaveUndoRedoAction(pView);
double level = pSection->m_fLevelScale;
double depth = pSection->m_fDepthScale;
double horz = pSection->m_fHorzScale;
CWellSection* pTmpSection = new CWellSection(); //Ö»ÓÃÀ´¶ÁÈ¡ÊôÐÔÊý¾Ý£¬Ê¹ÓÃÍêºóɾ³ý¡£(Ö±½ÓʹÓÃÔ­¶ÔÏó¶ÁȡӰÏìÌ«´óÁË)
pTmpSection->m_fLevelScale = pSection->m_fLevelScale;
pTmpSection->m_fDepthScale = pSection->m_fDepthScale;
pTmpSection->m_fHorzScale = pSection->m_fHorzScale;
pTmpSection->ReadPCG_Section(xp, ver, TRUE);
if (fabs(level - pTmpSection->m_fLevelScale) > 1)
pSection->ReSetScaleVer(pTmpSection->m_fLevelScale);
if (fabs(depth - pTmpSection->m_fDepthScale) > 1)
pSection->SetDepthScale(pTmpSection->m_fDepthScale);
if (fabs(horz - pTmpSection->m_fHorzScale) > 1)
pSection->ReSetScaleHor(pTmpSection->m_fHorzScale);
if (pSection->GetDisplayMode() != pTmpSection->GetDisplayMode())
{
if (pTmpSection->IsDisplayModeNormal())
{
pSection->SetDisplayModeNormal(TRUE);
pSection->SetWellPoleDisplayMode(0);
}
if (pTmpSection->IsDisplayMoedVertical())
{
pSection->SetDisplayModeVertical(TRUE);
pSection->SetWellPoleDisplayMode(2);
}
}
delete pTmpSection;
b = TRUE;
break;
}
}
}
return b;
}