Browse Source

Add MvTexCoordCmd undo command

master
Krisjanis Rijnieks 10 years ago
parent
commit
35593c1612
  1. 6
      example/example.xcodeproj/project.pbxproj
  2. 2
      src/Commands/MvAllTexCoordsCmd.h
  3. 26
      src/Commands/MvTexCoordCmd.cpp
  4. 29
      src/Commands/MvTexCoordCmd.h
  5. 16
      src/Surfaces/SurfaceManagerGui.cpp
  6. 1
      src/Surfaces/SurfaceManagerGui.h
  7. 5
      src/UserInterface/TextureEditor.cpp
  8. 1
      src/UserInterface/TextureEditor.h

6
example/example.xcodeproj/project.pbxproj

@ -9,6 +9,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 */; };
391717F71B0BCBB500F9A484 /* MvTexCoordCmd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 391717F51B0BCBB500F9A484 /* MvTexCoordCmd.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 */; };
@ -126,6 +127,8 @@
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>"; };
391717F51B0BCBB500F9A484 /* MvTexCoordCmd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MvTexCoordCmd.cpp; path = Commands/MvTexCoordCmd.cpp; sourceTree = "<group>"; };
391717F61B0BCBB500F9A484 /* MvTexCoordCmd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MvTexCoordCmd.h; path = Commands/MvTexCoordCmd.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>"; };
@ -669,6 +672,8 @@
391717ED1B08FFDA00F9A484 /* SetGuiModeCmd.cpp */,
391717F21B0A8A7300F9A484 /* MvAllTexCoordsCmd.h */,
391717F11B0A8A7300F9A484 /* MvAllTexCoordsCmd.cpp */,
391717F61B0BCBB500F9A484 /* MvTexCoordCmd.h */,
391717F51B0BCBB500F9A484 /* MvTexCoordCmd.cpp */,
);
name = Commands;
sourceTree = "<group>";
@ -906,6 +911,7 @@
39C1243B19EE9589005DF557 /* DeviceFilter.cpp in Sources */,
39C1243E19EE9589005DF557 /* DirectoryWatcher.cpp in Sources */,
39C1248119F187D5005DF557 /* TextureEditor.cpp in Sources */,
391717F71B0BCBB500F9A484 /* MvTexCoordCmd.cpp in Sources */,
E4B69E210A3A1BDC003C02F2 /* ofApp.cpp in Sources */,
39C1244B19EE9589005DF557 /* snappy.cc in Sources */,
3933D5D719BB87BD000ACA55 /* ofxPanel.cpp in Sources */,

2
src/Commands/MvAllTexCoordsCmd.h

@ -1,6 +1,6 @@
// MvAllTexCoordsCmd
// Move all texture coordinates of a selected surface undoable command
// Created by Krisjanis Rijnieks 2015-05-15
// Created by Krisjanis Rijnieks 2015-05-18
#pragma once

26
src/Commands/MvTexCoordCmd.cpp

@ -0,0 +1,26 @@
#include "MvTexCoordCmd.h"
namespace ofx{
namespace piMapper{
MvTexCoordCmd::MvTexCoordCmd(int jointIndex, TextureEditor * texEditor){
_jointIndex = jointIndex;
_texEditor = texEditor;
}
void MvTexCoordCmd::exec(){
ofLogNotice("MvTexCoordCmd", "exec");
_jointPosition = _texEditor->getJoints()[_jointIndex]->position;
}
void MvTexCoordCmd::undo(){
ofLogNotice("MvTexCoordCmd", "undo");
_texEditor->unselectAllJoints();
_texEditor->getJoints()[_jointIndex]->select();
_texEditor->getJoints()[_jointIndex]->position = _jointPosition;
_texEditor = 0;
}
} // namespace piMapper
} // namespace ofx

29
src/Commands/MvTexCoordCmd.h

@ -0,0 +1,29 @@
// MvTexCoordCmd
// Move texture coordinate of a selected surface and be able to undo it
// Created by Krisjanis Rijnieks 2015-05-19
#pragma once
#include "BaseCmd.h"
#include "CircleJoint.h"
#include "TextureEditor.h"
namespace ofx{
namespace piMapper{
class MvTexCoordCmd : public BaseUndoCmd{
public:
MvTexCoordCmd(int jointIndex, TextureEditor * texEditor);
void exec();
void undo();
private:
ofVec2f _jointPosition;
int _jointIndex;
TextureEditor * _texEditor;
};
} // namespace piMapper
} // namespace ofx

16
src/Surfaces/SurfaceManagerGui.cpp

@ -91,11 +91,23 @@ 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;
int jointIndex = -1;
for (auto i = 0; i < textureEditor.getJoints().size(); i++) {
if (textureEditor.getJoints()[i] == hitJoint) {
jointIndex = i;
break;
}
}
if (jointIndex != -1) {
_cmdManager->exec(new MvTexCoordCmd(jointIndex, &textureEditor));
}
} else {
textureEditor.unselectAllJoints();
}

1
src/Surfaces/SurfaceManagerGui.h

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

5
src/UserInterface/TextureEditor.cpp

@ -230,5 +230,10 @@ CircleJoint* TextureEditor::hitTestJoints(ofVec2f pos) {
}
return NULL;
}
vector<CircleJoint*> & TextureEditor::getJoints(){
return joints;
}
}
}

1
src/UserInterface/TextureEditor.h

@ -34,6 +34,7 @@ class TextureEditor {
void moveSelection(ofVec2f by);
void constrainJointsToQuad(int selectedJointIndex);
CircleJoint* hitTestJoints(ofVec2f pos);
vector<CircleJoint*> & getJoints();
private:
BaseSurface* surface;

Loading…
Cancel
Save