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.
143 lines
3.0 KiB
C++
143 lines
3.0 KiB
C++
#include "StdAfx.h"
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
//类: ActionMoveItem
|
|
//主要功能:
|
|
//
|
|
//程序编写:
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include ".\actionmoveitem.h"
|
|
#include "SigmaDoc.h"
|
|
#include "SigmaView.h"
|
|
#include "Visitor.h"
|
|
using namespace NAction;
|
|
|
|
NAction::CActionMoveItem::CActionMoveItem()
|
|
: CActionItem(nullptr, 0)
|
|
{
|
|
m_pXyDC = NULL;
|
|
}
|
|
|
|
CActionMoveItem::CActionMoveItem(CSigmaDoc * ppDoc, UINT actionType, const CPositionList& list, REAL* pmatrix)
|
|
: CActionItem(ppDoc,actionType)
|
|
{
|
|
SetDC(&ppDoc->GetDC());
|
|
Remember(list);
|
|
|
|
memcpy(matrix,pmatrix,sizeof(REAL)*6);
|
|
ConvertRealDistance();
|
|
}
|
|
|
|
CActionMoveItem::CActionMoveItem(CSigmaDoc * ppDoc, UINT actionType, COne* pOne, REAL* pmatrix)
|
|
: CActionItem(ppDoc,actionType)
|
|
{
|
|
SetDC(&ppDoc->GetDC());
|
|
if(pOne) value.AddTail(pOne);
|
|
memcpy(matrix,pmatrix,sizeof(REAL)*6);
|
|
ConvertRealDistance();
|
|
}
|
|
|
|
CActionMoveItem::~CActionMoveItem(void)
|
|
{
|
|
value.RemoveAll();
|
|
if(m_pXyDC)delete m_pXyDC;
|
|
m_pXyDC=NULL;
|
|
}
|
|
|
|
void CActionMoveItem::SetDC(void* pXyDC)
|
|
{
|
|
if(m_pXyDC)delete m_pXyDC;
|
|
m_pXyDC=new CXyDC();
|
|
*(CXyDC*)m_pXyDC=*(CXyDC*)pXyDC;
|
|
}
|
|
|
|
void CActionMoveItem::Undo()
|
|
{
|
|
CActionItem::Undo();
|
|
|
|
ConvertScreenDistance();
|
|
|
|
if(m_pXyDC) //恢复显示比例
|
|
GetDoc()->SetDC(*(CXyDC*)m_pXyDC);
|
|
|
|
//GetDoc()->BeginProgress("Undo Transform...");
|
|
CRect8 range(1e100,-1e100,-1e100,1e100);
|
|
CRect8 rect(1e100,-1e100,-1e100,1e100);
|
|
COne* pOne;
|
|
POSITION pos = value.GetTailPosition();
|
|
while (pos != NULL)
|
|
{
|
|
pOne = (COne*)value.GetPrev(pos);
|
|
pOne->GetRange(rect);
|
|
pOne->Transform((CXyDC*)m_pXyDC,matrix,TRUE);
|
|
pOne->GetRange(range);
|
|
}
|
|
//GetDoc()->EndProgress();
|
|
|
|
if(m_pXyDC)
|
|
GetDoc()->Invalidate();
|
|
else
|
|
{
|
|
Invalidate(rect);
|
|
Invalidate(range);
|
|
}
|
|
//if(GetDoc()->GetSelectItem())
|
|
// GetDoc()->GetSelectItem()->ReloadTrackerPath();
|
|
|
|
ConvertRealDistance();
|
|
}
|
|
|
|
void CActionMoveItem::Redo()
|
|
{
|
|
CActionItem::Redo();
|
|
|
|
ConvertScreenDistance();
|
|
|
|
if(m_pXyDC)
|
|
GetDoc()->SetDC(*(CXyDC*)m_pXyDC);
|
|
|
|
//GetDoc()->BeginProgress("Redo Transform...");
|
|
CRect8 range(1e100,-1e100,-1e100,1e100);
|
|
CRect8 rect(1e100,-1e100,-1e100,1e100);
|
|
COne* pOne;
|
|
POSITION pos = value.GetTailPosition();
|
|
while (pos != NULL)
|
|
{
|
|
pOne = (COne*)value.GetPrev(pos);
|
|
pOne->GetRange(rect);
|
|
pOne->Transform((CXyDC*)m_pXyDC,matrix);
|
|
pOne->GetRange(range);
|
|
}
|
|
//GetDoc()->EndProgress();
|
|
if(m_pXyDC)
|
|
GetDoc()->Invalidate();
|
|
else
|
|
{
|
|
Invalidate(rect);
|
|
Invalidate(range);
|
|
}
|
|
//if(GetDoc()->GetSelectItem())
|
|
// GetDoc()->GetSelectItem()->ReloadTrackerPath();
|
|
|
|
ConvertRealDistance();
|
|
}
|
|
|
|
void NAction::CActionMoveItem::accept(CActionVisitor& visitor)
|
|
{
|
|
visitor.visit(*this);
|
|
}
|
|
|
|
void NAction::CActionMoveItem::ConvertRealDistance()
|
|
{
|
|
//CXyDC& xyDC = m_pXyDC;
|
|
|
|
matrix[4] = ((CXyDC*)m_pXyDC)->GetRealWidth(matrix[4]);
|
|
matrix[5] = ((CXyDC*)m_pXyDC)->GetRealHeight(matrix[5]);
|
|
}
|
|
|
|
void NAction::CActionMoveItem::ConvertScreenDistance()
|
|
{
|
|
matrix[4] = ((CXyDC*)m_pXyDC)->GetScreenWidth(matrix[4]);
|
|
matrix[5] = ((CXyDC*)m_pXyDC)->GetScreenHeight(matrix[5]);
|
|
}
|