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/InterfaceWellGroupEditor.cpp

589 lines
18 KiB
C++

1 month ago
#include "stdafx.h"
#include "SigmaView.h"
#include "SectionDoc.h"
#include "ItemWellGroupEdit.h"
#include "ActionAddItem.h"
#include "ActionListItem.h"
#include ".\actionmodifieditem.h"
#include ".\actionbackupitem.h"
#include"TinyXml/tinyxml.h"
using namespace NBase;
extern "C" __declspec(dllexport)
int WellGroupEditSetData(CSigmaView * pView, BYTE* buffElement, int buffLen)
{
CItem * pItem = pView->GetItem();
if (pItem == NULL)
return 0;
CItemWellGroupEdit * itemEdit = dynamic_cast<CItemWellGroupEdit *>(pItem);
if (itemEdit == NULL)
return 0;
itemEdit->SetData(buffElement, buffLen);
return 1;
}
extern "C" __declspec(dllexport)
int WellGroupEditGetData(CSigmaView * pView, BYTE*& buffElement, int& buffLen)
{
int nElementCount = (int)pView->m_pDoc->m_BranchElements.size();
if (nElementCount == 0) {
return 0;
}
CWellGroup* pWellGroup = new CWellGroup;
COne* pOne = pView->m_pDoc->GetDraw()->CreateOne(pWellGroup, WELL_GROUP);
CXy* pXy = pView->m_pDoc->m_pXy;
vector<WellGroupBranchStruct> branchCopys;
for (int i = 0; i < nElementCount; i++) {
WellGroupBranchStruct branch = pView->m_pDoc->m_BranchElements[i];
//if(branch.)
WellGroupBranchStruct branchCopy;
branchCopy.BranchIndex = branch.BranchIndex;
branchCopy.DataPosition = branch.DataPosition;
branchCopy.DataType = branch.DataType;
branchCopys.push_back(branchCopy);
}
std::sort(branchCopys.begin(), branchCopys.end()
, [](const WellGroupBranchStruct& branchA, const WellGroupBranchStruct& branchB) {
if (branchA.BranchIndex == branchB.BranchIndex) {
return branchA.DataType < branchB.DataType;
}
return branchA.BranchIndex < branchB.BranchIndex;
});
int nCurrIndex = -1;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (int i = 0; i < nElementCount; i++) {
WellGroupBranchStruct branchInfo = branchCopys[i];
COne* pOne = pXy->GetAt(branchInfo.DataPosition);
// ƫ<><C6AB><EFBFBD><EFBFBD>
if (branchInfo.DataType == 0) {
CCurveEx* pCurveOffset = (CCurveEx*)pOne->value;
pWellGroup->x0 = pCurveOffset->x[0];
pWellGroup->y0 = pCurveOffset->y[0];
CPointNameEx ptStart, ptEnd;
CWellBranch* wellBranch = new CWellBranch;
if (pOne->HowToViewCurve != nullptr) {
CHowToViewCurve* pHwOffset = new CHowToViewCurve;
*pHwOffset = *pOne->HowToViewCurve;
wellBranch->m_pHowTowViewCurveOffset = pHwOffset;
}
for (int j = i + 1; j < nElementCount; j++) {
WellGroupBranchStruct branchHori = branchCopys[j];
if (branchHori.BranchIndex == branchInfo.BranchIndex)
{
i++;
COne* pOneOther = pXy->GetAt(branchHori.DataPosition);
if (pOneOther->HowToViewCurve != nullptr) {
CHowToViewCurve* pHwHori = new CHowToViewCurve;
*pHwHori = *pOneOther->HowToViewCurve;
wellBranch->m_pHowTowViewCurveHori = pHwHori;
}
CCurveEx* pCurveHori = (CCurveEx*)pOneOther->value;
wellBranch->PointStart.x0 = pCurveHori->x[0];
wellBranch->PointStart.y0 = pCurveHori->y[0];
wellBranch->PointEnd.x0 = pCurveHori->x[1];
wellBranch->PointEnd.y0 = pCurveHori->y[1];
break;
}
}
pWellGroup->WellBranches.push_back(wellBranch);
nCurrIndex++;
}
else if (branchInfo.DataType == 2) {
CPointNameEx* ptStart = (CPointNameEx*)(pOne->value);
pWellGroup->WellBranches[nCurrIndex]->PointStart = *ptStart;
if (pOne->HowToViewPoint != nullptr) {
CHowToViewPoint* pHwp = new CHowToViewPoint;
*pHwp = *pOne->HowToViewPoint;
pWellGroup->WellBranches[nCurrIndex]->m_pHowTowViewPointStart = pHwp;
}
}
else if (branchInfo.DataType == 3) {
CPointNameEx* ptStart = (CPointNameEx*)(pOne->value);
pWellGroup->WellBranches[nCurrIndex]->PointEnd = *ptStart;
if (pOne->HowToViewPoint != nullptr) {
CHowToViewPoint* pHwp = new CHowToViewPoint;
*pHwp = *pOne->HowToViewPoint;
pWellGroup->WellBranches[nCurrIndex]->m_pHowTowViewPointEnd = pHwp;
}
}
else if (branchInfo.DataType == 4)
{
CPointNameEx* pWell = (CPointNameEx*)pOne->value;
pWellGroup->SetName(pWell->GetName());
if (pOne->HowToViewPoint != nullptr) {
CHowToViewPoint* pHwp = new CHowToViewPoint;
*pHwp = *pOne->HowToViewPoint;
pWellGroup->m_pHowTowViewPointWell = pHwp;
}
}
}
pOne->WriteMemory(buffElement, 0, buffLen, 3);
return 1;
}
//extern "C" __declspec(dllexport)
//int WellGroupEditMovePoint(CSigmaView * pView, POSITION elementPos)
//{
// int nElementCount = pView->m_pDoc->m_BranchElements.size();
// if (nElementCount == 0) {
// return 0;
// }
// COne* pOneMoved = pView->m_pDoc->GetDraw()->GetAt(elementPos);
// CPointNameEx* ptMoved = (CPointNameEx*)pOneMoved->value;
//
// for (int i = 0; i < nElementCount; i++)
// {
// WellGroupBranchStruct branch = pView->m_pDoc->m_BranchElements[i];
// if (branch.DataPosition == elementPos) {
// // <20>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>
// if (branch.DataType == 2) {
// for (const auto &branchFind : pView->m_pDoc->m_BranchElements)
// {
// if (branchFind.BranchIndex == branch.BranchIndex
// && branchFind.DataType == 0) {
// COne* pOne = pView->m_pDoc->GetDraw()->GetAt(branchFind.DataPosition);
// CCurveEx* pCurve = (CCurveEx*)pOne->value;
// pCurve->x[1] = ptMoved->x0;
// pCurve->y[1] = ptMoved->y0;
// }
// else if (branchFind.BranchIndex == branch.BranchIndex
// && branchFind.DataType == 1)
// {
// COne* pOne = pView->m_pDoc->GetDraw()->GetAt(branchFind.DataPosition);
// CCurveEx* pCurve = (CCurveEx*)pOne->value;
// pCurve->x[0] = ptMoved->x0;
// pCurve->y[0] = ptMoved->y0;
// }
// }
// }
// else if (branch.DataType == 3) { // <20>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>е<EFBFBD>
// for (const auto &branchFind : pView->m_pDoc->m_BranchElements)
// {
// if (branchFind.BranchIndex == branch.BranchIndex
// && branchFind.DataType == 1) {
// COne* pOne = pView->m_pDoc->GetDraw()->GetAt(branchFind.DataPosition);
// CCurveEx* pCurve = (CCurveEx*)pOne->value;
// pCurve->x[1] = ptMoved->x0;
// pCurve->y[1] = ptMoved->y0;
// }
// }
// }
// else if (branch.DataType == 4) { // <20>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>
// for (const auto &branchFind : pView->m_pDoc->m_BranchElements)
// {
// if (branchFind.DataType == 0) {
// COne* pOne = pView->m_pDoc->GetDraw()->GetAt(branchFind.DataPosition);
// CCurveEx* pCurve = (CCurveEx*)pOne->value;
// pCurve->x[0] = ptMoved->x0;
// pCurve->y[0] = ptMoved->y0;
// }
// }
// }
// break;
// }
// }
// return 1;
//}
extern "C" __declspec(dllexport)
int WellGroupEditMoveElement(CSigmaView * pView, POSITION elementPos)
{
int nElementCount = (int)pView->m_pDoc->m_BranchElements.size();
if (nElementCount == 0) {
return 0;
}
COne* pOneMoved = pView->m_pDoc->GetDraw()->GetAt(elementPos);
if (pOneMoved->GetType() == DOUBLEFOX_CURVE) {
CCurveEx* pCurve = (CCurveEx*)pOneMoved->value;
for (int i = 0; i < nElementCount; i++)
{
WellGroupBranchStruct branch = pView->m_pDoc->m_BranchElements[i];
if (branch.DataPosition == elementPos) {
// ˮƽ<CBAE>α<EFBFBD><CEB1>ƶ<EFBFBD>
if (branch.DataType == 1)
{
for (const auto &branchFind : pView->m_pDoc->m_BranchElements)
{
if (branchFind.BranchIndex == branch.BranchIndex) {
if (branchFind.DataType == 0)
{
COne* pOneOffset = pView->m_pDoc->GetDraw()->GetAt(branchFind.DataPosition);
CCurveEx* pCurveOffset = (CCurveEx*)pOneOffset->value;
pCurveOffset->x[1] = pCurve->x[0];
pCurveOffset->y[1] = pCurve->y[0];
}
else if (branchFind.DataType == 2)
{
COne* pOneOffset = pView->m_pDoc->GetDraw()->GetAt(branchFind.DataPosition);
CPointNameEx* pPtStart = (CPointNameEx*)pOneOffset->value;
pPtStart->x0 = pCurve->x[0];
pPtStart->y0 = pCurve->y[0];
}
else if (branchFind.DataType == 3) {
COne* pOneOffset = pView->m_pDoc->GetDraw()->GetAt(branchFind.DataPosition);
CPointNameEx* pPtStart = (CPointNameEx*)pOneOffset->value;
pPtStart->x0 = pCurve->x[1];
pPtStart->y0 = pCurve->y[1];
}
}
}
}
break;
}
}
}
else if (pOneMoved->GetType() == DOUBLEFOX_POINT)
{
CPointNameEx* ptMoved = (CPointNameEx*)pOneMoved->value;
for (int i = 0; i < nElementCount; i++)
{
WellGroupBranchStruct branch = pView->m_pDoc->m_BranchElements[i];
if (branch.DataPosition == elementPos) {
// <20>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>
if (branch.DataType == 2) {
for (const auto &branchFind : pView->m_pDoc->m_BranchElements)
{
if (branchFind.BranchIndex == branch.BranchIndex
&& branchFind.DataType == 0) {
COne* pOne = pView->m_pDoc->GetDraw()->GetAt(branchFind.DataPosition);
CCurveEx* pCurve = (CCurveEx*)pOne->value;
pCurve->x[1] = ptMoved->x0;
pCurve->y[1] = ptMoved->y0;
}
else if (branchFind.BranchIndex == branch.BranchIndex
&& branchFind.DataType == 1)
{
COne* pOne = pView->m_pDoc->GetDraw()->GetAt(branchFind.DataPosition);
CCurveEx* pCurve = (CCurveEx*)pOne->value;
pCurve->x[0] = ptMoved->x0;
pCurve->y[0] = ptMoved->y0;
}
}
}
else if (branch.DataType == 3) { // <20>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>е<EFBFBD>
for (const auto &branchFind : pView->m_pDoc->m_BranchElements)
{
if (branchFind.BranchIndex == branch.BranchIndex
&& branchFind.DataType == 1) {
COne* pOne = pView->m_pDoc->GetDraw()->GetAt(branchFind.DataPosition);
CCurveEx* pCurve = (CCurveEx*)pOne->value;
pCurve->x[1] = ptMoved->x0;
pCurve->y[1] = ptMoved->y0;
}
}
}
else if (branch.DataType == 4) { // <20>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>
for (const auto &branchFind : pView->m_pDoc->m_BranchElements)
{
if (branchFind.DataType == 0) {
COne* pOne = pView->m_pDoc->GetDraw()->GetAt(branchFind.DataPosition);
CCurveEx* pCurve = (CCurveEx*)pOne->value;
pCurve->x[0] = ptMoved->x0;
pCurve->y[0] = ptMoved->y0;
}
}
}
break;
}
}
}
return 1;
}
extern "C" __declspec(dllexport)
int WellGroupEditMoveElementS(CSigmaView * pView)
{
CItem * pItem = pView->GetItem();
if (pItem == NULL)
return 0;
CItemWellGroupEdit * pItemEdit = dynamic_cast<CItemWellGroupEdit *>(pItem);
if (pItemEdit == NULL)
return 0;
CPositionList* pSelects = &(pItemEdit->m_selection); // <20><>ѡ<EFBFBD>е<EFBFBD>ͼԪ<CDBC>б<EFBFBD>
POSITION pos, pt;
pos = pSelects->GetHeadPosition();
while (pos != NULL)
{
pt = pSelects->GetNext(pos);
WellGroupEditMoveElement(pView, pt);
}
return 1;
}
extern "C" __declspec(dllexport)
double XyGetCurveLength(CXy* pXy, POSITION pos)
{
COne* pOne = pXy->GetAt(pos);
if (pOne == nullptr) {
return 0;
}
CCurveEx* pCurve = (CCurveEx*)pOne->value;
if (pCurve == nullptr) {
return 0;
}
return pCurve->Length();
}
extern "C" __declspec(dllexport)
void SetBranchHorizonLength(CSigmaView * pView,double curveLength, POSITION elementPos)
{
CItem * pItem = pView->GetItem();
if (pItem == NULL)
return;
CItemWellGroupEdit * itemEdit = dynamic_cast<CItemWellGroupEdit *>(pItem);
if (itemEdit == NULL)
return;
itemEdit->SetBranchHorizonLength(curveLength, elementPos);
}
///
/// <20><>¡<EFBFBD><C2A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
///
extern "C" __declspec(dllexport)
bool WellGroupClone(CSigmaView* pView, POSITION posSelect)
{
CItem * pItem = pView->GetItem();
if (pItem == NULL)
return nullptr;
CItemSelect * itemSelect = dynamic_cast<CItemSelect *>(pItem);
if (itemSelect == nullptr || itemSelect->m_selection.IsEmpty()) {
return nullptr;
}
pView->m_pDoc->SaveActionPosition();
POSITION pos = (itemSelect->m_selection).GetHeadPosition();
// <20><>¡ģ<C2A1><C4A3>
POSITION posElement = itemSelect->m_selection.GetAt(pos);
CXy* pXy = pView->m_pDoc->m_pXy;
COne* pOne = pXy->GetAt(posElement);
CWellGroup* pGroup = (CWellGroup*)pOne->value;
int selBranchCount = pGroup->WellBranches.size();
double dSelX = pGroup->x0;
double dSelY = pGroup->y0;
int leftCount = pGroup->m_pParameter->BranchCountLeft;
int rightCount = pGroup->m_pParameter->BranchCountRight;
CPtrList * values = pXy->GetValueList();
pos = values->GetHeadPosition();
CActionListItem* pAction = new CActionListItem(pView->m_pDoc, ID_PROCESS_CURVE_ENCRYPT);
int nCount = 0;
while (pos)
{
if (pos == posElement)
{
values->GetNext(pos);
continue;
}
COne* pOne = pXy->GetAt(pos);
if (pOne->GetType() == WELL_GROUP)
{
CWellGroup* pWellDest = (CWellGroup*)pOne->value;
if (pWellDest->m_pParameter == nullptr)
{
continue;
}
int leftCountDes = pWellDest->m_pParameter->BranchCountLeft;
int rightCountDes = pWellDest->m_pParameter->BranchCountRight;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD>򲻽<EFBFBD><F2B2BBBD>п<EFBFBD>¡
//int branchCount = pWellDest->WellBranches.size();
if (leftCountDes != leftCount || rightCountDes != rightCount)
{
values->GetNext(pos);
continue;
}
// <20><><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CActionModifiedItem* pModifiedItem = new CActionModifiedItem(pView->m_pDoc, IDS_STRING_CURVE);
pModifiedItem->BackupOldItem(pos, pOne);
CWellGroup wellOld;
wellOld = *pWellDest;
double dXOld = pWellDest->x0;
double dYOld = pWellDest->y0;
double dXOffset = dXOld - dSelX;
double dYOffset = dYOld - dSelY;
// <20><><EFBFBD>ƾ<EFBFBD><C6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*pWellDest = *pGroup;
pWellDest->Offset(dXOffset, dYOffset);
pWellDest->SetName(wellOld.GetName());
for (int i = 0; i < pWellDest->WellBranches.size(); i++)
{
if (wellOld.WellBranches.size() > i)
{
CString strStartName = wellOld.WellBranches[i]->PointStart.GetName();
pWellDest->WellBranches[i]->PointStart.SetName(strStartName);
CString strEndName = wellOld.WellBranches[i]->PointEnd.GetName();
pWellDest->WellBranches[i]->PointEnd.SetName(strEndName);
}
}
nCount++;
// <20><><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>
pModifiedItem->BackupNewItem();
pAction->AddTailItem(pModifiedItem);
}
values->GetNext(pos);
}
if (nCount > 0)
{
pView->m_pDoc->SetActionItem(pAction);
}
else
{
delete pAction;
}
return true;
}
extern "C" __declspec(dllexport)
BSTR WellGroupStatistic(CSigmaView* pView) {
CItem * pItem = pView->GetItem();
if (pItem == NULL)
return nullptr;
CItemSelect * itemSelect = dynamic_cast<CItemSelect *>(pItem);
if (itemSelect == nullptr || itemSelect->m_selection.IsEmpty()) {
return nullptr;
}
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>XML<4D><4C><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TiXmlDocument *xmlDocument = new TiXmlDocument();
TiXmlDeclaration * decl = new TiXmlDeclaration("1.0", "UTF-8", "");
xmlDocument->LinkEndChild(decl);
// <20><>Ԫ<EFBFBD>ء<EFBFBD>
TiXmlElement *rootElement = new TiXmlElement("ROOT");
xmlDocument->LinkEndChild(rootElement);
int decimal = 6;
CXy* pXy = pView->m_pDoc->m_pXy;
for (POSITION pos = (itemSelect->m_selection).GetHeadPosition(); pos != nullptr; (itemSelect->m_selection).GetNext(pos))
{
CString strText;
POSITION pt = itemSelect->m_selection.GetAt(pos);
COne* pOne = pXy->GetAt(pt);
if (pOne->GetType() == WELL_GROUP)
{
CWellGroup* pGroup = (CWellGroup*)pOne->value;
CString strName = pGroup->GetName();
for (const auto &branch : pGroup->WellBranches)
{
TiXmlElement *itemElement = new TiXmlElement("Item");
rootElement->LinkEndChild(itemElement);
TiXmlElement *nameElement = new TiXmlElement("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
itemElement->LinkEndChild(nameElement);
TiXmlText *nameValue = new TiXmlText(strName);
nameElement->LinkEndChild(nameValue);
TiXmlElement *nameStart = new TiXmlElement("<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>");
itemElement->LinkEndChild(nameStart);
strText = branch->PointStart.GetName();
TiXmlText *startValue = new TiXmlText(strText);
nameStart->LinkEndChild(startValue);
TiXmlElement *nameStartX = new TiXmlElement("<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>X");
itemElement->LinkEndChild(nameStartX);
AfxGetPublicFunction()->FloatToString(strText, branch->PointStart.x0, decimal);
TiXmlText *startX = new TiXmlText(strText);
nameStartX->LinkEndChild(startX);
TiXmlElement *nameStartY = new TiXmlElement("<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>Y");
itemElement->LinkEndChild(nameStartY);
AfxGetPublicFunction()->FloatToString(strText, branch->PointStart.y0, decimal);
TiXmlText *startY = new TiXmlText(strText);
nameStartY->LinkEndChild(startY);
TiXmlElement *nameEnd = new TiXmlElement("<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>");
itemElement->LinkEndChild(nameEnd);
strText = branch->PointEnd.GetName();
TiXmlText *EndValue = new TiXmlText(strText);
nameEnd->LinkEndChild(EndValue);
TiXmlElement *nameEndX = new TiXmlElement("<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>X");
itemElement->LinkEndChild(nameEndX);
AfxGetPublicFunction()->FloatToString(strText, branch->PointEnd.x0, decimal);
TiXmlText *endX = new TiXmlText(strText);
nameEndX->LinkEndChild(endX);
TiXmlElement *nameEndY = new TiXmlElement("<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>Y");
itemElement->LinkEndChild(nameEndY);
AfxGetPublicFunction()->FloatToString(strText, branch->PointEnd.y0, decimal);
TiXmlText *endY = new TiXmlText(strText);
nameEndY->LinkEndChild(endY);
// <20><><EFBFBD>㴹ֱ<E3B4B9><D6B1>ǰ<EFBFBD><C7B0>
double xA = pGroup->x0;
double yA = pGroup->y0;
double xB = branch->PointStart.x0;
double yB = branch->PointStart.y0;
double xC = xB;
double yC = yB;
double xD = branch->PointEnd.x0;
double yD = branch->PointEnd.y0;
double xAB = xB - xA;
double yAB = yB - yA;
double xCD = xD - xC;
double yCD = yD - yC;
double cos = (xAB*xCD + yAB * yCD) / sqrt((xAB*xAB + yAB * yAB)*(xCD*xCD+yCD*yCD));
double distOffset = sqrt(xAB*xAB + yAB * yAB)*cos;
// <20><>ǰλ<C7B0><CEBB>
double dOffsetLength = sqrt(xAB*xAB + yAB * yAB);
TiXmlElement *branchOffset = new TiXmlElement("<EFBFBD><EFBFBD>ǰλ<EFBFBD><EFBFBD>");
itemElement->LinkEndChild(branchOffset);
AfxGetPublicFunction()->FloatToString(strText, dOffsetLength, decimal);
TiXmlText *valueBranchOffset = new TiXmlText(strText);
branchOffset->LinkEndChild(valueBranchOffset);
// <20><>ֱ<EFBFBD><D6B1>ǰ<EFBFBD><C7B0>
TiXmlElement *nameOffsetDist = new TiXmlElement("<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>");
itemElement->LinkEndChild(nameOffsetDist);
AfxGetPublicFunction()->FloatToString(strText, distOffset, decimal);
TiXmlText *valueDist = new TiXmlText(strText);
nameOffsetDist->LinkEndChild(valueDist);
// <20><>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>
double dBranchLength = sqrt(xCD * xCD + yCD * yCD);
TiXmlElement *branchLength = new TiXmlElement("<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
itemElement->LinkEndChild(branchLength);
AfxGetPublicFunction()->FloatToString(strText, dBranchLength, decimal);
TiXmlText *valueBranchLength = new TiXmlText(strText);
branchLength->LinkEndChild(valueBranchLength);
// <20><>֧<EFBFBD>Ƕ<EFBFBD>
double dBranchAngle = 0;
if (xCD == 0) {
dBranchAngle = 90;
}
else {
dBranchAngle = atan(yCD / xCD);
dBranchAngle = dBranchAngle * 180 / PI;
}
TiXmlElement *branchAngle = new TiXmlElement("<EFBFBD><EFBFBD>֧<EFBFBD>Ƕ<EFBFBD>");
itemElement->LinkEndChild(branchAngle);
AfxGetPublicFunction()->FloatToString(strText, dBranchAngle, decimal);
TiXmlText *valueBranchAngle = new TiXmlText(strText);
branchAngle->LinkEndChild(valueBranchAngle);
}
}
}
TiXmlPrinter printer;
xmlDocument->Accept(&printer);
CString strReturn("");
strReturn = CString(printer.CStr());
delete xmlDocument;
xmlDocument = nullptr;
return strReturn.AllocSysString();
}