|
|
#include "stdafx.h"
|
|
|
|
|
|
#include "WellPoleLib/TrackGroup.h"
|
|
|
#include "WellPoleLib/WellPole.h"
|
|
|
|
|
|
#include "ActionWellTrackDeleteItem.h"
|
|
|
|
|
|
|
|
|
CActionWellTrackDeleteItem::CActionWellTrackDeleteItem(CSigmaDoc* ppDoc, UINT actionType, TRACKLIST& delTrackList)
|
|
|
: CActionItem(ppDoc, actionType)
|
|
|
{
|
|
|
m_bDeleted = false;
|
|
|
m_bPerformOperation = false;
|
|
|
|
|
|
GetTrackInfo(delTrackList);
|
|
|
|
|
|
RemoveOperation();//执行删除过程(就是保存删除的道),注意使用这个删除就不要使用itemSingelWell中的删除(它会真删除)
|
|
|
//PerformOperation();
|
|
|
}
|
|
|
|
|
|
CActionWellTrackDeleteItem::~CActionWellTrackDeleteItem(void)
|
|
|
{
|
|
|
if (m_bDeleted == true)
|
|
|
{
|
|
|
for (int ii =0; ii< int(m_DelTrackInfos.size()); ii++)
|
|
|
{
|
|
|
if (m_DelTrackInfos[ii].pDelTrack)
|
|
|
delete m_DelTrackInfos[ii].pDelTrack;
|
|
|
if (m_DelTrackInfos[ii].pParentGroup)
|
|
|
delete m_DelTrackInfos[ii].pParentGroup;
|
|
|
}
|
|
|
|
|
|
m_DelTrackInfos.clear();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void CActionWellTrackDeleteItem::Undo(void)
|
|
|
{
|
|
|
CActionItem::Undo();
|
|
|
AddOperation();
|
|
|
}
|
|
|
|
|
|
void CActionWellTrackDeleteItem::Redo(void)
|
|
|
{
|
|
|
CActionItem::Redo();
|
|
|
RemoveOperation();
|
|
|
}
|
|
|
void CActionWellTrackDeleteItem::Finish()
|
|
|
{
|
|
|
if (!m_bPerformOperation)
|
|
|
RemoveOperation();
|
|
|
CActionItem::Finish();
|
|
|
}
|
|
|
|
|
|
void CActionWellTrackDeleteItem::AddOperation()
|
|
|
{
|
|
|
m_bDeleted = false;
|
|
|
|
|
|
if (m_DelTrackInfos.size() < 1)
|
|
|
return;
|
|
|
|
|
|
for (int ii = 0; ii < int(m_DelTrackInfos.size()); ii++)
|
|
|
{
|
|
|
if (m_DelTrackInfos[ii].pParentGroup)
|
|
|
{
|
|
|
CTrackObj* pBrotherTrack = NULL;
|
|
|
//获得被删除道的兄弟道,并将这个道从其父组合道中删除
|
|
|
if ((*m_DelTrackInfos[ii].groupTrackTrackList.begin()) == m_DelTrackInfos[ii].pDelTrack)
|
|
|
{
|
|
|
pBrotherTrack = *m_DelTrackInfos[ii].groupTrackTrackList.end();
|
|
|
}
|
|
|
else
|
|
|
pBrotherTrack = *m_DelTrackInfos[ii].groupTrackTrackList.begin();
|
|
|
CTrackGroup* ppTrackG = (CTrackGroup*)pBrotherTrack->GetParent();
|
|
|
ppTrackG->RemoveTrack(ppTrackG);
|
|
|
|
|
|
m_DelTrackInfos[ii].pParentGroup->GetTrackList().clear();
|
|
|
m_DelTrackInfos[ii].pParentGroup->GetTrackList().assign(m_DelTrackInfos[ii].groupTrackTrackList.begin(), m_DelTrackInfos[ii].groupTrackTrackList.end());
|
|
|
ppTrackG = (CTrackGroup*)m_DelTrackInfos[ii].pParentGroup->GetParent();
|
|
|
ppTrackG->AddTarckToPos(m_DelTrackInfos[ii].m_iDelParentGroupPos, m_DelTrackInfos[ii].pParentGroup);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
CTrackGroup* ppTrackG = (CTrackGroup*)m_DelTrackInfos[ii].pDelTrack->GetParent();
|
|
|
ppTrackG->AddTarckToPos(m_DelTrackInfos[ii].m_iDelTrackPos,m_DelTrackInfos[ii].pDelTrack);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
CTrackGroup* pTrackG = (CTrackGroup*)(m_DelTrackInfos[0].pDelTrack->GetParent());
|
|
|
CWellPole* pWell = pTrackG->GetWell();
|
|
|
CPoint2D ptf = pWell->GetAnchorPoint(); //->GetPos().TopLeft();
|
|
|
pWell->CalculateSize(ptf);
|
|
|
}
|
|
|
void CActionWellTrackDeleteItem::RemoveOperation()
|
|
|
{
|
|
|
m_bDeleted = true;
|
|
|
|
|
|
if (m_DelTrackInfos.size() < 1)
|
|
|
return;
|
|
|
|
|
|
for (int ii = 0; ii < int(m_DelTrackInfos.size()); ii++)
|
|
|
{
|
|
|
if (m_DelTrackInfos[ii].pParentGroup)
|
|
|
{
|
|
|
CTrackGroup* ppTrackG = (CTrackGroup*)m_DelTrackInfos[ii].pParentGroup;
|
|
|
ppTrackG->RemoveTrack(m_DelTrackInfos[ii].pParentGroup);
|
|
|
m_DelTrackInfos[ii].pParentGroup->GetTrackList().clear(); //移走父道的同时清空其子链表
|
|
|
|
|
|
CTrackObj* pBrotherTrack = NULL;
|
|
|
//获得被删除道的兄弟道,并将这个道插入父组合道的位置
|
|
|
if ((*m_DelTrackInfos[ii].groupTrackTrackList.begin()) == m_DelTrackInfos[ii].pDelTrack)
|
|
|
{
|
|
|
pBrotherTrack = *m_DelTrackInfos[ii].groupTrackTrackList.end();
|
|
|
}
|
|
|
else
|
|
|
pBrotherTrack = *m_DelTrackInfos[ii].groupTrackTrackList.begin();
|
|
|
|
|
|
ppTrackG->AddTarckToPos(m_DelTrackInfos[ii].m_iDelParentGroupPos, pBrotherTrack);
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
CTrackGroup* ppTrackG =(CTrackGroup*)m_DelTrackInfos[ii].pDelTrack->GetParent();
|
|
|
ppTrackG->RemoveTrack(m_DelTrackInfos[ii].pDelTrack);
|
|
|
}
|
|
|
}
|
|
|
CTrackGroup* pTrackG = (CTrackGroup*)(m_DelTrackInfos[0].pDelTrack->GetParent());
|
|
|
CWellPole* pWell = pTrackG->GetWell();
|
|
|
CPoint2D ptf = pWell->GetAnchorPoint(); //->GetPos().TopLeft();
|
|
|
pWell->CalculateSize(ptf);
|
|
|
}
|
|
|
|
|
|
void CActionWellTrackDeleteItem::GetTrackInfo(TRACKLIST& delTrackList)
|
|
|
{
|
|
|
DELTRACKINFO delTrackInfo;
|
|
|
|
|
|
TRACKLIST::iterator it = delTrackList.begin();
|
|
|
for (; it != delTrackList.end(); it++)
|
|
|
{
|
|
|
CTrackGroup* pTrackG = (CTrackGroup*)(*it)->GetParent();
|
|
|
|
|
|
if (pTrackG->GetTrackList().size() == 2 && pTrackG->GetType() != KEP_WELL)
|
|
|
{//此时删除一个道,会引发其父道的删除,并将兄弟道替补父亲道的行为,因此记录父亲道的信息
|
|
|
delTrackInfo.pDelTrack = *it;
|
|
|
delTrackInfo.m_iDelTrackPos = pTrackG->GetTrackPosInList(*it);
|
|
|
delTrackInfo.pParentGroup = pTrackG;
|
|
|
|
|
|
CTrackGroup* ppTrackG = (CTrackGroup*)pTrackG->GetParent();
|
|
|
delTrackInfo.m_iDelParentGroupPos = ppTrackG->GetTrackPosInList(pTrackG);
|
|
|
delTrackInfo.groupTrackTrackList.clear();
|
|
|
delTrackInfo.groupTrackTrackList.assign(pTrackG->GetTrackList().begin(), pTrackG->GetTrackList().end());//父道中的道链表保存起来,
|
|
|
|
|
|
m_DelTrackInfos.push_back(delTrackInfo);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
delTrackInfo.pDelTrack = *it;
|
|
|
delTrackInfo.m_iDelTrackPos = pTrackG->GetTrackPosInList(*it);
|
|
|
delTrackInfo.pParentGroup = NULL;
|
|
|
delTrackInfo.m_iDelParentGroupPos = -1;
|
|
|
delTrackInfo.groupTrackTrackList.clear();
|
|
|
|
|
|
m_DelTrackInfos.push_back(delTrackInfo);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
void NAction::CActionWellTrackDeleteItem::accept(CActionVisitor& visitor)
|
|
|
{
|
|
|
//visitor.visit(*this);
|
|
|
} |