Added scene selector in the SettingsEngine, in the GUI under Global Properties.

Has placeholder functionality for what's coming in the next commit.
This commit is contained in:
Matthew Territo
2016-07-27 16:45:43 -06:00
parent 035f5ba989
commit fdb90f74ac
3 changed files with 56 additions and 7 deletions

View File

@@ -25,17 +25,57 @@
#include <openspace/engine/settingsengine.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/scene/scene.h>
#include <ghoul/ghoul.h>
#include <ghoul/filesystem/filesystem.h>
namespace openspace {
SettingsEngine::SettingsEngine() :
_eyeSeparation("eyeSeparation", "Eye Separation" , 0.f, 0.f, 10.f)
SettingsEngine::SettingsEngine()
: _eyeSeparation("eyeSeparation", "Eye Separation" , 0.f, 0.f, 10.f)
, _scenes("scenes", "Scene", properties::OptionProperty::DisplayType::DROPDOWN)
{
setName("Global Properties");
}
void SettingsEngine::initialize() {
initEyeSeparation();
initSceneFiles();
}
void SettingsEngine::initEyeSeparation() {
addProperty(_eyeSeparation);
setName("Global");
// Set interaction to change the window's (SGCT's) eye separation
_eyeSeparation.onChange(
[this](){ OsEng.windowWrapper().setEyeSeparationDistance(_eyeSeparation); });
[this]() { OsEng.windowWrapper().setEyeSeparationDistance(_eyeSeparation); });
}
void SettingsEngine::initSceneFiles() {
addProperty(_scenes);
// Load all matching files in the Scene
// TODO: match regex with either with new ghoul readFiles or local code
std::string sceneDir = "${SCENE}";
std::vector<std::string> scenes = ghoul::filesystem::Directory(sceneDir).readFiles();
for (std::size_t i = 0; i < scenes.size(); ++i) {
_scenes.addOption(i, scenes[i]);
}
// Set interaction to change ConfigurationManager and schedule the load
_scenes.onChange(
[this]() {
std::string sceneFile = _scenes.getDescriptionByValue(_scenes);
OsEng.configurationManager().setValue(
ConfigurationManager::KeyConfigScene, sceneFile);
std::cout << "For a relatively atomic commit, just pretending to load "
<< sceneFile << std::endl;
}
);
}
}