Browse Source

Add `RmGridColCmd`

master
Krisjanis Rijnieks 9 years ago
parent
commit
dd7080a60c
  1. 46
      src/Commands/RmGridColCmd.cpp
  2. 31
      src/Commands/RmGridColCmd.h

46
src/Commands/RmGridColCmd.cpp

@ -0,0 +1,46 @@
#include "RmGridColCmd.h"
namespace ofx {
namespace piMapper {
RmGridColCmd::RmGridColCmd(GridWarpSurface * s, ProjectionEditor * e){
_surface = s;
_editor = e;
_doNotUndo = false;
}
void RmGridColCmd::exec(){
if(_surface->getGridCols() > 1){
_vertices = _surface->getVertices();
_texCoords = _surface->getTexCoords();
_surface->setGridCols(_surface->getGridCols() - 1);
_editor->createJoints();
}else{
_doNotUndo = true;
}
}
void RmGridColCmd::undo(){
ofLogNotice("RmGridColCmd", "undo");
if(_doNotUndo){
return;
}
_surface->setGridCols(_surface->getGridCols() + 1);
vector <ofVec2f> 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

31
src/Commands/RmGridColCmd.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 RmGridColCmd : public BaseUndoCmd {
public:
RmGridColCmd(GridWarpSurface * s, ProjectionEditor * e);
void exec();
void undo();
private:
vector <ofVec3f> _vertices;
vector <ofVec2f> _texCoords;
GridWarpSurface * _surface;
ProjectionEditor * _editor;
bool _doNotUndo;
};
} // namespace piMapper
} // namespace ofx
Loading…
Cancel
Save