|
|
#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;
|
|
|
// Éú³ÉÊý¾Ý
|
|
|
for (int i = 0; i < nElementCount; i++) {
|
|
|
WellGroupBranchStruct branchInfo = branchCopys[i];
|
|
|
COne* pOne = pXy->GetAt(branchInfo.DataPosition);
|
|
|
// Æ«ÒÆÏß
|
|
|
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) {
|
|
|
// // ÒÆ¶¯µÄÊÇÈë°Ðµã
|
|
|
// 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) { // ÒÆ¶¯³ö°Ðµã
|
|
|
// 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) { // ÒÆ¶¯¾®µã
|
|
|
// 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) {
|
|
|
// ˮƽ¶Î±»Òƶ¯
|
|
|
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) {
|
|
|
// ÒÆ¶¯µÄÊÇÈë°Ðµã
|
|
|
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) { // ÒÆ¶¯³ö°Ðµã
|
|
|
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) { // ÒÆ¶¯¾®µã
|
|
|
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); // ±»Ñ¡ÖеÄͼԪÁбí
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
///
|
|
|
/// ¿Ë¡¾®×éÊý¾Ý
|
|
|
///
|
|
|
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();
|
|
|
// ¿Ë¡ģ°æ
|
|
|
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;
|
|
|
|
|
|
// Èç¹û¾®Ö§Êý²»Í¬£¬Ôò²»½øÐпË¡
|
|
|
//int branchCount = pWellDest->WellBranches.size();
|
|
|
if (leftCountDes != leftCount || rightCountDes != rightCount)
|
|
|
{
|
|
|
values->GetNext(pos);
|
|
|
continue;
|
|
|
}
|
|
|
// Ìí¼Ó³·Ïú¹¦ÄÜ
|
|
|
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;
|
|
|
|
|
|
// ¸´Öƾ®×éÊý¾Ý
|
|
|
*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++;
|
|
|
// ³·Ïú»Ö¸´
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
// ´´½¨Ò»¸öXMLµÄÎĵµ¶ÔÏó¡£
|
|
|
TiXmlDocument *xmlDocument = new TiXmlDocument();
|
|
|
TiXmlDeclaration * decl = new TiXmlDeclaration("1.0", "UTF-8", "");
|
|
|
xmlDocument->LinkEndChild(decl);
|
|
|
// ¸ùÔªËØ¡£
|
|
|
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("¾®ºÅ");
|
|
|
itemElement->LinkEndChild(nameElement);
|
|
|
TiXmlText *nameValue = new TiXmlText(strName);
|
|
|
nameElement->LinkEndChild(nameValue);
|
|
|
|
|
|
TiXmlElement *nameStart = new TiXmlElement("Èë°Ðµã");
|
|
|
itemElement->LinkEndChild(nameStart);
|
|
|
strText = branch->PointStart.GetName();
|
|
|
TiXmlText *startValue = new TiXmlText(strText);
|
|
|
nameStart->LinkEndChild(startValue);
|
|
|
|
|
|
TiXmlElement *nameStartX = new TiXmlElement("Èë°ÐµãX");
|
|
|
itemElement->LinkEndChild(nameStartX);
|
|
|
AfxGetPublicFunction()->FloatToString(strText, branch->PointStart.x0, decimal);
|
|
|
TiXmlText *startX = new TiXmlText(strText);
|
|
|
nameStartX->LinkEndChild(startX);
|
|
|
|
|
|
TiXmlElement *nameStartY = new TiXmlElement("Èë°ÐµãY");
|
|
|
itemElement->LinkEndChild(nameStartY);
|
|
|
AfxGetPublicFunction()->FloatToString(strText, branch->PointStart.y0, decimal);
|
|
|
TiXmlText *startY = new TiXmlText(strText);
|
|
|
nameStartY->LinkEndChild(startY);
|
|
|
|
|
|
TiXmlElement *nameEnd = new TiXmlElement("³ö°Ðµã");
|
|
|
itemElement->LinkEndChild(nameEnd);
|
|
|
strText = branch->PointEnd.GetName();
|
|
|
TiXmlText *EndValue = new TiXmlText(strText);
|
|
|
nameEnd->LinkEndChild(EndValue);
|
|
|
|
|
|
TiXmlElement *nameEndX = new TiXmlElement("³ö°ÐµãX");
|
|
|
itemElement->LinkEndChild(nameEndX);
|
|
|
AfxGetPublicFunction()->FloatToString(strText, branch->PointEnd.x0, decimal);
|
|
|
TiXmlText *endX = new TiXmlText(strText);
|
|
|
nameEndX->LinkEndChild(endX);
|
|
|
|
|
|
TiXmlElement *nameEndY = new TiXmlElement("³ö°ÐµãY");
|
|
|
itemElement->LinkEndChild(nameEndY);
|
|
|
AfxGetPublicFunction()->FloatToString(strText, branch->PointEnd.y0, decimal);
|
|
|
TiXmlText *endY = new TiXmlText(strText);
|
|
|
nameEndY->LinkEndChild(endY);
|
|
|
|
|
|
// ¼ÆËã´¹Ö±°Ðǰ¾à
|
|
|
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;
|
|
|
|
|
|
// °ÐÇ°Î»ÒÆ
|
|
|
double dOffsetLength = sqrt(xAB*xAB + yAB * yAB);
|
|
|
TiXmlElement *branchOffset = new TiXmlElement("°ÐÇ°Î»ÒÆ");
|
|
|
itemElement->LinkEndChild(branchOffset);
|
|
|
AfxGetPublicFunction()->FloatToString(strText, dOffsetLength, decimal);
|
|
|
TiXmlText *valueBranchOffset = new TiXmlText(strText);
|
|
|
branchOffset->LinkEndChild(valueBranchOffset);
|
|
|
// ´¹Ö±°Ðǰ¾à
|
|
|
TiXmlElement *nameOffsetDist = new TiXmlElement("´¹Ö±°Ðǰ¾à");
|
|
|
itemElement->LinkEndChild(nameOffsetDist);
|
|
|
AfxGetPublicFunction()->FloatToString(strText, distOffset, decimal);
|
|
|
TiXmlText *valueDist = new TiXmlText(strText);
|
|
|
nameOffsetDist->LinkEndChild(valueDist);
|
|
|
|
|
|
// ¾®Ö§³¤¶È
|
|
|
double dBranchLength = sqrt(xCD * xCD + yCD * yCD);
|
|
|
TiXmlElement *branchLength = new TiXmlElement("¾®Ö§³¤¶È");
|
|
|
itemElement->LinkEndChild(branchLength);
|
|
|
AfxGetPublicFunction()->FloatToString(strText, dBranchLength, decimal);
|
|
|
TiXmlText *valueBranchLength = new TiXmlText(strText);
|
|
|
branchLength->LinkEndChild(valueBranchLength);
|
|
|
|
|
|
// ¾®Ö§½Ç¶È
|
|
|
double dBranchAngle = 0;
|
|
|
if (xCD == 0) {
|
|
|
dBranchAngle = 90;
|
|
|
}
|
|
|
else {
|
|
|
dBranchAngle = atan(yCD / xCD);
|
|
|
dBranchAngle = dBranchAngle * 180 / PI;
|
|
|
}
|
|
|
TiXmlElement *branchAngle = new TiXmlElement("¾®Ö§½Ç¶È");
|
|
|
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();
|
|
|
}
|