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.

154 lines
3.6 KiB
C++

1 month ago
#include "stdafx.h"
#include "ActionModifiedWellItem.h"
#include "WellPoleDoc.h"
#include "WellPoleView.h"
#include "../Visitor.h"
int c_wellActionNum = 0;
CActionModifiedWell::CActionModifiedWell(CSigmaDoc* ppDoc, UINT actionType, BOOL bNoSaveData)
: CActionModifiedItem(ppDoc, actionType)
{
m_bNoSaveData = bNoSaveData;
//TRACE("%d ----------- --------- create CActionModifiedWell \r\n", c_wellActionNum++);
}
CActionModifiedWell::CActionModifiedWell(CSigmaDoc* ppDoc, UINT actionType, const CPositionList& list, BOOL bNoSaveData)
: CActionModifiedItem(ppDoc, actionType)
{
m_bNoSaveData = bNoSaveData;
AddCloneItem(list);
//TRACE("%d ----------- --------- create CActionModifiedWell \r\n", c_wellActionNum++);
}
CActionModifiedWell::~CActionModifiedWell(void)
{
//TRACE("%d -------------------- decreat CActionModifiedWell ,wellNUm=%d \r\n", c_wellActionNum--, int(m_WellObjBaseArr.size()));
for (int ii = 0; ii < m_WellObjBaseArr.size(); ii++)
{
delete m_WellObjBaseArr[ii];
}
}
void CActionModifiedWell::AddCloneItem(const CPositionList& list)
{
COne* pOne;
POSITION pt, pos;
pos = list.GetHeadPosition();
while (pos)
{
pt = list.GetNext(pos);
pOne = GetDoc()->GetDraw()->GetAt(pt);
if(pOne->GetType() == KEP_WELL)
AddCloneItem(pt, pOne);
}
}
bool CActionModifiedWell::AddCloneItem(POSITION pos, COne* pOne, bool bCreateAdd)
{
if (pos == NULL || pOne == NULL)
return false;
long index = GetDoc()->GetDraw()->GetElementIndex(pos);
m_indexArray.Add(index);
if (bCreateAdd)
{
CWellBaseObj* pObj = (CWellBaseObj*)pOne->value;
//pObj->SetActionNoSaveData(m_bNoSaveData);
CWellBaseObj* pNewObj =(CWellBaseObj*) pObj->CloneElement();
//pObj->SetActionNoSaveData(FALSE);
m_WellObjBaseArr.push_back(pNewObj);
//pOne->SetValue(pNewObj,KEP_WELL);
//m_WellObjBaseArr.push_back(pObj); //<2F><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><E6B5B5><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>ľ<EFBFBD><C4BE><EFBFBD>Ϊ<EFBFBD><CEAA>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
}
return true;
}
void CActionModifiedWell::PerformOperation(void)
{
GetDoc()->ClearSelection();
CRect8 range(1e100, -1e100, -1e100, 1e100);
//CDrawObj* pThat;
//CDrawObj* pThis;
//long i = 0;
//POSITION ps;
//POSITION pts = value.GetHeadPosition();
//while (pts)
//{
// pThis = (CDrawObj*)(value.GetAt(pts));
// ps = GetDoc()->GetDraw()->FindIndex(m_indexArray[i]);
// pThat = (CDrawObj*)GetDoc()->GetDraw()->GetAt(ps);
// //<2F><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>
// if (m_bNoSaveData)
// pThis->TransferData(pThat);
// //<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
// value.SetAt(pts, pThat);
// GetDoc()->GetDraw()->SetAt(ps, pThis);
// if (GetDoc()->GetItem())
// GetDoc()->GetItem()->SetPos(ps);
// AfterRedoUndo(pThat);
// value.GetNext(pts);
// pThis->GetRange(range);
// pThat->GetRange(range);
// i++;
// list.AddTail(ps);
//}
POSITION ps;
CWellBaseObj* pThat;
CWellBaseObj* pThis;
long i = 0;
for (int ii = 0; ii < m_WellObjBaseArr.size(); ii++)
{
pThis = m_WellObjBaseArr[ii];
ps = GetDoc()->GetDraw()->FindIndex(m_indexArray[i]);
COne* pOne = GetDoc()->GetDraw()->GetAt(ps);
if (pOne->GetType() == KEP_WELL)
{
pThat = (CWellBaseObj*)pOne->value;
//<2F><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>
if (m_bNoSaveData)
pThis->TransferData(pThat);
//<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
//value.SetAt(pts, pThat);
m_WellObjBaseArr[ii] = pThat;
//GetDoc()->GetDraw()->SetAt(ps, pThis);
pOne->value = pThis;
if (GetDoc()->GetItem())
GetDoc()->GetItem()->SetPos(ps);
//AfterRedoUndo(pThat);
//value.GetNext(pts);
pThis->GetRange(range);
pThat->GetRange(range);
i++;
}
}
Invalidate(range);
}
void CActionModifiedWell::PerformOperation(std::unique_ptr<COne> ModifiedEntry::* member)
{
PerformOperation();
}
void NAction::CActionModifiedWell::accept(CActionVisitor& visitor)
{
//visitor.visit(*this);
}