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/ActionMarkDeleteItem.cpp

145 lines
2.7 KiB
C++

#include "stdafx.h"
#include "SigmaDoc.h"
#include "ActionMarkDeleteItem.h"
#include "Visitor.h"
NAction::CActionMarkDeleteItem::CActionMarkDeleteItem()
: CActionItem(nullptr, 0)
{
}
NAction::CActionMarkDeleteItem::CActionMarkDeleteItem(CSigmaDoc * ppDoc, UINT actionType)
: CActionItem(ppDoc, actionType)
{
m_bDelete = TRUE;
m_bRePosition = FALSE;
}
NAction::CActionMarkDeleteItem::~CActionMarkDeleteItem(void)
{
if (m_bDelete) Clear();
}
void NAction::CActionMarkDeleteItem::AddMark(CXy * pMarkXy)
{
if (pMarkXy == NULL) return;
CString name = pMarkXy->m_strName;
name.MakeUpper();
mark.SetAt(name, pMarkXy);
}
void NAction::CActionMarkDeleteItem::Undo(void)
{
CActionItem::Undo();
m_bDelete = FALSE;
UndoToAdd();
}
void NAction::CActionMarkDeleteItem::Redo(void)
{
CActionItem::Redo();
m_bDelete = TRUE;
RedoToDelete();
}
void NAction::CActionMarkDeleteItem::EnableRePosition(BOOL bPosition)
{
m_bRePosition = bPosition;
}
void NAction::CActionMarkDeleteItem::Clear()
{
CString s;
void* pDraw = NULL;
POSITION p = mark.GetStartPosition();
while (p)
{
mark.GetNextAssoc(p, s, pDraw);
if (pDraw) delete (CXy*)pDraw;
}
mark.RemoveAll();
}
void NAction::CActionMarkDeleteItem::accept(CActionVisitor& visitor)
{
visitor.visit(*this);
}
void NAction::CActionMarkDeleteItem::UndoToAdd(void)
{
if (mark.IsEmpty()) return;
CString name;
void* pDraw;
POSITION p = mark.GetStartPosition();
while (p)
{
mark.GetNextAssoc(p, name, pDraw);
if (pDraw == NULL)continue;
GetDoc()->GetDraw()->AddMark((CXy*)pDraw);
}
if (m_bRePosition)
{
GetDoc()->GetDraw()->PositionNew(0);
//GetDoc()->Invalidate();
}
ReflashMarkLibrary();
}
void NAction::CActionMarkDeleteItem::RedoToDelete(void)
{
if (mark.IsEmpty()) return;
CString name;
void* pDraw;
void* value;
POSITION p = mark.GetStartPosition();
while (p)
{
mark.GetNextAssoc(p, name, pDraw);
if (pDraw == NULL)continue;
if (GetDoc()->GetDraw()->mark.Lookup(name, value))
{
if (value == pDraw)
GetDoc()->GetDraw()->RemoveMarkNoClear(name);
}
}
if (m_bRePosition)
{
GetDoc()->GetDraw()->PositionNew(0);
GetDoc()->Invalidate();
}
ReflashMarkLibrary();
}
NAction::CActionMarkAddItem::CActionMarkAddItem()
{
}
NAction::CActionMarkAddItem::CActionMarkAddItem(CSigmaDoc * ppDoc, UINT actionType)
: CActionMarkDeleteItem(ppDoc, actionType)
{
m_bDelete = FALSE;
m_bRePosition = FALSE;
}
NAction::CActionMarkAddItem::~CActionMarkAddItem(void)
{
if (m_bDelete) Clear();
}
void NAction::CActionMarkAddItem::Undo(void)
{
CActionItem::Redo();
m_bDelete = FALSE;
UndoToAdd(); //<2F><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>
}
void NAction::CActionMarkAddItem::Redo(void)
{
CActionItem::Undo();
m_bDelete = TRUE;
RedoToDelete(); //ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}