diff --git a/src/Surfaces/SurfaceManager.cpp b/src/Surfaces/SurfaceManager.cpp index e096c76..cf9e0a5 100644 --- a/src/Surfaces/SurfaceManager.cpp +++ b/src/Surfaces/SurfaceManager.cpp @@ -427,5 +427,17 @@ void SurfaceManager::setNextPreset(){ // TODO: Create command for this. } +void SurfaceManager::setActivePreset(unsigned int i){ + if(_presets.size() <= 1){ + throw runtime_error("ofxPiMapper: No presets to set."); + } + + if(i >= _presets.size()){ + throw runtime_error("ofxPiMapper: Preset index out of bounds."); + } + + _activePresetIndex = i; +} + } // namespace piMapper } // namespace ofx diff --git a/src/Surfaces/SurfaceManager.h b/src/Surfaces/SurfaceManager.h index 17b5bb9..e5ef5b9 100644 --- a/src/Surfaces/SurfaceManager.h +++ b/src/Surfaces/SurfaceManager.h @@ -71,12 +71,13 @@ class SurfaceManager { void onVertexChanged(int & i); void onVerticesChanged(vector & vertices); - + SurfaceStack * getActivePreset(); SurfaceStack * createPreset(); SurfaceStack * getPresetAt(unsigned int i); void setNextPreset(); + void setActivePreset(unsigned int i); private: BaseSurface * selectedSurface; diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index 734397d..510d620 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -22,6 +22,14 @@ void ofxPiMapper::registerFboSource(ofx::piMapper::FboSource * fboSource){ _application.addFboSource(fboSource); } +void ofxPiMapper::setActivePreset(unsigned int i){ + _application.getSurfaceManager()->setActivePreset(i); +} + bool ofxPiMapper::loadXmlSettings(string fileName){ return _application.loadXmlSettings(fileName); -} \ No newline at end of file +} + +unsigned int ofxPiMapper::getNumPresets(){ + return _application.getSurfaceManager()->getNumPresets(); +} diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index 5012daf..22bb2c1 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -27,8 +27,12 @@ class ofxPiMapper { void registerFboSource(ofx::piMapper::FboSource & fboSource); void registerFboSource(ofx::piMapper::FboSource * fboSource); + void setActivePreset(unsigned int i); + bool loadXmlSettings(string fileName); + + unsigned int getNumPresets(); private: ofx::piMapper::Application _application; -}; \ No newline at end of file +};