From e5329d31b6799b08d6a52ceb593e0211058cd490 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Sat, 30 Jan 2016 19:29:31 +0100 Subject: [PATCH] Add `AddGridRowCmd` --- src/Commands/AddGridRowCmd.cpp | 32 ++++++++++++++++++++++++++++++++ src/Commands/AddGridRowCmd.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/Commands/AddGridRowCmd.h diff --git a/src/Commands/AddGridRowCmd.cpp b/src/Commands/AddGridRowCmd.cpp index e69de29..7f76335 100644 --- a/src/Commands/AddGridRowCmd.cpp +++ b/src/Commands/AddGridRowCmd.cpp @@ -0,0 +1,32 @@ +#include "AddGridRowCmd.h" + +namespace ofx { +namespace piMapper { + +AddGridRowCmd::AddGridRowCmd(GridWarpSurface * s, ProjectionEditor * e){ + _surface = s; + _editor = e; +} + +void AddGridRowCmd::exec(){ + _vertices = _surface->getVertices(); + _texCoords = _surface->getTexCoords(); + _surface->setGridRows(_surface->getGridRows() + 1); + _editor->createJoints(); +} + +void AddGridRowCmd::undo(){ + ofLogNotice("AddGridRowCmd", "undo"); + _surface->setGridRows(_surface->getGridRows() - 1); + vector v; + for(int i = 0; i < _vertices.size(); ++i){ + v.push_back( ofVec2f(_vertices[i].x, _vertices[i].y) ); + } + _surface->setVertices(v); + _surface->setTexCoords(_texCoords); + _editor->createJoints(); +} + +} // namespace piMapper +} // namespace ofx + diff --git a/src/Commands/AddGridRowCmd.h b/src/Commands/AddGridRowCmd.h new file mode 100644 index 0000000..9401e28 --- /dev/null +++ b/src/Commands/AddGridRowCmd.h @@ -0,0 +1,30 @@ +#pragma once + +#include "SurfaceManager.h" +#include "BaseCmd.h" +#include "GridWarpSurface.h" +#include "ProjectionEditor.h" + +class ofxPiMapper; + +namespace ofx { +namespace piMapper { + +class AddGridRowCmd : public BaseUndoCmd { + + public: + AddGridRowCmd(GridWarpSurface * s, ProjectionEditor * e); + void exec(); + void undo(); + + private: + vector _vertices; + vector _texCoords; + GridWarpSurface * _surface; + ProjectionEditor * _editor; + +}; + +} // namespace piMapper +} // namespace ofx +