2021-05-10 12:20:53 +00:00
|
|
|
#include "commands.hpp"
|
|
|
|
|
2022-10-10 11:41:36 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <apps/opencs/view/render/editmode.hpp>
|
|
|
|
#include <apps/opencs/view/render/terrainselection.hpp>
|
|
|
|
|
2021-08-22 19:22:13 +00:00
|
|
|
#include <components/debug/debuglog.hpp>
|
2021-05-10 12:20:53 +00:00
|
|
|
|
2021-08-22 19:22:13 +00:00
|
|
|
#include "terrainshapemode.hpp"
|
|
|
|
#include "worldspacewidget.hpp"
|
2021-05-10 12:20:53 +00:00
|
|
|
|
2021-08-22 19:22:13 +00:00
|
|
|
CSVRender::DrawTerrainSelectionCommand::DrawTerrainSelectionCommand(
|
|
|
|
WorldspaceWidget* worldspaceWidget, QUndoCommand* parent)
|
|
|
|
: mWorldspaceWidget(worldspaceWidget)
|
2021-05-10 12:20:53 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSVRender::DrawTerrainSelectionCommand::redo()
|
|
|
|
{
|
2021-08-22 19:22:13 +00:00
|
|
|
tryUpdate();
|
2021-05-10 12:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSVRender::DrawTerrainSelectionCommand::undo()
|
|
|
|
{
|
2021-08-22 19:22:13 +00:00
|
|
|
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();
|
2021-05-10 12:20:53 +00:00
|
|
|
}
|