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.

170 lines
3.5 KiB
C++

1 month ago
//////////////////////////////////////////////////////////////////////////////
//<2F>ļ<EFBFBD> ActionItem.h
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>:
//
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д: 2006-12-07
/////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "SigmaDoc.h"
#include "SigmaView.h"
#include ".\ActionItem.h"
//#include "MainFrm.h"
using namespace NAction;
CActionItem::CActionItem(CSigmaDoc * ppDoc, UINT actionType)
: CAction(ppDoc,actionType)
{
}
CActionItem::~CActionItem(void)
{
}
void CActionItem::Undo(void)
{
CAction::Undo();
// regain the input focus
// GetView()->SetFocus();
// GetDoc()->Modified();
}
void CActionItem::Redo(void)
{
CAction::Redo();
// regain the input focus
// GetView()->SetFocus();
GetDoc()->Modified();
}
void CActionItem::Do(void)
{
CAction::Do();
Finish();
////If an action has inform the operation target to add itsleft to stack, the earlier One should be finshed.
//if (GetDoc()->GetActionItem())
//{
// if(GetDoc()->GetActionItem()->done ==false)
// GetDoc()->GetActionItem()->Do();
// GetDoc()->GetActionItem()->Finish();
//}
}
CSigmaDoc* CActionItem::GetDoc(void)
{
return (CSigmaDoc*)actionTarget;
}
//CDFDrawProView* CActionItem::GetView(void)
//{
// return pView;
//}
CSigmaView* CActionItem::GetView(void)
{
ASSERT(GetDoc()!=NULL);
return (CSigmaView*)GetDoc()->GetView();
//return (CDFDrawProView*)(GetDC()->pDC->GetWindow());
}
BOOL CActionItem::RemoveAt(COne* pOne)
{
CXy* pxy=GetDoc()->m_pXy;
if(pxy==NULL) return FALSE;
return pxy->RemoveAtNoClear(pOne);
}
BOOL NAction::CActionItem::RemoveAtNoClear(const std::vector<COne*>& pOnes)
{
CXy* pxy=GetDoc()->m_pXy;
if (pxy == NULL)
{
return FALSE;
}
std::unordered_set<COne*> pOneSet(pOnes.begin(), pOnes.end());
CPtrList& values = *(pxy->GetValueList());
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>ֹ<EFBFBD><D6B9>
POSITION pos = values.GetTailPosition();
while (pos != nullptr && !pOneSet.empty())
{
// <20><><EFBFBD>浱ǰλ<C7B0><CEBB>
POSITION currentPos = pos;
COne* pValue = reinterpret_cast<COne*>(values.GetPrev(pos));
// <20><><EFBFBD>鲢ɾ<E9B2A2><C9BE>
auto it = pOneSet.find(pValue);
if (it != pOneSet.end())
{
values.RemoveAt(currentPos);
pOneSet.erase(it); // <20>Ӵ<EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>
}
}
return 0;
}
void CActionItem::Clear(CPtrList& value)
{
COne *pOne;
POSITION p=value.GetHeadPosition();
while(p)
{
pOne=(COne *)(value.GetNext(p));
if (pOne)
{
if (::AfxIsValidAddress(pOne, sizeof(COne))) {
if (::AfxIsValidAddress(pOne->m_pLayer, sizeof(CLayer)))
{
delete pOne;
}
}
pOne = NULL;
}
}
value.RemoveAll();
}
void CActionItem::Invalidate(CRect8& range)
{
//CRect rt=GetDoc()->GetDC().GetScreen(range);
//rt.NormalizeRect();
//rt.InflateRect(GetDoc()->GetHandleSize());
//GetDoc()->Invalidate(&rt);
}
void CActionItem::Remember(const CPositionList& list)
{
if(list.GetCount()==0) return;
COne* pOne;
POSITION pt;
POSITION pos = list.GetHeadPosition();
while (pos != NULL)
{
pt = list.GetNext(pos);
pOne=GetDoc()->GetDraw()->GetAt(pt);
value.AddTail(pOne);
}
}
void NAction::CActionItem::ReflashLayer(void)
{
//CMainFrame* pmf = (CMainFrame*)GetDoc()->GetMainFrame();
//if(pmf)
// pmf->LoadLayer(NULL);
}
BOOL NAction::CActionItem::ReflashMarkLibrary(void)
{
//CMainFrame* pmf = (CMainFrame*)GetDoc()->GetMainFrame();
//if(pmf==NULL) return FALSE;
//if(pmf->m_paneMarkManager.GetSafeHwnd()==NULL) return FALSE;
//if(pmf->m_paneMarkManager.m_treeList.GetCurLoadMode()!=LOAD_MODE_MARK)
// return FALSE;
//if(pmf->m_paneMarkManager.m_treeList.Tree_IsCurrentItem()) //<2F>Ƿ<EFBFBD><C7B7>ǵ<EFBFBD>ǰ<EFBFBD>ĵ<EFBFBD><C4B5>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD>ʾ
// pmf->m_paneMarkManager.ReflashList();
return TRUE;
}