#include "stdafx.h" #include "WellPoleLib/WellBaseObj.h" #include "WellPoleLib/WellClassObjGroup.h" #include "WellPoleLib/InTrackDepthSegment.h" #include "WellPoleLib/WellPole.h" #include "WellPoleLib\InTrackResult.h" #include "WellPoleLib\InTrackLayerGroup.h" #include "MultiWellSectionLib/BendObj.h" #include "MultiWellSectionLib/FenceBendObj.h" #include "MultiWellSectionLib/FaultObj.h" #include "MultiWellSectionLib/SectionWellObj.h" #include "MultiWellSectionLib/WellSection.h" #include "ActionMoveSectionWellItem.h" #include "MultiWellSectionDoc.h" #include "MultiWellSectionlView.h" #include "ItemSectionWell.h" CActionMoveSectionWell::CActionMoveSectionWell(CSigmaDoc* ppDoc, UINT actionType) : CActionModifiedItem(ppDoc, actionType) { } CActionMoveSectionWell::CActionMoveSectionWell(CSigmaDoc* ppDoc, UINT actionType, const CPositionList& list, CWellBaseObj* pWellBase, CPoint2D delta) : CActionModifiedItem(ppDoc, actionType) { COne* pOne; POSITION pt, pos; pos = list.GetHeadPosition(); while (pos) { pt = list.GetNext(pos); CXy* pXy = GetDoc()->GetDraw(); pOne = pXy->GetAt(pt); if (pOne->GetType() == KEP_WELLSECTION) { AddCloneItem(pt, pOne, pWellBase,delta); break; } } } CActionMoveSectionWell::~CActionMoveSectionWell(void) { } bool CActionMoveSectionWell::AddCloneItem(POSITION pos, COne* pOne, CWellBaseObj* pWellBase, CPoint2D delta) { if (pos == NULL || pOne == NULL) return false; long index = GetDoc()->GetDraw()->GetElementIndex(pos); m_indexArray.Add(index); CWellBaseObj* pObj = (CWellBaseObj*)pOne->value; CWellSection* pSection = (CWellSection*)pObj; POSITION pos1 = pSection->m_WellList.GetHeadPosition(); int id = 0; while (pos1) { CWellBaseObj* pt = pSection->m_WellList.GetNext(pos1); if (pt == pWellBase) { m_WellPosInList.push_back(id); m_deltaPts.push_back(delta); break; } id++; } return true; } void CActionMoveSectionWell::PerformOperation(std::unique_ptr ModifiedEntry::* member) { PerformOperation(); } void CActionMoveSectionWell::PerformOperation(void) { GetDoc()->ClearSelection(); CRect8 range(1e100, -1e100, -1e100, 1e100); POSITION ps; long i = 0; for (int ii = 0; ii < m_indexArray.GetCount(); ii++) { ps = GetDoc()->GetDraw()->FindIndex(m_indexArray[i]); COne* pOne = GetDoc()->GetDraw()->GetAt(ps); if (pOne->GetType() == KEP_WELLSECTION) { CWellSection* pSection = (CWellSection*)pOne->value; //交换指针 int id = 0; POSITION wellpos = pSection->m_WellList.GetHeadPosition(); while (wellpos != NULL) { CWellPole* pThatWell = (CWellPole*)pSection->m_WellList.GetNext(wellpos); if (id == m_WellPosInList[ii]) { CPoint2D delta = m_deltaPts[ii]; delta.x0 = -delta.x0; delta.y0 = -delta.y0; //将移动位置反向一下 CItemSectionWell sectionWellItem(GetDoc()); sectionWellItem.MoveWellInSection(pSection,pThatWell , delta); pSection->ReSetPosition(); m_deltaPts[ii] = delta; break; } id++; } pSection->GetRange(range); i++; } } GetDoc()->Invalidate(); }