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.
82 lines
1.7 KiB
C++
82 lines
1.7 KiB
C++
#include "stdafx.h"
|
|
#include "ActionCurveEdit.h"
|
|
#include "SigmaDoc.h"
|
|
#include "Visitor.h"
|
|
|
|
namespace NAction
|
|
{
|
|
CActionCurveEdit::CActionCurveEdit()
|
|
: CActionItem(nullptr, 0)
|
|
{
|
|
}
|
|
|
|
CActionCurveEdit::CActionCurveEdit(CSigmaDoc * pDoc, UINT actionType, POSITION pos)
|
|
:CActionItem(pDoc, actionType),
|
|
m_posOfCurve(pos),
|
|
m_indexOfNodeForUndo(-1),
|
|
m_nodeXForUndo(0),
|
|
m_nodeYForUndo(0),
|
|
m_indexOfNodeForRedo(-1),
|
|
m_nodeXForRedo(0),
|
|
m_nodeYForRedo(0)
|
|
{
|
|
}
|
|
|
|
void CActionCurveEdit::Undo()
|
|
{
|
|
CCurveEx * pCurve = GetCurve();
|
|
if (pCurve == 0)
|
|
return;
|
|
|
|
if (m_indexOfNodeForUndo < 0 || m_indexOfNodeForUndo >= pCurve->num)
|
|
return;
|
|
|
|
pCurve->x[m_indexOfNodeForUndo] = m_nodeXForUndo;
|
|
pCurve->y[m_indexOfNodeForUndo] = m_nodeYForUndo;
|
|
}
|
|
|
|
void CActionCurveEdit::Redo()
|
|
{
|
|
CCurveEx * pCurve = GetCurve();
|
|
if (pCurve == 0)
|
|
return;
|
|
|
|
if (m_indexOfNodeForRedo < 0 || m_indexOfNodeForRedo >= pCurve->num)
|
|
return;
|
|
|
|
pCurve->x[m_indexOfNodeForRedo] = m_nodeXForRedo;
|
|
pCurve->y[m_indexOfNodeForRedo] = m_nodeYForRedo;
|
|
}
|
|
|
|
void CActionCurveEdit::BackupUndoNode(int indexOfNode, double nodeX, double nodeY)
|
|
{
|
|
m_indexOfNodeForUndo = indexOfNode;
|
|
m_nodeXForUndo = nodeX;
|
|
m_nodeYForUndo = nodeY;
|
|
}
|
|
|
|
void CActionCurveEdit::BackupRedoNode(int indexOfNode, double nodeX, double nodeY)
|
|
{
|
|
m_indexOfNodeForRedo = indexOfNode;
|
|
m_nodeXForRedo = nodeX;
|
|
m_nodeYForRedo = nodeY;
|
|
}
|
|
|
|
void CActionCurveEdit::accept(CActionVisitor& visitor)
|
|
{
|
|
visitor.visit(*this);
|
|
}
|
|
|
|
CCurveEx * CActionCurveEdit::GetCurve()
|
|
{
|
|
COne * pOne = GetDoc()->GetDraw()->GetAt(m_posOfCurve);
|
|
if (pOne == 0)
|
|
return 0;
|
|
|
|
if (pOne->GetType() != DOUBLEFOX_CURVE)
|
|
return 0;
|
|
|
|
CCurveEx * pCurve = (CCurveEx*)GetDoc()->GetDraw()->GetAtValue(m_posOfCurve);
|
|
return pCurve;
|
|
}
|
|
} //end namespace
|