コード例 #1
0
ファイル: ophist.cpp プロジェクト: vata/xarino
BOOL OperationHistory::UndoPrev()
{
    //TRACE( _T("Called Undo\n"));
    if (NowPtr != NULL) // Check if there is an operation to UNDO
    {
        // Tell the world that the op is about to be undone
        BROADCAST_TO_ALL(OpMsg(((Operation*)NowPtr),OpMsg::BEFORE_UNDO));
        Operation* pOp = (Operation*)NowPtr;

        if (pOp->Undo()) // Undo the operation
        {
            ERROR3IF(NowPtr == NULL, "The operation which has just been undone has been deleted");
            if (NowPtr != NULL)
            {
                // We used to find the prev op before the undo, this was wrong because it may have been deleted.
                NowPtr = OpHistoryList.GetPrev(NowPtr);
            }
            Operation* NextOp;
            if (NowPtr != NULL)
            {
                NextOp = ((Operation*)OpHistoryList.GetNext(NowPtr));
            }
            else
            {
                NextOp = ((Operation*)OpHistoryList.GetHead());
            }
            BROADCAST_TO_ALL(OpMsg(NextOp,OpMsg::AFTER_UNDO));
            return (TRUE);
        }
    }
    return (FALSE); // There are no operations to UNDO, or the Operation failed to undo
}
コード例 #2
0
void ManipulatorOperation::Undo()
{
	if (!m_lstUndo.empty())
	{
		Operation* op = m_lstUndo.back();
		op->Undo();
		m_lstUndo.pop_back();
		m_lstRedo.push_back(op);
		++m_snapshot;
	}
}