diff --git a/src/Application/TextureMappingState.cpp b/src/Application/TextureMappingState.cpp index a347ea9..67881de 100644 --- a/src/Application/TextureMappingState.cpp +++ b/src/Application/TextureMappingState.cpp @@ -16,5 +16,15 @@ void TextureMappingState::draw(Application * app){ app->getGui()->draw(); } +void TextureMappingState::onKeyPressed(Application * app, ofKeyEventArgs & args){ + switch(args.key){ + + case '>': + app->getCmdManager()->exec( + new SelNextTexCoordCmd(app->getGui()->getTextureEditor())); + break; + } +} + } // namespace piMapper } // namespace ofx \ No newline at end of file diff --git a/src/Application/TextureMappingState.h b/src/Application/TextureMappingState.h index aed5853..4a84084 100644 --- a/src/Application/TextureMappingState.h +++ b/src/Application/TextureMappingState.h @@ -4,6 +4,7 @@ #include "ofEvents.h" #include "ofLog.h" #include "ofGraphics.h" +#include "SelNextTexCoordCmd.h" namespace ofx { namespace piMapper { @@ -13,6 +14,7 @@ class TextureMappingState : public ApplicationBaseState { public: static TextureMappingState * instance(); void draw(Application * app); + void onKeyPressed(Application * app, ofKeyEventArgs & args); private: static TextureMappingState * _instance; diff --git a/src/Surfaces/SurfaceManagerGui.cpp b/src/Surfaces/SurfaceManagerGui.cpp index 70435c8..28adf85 100644 --- a/src/Surfaces/SurfaceManagerGui.cpp +++ b/src/Surfaces/SurfaceManagerGui.cpp @@ -315,6 +315,10 @@ ProjectionEditor * SurfaceManagerGui::getProjectionEditor(){ return &projectionEditor; } +TextureEditor * SurfaceManagerGui::getTextureEditor(){ + return &textureEditor; +} + void SurfaceManagerGui::onVertexChanged(int & i){ //cout << "VERTEX CHANGED: " << vertex.x << ", " << vertex.y << endl; bool isDragged = projectionEditor.getJoints()->at(i)->isDragged(); diff --git a/src/Surfaces/SurfaceManagerGui.h b/src/Surfaces/SurfaceManagerGui.h index 4fb4483..7b0f52f 100644 --- a/src/Surfaces/SurfaceManagerGui.h +++ b/src/Surfaces/SurfaceManagerGui.h @@ -48,6 +48,7 @@ class SurfaceManagerGui { void stopDrag(); ProjectionEditor * getProjectionEditor(); + TextureEditor * getTextureEditor(); void onVertexChanged(int & i); void onVerticesChanged(vector & vertices); diff --git a/src/UserInterface/TextureEditor.cpp b/src/UserInterface/TextureEditor.cpp index 17266fb..3404b9a 100644 --- a/src/UserInterface/TextureEditor.cpp +++ b/src/UserInterface/TextureEditor.cpp @@ -238,6 +238,52 @@ void TextureEditor::unselectAllJoints(){ } } +void TextureEditor::selectNextTexCoord(){ + if(joints.size() <= 0){ + return; + } + + // Search for current selected joint + for(unsigned int i = 0; i < joints.size(); ++i){ + if(joints[i]->isSelected()){ + unsigned int next = i + 1; + if(next >= joints.size()){ + next = 0; + } + unselectAllJoints(); + joints[next]->select(); + return; + } + } + + // If none found, select 0th + joints[0]->select(); +} + +void TextureEditor::selectPrevTexCoord(){ + if(joints.size() <= 0){ + return; + } + + // Search for current selected joint + for(unsigned int i = 0; i < joints.size(); ++i){ + if(joints[i]->isSelected()){ + unsigned int prev; + if(i == 0){ + prev = joints.size() - 1; + }else{ + prev = i - 1; + } + unselectAllJoints(); + joints[prev]->select(); + return; + } + } + + // Select last if none selected + joints[joints.size() - 1]->select(); +} + void TextureEditor::moveTexCoords(ofVec2f by){ if(surface == 0){ return; diff --git a/src/UserInterface/TextureEditor.h b/src/UserInterface/TextureEditor.h index 2220b55..d73a70a 100644 --- a/src/UserInterface/TextureEditor.h +++ b/src/UserInterface/TextureEditor.h @@ -33,6 +33,8 @@ class TextureEditor { void createJoints(); void clearJoints(); void unselectAllJoints(); + void selectNextTexCoord(); + void selectPrevTexCoord(); void moveTexCoords(ofVec2f by); void stopDragJoints(); void moveSelection(ofVec2f by);