From fa71960821ace9799025270b20b1451ed7978e88 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Tue, 13 Sep 2016 08:53:19 +0300 Subject: [PATCH] Fix not being able to drag vertices in projection mapping mode --- src/Application/States/ProjectionMappingState.cpp | 3 +++ src/Surfaces/SurfaceManagerGui.cpp | 11 +++++++++-- src/UserInterface/ProjectionEditor.cpp | 6 ++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Application/States/ProjectionMappingState.cpp b/src/Application/States/ProjectionMappingState.cpp index a8eb605..a15db1a 100644 --- a/src/Application/States/ProjectionMappingState.cpp +++ b/src/Application/States/ProjectionMappingState.cpp @@ -283,14 +283,17 @@ void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & ar void ProjectionMappingState::onMousePressed(Application * app, ofMouseEventArgs & args){ Gui::instance()->onMousePressed(args); + app->getGui()->mousePressed(args); } void ProjectionMappingState::onMouseReleased(Application * app, ofMouseEventArgs & args){ Gui::instance()->onMouseReleased(args); + app->getGui()->mouseReleased(args); } void ProjectionMappingState::onMouseDragged(Application * app, ofMouseEventArgs & args){ Gui::instance()->onMouseDragged(args); + app->getGui()->mouseDragged(args); } void ProjectionMappingState::onJointPressed(Application * app, GuiJointEvent & e){ diff --git a/src/Surfaces/SurfaceManagerGui.cpp b/src/Surfaces/SurfaceManagerGui.cpp index fd5339a..ec0fea9 100644 --- a/src/Surfaces/SurfaceManagerGui.cpp +++ b/src/Surfaces/SurfaceManagerGui.cpp @@ -163,16 +163,23 @@ void SurfaceManagerGui::mouseReleased(ofMouseEventArgs & args){ } void SurfaceManagerGui::mouseDragged(ofMouseEventArgs & args){ - textureEditor.mouseDragged(args); + if(guiMode == GuiMode::TEXTURE_MAPPING){ + textureEditor.mouseDragged(args); + }else if(guiMode == GuiMode::PROJECTION_MAPPING){ + projectionEditor.mouseDragged(args); + } if(bDrag){ ofVec2f mousePosition = ofVec2f(args.x, args.y); ofVec2f distance = mousePosition - clickPosition; if(guiMode == GuiMode::PROJECTION_MAPPING){ - // add this distance to all vertices in surface + + // Moves the selected surface on drag projectionEditor.moveSelectedSurface(distance); }else if(guiMode == GuiMode::TEXTURE_MAPPING){ + + // Moves the crop area of the texture textureEditor.moveTexCoords(distance); } clickPosition = mousePosition; diff --git a/src/UserInterface/ProjectionEditor.cpp b/src/UserInterface/ProjectionEditor.cpp index a22fa2b..4f0274a 100644 --- a/src/UserInterface/ProjectionEditor.cpp +++ b/src/UserInterface/ProjectionEditor.cpp @@ -78,6 +78,12 @@ void ProjectionEditor::draw(){ } void ProjectionEditor::mouseDragged(ofMouseEventArgs & args){ + + // Pass args to joint mouse events + for(unsigned int i = 0; i < joints.size(); ++i){ + joints[i]->mouseDragged(args); + } + ofVec2f mousePosition = ofVec2f(args.x, args.y); // Collect all vertices of the projection surfaces