From 9fd904cef4454f016e86a5222b4b582e7b2fce04 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Sat, 29 Oct 2016 15:30:21 +0300 Subject: [PATCH] Create command on TextureMappingMode::moveSelection --- src/Application/Modes/TextureMappingMode.cpp | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Application/Modes/TextureMappingMode.cpp b/src/Application/Modes/TextureMappingMode.cpp index 6eecac9..d62a0c7 100644 --- a/src/Application/Modes/TextureMappingMode.cpp +++ b/src/Application/Modes/TextureMappingMode.cpp @@ -268,7 +268,29 @@ void TextureMappingMode::drawTexture(Application * app){ } void TextureMappingMode::moveSelection(Application * app, ofVec2f by){ - // TODO: Create an undoable command out of this + // TODO: Make the command mechanism more elegant than this + bool foundSelected = false; + + for( + unsigned int i = 0; + i < Gui::instance()->getTextureEditorWidget().getJoints().size(); + ++i){ + + if(Gui::instance()->getTextureEditorWidget().getJoints()[i]->isSelected()){ + app->getCmdManager()->exec( + new MvTexCoordCmd( + i, &Gui::instance()->getTextureEditorWidget())); + foundSelected = true; + break; + } + } + + if(!foundSelected){ + app->getCmdManager()->exec(new MvAllTexCoordsCmd( + app->getSurfaceManager()->getSelectedSurface(), + &Gui::instance()->getTextureEditorWidget())); + } + Gui::instance()->getTextureEditorWidget().moveSelection(by); }