This commit is contained in:
Jonathas Costa
2017-12-14 11:23:30 -05:00
111 changed files with 4276 additions and 801 deletions
-57
View File
@@ -1,57 +0,0 @@
function preInitialization()
--[[
The scripts in this function are executed after the scene is loaded but before the
scene elements have been initialized, thus they should be used to set the time at
which the scene should start and other settings that might determine initialization
critical objects.
]]--
openspace.spice.loadKernel("${SPICE}/naif0012.tls")
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
openspace.time.setTime(openspace.time.currentWallTime())
dofile(openspace.absPath('${SCRIPTS}/bind_common_keys.lua'))
end
function postInitialization()
--[[
The scripts in this function are executed after all objects in the scene have been
created and initialized, but before the first render call. This is the place to set
graphical settings for the renderables.
]]--
openspace.set_default_gui_sorting()
openspace.printInfo("Setting default values")
openspace.setPropertyValue("Sun.renderable.Enabled", false)
openspace.setPropertyValue("SunMarker.renderable.Enabled", true)
openspace.setPropertyValue("EarthMarker.renderable.enabled", true)
openspace.setPropertyValue("Constellation Bounds.renderable.Enabled", false)
openspace.setPropertyValue("MilkyWay.renderable.Transparency", 0.55)
openspace.setPropertyValue("MilkyWay.renderable.Segments", 50)
openspace.printInfo("Done setting default values")
if openspace.modules.isLoaded("ISWA") then
openspace.iswa.addCdfFiles("${OPENSPACE_DATA}/cdflist.json");
end
end
return {
ScenePath = ".",
CommonFolder = "common",
Camera = {
Focus = "Earth",
Position = {1, 0, 0},
Rotation = {0.250635, -0.028751, 0.879269, 0.404030},
},
Modules = {
"sun",
"earth",
"stars/digitaluniverse",
-- "stars/denver",
"milkyway/digitaluniverse",
--"milkyway/eso",
}
}
+3 -2
View File
@@ -5,9 +5,10 @@ function preInitialization()
which the scene should start and other settings that might determine initialization
critical objects.
]]--
openspace.set_default_dashboard()
openspace.spice.loadKernel("${SPICE}/naif0012.tls")
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls"))
openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc"))
openspace.time.setTime("2011 AUG 06 00:00:00")
dofile(openspace.absPath('${SCRIPTS}/bind_common_keys.lua'))
+4 -3
View File
@@ -25,9 +25,10 @@ function preInitialization()
which the scene should start and other settings that might determine initialization
critical objects.
]]--
openspace.set_default_dashboard()
openspace.spice.loadKernel("${SPICE}/naif0012.tls")
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls"))
openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc"))
openspace.time.setTime(openspace.time.currentWallTime())
dofile(openspace.absPath('${SCRIPTS}/bind_common_keys.lua'))
@@ -132,7 +133,7 @@ return {
-- "satellites",
"grids",
"digitaluniverse",
-- "digitaluniverse",
"stars/digitaluniverse",
"milkyway/digitaluniverse"
}
+3 -2
View File
@@ -5,9 +5,10 @@ function preInitialization()
which the scene should start and other settings that might determine initialization
critical objects.
]]--
openspace.set_default_dashboard()
openspace.spice.loadKernel("${SPICE}/naif0012.tls")
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls"))
openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc"))
openspace.time.setTime("2015 JAN 01 12:00:00.000")
dofile(openspace.absPath('${SCRIPTS}/bind_common_keys.lua'))
+4 -2
View File
@@ -5,8 +5,10 @@ function preInitialization()
which the scene should start and other settings that might determine initialization
critical objects.
]]--
openspace.spice.loadKernel("${SPICE}/naif0012.tls")
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
openspace.set_default_dashboard()
openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls"))
openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc"))
openspace.time.setTime("2016-07-01T10:05:00.00")
+20 -3
View File
@@ -26,10 +26,27 @@ function preInitialization()
which the scene should start and other settings that might determine initialization
critical objects.
]]--
openspace.set_default_gui_sorting()
openspace.set_default_dashboard()
openspace.spice.loadKernel("${SPICE}/naif0012.tls")
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
openspace.dashboard.addDashboardItem({
Type = "DashboardItemSpacing",
Spacing = 50
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemDistance",
SourceType = "Node",
SourceNodeName = "NewHorizons",
DestinationType = "Node Surface",
DestinationNodeName = "Pluto"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemInstruments"
})
openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls"))
openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc"))
openspace.time.setTime("2015-07-14T08:00:00.00")
+4 -3
View File
@@ -7,9 +7,10 @@ function preInitialization()
which the scene should start and other settings that might determine initialization
critical objects.
]]--
openspace.set_default_dashboard()
openspace.spice.loadKernel("${SPICE}/naif0012.tls")
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls"))
openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc"))
--local startTime = "2019 APR 16 12:03:00.00"
openspace.time.setTime("2016 SEP 8 23:00:00.500")
@@ -72,7 +73,7 @@ function preInitialization()
"Toggles the visibility of the text marking the location of the Earth."
)
openspace.scriptScheduler.loadFile("${OPENSPACE_DATA}/scene/missions/osirisrex/scheduled_scripts.lua")
openspace.scriptScheduler.loadFile(openspace.absPath("${OPENSPACE_DATA}/scene/missions/osirisrex/scheduled_scripts.lua"))
end
function postInitialization()
+3 -2
View File
@@ -5,9 +5,10 @@ function preInitialization()
which the scene should start and other settings that might determine initialization
critical objects.
]]--
openspace.set_default_dashboard()
openspace.spice.loadKernel("${SPICE}/naif0012.tls")
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls"))
openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc"))
-- Usual start
openspace.time.setTime("2014-08-01T03:05:18.101")
+1 -1
View File
@@ -51,7 +51,7 @@ return {
Size = 1.3*10^10.5,
Origin = "Center",
Billboard = true,
Texture = "textures/sun-glare.png",
Texture = "textures/halo.png",
BlendMode = "Additive"
},
Transform = {
+237
View File
@@ -0,0 +1,237 @@
function preInitialization()
--[[
The scripts in this function are executed after the scene is loaded but before the
scene elements have been initialized, thus they should be used to set the time at
which the scene should start and other settings that might determine initialization
critical objects.
]]--
-- dofile(openspace.absPath('${SCRIPTS}/default_setup.lua'))
local TestFontSize1 = 20
local TestFontSize2 = 14
-- DashboardItemDate tests
openspace.dashboard.addDashboardItem({
Type = "DashboardItemDate"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemDate",
FontName = "Console"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemDate",
FontName = "Light",
FontSize = TestFontSize1
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemDate",
FontSize = TestFontSize2
})
-- DashboardItemDistance tests
openspace.dashboard.addDashboardItem({
Type = "DashboardItemDistance"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemDistance",
FontName = "Console",
SourceType = "Node",
SourceNodeName = "Moon"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemDistance",
FontName = "Light",
FontSize = TestFontSize1,
SourceType = "Focus",
DestinationType = "Camera"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemDistance",
FontSize = TestFontSize2,
SourceType = "Focus",
DestinationType = "Node",
DestinationNodeName = "Sun"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemDistance",
SourceType = "Camera",
DestinationType = "Focus"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemDistance",
SourceType = "Camera",
SourceType = "Node",
SourceNodeName = "Saturn",
DestinationType = "Node",
DestinationNodeName = "Sun"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemSpacing",
Spacing = 100
})
-- DashboardItemFramerate
openspace.dashboard.addDashboardItem({
Type = "DashboardItemFramerate"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemFramerate",
FontName = "Light",
FontSize = TestFontSize1,
FrametimeType = "Average Deltatime"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemFramerate",
FontName = "Console",
FrametimeType = "Frames per second"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemFramerate",
FontSize = TestFontSize2,
FrametimeType = "Average frames per second"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemFramerate",
FrametimeType = "None"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemSpacing"
})
-- DashboardItemSimulationIncrement
openspace.dashboard.addDashboardItem({
Type = "DashboardItemSimulationIncrement"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemSimulationIncrement",
FontName = "Light",
FontSize = TestFontSize1,
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemSimulationIncrement",
FontName = "Console"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemSimulationIncrement",
FontSize = TestFontSize2
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemSpacing"
})
-- DashboardItemAngle
openspace.dashboard.addDashboardItem({
Type = "DashboardItemAngle",
ReferenceType = "Node",
ReferenceNodeName = "Moon",
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemAngle",
FontName = "Console",
SourceType = "Node",
SourceNodeName = "Moon",
ReferenceType = "Node",
ReferenceNodeName = "Moon",
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemAngle",
FontName = "Light",
FontSize = TestFontSize1,
SourceType = "Focus",
ReferenceType = "Node",
ReferenceNodeName = "Moon",
DestinationType = "Camera"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemAngle",
FontSize = TestFontSize2,
SourceType = "Focus",
ReferenceType = "Node",
ReferenceNodeName = "Moon",
DestinationType = "Node",
DestinationNodeName = "Sun"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemAngle",
SourceType = "Camera",
ReferenceType = "Node",
ReferenceNodeName = "Moon",
DestinationType = "Focus"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemAngle",
SourceType = "Camera",
SourceType = "Node",
SourceNodeName = "Saturn",
ReferenceType = "Node",
ReferenceNodeName = "Moon",
DestinationType = "Node",
DestinationNodeName = "Sun"
})
openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls"))
openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc"))
openspace.time.setTime("2000 JAN 01")
dofile(openspace.absPath('${SCRIPTS}/bind_common_keys.lua'))
end
function postInitialization()
openspace.printInfo("Setting default values")
openspace.setPropertyValueSingle("Global Properties.GlobeBrowsing.GdalWrapper.LogGdalErrors", false)
openspace.setPropertyValueSingle("Earth.RenderableGlobe.Debug.LevelByProjectedAreaElseDistance", false)
openspace.globebrowsing.goToGeo(58.5877, 16.1924, 20000000)
openspace.printInfo("Done setting default values")
-- Defined in scene_helper.lua
-- Used to create focus buttons for a subset of scenegraph nodes
mark_interesting_nodes({
"Earth"
})
end
return {
ScenePath = ".",
CommonFolder = "common",
Camera = {
Focus = "Earth",
Position = {0, 0, 0},
Rotation = {0.758797, 0.221490, -0.605693, -0.091135},
},
Modules = {
-- # Solar system objects
"sun",
"mercury",
"venus",
"earth",
"moon",
"mars",
"jupiter",
"saturn",
"uranus",
"neptune",
-- "satellites",
-- "grids",
-- "digitaluniverse",
"stars/digitaluniverse",
"milkyway/digitaluniverse",
-- "missions/voyager"
}
}
+3 -2
View File
@@ -5,9 +5,10 @@ function preInitialization()
which the scene should start and other settings that might determine initialization
critical objects.
]]--
openspace.set_default_dashboard()
openspace.spice.loadKernel("${SPICE}/naif0012.tls")
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls"))
openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc"))
openspace.time.setTime(openspace.time.currentWallTime())
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))
+3 -2
View File
@@ -5,9 +5,10 @@ function preInitialization()
which the scene should start and other settings that might determine initialization
critical objects.
]]--
openspace.set_default_dashboard()
openspace.spice.loadKernel("${SPICE}/naif0012.tls")
openspace.spice.loadKernel("${SPICE}/pck00010.tpc")
openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls"))
openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc"))
-- openspace.time.setTime(openspace.time.currentWallTime())
openspace.time.setTime("1977 SEP 10 12:00:00")
@@ -43,6 +43,7 @@ namespace ghoul::fontrendering { class FontManager; }
namespace openspace {
class ConfigurationManager;
class Dashboard;
class DownloadManager;
class GUI;
class LoadingScreen;
@@ -107,6 +108,7 @@ public:
// Guaranteed to return a valid pointer
ConfigurationManager& configurationManager();
LuaConsole& console();
Dashboard& dashboard();
DownloadManager& downloadManager();
ModuleEngine& moduleEngine();
LoadingScreen& loadingScreen();
@@ -183,6 +185,7 @@ private:
// Components
std::unique_ptr<ConfigurationManager> _configurationManager;
std::unique_ptr<SceneManager> _sceneManager;
std::unique_ptr<Dashboard> _dashboard;
std::unique_ptr<DownloadManager> _downloadManager;
std::unique_ptr<LuaConsole> _console;
std::unique_ptr<ModuleEngine> _moduleEngine;
@@ -71,7 +71,7 @@ public:
void removeKeyBinding(const std::string& key);
std::vector<std::pair<KeyWithModifier, KeyInformation>> keyBinding(
const std::string& key) const;
const std::string& key) const;
static scripting::LuaLibrary luaLibrary();
+67
View File
@@ -0,0 +1,67 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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___DASHBOARD___H__
#define __OPENSPACE_CORE___DASHBOARD___H__
#include <openspace/properties/propertyowner.h>
#include <openspace/rendering/dashboarditem.h>
#include <ghoul/glm.h>
#include <memory>
#include <vector>
namespace openspace {
namespace scripting { struct LuaLibrary; }
class DashboardItem;
class Dashboard : public properties::PropertyOwner {
public:
Dashboard();
void render(glm::vec2& penPosition);
void addDashboardItem(std::unique_ptr<DashboardItem> item);
bool hasItem(int index) const;
const DashboardItem& item(int index) const;
void removeDashboardItem(int index);
void removeDashboardItems();
/**
* Returns the Lua library that contains all Lua functions available to affect the
* rendering.
*/
static scripting::LuaLibrary luaLibrary();
private:
std::vector<std::unique_ptr<DashboardItem>> _items;
};
} // openspace
#endif // __OPENSPACE_CORE___DASHBOARD___H__
@@ -0,0 +1,58 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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___DASHBOARDITEM___H__
#define __OPENSPACE_CORE___DASHBOARDITEM___H__
#include <openspace/properties/propertyowner.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <ghoul/glm.h>
#include <ghoul/misc/dictionary.h>
#include <string>
namespace openspace {
class DashboardItem : public properties::PropertyOwner {
public:
static std::unique_ptr<DashboardItem> createFromDictionary(
ghoul::Dictionary dictionary
);
DashboardItem(std::string name);
bool isEnabled() const;
virtual void render(glm::vec2& penPosition) = 0;
virtual glm::vec2 size() const = 0;
protected:
properties::BoolProperty _isEnabled;
};
} // openspace
#endif // __OPENSPACE_CORE___DASHBOARDITEM___H__
@@ -62,13 +62,6 @@ public:
Invalid
};
enum class FrametimeType {
DtTimeAvg = 0,
FPS,
FPSAvg,
None
};
RenderEngine();
~RenderEngine();
@@ -126,8 +119,6 @@ public:
std::string csPath,
const ghoul::Dictionary& dictionary = ghoul::Dictionary());
std::string progressToStr(int size, double t);
void removeRenderProgram(
const std::unique_ptr<ghoul::opengl::ProgramObject>& program);
@@ -179,8 +170,6 @@ private:
void setRenderer(std::unique_ptr<Renderer> renderer);
RendererImplementation rendererFromString(const std::string& method) const;
void renderInformation();
Camera* _camera;
Scene* _scene;
std::unique_ptr<RaycasterManager> _raycasterManager;
@@ -194,12 +183,6 @@ private:
ghoul::Dictionary _resolveData;
ScreenLog* _log;
properties::OptionProperty _frametimeType;
//FrametimeType _frametimeType;
properties::BoolProperty _showDate;
properties::BoolProperty _showInfo;
properties::BoolProperty _showLog;
properties::BoolProperty _showVersionInfo;
properties::BoolProperty _showCameraInfo;
+9
View File
@@ -82,6 +82,15 @@ public:
*/
virtual scripting::LuaLibrary luaLibrary() const;
/**
* Returns the Lua libraries that are defined by objects contained in this
* OpenSpaceModule. Note that the #luaLibrary library is *not* contained in this list
* as this is solely the list of libraries as defined by, for example Renderables,
* defined in the OpenSpaceModule.
* \return A list of libraries defined by items contained in this OpenSpaceModule
*/
virtual std::vector<scripting::LuaLibrary> luaLibraries() const;
/**
* Returns the minimum required OpenGL version of this OpenSpaceModule. Unless
* overwritten, it returns an OpenGL version of <code>3.3</code>.
+16
View File
@@ -25,6 +25,14 @@
include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemangle.h
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemdate.h
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemdistance.h
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemframerate.h
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemmission.h
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemparallelconnection.h
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemsimulationincrement.h
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemspacing.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/modelgeometry.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/multimodelgeometry.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodel.h
@@ -49,6 +57,14 @@ set(HEADER_FILES
source_group("Header Files" FILES ${HEADER_FILES})
set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemangle.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemdate.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemdistance.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemframerate.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemmission.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemparallelconnection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemsimulationincrement.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemspacing.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/modelgeometry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/multimodelgeometry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodel.cpp
+44
View File
@@ -31,6 +31,15 @@
#include <ghoul/misc/assert.h>
#include <modules/base/dashboard/dashboarditemangle.h>
#include <modules/base/dashboard/dashboarditemdate.h>
#include <modules/base/dashboard/dashboarditemdistance.h>
#include <modules/base/dashboard/dashboarditemframerate.h>
#include <modules/base/dashboard/dashboarditemmission.h>
#include <modules/base/dashboard/dashboarditemparallelconnection.h>
#include <modules/base/dashboard/dashboarditemsimulationincrement.h>
#include <modules/base/dashboard/dashboarditemspacing.h>
#include <modules/base/rendering/renderablemodel.h>
#include <modules/base/rendering/renderablesphere.h>
#include <modules/base/rendering/renderablesphericalgrid.h>
@@ -78,6 +87,22 @@ void BaseModule::internalInitialize() {
fSsRenderable->registerClass<ScreenSpaceImageOnline>("ScreenSpaceImageOnline");
fSsRenderable->registerClass<ScreenSpaceFramebuffer>("ScreenSpaceFramebuffer");
auto fDashboard = FactoryManager::ref().factory<DashboardItem>();
ghoul_assert(fDashboard, "Dashboard factory was not created");
fDashboard->registerClass<DashboardItemAngle>("DashboardItemAngle");
fDashboard->registerClass<DashboardItemDate>("DashboardItemDate");
fDashboard->registerClass<DashboardItemDistance>("DashboardItemDistance");
fDashboard->registerClass<DashboardItemFramerate>("DashboardItemFramerate");
fDashboard->registerClass<DashboardItemMission>("DashboardItemMission");
fDashboard->registerClass<DashboardItemParallelConnection>(
"DashboardItemParallelConnection"
);
fDashboard->registerClass<DashboardItemSimulationIncrement>(
"DashboardItemSimulationIncrement"
);
fDashboard->registerClass<DashboardItemSpacing>("DashboardItemSpacing");
auto fRenderable = FactoryManager::ref().factory<Renderable>();
ghoul_assert(fRenderable, "Renderable factory was not created");
@@ -114,24 +139,43 @@ void BaseModule::internalInitialize() {
std::vector<documentation::Documentation> BaseModule::documentations() const {
return {
DashboardItemDate::Documentation(),
DashboardItemDistance::Documentation(),
DashboardItemFramerate::Documentation(),
DashboardItemMission::Documentation(),
DashboardItemParallelConnection::Documentation(),
DashboardItemSimulationIncrement::Documentation(),
DashboardItemSpacing::Documentation(),
RenderableModel::Documentation(),
RenderablePlane::Documentation(),
RenderableSphere::Documentation(),
RenderableTrailOrbit::Documentation(),
RenderableTrailTrajectory::Documentation(),
ScreenSpaceDashboard::Documentation(),
ScreenSpaceFramebuffer::Documentation(),
ScreenSpaceImageLocal::Documentation(),
ScreenSpaceImageOnline::Documentation(),
FixedRotation::Documentation(),
LuaRotation::Documentation(),
StaticRotation::Documentation(),
LuaScale::Documentation(),
StaticScale::Documentation(),
LuaTranslation::Documentation(),
StaticTranslation::Documentation(),
modelgeometry::ModelGeometry::Documentation(),
};
}
std::vector<scripting::LuaLibrary> BaseModule::luaLibraries() const {
return {
ScreenSpaceDashboard::luaLibrary()
};
}
} // namespace openspace
+2
View File
@@ -35,7 +35,9 @@ public:
BaseModule();
virtual ~BaseModule() = default;
std::vector<documentation::Documentation> documentations() const override;
std::vector<scripting::LuaLibrary> luaLibraries() const override;
protected:
void internalInitialize() override;
@@ -0,0 +1,443 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 <modules/base/dashboard/dashboarditemangle.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/interaction/navigationhandler.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scene.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/util/camera.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
namespace {
const char* KeyFontMono = "Mono";
const float DefaultFontSize = 10.f;
static const openspace::properties::Property::PropertyInfo FontNameInfo = {
"FontName",
"Font Name",
"This value is the name of the font that is used. It can either refer to an "
"internal name registered previously, or it can refer to a path that is used."
};
static const openspace::properties::Property::PropertyInfo FontSizeInfo = {
"FontSize",
"Font Size",
"This value determines the size of the font that is used to render the date."
};
static const openspace::properties::Property::PropertyInfo SourceTypeInfo = {
"SourceType",
"Source Type",
"The type of position that is used as the triangle apex used to calculate the "
"angle. The default value is 'Camera'."
};
static const openspace::properties::Property::PropertyInfo SourceNodeNameInfo = {
"SourceNodeName",
"Source Node Name",
"If a scene graph node is selected as type, this value specifies the name of the "
"node that is to be used as the apex of the triangle used to calculate the "
"angle. The computed angle is the incident angle to Source in the triangle ("
"Source, Reference, Destination)."
};
static const openspace::properties::Property::PropertyInfo ReferenceTypeInfo = {
"ReferenceType",
"Reference Type",
"The type of position that is used as the destination of the reference line used "
"to calculate the angle. The computed angle is the incident angle to Source in "
"the triangle (Source, Reference, Destination)."
};
static const openspace::properties::Property::PropertyInfo ReferenceNodeNameInfo = {
"ReferenceNodeName",
"Reference Node Name",
"If a scene graph node is selected as type, this value specifies the name of the "
"node that is to be used as the reference direction to compute the angle."
};
static const openspace::properties::Property::PropertyInfo DestinationTypeInfo = {
"DestinationType",
"Destination Type",
"The type of position that is used as the destination to calculate the angle. "
"The computed angle is the incident angle to Source in the triangle ("
"Source, Reference, Destination). The default value for this is 'Focus'."
};
static const openspace::properties::Property::PropertyInfo DestinationNodeNameInfo = {
"DestinationNodeName",
"Destination Node Name",
"If a scene graph node is selected as type, this value specifies the name of the "
"node that is to be used as the destination for computing the angle."
};
} // namespace
namespace openspace {
documentation::Documentation DashboardItemAngle::Documentation() {
using namespace documentation;
return {
"DashboardItem Angle",
"base_dashboarditem_angle",
{
{
"Type",
new StringEqualVerifier("DashboardItemAngle"),
Optional::No
},
{
FontNameInfo.identifier,
new StringVerifier,
Optional::Yes,
FontNameInfo.description
},
{
FontSizeInfo.identifier,
new IntVerifier,
Optional::Yes,
FontSizeInfo.description
},
{
SourceTypeInfo.identifier,
new StringInListVerifier({
"Node", "Focus", "Camera"
}),
Optional::Yes,
SourceTypeInfo.description
},
{
SourceNodeNameInfo.identifier,
new StringVerifier,
Optional::Yes,
SourceNodeNameInfo.description
},
{
ReferenceTypeInfo.identifier,
new StringInListVerifier({
"Node", "Focus", "Camera"
}),
Optional::No,
ReferenceTypeInfo.description
},
{
ReferenceNodeNameInfo.identifier,
new StringVerifier,
Optional::Yes,
ReferenceNodeNameInfo.description
},
{
DestinationTypeInfo.identifier,
new StringInListVerifier({
"Node", "Focus", "Camera"
}),
Optional::Yes,
DestinationTypeInfo.description
},
{
DestinationNodeNameInfo.identifier,
new StringVerifier,
Optional::Yes,
DestinationNodeNameInfo.description
}
}
};
}
DashboardItemAngle::DashboardItemAngle(ghoul::Dictionary dictionary)
: DashboardItem("Distance")
, _fontName(FontNameInfo, KeyFontMono)
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
, _source{
properties::OptionProperty(
SourceTypeInfo,
properties::OptionProperty::DisplayType::Dropdown
),
properties::StringProperty(SourceNodeNameInfo),
nullptr
}
, _reference{
properties::OptionProperty(
ReferenceTypeInfo,
properties::OptionProperty::DisplayType::Dropdown
),
properties::StringProperty(ReferenceNodeNameInfo),
nullptr
}
, _destination{
properties::OptionProperty(
DestinationTypeInfo,
properties::OptionProperty::DisplayType::Dropdown
),
properties::StringProperty(DestinationNodeNameInfo),
nullptr
}
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemAngle"
);
if (dictionary.hasKey(FontNameInfo.identifier)) {
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
}
if (dictionary.hasKey(FontSizeInfo.identifier)) {
_fontSize = static_cast<float>(
dictionary.value<double>(FontSizeInfo.identifier)
);
}
_fontName.onChange([this]() {
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontName);
_fontSize.onChange([this]() {
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontSize);
_source.type.addOptions({
{ Type::Node, "Node" },
{ Type::Focus, "Focus" },
{ Type::Camera, "Camera" }
});
_source.type.onChange([this]() {
_source.nodeName.setVisibility(
properties::Property::Visibility(_source.type == Type::Node)
);
});
if (dictionary.hasKey(SourceTypeInfo.identifier)) {
std::string value = dictionary.value<std::string>(SourceTypeInfo.identifier);
if (value == "Node") {
_source.type = Type::Node;
}
else if (value == "Focus") {
_source.type = Type::Focus;
}
else {
_source.type = Type::Camera;
}
}
else {
_source.type = Type::Camera;
}
addProperty(_source.type);
_source.nodeName.onChange([this]() {
_source.node = nullptr;
});
if (_source.type == Type::Node) {
if (dictionary.hasKey(SourceNodeNameInfo.identifier)) {
_source.nodeName = dictionary.value<std::string>(
SourceNodeNameInfo.identifier
);
}
else {
LERRORC(
"DashboardItemAngle",
"Node type was selected for source but no node specified"
);
}
}
addProperty(_source.nodeName);
_reference.type.addOptions({
{ Type::Node, "Node" },
{ Type::Focus, "Focus" },
{ Type::Camera, "Camera" }
});
_reference.type.onChange([this]() {
_reference.nodeName.setVisibility(
properties::Property::Visibility(_reference.type == Type::Node)
);
});
std::string value = dictionary.value<std::string>(ReferenceTypeInfo.identifier);
if (value == "Node") {
_reference.type = Type::Node;
}
else if (value == "Focus") {
_reference.type = Type::Focus;
}
else {
_reference.type = Type::Camera;
}
addProperty(_reference.type);
_reference.nodeName.onChange([this]() {
_reference.node = nullptr;
});
if (_reference.type == Type::Node) {
if (dictionary.hasKey(ReferenceNodeNameInfo.identifier)) {
_reference.nodeName = dictionary.value<std::string>(
ReferenceNodeNameInfo.identifier
);
}
else {
LERRORC(
"DashboardItemAngle",
"Node type was selected for reference but no node specified"
);
}
}
addProperty(_source.nodeName);
_destination.type.addOptions({
{ Type::Node, "Node" },
{ Type::Focus, "Focus" },
{ Type::Camera, "Camera" }
});
_destination.type.onChange([this]() {
_destination.nodeName.setVisibility(
properties::Property::Visibility(_source.type == Type::Node)
);
});
if (dictionary.hasKey(DestinationTypeInfo.identifier)) {
std::string value = dictionary.value<std::string>(DestinationTypeInfo.identifier);
if (value == "Node") {
_destination.type = Type::Node;
}
else if (value == "Focus") {
_destination.type = Type::Focus;
}
else {
_destination.type = Type::Camera;
}
}
else {
_destination.type = Type::Focus;
}
addProperty(_destination.type);
_destination.nodeName.onChange([this]() {
_destination.node = nullptr;
});
if (_destination.type == Type::Node) {
if (dictionary.hasKey(DestinationNodeNameInfo.identifier)) {
_destination.nodeName = dictionary.value<std::string>(
DestinationNodeNameInfo.identifier
);
}
else {
LERRORC(
"DashboardItemAngle",
"Node type was selected for destination but no node specified"
);
}
}
addProperty(_destination.nodeName);
_font = OsEng.fontManager().font(_fontName, _fontSize);
}
std::pair<glm::dvec3, std::string> DashboardItemAngle::positionAndLabel(
Component& comp) const
{
if (comp.type == Type::Node) {
if (!comp.node) {
comp.node = OsEng.renderEngine().scene()->sceneGraphNode(
comp.nodeName
);
if (!comp.node) {
LERRORC(
"DashboardItemAngle",
"Could not find node '" + comp.nodeName.value() + "'"
);
return { glm::dvec3(0.0), "Node" };
}
}
}
switch (comp.type) {
case Type::Node:
return { comp.node->worldPosition(), comp.node->name() };
case Type::Focus:
return {
OsEng.navigationHandler().focusNode()->worldPosition(),
"focus"
};
case Type::Camera:
return { OsEng.renderEngine().camera()->positionVec3(), "camera" };
default:
return { glm::dvec3(0.0), "Unknown" };
}
};
void DashboardItemAngle::render(glm::vec2& penPosition) {
std::pair<glm::dvec3, std::string> sourceInfo = positionAndLabel(_source);
std::pair<glm::dvec3, std::string> referenceInfo = positionAndLabel(_reference);
std::pair<glm::dvec3, std::string> destinationInfo = positionAndLabel(_destination);
glm::dvec3 a = referenceInfo.first - sourceInfo.first;
glm::dvec3 b = destinationInfo.first - sourceInfo.first;
if (glm::length(a) == 0.0 || glm::length(b) == 0) {
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
"Could not compute angle at %s between %s and %s",
sourceInfo.second.c_str(),
destinationInfo.second.c_str(),
referenceInfo.second.c_str()
);
}
else {
double angle = glm::degrees(
glm::acos(glm::dot(a, b) / (glm::length(a) * glm::length(b)))
);
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
"Angle at %s between %s and %s: %f degrees",
sourceInfo.second.c_str(),
destinationInfo.second.c_str(),
referenceInfo.second.c_str(),
angle
);
}
}
glm::vec2 DashboardItemAngle::size() const {
double angle = 120;
return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
"Angle: %f %s",
angle
).boundingBox;
}
} // namespace openspace
@@ -0,0 +1,82 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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_MODULE_BASE___DASHBOARDITEMANGLE___H__
#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMANGLE___H__
#include <openspace/rendering/dashboarditem.h>
#include <openspace/properties/optionproperty.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <utility>
namespace ghoul::fontrendering { class Font; }
namespace openspace {
class SceneGraphNode;
namespace documentation { struct Documentation; }
class DashboardItemAngle : public DashboardItem {
public:
DashboardItemAngle(ghoul::Dictionary dictionary);
virtual ~DashboardItemAngle() = default;
void render(glm::vec2& penPosition) override;
glm::vec2 size() const override;
static documentation::Documentation Documentation();
private:
enum Type {
Node = 0,
Focus,
Camera
};
struct Component {
properties::OptionProperty type;
properties::StringProperty nodeName;
SceneGraphNode* node;
};
std::pair<glm::dvec3, std::string> positionAndLabel(Component& mainComp) const;
properties::StringProperty _fontName;
properties::FloatProperty _fontSize;
Component _source;
Component _reference;
Component _destination;
std::shared_ptr<ghoul::fontrendering::Font> _font;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMANGLE___H__
@@ -0,0 +1,132 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 <modules/base/dashboard/dashboarditemdate.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/util/timemanager.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
namespace {
const char* KeyFontMono = "Mono";
const float DefaultFontSize = 15.f;
static const openspace::properties::Property::PropertyInfo FontNameInfo = {
"FontName",
"Font Name",
"This value is the name of the font that is used. It can either refer to an "
"internal name registered previously, or it can refer to a path that is used."
};
static const openspace::properties::Property::PropertyInfo FontSizeInfo = {
"FontSize",
"Font Size",
"This value determines the size of the font that is used to render the date."
};
} // namespace
namespace openspace {
documentation::Documentation DashboardItemDate::Documentation() {
using namespace documentation;
return {
"DashboardItem Date",
"base_dashboarditem_date",
{
{
"Type",
new StringEqualVerifier("DashboardItemDate"),
Optional::No
},
{
FontNameInfo.identifier,
new StringVerifier,
Optional::Yes,
FontNameInfo.description
},
{
FontSizeInfo.identifier,
new IntVerifier,
Optional::Yes,
FontSizeInfo.description
}
}
};
}
DashboardItemDate::DashboardItemDate(ghoul::Dictionary dictionary)
: DashboardItem("Date")
, _fontName(FontNameInfo, KeyFontMono)
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemDate"
);
if (dictionary.hasKey(FontNameInfo.identifier)) {
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
}
_fontName.onChange([this](){
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontName);
if (dictionary.hasKey(FontSizeInfo.identifier)) {
_fontSize = static_cast<float>(
dictionary.value<double>(FontSizeInfo.identifier)
);
}
_fontSize.onChange([this](){
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontSize);
_font = OsEng.fontManager().font(_fontName, _fontSize);
}
void DashboardItemDate::render(glm::vec2& penPosition) {
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
"Date: %s",
OsEng.timeManager().time().UTC().c_str()
);
}
glm::vec2 DashboardItemDate::size() const {
return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
"Date: %s",
OsEng.timeManager().time().UTC().c_str()
).boundingBox;
}
} // namespace openspace
@@ -0,0 +1,61 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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_MODULE_BASE___DASHBOARDITEMDATE___H__
#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMDATE___H__
#include <openspace/rendering/dashboarditem.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
namespace ghoul::fontrendering {
class Font;
} // namespace ghoul::fontrendering
namespace openspace {
namespace documentation { struct Documentation; }
class DashboardItemDate : public DashboardItem {
public:
DashboardItemDate(ghoul::Dictionary dictionary);
~DashboardItemDate() = default;
void render(glm::vec2& penPosition) override;
glm::vec2 size() const override;
static documentation::Documentation Documentation();
private:
properties::StringProperty _fontName;
properties::FloatProperty _fontSize;
std::shared_ptr<ghoul::fontrendering::Font> _font;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMDATE___H__
@@ -0,0 +1,383 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 <modules/base/dashboard/dashboarditemdistance.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/interaction/navigationhandler.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scene.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/util/camera.h>
#include <openspace/util/distanceconversion.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
namespace {
const char* KeyFontMono = "Mono";
const float DefaultFontSize = 10.f;
static const openspace::properties::Property::PropertyInfo FontNameInfo = {
"FontName",
"Font Name",
"This value is the name of the font that is used. It can either refer to an "
"internal name registered previously, or it can refer to a path that is used."
};
static const openspace::properties::Property::PropertyInfo FontSizeInfo = {
"FontSize",
"Font Size",
"This value determines the size of the font that is used to render the date."
};
static const openspace::properties::Property::PropertyInfo SourceTypeInfo = {
"SourceType",
"Source Type",
"The type of position that is used as the source to calculate the distance. The "
"default value is 'Camera'."
};
static const openspace::properties::Property::PropertyInfo SourceNodeNameInfo = {
"SourceNodeName",
"Source Node Name",
"If a scene graph node is selected as type, this value specifies the name of the "
"node that is to be used as the source for computing the distance."
};
static const openspace::properties::Property::PropertyInfo DestinationTypeInfo = {
"DestinationType",
"Destination Type",
"The type of position that is used as the destination to calculate the distance. "
"The default value for this is 'Focus'."
};
static const openspace::properties::Property::PropertyInfo DestinationNodeNameInfo = {
"DestinationNodeName",
"Destination Node Name",
"If a scene graph node is selected as type, this value specifies the name of the "
"node that is to be used as the destination for computing the distance."
};
} // namespace
namespace openspace {
documentation::Documentation DashboardItemDistance::Documentation() {
using namespace documentation;
return {
"DashboardItem Distance",
"base_dashboarditem_distance",
{
{
"Type",
new StringEqualVerifier("DashboardItemDistance"),
Optional::No
},
{
FontNameInfo.identifier,
new StringVerifier,
Optional::Yes,
FontNameInfo.description
},
{
FontSizeInfo.identifier,
new IntVerifier,
Optional::Yes,
FontSizeInfo.description
},
{
SourceTypeInfo.identifier,
new StringInListVerifier({
"Node", "Node Surface", "Focus", "Camera"
}),
Optional::Yes,
SourceTypeInfo.description
},
{
SourceNodeNameInfo.identifier,
new StringVerifier,
Optional::Yes,
SourceNodeNameInfo.description
},
{
DestinationTypeInfo.identifier,
new StringInListVerifier({
"Node", "Node Surface", "Focus", "Camera"
}),
Optional::Yes,
DestinationTypeInfo.description
},
{
DestinationNodeNameInfo.identifier,
new StringVerifier,
Optional::Yes,
DestinationNodeNameInfo.description
}
}
};
}
DashboardItemDistance::DashboardItemDistance(ghoul::Dictionary dictionary)
: DashboardItem("Distance")
, _fontName(FontNameInfo, KeyFontMono)
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
, _source{
properties::OptionProperty(
SourceTypeInfo,
properties::OptionProperty::DisplayType::Dropdown
),
properties::StringProperty(SourceNodeNameInfo),
nullptr
}
, _destination{
properties::OptionProperty(
DestinationTypeInfo,
properties::OptionProperty::DisplayType::Dropdown
),
properties::StringProperty(DestinationNodeNameInfo),
nullptr
}
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemDistance"
);
if (dictionary.hasKey(FontNameInfo.identifier)) {
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
}
if (dictionary.hasKey(FontSizeInfo.identifier)) {
_fontSize = static_cast<float>(
dictionary.value<double>(FontSizeInfo.identifier)
);
}
_fontName.onChange([this]() {
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontName);
_fontSize.onChange([this]() {
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontSize);
_source.type.addOptions({
{ Type::Node, "Node" },
{ Type::NodeSurface, "Node Surface" },
{ Type::Focus, "Focus" },
{ Type::Camera, "Camera" }
});
_source.type.onChange([this]() {
_source.nodeName.setVisibility(
properties::Property::Visibility(
_source.type == Type::Node || _source.type == Type::NodeSurface
)
);
});
if (dictionary.hasKey(SourceTypeInfo.identifier)) {
std::string value = dictionary.value<std::string>(SourceTypeInfo.identifier);
if (value == "Node") {
_source.type = Type::Node;
}
else if (value == "Node Surface") {
_source.type = Type::NodeSurface;
}
else if (value == "Focus") {
_source.type = Type::Focus;
}
else {
_source.type = Type::Camera;
}
}
else {
_source.type = Type::Camera;
}
addProperty(_source.type);
_source.nodeName.onChange([this]() {
_source.node = nullptr;
});
if (_source.type == Type::Node || _source.type == Type::NodeSurface) {
if (dictionary.hasKey(SourceNodeNameInfo.identifier)) {
_source.nodeName = dictionary.value<std::string>(
SourceNodeNameInfo.identifier
);
}
else {
LERRORC(
"DashboardItemDistance",
"Node type was selected for source but no node specified"
);
}
}
addProperty(_source.nodeName);
_destination.type.addOptions({
{ Type::Node, "Node" },
{ Type::NodeSurface, "Node Surface" },
{ Type::Focus, "Focus" },
{ Type::Camera, "Camera" }
});
_destination.type.onChange([this]() {
_destination.nodeName.setVisibility(
properties::Property::Visibility(
_source.type == Type::Node || _source.type == Type::NodeSurface
)
);
});
if (dictionary.hasKey(DestinationTypeInfo.identifier)) {
std::string value = dictionary.value<std::string>(DestinationTypeInfo.identifier);
if (value == "Node") {
_destination.type = Type::Node;
}
else if (value == "Node Surface") {
_destination.type = Type::NodeSurface;
}
else if (value == "Focus") {
_destination.type = Type::Focus;
}
else {
_destination.type = Type::Camera;
}
}
else {
_destination.type = Type::Focus;
}
addProperty(_destination.type);
_destination.nodeName.onChange([this]() {
_destination.node = nullptr;
});
if (_destination.type == Type::Node || _destination.type == Type::NodeSurface) {
if (dictionary.hasKey(DestinationNodeNameInfo.identifier)) {
_destination.nodeName = dictionary.value<std::string>(
DestinationNodeNameInfo.identifier
);
}
else {
LERRORC(
"DashboardItemDistance",
"Node type was selected for destination but no node specified"
);
}
}
addProperty(_destination.nodeName);
_font = OsEng.fontManager().font(_fontName, _fontSize);
}
std::pair<glm::dvec3, std::string> DashboardItemDistance::positionAndLabel(
Component& mainComp,
Component& otherComp) const
{
if (mainComp.type == Type::Node || mainComp.type == Type::NodeSurface) {
if (!mainComp.node) {
mainComp.node = OsEng.renderEngine().scene()->sceneGraphNode(
mainComp.nodeName
);
if (!mainComp.node) {
LERRORC(
"DashboardItemDistance",
"Could not find node '" + mainComp.nodeName.value() + "'"
);
return { glm::dvec3(0.0), "Node" };
}
}
}
switch (mainComp.type) {
case Type::Node:
return { mainComp.node->worldPosition(), mainComp.node->name() };
case Type::NodeSurface:
{
glm::dvec3 otherPos;
if (otherComp.type == Type::NodeSurface) {
// We are only interested in the direction, and we want to prevent
// infinite recursion
otherPos = otherComp.node->worldPosition();
}
else {
otherPos = positionAndLabel(otherComp, mainComp).first;
}
glm::dvec3 thisPos = mainComp.node->worldPosition();
glm::dvec3 dir = glm::normalize(otherPos - thisPos);
glm::dvec3 dirLength = dir * glm::dvec3(mainComp.node->boundingSphere());
return { thisPos + dirLength, "surface of " + mainComp.node->name() };
}
case Type::Focus:
return {
OsEng.navigationHandler().focusNode()->worldPosition(),
"focus"
};
case Type::Camera:
return { OsEng.renderEngine().camera()->positionVec3(), "camera" };
default:
return { glm::dvec3(0.0), "Unknown" };
}
};
void DashboardItemDistance::render(glm::vec2& penPosition) {
std::pair<glm::dvec3, std::string> sourceInfo = positionAndLabel(
_source,
_destination
);
std::pair<glm::dvec3, std::string> destinationInfo = positionAndLabel(
_destination,
_source
);
double distance = glm::length(sourceInfo.first - destinationInfo.first);
std::pair<double, std::string> dist = simplifyDistance(distance);
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
"Distance from %s to %s: %f %s",
sourceInfo.second.c_str(),
destinationInfo.second.c_str(),
dist.first,
dist.second.c_str()
);
}
glm::vec2 DashboardItemDistance::size() const {
double distance = 1e20;
std::pair<double, std::string> dist = simplifyDistance(distance);
return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
"Distance from focus: %f %s",
dist.first,
dist.second.c_str()
).boundingBox;
}
} // namespace openspace
@@ -0,0 +1,85 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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_MODULE_BASE___DASHBOARDITEMDISTANCE___H__
#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMDISTANCE___H__
#include <openspace/rendering/dashboarditem.h>
#include <openspace/properties/optionproperty.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <utility>
namespace ghoul::fontrendering { class Font; }
namespace openspace {
class SceneGraphNode;
namespace documentation { struct Documentation; }
class DashboardItemDistance : public DashboardItem {
public:
DashboardItemDistance(ghoul::Dictionary dictionary);
virtual ~DashboardItemDistance() = default;
void render(glm::vec2& penPosition) override;
glm::vec2 size() const override;
static documentation::Documentation Documentation();
private:
enum Type {
Node = 0,
NodeSurface,
Focus,
Camera
};
struct Component {
properties::OptionProperty type;
properties::StringProperty nodeName;
SceneGraphNode* node;
};
std::pair<glm::dvec3, std::string> positionAndLabel(Component& mainComp,
Component& otherComp) const;
properties::StringProperty _fontName;
properties::FloatProperty _fontSize;
Component _source;
Component _destination;
std::shared_ptr<ghoul::fontrendering::Font> _font;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMDISTANCE___H__
@@ -0,0 +1,220 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 <modules/base/dashboard/dashboarditemframerate.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/engine/wrapper/windowwrapper.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
namespace {
const char* KeyFontMono = "Mono";
const float DefaultFontSize = 10.f;
static const openspace::properties::Property::PropertyInfo FontNameInfo = {
"FontName",
"Font Name",
"This value is the name of the font that is used. It can either refer to an "
"internal name registered previously, or it can refer to a path that is used."
};
static const openspace::properties::Property::PropertyInfo FontSizeInfo = {
"FontSize",
"Font Size",
"This value determines the size of the font that is used to render the date."
};
static const openspace::properties::Property::PropertyInfo FrametimeInfo = {
"FrametimeType",
"Type of the frame time display",
"This value determines the units in which the frame time is displayed."
};
} // namespace
namespace openspace {
documentation::Documentation DashboardItemFramerate::Documentation() {
using namespace documentation;
return {
"DashboardItem Framerate",
"base_dashboarditem_framerate",
{
{
"Type",
new StringEqualVerifier("DashboardItemFramerate"),
Optional::No
},
{
FontNameInfo.identifier,
new StringVerifier,
Optional::Yes,
FontNameInfo.description
},
{
FontSizeInfo.identifier,
new IntVerifier,
Optional::Yes,
FontSizeInfo.description
},
{
FrametimeInfo.identifier,
new StringInListVerifier({
"Average Deltatime", "Frames per second", "Average frames per second",
"None"
}),
Optional::Yes,
FrametimeInfo.description
}
}
};
}
DashboardItemFramerate::DashboardItemFramerate(ghoul::Dictionary dictionary)
: DashboardItem("Framerate")
, _fontName(FontNameInfo, KeyFontMono)
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
, _frametimeType(FrametimeInfo, properties::OptionProperty::DisplayType::Dropdown)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemDate"
);
if (dictionary.hasKey(FontNameInfo.identifier)) {
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
}
_fontName.onChange([this](){
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontName);
if (dictionary.hasKey(FontSizeInfo.identifier)) {
_fontSize = static_cast<float>(
dictionary.value<double>(FontSizeInfo.identifier)
);
}
_fontSize.onChange([this](){
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontSize);
_frametimeType.addOptions({
{ static_cast<int>(FrametimeType::DtTimeAvg), "Average Deltatime" },
{ static_cast<int>(FrametimeType::FPS), "Frames per second" },
{ static_cast<int>(FrametimeType::FPSAvg), "Average frames per second" },
{ static_cast<int>(FrametimeType::None), "None" }
});
if (dictionary.hasKey(FrametimeInfo.identifier)) {
std::string value = dictionary.value<std::string>(FrametimeInfo.identifier);
if (value == "Average Deltatime") {
_frametimeType = static_cast<int>(FrametimeType::DtTimeAvg);
}
else if (value == "Frames per second") {
_frametimeType = static_cast<int>(FrametimeType::FPS);
}
else if (value == "Average frames per second") {
_frametimeType = static_cast<int>(FrametimeType::FPSAvg);
}
else {
_frametimeType = static_cast<int>(FrametimeType::None);
}
}
else {
_frametimeType = static_cast<int>(FrametimeType::FPS);
}
addProperty(_frametimeType);
_font = OsEng.fontManager().font(_fontName, _fontSize);
}
void DashboardItemFramerate::render(glm::vec2& penPosition) {
FrametimeType frametimeType = FrametimeType(_frametimeType.value());
switch (frametimeType) {
case FrametimeType::DtTimeAvg:
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
"Avg. Frametime: %.5f",
OsEng.windowWrapper().averageDeltaTime()
);
break;
case FrametimeType::FPS:
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
"FPS: %3.2f",
1.0 / OsEng.windowWrapper().deltaTime()
);
break;
case FrametimeType::FPSAvg:
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
"Avg. FPS: %3.2f",
1.0 / OsEng.windowWrapper().averageDeltaTime()
);
break;
case FrametimeType::None:
break;
}
}
glm::vec2 DashboardItemFramerate::size() const {
FrametimeType frametimeType = FrametimeType(_frametimeType.value());
switch (frametimeType) {
case FrametimeType::DtTimeAvg:
return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
"Avg. Frametime: %.5f",
OsEng.windowWrapper().averageDeltaTime()
).boundingBox;
case FrametimeType::FPS:
return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
"FPS: %3.2f",
1.0 / OsEng.windowWrapper().deltaTime()
).boundingBox;
case FrametimeType::FPSAvg:
return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
"Avg. FPS: %3.2f",
1.0 / OsEng.windowWrapper().averageDeltaTime()
).boundingBox;
case FrametimeType::None:
return { 0.f, 0.f };
default:
return { 0.f, 0.f };
}
}
} // namespace openspace
@@ -0,0 +1,69 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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___DASHBOARDFRAMERATE___H__
#define __OPENSPACE_CORE___DASHBOARDFRAMERATE___H__
#include <openspace/rendering/dashboarditem.h>
#include <openspace/properties/optionproperty.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <ghoul/misc/dictionary.h>
namespace ghoul::fontrendering {
class Font;
} // namespace ghoul::fontrendering
namespace openspace {
namespace documentation { struct Documentation; }
class DashboardItemFramerate : public DashboardItem {
public:
enum class FrametimeType {
DtTimeAvg = 0,
FPS,
FPSAvg,
None
};
DashboardItemFramerate(ghoul::Dictionary dict);
void render(glm::vec2& penPosition) override;
glm::vec2 size() const override;
static documentation::Documentation Documentation();
private:
properties::StringProperty _fontName;
properties::FloatProperty _fontSize;
properties::OptionProperty _frametimeType;
std::shared_ptr<ghoul::fontrendering::Font> _font;
};
} // openspace
#endif // __OPENSPACE_CORE___DASHBOARDFRAMERATE___H__
@@ -0,0 +1,247 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 <modules/base/dashboard/dashboarditemmission.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/mission/mission.h>
#include <openspace/mission/missionmanager.h>
#include <openspace/util/timemanager.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
#include <stack>
namespace {
const char* KeyFontMono = "Mono";
const float DefaultFontSize = 15.f;
static const openspace::properties::Property::PropertyInfo FontNameInfo = {
"FontName",
"Font Name",
"This value is the name of the font that is used. It can either refer to an "
"internal name registered previously, or it can refer to a path that is used."
};
static const openspace::properties::Property::PropertyInfo FontSizeInfo = {
"FontSize",
"Font Size",
"This value determines the size of the font that is used to render the date."
};
std::string progressToStr(int size, double t) {
std::string progress = "|";
int g = static_cast<int>((t * (size - 1)) + 1);
g = std::max(g, 0);
for (int i = 0; i < g; i++) {
progress.append("-");
}
progress.append(">");
for (int i = 0; i < size - g; i++) {
progress.append(" ");
}
progress.append("|");
return progress;
}
} // namespace
namespace openspace {
documentation::Documentation DashboardItemMission::Documentation() {
using namespace documentation;
return {
"DashboardItem Mission",
"base_dashboarditem_mission",
{
{
"Type",
new StringEqualVerifier("DashboardItemMission"),
Optional::No
},
{
FontNameInfo.identifier,
new StringVerifier,
Optional::Yes,
FontNameInfo.description
},
{
FontSizeInfo.identifier,
new IntVerifier,
Optional::Yes,
FontSizeInfo.description
}
}
};
}
DashboardItemMission::DashboardItemMission(ghoul::Dictionary dictionary)
: DashboardItem("Mission")
, _fontName(FontNameInfo, KeyFontMono)
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemDate"
);
if (dictionary.hasKey(FontNameInfo.identifier)) {
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
}
_fontName.onChange([this](){
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontName);
if (dictionary.hasKey(FontSizeInfo.identifier)) {
_fontSize = static_cast<float>(
dictionary.value<double>(FontSizeInfo.identifier)
);
}
_fontSize.onChange([this](){
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontSize);
_font = OsEng.fontManager().font(_fontName, _fontSize);
}
void DashboardItemMission::render(glm::vec2& penPosition) {
if (MissionManager::ref().hasCurrentMission()) {
double currentTime = OsEng.timeManager().time().j2000Seconds();
const Mission& mission = MissionManager::ref().currentMission();
if (mission.phases().size() > 0) {
static const glm::vec4 nextMissionColor(0.7, 0.3, 0.3, 1);
//static const glm::vec4 missionProgressColor(0.4, 1.0, 1.0, 1);
static const glm::vec4 currentMissionColor(0.0, 0.5, 0.5, 1);
static const glm::vec4 missionProgressColor = currentMissionColor;
// static const glm::vec4 currentLeafMissionColor = missionProgressColor;
static const glm::vec4 nonCurrentMissionColor(0.3, 0.3, 0.3, 1);
// Add spacing
RenderFontCr(*_font, penPosition, nonCurrentMissionColor, " ");
auto phaseTrace = mission.phaseTrace(currentTime);
if (phaseTrace.size()) {
const MissionPhase& phase = phaseTrace.back().get();
std::string title = "Current Mission Phase: " + phase.name();
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
missionProgressColor,
title.c_str()
);
double remaining = phase.timeRange().end - currentTime;
float t = static_cast<float>(
1.0 - remaining / phase.timeRange().duration()
);
std::string progress = progressToStr(25, t);
penPosition.y -= _font->height();
RenderFont(*_font, penPosition, missionProgressColor,
"%.0f s %s %.1f %%", remaining, progress.c_str(), t * 100);
}
else {
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
nextMissionColor,
"Next Mission:"
);
double remaining = mission.timeRange().start - currentTime;
penPosition.y -= _font->height();
RenderFont(*_font, penPosition, nextMissionColor,
"%.0f s", remaining);
}
bool showAllPhases = false;
typedef std::pair<const MissionPhase*, int> PhaseWithDepth;
std::stack<PhaseWithDepth> S;
int pixelIndentation = 20;
S.push({ &mission, 0 });
while (!S.empty()) {
const MissionPhase* phase = S.top().first;
int depth = S.top().second;
S.pop();
bool isCurrentPhase = phase->timeRange().includes(currentTime);
penPosition.x += depth * pixelIndentation;
if (isCurrentPhase) {
double remaining = phase->timeRange().end - currentTime;
float t = static_cast<float>(
1.0 - remaining / phase->timeRange().duration()
);
std::string progress = progressToStr(25, t);
penPosition.y -= _font->height();
RenderFont(*_font, penPosition, currentMissionColor,
"%s %s %.1f %%",
phase->name().c_str(),
progress.c_str(),
t * 100
);
}
else {
if (!phase->name().empty()) {
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
nonCurrentMissionColor,
phase->name().c_str()
);
}
}
penPosition.x -= depth * pixelIndentation;
if (isCurrentPhase || showAllPhases) {
// phases are sorted increasingly by start time, and will be
// popped last-in-first-out from the stack, so add them in
// reversed order.
int indexLastPhase = static_cast<int>(
phase->phases().size()
) - 1;
for (int i = indexLastPhase; 0 <= i; --i) {
S.push({ &phase->phases()[i], depth + 1 });
}
}
}
}
}
}
glm::vec2 DashboardItemMission::size() const {
// @TODO fix this up ---abock
return { 0.f, 0.f };
}
} // namespace openspace
@@ -0,0 +1,61 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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_MODULE_BASE___DASHBOARDITEMMISSION___H__
#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMMISSION___H__
#include <openspace/rendering/dashboarditem.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
namespace ghoul::fontrendering {
class Font;
} // namespace ghoul::fontrendering
namespace openspace {
namespace documentation { struct Documentation; }
class DashboardItemMission : public DashboardItem {
public:
DashboardItemMission(ghoul::Dictionary dictionary);
virtual ~DashboardItemMission() = default;
void render(glm::vec2& penPosition) override;
glm::vec2 size() const override;
static documentation::Documentation Documentation();
private:
properties::StringProperty _fontName;
properties::FloatProperty _fontSize;
std::shared_ptr<ghoul::fontrendering::Font> _font;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMMISSION___H__
@@ -0,0 +1,221 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 <modules/base/dashboard/dashboarditemparallelconnection.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/interaction/navigationhandler.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/util/camera.h>
#include <openspace/util/distanceconversion.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
namespace {
const char* KeyFontMono = "Mono";
const float DefaultFontSize = 10.f;
static const openspace::properties::Property::PropertyInfo FontNameInfo = {
"FontName",
"Font Name",
"This value is the name of the font that is used. It can either refer to an "
"internal name registered previously, or it can refer to a path that is used."
};
static const openspace::properties::Property::PropertyInfo FontSizeInfo = {
"FontSize",
"Font Size",
"This value determines the size of the font that is used to render the date."
};
} // namespace
namespace openspace {
documentation::Documentation DashboardItemParallelConnection::Documentation() {
using namespace documentation;
return {
"DashboardItem Parallel Connection",
"base_dashboarditem_parallelconnection",
{
{
"Type",
new StringEqualVerifier("DashboardItemParallelConnection"),
Optional::No
},
{
FontNameInfo.identifier,
new StringVerifier,
Optional::Yes,
FontNameInfo.description
},
{
FontSizeInfo.identifier,
new IntVerifier,
Optional::Yes,
FontSizeInfo.description
}
}
};
}
DashboardItemParallelConnection::DashboardItemParallelConnection(ghoul::Dictionary dictionary)
: DashboardItem("Parallel Connection")
, _fontName(FontNameInfo, KeyFontMono)
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemDate"
);
if (dictionary.hasKey(FontNameInfo.identifier)) {
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
}
_fontName.onChange([this](){
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontName);
if (dictionary.hasKey(FontSizeInfo.identifier)) {
_fontSize = static_cast<float>(
dictionary.value<double>(FontSizeInfo.identifier)
);
}
_fontSize.onChange([this](){
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontSize);
_font = OsEng.fontManager().font(_fontName, _fontSize);
}
void DashboardItemParallelConnection::render(glm::vec2& penPosition) {
ParallelConnection::Status status = OsEng.parallelConnection().status();
size_t nConnections = OsEng.parallelConnection().nConnections();
const std::string& hostName = OsEng.parallelConnection().hostName();
std::string connectionInfo = "";
int nClients = static_cast<int>(nConnections);
if (status == ParallelConnection::Status::Host) {
nClients--;
if (nClients == 1) {
connectionInfo = "Hosting session with 1 client";
}
else {
connectionInfo =
"Hosting session with " + std::to_string(nClients) + " clients";
}
}
else if (status == ParallelConnection::Status::ClientWithHost) {
nClients--;
connectionInfo = "Session hosted by '" + hostName + "'";
}
else if (status == ParallelConnection::Status::ClientWithoutHost) {
connectionInfo = "Host is disconnected";
}
if (status == ParallelConnection::Status::ClientWithHost ||
status == ParallelConnection::Status::ClientWithoutHost) {
connectionInfo += "\n";
if (nClients > 2) {
std::string c = std::to_string(nClients - 1);
connectionInfo += "You and " + c + " more clients are tuned in";
}
else if (nClients == 2) {
std::string c = std::to_string(nClients - 1);
connectionInfo += "You and " + c + " more client are tuned in";
}
else if (nClients == 1) {
connectionInfo += "You are the only client";
}
}
if (!connectionInfo.empty()) {
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
connectionInfo.c_str()
);
}
}
glm::vec2 DashboardItemParallelConnection::size() const {
ParallelConnection::Status status = OsEng.parallelConnection().status();
size_t nConnections = OsEng.parallelConnection().nConnections();
const std::string& hostName = OsEng.parallelConnection().hostName();
std::string connectionInfo = "";
int nClients = static_cast<int>(nConnections);
if (status == ParallelConnection::Status::Host) {
nClients--;
if (nClients == 1) {
connectionInfo = "Hosting session with 1 client";
}
else {
connectionInfo =
"Hosting session with " + std::to_string(nClients) + " clients";
}
}
else if (status == ParallelConnection::Status::ClientWithHost) {
nClients--;
connectionInfo = "Session hosted by '" + hostName + "'";
}
else if (status == ParallelConnection::Status::ClientWithoutHost) {
connectionInfo = "Host is disconnected";
}
if (status == ParallelConnection::Status::ClientWithHost ||
status == ParallelConnection::Status::ClientWithoutHost) {
connectionInfo += "\n";
if (nClients > 2) {
std::string c = std::to_string(nClients - 1);
connectionInfo += "You and " + c + " more clients are tuned in";
}
else if (nClients == 2) {
std::string c = std::to_string(nClients - 1);
connectionInfo += "You and " + c + " more client are tuned in";
}
else if (nClients == 1) {
connectionInfo += "You are the only client";
}
}
if (!connectionInfo.empty()) {
return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
connectionInfo.c_str()
).boundingBox;
}
else {
return { 0.f, 0.f };
}
}
} // namespace openspace
@@ -0,0 +1,61 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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_MODULE_BASE___DASHBOARDITEMPARALLELCONNECTION___H__
#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMPARALLELCONNECTION___H__
#include <openspace/rendering/dashboarditem.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
namespace ghoul::fontrendering {
class Font;
} // namespace ghoul::fontrendering
namespace openspace {
namespace documentation { struct Documentation; }
class DashboardItemParallelConnection : public DashboardItem {
public:
DashboardItemParallelConnection(ghoul::Dictionary dictionary);
virtual ~DashboardItemParallelConnection() = default;
void render(glm::vec2& penPosition) override;
glm::vec2 size() const override;
static documentation::Documentation Documentation();
private:
properties::StringProperty _fontName;
properties::FloatProperty _fontSize;
std::shared_ptr<ghoul::fontrendering::Font> _font;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMPARALLELCONNECTION___H__
@@ -0,0 +1,141 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 <modules/base/dashboard/dashboarditemsimulationincrement.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/util/timeconversion.h>
#include <openspace/util/timemanager.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
namespace {
const char* KeyFontMono = "Mono";
const float DefaultFontSize = 10.f;
static const openspace::properties::Property::PropertyInfo FontNameInfo = {
"FontName",
"Font Name",
"This value is the name of the font that is used. It can either refer to an "
"internal name registered previously, or it can refer to a path that is used."
};
static const openspace::properties::Property::PropertyInfo FontSizeInfo = {
"FontSize",
"Font Size",
"This value determines the size of the font that is used to render the date."
};
} // namespace
namespace openspace {
documentation::Documentation DashboardItemSimulationIncrement::Documentation() {
using namespace documentation;
return {
"DashboardItem Simulation Increment",
"base_dashboarditem_simulationincrement",
{
{
"Type",
new StringEqualVerifier("DashboardItemSimulationIncrement"),
Optional::No
},
{
FontNameInfo.identifier,
new StringVerifier,
Optional::Yes,
FontNameInfo.description
},
{
FontSizeInfo.identifier,
new IntVerifier,
Optional::Yes,
FontSizeInfo.description
}
}
};
}
DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(ghoul::Dictionary dictionary)
: DashboardItem("Simulation Increment")
, _fontName(FontNameInfo, KeyFontMono)
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemDate"
);
if (dictionary.hasKey(FontNameInfo.identifier)) {
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
}
_fontName.onChange([this](){
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontName);
if (dictionary.hasKey(FontSizeInfo.identifier)) {
_fontSize = static_cast<float>(
dictionary.value<double>(FontSizeInfo.identifier)
);
}
_fontSize.onChange([this](){
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontSize);
_font = OsEng.fontManager().font(_fontName, _fontSize);
}
void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) {
std::pair<double, std::string> deltaTime = simplifyTime(
OsEng.timeManager().time().deltaTime()
);
penPosition.y -= _font->height();
RenderFont(
*_font,
penPosition,
"Simulation increment: %.1f %s / second",
deltaTime.first,
deltaTime.second.c_str()
);
}
glm::vec2 DashboardItemSimulationIncrement::size() const {
std::pair<double, std::string> deltaTime = simplifyTime(
OsEng.timeManager().time().deltaTime()
);
return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
"Simulation increment: %.1f %s / second",
deltaTime.first,
deltaTime.second.c_str()
).boundingBox;
}
} // namespace openspace
@@ -0,0 +1,60 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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_MODULE_BASE___DASHBOARDITEMSIMULATIONINCREMENT___H__
#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMSIMULATIONINCREMENT___H__
#include <openspace/rendering/dashboarditem.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
namespace ghoul::fontrendering {
class Font;
} // namespace ghoul::fontrendering
namespace openspace {
namespace documentation { struct Documentation; }
class DashboardItemSimulationIncrement : public DashboardItem {
public:
DashboardItemSimulationIncrement(ghoul::Dictionary dictionary);
virtual ~DashboardItemSimulationIncrement() = default;
void render(glm::vec2& penPosition) override;
glm::vec2 size() const override;
static documentation::Documentation Documentation();
private:
properties::StringProperty _fontName;
properties::FloatProperty _fontSize;
std::shared_ptr<ghoul::fontrendering::Font> _font;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMSIMULATIONINCREMENT___H__
@@ -0,0 +1,86 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 <modules/base/dashboard/dashboarditemspacing.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
namespace {
static const openspace::properties::Property::PropertyInfo SpacingInfo = {
"Spacing",
"Spacing",
"This value determines the spacing (in pixels) that this item represents. The "
"default value is 15."
};
} // namespace
namespace openspace {
documentation::Documentation DashboardItemSpacing::Documentation() {
using namespace documentation;
return {
"DashboardItem Spacing",
"base_dashboarditem_spacing",
{
{
"Type",
new StringEqualVerifier("DashboardItemSpacing"),
Optional::No
},
{
SpacingInfo.identifier,
new DoubleVerifier,
Optional::Yes,
SpacingInfo.description
}
}
};
}
DashboardItemSpacing::DashboardItemSpacing(ghoul::Dictionary dictionary)
: DashboardItem("Spacing")
, _spacing(SpacingInfo, 15.f, 0.f, 2048.f)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemSpacing"
);
if (dictionary.hasKey(SpacingInfo.identifier)) {
_spacing = static_cast<float>(dictionary.value<double>(SpacingInfo.identifier));
}
addProperty(_spacing);
}
void DashboardItemSpacing::render(glm::vec2& penPosition) {
penPosition.y -= _spacing;
}
glm::vec2 DashboardItemSpacing::size() const {
return { 0.f, _spacing };
}
} // namespace openspace
@@ -0,0 +1,53 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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_MODULE_BASE___DASHBOARDITEMSPACING___H__
#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMSPACING___H__
#include <openspace/rendering/dashboarditem.h>
#include <openspace/properties/scalar/floatproperty.h>
namespace openspace {
namespace documentation { struct Documentation; }
class DashboardItemSpacing : public DashboardItem {
public:
DashboardItemSpacing(ghoul::Dictionary dictionary);
virtual ~DashboardItemSpacing() = default;
void render(glm::vec2& penPosition) override;
glm::vec2 size() const override;
static documentation::Documentation Documentation();
private:
properties::FloatProperty _spacing;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMSPACING___H__
+2 -2
View File
@@ -159,8 +159,8 @@ bool RenderableModel::isReady() const {
void RenderableModel::initializeGL() {
_programObject = OsEng.renderEngine().buildRenderProgram(
"ModelProgram",
"${MODULE_BASE}/shaders/model_vs.glsl",
"${MODULE_BASE}/shaders/model_fs.glsl"
absPath("${MODULE_BASE}/shaders/model_vs.glsl"),
absPath("${MODULE_BASE}/shaders/model_fs.glsl")
);
loadTexture();
+4 -3
View File
@@ -183,9 +183,10 @@ void RenderablePlane::initializeGL() {
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
createPlane();
_shader = OsEng.renderEngine().buildRenderProgram("PlaneProgram",
"${MODULE_BASE}/shaders/plane_vs.glsl",
"${MODULE_BASE}/shaders/plane_fs.glsl"
_shader = OsEng.renderEngine().buildRenderProgram(
"PlaneProgram",
absPath("${MODULE_BASE}/shaders/plane_vs.glsl"),
absPath("${MODULE_BASE}/shaders/plane_fs.glsl")
);
loadTexture();
+5 -3
View File
@@ -227,9 +227,11 @@ void RenderableSphere::initializeGL() {
_sphere->initialize();
// pscstandard
_shader = OsEng.renderEngine().buildRenderProgram("Sphere",
"${MODULE_BASE}/shaders/sphere_vs.glsl",
"${MODULE_BASE}/shaders/sphere_fs.glsl");
_shader = OsEng.renderEngine().buildRenderProgram(
"Sphere",
absPath("${MODULE_BASE}/shaders/sphere_vs.glsl"),
absPath("${MODULE_BASE}/shaders/sphere_fs.glsl")
);
loadTexture();
}
@@ -32,6 +32,7 @@
#include <openspace/documentation/verifier.h>
#include <ghoul/glm.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/opengl/programobject.h>
namespace {
@@ -179,9 +180,9 @@ bool RenderableSphericalGrid::isReady() const {
void RenderableSphericalGrid::initializeGL() {
_gridProgram = OsEng.renderEngine().buildRenderProgram(
"GridProgram",
"${MODULE_BASE}/shaders/grid_vs.glsl",
"${MODULE_BASE}/shaders/grid_fs.glsl"
"GridProgram",
absPath("${MODULE_BASE}/shaders/grid_vs.glsl"),
absPath("${MODULE_BASE}/shaders/grid_fs.glsl")
);
glGenVertexArrays(1, &_vaoID);
+3 -2
View File
@@ -31,6 +31,7 @@
#include <openspace/scene/translation.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/opengl/programobject.h>
namespace {
@@ -221,8 +222,8 @@ void RenderableTrail::initializeGL() {
RenderEngine& renderEngine = OsEng.renderEngine();
_programObject = renderEngine.buildRenderProgram(
"EphemerisProgram",
"${MODULE_BASE}/shaders/renderabletrail_vs.glsl",
"${MODULE_BASE}/shaders/renderabletrail_fs.glsl"
absPath("${MODULE_BASE}/shaders/renderabletrail_vs.glsl"),
absPath("${MODULE_BASE}/shaders/renderabletrail_fs.glsl")
);
setRenderBin(Renderable::RenderBin::Overlay);
+131 -57
View File
@@ -32,21 +32,102 @@
#include <openspace/interaction/navigationhandler.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/util/distanceconversion.h>>
#include <openspace/util/distanceconversion.h>
#include <openspace/util/timeconversion.h>
#include <openspace/util/timemanager.h>
#include <openspace/rendering/dashboard.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
namespace {
const char* KeyName = "Name";
const char* KeyFontMono = "Mono";
static const openspace::properties::Property::PropertyInfo UseMainInfo = {
"UseMainDashboard",
"Use main dashboard",
"If this value is set to 'true', this ScreenSpaceDashboard will use the "
"main dashboard instead of creating an independent one."
};
} // namespace
namespace openspace {
namespace luascriptfunctions {
/**
* \ingroup LuaScripts
* addDashboardItemToScreenSpace(string, table):
*/
int addDashboardItemToScreenSpace(lua_State* L) {
int nArguments = lua_gettop(L);
if (nArguments != 2) {
return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments);
}
std::string name = luaL_checkstring(L, -2);
int type = lua_type(L, -1);
if (type != LUA_TTABLE) {
return luaL_error(L, "Expected argument of type 'table'");
}
else {
ghoul::Dictionary d;
try {
ghoul::lua::luaDictionaryFromState(L, d);
}
catch (const ghoul::lua::LuaFormatException& e) {
LERRORC("addDashboardItem", e.what());
return 0;
}
std::shared_ptr<ScreenSpaceRenderable> ssr =
OsEng.renderEngine().screenSpaceRenderable(name);
if (!ssr) {
return luaL_error(L, "Provided name is not a ScreenSpace item");
}
ScreenSpaceDashboard* dash = dynamic_cast<ScreenSpaceDashboard*>(ssr.get());
if (!dash) {
return luaL_error(L, "Provided name is a ScreenSpace item but not a dashboard");
}
dash->dashboard().addDashboardItem(DashboardItem::createFromDictionary(d));
return 0;
}
}
/**
* \ingroup LuaScripts
* removeDashboardItemsFromScreenSpace(string):
*/
int removeDashboardItemsFromScreenSpace(lua_State* L) {
int nArguments = lua_gettop(L);
if (nArguments != 1) {
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
}
std::string name = luaL_checkstring(L, -1);
std::shared_ptr<ScreenSpaceRenderable> ssr =
OsEng.renderEngine().screenSpaceRenderable(name);
if (!ssr) {
return luaL_error(L, "Provided name is not a ScreenSpace item");
}
ScreenSpaceDashboard* dash = dynamic_cast<ScreenSpaceDashboard*>(ssr.get());
if (!dash) {
return luaL_error(L, "Provided name is a ScreenSpace item but not a dashboard");
}
dash->dashboard().removeDashboardItems();
return 0;
}
} // namespace luascriptfunctions
documentation::Documentation ScreenSpaceDashboard::Documentation() {
using namespace openspace::documentation;
return {
@@ -58,6 +139,12 @@ documentation::Documentation ScreenSpaceDashboard::Documentation() {
new StringVerifier,
Optional::Yes,
"Specifies the GUI name of the ScreenSpaceDashboard"
},
{
UseMainInfo.identifier,
new BoolVerifier,
Optional::Yes,
UseMainInfo.description
}
}
};
@@ -65,9 +152,7 @@ documentation::Documentation ScreenSpaceDashboard::Documentation() {
ScreenSpaceDashboard::ScreenSpaceDashboard(const ghoul::Dictionary& dictionary)
: ScreenSpaceFramebuffer(dictionary)
, _fontRenderer(nullptr)
, _fontDate(nullptr)
, _fontInfo(nullptr)
, _useMainDashboard(UseMainInfo, false)
{
documentation::testSpecificationAndThrow(
Documentation(),
@@ -89,12 +174,13 @@ ScreenSpaceDashboard::ScreenSpaceDashboard(const ghoul::Dictionary& dictionary)
++id;
}
if (dictionary.hasKey(UseMainInfo.identifier)) {
_useMainDashboard = dictionary.value<bool>(UseMainInfo.identifier);
}
addProperty(_useMainDashboard);
_scale = 1.f;
_scale.setMaxValue(15.f);
_size.onChange([this]() {
_fontRenderer->setFramebufferSize({ _size.value().z, _size.value().w });
});
}
ScreenSpaceDashboard::~ScreenSpaceDashboard() {}
@@ -102,71 +188,32 @@ ScreenSpaceDashboard::~ScreenSpaceDashboard() {}
bool ScreenSpaceDashboard::initializeGL() {
ScreenSpaceFramebuffer::initializeGL();
_fontRenderer = ghoul::fontrendering::FontRenderer::createDefault();
_fontRenderer->setFramebufferSize({ _size.value().z, _size.value().w });
_fontDate = OsEng.fontManager().font(
KeyFontMono,
48
);
_fontInfo = OsEng.fontManager().font(
KeyFontMono,
32
);
addRenderFunction([this]() {
glm::vec2 penPosition = glm::vec2(
10.f,
_size.value().w
);
penPosition.y -= _fontDate->height();
RenderFontCr(
*_fontDate,
penPosition,
"Date: %s",
OsEng.timeManager().time().UTC().c_str()
);
std::pair<double, std::string> deltaTime = simplifyTime(
OsEng.timeManager().time().deltaTime()
);
RenderFontCr(
*_fontInfo,
penPosition,
"Simulation increment: %.1f %s / second",
deltaTime.first,
deltaTime.second.c_str()
);
double distance = glm::length(
OsEng.renderEngine().camera()->positionVec3() -
OsEng.navigationHandler().focusNode()->worldPosition()
);
std::pair<double, std::string> dist = simplifyDistance(distance);
RenderFontCr(
*_fontInfo,
penPosition,
"Distance from focus: %f %s",
dist.first,
dist.second.c_str()
);
if (_useMainDashboard) {
OsEng.dashboard().render(penPosition);
}
else {
_dashboard.render(penPosition);
}
});
return true;
}
bool ScreenSpaceDashboard::deinitializeGL() {
_fontRenderer = nullptr;
//_fontRenderer = nullptr;
return ScreenSpaceFramebuffer::deinitializeGL();
}
bool ScreenSpaceDashboard::isReady() const {
return (_fontRenderer != nullptr) &&
return /*(_fontRenderer != nullptr) &&
(_fontDate != nullptr) &&
(_fontInfo != nullptr) &&
(_fontInfo != nullptr) &&*/
ScreenSpaceFramebuffer::isReady();
}
@@ -179,4 +226,31 @@ void ScreenSpaceDashboard::update() {
}
}
Dashboard& ScreenSpaceDashboard::dashboard() {
return _dashboard;
}
const Dashboard& ScreenSpaceDashboard::dashboard() const {
return _dashboard;
}
scripting::LuaLibrary ScreenSpaceDashboard::luaLibrary() {
return {
"dashboard",
{
{
"addDashboardItemToScreenSpace",
&luascriptfunctions::addDashboardItemToScreenSpace,
"string, table",
"Adds a new dashboard item to an existing SceenSpaceDashboard."
},
{
"removeDashboardItemsFromScreenSpace",
&luascriptfunctions::removeDashboardItemsFromScreenSpace,
"string",
"Removes all dashboard items from an existing ScreenSpaceDashboard."
}
}
};
}
} // namespace openspace
+14 -3
View File
@@ -27,6 +27,9 @@
#include <modules/base/rendering/screenspaceframebuffer.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/rendering/dashboard.h>
namespace ghoul::fontrendering {
class Font;
class FontRenderer;
@@ -35,6 +38,7 @@ namespace ghoul::fontrendering {
namespace openspace {
namespace documentation { struct Documentation; }
namespace scripting { struct LuaLibrary; }
class ScreenSpaceDashboard: public ScreenSpaceFramebuffer {
public:
@@ -47,13 +51,20 @@ public:
bool isReady() const override;
void update() override;
Dashboard& dashboard();
const Dashboard& dashboard() const;
static scripting::LuaLibrary luaLibrary();
static documentation::Documentation Documentation();
private:
std::unique_ptr<ghoul::fontrendering::FontRenderer> _fontRenderer;
Dashboard _dashboard;
properties::BoolProperty _useMainDashboard;
//std::unique_ptr<ghoul::fontrendering::FontRenderer> _fontRenderer;
std::shared_ptr<ghoul::fontrendering::Font> _fontDate;
std::shared_ptr<ghoul::fontrendering::Font> _fontInfo;
//std::shared_ptr<ghoul::fontrendering::Font> _fontDate;
//std::shared_ptr<ghoul::fontrendering::Font> _fontInfo;
};
} // namespace openspace
@@ -31,6 +31,7 @@
#include <memory>
#include <ostream>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/misc/assert.h>
#include <iostream>
@@ -45,9 +46,9 @@ DebugRenderer* DebugRenderer::_reference = nullptr;
DebugRenderer::DebugRenderer() {
_programObject = OsEng.renderEngine().buildRenderProgram(
"BasicDebugShader",
"${MODULE_DEBUGGING}/rendering/debugshader_vs.glsl",
"${MODULE_DEBUGGING}/rendering/debugshader_fs.glsl"
);
absPath("${MODULE_DEBUGGING}/rendering/debugshader_vs.glsl"),
absPath("${MODULE_DEBUGGING}/rendering/debugshader_fs.glsl")
);
}
DebugRenderer::DebugRenderer(std::unique_ptr<ghoul::opengl::ProgramObject> programObject)
@@ -198,9 +198,9 @@ void RenderableDebugPlane::initializeGL() {
if (!_shader) {
RenderEngine& renderEngine = OsEng.renderEngine();
_shader = renderEngine.buildRenderProgram("PlaneProgram",
"${MODULE_BASE}/shaders/plane_vs.glsl",
"${MODULE_BASE}/shaders/plane_fs.glsl"
);
absPath("${MODULE_BASE}/shaders/plane_vs.glsl"),
absPath("${MODULE_BASE}/shaders/plane_fs.glsl")
);
}
}
@@ -509,10 +509,12 @@ void RenderableBillboardsCloud::initialize() {
void RenderableBillboardsCloud::initializeGL() {
RenderEngine& renderEngine = OsEng.renderEngine();
_program = renderEngine.buildRenderProgram("RenderableBillboardsCloud",
"${MODULE_DIGITALUNIVERSE}/shaders/billboard2_vs.glsl",
"${MODULE_DIGITALUNIVERSE}/shaders/billboard2_fs.glsl",
"${MODULE_DIGITALUNIVERSE}/shaders/billboard2_gs.glsl");
_program = renderEngine.buildRenderProgram(
"RenderableBillboardsCloud",
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard2_vs.glsl"),
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard2_fs.glsl"),
absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard2_gs.glsl")
);
if (_hasPolygon) {
createPolygonTexture();
@@ -391,9 +391,11 @@ bool RenderableDUMeshes::isReady() const {
void RenderableDUMeshes::initializeGL() {
RenderEngine& renderEngine = OsEng.renderEngine();
_program = renderEngine.buildRenderProgram("RenderableDUMeshes",
"${MODULE_DIGITALUNIVERSE}/shaders/dumesh_vs.glsl",
"${MODULE_DIGITALUNIVERSE}/shaders/dumesh_fs.glsl");
_program = renderEngine.buildRenderProgram(
"RenderableDUMeshes",
absPath("${MODULE_DIGITALUNIVERSE}/shaders/dumesh_vs.glsl"),
absPath("${MODULE_DIGITALUNIVERSE}/shaders/dumesh_fs.glsl")
);
bool success = loadData();
if (!success) {
@@ -447,9 +447,11 @@ void RenderablePlanesCloud::initialize() {
void RenderablePlanesCloud::initializeGL() {
RenderEngine& renderEngine = OsEng.renderEngine();
_program = renderEngine.buildRenderProgram("RenderablePlanesCloud",
"${MODULE_DIGITALUNIVERSE}/shaders/plane2_vs.glsl",
"${MODULE_DIGITALUNIVERSE}/shaders/plane2_fs.glsl");
_program = renderEngine.buildRenderProgram(
"RenderablePlanesCloud",
absPath("${MODULE_DIGITALUNIVERSE}/shaders/plane2_vs.glsl"),
absPath("${MODULE_DIGITALUNIVERSE}/shaders/plane2_fs.glsl")
);
createPlanes();
@@ -263,15 +263,18 @@ namespace openspace {
void RenderablePoints::initializeGL() {
RenderEngine& renderEngine = OsEng.renderEngine();
if (_hasSpriteTexture) {
_program = renderEngine.buildRenderProgram("RenderablePoints",
"${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl",
"${MODULE_DIGITALUNIVERSE}/shaders/points_sprite_fs.glsl");
_program = renderEngine.buildRenderProgram(
"RenderablePoints",
absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl"),
absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_sprite_fs.glsl")
);
}
else {
_program = renderEngine.buildRenderProgram("RenderablePoints",
"${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl",
"${MODULE_DIGITALUNIVERSE}/shaders/points_fs.glsl");// ,
//"${MODULE_DIGITALUNIVERSE}/shaders/points_gs.glsl");
_program = renderEngine.buildRenderProgram(
"RenderablePoints",
absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl"),
absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_fs.glsl")
);
}
}
@@ -242,9 +242,9 @@ void RenderableFieldlines::initializeGL() {
_program = OsEng.renderEngine().buildRenderProgram(
"Fieldline",
"${MODULE_FIELDLINES}/shaders/fieldline_vs.glsl",
"${MODULE_FIELDLINES}/shaders/fieldline_fs.glsl",
"${MODULE_FIELDLINES}/shaders/fieldline_gs.glsl"
absPath("${MODULE_FIELDLINES}/shaders/fieldline_vs.glsl"),
absPath("${MODULE_FIELDLINES}/shaders/fieldline_fs.glsl"),
absPath("${MODULE_FIELDLINES}/shaders/fieldline_gs.glsl")
);
}
@@ -266,8 +266,8 @@ void RenderableFieldlinesSequence::initialize() {
// Setup shader program
_shaderProgram = OsEng.renderEngine().buildRenderProgram(
"FieldlinesSequence",
"${MODULE_FIELDLINESSEQUENCE}/shaders/fieldlinessequence_vs.glsl",
"${MODULE_FIELDLINESSEQUENCE}/shaders/fieldlinessequence_fs.glsl"
absPath("${MODULE_FIELDLINESSEQUENCE}/shaders/fieldlinessequence_vs.glsl"),
absPath("${MODULE_FIELDLINESSEQUENCE}/shaders/fieldlinessequence_fs.glsl")
);
if (!_shaderProgram) {
@@ -342,7 +342,12 @@ bool RenderableFieldlinesSequence::extractMandatoryInfoFromDictionary(
[inputFileTypeString](std::string str) {
const size_t extLength = inputFileTypeString.length();
std::string sub = str.substr(str.length() - extLength, extLength);
std::transform(sub.begin(), sub.end(), sub.begin(), ::tolower);
std::transform(
sub.begin(),
sub.end(),
sub.begin(),
[](char c) { return static_cast<char>(::tolower(c)); }
);
return sub != inputFileTypeString;
}), _sourceFiles.end());
// Ensure that there are available and valid source files left
@@ -416,7 +421,12 @@ void RenderableFieldlinesSequence::extractOptionalInfoFromDictionary(
bool RenderableFieldlinesSequence::extractJsonInfoFromDictionary(fls::Model& model) {
std::string modelStr;
if (_dictionary->getValue(KeyJsonSimulationModel, modelStr)) {
std::transform(modelStr.begin(), modelStr.end(), modelStr.begin(), ::tolower);
std::transform(
modelStr.begin(),
modelStr.end(),
modelStr.begin(),
[](char c) { return static_cast<char>(::tolower(c)); }
);
model = fls::stringToModel(modelStr);
} else {
LERROR(_name << ": Must specify '" << KeyJsonSimulationModel << "'");
@@ -28,9 +28,21 @@
#include <modules/fieldlinessequence/util/fieldlinesstate.h>
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
#include <ccmc/Kameleon.h>
#include <ccmc/KameleonInterpolator.h>
#include <modules/kameleon/include/kameleonhelper.h>
#ifdef _MSC_VER
#pragma warning (push)
// Boost throws #pragma warning: there is no warning number '4675'
#pragma warning (disable : 4619)
#endif // _MSC_VER
#include <ccmc/Kameleon.h>
#include <ccmc/KameleonInterpolator.h>
#include <modules/kameleon/include/kameleonhelper.h>
#ifdef _MSC_VER
#pragma warning (pop)
#endif // _MSC_VER
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
#include <ghoul/logging/logmanager.h>
@@ -260,10 +260,12 @@ void RenderableGalaxy::initializeGL() {
RenderEngine& renderEngine = OsEng.renderEngine();
_pointsProgram = renderEngine.buildRenderProgram("Galaxy points",
"${MODULE_GALAXY}/shaders/points.vs",
"${MODULE_GALAXY}/shaders/points.fs",
ghoul::Dictionary());
_pointsProgram = renderEngine.buildRenderProgram(
"Galaxy points",
absPath("${MODULE_GALAXY}/shaders/points.vs"),
absPath("${MODULE_GALAXY}/shaders/points.fs"),
ghoul::Dictionary()
);
_pointsProgram->setIgnoreUniformLocationError(
ghoul::opengl::ProgramObject::IgnoreError::Yes
+1 -1
View File
@@ -267,7 +267,7 @@ void MemoryAwareTileCache::createTileAndPut(ProviderTileKey key,
ghoul_assert(texture->dataOwnership(),
"Texture must have ownership of old data to avoid leaks");
texture->setPixelData(rawTile->imageData, Texture::TakeOwnership::Yes);
size_t expectedDataSize = texture->expectedPixelDataSize();
[[ maybe_unused ]] size_t expectedDataSize = texture->expectedPixelDataSize();
size_t numBytes = rawTile->textureInitData->totalNumBytes();
ghoul_assert(expectedDataSize == numBytes, "Pixel data size is incorrect");
_numTextureBytesAllocatedOnCPU += numBytes - previousExpectedDataSize;
@@ -54,7 +54,19 @@
#ifdef GLOBEBROWSING_USE_GDAL
#include <gdal.h>
#ifdef _MSC_VER
#pragma warning (push)
// CPL throws warning about missing DLL interface
#pragma warning (disable : 4251)
#endif // _MSC_VER
#include <cpl_string.h>
#ifdef _MSC_VER
#pragma warning (pop)
#endif // _MSC_VER
#endif // GLOBEBROWSING_USE_GDAL
#include "globebrowsingmodule_lua.inl"
+4 -2
View File
@@ -31,6 +31,7 @@
#include <openspace/rendering/renderengine.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/opengl/programobject.h>
namespace {
@@ -67,8 +68,9 @@ PointGlobe::~PointGlobe() {
void PointGlobe::initialize() {
_programObject = OsEng.renderEngine().buildRenderProgram(
"PointGlobe",
"${MODULE_GLOBEBROWSING}/shaders/pointglobe_vs.glsl",
"${MODULE_GLOBEBROWSING}/shaders/pointglobe_fs.glsl");
absPath("${MODULE_GLOBEBROWSING}/shaders/pointglobe_vs.glsl"),
absPath("${MODULE_GLOBEBROWSING}/shaders/pointglobe_fs.glsl")
);
glGenVertexArrays(1, &_vaoID);
glGenBuffers(1, &_vertexBufferID);
@@ -33,6 +33,7 @@
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/opengl/programobject.h>
namespace openspace::globebrowsing {
@@ -225,8 +226,8 @@ void LayerShaderManager::recompileShaderProgram(
_programObject = OsEng.renderEngine().buildRenderProgram(
_shaderName,
_vsPath,
_fsPath,
absPath(_vsPath),
absPath(_fsPath),
shaderDictionary
);
@@ -37,12 +37,22 @@
#include <ghoul/misc/assert.h>
#include <ghoul/misc/dictionary.h>
#ifdef _MSC_VER
#pragma warning (push)
// CPL throws warning about missing DLL interface
#pragma warning (disable : 4251)
#endif // _MSC_VER
#include <ogr_featurestyle.h>
#include <ogr_spatialref.h>
#include <cpl_virtualmem.h>
#include <gdal_priv.h>
#ifdef _MSC_VER
#pragma warning (pop)
#endif // _MSC_VER
#include <algorithm>
namespace openspace::globebrowsing {
@@ -361,8 +361,8 @@ PixelRegion::PixelCoordinate RawTileDataReader::geodeticToPixel(
// ref: https://www.wolframalpha.com/input/?i=X+%3D+a0+%2B+a1P+%2B+a2L,
// +Y+%3D+b0+%2B+b1P+%2B+b2L,+solve+for+P+and+L
double Xp = a[0] + P*a[1] + L*a[2];
double Yp = b[0] + P*b[1] + L*b[2];
[[ maybe_unused ]] double Xp = a[0] + P*a[1] + L*a[2];
[[ maybe_unused ]] double Yp = b[0] + P*b[1] + L*b[2];
ghoul_assert(std::abs(X - Xp) < 1e-10, "inverse should yield X as before");
ghoul_assert(std::abs(Y - Yp) < 1e-10, "inverse should yield Y as before");
@@ -25,8 +25,19 @@
#include <modules/globebrowsing/tile/rawtiledatareader/tiledatatype.h>
#ifdef GLOBEBROWSING_USE_GDAL
#ifdef _MSC_VER
#pragma warning (push)
// CPL throws warning about missing DLL interface
#pragma warning (disable : 4251)
#endif // _MSC_VER
#include <ogr_featurestyle.h>
#include <ogr_spatialref.h>
#ifdef _MSC_VER
#pragma warning (pop)
#endif // _MSC_VER
#endif // GLOBEBROWSING_USE_GDAL
#include <ghoul/logging/logmanager.h>
+3 -1
View File
@@ -33,6 +33,7 @@
#include <openspace/interaction/navigationhandler.h>
#include <openspace/interaction/luaconsole.h>
#include <openspace/network/parallelconnection.h>
#include <openspace/rendering/dashboard.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/rendering/screenspacerenderable.h>
#include <openspace/scene/scene.h>
@@ -68,7 +69,8 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
&(OsEng.navigationHandler()),
&(OsEng.renderEngine()),
&(OsEng.parallelConnection()),
&(OsEng.console())
&(OsEng.console()),
&(OsEng.dashboard())
};
return res;
}
+14 -4
View File
@@ -529,8 +529,8 @@ void GUI::deinitialize() {
void GUI::initializeGL() {
_program = ghoul::opengl::ProgramObject::Build(
"GUI",
"${MODULE_IMGUI}/shaders/gui_vs.glsl",
"${MODULE_IMGUI}/shaders/gui_fs.glsl"
absPath("${MODULE_IMGUI}/shaders/gui_vs.glsl"),
absPath("${MODULE_IMGUI}/shaders/gui_fs.glsl")
);
if (!_program) {
return;
@@ -812,7 +812,7 @@ void GUI::render() {
ImGui::SetNextWindowCollapsed(_isCollapsed);
ImGui::Begin("OpenSpace GUI", nullptr);
_isCollapsed = ImGui::IsWindowCollapsed();
bool property = _property.isEnabled();
@@ -893,7 +893,7 @@ void GUI::render() {
addScreenSpaceRenderableOnline(std::string(addImageOnlineBuffer));
}
bool addDashboard = ImGui::Button("Add Dashboard");
bool addDashboard = ImGui::Button("Add New Dashboard");
if (addDashboard) {
OsEng.scriptEngine().queueScript(
"openspace.addScreenSpaceRenderable({ Type = 'ScreenSpaceDashboard' });",
@@ -901,6 +901,16 @@ void GUI::render() {
);
}
bool addDashboardCopy = ImGui::Button("Add Copy of Main Dashboard");
if (addDashboardCopy) {
OsEng.scriptEngine().queueScript(
"openspace.addScreenSpaceRenderable({ "
"Type = 'ScreenSpaceDashboard', UseMainDashboard = true "
"});",
openspace::scripting::ScriptEngine::RemoteScripting::Yes
);
}
ImGui::Checkbox("ImGUI Internals", &_showInternals);
if (_showInternals) {
ImGui::Begin("Style Editor");
+1 -1
View File
@@ -36,7 +36,7 @@ GuiFilePathComponent::GuiFilePathComponent()
void GuiFilePathComponent::render() {
ImGui::SetNextWindowCollapsed(_isCollapsed);
bool v = _isEnabled;
ImGui::Begin("File Path", &v);
_isCollapsed = ImGui::IsWindowCollapsed();
+1 -1
View File
@@ -55,7 +55,7 @@ void GuiIswaComponent::render() {
bool oldIonDataValue = _ionData;
ImGui::SetNextWindowCollapsed(_isCollapsed);
bool e = _isEnabled;
ImGui::Begin("ISWA", &e, WindowSize, 0.5f);
_isEnabled = e;
+1 -1
View File
@@ -102,7 +102,7 @@ void GuiMissionComponent::render() {
bool v = _isEnabled;
ImGui::Begin(name().c_str(), &v, Size, 0.75f);
_isEnabled = v;
_isCollapsed = ImGui::IsWindowCollapsed();
ghoul_assert(
+1 -1
View File
@@ -296,7 +296,7 @@ void renderStringListProperty(Property* prop, const std::string& ownerName,
}
}
script += "}";
executeScript(
p->fullyQualifiedIdentifier(),
std::move(script),
+5 -3
View File
@@ -31,6 +31,7 @@
#include <openspace/util/powerscaledcoordinate.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/opengl/programobject.h>
namespace {
@@ -266,9 +267,10 @@ void IswaCygnet::initializeTime() {
bool IswaCygnet::createShader() {
if (_shader == nullptr) {
RenderEngine& renderEngine = OsEng.renderEngine();
_shader = renderEngine.buildRenderProgram(_programName,
_vsPath,
_fsPath
_shader = renderEngine.buildRenderProgram(
_programName,
absPath(_vsPath),
absPath(_fsPath)
);
if (!_shader) {
return false;
+1 -1
View File
@@ -173,7 +173,7 @@ void DataProcessor::calculateFilterValues(std::vector<int> selectedOptions) {
standardDeviation,
_normValues
);
filterWidth = fabs(0.5-normalizeWithStandardScore(
filterWidth = fabs(0.5f-normalizeWithStandardScore(
filterWidth,
mean,
standardDeviation,
+11
View File
@@ -26,7 +26,18 @@
#include <openspace/util/time.h>
#ifdef _MSC_VER
#pragma warning (push)
// Boost throws #pragma warning: there is no warning number '4675'
#pragma warning (disable : 4619)
#endif // _MSC_VER
#include <ccmc/Kameleon.h>
#ifdef _MSC_VER
#pragma warning (pop)
#endif // _MSC_VER
#include <ghoul/logging/logmanager.h>
@@ -338,7 +338,7 @@ bool RenderableKameleonVolume::cachingEnabled() {
}
void RenderableKameleonVolume::load() {
if (!FileSys.fileExists(_sourcePath)) {
if (!FileSys.fileExists(ghoul::filesystem::File(_sourcePath))) {
LERROR("File " << _sourcePath << " does not exist.");
return;
}
@@ -198,8 +198,8 @@ RenderableConstellationBounds::RenderableConstellationBounds(
void RenderableConstellationBounds::initializeGL() {
_program = OsEng.renderEngine().buildRenderProgram(
"ConstellationBounds",
"${MODULE_SPACE}/shaders/constellationbounds_vs.glsl",
"${MODULE_SPACE}/shaders/constellationbounds_fs.glsl"
absPath("${MODULE_SPACE}/shaders/constellationbounds_vs.glsl"),
absPath("${MODULE_SPACE}/shaders/constellationbounds_fs.glsl")
);
+12 -8
View File
@@ -342,29 +342,33 @@ void RenderablePlanet::initializeGL() {
// shadow program
_programObject = renderEngine.buildRenderProgram(
"shadowNightProgram",
"${MODULE_SPACE}/shaders/shadow_nighttexture_vs.glsl",
"${MODULE_SPACE}/shaders/shadow_nighttexture_fs.glsl");
absPath("${MODULE_SPACE}/shaders/shadow_nighttexture_vs.glsl"),
absPath("${MODULE_SPACE}/shaders/shadow_nighttexture_fs.glsl")
);
}
else if (_programObject == nullptr && _shadowEnabled) {
// shadow program
_programObject = renderEngine.buildRenderProgram(
"shadowProgram",
"${MODULE_SPACE}/shaders/shadow_vs.glsl",
"${MODULE_SPACE}/shaders/shadow_fs.glsl");
absPath("${MODULE_SPACE}/shaders/shadow_vs.glsl"),
absPath("${MODULE_SPACE}/shaders/shadow_fs.glsl")
);
}
else if (_programObject == nullptr && _hasNightTexture) {
// Night texture program
_programObject = renderEngine.buildRenderProgram(
"nightTextureProgram",
"${MODULE_SPACE}/shaders/nighttexture_vs.glsl",
"${MODULE_SPACE}/shaders/nighttexture_fs.glsl");
absPath("${MODULE_SPACE}/shaders/nighttexture_vs.glsl"),
absPath("${MODULE_SPACE}/shaders/nighttexture_fs.glsl")
);
}
else if (_programObject == nullptr) {
// pscstandard
_programObject = renderEngine.buildRenderProgram(
"pscstandard",
"${MODULE_SPACE}/shaders/renderableplanet_vs.glsl",
"${MODULE_SPACE}/shaders/renderableplanet_fs.glsl");
absPath("${MODULE_SPACE}/shaders/renderableplanet_vs.glsl"),
absPath("${MODULE_SPACE}/shaders/renderableplanet_fs.glsl")
);
}
using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError;
_programObject->setIgnoreSubroutineUniformLocationError(IgnoreError::Yes);
+5 -4
View File
@@ -186,10 +186,11 @@ bool RenderableRings::isReady() const {
void RenderableRings::initializeGL() {
if (!_shader) {
RenderEngine& renderEngine = OsEng.renderEngine();
_shader = renderEngine.buildRenderProgram("RingProgram",
"${MODULE_SPACE}/shaders/rings_vs.glsl",
"${MODULE_SPACE}/shaders/rings_fs.glsl"
);
_shader = renderEngine.buildRenderProgram(
"RingProgram",
absPath("${MODULE_SPACE}/shaders/rings_vs.glsl"),
absPath("${MODULE_SPACE}/shaders/rings_fs.glsl")
);
_shader->setIgnoreUniformLocationError(
ghoul::opengl::ProgramObject::IgnoreError::Yes
);
+4 -3
View File
@@ -289,9 +289,10 @@ bool RenderableStars::isReady() const {
void RenderableStars::initializeGL() {
RenderEngine& renderEngine = OsEng.renderEngine();
_program = renderEngine.buildRenderProgram("Star",
"${MODULE_SPACE}/shaders/star_vs.glsl",
"${MODULE_SPACE}/shaders/star_fs.glsl",
"${MODULE_SPACE}/shaders/star_ge.glsl");
absPath("${MODULE_SPACE}/shaders/star_vs.glsl"),
absPath("${MODULE_SPACE}/shaders/star_fs.glsl"),
absPath("${MODULE_SPACE}/shaders/star_ge.glsl")
);
bool success = loadData();
if (!success) {
@@ -147,13 +147,13 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary)
// Due to the specification, we can be sure it is either a Dictionary or a string
if (dictionary.hasValue<std::string>(KeyKernels)) {
std::string kernel = dictionary.value<std::string>(KeyKernels);
loadKernel(kernel);
loadKernel(absPath(kernel));
}
else {
ghoul::Dictionary kernels = dictionary.value<ghoul::Dictionary>(KeyKernels);
for (size_t i = 1; i <= kernels.size(); ++i) {
std::string kernel = kernels.value<std::string>(std::to_string(i));
loadKernel(kernel);
loadKernel(absPath(kernel));
}
}
}
@@ -25,6 +25,7 @@
include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditeminstruments.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablecrawlingline.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefov.h
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplaneprojection.h
@@ -47,6 +48,7 @@ set(HEADER_FILES
source_group("Header Files" FILES ${HEADER_FILES})
set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditeminstruments.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablecrawlingline.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefov.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplaneprojection.cpp
@@ -0,0 +1,498 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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 <modules/spacecraftinstruments/dashboard/dashboarditeminstruments.h>
#include <modules/spacecraftinstruments/util/imagesequencer.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scene.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/timemanager.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
#include <chrono>
namespace {
const char* KeyFontMono = "Mono";
const float DefaultFontSize = 10.f;
static const openspace::properties::Property::PropertyInfo FontNameInfo = {
"FontName",
"Font Name",
"This value is the name of the font that is used. It can either refer to an "
"internal name registered previously, or it can refer to a path that is used."
};
static const openspace::properties::Property::PropertyInfo FontSizeInfo = {
"FontSize",
"Font Size",
"This value determines the size of the font that is used to render the date."
};
static const openspace::properties::Property::PropertyInfo ActiveColorInfo = {
"ActiveColor",
"Active Color",
"This value determines the color that the active instrument is rendered in. "
"Shortly after activation, the used color is mixture of this and the flash color. "
"The default value is (0.6, 1.0, 0.0)."
};
static const openspace::properties::Property::PropertyInfo FlashColorInfo = {
"FlashColor",
"Flash Color",
"This value determines the color that is used shortly after an instrument "
"activation. The default value is (0.9, 1.0, 0.75)"
};
std::string progressToStr(int size, double t) {
std::string progress = "|";
int g = static_cast<int>((t * (size - 1)) + 1);
g = std::max(g, 0);
for (int i = 0; i < g; i++) {
progress.append("-");
}
progress.append(">");
for (int i = 0; i < size - g; i++) {
progress.append(" ");
}
progress.append("|");
return progress;
}
glm::vec2 addToBoundingbox(glm::vec2 lhs, glm::vec2 rhs) {
return {
std::max(lhs.x, rhs.x),
lhs.y + rhs.y
};
}
} // namespace
namespace openspace {
documentation::Documentation DashboardItemInstruments::Documentation() {
using namespace documentation;
return {
"DashboardItem Instruments",
"spacecraftinstruments_dashboarditem_instuments",
{
{
"Type",
new StringEqualVerifier("DashboardItemInstruments"),
Optional::No
},
{
FontNameInfo.identifier,
new StringVerifier,
Optional::Yes,
FontNameInfo.description
},
{
FontSizeInfo.identifier,
new IntVerifier,
Optional::Yes,
FontSizeInfo.description
},
{
ActiveColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
ActiveColorInfo.description
},
{
FlashColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
FlashColorInfo.description
}
}
};
}
DashboardItemInstruments::DashboardItemInstruments(ghoul::Dictionary dictionary)
: DashboardItem("Instruments")
, _fontName(FontNameInfo, KeyFontMono)
, _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f)
, _activeColor(
ActiveColorInfo,
glm::vec3(0.6f, 1.f, 0.f),
glm::vec3(0.f),
glm::vec3(1.f)
)
, _activeFlash(FlashColorInfo,
glm::vec3(0.9f, 1.f, 0.75f),
glm::vec3(0.f),
glm::vec3(1.f)
)
, _font(OsEng.fontManager().font(KeyFontMono, 10))
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemInstruments"
);
if (dictionary.hasKey(FontNameInfo.identifier)) {
_fontName = dictionary.value<std::string>(FontNameInfo.identifier);
}
if (dictionary.hasKey(FontSizeInfo.identifier)) {
_fontSize = static_cast<float>(
dictionary.value<double>(FontSizeInfo.identifier)
);
}
_fontName.onChange([this]() {
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontName);
_fontSize.onChange([this]() {
_font = OsEng.fontManager().font(_fontName, _fontSize);
});
addProperty(_fontSize);
_activeColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_activeColor);
_activeFlash.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_activeFlash);
_font = OsEng.fontManager().font(_fontName, _fontSize);
}
void DashboardItemInstruments::render(glm::vec2& penPosition) {
double currentTime = OsEng.timeManager().time().j2000Seconds();
if (ImageSequencer::ref().isReady()) {
penPosition.y -= 25.f;
glm::vec4 targetColor(0.f, 0.75f, 1.f, 1.f);
double remaining = ImageSequencer::ref().getNextCaptureTime() - currentTime;
float t = static_cast<float>(
1.0 - remaining / ImageSequencer::ref().getIntervalLength()
);
if (remaining > 0) {
RenderFontCr(*_font,
penPosition,
glm::vec4(glm::mix(_activeColor.value(), _activeFlash.value(), t), 1.f),
//active * t + brigther_active,
"Next instrument activity:"
);
const int Size = 25;
int p = std::max(static_cast<int>((t * (Size - 1)) + 1), 0);
RenderFontCr(*_font,
penPosition,
glm::vec4(glm::mix(_activeColor.value(), _activeFlash.value(), t), 1.f),
"%4.0f s |%s>%s| %.1f %%",
remaining,
std::string(p, '-').c_str(),
std::string(Size - p, ' ').c_str(),
t * 100
);
std::string str = SpiceManager::ref().dateFromEphemerisTime(
ImageSequencer::ref().getNextCaptureTime(),
"YYYY MON DD HR:MN:SC"
);
RenderFontCr(*_font,
penPosition,
glm::vec4(_activeColor.value(), 1.f),
"Data acquisition time: %s",
str.c_str()
);
}
std::pair<double, std::string> nextTarget = ImageSequencer::ref().getNextTarget();
std::pair<double, std::string> currentTarget =
ImageSequencer::ref().getCurrentTarget();
if (currentTarget.first > 0.0) {
using namespace std::chrono;
seconds tls = seconds(static_cast<int>(nextTarget.first - currentTime));
hours tlh = duration_cast<hours>(tls);
tls -= tlh;
minutes tlm = duration_cast<minutes>(tls);
tls -= tlm;
RenderFontCr(*_font,
penPosition,
targetColor,
"Next image: [%02i:%02i:%02i]",
tlh.count(), tlm.count(), tls.count()
);
penPosition.y -= _font->height();
std::map<std::string, bool> activeMap =
ImageSequencer::ref().getActiveInstruments();
glm::vec4 firing(0.58 - t, 1 - t, 1 - t, 1);
glm::vec4 notFiring(0.5, 0.5, 0.5, 1);
RenderFontCr(*_font,
penPosition,
glm::vec4(_activeColor.value(), 1.f),
"Active Instruments:"
);
for (auto m : activeMap) {
if (m.second == false) {
RenderFont(*_font,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
"| |"
);
RenderFontCr(*_font,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
" %5s",
m.first.c_str()
);
}
else {
RenderFont(*_font,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
"|"
);
if (m.first == "NH_LORRI") {
RenderFont(*_font,
penPosition,
firing,
" + "
);
}
RenderFont(*_font,
penPosition,
glm::vec4(0.3, 0.3, 0.3, 1),
" |"
);
RenderFontCr(*_font,
penPosition,
glm::vec4(_activeColor.value(), 1.f),
" %5s",
m.first.c_str()
);
}
}
}
}
}
glm::vec2 DashboardItemInstruments::size() const {
glm::vec2 size = { 0.f, 0.f };
//return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
bool hasNewHorizons = OsEng.renderEngine().scene()->sceneGraphNode("NewHorizons");
double currentTime = OsEng.timeManager().time().j2000Seconds();
if (ImageSequencer::ref().isReady()) {
glm::vec4 targetColor(0.f, 0.75f, 1.f, 1.f);
if (hasNewHorizons) {
try {
double lt;
glm::dvec3 p = SpiceManager::ref().targetPosition(
"PLUTO",
"NEW HORIZONS",
"GALACTIC",
{},
currentTime,
lt
);
psc nhPos = PowerScaledCoordinate::CreatePowerScaledCoordinate(
p.x,
p.y,
p.z
);
float a, b;
glm::dvec3 radii;
SpiceManager::ref().getValue("PLUTO", "RADII", radii);
a = static_cast<float>(radii.x);
b = static_cast<float>(radii.y);
float radius = (a + b) / 2.f;
float distToSurf = glm::length(nhPos.vec3()) - radius;
size = addToBoundingbox(
size,
ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
"Distance to Pluto: % .1f (KM)",
distToSurf
).boundingBox
);
}
catch (...) {
// @CLEANUP: This is bad as it will discard all exceptions
// without telling us about it! ---abock
}
}
double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() -
currentTime;
float t = static_cast<float>(
1.0 - remaining / openspace::ImageSequencer::ref().getIntervalLength()
);
std::string str = SpiceManager::ref().dateFromEphemerisTime(
ImageSequencer::ref().getNextCaptureTime(),
"YYYY MON DD HR:MN:SC"
);
if (remaining > 0) {
std::string progress = progressToStr(25, t);
size = addToBoundingbox(
size,
ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
"Next instrument activity:"
).boundingBox
);
size = addToBoundingbox(
size,
ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
"%.0f s %s %.1f %%",
remaining, progress.c_str(), t * 100
).boundingBox
);
size = addToBoundingbox(
size,
ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
"Data acquisition time: %s",
str.c_str()
).boundingBox
);
}
std::pair<double, std::string> nextTarget = ImageSequencer::ref().getNextTarget();
std::pair<double, std::string> currentTarget =
ImageSequencer::ref().getCurrentTarget();
if (currentTarget.first > 0.0) {
int timeleft = static_cast<int>(nextTarget.first - currentTime);
int hour = timeleft / 3600;
int second = timeleft % 3600;
int minute = second / 60;
second = second % 60;
std::string hh, mm, ss;
if (hour < 10)
hh.append("0");
if (minute < 10)
mm.append("0");
if (second < 10)
ss.append("0");
hh.append(std::to_string(hour));
mm.append(std::to_string(minute));
ss.append(std::to_string(second));
size = addToBoundingbox(
size,
ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
"Data acquisition adjacency: [%s:%s:%s]",
hh.c_str(), mm.c_str(), ss.c_str()
).boundingBox
);
size.y += _font->height();
std::map<std::string, bool> activeMap =
ImageSequencer::ref().getActiveInstruments();
glm::vec4 firing(0.58 - t, 1 - t, 1 - t, 1);
glm::vec4 notFiring(0.5, 0.5, 0.5, 1);
size = addToBoundingbox(
size,
ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox(
*_font,
"Active Instruments:"
).boundingBox
);
// @TODO: Fix this up ---abock
//for (auto m : activeMap) {
// if (m.second == false) {
// RenderFont(*_font,
// penPosition,
// glm::vec4(0.3, 0.3, 0.3, 1),
// "| |"
// );
// RenderFontCr(*_font,
// penPosition,
// glm::vec4(0.3, 0.3, 0.3, 1),
// " %5s",
// m.first.c_str()
// );
// }
// else {
// RenderFont(*_font,
// penPosition,
// glm::vec4(0.3, 0.3, 0.3, 1),
// "|"
// );
// if (m.first == "NH_LORRI") {
// RenderFont(*_font,
// penPosition,
// firing,
// " + "
// );
// }
// RenderFont(*_font,
// penPosition,
// glm::vec4(0.3, 0.3, 0.3, 1),
// " |"
// );
// RenderFontCr(*_font,
// penPosition,
// active,
// " %5s",
// m.first.c_str()
// );
// }
//}
}
}
return size;
}
} // namespace openspace
@@ -0,0 +1,64 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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_MODULE_SPACECRAFTINSTRUMENTS___DASHBOARDITEMINSTRUMENTS___H__
#define __OPENSPACE_MODULE_SPACECRAFTINSTRUMENTS___DASHBOARDITEMINSTRUMENTS___H__
#include <openspace/rendering/dashboarditem.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/vector/vec3property.h>
namespace ghoul::fontrendering { class Font; }
namespace openspace {
namespace documentation { struct Documentation; }
class DashboardItemInstruments : public DashboardItem {
public:
DashboardItemInstruments(ghoul::Dictionary dictionary);
~DashboardItemInstruments() = default;
void render(glm::vec2& penPosition) override;
glm::vec2 size() const override;
static documentation::Documentation Documentation();
private:
properties::StringProperty _fontName;
properties::FloatProperty _fontSize;
properties::Vec3Property _activeColor;
properties::Vec3Property _activeFlash;
std::shared_ptr<ghoul::fontrendering::Font> _font;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_SPACECRAFTINSTRUMENTS___DASHBOARDITEMINSTRUMENTS___H__
@@ -32,6 +32,7 @@
#include <openspace/util/spicemanager.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/glm.h>
@@ -139,8 +140,8 @@ void RenderableCrawlingLine::initializeGL() {
RenderEngine& renderEngine = OsEng.renderEngine();
_program = renderEngine.buildRenderProgram(
"RenderableCrawlingLine",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/crawlingline_vs.glsl",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/crawlingline_fs.glsl"
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/crawlingline_vs.glsl"),
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/crawlingline_fs.glsl")
);
glGenVertexArrays(1, &_vao);
@@ -32,6 +32,7 @@
#include <openspace/rendering/renderengine.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/opengl/programobject.h>
#include <glm/gtx/projection.hpp>
@@ -301,8 +302,8 @@ void RenderableFov::initializeGL() {
RenderEngine& renderEngine = OsEng.renderEngine();
_programObject = renderEngine.buildRenderProgram(
"FovProgram",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/fov_vs.glsl",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/fov_fs.glsl"
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/fov_vs.glsl"),
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/fov_fs.glsl")
);
// Fetch information about the specific instrument
@@ -182,21 +182,31 @@ bool RenderableModelProjection::isReady() const {
void RenderableModelProjection::initializeGL() {
RenderEngine& renderEngine = OsEng.renderEngine();
_programObject = renderEngine.buildRenderProgram("ModelShader",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModel_vs.glsl",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModel_fs.glsl");
_programObject = renderEngine.buildRenderProgram(
"ModelShader",
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModel_vs.glsl"),
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModel_fs.glsl")
);
_fboProgramObject = ghoul::opengl::ProgramObject::Build("ProjectionPass",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelProjection_vs.glsl",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelProjection_fs.glsl");
_fboProgramObject = ghoul::opengl::ProgramObject::Build(
"ProjectionPass",
absPath(
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelProjection_vs.glsl"
),
absPath(
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelProjection_fs.glsl"
)
);
_fboProgramObject->setIgnoreUniformLocationError(
ghoul::opengl::ProgramObject::IgnoreError::Yes
);
_depthFboProgramObject = ghoul::opengl::ProgramObject::Build("DepthPass",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelDepth_vs.glsl",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelDepth_fs.glsl");
_depthFboProgramObject = ghoul::opengl::ProgramObject::Build(
"DepthPass",
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelDepth_vs.glsl"),
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelDepth_fs.glsl")
);
loadTextures();
@@ -100,8 +100,8 @@ void RenderablePlaneProjection::initializeGL() {
RenderEngine& renderEngine = OsEng.renderEngine();
_shader = renderEngine.buildRenderProgram(
"Image Plane",
"${MODULE_BASE}/shaders/imageplane_vs.glsl",
"${MODULE_BASE}/shaders/imageplane_fs.glsl"
absPath("${MODULE_BASE}/shaders/imageplane_vs.glsl"),
absPath("${MODULE_BASE}/shaders/imageplane_fs.glsl")
);
setTarget(_defaultTarget);
@@ -226,14 +226,18 @@ RenderablePlanetProjection::~RenderablePlanetProjection() {}
void RenderablePlanetProjection::initializeGL() {
_programObject = OsEng.renderEngine().buildRenderProgram(
"projectiveProgram",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanet_vs.glsl",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanet_fs.glsl"
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanet_vs.glsl"),
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanet_fs.glsl")
);
_fboProgramObject = ghoul::opengl::ProgramObject::Build(
"fboPassProgram",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanetProjection_vs.glsl",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanetProjection_fs.glsl"
absPath(
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanetProjection_vs.glsl"
),
absPath(
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanetProjection_fs.glsl"
)
);
loadTextures();
@@ -31,6 +31,7 @@
#include <openspace/util/spicemanager.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/opengl/programobject.h>
namespace {
@@ -267,8 +268,8 @@ void RenderableShadowCylinder::initializeGL() {
RenderEngine& renderEngine = OsEng.renderEngine();
_shader = renderEngine.buildRenderProgram(
"ShadowCylinderProgram",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/terminatorshadow_vs.glsl",
"${MODULE_SPACECRAFTINSTRUMENTS}/shaders/terminatorshadow_fs.glsl"
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/terminatorshadow_vs.glsl"),
absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/terminatorshadow_fs.glsl")
);
}
@@ -24,6 +24,8 @@
#include <modules/spacecraftinstruments/spacecraftinstrumentsmodule.h>
#include <modules/spacecraftinstruments/dashboard/dashboarditeminstruments.h>
#include <modules/spacecraftinstruments/rendering/renderablecrawlingline.h>
#include <modules/spacecraftinstruments/rendering/renderablefov.h>
#include <modules/spacecraftinstruments/rendering/renderablemodelprojection.h>
@@ -53,6 +55,11 @@ void SpacecraftInstrumentsModule::internalInitialize() {
"Decoder"
);
auto fDashboard = FactoryManager::ref().factory<DashboardItem>();
ghoul_assert(fDashboard, "Dashboard factory was not created");
fDashboard->registerClass<DashboardItemInstruments>("DashboardItemInstruments");
auto fRenderable = FactoryManager::ref().factory<Renderable>();
ghoul_assert(fRenderable, "No renderable factory existed");
@@ -297,11 +297,7 @@ bool HongKangParser::augmentWithSpice(Image& image, std::string spacecraft,
std::vector<std::string> potentialTargets)
{
image.target = "VOID";
// we have (?) to cast to int, unfortunately
// Why? --abock
// because: old comment --m
int exposureTime = image.timeRange.duration();
int exposureTime = static_cast<int>(image.timeRange.duration());
if (exposureTime == 0) {
exposureTime = 1;
}
+2 -2
View File
@@ -1034,11 +1034,11 @@ void TouchInteraction::step(double dt) {
directionToCenter = normalize(-centerToCam);
dvec3 lookUpWhenFacingCenter = globalCamRot *
dvec3(_camera->lookUpVectorCameraSpace());
dmat4 lookAtMat = lookAt(
dmat4 lookAtMatrix = lookAt(
dvec3(0, 0, 0),
directionToCenter,
lookUpWhenFacingCenter);
globalCamRot = normalize(quat_cast(inverse(lookAtMat)));
globalCamRot = normalize(quat_cast(inverse(lookAtMatrix)));
}
{ // Zooming
centerToBoundingSphere = -directionToCenter * boundingSphere;
+4 -3
View File
@@ -94,9 +94,10 @@ bool TouchMarker::initialize() {
glGenBuffers(1, &_vertexPositionBuffer); // generate buffer
try {
_shader = OsEng.renderEngine().buildRenderProgram("MarkerProgram",
"${MODULE_TOUCH}/shaders/marker_vs.glsl",
"${MODULE_TOUCH}/shaders/marker_fs.glsl"
_shader = OsEng.renderEngine().buildRenderProgram(
"MarkerProgram",
absPath("${MODULE_TOUCH}/shaders/marker_vs.glsl"),
absPath("${MODULE_TOUCH}/shaders/marker_fs.glsl")
);
}
catch (const ghoul::opengl::ShaderObject::ShaderCompileError& e) {
+3 -2
View File
@@ -33,6 +33,7 @@ return {
-- Scene = "${SCENE}/newhorizons.scene",
-- Scene = "${SCENE}/rosetta.scene",
-- Scene = "${SCENE}/osirisrex.scene",
-- Scene = "${SCENE}/voyager.scene",
TasksRoot = "${OPENSPACE_DATA}/tasks",
@@ -92,8 +93,8 @@ return {
ShowNodeNames = true,
ShowProgressbar = true
},
CheckOpenGLState = true,
LogEachOpenGLCall = true,
CheckOpenGLState = false,
LogEachOpenGLCall = false,
ShutdownCountdown = 3,
-- OnScreenTextScaling = "framebuffer",
+31 -1
View File
@@ -12,6 +12,14 @@ openspace.documentation = {
Documentation = "This function sets the default GUI sorting for the space " ..
"environment to increasing size, from solar system, through Milky Way, " ..
"Universe and finishing with other elements"
},
{
Name = "set_default_dashboard",
Arguments = "",
Documentation = "This function sets the default values for the dashboard " ..
"consisting of 'DashboardItemDate', 'DashboardItemSimulationIncrement', " ..
"'DashboardItemDistance', 'DashboardItemFramerate', and " ..
"'DashboardItemParallelConnection'."
}
}
@@ -23,6 +31,28 @@ openspace.mark_interesting_nodes = function(nodes)
end
end
openspace.set_default_dashboard = function()
openspace.dashboard.addDashboardItem({
Type = "DashboardItemDate"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemSimulationIncrement"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemDistance"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemFramerate"
})
openspace.dashboard.addDashboardItem({
Type = "DashboardItemParallelConnection"
})
end
openspace.set_default_gui_sorting = function()
openspace.setPropertyValueSingle(
'Global Properties.ImGUI.Main.Properties.Ordering',
@@ -30,4 +60,4 @@ openspace.set_default_gui_sorting = function()
"Solar System", "Milky Way", "Universe", "Other"
}
)
end
end
+5
View File
@@ -120,6 +120,9 @@ set(OPENSPACE_SOURCE
${OPENSPACE_BASE_DIR}/src/properties/vector/vec4property.cpp
${OPENSPACE_BASE_DIR}/src/query/query.cpp
${OPENSPACE_BASE_DIR}/src/rendering/abufferrenderer.cpp
${OPENSPACE_BASE_DIR}/src/rendering/dashboard.cpp
${OPENSPACE_BASE_DIR}/src/rendering/dashboard_lua.inl
${OPENSPACE_BASE_DIR}/src/rendering/dashboarditem.cpp
${OPENSPACE_BASE_DIR}/src/rendering/framebufferrenderer.cpp
${OPENSPACE_BASE_DIR}/src/rendering/loadingscreen.cpp
${OPENSPACE_BASE_DIR}/src/rendering/raycastermanager.cpp
@@ -286,6 +289,8 @@ set(OPENSPACE_HEADER
${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/vec4property.h
${OPENSPACE_BASE_DIR}/include/openspace/query/query.h
${OPENSPACE_BASE_DIR}/include/openspace/rendering/abufferrenderer.h
${OPENSPACE_BASE_DIR}/include/openspace/rendering/dashboard.h
${OPENSPACE_BASE_DIR}/include/openspace/rendering/dashboarditem.h
${OPENSPACE_BASE_DIR}/include/openspace/rendering/framebufferrenderer.h
${OPENSPACE_BASE_DIR}/include/openspace/rendering/loadingscreen.h
${OPENSPACE_BASE_DIR}/include/openspace/rendering/raycasterlistener.h
+8 -7
View File
@@ -34,6 +34,7 @@
#include <openspace/interaction/keybindingmanager.h>
#include <openspace/mission/mission.h>
#include <openspace/mission/missionmanager.h>
#include <openspace/rendering/dashboard.h>
#include <openspace/rendering/renderable.h>
#include <openspace/rendering/screenspacerenderable.h>
#include <openspace/scene/rotation.h>
@@ -51,8 +52,8 @@
namespace openspace {
void registerCoreClasses(documentation::DocumentationEngine& engine) {
engine.addDocumentation(LogFactoryDocumentation());
engine.addDocumentation(ConfigurationManager::Documentation());
engine.addDocumentation(LogFactoryDocumentation());
engine.addDocumentation(Mission::Documentation());
engine.addDocumentation(Renderable::Documentation());
engine.addDocumentation(Rotation::Documentation());
@@ -65,19 +66,19 @@ void registerCoreClasses(documentation::DocumentationEngine& engine) {
}
void registerCoreClasses(scripting::ScriptEngine& engine) {
engine.addLibrary(Dashboard::luaLibrary());
engine.addLibrary(MissionManager::luaLibrary());
engine.addLibrary(ModuleEngine::luaLibrary());
engine.addLibrary(OpenSpaceEngine::luaLibrary());
engine.addLibrary(SpiceManager::luaLibrary());
engine.addLibrary(ParallelConnection::luaLibrary());
engine.addLibrary(RenderEngine::luaLibrary());
engine.addLibrary(SpiceManager::luaLibrary());
engine.addLibrary(Scene::luaLibrary());
engine.addLibrary(Time::luaLibrary());
engine.addLibrary(WindowWrapper::luaLibrary());
engine.addLibrary(interaction::KeyBindingManager::luaLibrary());
engine.addLibrary(interaction::NavigationHandler::luaLibrary());
engine.addLibrary(ParallelConnection::luaLibrary());
engine.addLibrary(ModuleEngine::luaLibrary());
engine.addLibrary(scripting::ScriptScheduler::luaLibrary());
engine.addLibrary(WindowWrapper::luaLibrary());
engine.addLibrary(MissionManager::luaLibrary());
engine.addLibrary(scripting::generalSystemCapabilities());
engine.addLibrary(scripting::openglSystemCapabilities());
}
+1 -2
View File
@@ -157,8 +157,7 @@ void ConfigurationManager::loadFromFile(const string& filename) {
FileSystem::TokenClosingBraces;
// Retrieving the directory in which the configuration file lies
string absolutePath = FileSys.absolutePath(filename);
string basePath = ghoul::filesystem::File(absolutePath).directoryName();
string basePath = ghoul::filesystem::File(filename).directoryName();
FileSys.registerPathToken(basePathToken, basePath);
ghoul::lua::LuaState state;
+21 -4
View File
@@ -41,6 +41,8 @@
#include <openspace/interaction/luaconsole.h>
#include <openspace/network/networkengine.h>
#include <openspace/network/parallelconnection.h>
#include <openspace/rendering/dashboard.h>
#include <openspace/rendering/dashboarditem.h>
#include <openspace/rendering/loadingscreen.h>
#include <openspace/rendering/renderable.h>
#include <openspace/scripting/scriptscheduler.h>
@@ -146,6 +148,7 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName,
std::unique_ptr<WindowWrapper> windowWrapper)
: _configurationManager(new ConfigurationManager)
, _sceneManager(new SceneManager)
, _dashboard(new Dashboard)
, _downloadManager(nullptr)
, _console(new LuaConsole)
, _moduleEngine(new ModuleEngine)
@@ -177,13 +180,14 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName,
{
_navigationHandler->setPropertyOwner(_globalPropertyNamespace.get());
// New property subowners also have to be added to the OnScreenGuiModule callback!
// New property subowners also have to be added to the ImGuiModule callback!
_globalPropertyNamespace->addPropertySubOwner(_navigationHandler.get());
_globalPropertyNamespace->addPropertySubOwner(_settingsEngine.get());
_globalPropertyNamespace->addPropertySubOwner(_renderEngine.get());
_globalPropertyNamespace->addPropertySubOwner(_windowWrapper.get());
_globalPropertyNamespace->addPropertySubOwner(_parallelConnection.get());
_globalPropertyNamespace->addPropertySubOwner(_console.get());
_globalPropertyNamespace->addPropertySubOwner(_dashboard.get());
_versionInformation.versionString.setReadOnly(true);
@@ -212,6 +216,10 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName,
std::make_unique<ghoul::TemplateFactory<Task>>(),
"Task"
);
FactoryManager::ref().addFactory(
std::make_unique<ghoul::TemplateFactory<DashboardItem>>(),
"DashboardItem"
);
SpiceManager::initialize();
TransformationManager::initialize();
@@ -515,6 +523,10 @@ void OpenSpaceEngine::initialize() {
for (OpenSpaceModule* module : _moduleEngine->modules()) {
_scriptEngine->addLibrary(module->luaLibrary());
for (scripting::LuaLibrary& l : module->luaLibraries()) {
_scriptEngine->addLibrary(l);
}
}
// TODO: Maybe move all scenegraph and renderengine stuff to initializeGL
@@ -597,7 +609,7 @@ void OpenSpaceEngine::loadScene(const std::string& scenePath) {
}
bool showNodeNames = true;
std::string kNames =
std::string kNames =
ConfigurationManager::KeyLoadingScreen + "." +
ConfigurationManager::PartShowNodeNames;
@@ -907,12 +919,12 @@ void OpenSpaceEngine::runGlobalCustomizationScripts(const std::string& sceneDesc
if (_configurationManager->hasKey(k)) {
ghoul::Dictionary dict = _configurationManager->value<ghoul::Dictionary>(k);
for (int i = 1; i <= dict.size(); ++i) {
std::string script = dict.value<std::string>(std::to_string(i));
std::string script = absPath(dict.value<std::string>(std::to_string(i)));
if (FileSys.fileExists(script)) {
try {
LINFO("Running global customization script: " << script);
ghoul::lua::runScriptFile(state, absPath(script));
ghoul::lua::runScriptFile(state, script);
} catch (ghoul::RuntimeError& e) {
LERRORC(e.component, e.message);
}
@@ -1627,6 +1639,11 @@ LuaConsole& OpenSpaceEngine::console() {
return *_console;
}
Dashboard& OpenSpaceEngine::dashboard() {
ghoul_assert(_dashboard, "Dashboard must not be nullptr");
return *_dashboard;
}
DownloadManager& OpenSpaceEngine::downloadManager() {
ghoul_assert(_downloadManager, "Download Manager must not be nullptr");
return *_downloadManager;
+2 -2
View File
@@ -223,8 +223,8 @@ void LuaConsole::initialize() {
_program = ghoul::opengl::ProgramObject::Build(
"Console",
"${SHADERS}/luaconsole.vert",
"${SHADERS}/luaconsole.frag"
absPath("${SHADERS}/luaconsole.vert"),
absPath("${SHADERS}/luaconsole.frag")
);
GLfloat data[] = {
+114
View File
@@ -0,0 +1,114 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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/rendering/dashboard.h>
#include <openspace/rendering/dashboarditem.h>
#include <openspace/scripting/scriptengine.h>
#include "dashboard_lua.inl"
namespace openspace {
Dashboard::Dashboard()
: properties::PropertyOwner({ "Dashboard" })
{}
void Dashboard::addDashboardItem(std::unique_ptr<DashboardItem> item) {
std::string originalName = item->name();
int suffix = 1;
while (true) {
auto it = std::find_if(
_items.begin(),
_items.end(),
[&item](const std::unique_ptr<DashboardItem>& i) {
return (i->name() == item->name());
}
);
if (it == _items.end()) {
// We found a unique name
break;
}
else {
item->setName(originalName + " " + std::to_string(suffix));
++suffix;
}
}
addPropertySubOwner(item.get());
_items.push_back(std::move(item));
}
void Dashboard::removeDashboardItem(int index) {
ghoul_assert(index < _items.size(), "Invalid index");
removePropertySubOwner(_items[index].get());
_items.erase(_items.begin() + index);
}
bool Dashboard::hasItem(int index) const {
return (index >= 0) && (index < _items.size());
}
const DashboardItem& Dashboard::item(int index) const {
ghoul_assert(index < _items.size(), "Invalid index");
return *_items[index];
}
void Dashboard::removeDashboardItems() {
for (const std::unique_ptr<DashboardItem>& item : _items) {
removePropertySubOwner(item.get());
}
_items.clear();
}
void Dashboard::render(glm::vec2& penPosition) {
for (const std::unique_ptr<DashboardItem>& item : _items) {
if (item->isEnabled()) {
item->render(penPosition);
}
}
}
scripting::LuaLibrary Dashboard::luaLibrary() {
return {
"dashboard",
{
{
"addDashboardItem",
&luascriptfunctions::addDashboardItem,
"table",
"Adds a new dashboard item to the main dashboard."
},
{
"removeDashboardItems",
&luascriptfunctions::removeDashboardItems,
"",
"Removes all dashboard items from the main dashboard."
}
}
};
}
} // namespace openspace
+74
View File
@@ -0,0 +1,74 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
#include <modules/base/rendering/screenspacedashboard.h>
namespace openspace::luascriptfunctions {
/**
* \ingroup LuaScripts
* addDashboardItem(table):
*/
int addDashboardItem(lua_State* L) {
int nArguments = lua_gettop(L);
if (nArguments != 1) {
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
}
int type = lua_type(L, -1);
if (type == LUA_TTABLE) {
ghoul::Dictionary d;
try {
ghoul::lua::luaDictionaryFromState(L, d);
}
catch (const ghoul::lua::LuaFormatException& e) {
LERRORC("addDashboardItem", e.what());
return 0;
}
OsEng.dashboard().addDashboardItem(DashboardItem::createFromDictionary(d));
return 0;
}
else {
return luaL_error(L, "Expected argument of type 'string' or 'table'");
}
}
/**
* \ingroup LuaScripts
* removeDashboardItems():
*/
int removeDashboardItems(lua_State* L) {
int nArguments = lua_gettop(L);
if (nArguments > 1) {
return luaL_error(L, "Expected %i or %i arguments, got %i", 0, 1, nArguments);
}
OsEng.dashboard().removeDashboardItems();
return 0;
}
}// namespace openspace::luascriptfunctions
+65
View File
@@ -0,0 +1,65 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* 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/rendering/dashboarditem.h>
#include <openspace/util/factorymanager.h>
#include <ghoul/misc/templatefactory.h>
namespace {
const char* KeyType = "Type";
static const openspace::properties::Property::PropertyInfo EnabledInfo = {
"Enabled",
"Is Enabled",
"If this value is set to 'true' this dashboard item is shown in the dashboard"
};
} // namespace
namespace openspace {
std::unique_ptr<DashboardItem> DashboardItem::createFromDictionary(
ghoul::Dictionary dictionary)
{
auto factory = FactoryManager::ref().factory<DashboardItem>();
ghoul_assert(factory, "DashboardItem factory did not exist");
std::string dashboardType = dictionary.value<std::string>(KeyType);
return factory->create(dashboardType, dictionary);
}
DashboardItem::DashboardItem(std::string name)
: properties::PropertyOwner({ std::move(name) })
, _isEnabled(EnabledInfo, true)
{
addProperty(_isEnabled);
}
bool DashboardItem::isEnabled() const {
return _isEnabled;
}
} // namespace openspace

Some files were not shown because too many files have changed in this diff Show More