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

73 lines
1.5 KiB
C++

#include "stdafx.h"
#include "ActionModifiedMeshItem.h"
#include "Visitor.h"
NAction::CActionModifiedMeshItem::CActionModifiedMeshItem()
:CActionItem(nullptr, 0)
{
}
NAction::CActionModifiedMeshItem::CActionModifiedMeshItem(CSigmaDoc* ppDoc, UINT actionType)
: CActionItem(ppDoc, actionType)
{
}
void NAction::CActionModifiedMeshItem::BackupOldArguments(COne* pOne)
{
assert(pOne != nullptr);
assert(pOne->GetType() == DOUBLEFOX_MESH);
m_pOne = pOne;
m_oldArguments = GetArguments();
}
void NAction::CActionModifiedMeshItem::BackupNewArguments()
{
m_newArguments = GetArguments();
}
void NAction::CActionModifiedMeshItem::Undo(void)
{
CActionItem::Undo();
SetArguments(m_oldArguments);
}
void NAction::CActionModifiedMeshItem::Redo(void)
{
CActionItem::Redo();
SetArguments(m_newArguments);
}
void NAction::CActionModifiedMeshItem::accept(CActionVisitor& visitor)
{
visitor.visit(*this);
}
CString NAction::CActionModifiedMeshItem::GetArguments() const
{
assert(m_pOne != nullptr);
CMesh* pMesh = m_pOne->GetValueSafe<CMesh>();
BYTE* pBuff = nullptr;
int buffLen = 0;
pMesh->WriteElementDML(pBuff, buffLen);
assert(pBuff != nullptr);
return CString(reinterpret_cast<LPCTSTR>(pBuff), buffLen);
}
void NAction::CActionModifiedMeshItem::SetArguments(CString& arguments)
{
CMesh* pMesh = m_pOne->GetValueSafe<CMesh>();
pMesh->ReadElementDML(reinterpret_cast<BYTE*>(arguments.GetBuffer()), -1, arguments.GetLength());
pMesh->SetM(pMesh->m_pRuler->zmin, pMesh->m_pRuler->zmax);
pMesh->GetBitmap();
}