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.
761 lines
25 KiB
C++
761 lines
25 KiB
C++
#include "stdafx.h"
|
|
#include "nlohmann\json.hpp"
|
|
#include "WellObjectAttributesJson.h"
|
|
#include "DrawOperator/Encoding.h"
|
|
|
|
extern 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;
|
|
//}
|
|
|
|
extern 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\"",
|
|
extern 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\"",
|
|
extern 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);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
CWellObjectAttributesJson::CWellObjectAttributesJson()
|
|
{
|
|
|
|
}
|
|
|
|
BOOL CWellObjectAttributesJson::GetWellObjectAttributesJson(ULONGLONG objHandle, int type, int ttype, CString& strJson)
|
|
{
|
|
BOOL b = FALSE;
|
|
try
|
|
{
|
|
CWellBaseObj* pWellBase = (CWellBaseObj*)objHandle;
|
|
if (type == KEP_WELL)
|
|
{
|
|
CWellPole* pWell = dynamic_cast<CWellPole*>(pWellBase);
|
|
b = CWellObjectAttributesJson::GetWellObjectAttributes(pWell, strJson);
|
|
}
|
|
else if (type == KEP_TRACK)
|
|
{
|
|
if (ttype == Track_Depth)
|
|
{
|
|
CTrackDepth* pDepthTrack = dynamic_cast<CTrackDepth*>(pWellBase);
|
|
if (pDepthTrack == NULL) return b;
|
|
b = CWellObjectAttributesJson::GetDepthTrackAttributes(pDepthTrack, strJson);
|
|
}
|
|
else if (ttype == Track_Text)
|
|
{
|
|
CTrackText* pTextTrack = dynamic_cast<CTrackText*>(pWellBase);
|
|
if (pTextTrack == NULL) return b;
|
|
b = CWellObjectAttributesJson::GetTextTrackAttributes(pTextTrack, strJson);
|
|
}
|
|
else if (ttype == Track_Lith)
|
|
{
|
|
CTrackLith* pLithTrack = dynamic_cast<CTrackLith*>(pWellBase);
|
|
if (pLithTrack == NULL) return b;
|
|
b = CWellObjectAttributesJson::GetLithologyTrackAttributes(pLithTrack, strJson);
|
|
}
|
|
else if (ttype == Track_Curve)
|
|
{
|
|
CTrackCurve* pCurveTrack = dynamic_cast<CTrackCurve*>(pWellBase);
|
|
if (pCurveTrack == NULL) return b;
|
|
b = CWellObjectAttributesJson::GetCurveTrackAttributes(pCurveTrack, strJson);
|
|
}
|
|
}
|
|
else if (type == KEP_TRACKINDATA)
|
|
{
|
|
b = CWellObjectAttributesJson::GetInTrackDataAttributes(pWellBase,ttype, strJson);
|
|
}
|
|
}
|
|
catch (std::exception e)
|
|
{
|
|
return FALSE;
|
|
}
|
|
return b;
|
|
}
|
|
|
|
|
|
BOOL CWellObjectAttributesJson::SetWellObjectAttributesJson(ULONGLONG objHandle, int type, int ttype, CString& strJson)
|
|
{
|
|
BOOL b = FALSE;
|
|
try
|
|
{
|
|
CWellBaseObj* pWellBase = (CWellBaseObj*)objHandle;
|
|
if (type == KEP_WELL)
|
|
{
|
|
CWellPole* pWell = dynamic_cast<CWellPole*>(pWellBase);
|
|
b = CWellObjectAttributesJson::SetWellObjectAttributes(pWell, strJson);
|
|
}
|
|
else if (type == KEP_TRACK)
|
|
{
|
|
if (ttype == Track_Depth)
|
|
{
|
|
CTrackDepth* pDepthTrack = dynamic_cast<CTrackDepth*>(pWellBase);
|
|
if (pDepthTrack == NULL) return b;
|
|
b = CWellObjectAttributesJson::SetDepthTrackAttributes(pDepthTrack, strJson);
|
|
}
|
|
else if (ttype == Track_Text)
|
|
{
|
|
CTrackText* pTextTrack = dynamic_cast<CTrackText*>(pWellBase);
|
|
if (pTextTrack == NULL) return b;
|
|
b = CWellObjectAttributesJson::SetTextTrackAttributes(pTextTrack, strJson);
|
|
}
|
|
else if (ttype == Track_Lith)
|
|
{
|
|
CTrackLith* pLithTrack = dynamic_cast<CTrackLith*>(pWellBase);
|
|
if (pLithTrack == NULL) return b;
|
|
b = CWellObjectAttributesJson::SetLithologyTrackAttributes(pLithTrack, strJson);
|
|
}
|
|
else if (ttype == Track_Curve)
|
|
{
|
|
CTrackCurve* pCurveTrack = dynamic_cast<CTrackCurve*>(pWellBase);
|
|
if (pCurveTrack == NULL) return b;
|
|
b = CWellObjectAttributesJson::SetCurveTrackAttributes(pCurveTrack, strJson);
|
|
}
|
|
}
|
|
else if (type == KEP_TRACKINDATA)
|
|
{
|
|
b = CWellObjectAttributesJson::SetInTrackDataAttributes(pWellBase,ttype, strJson);
|
|
}
|
|
}
|
|
catch (std::exception e)
|
|
{
|
|
return FALSE;
|
|
}
|
|
return b;
|
|
}
|
|
|
|
BOOL CWellObjectAttributesJson::GetWellObjectAttributes(CWellPole* pWell, CString& strJson)
|
|
{
|
|
BOOL b = FALSE;
|
|
if (pWell)
|
|
{
|
|
try
|
|
{
|
|
nlohmann::json json;
|
|
json["type"] = "wellPole";
|
|
|
|
nlohmann::json baseProp;
|
|
|
|
baseProp[GB2312_To_UTF8("±êÌâ")] = GB2312_To_UTF8(pWell->m_strTitle);
|
|
baseProp[GB2312_To_UTF8("¾®Ãû")] = GB2312_To_UTF8(pWell->GetWellName());
|
|
baseProp[GB2312_To_UTF8("²¹Ðĺ£°Î")] = pWell->m_fLevel;
|
|
baseProp[GB2312_To_UTF8("Éî¶È±ÈÀý³ß")] = pWell->m_dDepthRatio;
|
|
baseProp[GB2312_To_UTF8("ÆðʼÉî¶È")] = pWell->m_dSdep;
|
|
baseProp[GB2312_To_UTF8("½áÊøÉî¶È")] = pWell->m_dEdep;
|
|
baseProp[GB2312_To_UTF8("×óÓұ߾à")] = pWell->m_fMarginLR;
|
|
baseProp[GB2312_To_UTF8("ÉÏϱ߾à")] = pWell->m_fMarginTB;
|
|
|
|
nlohmann::json scaleProp;
|
|
scaleProp[GB2312_To_UTF8("Ö÷¿Ì¶È")] = pWell->m_fMajorSpace;
|
|
scaleProp[GB2312_To_UTF8("¸±¿Ì¶È")] = pWell->m_fMinorSpace;
|
|
|
|
nlohmann::json fontsJson;
|
|
fontsJson[GB2312_To_UTF8("±êÌâ×ÖÌå")] = GB2312_To_UTF8(GetGdfFontStr(pWell->m_font));
|
|
fontsJson[GB2312_To_UTF8("µÀÍ·×ÖÌå")] = GB2312_To_UTF8(GetGdfFontStr(pWell->m_fontTrack));
|
|
fontsJson[GB2312_To_UTF8("µÀÍ·¿Ì¶È×ÖÌå")] = GB2312_To_UTF8(GetGdfFontStr(pWell->m_fontHeadMark));
|
|
fontsJson[GB2312_To_UTF8("Éî¶È¿Ì¶È×ÖÌå")] = GB2312_To_UTF8(GetGdfFontStr(pWell->m_fontGridMark));
|
|
|
|
nlohmann::json pensJson;
|
|
pensJson[GB2312_To_UTF8("¾®±ß¿òÏß")] = GetGdfPenStr(pWell->m_pen);
|
|
pensJson[GB2312_To_UTF8("µÀ±ß¿òÏß")] = GetGdfPenStr(pWell->m_penTrack);
|
|
pensJson[GB2312_To_UTF8("Ö÷¿Ì¶ÈÏß")] = GetGdfPenStr(pWell->m_penGridMajor);
|
|
pensJson[GB2312_To_UTF8("´Î¿Ì¶ÈÏß")] = GetGdfPenStr(pWell->m_penGridMinor);
|
|
|
|
nlohmann::json jsonProps;
|
|
jsonProps["baseProperties"] = baseProp;
|
|
jsonProps[GB2312_To_UTF8("»ù±¾ÊôÐÔ")] = baseProp;
|
|
jsonProps[GB2312_To_UTF8("¼ä¸ôÉèÖÃ")] = scaleProp;
|
|
jsonProps[GB2312_To_UTF8("×ÖÌå")] = fontsJson;
|
|
jsonProps[GB2312_To_UTF8("ÏßÊôÐÔ")] = pensJson;
|
|
|
|
json["properties"] = jsonProps;
|
|
|
|
strJson = json.dump().c_str();
|
|
b = TRUE;
|
|
}
|
|
catch (nlohmann::json::parse_error& e)
|
|
{
|
|
return FALSE;
|
|
}
|
|
}
|
|
return b;
|
|
}
|
|
|
|
|
|
BOOL CWellObjectAttributesJson::SetWellObjectAttributes(CWellPole* pWell, CString& strJson)
|
|
{
|
|
BOOL b = FALSE;
|
|
if (pWell)
|
|
{
|
|
nlohmann::json tjson;
|
|
try
|
|
{
|
|
tjson = nlohmann::json::parse(strJson.GetBuffer());
|
|
strJson.ReleaseBuffer();
|
|
|
|
CString str;
|
|
str = tjson["type"].get<std::string>().c_str();
|
|
if (str != "wellPole")
|
|
return FALSE;
|
|
|
|
nlohmann::json propsJson;
|
|
propsJson = tjson["properties"];
|
|
|
|
nlohmann::json baseJson;
|
|
baseJson = propsJson[GB2312_To_UTF8("»ù±¾ÊôÐÔ")];
|
|
|
|
pWell->m_strTitle = UTF8_To_GB2312(baseJson[GB2312_To_UTF8("±êÌâ")].get<std::string>().c_str());
|
|
pWell->SetWellName(UTF8_To_GB2312(baseJson[GB2312_To_UTF8("¾®Ãû")].get<std::string>().c_str()));
|
|
pWell->m_fLevel = baseJson[GB2312_To_UTF8("²¹Ðĺ£°Î")].get<float>();
|
|
pWell->m_fProportion = baseJson[GB2312_To_UTF8("Éî¶È±ÈÀý³ß")].get<float>();
|
|
pWell->m_dSdep = baseJson[GB2312_To_UTF8("ÆðʼÉî¶È")].get<float>();
|
|
pWell->m_dEdep = baseJson[GB2312_To_UTF8("½áÊøÉî¶È")].get<float>();
|
|
|
|
pWell->m_fMarginLR = baseJson[GB2312_To_UTF8("×óÓұ߾à")].get<float>();
|
|
pWell->m_fMarginTB = baseJson[GB2312_To_UTF8("ÉÏϱ߾à")].get<float>();
|
|
|
|
nlohmann::json scaleProp;
|
|
scaleProp = baseJson[GB2312_To_UTF8("¼ä¸ôÉèÖÃ")];
|
|
pWell->m_fMajorSpace = scaleProp[GB2312_To_UTF8("Ö÷¿Ì¶È")].get<float>();
|
|
pWell->m_fMinorSpace = scaleProp[GB2312_To_UTF8("¸±¿Ì¶È")].get<float>();
|
|
|
|
nlohmann::json fontsJson;
|
|
fontsJson = baseJson[GB2312_To_UTF8("×ÖÌå")];
|
|
SetStrValueToGdfFont(fontsJson[GB2312_To_UTF8("±êÌâ×ÖÌå")].get<std::string>().c_str(), pWell->m_font);
|
|
SetStrValueToGdfFont(fontsJson[GB2312_To_UTF8("µÀÍ·×ÖÌå")].get<std::string>().c_str(), pWell->m_fontTrack);
|
|
SetStrValueToGdfFont(fontsJson[GB2312_To_UTF8("µÀÍ·¿Ì¶È×ÖÌå")].get<std::string>().c_str(), pWell->m_fontHeadMark);
|
|
SetStrValueToGdfFont(fontsJson[GB2312_To_UTF8("Éî¶È¿Ì¶È×ÖÌå")].get<std::string>().c_str(), pWell->m_fontGridMark);
|
|
|
|
nlohmann::json pensJson;
|
|
pensJson = baseJson[GB2312_To_UTF8("×ÖÌå")];
|
|
SetStrValueToGdfPen(pensJson[GB2312_To_UTF8("¾®±ß¿òÏß")].get<std::string>().c_str(),pWell->m_pen);
|
|
SetStrValueToGdfPen(pensJson[GB2312_To_UTF8("µÀ±ß¿òÏß")].get<std::string>().c_str(), pWell->m_penTrack);
|
|
SetStrValueToGdfPen(pensJson[GB2312_To_UTF8("Ö÷¿Ì¶ÈÏß")].get<std::string>().c_str(), pWell->m_penGridMajor);
|
|
SetStrValueToGdfPen(pensJson[GB2312_To_UTF8("´Î¿Ì¶ÈÏß")].get<std::string>().c_str(), pWell->m_penGridMinor);
|
|
}
|
|
catch (nlohmann::json::parse_error& e)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
b = TRUE;
|
|
}
|
|
|
|
return b;
|
|
}
|
|
|
|
BOOL CWellObjectAttributesJson::GetDepthTrackAttributes(CTrackDepth* pTrack, CString& strJson)
|
|
{
|
|
CPublicFunction& pf = *AfxGetPublicFunction();
|
|
BOOL b = FALSE;
|
|
try
|
|
{
|
|
nlohmann::json json;
|
|
json["type"] = "depthTrack";
|
|
|
|
nlohmann::json baseProp;
|
|
baseProp[GB2312_To_UTF8("±êÌâ")] = GB2312_To_UTF8(pTrack->m_strTitle);
|
|
baseProp[GB2312_To_UTF8("¿í¶È")] = pTrack->m_dTrackWidth;
|
|
baseProp[GB2312_To_UTF8("Ìî³ä")] = bool(pTrack->IsFlagBrush());
|
|
baseProp[GB2312_To_UTF8("±³¾°ÑÕÉ«")] = pf.ColorRefToHex(pTrack->m_brush.m_color);
|
|
|
|
nlohmann::json scaleJson;
|
|
scaleJson[GB2312_To_UTF8("ÏÔʾº£°Î¿Ì¶È")] = bool(pTrack->IsMarkLevel());
|
|
scaleJson[GB2312_To_UTF8("¿Ì¶È¾Ó×ó")] = bool(pTrack->IsMarkLeft());
|
|
scaleJson[GB2312_To_UTF8("Ó¢ÖÆµ¥Î»")] = bool(pTrack->IsMarkFeet());
|
|
scaleJson[GB2312_To_UTF8("Ö÷¿Ì¶È")] = pTrack->m_fMajorGrid;
|
|
scaleJson[GB2312_To_UTF8("¸±¿Ì¶È")] = pTrack->m_fMinorGrid;
|
|
scaleJson[GB2312_To_UTF8("Ö÷¿Ì¶È¿í¶È")] = pTrack->m_fMajorWidth;
|
|
scaleJson[GB2312_To_UTF8("¸±¿Ì¶È¿í¶È")] = pTrack->m_fMinorWidth;
|
|
scaleJson[GB2312_To_UTF8("Ö÷¿Ì¶ÈÏß")] = GetGdfPenStr(pTrack->m_penGridMajor);
|
|
scaleJson[GB2312_To_UTF8("´Î¿Ì¶ÈÏß")] = GetGdfPenStr(pTrack->m_penGridMinor);
|
|
scaleJson[GB2312_To_UTF8("¿Ì¶È×ÖÌå")] = GB2312_To_UTF8(GetGdfFontStr(pTrack->m_fontGridMark));
|
|
|
|
nlohmann::json markJson;
|
|
markJson[GB2312_To_UTF8("ÏÔʾÉî¶Èµ¥Î»")] = bool(pTrack->IsShowMarkUnit());
|
|
markJson[GB2312_To_UTF8("´¹Ö±ÏÔʾ±ê×¢")] = bool(pTrack->IsMarkArrange());
|
|
|
|
nlohmann::json jsonProps;
|
|
jsonProps["baseProperties"] = baseProp;
|
|
jsonProps[GB2312_To_UTF8("Éî¶ÈµÀ")] = baseProp;
|
|
jsonProps[GB2312_To_UTF8("¿Ì¶È")] = scaleJson;
|
|
jsonProps[GB2312_To_UTF8("±ê×¢")] = markJson;
|
|
|
|
json["properties"] = jsonProps;
|
|
|
|
strJson = json.dump().c_str();
|
|
|
|
b = TRUE;
|
|
}
|
|
catch (nlohmann::json::parse_error& e)
|
|
{
|
|
return FALSE;
|
|
}
|
|
return b;
|
|
}
|
|
BOOL CWellObjectAttributesJson::SetDepthTrackAttributes(CTrackDepth* pTrack, CString& strJson)
|
|
{
|
|
CPublicFunction& pf = *AfxGetPublicFunction();
|
|
BOOL b = FALSE;
|
|
nlohmann::json tjson;
|
|
try
|
|
{
|
|
tjson = nlohmann::json::parse(strJson.GetBuffer());
|
|
strJson.ReleaseBuffer();
|
|
|
|
CString str;
|
|
str = tjson["type"].get<std::string>().c_str();
|
|
if (str != "depthTrack")
|
|
return FALSE;
|
|
|
|
nlohmann::json propsJson;
|
|
propsJson = tjson["properties"];
|
|
|
|
nlohmann::json baseJson;
|
|
baseJson = propsJson[GB2312_To_UTF8("Éî¶ÈµÀ")];
|
|
pTrack->m_strTitle = UTF8_To_GB2312(baseJson[GB2312_To_UTF8("±êÌâ")].get<std::string>().c_str());
|
|
pTrack->m_dTrackWidth = baseJson[GB2312_To_UTF8("¿í¶È")].get<float>();
|
|
pTrack->SetFlagBrush(baseJson[GB2312_To_UTF8("Ìî³ä")].get<bool>());
|
|
pTrack->m_brush.m_color = pf.HexToColorRef(baseJson[GB2312_To_UTF8("±³¾°ÑÕÉ«")].get<std::string>().c_str());
|
|
|
|
nlohmann::json scaleJson;
|
|
scaleJson = propsJson[GB2312_To_UTF8("¿Ì¶È")];
|
|
pTrack->SetMarkLevel(scaleJson[GB2312_To_UTF8("ÏÔʾº£°Î¿Ì¶È")].get<bool>());
|
|
pTrack->SetMarkLeft(scaleJson[GB2312_To_UTF8("¿Ì¶È¾Ó×ó")].get<bool>());
|
|
pTrack->SetMarkFeet(scaleJson[GB2312_To_UTF8("Ó¢ÖÆµ¥Î»")].get<bool>());
|
|
pTrack->m_fMajorGrid = scaleJson[GB2312_To_UTF8("Ö÷¿Ì¶È")].get<float>();
|
|
pTrack->m_fMinorGrid = scaleJson[GB2312_To_UTF8("¸±¿Ì¶È")].get<float>();
|
|
pTrack->m_fMajorWidth = scaleJson[GB2312_To_UTF8("Ö÷¿Ì¶È¿í¶È")].get<float>();
|
|
pTrack->m_fMinorWidth = scaleJson[GB2312_To_UTF8("¸±¿Ì¶È¿í¶È")].get<float>();
|
|
|
|
SetStrValueToGdfPen(scaleJson[GB2312_To_UTF8("Ö÷¿Ì¶ÈÏß")].get<std::string>().c_str(), pTrack->m_penGridMajor);
|
|
SetStrValueToGdfPen(scaleJson[GB2312_To_UTF8("´Î¿Ì¶ÈÏß")].get<std::string>().c_str(), pTrack->m_penGridMinor);
|
|
SetStrValueToGdfFont(scaleJson[GB2312_To_UTF8("¿Ì¶È×ÖÌå")].get<std::string>().c_str(), pTrack->m_fontGridMark);
|
|
|
|
nlohmann::json markJson = propsJson[GB2312_To_UTF8("±ê×¢")];
|
|
pTrack->SetShowMarkUnit(markJson[GB2312_To_UTF8("ÏÔʾÉî¶Èµ¥Î»")].get<bool>());
|
|
pTrack->SetMarkArrange(markJson[GB2312_To_UTF8("´¹Ö±ÏÔʾ±ê×¢")].get<bool>());
|
|
}
|
|
catch (nlohmann::json::parse_error& e)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
b = TRUE;
|
|
|
|
return b;
|
|
}
|
|
|
|
BOOL CWellObjectAttributesJson::GetTextTrackAttributes(CTrackText* pTrack, CString& strJson)
|
|
{
|
|
CPublicFunction& pf = *AfxGetPublicFunction();
|
|
BOOL b = FALSE;
|
|
try
|
|
{
|
|
nlohmann::json json;
|
|
json["type"] = "textTrack";
|
|
|
|
nlohmann::json baseProp;
|
|
baseProp[GB2312_To_UTF8("±êÌâ")] = GB2312_To_UTF8(pTrack->m_strTitle);
|
|
baseProp[GB2312_To_UTF8("¿í¶È")] = pTrack->m_dTrackWidth;
|
|
baseProp[GB2312_To_UTF8("Ìî³ä")] = bool(pTrack->IsFlagBrush());
|
|
baseProp[GB2312_To_UTF8("±³¾°ÑÕÉ«")] = pf.ColorRefToHex(pTrack->m_brush.m_color);
|
|
baseProp[GB2312_To_UTF8("µÀÍ·×ÖÌå")] = GB2312_To_UTF8(GetGdfFontStr(pTrack->m_font));
|
|
|
|
nlohmann::json indataJson;
|
|
indataJson[GB2312_To_UTF8("±ß¿òÏß")] = GetGdfPenStr(pTrack->m_penChild);
|
|
indataJson[GB2312_To_UTF8("±³¾°ÑÕÉ«")] = pf.ColorRefToHex(pTrack->m_brushChild.m_color);
|
|
indataJson[GB2312_To_UTF8("×ÖÌå")] = GB2312_To_UTF8(GetGdfFontStr(pTrack->m_fontChild));
|
|
|
|
nlohmann::json jsonProps;
|
|
jsonProps["baseProperties"] = baseProp;
|
|
jsonProps[GB2312_To_UTF8("Îı¾µÀ")] = baseProp;
|
|
jsonProps[GB2312_To_UTF8("µÀÄÚ¶ÔÏóÉèÖÃ")] = indataJson;
|
|
|
|
json["properties"] = jsonProps;
|
|
|
|
strJson = json.dump().c_str();
|
|
|
|
b = TRUE;
|
|
}
|
|
catch (nlohmann::json::parse_error& e)
|
|
{
|
|
return FALSE;
|
|
}
|
|
return b;
|
|
}
|
|
|
|
BOOL CWellObjectAttributesJson::SetTextTrackAttributes(CTrackText* pTrack, CString& strJson)
|
|
{
|
|
CPublicFunction& pf = *AfxGetPublicFunction();
|
|
BOOL b = FALSE;
|
|
nlohmann::json tjson;
|
|
try
|
|
{
|
|
tjson = nlohmann::json::parse(strJson.GetBuffer());
|
|
strJson.ReleaseBuffer();
|
|
|
|
CString str;
|
|
str = tjson["type"].get<std::string>().c_str();
|
|
if (str != "textTrack")
|
|
return FALSE;
|
|
|
|
nlohmann::json propsJson;
|
|
propsJson = tjson["properties"];
|
|
|
|
nlohmann::json baseJson;
|
|
baseJson = propsJson[GB2312_To_UTF8("Éî¶ÈµÀ")];
|
|
pTrack->m_strTitle = UTF8_To_GB2312(baseJson[GB2312_To_UTF8("±êÌâ")].get<std::string>().c_str());
|
|
pTrack->m_dTrackWidth = baseJson[GB2312_To_UTF8("¿í¶È")].get<float>();
|
|
pTrack->SetFlagBrush(baseJson[GB2312_To_UTF8("Ìî³ä")].get<bool>());
|
|
pTrack->m_brush.m_color = pf.HexToColorRef(baseJson[GB2312_To_UTF8("±³¾°ÑÕÉ«")].get<std::string>().c_str());
|
|
SetStrValueToGdfFont(baseJson[GB2312_To_UTF8("µÀÍ·×ÖÌå")].get<std::string>().c_str(), pTrack->m_font);
|
|
|
|
nlohmann::json indataJson = propsJson[GB2312_To_UTF8("µÀÄÚ¶ÔÏóÉèÖÃ")];
|
|
SetStrValueToGdfPen(indataJson[GB2312_To_UTF8("±ß¿òÏß")].get<std::string>().c_str(), pTrack->m_penChild);
|
|
pTrack->m_brushChild.m_color = pf.HexToColorRef(indataJson[GB2312_To_UTF8("±³¾°ÑÕÉ«")].get<std::string>().c_str());
|
|
SetStrValueToGdfFont(indataJson[GB2312_To_UTF8("×ÖÌå")].get<std::string>().c_str(), pTrack->m_fontChild);
|
|
}
|
|
catch (nlohmann::json::parse_error& e)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
b = TRUE;
|
|
|
|
return b;
|
|
}
|
|
|
|
|
|
BOOL CWellObjectAttributesJson::GetLithologyTrackAttributes(CTrackLith* pTrack, CString& strJson)
|
|
{
|
|
CPublicFunction& pf = *AfxGetPublicFunction();
|
|
BOOL b = FALSE;
|
|
try
|
|
{
|
|
nlohmann::json json;
|
|
json["type"] = "lithologyTrack";
|
|
|
|
nlohmann::json baseProp;
|
|
baseProp[GB2312_To_UTF8("±êÌâ")] = GB2312_To_UTF8(pTrack->m_strTitle);
|
|
baseProp[GB2312_To_UTF8("¿í¶È")] = pTrack->m_dTrackWidth;
|
|
baseProp[GB2312_To_UTF8("Ìî³ä")] = bool(pTrack->IsFlagBrush());
|
|
baseProp[GB2312_To_UTF8("±³¾°ÑÕÉ«")] = pf.ColorRefToHex(pTrack->m_brush.m_color);
|
|
baseProp[GB2312_To_UTF8("µÀÍ·×ÖÌå")] = GB2312_To_UTF8(GetGdfFontStr(pTrack->m_font));
|
|
|
|
nlohmann::json indataJson;
|
|
indataJson[GB2312_To_UTF8("ÓÍÆøÐÔ¿í¶È°Ù·Ö±È")] = pTrack->m_nWidthOil;
|
|
indataJson[GB2312_To_UTF8("µ¥¸ö·ûºÅºñ¶È")] = pTrack->m_nThick;
|
|
indataJson[GB2312_To_UTF8("µ¥¸ö·ûºÅ³äÌî")] = bool(pTrack->IsSingle());
|
|
indataJson[GB2312_To_UTF8("ÊÇ·ñÏÔʾÑÒÐÔ")] = bool(pTrack->IsShowLith());
|
|
indataJson[GB2312_To_UTF8("ÏÔʾÑÒÐÔÑÕÉ«")] = bool(pTrack->IsShowColor());
|
|
indataJson[GB2312_To_UTF8("ÏÔʾº¬ÓÍÆøÐÔ")] = bool(pTrack->IsShowOil());
|
|
indataJson[GB2312_To_UTF8("¿ØÖÆÑÒÐÔ¿í¶È")] = bool(pTrack->IsWidth());
|
|
indataJson[GB2312_To_UTF8("º¬ÓÍÆøÐÔÔÚµÀÓÒ²à")] = bool(pTrack->IsRightOil());
|
|
|
|
nlohmann::json jsonProps;
|
|
jsonProps["baseProperties"] = baseProp;
|
|
jsonProps[GB2312_To_UTF8("ÑÒÐÔµÀ")] = baseProp;
|
|
jsonProps[GB2312_To_UTF8("µÀÄÚ¶ÔÏóÉèÖÃ")] = indataJson;
|
|
|
|
json["properties"] = jsonProps;
|
|
|
|
strJson = json.dump().c_str();
|
|
|
|
b = TRUE;
|
|
}
|
|
catch (nlohmann::json::parse_error& e)
|
|
{
|
|
return FALSE;
|
|
}
|
|
return b;
|
|
}
|
|
BOOL CWellObjectAttributesJson::SetLithologyTrackAttributes(CTrackLith* pTrack, CString& strJson)
|
|
{
|
|
CPublicFunction& pf = *AfxGetPublicFunction();
|
|
BOOL b = FALSE;
|
|
nlohmann::json tjson;
|
|
try
|
|
{
|
|
tjson = nlohmann::json::parse(strJson.GetBuffer());
|
|
strJson.ReleaseBuffer();
|
|
|
|
CString str;
|
|
str = tjson["type"].get<std::string>().c_str();
|
|
if (str != "lithologyTrack")
|
|
return FALSE;
|
|
|
|
nlohmann::json propsJson;
|
|
propsJson = tjson["properties"];
|
|
|
|
nlohmann::json baseJson;
|
|
baseJson = propsJson[GB2312_To_UTF8("ÑÒÐÔµÀ")];
|
|
pTrack->m_strTitle = UTF8_To_GB2312(baseJson[GB2312_To_UTF8("±êÌâ")].get<std::string>().c_str());
|
|
pTrack->m_dTrackWidth = baseJson[GB2312_To_UTF8("¿í¶È")].get<float>();
|
|
pTrack->SetFlagBrush(baseJson[GB2312_To_UTF8("Ìî³ä")].get<bool>());
|
|
pTrack->m_brush.m_color = pf.HexToColorRef(baseJson[GB2312_To_UTF8("±³¾°ÑÕÉ«")].get<std::string>().c_str());
|
|
SetStrValueToGdfFont(baseJson[GB2312_To_UTF8("µÀÍ·×ÖÌå")].get<std::string>().c_str(), pTrack->m_font);
|
|
|
|
nlohmann::json indataJson = propsJson[GB2312_To_UTF8("µÀÄÚ¶ÔÏóÉèÖÃ")];
|
|
|
|
pTrack->m_nWidthOil = indataJson[GB2312_To_UTF8("ÓÍÆøÐÔ¿í¶È°Ù·Ö±È")].get<float>();
|
|
pTrack->m_nThick = indataJson[GB2312_To_UTF8("µ¥¸ö·ûºÅºñ¶È")].get<int>() ;
|
|
pTrack->SetSingle(indataJson[GB2312_To_UTF8("µ¥¸ö·ûºÅ³äÌî")].get<bool>());
|
|
pTrack->SetShowLith(indataJson[GB2312_To_UTF8("ÊÇ·ñÏÔʾÑÒÐÔ")].get<bool>());
|
|
pTrack->SetShowColor(indataJson[GB2312_To_UTF8("ÏÔʾÑÒÐÔÑÕÉ«")].get<bool>());
|
|
pTrack->SetShowOil(indataJson[GB2312_To_UTF8("ÏÔʾº¬ÓÍÆøÐÔ")].get<bool>());
|
|
pTrack->SetWidth(indataJson[GB2312_To_UTF8("¿ØÖÆÑÒÐÔ¿í¶È")].get<bool>());
|
|
pTrack->SetRightOil(indataJson[GB2312_To_UTF8("º¬ÓÍÆøÐÔÔÚµÀÓÒ²à")].get<bool>());
|
|
}
|
|
catch (nlohmann::json::parse_error& e)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
b = TRUE;
|
|
|
|
return b;
|
|
}
|
|
|
|
BOOL CWellObjectAttributesJson::GetCurveTrackAttributes(CTrackCurve* pTrack, CString& strJson)
|
|
{
|
|
CPublicFunction& pf = *AfxGetPublicFunction();
|
|
BOOL b = FALSE;
|
|
try
|
|
{
|
|
nlohmann::json json;
|
|
json["type"] = "curveTrack";
|
|
|
|
nlohmann::json baseProp;
|
|
baseProp[GB2312_To_UTF8("±êÌâ")] = GB2312_To_UTF8(pTrack->m_strTitle);
|
|
baseProp[GB2312_To_UTF8("¿í¶È")] = pTrack->m_dTrackWidth;
|
|
baseProp[GB2312_To_UTF8("×óÖµ")] = pTrack->m_curve_left;
|
|
baseProp[GB2312_To_UTF8("ÓÒÖµ")] = pTrack->m_curve_right;
|
|
baseProp[GB2312_To_UTF8("±ê×¢¸ñʽ")] = pTrack->m_strFormat;
|
|
baseProp[GB2312_To_UTF8("¶ÔÊý")] = bool(pTrack->IsLog());
|
|
baseProp[GB2312_To_UTF8("ÏÔʾµÀÍ·¿Ì¶È")] = bool(pTrack->IsShowGridHead());
|
|
baseProp[GB2312_To_UTF8("ÏÔʾµÀÍ·¿Ì¶È")] = bool(pTrack->IsShowHeadLine());
|
|
baseProp[GB2312_To_UTF8("ÇúÏßÏÔʾÑùʽ")] = pTrack->GetCurveShowMode();
|
|
baseProp[GB2312_To_UTF8("µÀÍ·×ÖÌå")] = GB2312_To_UTF8(GetGdfFontStr(pTrack->m_font));
|
|
|
|
nlohmann::json gridJson;
|
|
gridJson["ÏÔʾºáÍø¸ñ"] = bool(pTrack->IsShowGridX());
|
|
gridJson["ÏÔʾ×ÝÍø¸ñ"] = bool(pTrack->IsShowGridY());
|
|
gridJson["Ö÷¿Ì¶È¸öÊý"] = pTrack->m_nMajorSpace;
|
|
gridJson["´Î¿Ì¶È¸öÊý"] = pTrack->m_nMinorSpace;
|
|
|
|
nlohmann::json fillJson;
|
|
int nInitfill = -1;
|
|
if (pTrack->IsFillStyleLeft())
|
|
nInitfill = 0;
|
|
else if (pTrack->IsFillStyleRight())
|
|
nInitfill = 1;
|
|
else if (pTrack->IsFillStyleLeftV())
|
|
nInitfill = 2;
|
|
else if (pTrack->IsFillStyleRightV())
|
|
nInitfill = 3;
|
|
|
|
fillJson[GB2312_To_UTF8("³äÌʽ")] = nInitfill;
|
|
int nInitbrush = 0;
|
|
if (pTrack->IsFillBrushColor())
|
|
{
|
|
nInitbrush = 1;
|
|
}
|
|
else if (pTrack->IsFillBrushPattern() || pTrack->IsFillBrushVector())
|
|
{
|
|
nInitbrush = 2;
|
|
}
|
|
else if (pTrack->IsFillBrushGradient())
|
|
{
|
|
nInitbrush = 3;
|
|
}
|
|
fillJson[GB2312_To_UTF8("»Ë¢ÀàÐÍ")] = nInitbrush;
|
|
|
|
fillJson[GB2312_To_UTF8("³äÌîÇúÏß")] = pTrack->m_strFillSideCurve;
|
|
fillJson[GB2312_To_UTF8("ÏÔʾ³äÌîÇúÏß")] = bool(pTrack->IsShowFillSideCurve());
|
|
fillJson[GB2312_To_UTF8("³äÌîÑÕÉ«")] = pf.ColorRefToHex(pTrack->m_fillClr);
|
|
fillJson[GB2312_To_UTF8("³äÌîµÀÍ·")] = bool(pTrack->IsShowHeadFill());
|
|
fillJson[GB2312_To_UTF8("³äÌî·ûºÅ")] = pTrack->m_strFillSymbol;
|
|
|
|
nlohmann::json curveStyleJson;
|
|
int tstyle = 1;
|
|
if (pTrack->IsShowStep())
|
|
tstyle = 2;
|
|
curveStyleJson["Ñùʽ"] = tstyle;
|
|
curveStyleJson["ÏßÐÍ"] = GetGdfPenStr(pTrack->m_penCurve);
|
|
|
|
nlohmann::json symbolJson;
|
|
symbolJson["É¢µã"] = bool(pTrack->IsShowDot());
|
|
symbolJson["·ûºÅ"] = pTrack->m_strDotSymbol;
|
|
symbolJson["·ûºÅ±ß¿òÑÕÉ«"] = pf.ColorRefToHex(pTrack->m_dotBorderClr);
|
|
symbolJson["·ûºÅÌî³äÑÕÉ«"] = pf.ColorRefToHex(pTrack->m_dotFillClr);
|
|
symbolJson["·ûºÅ´óС"] = pTrack->m_dotSize.cx;
|
|
|
|
nlohmann::json jsonProps;
|
|
jsonProps["baseProperties"] = baseProp;
|
|
jsonProps[GB2312_To_UTF8("ÇúÏßµÀ")] = baseProp;
|
|
jsonProps[GB2312_To_UTF8("Íø¸ñ")] = gridJson;
|
|
jsonProps[GB2312_To_UTF8("³äÌî")] = fillJson;
|
|
jsonProps[GB2312_To_UTF8("ÇúÏß·ç¸ñ")] = curveStyleJson;
|
|
jsonProps[GB2312_To_UTF8("·ûºÅ")] = symbolJson;
|
|
|
|
json["properties"] = jsonProps;
|
|
strJson = json.dump().c_str();
|
|
|
|
b = TRUE;
|
|
}
|
|
catch (nlohmann::json::parse_error& e)
|
|
{
|
|
return FALSE;
|
|
}
|
|
return b;
|
|
}
|
|
|
|
BOOL CWellObjectAttributesJson::SetCurveTrackAttributes(CTrackCurve* pTrack, CString& strJson)
|
|
{
|
|
BOOL b = FALSE;
|
|
|
|
return b;
|
|
}
|
|
|
|
BOOL CWellObjectAttributesJson::GetInTrackDataAttributes(CWellBaseObj* pDataBase, int inTrackType, CString& strJson)
|
|
{
|
|
BOOL b = FALSE;
|
|
|
|
return b;
|
|
}
|
|
|
|
BOOL CWellObjectAttributesJson::SetInTrackDataAttributes(CWellBaseObj* pDataBase, int inTrackType, CString& strJson)
|
|
{
|
|
BOOL b = FALSE;
|
|
|
|
return b;
|
|
} |