Browse Source

Add loading presets from xml

master
Krisjanis Rijnieks 9 years ago
parent
commit
17433cdb97
  1. 4
      src/Application/Modes/ProjectionMappingMode.cpp
  2. 19
      src/Application/SettingsLoader.cpp
  3. 4
      src/Application/SettingsLoader.h

4
src/Application/Modes/ProjectionMappingMode.cpp

@ -285,6 +285,10 @@ void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & arg
} }
break; break;
case 'n': // Set next preset
app->getSurfaceManager()->setNextPreset();
break;
default: default:
break; break;
} }

19
src/Application/SettingsLoader.cpp

@ -32,12 +32,6 @@ bool SettingsLoader::load(
return false; return false;
} }
/* TODO: Add presets.
* Presets would be surface groups. Now we are using a single <surfaces> tag
* to store only one possible composition. We can multiply the <surfaces> container
* in order to get presets working.
*/
if(!xmlSettings->tagExists("surfaces")){ if(!xmlSettings->tagExists("surfaces")){
ofLogWarning("SettingsLoader::load()") << "XML settings is empty or has wrong markup"; ofLogWarning("SettingsLoader::load()") << "XML settings is empty or has wrong markup";
return false; return false;
@ -47,13 +41,14 @@ bool SettingsLoader::load(
cout << "numPresets: " << numPresets << endl; cout << "numPresets: " << numPresets << endl;
// Clear previous presets and surfaces first. // Clear previous presets and surfaces first.
// TODO... surfaceManager.clearPresets();
// Add new presets. // Loop through <surfaces> tags in the XML.
// surfaceManager.createPreset... for(unsigned int i = 0; i < numPresets; ++i){
SurfaceStack * surfaces = surfaceManager.createPreset();
xmlSettings->pushTag("surfaces"); xmlSettings->pushTag("surfaces", i);
SurfaceStack * surfaces = surfaceManager.createPreset();
int numSurfaces = xmlSettings->getNumTags("surface"); int numSurfaces = xmlSettings->getNumTags("surface");
for(int i = 0; i < numSurfaces; i++){ for(int i = 0; i < numSurfaces; i++){
@ -139,6 +134,8 @@ bool SettingsLoader::load(
} }
xmlSettings->popTag(); // surfaces xmlSettings->popTag(); // surfaces
} // for
} }
_lastLoadedFilename = fileName; _lastLoadedFilename = fileName;

4
src/Application/SettingsLoader.h

@ -34,5 +34,5 @@ class SettingsLoader {
string _lastLoadedFilename; string _lastLoadedFilename;
}; };
} } // namespace piMapper
} } // namespace ofx
Loading…
Cancel
Save