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.
kev/Drawer/Module/GeoSigmaDraw/ActionDeleteLayerItem.cpp

107 lines
2.2 KiB
C++

//////////////////////////////////////////////////////////////////////////////
//文件 ActionDeleteLayerItem.h
//主要功能:
//
//程序编写: 2006-12-07
/////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include ".\actiondeletelayeritem.h"
#include "SigmaDoc.h"
#include "SigmaView.h"
#include "Visitor.h"
NAction::CActionLayerDeleteItem::CActionLayerDeleteItem()
: CActionDeleteItem(nullptr, 0)
{
}
CActionLayerDeleteItem::CActionLayerDeleteItem(CSigmaDoc * ppDoc, CLayer* pLayer)
: CActionDeleteItem(ppDoc, ActionType::ActionTypeLayerDelete)
{
if(pLayer)
{
LayerList.AddTail(pLayer);
pLayer->GetParentClass()->RemoveAt(pLayer);
}
}
CActionLayerDeleteItem::CActionLayerDeleteItem(CSigmaDoc * ppDoc, const CPositionList& ElementList, CPtrList& cLayerList)
: CActionDeleteItem(ppDoc, ActionTypeLayerDelete, ElementList)
{
CLayer* pv;
POSITION pos=cLayerList.GetHeadPosition();
while(pos)
{
pv=(CLayer*)cLayerList.GetNext(pos);
if(pv==NULL) continue;
LayerList.AddTail(pv);
pv->GetParentClass()->RemoveAt(pv);
}
}
CActionLayerDeleteItem::~CActionLayerDeleteItem(void)
{
Clear();
}
void NAction::CActionLayerDeleteItem::Clear(void)
{
CActionDeleteItem::Clear();
if(m_bDeleted)
{
CLayer* pv;
POSITION pos=LayerList.GetHeadPosition();
while(pos)
{
pv=(CLayer*)LayerList.GetNext(pos);
delete pv;
pv = nullptr;
}
LayerList.RemoveAll();
}
}
void CActionLayerDeleteItem::Undo()
{
CLayer* pLayer;
POSITION pos=LayerList.GetHeadPosition();
while(pos)
{
pLayer=(CLayer*)LayerList.GetNext(pos);
GetDoc()->GetDraw()->AddLayer(pLayer);
}
//Undo所删除层位下的元素
CActionDeleteItem::Undo();
ReflashLayer();
}
void CActionLayerDeleteItem::Redo()
{
//Redo所删除层位下的元素
CActionDeleteItem::Redo();
CLayer* pLayer;
POSITION pos=LayerList.GetHeadPosition();
while(pos)
{
pLayer=(CLayer*)LayerList.GetNext(pos);
pLayer->GetParentClass()->RemoveAt(pLayer);
}
ReflashLayer();
CXy* pXy = GetDoc()->GetDraw();
if (pXy->GetLayerCount() == 0)
{
pXy->InitLayerClass();
}
pXy->SetCurrentLayer(pXy->GetClassList()->GetHead()->GetHead());
}
void NAction::CActionLayerDeleteItem::accept(CActionVisitor& visitor)
{
visitor.visit(*this);
}