mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-26 06:49:09 -06:00
Merge branch 'master' into issue/733
This commit is contained in:
@@ -91,6 +91,7 @@ struct Configuration {
|
||||
glm::dvec3 screenSpaceRotation = glm::dvec3(0.0);
|
||||
glm::dvec3 masterRotation = glm::dvec3(0.0);
|
||||
bool isConsoleDisabled = false;
|
||||
bool usingProfile = false;
|
||||
|
||||
std::map<std::string, ghoul::Dictionary> moduleConfigurations;
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace scripting {
|
||||
class ScriptEngine;
|
||||
class ScriptScheduler;
|
||||
} // namespace scripting
|
||||
class Profile;
|
||||
|
||||
namespace global {
|
||||
|
||||
@@ -100,6 +101,7 @@ properties::PropertyOwner& gRootPropertyOwner();
|
||||
properties::PropertyOwner& gScreenSpaceRootPropertyOwner();
|
||||
scripting::ScriptEngine& gScriptEngine();
|
||||
scripting::ScriptScheduler& gScriptScheduler();
|
||||
Profile& gProfile();
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -139,6 +141,7 @@ static properties::PropertyOwner& screenSpaceRootPropertyOwner =
|
||||
detail::gScreenSpaceRootPropertyOwner();
|
||||
static scripting::ScriptEngine& scriptEngine = detail::gScriptEngine();
|
||||
static scripting::ScriptScheduler& scriptScheduler = detail::gScriptScheduler();
|
||||
static Profile& profile = detail::gProfile();
|
||||
|
||||
void initialize();
|
||||
void initializeGL();
|
||||
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
const glm::mat4& projectionMatrix);
|
||||
void drawOverlays();
|
||||
void postDraw();
|
||||
void resetPropertyChangeFlags();
|
||||
void keyboardCallback(Key key, KeyModifier mod, KeyAction action);
|
||||
void charCallback(unsigned int codepoint, KeyModifier modifier);
|
||||
void mouseButtonCallback(MouseButton button, MouseAction action, KeyModifier mods);
|
||||
@@ -110,6 +111,7 @@ private:
|
||||
void runGlobalCustomizationScripts();
|
||||
void configureLogging();
|
||||
std::string generateFilePath(std::string openspaceRelativePath);
|
||||
void resetPropertyChangeFlagsOfSubowners(openspace::properties::PropertyOwner* po);
|
||||
|
||||
std::unique_ptr<Scene> _scene;
|
||||
std::unique_ptr<AssetManager> _assetManager;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <openspace/interaction/externinteraction.h>
|
||||
#include <openspace/interaction/keyframenavigator.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/scripting/lualibrary.h>
|
||||
#include <vector>
|
||||
|
||||
@@ -65,6 +66,12 @@ public:
|
||||
*/
|
||||
void preSynchronization();
|
||||
|
||||
/**
|
||||
* If enabled, calling this function will render information about the session
|
||||
* recording that is currently taking place to the screen.
|
||||
*/
|
||||
void render();
|
||||
|
||||
/**
|
||||
* Current time based on playback mode
|
||||
*/
|
||||
@@ -209,6 +216,8 @@ public:
|
||||
std::vector<std::string> playbackList() const;
|
||||
|
||||
private:
|
||||
properties::BoolProperty _renderPlaybackInformation;
|
||||
|
||||
enum class RecordedType {
|
||||
Camera = 0,
|
||||
Time,
|
||||
|
||||
@@ -495,6 +495,18 @@ public:
|
||||
*/
|
||||
virtual std::string generateAdditionalJsonDescription() const;
|
||||
|
||||
/**
|
||||
* Returns whether or not the property value has changed.
|
||||
*
|
||||
* \return true if the property has changed
|
||||
*/
|
||||
bool hasChanged() const;
|
||||
|
||||
/**
|
||||
* Reset the valChanged flag to an unchanged state, as if value has not been changed.
|
||||
*/
|
||||
void resetToUnchanged();
|
||||
|
||||
protected:
|
||||
static const char* IdentifierKey;
|
||||
static const char* NameKey;
|
||||
@@ -531,6 +543,9 @@ protected:
|
||||
/// The callback function sthat will be invoked whenever the value changes
|
||||
std::vector<std::pair<OnDeleteHandle, std::function<void()>>> _onDeleteCallbacks;
|
||||
|
||||
/// Flag indicating that this property value has been changed after initialization
|
||||
bool _isValueDirty = false;
|
||||
|
||||
private:
|
||||
void notifyDeleteListeners();
|
||||
|
||||
|
||||
@@ -176,6 +176,7 @@ void openspace::properties::TemplateProperty<T>::setValue(T val) {
|
||||
if (val != _value) {
|
||||
_value = std::move(val);
|
||||
notifyChangeListeners();
|
||||
_isValueDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,6 +197,7 @@ void TemplateProperty<T>::set(std::any value) {
|
||||
if (v != _value) {
|
||||
_value = std::move(v);
|
||||
notifyChangeListeners();
|
||||
_isValueDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,9 @@ public:
|
||||
enum class RenderBin : int {
|
||||
Background = 1,
|
||||
Opaque = 2,
|
||||
Transparent = 4,
|
||||
Overlay = 8
|
||||
PreDeferredTransparent = 4,
|
||||
PostDeferredTransparent = 8,
|
||||
Overlay = 16
|
||||
};
|
||||
|
||||
static std::unique_ptr<Renderable> createFromDictionary(
|
||||
|
||||
@@ -218,6 +218,7 @@ private:
|
||||
_onDependencyInitializationFunctionRefs;
|
||||
std::unordered_map<Asset*, std::map<Asset*, std::vector<int>>>
|
||||
_onDependencyDeinitializationFunctionRefs;
|
||||
|
||||
int _assetsTableRef = 0;
|
||||
};
|
||||
|
||||
|
||||
163
include/openspace/scene/profile.h
Normal file
163
include/openspace/scene/profile.h
Normal file
@@ -0,0 +1,163 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_CORE___PROFILE___H__
|
||||
#define __OPENSPACE_CORE___PROFILE___H__
|
||||
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/util/keys.h>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace scripting { struct LuaLibrary; }
|
||||
|
||||
class Profile {
|
||||
public:
|
||||
// Version
|
||||
struct Version {
|
||||
int major = 0;
|
||||
int minor = 0;
|
||||
};
|
||||
struct Module {
|
||||
std::string name;
|
||||
std::string loadedInstruction;
|
||||
std::string notLoadedInstruction;
|
||||
};
|
||||
struct Meta {
|
||||
std::string name;
|
||||
std::string version;
|
||||
std::string description;
|
||||
std::string author;
|
||||
std::string url;
|
||||
std::string license;
|
||||
};
|
||||
struct Asset {
|
||||
std::string path;
|
||||
std::string name;
|
||||
};
|
||||
struct Property {
|
||||
enum class SetType {
|
||||
SetPropertyValue,
|
||||
SetPropertyValueSingle
|
||||
};
|
||||
|
||||
SetType setType;
|
||||
std::string name;
|
||||
std::string value;
|
||||
};
|
||||
struct Keybinding {
|
||||
KeyWithModifier key;
|
||||
std::string documentation;
|
||||
std::string name;
|
||||
std::string guiPath;
|
||||
bool isLocal;
|
||||
std::string script;
|
||||
};
|
||||
struct Time {
|
||||
enum class Type {
|
||||
Absolute,
|
||||
Relative
|
||||
};
|
||||
|
||||
Type type;
|
||||
std::string time;
|
||||
};
|
||||
struct CameraNavState {
|
||||
static constexpr const char* Type = "setNavigationState";
|
||||
|
||||
std::string anchor;
|
||||
std::string aim;
|
||||
std::string referenceFrame;
|
||||
glm::dvec3 position;
|
||||
std::optional<glm::dvec3> up;
|
||||
std::optional<double> yaw;
|
||||
std::optional<double> pitch;
|
||||
};
|
||||
struct CameraGoToGeo {
|
||||
static constexpr const char* Type = "goToGeo";
|
||||
|
||||
std::string anchor;
|
||||
double latitude;
|
||||
double longitude;
|
||||
std::optional<double> altitude;
|
||||
};
|
||||
using CameraType = std::variant<CameraNavState, CameraGoToGeo>;
|
||||
|
||||
Profile() = default;
|
||||
Profile(const std::vector<std::string>& content);
|
||||
std::string serialize() const;
|
||||
|
||||
std::string convertToScene() const;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void saveCurrentSettingsToProfile(const properties::PropertyOwner& rootOwner,
|
||||
const std::string& currentTime,
|
||||
interaction::NavigationHandler::NavigationState navState);
|
||||
|
||||
/// If the value passed to this function is 'true', the addAsset and removeAsset
|
||||
/// functions will be no-ops instead
|
||||
void setIgnoreUpdates(bool ignoreUpdates);
|
||||
|
||||
/// Adds a new asset and checks for duplicates
|
||||
void addAsset(const std::string& path);
|
||||
|
||||
/// Removes an asset
|
||||
void removeAsset(const std::string& path);
|
||||
|
||||
/**
|
||||
* Returns the Lua library that contains all Lua functions available to provide
|
||||
* profile functionality.
|
||||
* \return The Lua library that contains all Lua functions available for profiles
|
||||
*/
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
static constexpr const Version CurrentVersion = Version { 1, 0 };
|
||||
|
||||
Version version = CurrentVersion;
|
||||
std::vector<Module> modules;
|
||||
std::optional<Meta> meta;
|
||||
std::vector<Asset> assets;
|
||||
std::vector<Property> properties;
|
||||
std::vector<Keybinding> keybindings;
|
||||
std::optional<Time> time;
|
||||
std::optional<CameraType> camera;
|
||||
std::vector<std::string> markNodes;
|
||||
std::vector<std::string> additionalScripts;
|
||||
|
||||
bool _ignoreUpdates = false;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___PROFILE___H__
|
||||
Reference in New Issue
Block a user