From 687960c5373a130428b06f9182f0e727b21e585b Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Wed, 25 Jan 2017 19:43:22 +0100 Subject: [PATCH] Add ofxPiMapper::togglePerspective() --- src/Application/Application.cpp | 11 +++++++++++ src/Application/Application.h | 1 + src/Application/Modes/ProjectionMappingMode.cpp | 12 +----------- src/ofxPiMapper.cpp | 4 ++++ src/ofxPiMapper.h | 1 + 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index fe845a3..7f6c39b 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -223,6 +223,17 @@ void Application::toggleInfo(){ _info.toggle(); } +void Application::togglePerspective(){ + if(getSurfaceManager()->getSelectedSurface() == 0){ + return; + } + + if(getSurfaceManager()->getSelectedSurface()->getType() == SurfaceType::QUAD_SURFACE){ + getCmdManager()->exec(new TogglePerspectiveCmd( + (QuadSurface *)getSurfaceManager()->getSelectedSurface())); + } +} + void Application::saveProject(){ ofLogNotice("Application::saveProject", "Saving project..."); _surfaceManager.saveXmlSettings(SettingsLoader::instance()->getLastLoadedFilename()); diff --git a/src/Application/Application.h b/src/Application/Application.h index 19ca697..719c535 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -65,6 +65,7 @@ class Application : public KeyListener { void eraseSurface(int i); void setInfoText(string text); void toggleInfo(); + void togglePerspective(); void saveProject(); bool loadXmlSettings(string fileName); diff --git a/src/Application/Modes/ProjectionMappingMode.cpp b/src/Application/Modes/ProjectionMappingMode.cpp index 01585ef..07a4a15 100644 --- a/src/Application/Modes/ProjectionMappingMode.cpp +++ b/src/Application/Modes/ProjectionMappingMode.cpp @@ -79,17 +79,7 @@ void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & arg break; case 'p': - if(app->getSurfaceManager()->getSelectedSurface() == 0){ - break; - } - - if(app->getSurfaceManager()->getSelectedSurface()->getType() == - SurfaceType::QUAD_SURFACE){ - - app->getCmdManager()->exec( - new TogglePerspectiveCmd( - (QuadSurface *)app->getSurfaceManager()->getSelectedSurface() ) ); - } + app->togglePerspective(); break; case '}': diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index 108a574..74023ce 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -83,6 +83,10 @@ void ofxPiMapper::selectSurface(int i){ _application.getState()->selectSurface(&_application, i); } +void ofxPiMapper::togglePerspective(){ + _application.togglePerspective(); +} + void ofxPiMapper::selectNextSurface(){ _application.getState()->selectNextSurface(&_application); } diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index d7bcea1..ecd0b7b 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -48,6 +48,7 @@ class ofxPiMapper { // Surfaces, active preset unsigned int getNumSurfaces(); void selectSurface(int i); + void togglePerspective(); void selectNextSurface(); void selectPrevSurface(); void duplicateSurface();