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

73 lines
1.5 KiB
C++

1 month ago
#include "stdafx.h"
#include "ActionRotationItem.h"
#include "Util.h"
#include "BlobSerializer.h"
#include "SigmaDoc.h"
CActionRotationItem::CActionRotationItem()
: CActionItem(nullptr, 0)
{
}
CActionRotationItem::CActionRotationItem(CSigmaDoc* ppDoc, UINT actionType, double x, double y, double angle)
: CActionItem(ppDoc, actionType),
m_x(x), m_y(y), m_angle(angle)
{
}
CActionRotationItem::CActionRotationItem(CSigmaDoc* ppDoc, UINT actionType, double x, double y, double angle, const CPositionList &elements)
: CActionItem(ppDoc, actionType),
m_x(x), m_y(y), m_angle(angle)
{
CListAddRange(m_elements, elements);
}
void CActionRotationItem::Undo()
{
Rotation(-m_angle);
}
void CActionRotationItem::Redo()
{
Rotation(m_angle);
}
void CActionRotationItem::Do()
{
Rotation(m_angle);
}
void CActionRotationItem::Rotation(double angle)
{
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD>Ϊ 0<><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><CEBA><EFBFBD>ת
if (fabs(angle) < std::numeric_limits<double>::epsilon())
{
return;
}
if (!m_elements.IsEmpty()) // Ҫ<><D2AA>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>ͼԪ
{
CPtrList* pValues = GetDoc()->GetDraw()->GetValueList();
POSITION pos = m_elements.GetHeadPosition();
while (pos != nullptr)
{
POSITION pt = m_elements.GetNext(pos);
COne* pOne = reinterpret_cast<COne*>(pValues->GetAt(pt));
if (pOne != nullptr)
{
pOne->Rotate(m_x, m_y, angle);
}
}
}
else // Ҫ<><D2AA>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>ͼԪ
{
GetDoc()->GetDraw()->Rotate(m_x, m_y, angle);
}
}
void CActionRotationItem::accept(CActionVisitor& visitor)
{
visitor.visit(*this);
}