Browse Source

Add MvAllTexCoordsCmd undo feature

master
Krisjanis Rijnieks 10 years ago
parent
commit
424a7827c1
  1. 6
      example/example.xcodeproj/project.pbxproj
  2. 27
      src/Commands/MvAllTexCoordsCmd.cpp
  3. 29
      src/Commands/MvAllTexCoordsCmd.h
  4. 11
      src/Surfaces/SurfaceManagerGui.cpp
  5. 1
      src/Surfaces/SurfaceManagerGui.h

6
example/example.xcodeproj/project.pbxproj

@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
391717EF1B08FFDA00F9A484 /* SetGuiModeCmd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 391717ED1B08FFDA00F9A484 /* SetGuiModeCmd.cpp */; };
391717F31B0A8A7300F9A484 /* MvAllTexCoordsCmd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 391717F11B0A8A7300F9A484 /* MvAllTexCoordsCmd.cpp */; };
3926483B192224DA0008A7F5 /* ofxXmlSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 39264839192224DA0008A7F5 /* ofxXmlSettings.cpp */; };
39264841192224F90008A7F5 /* tinyxml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3926483D192224F90008A7F5 /* tinyxml.cpp */; };
39264842192224F90008A7F5 /* tinyxmlerror.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3926483F192224F90008A7F5 /* tinyxmlerror.cpp */; };
@ -123,6 +124,8 @@
/* Begin PBXFileReference section */
391717ED1B08FFDA00F9A484 /* SetGuiModeCmd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SetGuiModeCmd.cpp; path = Commands/SetGuiModeCmd.cpp; sourceTree = "<group>"; };
391717EE1B08FFDA00F9A484 /* SetGuiModeCmd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SetGuiModeCmd.h; path = Commands/SetGuiModeCmd.h; sourceTree = "<group>"; };
391717F11B0A8A7300F9A484 /* MvAllTexCoordsCmd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MvAllTexCoordsCmd.cpp; path = Commands/MvAllTexCoordsCmd.cpp; sourceTree = "<group>"; };
391717F21B0A8A7300F9A484 /* MvAllTexCoordsCmd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MvAllTexCoordsCmd.h; path = Commands/MvAllTexCoordsCmd.h; sourceTree = "<group>"; };
39264839192224DA0008A7F5 /* ofxXmlSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ofxXmlSettings.cpp; path = ../../ofxXmlSettings/src/ofxXmlSettings.cpp; sourceTree = "<group>"; };
3926483A192224DA0008A7F5 /* ofxXmlSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ofxXmlSettings.h; path = ../../ofxXmlSettings/src/ofxXmlSettings.h; sourceTree = "<group>"; };
3926483D192224F90008A7F5 /* tinyxml.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tinyxml.cpp; sourceTree = "<group>"; };
@ -664,6 +667,8 @@
39A9AADE1B04E78600AA83BC /* RmSurfaceCmd.cpp */,
391717EE1B08FFDA00F9A484 /* SetGuiModeCmd.h */,
391717ED1B08FFDA00F9A484 /* SetGuiModeCmd.cpp */,
391717F21B0A8A7300F9A484 /* MvAllTexCoordsCmd.h */,
391717F11B0A8A7300F9A484 /* MvAllTexCoordsCmd.cpp */,
);
name = Commands;
sourceTree = "<group>";
@ -886,6 +891,7 @@
39C1244A19EE9589005DF557 /* snappy-stubs-internal.cc in Sources */,
39C1245F19F08965005DF557 /* VideoSource.cpp in Sources */,
39C1244119EE9589005DF557 /* HexBinaryEncoding.cpp in Sources */,
391717F31B0A8A7300F9A484 /* MvAllTexCoordsCmd.cpp in Sources */,
397EFC7C1A08E7680009286E /* ofxPiMapper.cpp in Sources */,
39C1244219EE9589005DF557 /* HiddenFileFilter.cpp in Sources */,
39C1244819EE9589005DF557 /* SearchPath.cpp in Sources */,

27
src/Commands/MvAllTexCoordsCmd.cpp

@ -0,0 +1,27 @@
#include "MvAllTexCoordsCmd.h"
namespace ofx{
namespace piMapper{
MvAllTexCoordsCmd::MvAllTexCoordsCmd(BaseSurface * surface, TextureEditor * texEditor){
_surface = surface;
_texEditor = texEditor;
}
void MvAllTexCoordsCmd::exec(){
ofLogNotice("MvAllTexCoordsCmd", "exec");
_texCoords = _surface->getTexCoords();
}
void MvAllTexCoordsCmd::undo(){
ofLogNotice("MvAllTexCoordsCmd", "undo");
ofVec2f dist = _texCoords[0] - _surface->getTexCoords()[0];
dist.x = _surface->getSource()->getTexture()->getWidth() * dist.x;
dist.y = _surface->getSource()->getTexture()->getHeight() * dist.y;
_texEditor->moveTexCoords(dist);
_surface = 0;
}
} // namespace piMapper
} // namespace ofx

29
src/Commands/MvAllTexCoordsCmd.h

@ -0,0 +1,29 @@
// MvAllTexCoordsCmd
// Move all texture coordinates of a selected surface undoable command
// Created by Krisjanis Rijnieks 2015-05-15
#pragma once
#include "BaseCmd.h"
#include "BaseSurface.h"
#include "TextureEditor.h"
namespace ofx{
namespace piMapper{
class MvAllTexCoordsCmd : public BaseUndoCmd{
public:
MvAllTexCoordsCmd(BaseSurface * surface, TextureEditor * texEditor);
void exec();
void undo();
private:
vector<ofVec2f> _texCoords;
BaseSurface * _surface;
TextureEditor * _texEditor;
};
} // namespace piMapper
} // namespace ofx

11
src/Surfaces/SurfaceManagerGui.cpp

@ -91,6 +91,8 @@ namespace ofx {
textureEditor.hitTestJoints(ofVec2f(args.x, args.y));
if (hitJoint != NULL) {
textureEditor.unselectAllJoints();
// TODO: Add texture coord move command
// MvTexCoordCmd
hitJoint->select();
hitJoint->startDrag();
bSurfaceSelected = true;
@ -101,9 +103,16 @@ namespace ofx {
if (surfaceManager->getSelectedSurface() != NULL && !bSurfaceSelected) {
// hittest texture area to see if we are hitting the texture surface
if (surfaceManager->getSelectedSurface()->getTextureHitArea().inside(
args.x, args.y)) {
args.x, args.y)) {
// TODO: move these to a separate routine
clickPosition = ofVec2f(args.x, args.y);
startDrag();
_cmdManager->exec(new MvAllTexCoordsCmd(
surfaceManager->getSelectedSurface(),
&textureEditor));
}
}

1
src/Surfaces/SurfaceManagerGui.h

@ -15,6 +15,7 @@
#include "MvSurfaceCmd.h"
#include "SelSurfaceCmd.h"
#include "MvSurfaceVertCmd.h"
#include "MvAllTexCoordsCmd.h"
namespace ofx {
namespace piMapper {

Loading…
Cancel
Save