From 40e8bf2d0cba540935553b75e4fae639a92a1a46 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Sat, 30 Jan 2016 19:44:20 +0100 Subject: [PATCH] Add `AddGridColCmd` --- src/Commands/AddGridColCmd.cpp | 32 ++++++++++++++++++++++++++++++++ src/Commands/AddGridColCmd.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/Commands/AddGridColCmd.cpp create mode 100644 src/Commands/AddGridColCmd.h diff --git a/src/Commands/AddGridColCmd.cpp b/src/Commands/AddGridColCmd.cpp new file mode 100644 index 0000000..645234e --- /dev/null +++ b/src/Commands/AddGridColCmd.cpp @@ -0,0 +1,32 @@ +#include "AddGridColCmd.h" + +namespace ofx { +namespace piMapper { + +AddGridColCmd::AddGridColCmd(GridWarpSurface * s, ProjectionEditor * e){ + _surface = s; + _editor = e; +} + +void AddGridColCmd::exec(){ + _vertices = _surface->getVertices(); + _texCoords = _surface->getTexCoords(); + _surface->setGridCols(_surface->getGridCols() + 1); + _editor->createJoints(); +} + +void AddGridColCmd::undo(){ + ofLogNotice("AddGridColCmd", "undo"); + _surface->setGridCols(_surface->getGridCols() - 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/AddGridColCmd.h b/src/Commands/AddGridColCmd.h new file mode 100644 index 0000000..c2d84ea --- /dev/null +++ b/src/Commands/AddGridColCmd.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 AddGridColCmd : public BaseUndoCmd { + + public: + AddGridColCmd(GridWarpSurface * s, ProjectionEditor * e); + void exec(); + void undo(); + + private: + vector _vertices; + vector _texCoords; + GridWarpSurface * _surface; + ProjectionEditor * _editor; + +}; + +} // namespace piMapper +} // namespace ofx +