mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-01 09:10:18 -06:00
SGCT compile fix
First pass for pull request
This commit is contained in:
@@ -517,7 +517,7 @@ void mainPostSyncPreDrawFunc() {
|
||||
|
||||
|
||||
|
||||
void mainRenderFunc(const RenderData& data) {
|
||||
void mainRenderFunc(const sgct::RenderData& data) {
|
||||
ZoneScoped
|
||||
|
||||
#ifdef OPENSPACE_HAS_VTUNE
|
||||
@@ -592,7 +592,7 @@ void mainRenderFunc(const RenderData& data) {
|
||||
|
||||
|
||||
|
||||
void mainDraw2DFunc(const RenderData& data) {
|
||||
void mainDraw2DFunc(const sgct::RenderData& data) {
|
||||
ZoneScoped
|
||||
|
||||
#ifdef OPENSPACE_HAS_VTUNE
|
||||
@@ -1295,9 +1295,9 @@ int main(int argc, char** argv) {
|
||||
Engine::create(cluster, callbacks, config);
|
||||
}
|
||||
catch (...) {
|
||||
Engine::destroy();
|
||||
global::openSpaceEngine.deinitialize();
|
||||
ghoul::deinitialize();
|
||||
Engine::destroy();
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
#Asset
|
||||
scene/solarsystem/planets/earth/earth required
|
||||
scene/solarsystem/planets/earth/satellites/satellites required
|
||||
scene/solarsystem/planets/earth/satellites/satellites required
|
||||
|
||||
#Property
|
||||
setPropertyValue {earth_satellites}.Renderable.Enabled false
|
||||
setPropertyValue {earth_satellites}.Renderable.Enabled false
|
||||
|
||||
#Time
|
||||
relative -1d
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
const glm::mat4& projectionMatrix);
|
||||
void drawOverlays();
|
||||
void postDraw();
|
||||
std::vector<Profile::AssetEvent> listOfAllAssetEvents();
|
||||
std::vector<Profile::AssetEvent> assetEvents();
|
||||
void resetAssetChangeTracking();
|
||||
void resetPropertyChangeFlags();
|
||||
void keyboardCallback(Key key, KeyModifier mod, KeyAction action);
|
||||
|
||||
@@ -500,7 +500,7 @@ public:
|
||||
*
|
||||
* \return true if the property has changed
|
||||
*/
|
||||
bool hasChanged();
|
||||
bool hasChanged() const;
|
||||
|
||||
/**
|
||||
* Reset the valChanged flag to an unchanged state, as if value has not been changed.
|
||||
@@ -544,7 +544,7 @@ protected:
|
||||
std::vector<std::pair<OnDeleteHandle, std::function<void()>>> _onDeleteCallbacks;
|
||||
|
||||
/// Flag indicating that this property value has been changed after initialization
|
||||
bool valChanged = false;
|
||||
bool _isValueDirty = false;
|
||||
|
||||
private:
|
||||
void notifyDeleteListeners();
|
||||
|
||||
@@ -176,7 +176,7 @@ void openspace::properties::TemplateProperty<T>::setValue(T val) {
|
||||
if (val != _value) {
|
||||
_value = std::move(val);
|
||||
notifyChangeListeners();
|
||||
valChanged = true;
|
||||
_isValueDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ void TemplateProperty<T>::set(std::any value) {
|
||||
if (v != _value) {
|
||||
_value = std::move(v);
|
||||
notifyChangeListeners();
|
||||
valChanged = true;
|
||||
_isValueDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,12 +174,12 @@ public:
|
||||
* Retrieve a reference to vector list of all assets events, including require,
|
||||
* request, and remove
|
||||
*/
|
||||
std::vector<Profile::AssetEvent>& listOfAllAssetEvents();
|
||||
const std::vector<Profile::AssetEvent>& assetEvents() const;
|
||||
|
||||
/**
|
||||
* Clear lists of all assets that have been either requested, required, or removed
|
||||
*/
|
||||
void listOfAllAssetEvents_reset();
|
||||
void resetAssetEvents();
|
||||
|
||||
private:
|
||||
std::shared_ptr<Asset> require(const std::string& identifier);
|
||||
@@ -241,9 +241,6 @@ private:
|
||||
int _assetsTableRef;
|
||||
|
||||
std::vector<Profile::AssetEvent> _profileAssets;
|
||||
std::vector<std::string> _profileAssetsRequired;
|
||||
std::vector<std::string> _profileAssetsRequested;
|
||||
std::vector<std::string> _profileAssetsRemoved;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -71,8 +71,8 @@ public:
|
||||
std::shared_ptr<Asset> child) override;
|
||||
|
||||
bool update();
|
||||
const std::vector<Profile::AssetEvent>& listOfAllAssetEvents() const;
|
||||
void listOfAllAssetEvents_reset();
|
||||
const std::vector<Profile::AssetEvent>& assetEvents() const;
|
||||
void resetAssetEvents();
|
||||
scripting::LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
|
||||
@@ -25,9 +25,8 @@
|
||||
#ifndef __OPENSPACE_CORE___PROFILE___H__
|
||||
#define __OPENSPACE_CORE___PROFILE___H__
|
||||
|
||||
#include <openspace/scene/profilefile.h>
|
||||
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/scene/profilefile.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/scene/scenelicense.h>
|
||||
#include <ghoul/misc/easing.h>
|
||||
@@ -45,24 +44,18 @@ namespace openspace {
|
||||
namespace documentation { struct Documentation; }
|
||||
namespace scripting { struct LuaLibrary; }
|
||||
|
||||
const std::string profileFormatVersion = "1.0";
|
||||
|
||||
class Profile {
|
||||
public:
|
||||
static constexpr const char* FormatVersion = "1.0";
|
||||
|
||||
enum class AssetEventType {
|
||||
add,
|
||||
require,
|
||||
request,
|
||||
remove,
|
||||
ignore
|
||||
};
|
||||
const std::map<AssetEventType, std::string> AssetEventTypeString {
|
||||
{AssetEventType::add, "add"},
|
||||
{AssetEventType::require, "required"},
|
||||
{AssetEventType::request, "requested"},
|
||||
{AssetEventType::remove, "removed"},
|
||||
{AssetEventType::ignore, "ignored"},
|
||||
Add,
|
||||
Require,
|
||||
Request,
|
||||
Remove,
|
||||
Ignore
|
||||
};
|
||||
|
||||
struct AssetEvent {
|
||||
std::string name;
|
||||
AssetEventType eventType;
|
||||
@@ -70,16 +63,12 @@ public:
|
||||
|
||||
virtual ~Profile() {};
|
||||
|
||||
const std::string formatVersion() {
|
||||
return profileFormatVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves all current settings, starting from the profile that was loaded at startup,
|
||||
* and all of the property & asset changes that were made since startup.
|
||||
* \param filename The filename of the new profile to be saved
|
||||
*/
|
||||
void saveCurrentSettingsToProfile(std::string filename);
|
||||
void saveCurrentSettingsToProfile(const std::string& filename);
|
||||
|
||||
/**
|
||||
* Saves all current settings, similar to saveCurrentSettingsToProfile() except the
|
||||
@@ -94,8 +83,8 @@ public:
|
||||
* \param outFilePath The output file path that will be written with the converted
|
||||
* contents (in an .asset file)
|
||||
*/
|
||||
void convertToSceneFile(const std::string inProfilePath,
|
||||
const std::string outFilePath);
|
||||
void convertToSceneFile(const std::string& inProfilePath,
|
||||
const std::string& outFilePath);
|
||||
|
||||
/**
|
||||
* Returns the string contents of a profileFile object converted to scene/asset
|
||||
@@ -120,10 +109,10 @@ private:
|
||||
std::vector<AssetEvent> base;
|
||||
std::vector<AssetEvent> changed;
|
||||
};
|
||||
virtual bool usingProfile();
|
||||
virtual std::string initialProfile();
|
||||
virtual std::string profileBaseDirectory();
|
||||
virtual std::vector<AssetEvent> listOfAllAssetEvents();
|
||||
virtual bool usingProfile() const;
|
||||
virtual std::string initialProfile() const;
|
||||
virtual std::string profileBaseDirectory() const;
|
||||
virtual std::vector<AssetEvent> assetEvents() const;
|
||||
ProfileFile collateBaseWithChanges();
|
||||
std::string convertToScene_assets(ProfileFile& pf);
|
||||
std::string convertToScene_modules(ProfileFile& pf);
|
||||
@@ -133,23 +122,16 @@ private:
|
||||
std::string convertToScene_time(ProfileFile& pf);
|
||||
std::string convertToScene_camera(ProfileFile& pf);
|
||||
|
||||
void updateToCurrentFormatVersion(ProfileFile& pf);
|
||||
std::vector<AssetEvent> modifyAssetsToReflectChanges(ProfileFile& pf);
|
||||
void parseAssetFileLines(std::vector<AssetEvent>& results, ProfileFile& pf);
|
||||
void handleChangedAdd(std::vector<AssetEvent>& base, unsigned int changedIdx,
|
||||
std::vector<AssetEvent>& changed, std::string asset);
|
||||
void handleChangedRemove(std::vector<AssetEvent>& base, std::string asset);
|
||||
void addAssetsToProfileFile(std::vector<AssetEvent>& allAssets, ProfileFile& pf);
|
||||
|
||||
void modifyPropertiesToReflectChanges(ProfileFile& pf);
|
||||
virtual std::vector<openspace::properties::Property*> getChangedProperties();
|
||||
void checkForChangedProps(std::vector<openspace::properties::Property*>& changedList,
|
||||
openspace::properties::PropertyOwner* po);
|
||||
virtual std::vector<openspace::properties::Property*> changedProperties();
|
||||
std::string getFullPropertyPath(openspace::properties::Property* prop);
|
||||
virtual std::vector<std::string> getChangedPropertiesFormatted();
|
||||
virtual std::string getCurrentTimeUTC();
|
||||
virtual interaction::NavigationHandler::NavigationState getCurrentCameraState();
|
||||
void addCurrentTimeToProfileFile(ProfileFile& pf);
|
||||
void addCurrentCameraToProfileFile(ProfileFile& pf);
|
||||
virtual std::vector<std::string> changedPropertiesFormatted();
|
||||
virtual std::string currentTimeUTC() const;
|
||||
virtual interaction::NavigationHandler::NavigationState currentCameraState() const;
|
||||
void addCurrentCameraToProfileFile(ProfileFile& pf) const;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -150,21 +150,21 @@ public:
|
||||
* form.
|
||||
* \param filename The filename to write to.
|
||||
*/
|
||||
void writeToFile(const std::string filename);
|
||||
void writeToFile(const std::string& filename);
|
||||
|
||||
/**
|
||||
* Updates the full string that defines the starting time. The format for this line
|
||||
* is defined by ProfileFile::parseTime and Profile::convertToAsset_time
|
||||
* \param line The time entry line to replace current time entry
|
||||
*/
|
||||
void updateTime(const std::string line);
|
||||
void updateTime(std::string line);
|
||||
|
||||
/**
|
||||
* Updates the full string that defines the starting camera position. The format for
|
||||
* this line is defined by ProfileFile::parseCamera & Profile::convertToAsset_camera
|
||||
* \param line The camera entry line to replace current camera entry
|
||||
*/
|
||||
void updateCamera(const std::string line);
|
||||
void updateCamera(std::string line);
|
||||
|
||||
/**
|
||||
* Adds a new module line to the list of module lines to be analyzed by the profile
|
||||
@@ -172,14 +172,14 @@ public:
|
||||
* and Profile::convertToAsset_modules
|
||||
* \param line The module name to be added
|
||||
*/
|
||||
void addModuleLine(const std::string line);
|
||||
void addModuleLine(std::string line);
|
||||
|
||||
/**
|
||||
* Adds a new asset to the list of assets to be loaded at startup. The format for an
|
||||
* asset line is defined by ProfileFile::parseAsset & Profile::convertToAsset_assets
|
||||
* \param line The asset name to be added
|
||||
*/
|
||||
void addAssetLine(const std::string line);
|
||||
void addAssetLine(std::string line);
|
||||
|
||||
/**
|
||||
* Clears all asset entries
|
||||
@@ -192,7 +192,7 @@ public:
|
||||
* ProfileFile::parseProperty and Profile::convertToAsset_properties
|
||||
* \param line The property set command to be added
|
||||
*/
|
||||
void addPropertyLine(const std::string line);
|
||||
void addPropertyLine(std::string line);
|
||||
|
||||
/**
|
||||
* Adds a new keybinding shortcut to the list of keybindings. The format for a
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
* Profile::convertToAsset_keybindings
|
||||
* \param line The keyboard shortcut line to be added
|
||||
*/
|
||||
void addKeybindingLine(const std::string line);
|
||||
void addKeybindingLine(std::string line);
|
||||
|
||||
/**
|
||||
* Adds a new scenegraph node name to be added to the list of those marked as
|
||||
@@ -208,7 +208,7 @@ public:
|
||||
* ProfileFile::parseMarkNodes and Profile::convertToAsset_markNodes
|
||||
* \param line The scenegraph node to be added
|
||||
*/
|
||||
void addMarkNodesLine(const std::string line);
|
||||
void addMarkNodesLine(std::string line);
|
||||
|
||||
/**
|
||||
* Returns the format version number (profiles syntax version) string
|
||||
|
||||
@@ -190,16 +190,13 @@ GUI::GUI()
|
||||
|
||||
GUI::~GUI() {} // NOLINT
|
||||
|
||||
void GUI::initialize() {
|
||||
|
||||
}
|
||||
void GUI::initialize() {}
|
||||
|
||||
void GUI::deinitialize() {
|
||||
ImGui::Shutdown();
|
||||
|
||||
int nWindows = global::windowDelegate.nWindows();
|
||||
for (int i = 0; i < nWindows; ++i) {
|
||||
ImGui::DestroyContext(_contexts[i]);
|
||||
for (ImGuiContext* ctx : _contexts) {
|
||||
ImGui::DestroyContext(ctx);
|
||||
}
|
||||
|
||||
for (GuiComponent* comp : _components) {
|
||||
|
||||
@@ -45,7 +45,7 @@ SGCTConfig = sgct.config.single{}
|
||||
|
||||
-- Sets the scene that is to be loaded by OpenSpace. A scene file is a description
|
||||
-- of all entities that will be visible during an instance of OpenSpace
|
||||
Asset = "default"
|
||||
-- Asset = "default"
|
||||
-- Asset = "asteroids"
|
||||
-- Asset = "default_full"
|
||||
-- Asset = "newhorizons"
|
||||
@@ -64,7 +64,7 @@ Asset = "default"
|
||||
-- Sets the profile that should be loaded by OpenSpace. Profiles are going to replace
|
||||
-- assets in a future versions and shouldn't be used at the same time as the 'Asset'
|
||||
-- setting above
|
||||
-- Profile = "default"
|
||||
Profile = "default"
|
||||
|
||||
-- These scripts are executed after the initialization of each scene, thus making
|
||||
-- it possible to have global overrides to default values or execute other scripts
|
||||
|
||||
@@ -1286,11 +1286,11 @@ void OpenSpaceEngine::postDraw() {
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::resetAssetChangeTracking() {
|
||||
global::openSpaceEngine._assetManager->listOfAllAssetEvents_reset();
|
||||
global::openSpaceEngine._assetManager->resetAssetEvents();
|
||||
}
|
||||
|
||||
std::vector<Profile::AssetEvent> OpenSpaceEngine::listOfAllAssetEvents() {
|
||||
return global::openSpaceEngine._assetManager->listOfAllAssetEvents();
|
||||
std::vector<Profile::AssetEvent> OpenSpaceEngine::assetEvents() {
|
||||
return global::openSpaceEngine._assetManager->assetEvents();
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::resetPropertyChangeFlags() {
|
||||
|
||||
@@ -312,12 +312,12 @@ void Property::notifyDeleteListeners() {
|
||||
}
|
||||
}
|
||||
|
||||
bool Property::hasChanged() {
|
||||
return valChanged;
|
||||
bool Property::hasChanged() const {
|
||||
return _isValueDirty;
|
||||
}
|
||||
|
||||
void Property::resetToUnchanged() {
|
||||
valChanged = false;
|
||||
_isValueDirty = false;
|
||||
}
|
||||
|
||||
std::string Property::generateBaseJsonDescription() const {
|
||||
|
||||
@@ -456,7 +456,7 @@ std::shared_ptr<Asset> AssetLoader::request(const std::string& identifier) {
|
||||
}
|
||||
|
||||
void AssetLoader::addToProfileTracking(std::string asset, Profile::AssetEventType type) {
|
||||
Profile::AssetEvent pa = {asset, type};
|
||||
Profile::AssetEvent pa = { std::move(asset), type };
|
||||
_profileAssets.push_back(pa);
|
||||
}
|
||||
|
||||
@@ -478,7 +478,7 @@ ghoul::filesystem::Directory AssetLoader::currentDirectory() const {
|
||||
|
||||
std::shared_ptr<Asset> AssetLoader::add(const std::string& identifier) {
|
||||
setCurrentAsset(_rootAsset);
|
||||
addToProfileTracking(identifier, Profile::AssetEventType::add);
|
||||
addToProfileTracking(identifier, Profile::AssetEventType::Add);
|
||||
return request(identifier);
|
||||
}
|
||||
|
||||
@@ -486,8 +486,7 @@ std::shared_ptr<Asset> AssetLoader::add(const std::string& identifier) {
|
||||
void AssetLoader::remove(const std::string& identifier) {
|
||||
setCurrentAsset(_rootAsset);
|
||||
unrequest(identifier);
|
||||
_profileAssetsRemoved.push_back(identifier);
|
||||
addToProfileTracking(identifier, Profile::AssetEventType::remove);
|
||||
addToProfileTracking(identifier, Profile::AssetEventType::Remove);
|
||||
}
|
||||
|
||||
std::shared_ptr<Asset> AssetLoader::has(const std::string& identifier) const {
|
||||
@@ -814,11 +813,11 @@ void AssetLoader::assetUnrequested(std::shared_ptr<Asset> parent,
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Profile::AssetEvent>& AssetLoader::listOfAllAssetEvents() {
|
||||
const std::vector<Profile::AssetEvent>& AssetLoader::assetEvents() const {
|
||||
return _profileAssets;
|
||||
}
|
||||
|
||||
void AssetLoader::listOfAllAssetEvents_reset() {
|
||||
void AssetLoader::resetAssetEvents() {
|
||||
_profileAssets.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -121,12 +121,12 @@ std::shared_ptr<Asset> AssetManager::rootAsset() {
|
||||
return _assetLoader->rootAsset();
|
||||
}
|
||||
|
||||
const std::vector<Profile::AssetEvent>& AssetManager::listOfAllAssetEvents() const {
|
||||
return _assetLoader->listOfAllAssetEvents();
|
||||
const std::vector<Profile::AssetEvent>& AssetManager::assetEvents() const {
|
||||
return _assetLoader->assetEvents();
|
||||
}
|
||||
|
||||
void AssetManager::listOfAllAssetEvents_reset() {
|
||||
_assetLoader->listOfAllAssetEvents_reset();
|
||||
void AssetManager::resetAssetEvents() {
|
||||
_assetLoader->resetAssetEvents();
|
||||
}
|
||||
|
||||
scripting::LuaLibrary AssetManager::luaLibrary() {
|
||||
|
||||
@@ -51,15 +51,104 @@
|
||||
|
||||
#include "profile_lua.inl"
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "Profile";
|
||||
constexpr const char* KeyIdentifier = "Identifier";
|
||||
constexpr const char* KeyParent = "Parent";
|
||||
|
||||
const std::map<Profile::AssetEventType, std::string> AssetEventTypeString{
|
||||
{ Profile::AssetEventType::Add, "add" },
|
||||
{ Profile::AssetEventType::Require, "required" },
|
||||
{ Profile::AssetEventType::Request, "requested" },
|
||||
{ Profile::AssetEventType::Remove, "removed" },
|
||||
{ Profile::AssetEventType::Ignore, "ignored" },
|
||||
};
|
||||
|
||||
void handleChangedAdd(std::vector<Profile::AssetEvent>& base, unsigned int changedIdx,
|
||||
std::vector<Profile::AssetEvent>& changed, std::string asset)
|
||||
{
|
||||
// @TODO: Replace the next for loop with std::any_of or std::all_of
|
||||
|
||||
bool addThisAsset = true;
|
||||
// Check base profile to see if has already been added there
|
||||
for (const Profile::AssetEvent& b : base) {
|
||||
if (b.name == asset) {
|
||||
if (b.eventType == Profile::AssetEventType::Require
|
||||
|| b.eventType == Profile::AssetEventType::Request)
|
||||
{
|
||||
addThisAsset = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check changed asset commands only prior to this one to see if already added
|
||||
for (unsigned int i = 0; i < changedIdx; i++) {
|
||||
if (changed[i].name == asset) {
|
||||
addThisAsset = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (addThisAsset) {
|
||||
Profile::AssetEvent ae = {
|
||||
std::move(asset),
|
||||
Profile::AssetEventType::Request
|
||||
};
|
||||
base.push_back(ae);
|
||||
}
|
||||
}
|
||||
|
||||
void handleChangedRemove(std::vector<Profile::AssetEvent>& base, std::string asset) {
|
||||
base.push_back({ std::move(asset), Profile::AssetEventType::Remove });
|
||||
}
|
||||
|
||||
void addAssetsToProfileFile(ProfileFile& pf,
|
||||
const std::vector<Profile::AssetEvent>& allAssets)
|
||||
{
|
||||
pf.clearAssets();
|
||||
for (Profile::AssetEvent a : allAssets) {
|
||||
if (a.eventType != Profile::AssetEventType::Ignore) {
|
||||
std::string entry =
|
||||
a.name + "\t" + AssetEventTypeString.at(a.eventType);
|
||||
pf.addAssetLine(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string recurseForFullName(properties::PropertyOwner* po) {
|
||||
if (po == nullptr) {
|
||||
return "";
|
||||
}
|
||||
std::string name = recurseForFullName(po->owner()) + po->identifier();
|
||||
if (!name.empty()) {
|
||||
return name + ".";
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void checkForChangedProps(std::vector<properties::Property*>& changedList,
|
||||
properties::PropertyOwner* po)
|
||||
{
|
||||
if (po) {
|
||||
for (properties::PropertyOwner* subOwner : po->propertySubOwners()) {
|
||||
checkForChangedProps(changedList, subOwner);
|
||||
}
|
||||
for (properties::Property* p : po->properties()) {
|
||||
if (p->hasChanged()) {
|
||||
changedList.push_back(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
void Profile::saveCurrentSettingsToProfile(std::string filename) {
|
||||
void Profile::saveCurrentSettingsToProfile(const std::string& filename) {
|
||||
ProfileFile pf = collateBaseWithChanges();
|
||||
pf.writeToFile(filename);
|
||||
}
|
||||
@@ -69,112 +158,67 @@ std::string Profile::saveCurrentSettingsToProfile_string() {
|
||||
return pf.writeToString();
|
||||
}
|
||||
|
||||
bool Profile::usingProfile() {
|
||||
bool Profile::usingProfile() const {
|
||||
return global::configuration.usingProfile;
|
||||
}
|
||||
|
||||
std::string Profile::initialProfile() {
|
||||
std::string Profile::initialProfile() const {
|
||||
return global::configuration.profile;
|
||||
}
|
||||
|
||||
std::vector<Profile::AssetEvent> Profile::listOfAllAssetEvents() {
|
||||
return global::openSpaceEngine.listOfAllAssetEvents();
|
||||
std::vector<Profile::AssetEvent> Profile::assetEvents() const {
|
||||
return global::openSpaceEngine.assetEvents();
|
||||
}
|
||||
|
||||
std::string Profile::profileBaseDirectory() {
|
||||
std::string Profile::profileBaseDirectory() const {
|
||||
return _profileBaseDirectory;
|
||||
}
|
||||
|
||||
ProfileFile Profile::collateBaseWithChanges() {
|
||||
if (! usingProfile()) {
|
||||
if (!usingProfile()) {
|
||||
std::string errorMessage = "Program was not started using a profile, "
|
||||
"so cannot use this save-current-settings feature.";
|
||||
"so cannot use this save-current-settings feature";
|
||||
LERROR(errorMessage);
|
||||
}
|
||||
std::string initProfile = initialProfile();
|
||||
std::string inputProfilePath = absPath(_profileBaseDirectory) + "/" + initProfile
|
||||
+ ".profile";
|
||||
ProfileFile pf(inputProfilePath);
|
||||
updateToCurrentFormatVersion(pf);
|
||||
pf.setVersion(FormatVersion);
|
||||
std::vector<AssetEvent> ass = modifyAssetsToReflectChanges(pf);
|
||||
addAssetsToProfileFile(ass, pf);
|
||||
addAssetsToProfileFile(pf, ass);
|
||||
modifyPropertiesToReflectChanges(pf);
|
||||
addCurrentTimeToProfileFile(pf);
|
||||
|
||||
// add current time to profile file
|
||||
std::string t = currentTimeUTC();
|
||||
std::string update = "absolute\t" + t;
|
||||
pf.updateTime(update);
|
||||
|
||||
addCurrentCameraToProfileFile(pf);
|
||||
return pf;
|
||||
}
|
||||
|
||||
void Profile::updateToCurrentFormatVersion(ProfileFile& pf) {
|
||||
pf.setVersion(profileFormatVersion);
|
||||
}
|
||||
|
||||
std::vector<Profile::AssetEvent> Profile::modifyAssetsToReflectChanges(ProfileFile& pf) {
|
||||
std::vector<AssetEvent> a;
|
||||
parseAssetFileLines(a, pf);
|
||||
AllAssetDetails assetDetails;
|
||||
|
||||
assetDetails.base = a;
|
||||
assetDetails.changed = listOfAllAssetEvents();
|
||||
assetDetails.changed = assetEvents();
|
||||
|
||||
for (unsigned int i = 0; i < assetDetails.changed.size(); i++) {
|
||||
AssetEvent event = assetDetails.changed[i];
|
||||
|
||||
if (event.eventType == AssetEventType::add) {
|
||||
if (event.eventType == AssetEventType::Add) {
|
||||
handleChangedAdd(assetDetails.base, i, assetDetails.changed, event.name);
|
||||
}
|
||||
else if (event.eventType == AssetEventType::remove) {
|
||||
else if (event.eventType == AssetEventType::Remove) {
|
||||
handleChangedRemove(assetDetails.base, event.name);
|
||||
}
|
||||
}
|
||||
return assetDetails.base;
|
||||
}
|
||||
|
||||
void Profile::handleChangedAdd(std::vector<AssetEvent>& base, unsigned int changedIdx,
|
||||
std::vector<AssetEvent>& changed, std::string asset)
|
||||
{
|
||||
bool addThisAsset = true;
|
||||
//Check base profile to see if has already been added there
|
||||
for (auto b : base) {
|
||||
if (b.name == asset ) {
|
||||
if ( b.eventType == AssetEventType::require
|
||||
|| b.eventType == AssetEventType::request)
|
||||
{
|
||||
addThisAsset = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check changed asset commands only prior to this one to see if already added
|
||||
for (unsigned int i = 0; i < changedIdx; i++) {
|
||||
if (changed[i].name == asset) {
|
||||
addThisAsset = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (addThisAsset) {
|
||||
AssetEvent ae = {asset, AssetEventType::request};
|
||||
base.push_back(ae);
|
||||
}
|
||||
}
|
||||
|
||||
void Profile::handleChangedRemove(std::vector<AssetEvent>& base, std::string asset)
|
||||
{
|
||||
base.push_back({asset, AssetEventType::remove});
|
||||
}
|
||||
|
||||
void Profile::addAssetsToProfileFile(std::vector<AssetEvent>& allAssets, ProfileFile& pf)
|
||||
{
|
||||
pf.clearAssets();
|
||||
for (AssetEvent a : allAssets) {
|
||||
if (a.eventType != AssetEventType::ignore) {
|
||||
std::string entry = a.name + "\t" + AssetEventTypeString.at(a.eventType);
|
||||
pf.addAssetLine(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Profile::parseAssetFileLines(std::vector<AssetEvent>& results, ProfileFile& pf) {
|
||||
std::vector<std::string> elements;
|
||||
AssetEvent a;
|
||||
@@ -183,25 +227,29 @@ void Profile::parseAssetFileLines(std::vector<AssetEvent>& results, ProfileFile&
|
||||
pf.splitByTab(line, elements);
|
||||
|
||||
if (elements[0].empty()) {
|
||||
LERROR("Error in parsing asset file line '" + line
|
||||
+ "'. Asset name is needed (field 1/2).");
|
||||
LERROR(fmt::format(
|
||||
"Error parsing profile line '{}'. Asset name is needed (field 1/2)",
|
||||
line
|
||||
));
|
||||
}
|
||||
else {
|
||||
a.name = elements[0];
|
||||
}
|
||||
|
||||
if (elements[1] == AssetEventTypeString.at(AssetEventType::require)) {
|
||||
a.eventType = AssetEventType::require;
|
||||
if (elements[1] == AssetEventTypeString.at(AssetEventType::Require)) {
|
||||
a.eventType = AssetEventType::Require;
|
||||
}
|
||||
else if (elements[1] == AssetEventTypeString.at(AssetEventType::request)) {
|
||||
a.eventType = AssetEventType::request;
|
||||
else if (elements[1] == AssetEventTypeString.at(AssetEventType::Request)) {
|
||||
a.eventType = AssetEventType::Request;
|
||||
}
|
||||
else if (elements[1] == "") {
|
||||
a.eventType = AssetEventType::request;
|
||||
a.eventType = AssetEventType::Request;
|
||||
}
|
||||
else {
|
||||
LERROR("Error in parsing asset file line '" + line
|
||||
+ "'. Invalid required param (field 2/2).");
|
||||
LERROR(fmt::format(
|
||||
"Error parsing profile line '{}'. Invalid required param (field 2/2)",
|
||||
line
|
||||
));
|
||||
}
|
||||
|
||||
results.push_back(a);
|
||||
@@ -209,19 +257,18 @@ void Profile::parseAssetFileLines(std::vector<AssetEvent>& results, ProfileFile&
|
||||
}
|
||||
|
||||
void Profile::modifyPropertiesToReflectChanges(ProfileFile& pf) {
|
||||
std::vector<std::string> formatted = getChangedPropertiesFormatted();
|
||||
std::vector<std::string> formatted = changedPropertiesFormatted();
|
||||
|
||||
for (std::string line: formatted) {
|
||||
pf.addPropertyLine(line);
|
||||
for (std::string line : formatted) {
|
||||
pf.addPropertyLine(std::move(line));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> Profile::getChangedPropertiesFormatted() {
|
||||
std::vector<openspace::properties::Property*> changedProps
|
||||
= getChangedProperties();
|
||||
std::vector<std::string> Profile::changedPropertiesFormatted() {
|
||||
std::vector<properties::Property*> changedProps = changedProperties();
|
||||
std::vector<std::string> formattedLines;
|
||||
|
||||
for (auto prop : changedProps) {
|
||||
for (properties::Property* prop : changedProps) {
|
||||
std::string newLine = "setPropertyValueSingle\t";
|
||||
newLine += getFullPropertyPath(prop) + "\t";
|
||||
newLine += prop->getStringValue();
|
||||
@@ -230,69 +277,35 @@ std::vector<std::string> Profile::getChangedPropertiesFormatted() {
|
||||
return formattedLines;
|
||||
}
|
||||
|
||||
std::string recurseForFullName(openspace::properties::PropertyOwner* po) {
|
||||
std::string path;
|
||||
if (po != nullptr) {
|
||||
std::string name = recurseForFullName(po->owner()) + po->identifier();
|
||||
if (!name.empty()) {
|
||||
path = name + ".";
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
std::string Profile::getFullPropertyPath(openspace::properties::Property* prop) {
|
||||
std::string Profile::getFullPropertyPath(properties::Property* prop) {
|
||||
return recurseForFullName(prop->owner()) + prop->identifier();
|
||||
}
|
||||
|
||||
void Profile::checkForChangedProps(
|
||||
std::vector<openspace::properties::Property*>& changedList,
|
||||
openspace::properties::PropertyOwner* po)
|
||||
{
|
||||
if (po != nullptr) {
|
||||
for (auto subOwner : po->propertySubOwners()) {
|
||||
checkForChangedProps(changedList, subOwner);
|
||||
}
|
||||
for (auto p : po->properties()) {
|
||||
if (p->hasChanged()) {
|
||||
changedList.push_back(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<openspace::properties::Property*> Profile::getChangedProperties()
|
||||
{
|
||||
std::vector<properties::Property*> Profile::changedProperties() {
|
||||
ZoneScoped
|
||||
|
||||
std::vector<SceneGraphNode*> nodes
|
||||
std::vector<SceneGraphNode*> nodes
|
||||
= global::renderEngine.scene()->allSceneGraphNodes();
|
||||
std::vector<openspace::properties::Property*> changedProps;
|
||||
std::vector<properties::Property*> changedProps;
|
||||
|
||||
for (auto n : nodes) {
|
||||
for (SceneGraphNode* n : nodes) {
|
||||
checkForChangedProps(changedProps, n);
|
||||
}
|
||||
return changedProps;
|
||||
}
|
||||
|
||||
std::string Profile::getCurrentTimeUTC() {
|
||||
std::string Profile::currentTimeUTC() const {
|
||||
return global::timeManager.time().ISO8601();
|
||||
}
|
||||
|
||||
void Profile::addCurrentTimeToProfileFile(ProfileFile& pf) {
|
||||
std::string t = getCurrentTimeUTC();
|
||||
std::string update = "absolute\t" + t;
|
||||
pf.updateTime(update);
|
||||
}
|
||||
|
||||
interaction::NavigationHandler::NavigationState Profile::getCurrentCameraState() {
|
||||
interaction::NavigationHandler::NavigationState Profile::currentCameraState() const {
|
||||
return global::navigationHandler.navigationState();
|
||||
}
|
||||
|
||||
void Profile::addCurrentCameraToProfileFile(ProfileFile& pf) {
|
||||
void Profile::addCurrentCameraToProfileFile(ProfileFile& pf) const {
|
||||
std::string update = "setNavigationState\t";
|
||||
interaction::NavigationHandler::NavigationState nav;
|
||||
nav = getCurrentCameraState();
|
||||
nav = currentCameraState();
|
||||
update += "\"" + nav.anchor + "\"\t";
|
||||
update += "\"" + nav.aim + "\"\t";
|
||||
update += "\"" + nav.referenceFrame + "\"\t";
|
||||
@@ -313,8 +326,8 @@ void Profile::addCurrentCameraToProfileFile(ProfileFile& pf) {
|
||||
pf.updateCamera(update);
|
||||
}
|
||||
|
||||
void Profile::convertToSceneFile(const std::string inProfilePath,
|
||||
const std::string outFilePath)
|
||||
void Profile::convertToSceneFile(const std::string& inProfilePath,
|
||||
const std::string& outFilePath)
|
||||
{
|
||||
ZoneScoped
|
||||
|
||||
@@ -324,7 +337,7 @@ void Profile::convertToSceneFile(const std::string inProfilePath,
|
||||
try {
|
||||
outFile.open(outFilePath, std::ofstream::out);
|
||||
}
|
||||
catch (std::ofstream::failure& e) {
|
||||
catch (const std::ofstream::failure& e) {
|
||||
LERROR("Exception opening scene file for write: " + outFilePath
|
||||
+ " (" + e.what() + ")");
|
||||
}
|
||||
@@ -332,7 +345,7 @@ void Profile::convertToSceneFile(const std::string inProfilePath,
|
||||
try {
|
||||
outFile << convertToScene(pf);
|
||||
}
|
||||
catch (std::ofstream::failure& e) {
|
||||
catch (const std::ofstream::failure& e) {
|
||||
LERROR("Data write error to scene file: " + outFilePath
|
||||
+ " (" + e.what() + ")");
|
||||
}
|
||||
@@ -340,7 +353,7 @@ void Profile::convertToSceneFile(const std::string inProfilePath,
|
||||
try {
|
||||
outFile.close();
|
||||
}
|
||||
catch (std::ofstream::failure& e) {
|
||||
catch (const std::ofstream::failure& e) {
|
||||
LERROR("Exception closing scene file after write: " + outFilePath
|
||||
+ " (" + e.what() + ")");
|
||||
}
|
||||
@@ -371,18 +384,23 @@ std::string Profile::convertToScene_modules(ProfileFile& pf) {
|
||||
|
||||
for (std::string m : pf.modules()) {
|
||||
pf.splitByTab(m, fields);
|
||||
if (fields[moduleFieldLoaded] != "" && fields[moduleFieldNotLoaded] != "") {
|
||||
result += "if openspace.modules.isLoaded(\"" + fields[moduleFieldName];
|
||||
result += "\") then\n " + fields[moduleFieldLoaded] + "\nelse\n";
|
||||
result += " " + fields[moduleFieldNotLoaded] + "\nend\n";
|
||||
if (!fields[moduleFieldLoaded].empty() && !fields[moduleFieldNotLoaded].empty()) {
|
||||
result += fmt::format(
|
||||
"if openspace.modules.isLoaded(\"{}\") then {} else {} end\n",
|
||||
fields[moduleFieldName], fields[moduleFieldLoaded], fields[moduleFieldNotLoaded]
|
||||
);
|
||||
}
|
||||
else if (fields[moduleFieldNotLoaded] == "") {
|
||||
result += "if not openspace.modules.isLoaded(\"" + fields[moduleFieldName];
|
||||
result += "\") then\n " + fields[moduleFieldNotLoaded] + "\nend\n";
|
||||
else if (fields[moduleFieldNotLoaded].empty()) {
|
||||
result += fmt::format(
|
||||
"if not openspace.modules.isLoaded(\"{}\") then {} end\n",
|
||||
fields[moduleFieldName], fields[moduleFieldNotLoaded]
|
||||
);
|
||||
}
|
||||
else if (fields[moduleFieldLoaded] == "") {
|
||||
result += "if openspace.modules.isLoaded(\"" + fields[moduleFieldName];
|
||||
result += "\") then\n " + fields[moduleFieldLoaded] + "\nend\n";
|
||||
else if (fields[moduleFieldLoaded].empty()) {
|
||||
result += fmt::format(
|
||||
"if openspace.modules.isLoaded(\"{}\") then {} end\n",
|
||||
fields[moduleFieldName], fields[moduleFieldLoaded]
|
||||
);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -413,12 +431,13 @@ std::string Profile::convertToScene_assets(ProfileFile& pf) {
|
||||
assetR = "require";
|
||||
}
|
||||
else {
|
||||
std::string err = "Asset " + std::to_string(i + 1) + " of ";
|
||||
err += std::to_string(pf.assets().size()) + " has bad arg 2/2 which must ";
|
||||
err += "be either 'required' or 'requested'";
|
||||
std::string err = fmt::format(
|
||||
"Asset {} of {} has bad arg 2/2 which must be 'required' or 'requested'",
|
||||
i + 1, pf.assets().size()
|
||||
);
|
||||
throw ghoul::RuntimeError(err);
|
||||
}
|
||||
result += "asset." + assetR + "(\"" + fields[assetFieldName] + "\")\n";
|
||||
result += fmt::format("asset.{}(\"{}\")\n", assetR, fields[assetFieldName]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -434,14 +453,18 @@ std::string Profile::convertToScene_properties(ProfileFile& pf) {
|
||||
if (fields[propertyFieldType] != "setPropertyValue"
|
||||
&& fields[propertyFieldType] != "setPropertyValueSingle")
|
||||
{
|
||||
std::string err = "Property" + std::to_string(i + 1) + " of ";
|
||||
err += std::to_string(pf.properties().size()) + " has bad arg 1/1 which ";
|
||||
err += "must be either 'setPropertyValue' or 'setPropertyValueSingle'";
|
||||
std::string err = fmt::format(
|
||||
"Property {} of {} has bad arg 1/1 which must be "
|
||||
"'setPropertyValue' or 'setPropertyValueSingle'",
|
||||
i + 1, pf.properties().size()
|
||||
);
|
||||
throw ghoul::RuntimeError(err);
|
||||
}
|
||||
else {
|
||||
result += " openspace." + fields[propertyFieldType] + "(\""
|
||||
+ fields[propertyFieldName] + "\", " + fields[propertyFieldValue] + ")\n";
|
||||
result += fmt::format(
|
||||
" openspace.{}(\"{}\", {})\n",
|
||||
fields[propertyFieldType], fields[propertyFieldName], fields[propertyFieldValue]
|
||||
);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -458,12 +481,12 @@ std::string Profile::convertToScene_keybindings(ProfileFile& pf) {
|
||||
pf.splitByTab(k, fields);
|
||||
|
||||
result += " {\n";
|
||||
result += " Key = \"" + fields[0] + "\",\n";
|
||||
result += " Documentation = \"" + fields[1] + "\",\n";
|
||||
result += " Name = \"" + fields[2] + "\",\n";
|
||||
result += " GuiPath = \"" + fields[3] + "\",\n";
|
||||
result += " Local = " + fields[4] + ",\n";
|
||||
result += " Command = " + fields[5] + "\n";
|
||||
result += fmt::format(" {} = \"{}\",\n", "Key", fields[0]);
|
||||
result += fmt::format(" {} = \"{}\",\n", "Documentation", fields[1]);
|
||||
result += fmt::format(" {} = \"{}\",\n", "Name", fields[2]);
|
||||
result += fmt::format(" {} = \"{}\",\n", "GuiPath", fields[3]);
|
||||
result += fmt::format(" {} = \"{}\",\n", "Local", fields[4]);
|
||||
result += fmt::format(" {} = \"{}\"\n", "Command", fields[5]);
|
||||
result += " },\n";
|
||||
}
|
||||
result += "}\n";
|
||||
@@ -473,10 +496,10 @@ std::string Profile::convertToScene_keybindings(ProfileFile& pf) {
|
||||
std::string Profile::convertToScene_markNodes(ProfileFile& pf) {
|
||||
std::string result;
|
||||
|
||||
if (pf.markNodes().size() > 0) {
|
||||
if (!pf.markNodes().empty()) {
|
||||
result += " openspace.markInterestingNodes({";
|
||||
for (std::string m : pf.markNodes()) {
|
||||
result += "\"" + m + "\", ";
|
||||
for (const std::string& m : pf.markNodes()) {
|
||||
result += fmt::format("\"{}\",", m);
|
||||
}
|
||||
result += "})\n";
|
||||
}
|
||||
@@ -491,9 +514,14 @@ std::string Profile::convertToScene_time(ProfileFile& pf) {
|
||||
pf.splitByTab(pf.time(), fields);
|
||||
|
||||
if (fields[timeFieldType] == "absolute") {
|
||||
result += " openspace.time.setTime(\"" + fields[timeFieldSet] + "\")\n";
|
||||
result += fmt::format(" openspace.time.setTime(\"{}\")\n", fields[timeFieldSet]);
|
||||
}
|
||||
else if (fields[timeFieldType] == "relative") {
|
||||
result += fmt::format(
|
||||
" openspace.time.setTime(openspace.time.advancedTime("
|
||||
"openspace.time.currentWallTime(), \"{}\"))\n",
|
||||
fields[timeFieldSet]
|
||||
);
|
||||
result += " local now = openspace.time.currentWallTime(); ";
|
||||
result += "openspace.time.setTime(";
|
||||
result += "openspace.time.advancedTime(now, \"" + fields[timeFieldSet] + "\"))\n";
|
||||
@@ -514,41 +542,41 @@ std::string Profile::convertToScene_camera(ProfileFile& pf) {
|
||||
|
||||
if (fields[cameraFieldType] == "setNavigationState") {
|
||||
result += " openspace.navigation.setNavigationState({";
|
||||
result += "Anchor = " + fields[cameraNavigationFieldAnchor] + ", ";
|
||||
if (fields[cameraNavigationFieldAim] != "") {
|
||||
result += "Aim = " + fields[cameraNavigationFieldAim] + ", ";
|
||||
result += fmt::format("Anchor = {}, ", fields[cameraNavigationFieldAnchor]);
|
||||
if (!fields[cameraNavigationFieldAim].empty()) {
|
||||
result += fmt::format("Aim = {}, ", fields[cameraNavigationFieldAim]);
|
||||
}
|
||||
if (fields[cameraNavigationFieldRef] != "") {
|
||||
result += "ReferenceFrame = " + fields[cameraNavigationFieldRef] + ", ";
|
||||
if (!fields[cameraNavigationFieldRef].empty()) {
|
||||
result += fmt::format("ReferenceFrame = {}, ", fields[cameraNavigationFieldRef]);
|
||||
}
|
||||
result += "Position = {" + fields[cameraNavigationFieldPosition] + "}, ";
|
||||
if (fields[cameraNavigationFieldUp] != "") {
|
||||
result += "Up = {" + fields[cameraNavigationFieldUp] + "}, ";
|
||||
result += fmt::format("Position = {{ {} }}, ", fields[cameraNavigationFieldPosition]);
|
||||
if (!fields[cameraNavigationFieldUp].empty()) {
|
||||
result += fmt::format("Up = {{ {} }}, ", fields[cameraNavigationFieldUp]);
|
||||
}
|
||||
if (fields[cameraNavigationFieldYaw] != "") {
|
||||
result += "Yaw = " + fields[cameraNavigationFieldYaw] + ", ";
|
||||
if (!fields[cameraNavigationFieldYaw].empty()) {
|
||||
result += fmt::format("Yaw = {}, ", fields[cameraNavigationFieldYaw]);
|
||||
}
|
||||
if (fields[cameraNavigationFieldPitch] != "") {
|
||||
result += "Pitch = " + fields[cameraNavigationFieldPitch] + " ";
|
||||
if (!fields[cameraNavigationFieldPitch].empty()) {
|
||||
result += fmt::format("Pitch = {} ", fields[cameraNavigationFieldPitch]);
|
||||
}
|
||||
result += "})\n";
|
||||
}
|
||||
else if (fields[cameraFieldType] == "goToGeo") {
|
||||
result += " openspace.globebrowsing.goToGeo({ ";
|
||||
if (fields[cameraGeoFieldAnchor] != "") {
|
||||
if (!fields[cameraGeoFieldAnchor].empty()) {
|
||||
result += fields[cameraGeoFieldAnchor] + ", ";
|
||||
}
|
||||
result += fields[cameraGeoFieldLatitude] + ", ";
|
||||
result += fields[cameraGeoFieldLongitude] + ", ";
|
||||
if (fields[cameraGeoFieldAltitude] != "") {
|
||||
if (!fields[cameraGeoFieldAltitude].empty()) {
|
||||
result += fields[cameraGeoFieldAltitude] + ", ";
|
||||
}
|
||||
result += ")\n";
|
||||
}
|
||||
else {
|
||||
std::string err = "Camera entry's arg 1/1 must be either ";
|
||||
err += "'setNavigationState' or 'goToGeo'";
|
||||
throw ghoul::RuntimeError(err);
|
||||
throw ghoul::RuntimeError(
|
||||
"Camera entry's arg 1/1 must be either 'setNavigationState' or 'goToGeo'"
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace {
|
||||
constexpr const char* _loggerCat = "ProfileFile";
|
||||
constexpr const char* KeyIdentifier = "Identifier";
|
||||
constexpr const char* KeyParent = "Parent";
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
@@ -115,7 +114,7 @@ void ProfileFile::processIndividualLine(bool& insideSection, std::string line) {
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileFile::writeToFile(const std::string filename) {
|
||||
void ProfileFile::writeToFile(const std::string& filename) {
|
||||
if (filename.find("/") != std::string::npos) {
|
||||
LERROR("Profile filename must not contain path (/) elements");
|
||||
return;
|
||||
@@ -195,11 +194,11 @@ const std::string ProfileFile::getVersion() const {
|
||||
}
|
||||
|
||||
void ProfileFile::setVersion(std::string v) {
|
||||
_version = v;
|
||||
_version = std::move(v);
|
||||
}
|
||||
|
||||
void ProfileFile::addAllElements(std::string& str, std::vector<std::string>& list) {
|
||||
for (auto s : list) {
|
||||
for (const std::string& s : list) {
|
||||
str += s + '\n';
|
||||
}
|
||||
}
|
||||
@@ -487,26 +486,32 @@ size_t ProfileFile::splitByTab(std::string line, std::vector<std::string>& resul
|
||||
return result.size();
|
||||
}
|
||||
|
||||
void ProfileFile::updateTime(const std::string line) {
|
||||
_time = line;
|
||||
void ProfileFile::updateTime(std::string line) {
|
||||
_time = std::move(line);
|
||||
}
|
||||
void ProfileFile::updateCamera(const std::string line) {
|
||||
_camera = line;
|
||||
|
||||
void ProfileFile::updateCamera(std::string line) {
|
||||
_camera = std::move(line);
|
||||
}
|
||||
void ProfileFile::addModuleLine(const std::string line) {
|
||||
_modules.push_back(line);
|
||||
|
||||
void ProfileFile::addModuleLine(std::string line) {
|
||||
_modules.push_back(std::move(line));
|
||||
}
|
||||
void ProfileFile::addAssetLine(const std::string line) {
|
||||
_assets.push_back(line);
|
||||
|
||||
void ProfileFile::addAssetLine(std::string line) {
|
||||
_assets.push_back(std::move(line));
|
||||
}
|
||||
void ProfileFile::addPropertyLine(const std::string line) {
|
||||
_properties.push_back(line);
|
||||
|
||||
void ProfileFile::addPropertyLine(std::string line) {
|
||||
_properties.push_back(std::move(line));
|
||||
}
|
||||
void ProfileFile::addKeybindingLine(const std::string line) {
|
||||
_keybindings.push_back(line);
|
||||
|
||||
void ProfileFile::addKeybindingLine(std::string line) {
|
||||
_keybindings.push_back(std::move(line));
|
||||
}
|
||||
void ProfileFile::addMarkNodesLine(const std::string line) {
|
||||
_markNodes.push_back(line);
|
||||
|
||||
void ProfileFile::addMarkNodesLine(std::string line) {
|
||||
_markNodes.push_back(std::move(line));
|
||||
}
|
||||
|
||||
void ProfileFile::clearAssets() {
|
||||
|
||||
@@ -422,7 +422,7 @@ end)";
|
||||
|
||||
const std::string detectChangedPropsResult_1 = "\
|
||||
#Version\n\
|
||||
" + profileFormatVersion + "\n\
|
||||
" + std::string(Profile::FormatVersion) + "\n\
|
||||
\n\
|
||||
#Module\n\
|
||||
\n\
|
||||
@@ -456,7 +456,7 @@ Sun\n\
|
||||
|
||||
const std::string detectChangedAssetsResult_1 = "\
|
||||
#Version\n\
|
||||
" + profileFormatVersion + "\n\
|
||||
" + std::string(Profile::FormatVersion) + "\n\
|
||||
\n\
|
||||
#Module\n\
|
||||
\n\
|
||||
@@ -489,7 +489,7 @@ Sun\n\
|
||||
|
||||
const std::string detectChangedAssetsResult_2 = "\
|
||||
#Version\n\
|
||||
" + profileFormatVersion + "\n\
|
||||
" + std::string(Profile::FormatVersion) + "\n\
|
||||
\n\
|
||||
#Module\n\
|
||||
\n\
|
||||
@@ -521,7 +521,7 @@ Sun\n\
|
||||
|
||||
const std::string detectChangedAssetsResult_3 = "\
|
||||
#Version\n\
|
||||
" + profileFormatVersion + "\n\
|
||||
" + std::string(Profile::FormatVersion) + "\n\
|
||||
\n\
|
||||
#Module\n\
|
||||
\n\
|
||||
@@ -553,7 +553,7 @@ Sun\n\
|
||||
|
||||
const std::string detectChangedAssetsResult_4 = "\
|
||||
#Version\n\
|
||||
" + profileFormatVersion + "\n\
|
||||
" + std::string(Profile::FormatVersion) + "\n\
|
||||
\n\
|
||||
#Module\n\
|
||||
\n\
|
||||
@@ -585,7 +585,7 @@ Sun\n\
|
||||
|
||||
const std::string detectChangedAssetsResult_5 = "\
|
||||
#Version\n\
|
||||
" + profileFormatVersion + "\n\
|
||||
" + std::string(Profile::FormatVersion) + "\n\
|
||||
\n\
|
||||
#Module\n\
|
||||
\n\
|
||||
@@ -618,7 +618,7 @@ Sun\n\
|
||||
|
||||
const std::string detectChangedAssetsResult_6 = "\
|
||||
#Version\n\
|
||||
" + profileFormatVersion + "\n\
|
||||
" + std::string(Profile::FormatVersion) + "\n\
|
||||
\n\
|
||||
#Module\n\
|
||||
\n\
|
||||
|
||||
@@ -56,10 +56,10 @@ namespace {
|
||||
class Profile2 : public Profile {
|
||||
public:
|
||||
Profile2(AssetLoader& refAssetLoader) : _assLoader(refAssetLoader) {}
|
||||
std::string getCurrentTimeUTC() override {
|
||||
std::string currentTimeUTC() const override {
|
||||
return "2020-02-29T01:23:45.00";
|
||||
}
|
||||
interaction::NavigationHandler::NavigationState getCurrentCameraState() override {
|
||||
interaction::NavigationHandler::NavigationState currentCameraState() const override {
|
||||
interaction::NavigationHandler::NavigationState n;
|
||||
n.anchor = "Earth";
|
||||
n.aim = "Sun";
|
||||
@@ -73,24 +73,24 @@ public:
|
||||
void addPropertiesMarkedAsChanged(std::string formattedLine) {
|
||||
_scenegraphProps.push_back(formattedLine);
|
||||
}
|
||||
std::vector<std::string> getChangedPropertiesFormatted() override {
|
||||
std::vector<std::string> changedPropertiesFormatted() override {
|
||||
std::vector<std::string> formattedLines;
|
||||
for (std::string s : _scenegraphProps) {
|
||||
formattedLines.push_back(s);
|
||||
}
|
||||
return formattedLines;
|
||||
}
|
||||
bool usingProfile() override {
|
||||
bool usingProfile() const override {
|
||||
return true;
|
||||
}
|
||||
std::string initialProfile() override {
|
||||
std::string initialProfile() const override {
|
||||
return _initProfile;
|
||||
}
|
||||
void setInitialProfile(std::string file) {
|
||||
_initProfile = file;
|
||||
}
|
||||
std::vector<Profile::AssetEvent> listOfAllAssetEvents() override {
|
||||
return _assLoader.listOfAllAssetEvents();
|
||||
std::vector<Profile::AssetEvent> assetEvents() const override {
|
||||
return _assLoader.assetEvents();
|
||||
}
|
||||
void setProfileBaseDirectory(std::string dir) {
|
||||
_profileBaseDirectory = dir;
|
||||
@@ -235,7 +235,7 @@ TEST_CASE("profile: Detect new added assets after reset", "[profile]") {
|
||||
asset->initialize();
|
||||
std::shared_ptr<openspace::Asset> asset2 = assetLoader.add("test2");
|
||||
asset2->initialize();
|
||||
assetLoader.listOfAllAssetEvents_reset();
|
||||
assetLoader.resetAssetEvents();
|
||||
std::shared_ptr<openspace::Asset> asset3 = assetLoader.add("test3");
|
||||
asset3->initialize();
|
||||
std::shared_ptr<openspace::Asset> asset4 = assetLoader.add("test4");
|
||||
|
||||
Reference in New Issue
Block a user