mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-13 23:26:19 +00:00
Split off lots of editor functionality into new abstract INodeEditor class and viewport functionality into CBasicViewport class; added viewport subclasses and undo/redo system in the World Editor
This commit is contained in:
42
UI/undo/CClearSelectionCommand.cpp
Normal file
42
UI/undo/CClearSelectionCommand.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "CClearSelectionCommand.h"
|
||||
#include "../CWorldEditor.h"
|
||||
|
||||
CClearSelectionCommand::CClearSelectionCommand(INodeEditor *pEditor, QList<CSceneNode*>& selection)
|
||||
: QUndoCommand("Clear Selection"),
|
||||
mpEditor(pEditor),
|
||||
mSelectionState(selection),
|
||||
mpSelection(&selection)
|
||||
{
|
||||
}
|
||||
|
||||
CClearSelectionCommand::~CClearSelectionCommand()
|
||||
{
|
||||
}
|
||||
|
||||
void CClearSelectionCommand::undo()
|
||||
{
|
||||
mpSelection->reserve(mSelectionState.size());
|
||||
|
||||
foreach (CSceneNode *pNode, mSelectionState)
|
||||
{
|
||||
if (!pNode->IsSelected())
|
||||
{
|
||||
pNode->SetSelected(true);
|
||||
mpSelection->push_back(pNode);
|
||||
}
|
||||
}
|
||||
|
||||
mpEditor->RecalculateSelectionBounds();
|
||||
mpEditor->UpdateSelectionUI();
|
||||
}
|
||||
|
||||
void CClearSelectionCommand::redo()
|
||||
{
|
||||
foreach (CSceneNode *pNode, *mpSelection)
|
||||
if (pNode->IsSelected())
|
||||
pNode->SetSelected(false);
|
||||
|
||||
mpSelection->clear();
|
||||
mpEditor->RecalculateSelectionBounds();
|
||||
mpEditor->UpdateSelectionUI();
|
||||
}
|
||||
Reference in New Issue
Block a user