diff --git a/src/Commands/RmGridRowCmd.cpp b/src/Commands/RmGridRowCmd.cpp new file mode 100644 index 0000000..0df2359 --- /dev/null +++ b/src/Commands/RmGridRowCmd.cpp @@ -0,0 +1,46 @@ +#include "RmGridRowCmd.h" + +namespace ofx { +namespace piMapper { + +RmGridRowCmd::RmGridRowCmd(GridWarpSurface * s, ProjectionEditor * e){ + _surface = s; + _editor = e; + _doNotUndo = false; +} + +void RmGridRowCmd::exec(){ + + if(_surface->getGridRows() > 1){ + _vertices = _surface->getVertices(); + _texCoords = _surface->getTexCoords(); + _surface->setGridRows(_surface->getGridRows() - 1); + _editor->createJoints(); + }else{ + _doNotUndo = true; + } + +} + +void RmGridRowCmd::undo(){ + ofLogNotice("RmGridRowCmd", "undo"); + + if(_doNotUndo){ + return; + } + + _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/RmGridRowCmd.h b/src/Commands/RmGridRowCmd.h new file mode 100644 index 0000000..5643b04 --- /dev/null +++ b/src/Commands/RmGridRowCmd.h @@ -0,0 +1,31 @@ +#pragma once + +#include "SurfaceManager.h" +#include "BaseCmd.h" +#include "GridWarpSurface.h" +#include "ProjectionEditor.h" + +class ofxPiMapper; + +namespace ofx { +namespace piMapper { + +class RmGridRowCmd : public BaseUndoCmd { + + public: + RmGridRowCmd(GridWarpSurface * s, ProjectionEditor * e); + void exec(); + void undo(); + + private: + vector _vertices; + vector _texCoords; + GridWarpSurface * _surface; + ProjectionEditor * _editor; + bool _doNotUndo; + +}; + +} // namespace piMapper +} // namespace ofx +