diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index a1c5227..fc45d66 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -404,5 +404,62 @@ void Application::setNextSource(){ } } +void Application::addGridRow(){ + if(getSurfaceManager()->getSelectedSurface() != 0){ + if(getSurfaceManager()->getSelectedSurface()->getType() == + SurfaceType::GRID_WARP_SURFACE){ + + // TODO: The command should not require projection editor pointer + getCmdManager()->exec( + new AddGridRowCmd( + (GridWarpSurface *)getSurfaceManager()->getSelectedSurface() )); + } + } +} + +void Application::addGridColumn(){ + if(getSurfaceManager()->getSelectedSurface() != 0){ + if(getSurfaceManager()->getSelectedSurface()->getType() == + SurfaceType::GRID_WARP_SURFACE){ + + // TODO: The command should not require projection editor pointer + getCmdManager()->exec( + new AddGridColCmd( + (GridWarpSurface *)getSurfaceManager()->getSelectedSurface() )); + } + } + +} + +void Application::removeGridRow(){ + if(getSurfaceManager()->getSelectedSurface() != 0){ + if(getSurfaceManager()->getSelectedSurface()->getType() == + SurfaceType::GRID_WARP_SURFACE){ + + if(((GridWarpSurface *)getSurfaceManager()->getSelectedSurface())->getGridRows() > 1){ + // TODO: The command should not require projection editor pointer + getCmdManager()->exec( + new RmGridRowCmd( + (GridWarpSurface *)getSurfaceManager()->getSelectedSurface() )); + } + } + } +} + +void Application::removeGridColumn(){ + if(getSurfaceManager()->getSelectedSurface() != 0){ + if(getSurfaceManager()->getSelectedSurface()->getType() == + SurfaceType::GRID_WARP_SURFACE){ + + if(((GridWarpSurface *)getSurfaceManager()->getSelectedSurface())->getGridCols() > 1){ + // TODO: The command should not require projection editor pointer + getCmdManager()->exec( + new RmGridColCmd( + (GridWarpSurface *)getSurfaceManager()->getSelectedSurface() )); + } + } + } +} + } // namespace piMapper } // namespace ofx diff --git a/src/Application/Application.h b/src/Application/Application.h index 82fed4f..c7ea336 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -98,6 +98,10 @@ class Application : public KeyListener { void scaleDown(); void duplicateSurface(); void setNextSource(); + void addGridRow(); + void addGridColumn(); + void removeGridRow(); + void removeGridColumn(); void setPreset(unsigned int i); void setNextPreset(); diff --git a/src/Application/Modes/ProjectionMappingMode.cpp b/src/Application/Modes/ProjectionMappingMode.cpp index c967043..c6c74e2 100644 --- a/src/Application/Modes/ProjectionMappingMode.cpp +++ b/src/Application/Modes/ProjectionMappingMode.cpp @@ -77,59 +77,19 @@ void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & arg break; case '}': - if(app->getSurfaceManager()->getSelectedSurface() != 0){ - if(app->getSurfaceManager()->getSelectedSurface()->getType() == - SurfaceType::GRID_WARP_SURFACE){ - - // TODO: The command should not require projection editor pointer - app->getCmdManager()->exec( - new AddGridRowCmd( - (GridWarpSurface *)app->getSurfaceManager()->getSelectedSurface() )); - } - } + app->addGridRow(); break; case '{': - if(app->getSurfaceManager()->getSelectedSurface() != 0){ - if(app->getSurfaceManager()->getSelectedSurface()->getType() == - SurfaceType::GRID_WARP_SURFACE){ - - if(((GridWarpSurface *)app->getSurfaceManager()->getSelectedSurface())->getGridRows() > 1){ - // TODO: The command should not require projection editor pointer - app->getCmdManager()->exec( - new RmGridRowCmd( - (GridWarpSurface *)app->getSurfaceManager()->getSelectedSurface() )); - } - } - } + app->removeGridRow(); break; case ']': - if(app->getSurfaceManager()->getSelectedSurface() != 0){ - if(app->getSurfaceManager()->getSelectedSurface()->getType() == - SurfaceType::GRID_WARP_SURFACE){ - - // TODO: The command should not require projection editor pointer - app->getCmdManager()->exec( - new AddGridColCmd( - (GridWarpSurface *)app->getSurfaceManager()->getSelectedSurface() )); - } - } + app->addGridColumn(); break; case '[': - if(app->getSurfaceManager()->getSelectedSurface() != 0){ - if(app->getSurfaceManager()->getSelectedSurface()->getType() == - SurfaceType::GRID_WARP_SURFACE){ - - if(((GridWarpSurface *)app->getSurfaceManager()->getSelectedSurface())->getGridCols() > 1){ - // TODO: The command should not require projection editor pointer - app->getCmdManager()->exec( - new RmGridColCmd( - (GridWarpSurface *)app->getSurfaceManager()->getSelectedSurface() )); - } - } - } + app->removeGridColumn(); break; case '.':