Browse Source

Rename `MvSurfaceCmd` to `StartDragSurfaceCmd`

Also optimize - remove the need to pass projection editor as an argument
master
Krisjanis Rijnieks 9 years ago
parent
commit
94d76d786e
  1. 29
      src/Commands/MvSurfaceCmd.cpp
  2. 31
      src/Commands/MvSurfaceCmd.h
  3. 23
      src/Commands/StartDragSurfaceCmd.cpp
  4. 24
      src/Commands/StartDragSurfaceCmd.h

29
src/Commands/MvSurfaceCmd.cpp

@ -1,29 +0,0 @@
#include "MvSurfaceCmd.h"
namespace ofx {
namespace piMapper {
MvSurfaceCmd::MvSurfaceCmd(BaseSurface * surface,
ProjectionEditor * projectionEditor){
_surface = surface;
_projectionEditor = projectionEditor;
}
void MvSurfaceCmd::exec(){
ofLogNotice("MvSurfaceCmd", "exec");
_previousVertices = _surface->getVertices();
_surface->setMoved(false);
}
void MvSurfaceCmd::undo(){
ofLogNotice("MvSurfaceCmd", "undo");
_surface->moveBy(_previousVertices[0] - _surface->getVertices()[0]);
_projectionEditor->updateJoints();
_previousVertices.clear();
_surface = 0;
}
} // namespace piMapper
} // namespace ofx

31
src/Commands/MvSurfaceCmd.h

@ -1,31 +0,0 @@
// MvSurfaceCmd
// Provides with option to undo move surface operation.
// Created by Krisjanis Rijnieks 2015-05-14
#pragma once
#include "BaseCmd.h"
#include "BaseSurface.h"
#include "ProjectionEditor.h"
namespace ofx {
namespace piMapper {
class MvSurfaceCmd : public BaseUndoCmd {
public:
MvSurfaceCmd(BaseSurface * surface,
ProjectionEditor * projectionEditor);
void exec();
void undo();
private:
BaseSurface * _surface;
ProjectionEditor * _projectionEditor;
vector <ofVec3f> _previousVertices;
};
} // namespace piMapper
} // namespace ofx

23
src/Commands/StartDragSurfaceCmd.cpp

@ -0,0 +1,23 @@
#include "StartDragSurfaceCmd.h"
namespace ofx {
namespace piMapper {
StartDragSurfaceCmd::StartDragSurfaceCmd(BaseSurface * surface){
_surface = surface;
}
void StartDragSurfaceCmd::exec(){
ofLogNotice("StartDragSurfaceCmd", "exec");
_previousVertices = _surface->getVertices();
_surface->setMoved(false);
}
void StartDragSurfaceCmd::undo(){
ofLogNotice("StartDragSurfaceCmd", "undo");
_surface->moveBy(_previousVertices[0] - _surface->getVertices()[0]);
}
} // namespace piMapper
} // namespace ofx

24
src/Commands/StartDragSurfaceCmd.h

@ -0,0 +1,24 @@
#pragma once
#include "BaseCmd.h"
#include "BaseSurface.h"
namespace ofx {
namespace piMapper {
class StartDragSurfaceCmd : public BaseUndoCmd {
public:
StartDragSurfaceCmd(BaseSurface * surface);
void exec();
void undo();
private:
BaseSurface * _surface;
vector <ofVec3f> _previousVertices;
};
} // namespace piMapper
} // namespace ofx
Loading…
Cancel
Save