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.
104 lines
2.2 KiB
C++
104 lines
2.2 KiB
C++
|
1 month ago
|
#include "stdafx.h"
|
||
|
|
#include "WellPoleLib/WellPole.h"
|
||
|
|
#include "ActionWellTrackAddItem.h"
|
||
|
|
#include "../Visitor.h"
|
||
|
|
|
||
|
|
CActionWellTrackAddItem::CActionWellTrackAddItem(CSigmaDoc* ppDoc, UINT actionType, TRACKLIST& AddTrackList)
|
||
|
|
: CActionItem(ppDoc, actionType)
|
||
|
|
{
|
||
|
|
m_bAdded = false;
|
||
|
|
|
||
|
|
GetTrackInfo(AddTrackList);
|
||
|
|
PerformOperation();
|
||
|
|
}
|
||
|
|
|
||
|
|
CActionWellTrackAddItem::~CActionWellTrackAddItem(void)
|
||
|
|
{
|
||
|
|
if (m_bAdded == false)
|
||
|
|
{
|
||
|
|
TRACKLIST::iterator it = m_addTrackList.begin();
|
||
|
|
for (; it != m_addTrackList.end(); it++)
|
||
|
|
{
|
||
|
|
delete *it;
|
||
|
|
}
|
||
|
|
|
||
|
|
m_addTrackList.clear();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void CActionWellTrackAddItem::Undo(void)
|
||
|
|
{
|
||
|
|
CActionItem::Undo();
|
||
|
|
//delete this new track
|
||
|
|
CTrackGroup* pTrackG = (CTrackGroup*)((*m_addTrackList.begin()))->GetParent();
|
||
|
|
|
||
|
|
TRACKLIST::iterator it = m_addTrackList.begin();
|
||
|
|
for (; it != m_addTrackList.end(); it++)
|
||
|
|
{
|
||
|
|
pTrackG->RemoveTrack(*it);
|
||
|
|
}
|
||
|
|
|
||
|
|
CWellPole* pWell = pTrackG->GetWell();
|
||
|
|
CPoint2D ptf = pWell->GetAnchorPoint(); //->GetPos().TopLeft();
|
||
|
|
pWell->CalculateSize(ptf);
|
||
|
|
|
||
|
|
m_bAdded = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
void CActionWellTrackAddItem::Redo(void)
|
||
|
|
{
|
||
|
|
CActionItem::Redo();
|
||
|
|
//add this new track
|
||
|
|
CTrackGroup* pTrackG = (CTrackGroup*)((*m_addTrackList.begin()))->GetParent();
|
||
|
|
|
||
|
|
int count = 0;
|
||
|
|
TRACKLIST::iterator it = m_addTrackList.begin();
|
||
|
|
for (; it != m_addTrackList.end(); it++)
|
||
|
|
{
|
||
|
|
pTrackG->AddTarckToPos(m_iTracksPos[count], *it);
|
||
|
|
count++;
|
||
|
|
}
|
||
|
|
|
||
|
|
//if (m_iTrackPos < 0)
|
||
|
|
//{
|
||
|
|
// pTrackG->AddTrack((CTrackObj*)m_pNewTrack);
|
||
|
|
//}
|
||
|
|
//else
|
||
|
|
//{
|
||
|
|
// pTrackG->AddTarckToPos(m_iTrackPos, (CTrackObj*)m_pNewTrack);
|
||
|
|
//}
|
||
|
|
|
||
|
|
CWellPole* pWell = pTrackG->GetWell();
|
||
|
|
CPoint2D ptf = pWell->GetAnchorPoint(); //->GetPos().TopLeft();
|
||
|
|
pWell->CalculateSize(ptf);
|
||
|
|
|
||
|
|
m_bAdded = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
void CActionWellTrackAddItem::Finish()
|
||
|
|
{
|
||
|
|
PerformOperation();
|
||
|
|
CActionItem::Finish();
|
||
|
|
}
|
||
|
|
|
||
|
|
void CActionWellTrackAddItem::PerformOperation()
|
||
|
|
{
|
||
|
|
m_bAdded = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
void CActionWellTrackAddItem::GetTrackInfo(TRACKLIST& AddTrackList)
|
||
|
|
{
|
||
|
|
TRACKLIST::iterator it = AddTrackList.begin();
|
||
|
|
for (; it != AddTrackList.end(); it++)
|
||
|
|
{
|
||
|
|
CTrackGroup* pTrackG = (CTrackGroup*)(*it)->GetParent();
|
||
|
|
m_iTracksPos.push_back(pTrackG->GetTrackPosInList(*it));
|
||
|
|
m_addTrackList.push_back(*it);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void NAction::CActionWellTrackAddItem::accept(CActionVisitor& visitor)
|
||
|
|
{
|
||
|
|
//visitor.visit(*this);
|
||
|
|
}
|