1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-01 03:21:41 +00:00
OpenMW/apps/opencs/view/render/commands.cpp
2022-10-10 15:16:18 +02:00

46 lines
1.1 KiB
C++

#include "commands.hpp"
#include <memory>
#include <apps/opencs/view/render/editmode.hpp>
#include <apps/opencs/view/render/terrainselection.hpp>
#include <components/debug/debuglog.hpp>
#include "terrainshapemode.hpp"
#include "worldspacewidget.hpp"
CSVRender::DrawTerrainSelectionCommand::DrawTerrainSelectionCommand(
WorldspaceWidget* worldspaceWidget, QUndoCommand* parent)
: mWorldspaceWidget(worldspaceWidget)
{
}
void CSVRender::DrawTerrainSelectionCommand::redo()
{
tryUpdate();
}
void CSVRender::DrawTerrainSelectionCommand::undo()
{
tryUpdate();
}
void CSVRender::DrawTerrainSelectionCommand::tryUpdate()
{
if (!mWorldspaceWidget)
{
Log(Debug::Verbose) << "Can't update terrain selection, no WorldspaceWidget found!";
return;
}
auto terrainMode = dynamic_cast<CSVRender::TerrainShapeMode*>(mWorldspaceWidget->getEditMode());
if (!terrainMode)
{
Log(Debug::Verbose) << "Can't update terrain selection in current EditMode";
return;
}
terrainMode->getTerrainSelection()->update();
}