mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-02 00:44:43 -05:00
Merge with develop and solve conflicts.
This commit is contained in:
@@ -154,3 +154,4 @@ data/scene/juno/juno/textures
|
||||
data/scene/juno/juno/spice
|
||||
data/scene/juno/juno/Juno.mtl
|
||||
data/scene/juno/juno/Juno.obj
|
||||
KeyboardMapping.txt
|
||||
|
||||
@@ -130,6 +130,9 @@ int main(int argc, char** argv) {
|
||||
_sgctEngine->setExternalControlCallback(mainExternalControlCallback);
|
||||
_sgctEngine->setCharCallbackFunction(mainCharCallback);
|
||||
|
||||
// Disable the immediate exit of the application when the ESC key is pressed
|
||||
_sgctEngine->setExitKey(SGCT_KEY_UNKNOWN);
|
||||
|
||||
sgct::MessageHandler::instance()->setNotifyLevel(sgct::MessageHandler::NOTIFY_ALL);
|
||||
|
||||
// set encode and decode functions
|
||||
|
||||
@@ -6,6 +6,9 @@ function preInitialization()
|
||||
critical objects.
|
||||
]]--
|
||||
|
||||
openspace.spice.loadKernel("${SPICE}/naif0011.tls")
|
||||
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
|
||||
|
||||
openspace.time.setTime(openspace.time.currentWallTime())
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))
|
||||
end
|
||||
|
||||
@@ -6,6 +6,9 @@ function preInitialization()
|
||||
critical objects.
|
||||
]]--
|
||||
|
||||
openspace.spice.loadKernel("${SPICE}/naif0011.tls")
|
||||
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
|
||||
|
||||
openspace.time.setTime("2011 AUG 06 00:00:00")
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))
|
||||
end
|
||||
|
||||
@@ -19,6 +19,9 @@ function preInitialization()
|
||||
|
||||
-- 6:20 -> 23:20 day before in UTC
|
||||
]]--
|
||||
openspace.spice.loadKernel("${SPICE}/naif0011.tls")
|
||||
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
|
||||
|
||||
openspace.time.setTime("2016-03-08T22:45:00")
|
||||
|
||||
|
||||
|
||||
@@ -6,9 +6,12 @@ function preInitialization()
|
||||
critical objects.
|
||||
]]--
|
||||
|
||||
--openspace.time.setTime(openspace.time.currentWallTime())
|
||||
openspace.time.setTime('2015-03-15T11:00:00.00')
|
||||
openspace.spice.loadKernel("${SPICE}/naif0011.tls")
|
||||
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
|
||||
|
||||
openspace.time.setTime(openspace.time.currentWallTime())
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))
|
||||
|
||||
end
|
||||
|
||||
function postInitialization()
|
||||
@@ -66,7 +69,7 @@ return {
|
||||
"uranus",
|
||||
"neptune",
|
||||
"stars",
|
||||
--"stars-denver",
|
||||
-- "stars-denver",
|
||||
"milkyway",
|
||||
--"milkyway-eso",
|
||||
"constellationbounds",
|
||||
|
||||
@@ -6,6 +6,9 @@ function preInitialization()
|
||||
critical objects.
|
||||
]]--
|
||||
|
||||
openspace.spice.loadKernel("${SPICE}/naif0011.tls")
|
||||
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
|
||||
|
||||
openspace.time.setTime("2015 JAN 01 12:00:00.000")
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))
|
||||
end
|
||||
|
||||
@@ -6,10 +6,14 @@ function preInitialization()
|
||||
critical objects.
|
||||
]]--
|
||||
|
||||
openspace.time.setTime("2015 NOV 24 00:00:00")
|
||||
--openspace.time.setTime(openspace.time.currentWallTime())
|
||||
openspace.spice.loadKernel("${SPICE}/naif0011.tls")
|
||||
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
|
||||
|
||||
openspace.time.setTime("2015 NOV 24 00:00:00")
|
||||
|
||||
openspace.time.setTime(openspace.time.currentWallTime())
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))
|
||||
--openspace.bindKey("v", "openspace.setPropertyValue('DebugGlobe.saveOrThrowCamera', true)")
|
||||
end
|
||||
|
||||
function postInitialization()
|
||||
|
||||
@@ -5,16 +5,10 @@ function preInitialization()
|
||||
which the scene should start and other settings that might determine initialization
|
||||
critical objects.
|
||||
]]--
|
||||
openspace.spice.loadKernel("${SPICE}/naif0011.tls")
|
||||
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
|
||||
|
||||
-- openspace.time.setTime("2007-02-28T11:40:00.000")
|
||||
|
||||
-- openspace.time.setTime("2015-07-08T15:57:45.00")
|
||||
-- openspace.time.setTime("2015-07-12T07:41:00.00")
|
||||
-- openspace.time.setTime("2015-07-12T15:43:00.00")
|
||||
-- openspace.time.setTime("2015-07-12T22:19:20.00")
|
||||
-- openspace.time.setTime("2015-07-13T20:59:00.00")
|
||||
-- openspace.time.setTime("2015-07-14T02:41:55.00")
|
||||
openspace.time.setTime("2016-07-12T10:05:00.00")
|
||||
openspace.time.setTime("2016-07-05T10:05:00.00")
|
||||
openspace.time.setDeltaTime(0)
|
||||
|
||||
dofile(openspace.absPath('${SCRIPTS}/common.lua'))
|
||||
@@ -24,6 +18,8 @@ function preInitialization()
|
||||
1, 5, 10, 20, 40, 90, 360, 720, 2880, 14400,
|
||||
28800, 57600, 115200, 230400, 460800, 921600, 1843200, 3686400, 7372800, 14745600
|
||||
})
|
||||
|
||||
openspace.bindKey("F6", "openspace.setPropertyValue('Interaction.coordinateSystem', 'Jupiter');");
|
||||
end
|
||||
|
||||
function postInitialization()
|
||||
|
||||
@@ -26,12 +26,8 @@ return {
|
||||
0.0, -1.0, 0.0
|
||||
}
|
||||
},
|
||||
Shading = {
|
||||
PerformShading = true,
|
||||
Fadeable = false,
|
||||
Ghosting = false,
|
||||
},
|
||||
},
|
||||
|
||||
Ephemeris = {
|
||||
Type = "Spice",
|
||||
Body = "JUNO",
|
||||
@@ -136,8 +132,7 @@ return {
|
||||
Body = "JUNO",
|
||||
Frame = "GALACTIC",
|
||||
Observer = "JUPITER BARYCENTER",
|
||||
-- Observer = "PLUTO BARYCENTER",
|
||||
RGB = {0.70,0.50,0.20},
|
||||
RGB = { 0.70,0.50,0.20 },
|
||||
TropicalOrbitPeriod = 394250.0,
|
||||
EarthOrbitRatio = 4.5,
|
||||
DayLength = 9.9259,
|
||||
@@ -145,9 +140,7 @@ return {
|
||||
Textures = {
|
||||
Type = "simple",
|
||||
Color = "textures/glare_blue.png",
|
||||
-- need to add different texture
|
||||
},
|
||||
},
|
||||
GuiName = "/Solar/JunoTrail"
|
||||
},
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ function preInitialization()
|
||||
critical objects.
|
||||
]]--
|
||||
|
||||
openspace.spice.loadKernel("${SPICE}/naif0011.tls")
|
||||
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
|
||||
|
||||
-- openspace.time.setTime("2007-02-28T11:40:00.000")
|
||||
|
||||
-- openspace.time.setTime("2015-07-08T15:57:45.00")
|
||||
|
||||
@@ -6,6 +6,9 @@ function preInitialization()
|
||||
critical objects.
|
||||
]]--
|
||||
|
||||
openspace.spice.loadKernel("${SPICE}/naif0011.tls")
|
||||
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
|
||||
|
||||
openspace.time.setTime("2014-08-15T03:05:18.101")
|
||||
-- openspace.time.setTime("2014-11-17T03:05:18.101")
|
||||
-- openspace.time.setTime("2015-07-29T06:02:10.000")
|
||||
|
||||
@@ -6,6 +6,9 @@ function preInitialization()
|
||||
critical objects.
|
||||
]]--
|
||||
|
||||
openspace.spice.loadKernel("${SPICE}/naif0011.tls")
|
||||
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
|
||||
|
||||
openspace.time.setTime(openspace.time.currentWallTime())
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))
|
||||
end
|
||||
|
||||
+1
-1
Submodule ext/ghoul updated: 18c2a46152...60e65350db
@@ -61,6 +61,10 @@ public:
|
||||
static const std::string KeyPropertyDocumentationType;
|
||||
/// The key that stores the save location of the Property documentation
|
||||
static const std::string KeyPropertyDocumentationFile;
|
||||
/// The key that stores the type of keyboard bindings that should be stored
|
||||
static const std::string KeyKeyboardShortcutsType;
|
||||
/// The key that stores the save location of the keyboard bindings file
|
||||
static const std::string KeyKeyboardShortcutsFile;
|
||||
/// The key that stores the location of the scene file that is initially loaded
|
||||
static const std::string KeyConfigScene;
|
||||
/// The key that stores the subdirectory containing a list of all startup scripts to
|
||||
@@ -69,12 +73,6 @@ public:
|
||||
/// The key that stores the subdirectory containing a list of all settings scripts to
|
||||
/// be executed on application start and after the scene file is loaded
|
||||
static const std::string KeySettingsScript;
|
||||
/// The key that stores the location of the SPICE time kernel to be loaded on
|
||||
/// application start
|
||||
static const std::string KeySpiceTimeKernel;
|
||||
/// The key that stores the location of the SPICE leapsecond kernel to be loaded on
|
||||
/// application start
|
||||
static const std::string KeySpiceLeapsecondKernel;
|
||||
/// The key that stores the desired LogLevel for the whole application
|
||||
/// \sa ghoul::logging::LogManager
|
||||
static const std::string KeyLogLevel;
|
||||
@@ -88,6 +86,9 @@ public:
|
||||
/// The key that stores the verbosity (None, Minimal, Default, Full) of the system
|
||||
/// capabilities components
|
||||
static const std::string KeyCapabilitiesVerbosity;
|
||||
/// The key that stores the time (in seconds) that the application will wait before
|
||||
/// shutting down after the shutdown call is made
|
||||
static const std::string KeyShutdownCountdown;
|
||||
/// The key that stores whether the master node should perform rendering just function
|
||||
/// as a pure manager
|
||||
static const std::string KeyDisableMasterRendering;
|
||||
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
* Returns the Lua library that contains all Lua functions available to affect the
|
||||
* modules.
|
||||
*/
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
/// The list of all registered OpenSpaceModule%s
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <openspace/util/keys.h>
|
||||
#include <openspace/util/mouse.h>
|
||||
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
|
||||
@@ -55,7 +57,7 @@ class SettingsEngine;
|
||||
|
||||
namespace interaction { class InteractionHandler; }
|
||||
namespace gui { class GUI; }
|
||||
namespace scripting { class ScriptEngine; }
|
||||
//namespace scripting { class ScriptEngine; }
|
||||
namespace network { class ParallelConnection; }
|
||||
namespace properties { class PropertyOwner; }
|
||||
|
||||
@@ -110,15 +112,22 @@ public:
|
||||
void enableBarrier();
|
||||
void disableBarrier();
|
||||
|
||||
void toggleShutdownMode();
|
||||
|
||||
void runPostInitializationScripts(const std::string& sceneDescription);
|
||||
|
||||
/**
|
||||
* Returns the Lua library that contains all Lua functions available to affect the
|
||||
* application.
|
||||
*/
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
OpenSpaceEngine(std::string programName, std::unique_ptr<WindowWrapper> windowWrapper);
|
||||
~OpenSpaceEngine();
|
||||
|
||||
void clearAllWindows();
|
||||
bool gatherCommandlineArguments();
|
||||
bool loadSpiceKernels();
|
||||
void loadFonts();
|
||||
void runScripts(const ghoul::Dictionary& scripts);
|
||||
void runPreInitializationScripts(const std::string& sceneDescription);
|
||||
@@ -149,6 +158,14 @@ private:
|
||||
bool _isMaster;
|
||||
double _runTime;
|
||||
|
||||
// Whether the application is currently in shutdown mode (i.e. counting down the timer
|
||||
// and closing it at '0'
|
||||
bool _isInShutdownMode;
|
||||
// The total amount of time the application will wait before actually shutting down
|
||||
float _shutdownWait;
|
||||
// The current state of the countdown; if it reaches '0', the application will close
|
||||
float _shutdownCountdown;
|
||||
|
||||
static OpenSpaceEngine* _engine;
|
||||
};
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace openspace {
|
||||
*/
|
||||
class SGCTWindowWrapper : public WindowWrapper {
|
||||
public:
|
||||
void terminate() override;
|
||||
void setBarrier(bool enabled) override;
|
||||
void clearAllWindows(const glm::vec4& clearColor) override;
|
||||
bool windowHasResized() const override;
|
||||
|
||||
@@ -42,6 +42,12 @@ namespace openspace {
|
||||
*/
|
||||
class WindowWrapper {
|
||||
public:
|
||||
/**
|
||||
* This method closes the application by calling the necessary terminate function of
|
||||
* the window management system
|
||||
*/
|
||||
virtual void terminate();
|
||||
|
||||
/**
|
||||
* This method enables or disables a framelock barrier. If the specific windowing
|
||||
* framework does not provide a framelock, this method defaults to a no-op.
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
* \return The Lua library that contains all Lua functions available to affect the
|
||||
* interaction
|
||||
*/
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
|
||||
// Callback functions
|
||||
@@ -108,6 +108,7 @@ public:
|
||||
void distanceDelta(const PowerScaledScalar& distance, size_t iterations = 0);
|
||||
void lookAt(const glm::quat& rotation);
|
||||
void setRotation(const glm::quat& rotation);
|
||||
|
||||
|
||||
private:
|
||||
// Remove copy and move constructors
|
||||
@@ -187,7 +188,7 @@ public:
|
||||
* \return The Lua library that contains all Lua functions available to affect the
|
||||
* interaction
|
||||
*/
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
// Callback functions
|
||||
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
|
||||
@@ -197,6 +198,7 @@ public:
|
||||
|
||||
void saveCameraStateToFile(const std::string& filepath);
|
||||
void restoreCameraStateFromFile(const std::string& filepath);
|
||||
void writeKeyboardDocumentation(const std::string& type, const std::string& file);
|
||||
|
||||
private:
|
||||
void setInteractionMode(std::shared_ptr<InteractionMode> interactionMode);
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
void setVisible(bool visible);
|
||||
void toggleVisibility();
|
||||
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace openspace{
|
||||
* \return The Lua library that contains all Lua functions available to affect the
|
||||
* interaction
|
||||
*/
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifndef __PERFORMANCEMEASUREMENT_H__
|
||||
#define __PERFORMANCEMEASUREMENT_H__
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
|
||||
@@ -49,7 +52,12 @@ private:
|
||||
#define __LABEL(a) __MERGE(unique_name_, a)
|
||||
|
||||
/// Declare a new variable for measuring the performance of the current block
|
||||
#define PerfMeasure(name) auto __LABEL(__LINE__) = openspace::performance::PerformanceMeasurement((name), OsEng.renderEngine().performanceManager())
|
||||
#define PerfMeasure(name) \
|
||||
auto __LABEL(__LINE__) = \
|
||||
openspace::performance::PerformanceMeasurement(\
|
||||
(name), \
|
||||
OsEng.renderEngine().performanceManager() \
|
||||
)
|
||||
|
||||
} // namespace performance
|
||||
} // namespace openspace
|
||||
|
||||
@@ -26,12 +26,14 @@
|
||||
#define __QUERY_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace properties {
|
||||
class Property;
|
||||
}
|
||||
|
||||
class Renderable;
|
||||
class Scene;
|
||||
class SceneGraphNode;
|
||||
@@ -42,6 +44,7 @@ Scene* sceneGraph();
|
||||
SceneGraphNode* sceneGraphNode(const std::string& name);
|
||||
Renderable* renderable(const std::string& name);
|
||||
properties::Property* property(const std::string& uri);
|
||||
std::vector<properties::Property*> allProperties();
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -89,7 +89,10 @@ public:
|
||||
bool initializeGL();
|
||||
void postSynchronizationPreDraw();
|
||||
void preSynchronization();
|
||||
void render(const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix, bool showGui);
|
||||
void render(const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix);
|
||||
|
||||
void renderScreenLog();
|
||||
void renderShutdownInformation(float timer, float fullTime);
|
||||
void postDraw();
|
||||
|
||||
void takeScreenshot();
|
||||
@@ -162,7 +165,7 @@ public:
|
||||
* Returns the Lua library that contains all Lua functions available to affect the
|
||||
* rendering.
|
||||
*/
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
// This is a temporary method to change the origin of the coordinate system ---abock
|
||||
void changeViewPoint(std::string origin);
|
||||
@@ -183,7 +186,6 @@ private:
|
||||
RendererImplementation rendererFromString(const std::string& method);
|
||||
|
||||
void renderInformation();
|
||||
void renderScreenLog();
|
||||
|
||||
Camera* _mainCamera;
|
||||
Scene* _sceneGraph;
|
||||
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
*/
|
||||
SceneGraphNode* sceneGraphNode(const std::string& name) const;
|
||||
|
||||
std::vector<SceneGraphNode*> allSceneGraphNodes();
|
||||
std::vector<SceneGraphNode*> allSceneGraphNodes() const;
|
||||
|
||||
SceneGraph& sceneGraph();
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
* \return The Lua library that contains all Lua functions available to change the
|
||||
* scene graph
|
||||
*/
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
bool loadSceneInternal(const std::string& sceneDescriptionFilePath);
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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 __LUALIBRARY_H__
|
||||
#define __LUALIBRARY_H__
|
||||
|
||||
#include <ghoul/lua/ghoul_lua.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace scripting {
|
||||
|
||||
/**
|
||||
* This structure represents a Lua library, itself consisting of a unique #name and
|
||||
* an arbitrary number of #functions
|
||||
*/
|
||||
struct LuaLibrary {
|
||||
/**
|
||||
* This structure represents a Lua function with its #name, #function pointer
|
||||
* #argumentText describing the arguments this function takes, the #helpText
|
||||
* describing the function, and whether it should be shared in a parallel
|
||||
* connection (#parallelShared)
|
||||
*/
|
||||
struct Function {
|
||||
/// The name of the function
|
||||
std::string name;
|
||||
/// The function pointer that is executed if the function is called
|
||||
lua_CFunction function;
|
||||
/// A text describing the arugments to this function
|
||||
std::string argumentText;
|
||||
/// A help text describing what the function does/
|
||||
std::string helpText;
|
||||
/// If <code>true</code>, this function will be shared with other parallel
|
||||
/// connections
|
||||
bool parallelShared;
|
||||
};
|
||||
/// The name of the library
|
||||
std::string name;
|
||||
/// The list of all functions for this library
|
||||
std::vector<Function> functions;
|
||||
|
||||
/// Comparison function that compares two LuaLibrary%s name
|
||||
bool operator<(const LuaLibrary& rhs) const;
|
||||
};
|
||||
|
||||
} // namespace scripting
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __LUALIBRARY_H__
|
||||
@@ -25,6 +25,8 @@
|
||||
#ifndef __SCRIPTENGINE_H__
|
||||
#define __SCRIPTENGINE_H__
|
||||
|
||||
#include <openspace/scripting/lualibrary.h>
|
||||
|
||||
#include <ghoul/lua/ghoul_lua.h>
|
||||
|
||||
#include <map>
|
||||
@@ -47,39 +49,6 @@ namespace scripting {
|
||||
*/
|
||||
class ScriptEngine {
|
||||
public:
|
||||
/**
|
||||
* This structure represents a Lua library, itself consisting of a unique #name and
|
||||
* an arbitrary number of #functions
|
||||
*/
|
||||
struct LuaLibrary {
|
||||
/**
|
||||
* This structure represents a Lua function with its #name, #function pointer
|
||||
* #argumentText describing the arguments this function takes, the #helpText
|
||||
* describing the function, and whether it should be shared in a parallel
|
||||
* connection (#parallelShared)
|
||||
*/
|
||||
struct Function {
|
||||
/// The name of the function
|
||||
std::string name;
|
||||
/// The function pointer that is executed if the function is called
|
||||
lua_CFunction function;
|
||||
/// A text describing the arugments to this function
|
||||
std::string argumentText;
|
||||
/// A help text describing what the function does/
|
||||
std::string helpText;
|
||||
/// If <code>true</code>, this function will be shared with other parallel
|
||||
/// connections
|
||||
bool parallelShared;
|
||||
};
|
||||
/// The name of the library
|
||||
std::string name;
|
||||
/// The list of all functions for this library
|
||||
std::vector<Function> functions;
|
||||
|
||||
/// Comparison function that compares two LuaLibrary%s name
|
||||
bool operator<(const LuaLibrary& rhs) const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initializes the internal Lua state and registers a common set of library functions
|
||||
* \throw LuaRuntimeException If the creation of the new Lua state fails
|
||||
|
||||
@@ -359,7 +359,14 @@ static const std::map<std::string, Key> KeyMapping = {
|
||||
{ "MENU", Key::Menu }
|
||||
};
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
namespace std {
|
||||
|
||||
std::string to_string(openspace::Key key);
|
||||
std::string to_string(openspace::KeyModifier mod);
|
||||
std::string to_string(openspace::KeyWithModifier key);
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif // __KEYS_H__
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#ifndef __SPICEMANAGER_H__
|
||||
#define __SPICEMANAGER_H__
|
||||
|
||||
#include <openspace/scripting/lualibrary.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
@@ -47,7 +48,6 @@ namespace openspace {
|
||||
|
||||
class SpiceManager : public ghoul::Singleton<SpiceManager> {
|
||||
friend class ghoul::Singleton<SpiceManager>;
|
||||
|
||||
public:
|
||||
using TransformMatrix = std::array<double, 36>;
|
||||
using KernelHandle = unsigned int;
|
||||
@@ -809,6 +809,8 @@ public:
|
||||
*/
|
||||
std::string frameFromBody(const std::string& body) const;
|
||||
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
/// Struct storing the information about all loaded kernels
|
||||
struct KernelInformation {
|
||||
|
||||
@@ -207,7 +207,7 @@ public:
|
||||
* \return The Lua library that contains all Lua functions available to change the
|
||||
* Time singleton
|
||||
*/
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
static Time* _instance; ///< The singleton instance
|
||||
|
||||
@@ -652,7 +652,7 @@ void IswaManager::setBaseUrl(std::string bUrl){
|
||||
baseUrl = bUrl;
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary IswaManager::luaLibrary() {
|
||||
scripting::LuaLibrary IswaManager::luaLibrary() {
|
||||
return {
|
||||
"iswa",
|
||||
{
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
std::map<std::string, std::shared_ptr<IswaBaseGroup>>& groups();
|
||||
std::map<std::string, std::vector<CdfInfo>>& cdfInformation();
|
||||
|
||||
static scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
static scripting::LuaLibrary luaLibrary();
|
||||
|
||||
ghoul::Event<>& iswaEvent(){
|
||||
return _iswaEvent;
|
||||
|
||||
@@ -33,7 +33,7 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guipropertycomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guitimecomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guiiswacomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/renderproperties.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/renderproperties.h
|
||||
)
|
||||
source_group("Header Files" FILES ${HEADER_FILES})
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
|
||||
void render();
|
||||
|
||||
static openspace::scripting::ScriptEngine::LuaLibrary luaLibrary();
|
||||
static openspace::scripting::LuaLibrary luaLibrary();
|
||||
|
||||
//protected:
|
||||
GuiHelpComponent _help;
|
||||
|
||||
@@ -499,7 +499,7 @@ void GUI::render() {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary GUI::luaLibrary() {
|
||||
scripting::LuaLibrary GUI::luaLibrary() {
|
||||
return {
|
||||
"gui",
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ void renderTooltip(Property* prop) {
|
||||
|
||||
void executeScript(const std::string& id, const std::string& value) {
|
||||
std::string script =
|
||||
"openspace.setPropertyValue('" + id + "', " + value + ");";
|
||||
"openspace.setPropertyValueSingle('" + id + "', " + value + ");";
|
||||
OsEng.scriptEngine().queueScript(script);
|
||||
}
|
||||
|
||||
|
||||
+1
-4
@@ -27,10 +27,6 @@ return {
|
||||
CACHE = "${BASE_PATH}/cache",
|
||||
FONTS = "${OPENSPACE_DATA}/fonts",
|
||||
},
|
||||
SpiceKernel = {
|
||||
Time = "${SPICE}/naif0011.tls",
|
||||
LeapSecond = "${SPICE}/pck00010.tpc",
|
||||
},
|
||||
Fonts = {
|
||||
Mono = "${FONTS}/Droid_Sans_Mono/DroidSansMono.ttf",
|
||||
Light = "${FONTS}/Roboto/Roboto-Regular.ttf"
|
||||
@@ -55,6 +51,7 @@ return {
|
||||
Type = "text",
|
||||
File = "${BASE_PATH}/ScriptLog.txt"
|
||||
},
|
||||
ShutdownCountdown = 3,
|
||||
DownloadRequestURL = "http://openspace.itn.liu.se/request.cgi",
|
||||
RenderingMethod = "Framebuffer"
|
||||
--RenderingMethod = "ABuffer" -- alternative: "Framebuffer"
|
||||
|
||||
@@ -11,6 +11,8 @@ helper.setCommonKeys = function()
|
||||
openspace.bindKey("F2", "openspace.setPerformanceMeasurement(true)")
|
||||
openspace.bindKey("F3", "openspace.setPerformanceMeasurement(false)")
|
||||
|
||||
openspace.bindKey("ESC", "openspace.toggleShutdown()")
|
||||
|
||||
openspace.bindKey("PRINT_SCREEN", "openspace.takeScreenshot()")
|
||||
openspace.bindKey("SPACE", "openspace.time.togglePause()")
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ set(OPENSPACE_SOURCE
|
||||
${OPENSPACE_BASE_DIR}/src/scene/scene_lua.inl
|
||||
${OPENSPACE_BASE_DIR}/src/scene/scenegraph.cpp
|
||||
${OPENSPACE_BASE_DIR}/src/scene/scenegraphnode.cpp
|
||||
${OPENSPACE_BASE_DIR}/src/scripting/lualibrary.cpp
|
||||
${OPENSPACE_BASE_DIR}/src/scripting/scriptengine.cpp
|
||||
${OPENSPACE_BASE_DIR}/src/scripting/scriptengine_lua.inl
|
||||
${OPENSPACE_BASE_DIR}/src/util/blockplaneintersectiongeometry.cpp
|
||||
@@ -160,6 +161,7 @@ set(OPENSPACE_HEADER
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/scene/scene.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/scene/scenegraph.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/scene/scenegraphnode.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/scripting/lualibrary.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/scripting/script_helper.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/scripting/scriptengine.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/util/blockplaneintersectiongeometry.h
|
||||
|
||||
@@ -51,14 +51,15 @@ const string ConfigurationManager::KeyPropertyDocumentationType =
|
||||
"PropertyDocumentationFile.Type";
|
||||
const string ConfigurationManager::KeyPropertyDocumentationFile =
|
||||
"PropertyDocumentationFile.File";
|
||||
const string ConfigurationManager::KeyKeyboardShortcutsType = "KeyboardShortcuts.Type";
|
||||
const string ConfigurationManager::KeyKeyboardShortcutsFile = "KeyboardShortcuts.File";
|
||||
const string ConfigurationManager::KeyConfigScene = "Scene";
|
||||
const string ConfigurationManager::KeySpiceTimeKernel = "SpiceKernel.Time";
|
||||
const string ConfigurationManager::KeySpiceLeapsecondKernel = "SpiceKernel.LeapSecond";
|
||||
const string ConfigurationManager::KeyLogLevel = "Logging.LogLevel";
|
||||
const string ConfigurationManager::KeyLogImmediateFlush = "Logging.ImmediateFlush";
|
||||
const string ConfigurationManager::KeyLogs = "Logging.Logs";
|
||||
const string ConfigurationManager::KeyCapabilitiesVerbosity =
|
||||
"Logging.CapabilitiesVerbosity";
|
||||
const string ConfigurationManager::KeyShutdownCountdown = "ShutdownCountdown";
|
||||
const string ConfigurationManager::KeyDisableMasterRendering = "DisableRenderingOnMaster";
|
||||
const string ConfigurationManager::KeyDownloadRequestURL = "DownloadRequestURL";
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ std::vector<OpenSpaceModule*> ModuleEngine::modules() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary ModuleEngine::luaLibrary() {
|
||||
scripting::LuaLibrary ModuleEngine::luaLibrary() {
|
||||
return {
|
||||
"modules",
|
||||
{
|
||||
|
||||
@@ -84,6 +84,8 @@
|
||||
#include <WinBase.h>
|
||||
#endif
|
||||
|
||||
#include "openspaceengine_lua.inl"
|
||||
|
||||
using namespace openspace::scripting;
|
||||
using namespace ghoul::filesystem;
|
||||
using namespace ghoul::logging;
|
||||
@@ -140,6 +142,9 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName,
|
||||
, _isMaster(false)
|
||||
, _runTime(0.0)
|
||||
, _syncBuffer(new SyncBuffer(4096))
|
||||
, _isInShutdownMode(false)
|
||||
, _shutdownCountdown(0.f)
|
||||
, _shutdownWait(0.f)
|
||||
{
|
||||
_interactionHandler->setPropertyOwner(_globalPropertyNamespace.get());
|
||||
_globalPropertyNamespace->addPropertySubOwner(_interactionHandler.get());
|
||||
@@ -369,13 +374,10 @@ bool OpenSpaceEngine::initialize() {
|
||||
_downloadManager = std::make_unique<DownloadManager>(requestURL, DownloadVersion);
|
||||
}
|
||||
|
||||
// Load SPICE time kernel
|
||||
success = loadSpiceKernels();
|
||||
if (!success)
|
||||
return false;
|
||||
|
||||
// Register Lua script functions
|
||||
LDEBUG("Registering Lua libraries");
|
||||
_scriptEngine->addLibrary(OpenSpaceEngine::luaLibrary());
|
||||
_scriptEngine->addLibrary(SpiceManager::luaLibrary());
|
||||
_scriptEngine->addLibrary(RenderEngine::luaLibrary());
|
||||
_scriptEngine->addLibrary(Scene::luaLibrary());
|
||||
_scriptEngine->addLibrary(Time::luaLibrary());
|
||||
@@ -410,6 +412,9 @@ bool OpenSpaceEngine::initialize() {
|
||||
ConfigurationManager::KeyDisableMasterRendering, disableMasterRendering);
|
||||
_renderEngine->setDisableRenderingOnMaster(disableMasterRendering);
|
||||
|
||||
configurationManager().getValue(
|
||||
ConfigurationManager::KeyShutdownCountdown, _shutdownWait
|
||||
);
|
||||
|
||||
// Load scenegraph
|
||||
Scene* sceneGraph = new Scene;
|
||||
@@ -525,30 +530,6 @@ bool OpenSpaceEngine::gatherCommandlineArguments() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenSpaceEngine::loadSpiceKernels() {
|
||||
// Load time kernel
|
||||
std::string timeKernel;
|
||||
bool success = configurationManager().getValue(ConfigurationManager::KeySpiceTimeKernel, timeKernel);
|
||||
// Move this to configurationmanager::completenesscheck ---abock
|
||||
if (!success) {
|
||||
LERROR("Configuration file does not contain a '" << ConfigurationManager::KeySpiceTimeKernel << "'");
|
||||
return false;
|
||||
}
|
||||
SpiceManager::KernelHandle id =
|
||||
SpiceManager::ref().loadKernel(timeKernel);
|
||||
|
||||
// Load SPICE leap second kernel
|
||||
std::string leapSecondKernel;
|
||||
success = configurationManager().getValue(ConfigurationManager::KeySpiceLeapsecondKernel, leapSecondKernel);
|
||||
if (!success) {
|
||||
// Move this to configurationmanager::completenesscheck ---abock
|
||||
LERROR("Configuration file does not have a '" << ConfigurationManager::KeySpiceLeapsecondKernel << "'");
|
||||
return false;
|
||||
}
|
||||
id = SpiceManager::ref().loadKernel(std::move(leapSecondKernel));
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::runScripts(const ghoul::Dictionary& scripts) {
|
||||
for (size_t i = 1; i <= scripts.size(); ++i) {
|
||||
std::stringstream stream;
|
||||
@@ -768,6 +749,13 @@ void OpenSpaceEngine::preSynchronization() {
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
if (_isInShutdownMode) {
|
||||
if (_shutdownCountdown <= 0.f) {
|
||||
_windowWrapper->terminate();
|
||||
}
|
||||
_shutdownCountdown -= _windowWrapper->averageDeltaTime();
|
||||
}
|
||||
|
||||
Time::ref().postSynchronizationPreDraw();
|
||||
|
||||
_scriptEngine->postSynchronizationPreDraw();
|
||||
@@ -816,24 +804,26 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::render(const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix) {
|
||||
bool showGui = _windowWrapper->hasGuiWindow() ? _windowWrapper->isGuiWindow() : true;
|
||||
|
||||
_renderEngine->render(projectionMatrix, viewMatrix, showGui);
|
||||
|
||||
if (_isMaster && _windowWrapper->isRegularRendering()) {
|
||||
if (showGui) {
|
||||
if (_console->isVisible())
|
||||
_console->render();
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
if (_gui->isEnabled())
|
||||
_gui->endFrame();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
_renderEngine->render(projectionMatrix, viewMatrix);
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::postDraw() {
|
||||
_renderEngine->postDraw();
|
||||
|
||||
bool showGui = _windowWrapper->hasGuiWindow() ? _windowWrapper->isGuiWindow() : true;
|
||||
if (showGui) {
|
||||
_renderEngine->renderScreenLog();
|
||||
|
||||
if (_console->isVisible())
|
||||
_console->render();
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
if (_gui->isEnabled())
|
||||
_gui->endFrame();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (_isInShutdownMode)
|
||||
_renderEngine->renderShutdownInformation(_shutdownCountdown, _shutdownWait);
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::keyboardCallback(Key key, KeyModifier mod, KeyAction action) {
|
||||
@@ -936,6 +926,35 @@ void OpenSpaceEngine::externalControlCallback(const char* receivedChars, int siz
|
||||
_networkEngine->handleMessage(std::string(receivedChars, size));
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::toggleShutdownMode() {
|
||||
if (_isInShutdownMode) {
|
||||
// If we are already in shutdown mode, we want to disable it instead
|
||||
LINFO("Disabled shutdown mode");
|
||||
_isInShutdownMode = false;
|
||||
}
|
||||
else {
|
||||
// Else, we hav eto enable it
|
||||
LINFO("Shutting down OpenSpace");
|
||||
_shutdownCountdown = _shutdownWait;
|
||||
_isInShutdownMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
scripting::LuaLibrary OpenSpaceEngine::luaLibrary() {
|
||||
return {
|
||||
"",
|
||||
{
|
||||
{
|
||||
"toggleShutdown",
|
||||
&luascriptfunctions::toggleShutdown,
|
||||
"",
|
||||
"Toggles the shutdown mode that will close the application after the count"
|
||||
"down timer is reached"
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::enableBarrier() {
|
||||
_windowWrapper->setBarrier(true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
namespace openspace {
|
||||
namespace luascriptfunctions {
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* toggleShutdown():
|
||||
* Toggles the shutdown mode that will close the application after the countdown timer is
|
||||
* reached
|
||||
*/
|
||||
int toggleShutdown(lua_State* L) {
|
||||
int nArguments = lua_gettop(L);
|
||||
if (nArguments != 0)
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
|
||||
|
||||
OsEng.toggleShutdownMode();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
} // namespace luascriptfunctions
|
||||
} // namespace openspace
|
||||
@@ -36,6 +36,10 @@ namespace {
|
||||
|
||||
namespace openspace {
|
||||
|
||||
void SGCTWindowWrapper::terminate() {
|
||||
sgct::Engine::instance()->terminate();
|
||||
}
|
||||
|
||||
void SGCTWindowWrapper::setBarrier(bool enabled) {
|
||||
sgct::SGCTWindow::setBarrier(enabled);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace openspace {
|
||||
WindowWrapper::WindowWrapperException::WindowWrapperException(const std::string& msg)
|
||||
: ghoul::RuntimeError(msg, "WindowWrapper")
|
||||
{}
|
||||
|
||||
void WindowWrapper::terminate() {}
|
||||
|
||||
void WindowWrapper::setBarrier(bool) {}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/interaction/interactionhandler.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/interaction/interactionhandler.h>
|
||||
#include <openspace/query/query.h>
|
||||
@@ -29,6 +31,7 @@
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/keys.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/interpolator.h>
|
||||
|
||||
@@ -494,7 +497,7 @@ void InteractionHandler::bindKey(Key key, KeyModifier modifier, std::string lua)
|
||||
});
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary InteractionHandler::luaLibrary() {
|
||||
scripting::LuaLibrary InteractionHandler::luaLibrary() {
|
||||
return {
|
||||
"",
|
||||
{
|
||||
@@ -925,8 +928,26 @@ void InteractionHandler::bindKey(Key key, KeyModifier modifier, std::string lua)
|
||||
lua
|
||||
});
|
||||
}
|
||||
|
||||
void InteractionHandler::writeKeyboardDocumentation(const std::string& type, const std::string& file)
|
||||
{
|
||||
if (type == "text") {
|
||||
std::ofstream f(absPath(file));
|
||||
|
||||
for (const auto& p : _keyLua) {
|
||||
f << std::to_string(p.first) << ": " <<
|
||||
p.second << std::endl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw ghoul::RuntimeError(
|
||||
"Unsupported keyboard documentation type '" + type + "'",
|
||||
"InteractionHandler"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary InteractionHandler::luaLibrary() {
|
||||
scripting::LuaLibrary InteractionHandler::luaLibrary() {
|
||||
return{
|
||||
"",
|
||||
{
|
||||
|
||||
@@ -398,7 +398,7 @@ void LuaConsole::toggleVisibility() {
|
||||
_isVisible = !_isVisible;
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary LuaConsole::luaLibrary() {
|
||||
scripting::LuaLibrary LuaConsole::luaLibrary() {
|
||||
return {
|
||||
"console",
|
||||
{
|
||||
|
||||
@@ -1100,7 +1100,7 @@ int ParallelConnection::headerSize(){
|
||||
return 2 * sizeof(uint8_t) + 2 + sizeof(uint32_t);
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary ParallelConnection::luaLibrary() {
|
||||
scripting::LuaLibrary ParallelConnection::luaLibrary() {
|
||||
return {
|
||||
"parallel",
|
||||
{
|
||||
|
||||
@@ -104,8 +104,9 @@ Property* PropertyOwner::property(const std::string& id) const {
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
|
||||
bool PropertyOwner::hasProperty(const std::string& id) const {
|
||||
|
||||
@@ -96,4 +96,31 @@ properties::Property* property(const std::string& uri) {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<properties::Property*> allProperties() {
|
||||
std::vector<properties::Property*> properties;
|
||||
|
||||
auto p = OsEng.globalPropertyOwner().propertiesRecursive();
|
||||
|
||||
properties.insert(
|
||||
properties.end(),
|
||||
p.begin(),
|
||||
p.end()
|
||||
);
|
||||
|
||||
const Scene* graph = sceneGraph();
|
||||
std::vector<SceneGraphNode*> nodes = graph->allSceneGraphNodes();
|
||||
|
||||
for (SceneGraphNode* n : nodes) {
|
||||
auto p = n->propertiesRecursive();
|
||||
properties.insert(
|
||||
properties.end(),
|
||||
p.begin(),
|
||||
p.end()
|
||||
);
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -384,12 +384,10 @@ void RenderEngine::postSynchronizationPreDraw() {
|
||||
|
||||
}
|
||||
|
||||
void RenderEngine::render(const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix, bool showGui) {
|
||||
void RenderEngine::render(const glm::mat4& projectionMatrix, const glm::mat4& viewMatrix){
|
||||
_mainCamera->sgctInternal.setViewMatrix(viewMatrix);
|
||||
_mainCamera->sgctInternal.setProjectionMatrix(projectionMatrix);
|
||||
|
||||
|
||||
|
||||
if (!(OsEng.isMaster() && _disableMasterRendering) && !OsEng.windowWrapper().isGuiWindow()) {
|
||||
_renderer->render(_globalBlackOutFactor, _performanceManager != nullptr);
|
||||
}
|
||||
@@ -399,9 +397,6 @@ void RenderEngine::render(const glm::mat4& projectionMatrix, const glm::mat4& vi
|
||||
if (_showInfo) {
|
||||
renderInformation();
|
||||
}
|
||||
if (_showLog && showGui) {
|
||||
renderScreenLog();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto screenSpaceRenderable : _screenSpaceRenderables) {
|
||||
@@ -410,16 +405,44 @@ void RenderEngine::render(const glm::mat4& projectionMatrix, const glm::mat4& vi
|
||||
}
|
||||
}
|
||||
|
||||
void RenderEngine::renderShutdownInformation(float timer, float fullTime) {
|
||||
timer = timer < 0.f ? 0.f : timer;
|
||||
|
||||
auto size = ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
|
||||
*_fontDate,
|
||||
"Shutdown in: %.2fs/%.2fs",
|
||||
timer,
|
||||
fullTime
|
||||
);
|
||||
|
||||
glm::vec2 penPosition = glm::vec2(
|
||||
OsEng.windowWrapper().viewportPixelCoordinates().y - size.boundingBox.x,
|
||||
OsEng.windowWrapper().viewportPixelCoordinates().w - size.boundingBox.y
|
||||
);
|
||||
penPosition.y -= _fontDate->height();
|
||||
|
||||
RenderFontCr(
|
||||
*_fontDate,
|
||||
penPosition,
|
||||
"Shutdown in: %.2fs/%.2fs",
|
||||
timer,
|
||||
fullTime
|
||||
);
|
||||
}
|
||||
|
||||
void RenderEngine::postDraw() {
|
||||
if (Time::ref().timeJumped())
|
||||
if (Time::ref().timeJumped()) {
|
||||
Time::ref().setTimeJumped(false);
|
||||
}
|
||||
|
||||
if (_takeScreenshot) {
|
||||
OsEng.windowWrapper().takeScreenshot();
|
||||
_takeScreenshot = false;
|
||||
}
|
||||
|
||||
if (_performanceManager)
|
||||
if (_performanceManager) {
|
||||
_performanceManager->storeScenePerformanceMeasurements(scene()->allSceneGraphNodes());
|
||||
}
|
||||
}
|
||||
|
||||
void RenderEngine::takeScreenshot() {
|
||||
@@ -655,7 +678,7 @@ void RenderEngine::setNAaSamples(int nAaSamples) {
|
||||
}
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary RenderEngine::luaLibrary() {
|
||||
scripting::LuaLibrary RenderEngine::luaLibrary() {
|
||||
return {
|
||||
"",
|
||||
{
|
||||
@@ -1202,7 +1225,7 @@ void RenderEngine::renderInformation() {
|
||||
glm::vec2 penPosition = glm::vec2(
|
||||
10.f,
|
||||
OsEng.windowWrapper().viewportPixelCoordinates().w
|
||||
);
|
||||
);
|
||||
penPosition.y -= _fontDate->height();
|
||||
|
||||
RenderFontCr(*_fontDate,
|
||||
@@ -1413,6 +1436,9 @@ void RenderEngine::renderInformation() {
|
||||
}
|
||||
|
||||
void RenderEngine::renderScreenLog() {
|
||||
if (!_showLog)
|
||||
return;
|
||||
|
||||
_log->removeExpiredEntries();
|
||||
|
||||
const int max = 10;
|
||||
|
||||
+35
-5
@@ -87,14 +87,28 @@ bool Scene::deinitialize() {
|
||||
return true;
|
||||
}
|
||||
|
||||
//bool ONCE = false;
|
||||
|
||||
void Scene::update(const UpdateData& data) {
|
||||
if (!_sceneGraphToLoad.empty()) {
|
||||
OsEng.renderEngine().scene()->clearSceneGraph();
|
||||
try {
|
||||
loadSceneInternal(_sceneGraphToLoad);
|
||||
_sceneGraphToLoad = "";
|
||||
|
||||
// After loading the scene, the keyboard bindings have been set
|
||||
|
||||
std::string type;
|
||||
std::string file;
|
||||
bool hasType = OsEng.configurationManager().getValue(
|
||||
ConfigurationManager::KeyKeyboardShortcutsType, type
|
||||
);
|
||||
|
||||
bool hasFile = OsEng.configurationManager().getValue(
|
||||
ConfigurationManager::KeyKeyboardShortcutsFile, file
|
||||
);
|
||||
|
||||
if (hasType && hasFile) {
|
||||
OsEng.interactionHandler().writeKeyboardDocumentation(type, file);
|
||||
}
|
||||
}
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LERROR(e.what());
|
||||
@@ -380,7 +394,7 @@ SceneGraphNode* Scene::sceneGraphNode(const std::string& name) const {
|
||||
return _graph.sceneGraphNode(name);
|
||||
}
|
||||
|
||||
std::vector<SceneGraphNode*> Scene::allSceneGraphNodes() {
|
||||
std::vector<SceneGraphNode*> Scene::allSceneGraphNodes() const {
|
||||
return _graph.nodes();
|
||||
}
|
||||
|
||||
@@ -415,7 +429,7 @@ void Scene::writePropertyDocumentation(const std::string& filename, const std::s
|
||||
LERROR("Undefined type '" << type << "' for Property documentation");
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary Scene::luaLibrary() {
|
||||
scripting::LuaLibrary Scene::luaLibrary() {
|
||||
return {
|
||||
"",
|
||||
{
|
||||
@@ -423,9 +437,25 @@ scripting::ScriptEngine::LuaLibrary Scene::luaLibrary() {
|
||||
"setPropertyValue",
|
||||
&luascriptfunctions::property_setValue,
|
||||
"string, *",
|
||||
"Sets all properties identified by the URI (with potential wildcards) in "
|
||||
"the first argument. The second argument can be any type, but it has to "
|
||||
"match the type that the property (or properties) expect."
|
||||
},
|
||||
{
|
||||
"setPropertyValueRegex",
|
||||
&luascriptfunctions::property_setValueRegex,
|
||||
"Sets all properties that pass the regular expression in the first "
|
||||
"argument. The second argument can be any type, but it has to match the "
|
||||
"type of the properties that matched the regular expression. The regular "
|
||||
"expression has to be of the ECMAScript grammar."
|
||||
},
|
||||
{
|
||||
"setPropertyValueSingle",
|
||||
&luascriptfunctions::property_setValueSingle,
|
||||
"string, *",
|
||||
"Sets a property identified by the URI in "
|
||||
"the first argument. The second argument can be any type, but it has to "
|
||||
" agree with the type that the property expects",
|
||||
"match the type that the property expects.",
|
||||
true
|
||||
},
|
||||
{
|
||||
|
||||
+113
-4
@@ -22,18 +22,58 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <regex>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace {
|
||||
|
||||
void applyRegularExpression(lua_State* L, std::regex regex, std::vector<properties::Property*> properties, int type) {
|
||||
static const std::string _loggerCat = "property_setValue";
|
||||
|
||||
using ghoul::lua::errorLocation;
|
||||
using ghoul::lua::luaTypeToString;
|
||||
|
||||
for (properties::Property* prop : properties) {
|
||||
// Check the regular expression for all properties
|
||||
std::string id = prop->fullyQualifiedIdentifier();
|
||||
if (std::regex_match(id, regex)) {
|
||||
// If the fully qualified id matches the regular expression, we queue the
|
||||
// value change if the types agree
|
||||
|
||||
if (type != prop->typeLua()) {
|
||||
LERROR(errorLocation(L) << "Property '" <<
|
||||
prop->fullyQualifiedIdentifier() <<
|
||||
"' does not accept input of type '" << luaTypeToString(type) <<
|
||||
"'. Requested type: '" << luaTypeToString(prop->typeLua()) << "'");
|
||||
}
|
||||
else {
|
||||
prop->setLuaValue(L);
|
||||
//ensure properties are synced over parallel connection
|
||||
std::string value;
|
||||
prop->getStringValue(value);
|
||||
OsEng.parallelConnection().scriptMessage(
|
||||
prop->fullyQualifiedIdentifier(),
|
||||
value
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace luascriptfunctions {
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* setPropertyValue(string, *):
|
||||
* setPropertyValueSingle(string, *):
|
||||
* Sets the property identified by the URI in the first argument to the value passed to
|
||||
* the second argument. The type of the second argument is arbitrary, but it must agree
|
||||
* with the type the denoted Property expects
|
||||
*/
|
||||
int property_setValue(lua_State* L) {
|
||||
int property_setValueSingle(lua_State* L) {
|
||||
static const std::string _loggerCat = "property_setValue";
|
||||
using ghoul::lua::errorLocation;
|
||||
using ghoul::lua::luaTypeToString;
|
||||
@@ -44,7 +84,7 @@ int property_setValue(lua_State* L) {
|
||||
std::string uri = luaL_checkstring(L, -2);
|
||||
const int type = lua_type(L, -1);
|
||||
|
||||
openspace::properties::Property* prop = property(uri);
|
||||
properties::Property* prop = property(uri);
|
||||
if (!prop) {
|
||||
LERROR(errorLocation(L) << "Property with URI '" << uri << "' was not found");
|
||||
return 0;
|
||||
@@ -57,7 +97,7 @@ int property_setValue(lua_State* L) {
|
||||
"'. Requested type: '" << luaTypeToString(prop->typeLua()) << "'");
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
prop->setLuaValue(L);
|
||||
//ensure properties are synced over parallel connection
|
||||
std::string value;
|
||||
@@ -68,6 +108,75 @@ int property_setValue(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* setPropertyValueRegex(string, *):
|
||||
* Sets all properties that pass the regular expression in the first argument. The second
|
||||
* argument can be any type, but it has to match the type of the properties that matched
|
||||
* the regular expression. The regular expression has to be of the ECMAScript grammar.
|
||||
*/
|
||||
int property_setValueRegex(lua_State* L) {
|
||||
static const std::string _loggerCat = "property_setValueRegex";
|
||||
using ghoul::lua::errorLocation;
|
||||
using ghoul::lua::luaTypeToString;
|
||||
|
||||
int nArguments = lua_gettop(L);
|
||||
SCRIPT_CHECK_ARGUMENTS(L, 2, nArguments);
|
||||
|
||||
std::string regex = luaL_checkstring(L, -2);
|
||||
try {
|
||||
applyRegularExpression(
|
||||
L,
|
||||
std::regex(regex, std::regex_constants::optimize),
|
||||
allProperties(),
|
||||
lua_type(L, -1)
|
||||
);
|
||||
}
|
||||
catch (const std::regex_error& e) {
|
||||
LERROR("Malformed regular expression: '" << regex << "'");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* setPropertyValue(string, *):
|
||||
* Sets all properties identified by the URI (with potential wildcards) in the first
|
||||
* argument. The second argument can be any type, but it has to match the type that the
|
||||
* property (or properties) expect.
|
||||
*/
|
||||
|
||||
int property_setValue(lua_State* L) {
|
||||
static const std::string _loggerCat = "property_setValueRegex";
|
||||
using ghoul::lua::errorLocation;
|
||||
using ghoul::lua::luaTypeToString;
|
||||
|
||||
int nArguments = lua_gettop(L);
|
||||
SCRIPT_CHECK_ARGUMENTS(L, 2, nArguments);
|
||||
|
||||
std::string regex = luaL_checkstring(L, -2);
|
||||
|
||||
// Replace all wildcards * with the correct regex (.*)
|
||||
size_t startPos = regex.find("*");
|
||||
while (startPos != std::string::npos) {
|
||||
regex.replace(startPos, 1, "(.*)");
|
||||
startPos += 4;
|
||||
|
||||
startPos = regex.find("*", startPos);
|
||||
}
|
||||
|
||||
|
||||
applyRegularExpression(
|
||||
L,
|
||||
std::regex(regex/*, std::regex_constants::optimize*/),
|
||||
allProperties(),
|
||||
lua_type(L, -1)
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* getPropertyValue(string):
|
||||
|
||||
@@ -168,9 +168,15 @@ bool SceneGraph::loadFromFile(const std::string& sceneDescription) {
|
||||
LERROR("Specified common folder '" << fullCommonFolder << "' did not exist");
|
||||
else {
|
||||
if (!commonFolder.empty()) {
|
||||
FileSys.registerPathToken(_commonModuleToken, commonFolder);
|
||||
FileSys.registerPathToken(
|
||||
_commonModuleToken, commonFolder,
|
||||
ghoul::filesystem::FileSystem::Override::Yes
|
||||
);
|
||||
size_t nKeys = moduleDictionary.size();
|
||||
moduleDictionary.setValue(std::to_string(nKeys + 1), commonFolder);
|
||||
moduleDictionary.setValue(
|
||||
std::to_string(nKeys + 1),
|
||||
commonFolder
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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/scripting/lualibrary.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace scripting {
|
||||
|
||||
bool LuaLibrary::operator<(const LuaLibrary& rhs) const {
|
||||
return name < rhs.name;
|
||||
}
|
||||
|
||||
} // namespace scripting
|
||||
} // namespace openspace
|
||||
@@ -54,10 +54,6 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
bool ScriptEngine::LuaLibrary::operator<(const LuaLibrary& rhs) const {
|
||||
return name < rhs.name;
|
||||
}
|
||||
|
||||
void ScriptEngine::initialize() {
|
||||
LDEBUG("Adding base library");
|
||||
addBaseLibrary();
|
||||
@@ -208,7 +204,7 @@ bool ScriptEngine::shouldScriptBeSent(const std::string& library, const std::str
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<scripting::ScriptEngine::LuaLibrary::Function>::const_iterator funcit;
|
||||
std::vector<scripting::LuaLibrary::Function>::const_iterator funcit;
|
||||
//library was found
|
||||
if (libit != _registeredLibraries.cend()){
|
||||
for (funcit = libit->functions.cbegin();
|
||||
|
||||
@@ -110,3 +110,39 @@ bool operator<(const KeyWithModifier& lhs, const KeyWithModifier& rhs) {
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
namespace std {
|
||||
|
||||
std::string to_string(openspace::Key key) {
|
||||
for (const auto& p : openspace::KeyMapping) {
|
||||
if (p.second == key)
|
||||
return p.first;
|
||||
}
|
||||
ghoul_assert(false, "Missing key in KeyMapping");
|
||||
}
|
||||
|
||||
std::string to_string(openspace::KeyModifier mod) {
|
||||
using namespace openspace;
|
||||
|
||||
if (mod == KeyModifier::NoModifier)
|
||||
return "";
|
||||
|
||||
std::string result;
|
||||
for (const auto& p : KeyModifierMapping) {
|
||||
if (hasKeyModifier(mod, p.second)) {
|
||||
result += p.first + "+";
|
||||
}
|
||||
}
|
||||
// The last addition has added an additional '+' that we
|
||||
// should remove
|
||||
return result.substr(0, result.size() - 1);
|
||||
}
|
||||
|
||||
std::string to_string(openspace::KeyWithModifier key) {
|
||||
if (key.modifier == openspace::KeyModifier::NoModifier)
|
||||
return to_string(key.key);
|
||||
else
|
||||
return to_string(key.modifier) + "+" + to_string(key.key);
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
@@ -78,6 +78,8 @@ namespace {
|
||||
using fmt::format;
|
||||
using std::string;
|
||||
|
||||
#include "spicemanager_lua.inl"
|
||||
|
||||
namespace openspace {
|
||||
|
||||
|
||||
@@ -1109,6 +1111,28 @@ glm::dmat3 SpiceManager::getEstimatedTransformMatrix(const std::string& fromFram
|
||||
return result;
|
||||
}
|
||||
|
||||
scripting::LuaLibrary SpiceManager::luaLibrary() {
|
||||
return {
|
||||
"spice",
|
||||
{
|
||||
{
|
||||
"loadKernel",
|
||||
&luascriptfunctions::loadKernel,
|
||||
"string",
|
||||
"Loads the provided SPICE kernel by name. The name can contain path "
|
||||
"tokens, which are automatically resolved"
|
||||
},
|
||||
{
|
||||
"unloadKernel",
|
||||
&luascriptfunctions::unloadKernel,
|
||||
"{string, number}",
|
||||
"Unloads the provided SPICE kernel. The name can contain path tokens, "
|
||||
"which are automatically resolved"
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* 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/scripting/script_helper.h>
|
||||
|
||||
namespace openspace {
|
||||
namespace luascriptfunctions {
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* loadKernel(string):
|
||||
* Loads the provided SPICE kernel by name. The name can contain path tokens, which are
|
||||
* automatically resolved.
|
||||
*/
|
||||
|
||||
int loadKernel(lua_State* L) {
|
||||
const std::string _loggerCat = "loadKernel";
|
||||
|
||||
int nArguments = lua_gettop(L);
|
||||
SCRIPT_CHECK_ARGUMENTS(L, 1, nArguments);
|
||||
|
||||
bool isString = (lua_isstring(L, -1) == 1);
|
||||
if (!isString) {
|
||||
LERROR(ghoul::lua::errorLocation(L) << "Expected argument of type 'string'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string argument = lua_tostring(L, -1);
|
||||
unsigned int result = SpiceManager::ref().loadKernel(argument);
|
||||
|
||||
lua_pushnumber(L, result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* unloadKernel({string, number}):
|
||||
* Unloads the provided SPICE kernel. The name can contain path tokens, which are
|
||||
* automatically resolved.
|
||||
*/
|
||||
int unloadKernel(lua_State* L) {
|
||||
const std::string _loggerCat = "loadKernel";
|
||||
|
||||
int nArguments = lua_gettop(L);
|
||||
SCRIPT_CHECK_ARGUMENTS(L, 1, nArguments);
|
||||
|
||||
bool isString = (lua_isstring(L, -1) == 1);
|
||||
bool isNumber = (lua_isnumber(L, -1) == 1);
|
||||
|
||||
if (!isString && !isNumber) {
|
||||
LERROR(
|
||||
ghoul::lua::errorLocation(L) <<
|
||||
"Expected argument of type 'string' or 'number'"
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (isString) {
|
||||
std::string argument = lua_tostring(L, -1);
|
||||
SpiceManager::ref().unloadKernel(argument);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (isNumber) {
|
||||
unsigned int argument = static_cast<unsigned int>(lua_tonumber(L, -1));
|
||||
SpiceManager::ref().unloadKernel(argument);
|
||||
}
|
||||
}
|
||||
|
||||
} // luascriptfunctions
|
||||
} // namespace openspace
|
||||
+2
-3
@@ -240,8 +240,8 @@ bool Time::paused() const {
|
||||
return _timePaused;
|
||||
}
|
||||
|
||||
scripting::ScriptEngine::LuaLibrary Time::luaLibrary() {
|
||||
scripting::ScriptEngine::LuaLibrary timeLibrary = {
|
||||
scripting::LuaLibrary Time::luaLibrary() {
|
||||
return {
|
||||
"time",
|
||||
{
|
||||
{
|
||||
@@ -307,7 +307,6 @@ scripting::ScriptEngine::LuaLibrary Time::luaLibrary() {
|
||||
}
|
||||
}
|
||||
};
|
||||
return timeLibrary;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -363,7 +363,10 @@ function (handle_internal_modules)
|
||||
|
||||
message(STATUS "Included modules:")
|
||||
foreach (module ${sortedModules})
|
||||
message(STATUS "\t${module}")
|
||||
create_option_name(${module} optionName)
|
||||
if (${optionName})
|
||||
message(STATUS "\t${module}")
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
# Add subdirectories in the correct order
|
||||
|
||||
Reference in New Issue
Block a user