mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-05-25 08:41:26 +00:00
43 lines
949 B
C++
43 lines
949 B
C++
#include "CSelectNodeCommand.h"
|
|
#include "Editor/INodeEditor.h"
|
|
|
|
CSelectNodeCommand::CSelectNodeCommand(INodeEditor *pEditor, CSceneNode *pNode, QList<CSceneNode*>& selection)
|
|
: IUndoCommand("Select"),
|
|
mpEditor(pEditor),
|
|
mpNode(pNode),
|
|
mpSelection(&selection)
|
|
{
|
|
}
|
|
|
|
void CSelectNodeCommand::undo()
|
|
{
|
|
if (mpNode->IsSelected())
|
|
{
|
|
mpNode->SetSelected(false);
|
|
|
|
for (auto it = mpSelection->begin(); it != mpSelection->end(); it++)
|
|
{
|
|
if (*it == mpNode)
|
|
{
|
|
mpSelection->erase(it);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
mpEditor->RecalculateSelectionBounds();
|
|
mpEditor->NotifySelectionModified();
|
|
}
|
|
|
|
void CSelectNodeCommand::redo()
|
|
{
|
|
if (!mpNode->IsSelected())
|
|
{
|
|
mpNode->SetSelected(true);
|
|
mpSelection->push_back(mpNode);
|
|
}
|
|
|
|
mpEditor->ExpandSelectionBounds(mpNode);
|
|
mpEditor->NotifySelectionModified();
|
|
}
|