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.
118 lines
2.3 KiB
C++
118 lines
2.3 KiB
C++
#include "StdAfx.h"
|
|
#include ".\actionoffsetitem.h"
|
|
#include "SigmaDoc.h"
|
|
#include "SigmaView.h"
|
|
#include "ActionOffsetItem.h"
|
|
#include "Visitor.h"
|
|
|
|
NAction::CActionOffsetItem::CActionOffsetItem()
|
|
: CActionItem(nullptr, 0)
|
|
{
|
|
}
|
|
|
|
CActionOffsetItem::CActionOffsetItem(CSigmaDoc * ppDoc, UINT actionType, const CPositionList& list, CPoint2D* pOffset)
|
|
: CActionItem(ppDoc,actionType)
|
|
{
|
|
int num=(int)list.GetCount();
|
|
if(num>0)
|
|
{
|
|
this->Remember(list);
|
|
Create(num);
|
|
for(int i=0;i<num;i++)
|
|
{
|
|
offset_x[i]=pOffset[i].x0;
|
|
offset_y[i]=pOffset[i].y0;
|
|
}
|
|
}
|
|
}
|
|
|
|
CActionOffsetItem::CActionOffsetItem(CSigmaDoc * ppDoc, UINT actionType, const CPositionList& list, CPoint2D ptOffset)
|
|
: CActionItem(ppDoc,actionType)
|
|
{
|
|
int num=(int)list.GetCount();
|
|
if(num>0)
|
|
{
|
|
this->Remember(list);
|
|
Create(num);
|
|
for(int i=0;i<num;i++)
|
|
{
|
|
offset_x[i]=ptOffset.x0;
|
|
offset_y[i]=ptOffset.y0;
|
|
}
|
|
}
|
|
}
|
|
|
|
CActionOffsetItem::CActionOffsetItem(CSigmaDoc * ppDoc, UINT actionType, COne* pOne, CPoint2D ptOffset)
|
|
: CActionItem(ppDoc,actionType)
|
|
{
|
|
if(pOne)
|
|
{
|
|
value.AddTail(pOne);
|
|
Create(1);
|
|
offset_x[0]=ptOffset.x0;
|
|
offset_y[0]=ptOffset.y0;
|
|
}
|
|
}
|
|
|
|
CActionOffsetItem::~CActionOffsetItem(void)
|
|
{
|
|
value.RemoveAll();
|
|
}
|
|
|
|
void NAction::CActionOffsetItem::Create(int num)
|
|
{
|
|
offset_x.resize(num);
|
|
offset_y.resize(num);
|
|
}
|
|
|
|
void CActionOffsetItem::Redo()
|
|
{
|
|
CActionItem::Redo();
|
|
|
|
CRect8 range(1e100,-1e100,-1e100,1e100);
|
|
CRect8 rect(1e100,-1e100,-1e100,1e100);
|
|
int i=0;
|
|
COne* pOne;
|
|
POSITION pos = value.GetHeadPosition();
|
|
while (pos != NULL)
|
|
{
|
|
pOne = (COne*)value.GetNext(pos);
|
|
pOne->GetRange(rect);
|
|
pOne->Offset(offset_x[i],offset_y[i]);
|
|
pOne->GetRange(range);
|
|
i++;
|
|
}
|
|
//if(GetDoc()->GetSelectItem())
|
|
//GetDoc()->GetSelectItem()->ReloadTrackerPath();
|
|
Invalidate(rect);
|
|
Invalidate(range);
|
|
}
|
|
|
|
void NAction::CActionOffsetItem::accept(CActionVisitor& visitor)
|
|
{
|
|
visitor.visit(*this);
|
|
}
|
|
|
|
void CActionOffsetItem::Undo()
|
|
{
|
|
CActionItem::Undo();
|
|
|
|
CRect8 range(1e100,-1e100,-1e100,1e100);
|
|
CRect8 rect(1e100,-1e100,-1e100,1e100);
|
|
int i=0;
|
|
COne* pOne;
|
|
POSITION pos = value.GetHeadPosition();
|
|
while (pos != NULL)
|
|
{
|
|
pOne = (COne*)value.GetNext(pos);
|
|
pOne->GetRange(rect);
|
|
pOne->Offset(-offset_x[i],-offset_y[i]);
|
|
pOne->GetRange(range);
|
|
i++;
|
|
}
|
|
//if(GetDoc()->GetSelectItem())
|
|
//GetDoc()->GetSelectItem()->ReloadTrackerPath();
|
|
Invalidate(rect);
|
|
Invalidate(range);
|
|
}
|