mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-05 02:20:11 -05:00
Feature/alex is flying (#729)
* Correctly specify maximum text sizes for grids * Use StaticScale transformations in grids and remove fixed radius * Fix Verifier to let grids accept non-integer min and max sizes * Add a new scale that changes it's value based on the current time and a reference time * Add a proper radiosphere that grows in real time (closes #728) * Add default globe customization folders to the assets (closes #724) * Add new dashboarditem that shows the current camera velocity (closes #702) * Add ability to add interesting times to a scene (closes #715) * Reenable keybindings gui element * Add ShortcutManager * Add ability to bind keyless keybinds to use as arbitrary shortcuts (closes #710)
This commit is contained in:
@@ -53,6 +53,8 @@ set(OPENSPACE_SOURCE
|
||||
${OPENSPACE_BASE_DIR}/src/interaction/navigationhandler_lua.inl
|
||||
${OPENSPACE_BASE_DIR}/src/interaction/mousecamerastates.cpp
|
||||
${OPENSPACE_BASE_DIR}/src/interaction/orbitalnavigator.cpp
|
||||
${OPENSPACE_BASE_DIR}/src/interaction/shortcutmanager.cpp
|
||||
${OPENSPACE_BASE_DIR}/src/interaction/shortcutmanager_lua.inl
|
||||
${OPENSPACE_BASE_DIR}/src/mission/mission.cpp
|
||||
${OPENSPACE_BASE_DIR}/src/mission/missionmanager.cpp
|
||||
${OPENSPACE_BASE_DIR}/src/mission/missionmanager_lua.inl
|
||||
@@ -230,6 +232,7 @@ set(OPENSPACE_HEADER
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/interaction/mousecamerastates.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/interaction/navigationhandler.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/interaction/orbitalnavigator.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/interaction/shortcutmanager.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/mission/mission.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/mission/missionmanager.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/network/networkengine.h
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/interaction/keybindingmanager.h>
|
||||
#include <openspace/interaction/shortcutmanager.h>
|
||||
#include <openspace/mission/mission.h>
|
||||
#include <openspace/mission/missionmanager.h>
|
||||
#include <openspace/network/parallelpeer.h>
|
||||
@@ -79,6 +80,7 @@ void registerCoreClasses(scripting::ScriptEngine& engine) {
|
||||
engine.addLibrary(Time::luaLibrary());
|
||||
engine.addLibrary(interaction::KeybindingManager::luaLibrary());
|
||||
engine.addLibrary(interaction::NavigationHandler::luaLibrary());
|
||||
engine.addLibrary(interaction::ShortcutManager::luaLibrary());
|
||||
engine.addLibrary(scripting::ScriptScheduler::luaLibrary());
|
||||
engine.addLibrary(scripting::generalSystemCapabilities());
|
||||
engine.addLibrary(scripting::openglSystemCapabilities());
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <openspace/interaction/keybindingmanager.h>
|
||||
#include <openspace/interaction/joystickinputstate.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/interaction/shortcutmanager.h>
|
||||
#include <openspace/mission/missionmanager.h>
|
||||
#include <openspace/network/networkengine.h>
|
||||
#include <openspace/network/parallelpeer.h>
|
||||
@@ -162,6 +163,11 @@ interaction::NavigationHandler& gNavigationHandler() {
|
||||
return g;
|
||||
}
|
||||
|
||||
interaction::ShortcutManager& gShortcutManager() {
|
||||
static interaction::ShortcutManager g;
|
||||
return g;
|
||||
}
|
||||
|
||||
performance::PerformanceManager& gPerformanceManager() {
|
||||
static performance::PerformanceManager g;
|
||||
return g;
|
||||
|
||||
@@ -123,6 +123,12 @@ KeybindingManager::keyBinding(const std::string& key) const
|
||||
return result;
|
||||
}
|
||||
|
||||
const std::multimap<KeyWithModifier, KeybindingManager::KeyInformation>&
|
||||
KeybindingManager::keyBindings() const
|
||||
{
|
||||
return _keyLua;
|
||||
}
|
||||
|
||||
std::string KeybindingManager::generateJson() const {
|
||||
std::stringstream json;
|
||||
json << "[";
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/interaction/shortcutmanager.h>
|
||||
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/scripting/lualibrary.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <ghoul/glm.h>
|
||||
#include <sstream>
|
||||
|
||||
#include "shortcutmanager_lua.inl"
|
||||
|
||||
namespace openspace::interaction {
|
||||
|
||||
void ShortcutManager::resetShortcuts() {
|
||||
_shortcuts.clear();
|
||||
}
|
||||
|
||||
void ShortcutManager::addShortcut(ShortcutInformation info) {
|
||||
_shortcuts.push_back(std::move(info));
|
||||
}
|
||||
|
||||
const std::vector<ShortcutManager::ShortcutInformation>&
|
||||
ShortcutManager::shortcuts() const
|
||||
{
|
||||
return _shortcuts;
|
||||
}
|
||||
|
||||
scripting::LuaLibrary ShortcutManager::luaLibrary() {
|
||||
return {
|
||||
"",
|
||||
{
|
||||
{
|
||||
"clearShortcuts",
|
||||
&luascriptfunctions::clearShortcuts,
|
||||
{},
|
||||
"",
|
||||
"Clear all shortcuts in this scene"
|
||||
},
|
||||
{
|
||||
"bindShortcut",
|
||||
&luascriptfunctions::bindShortcut,
|
||||
{},
|
||||
"string, string [, string]",
|
||||
"Binds a Lua script to a new shortcut that is executed both locally and "
|
||||
"to be broadcast to clients if this is the host of a parallel session. "
|
||||
"The first argument is a human-readable name for this shortcut, the "
|
||||
"second argument is the Lua script that will be executed and the last "
|
||||
"argument is a describtive text for the shortcut for tooltips, etc."
|
||||
},
|
||||
{
|
||||
"bindShortcutLocal",
|
||||
&luascriptfunctions::bindShortcutLocal,
|
||||
{},
|
||||
"string, string [, string]",
|
||||
"Binds a Lua script to a new shortcut that is executed onlylocally. The "
|
||||
"first argument is a human-readable name for this shortcut, the second "
|
||||
"argument is the Lua script that will be executed and the last argument "
|
||||
"is a describtive text for the shortcut for tooltips, etc."
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace openspace::interaction
|
||||
@@ -0,0 +1,76 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2018 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
|
||||
openspace::interaction::ShortcutManager::ShortcutInformation extractInfo(lua_State* L,
|
||||
int nArguments,
|
||||
bool isSync)
|
||||
{
|
||||
openspace::interaction::ShortcutManager::ShortcutInformation i = {
|
||||
ghoul::lua::value<std::string>(L, 1, ghoul::lua::PopValue::No),
|
||||
ghoul::lua::value<std::string>(L, 2, ghoul::lua::PopValue::No),
|
||||
openspace::interaction::ShortcutManager::IsSynchronized(isSync),
|
||||
nArguments == 3 ?
|
||||
ghoul::lua::value<std::string>(L, 3, ghoul::lua::PopValue::No) :
|
||||
""
|
||||
};
|
||||
lua_pop(L, nArguments);
|
||||
return i;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace openspace::luascriptfunctions {
|
||||
|
||||
int clearShortcuts(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::clearShortcuts");
|
||||
global::shortcutManager.resetShortcuts();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bindShortcut(lua_State* L) {
|
||||
int n = ghoul::lua::checkArgumentsAndThrow(L, 2, 3, "lua::bindKeyLocal");
|
||||
|
||||
interaction::ShortcutManager::ShortcutInformation info = extractInfo(L, n, true);
|
||||
global::shortcutManager.addShortcut(std::move(info));
|
||||
|
||||
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bindShortcutLocal(lua_State* L) {
|
||||
int n = ghoul::lua::checkArgumentsAndThrow(L, 2, 3, "lua::bindKeyLocal");
|
||||
|
||||
interaction::ShortcutManager::ShortcutInformation info = extractInfo(L, n, false);
|
||||
global::shortcutManager.addShortcut(std::move(info));
|
||||
|
||||
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace openspace::luascriptfunctions
|
||||
@@ -540,6 +540,14 @@ void Scene::updateInterpolations() {
|
||||
);
|
||||
}
|
||||
|
||||
void Scene::addInterestingTime(InterestingTime time) {
|
||||
_interestingTimes.push_back(std::move(time));
|
||||
}
|
||||
|
||||
const std::vector<Scene::InterestingTime>& Scene::interestingTimes() const {
|
||||
return _interestingTimes;
|
||||
}
|
||||
|
||||
void Scene::writeSceneLicenseDocumentation(const std::string& path) const {
|
||||
SceneLicenseWriter writer(_licenses);
|
||||
writer.writeDocumentation(path);
|
||||
@@ -628,6 +636,15 @@ scripting::LuaLibrary Scene::luaLibrary() {
|
||||
"string",
|
||||
"Checks whether the specifies SceneGraphNode is present in the current "
|
||||
"scene"
|
||||
},
|
||||
{
|
||||
"addInterestingTime",
|
||||
&luascriptfunctions::addInterestingTime,
|
||||
{},
|
||||
"string, string",
|
||||
"Adds an interesting time to the current scene. The first argument is "
|
||||
"the name of the time and the second argument is the time itself in the "
|
||||
"format YYYY-MM-DDThh:mm:ss.uuu"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+17
-3
@@ -375,7 +375,7 @@ int property_setValueSingle(lua_State* L) {
|
||||
int property_getValue(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::property_getValue");
|
||||
|
||||
const std::string& uri = ghoul::lua::value<std::string>(
|
||||
std::string uri = ghoul::lua::value<std::string>(
|
||||
L,
|
||||
1,
|
||||
ghoul::lua::PopValue::Yes
|
||||
@@ -459,7 +459,7 @@ int addSceneGraphNode(lua_State* L) {
|
||||
int removeSceneGraphNode(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::removeSceneGraphNode");
|
||||
|
||||
const std::string& nodeName = ghoul::lua::value<std::string>(
|
||||
std::string nodeName = ghoul::lua::value<std::string>(
|
||||
L,
|
||||
1,
|
||||
ghoul::lua::PopValue::Yes
|
||||
@@ -509,7 +509,7 @@ int removeSceneGraphNode(lua_State* L) {
|
||||
int hasSceneGraphNode(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::hasSceneGraphNode");
|
||||
|
||||
const std::string& nodeName = ghoul::lua::value<std::string>(
|
||||
std::string nodeName = ghoul::lua::value<std::string>(
|
||||
L,
|
||||
1,
|
||||
ghoul::lua::PopValue::Yes
|
||||
@@ -522,4 +522,18 @@ int hasSceneGraphNode(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#pragma optimize("", off)
|
||||
int addInterestingTime(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 2, "lua::addInterestingTime");
|
||||
|
||||
std::string name = ghoul::lua::value<std::string>(L, 1, ghoul::lua::PopValue::No);
|
||||
std::string time = ghoul::lua::value<std::string>(L, 2, ghoul::lua::PopValue::No);
|
||||
lua_pop(L, 2);
|
||||
|
||||
global::renderEngine.scene()->addInterestingTime({std::move(name), std::move(time)});
|
||||
|
||||
ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack");
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace openspace::luascriptfunctions
|
||||
|
||||
Reference in New Issue
Block a user