Merge branch 'master' into thesis/2025/black-hole

This commit is contained in:
Wilhelm Björkström
2025-03-03 16:03:23 +01:00
91 changed files with 815 additions and 503 deletions
@@ -45,8 +45,6 @@
using namespace openspace;
namespace {
constexpr std::string_view _loggerCat = "LauncherWindow";
constexpr int ScreenWidth = 480;
constexpr int ScreenHeight = 640;
@@ -598,7 +596,7 @@ void LauncherWindow::openProfileEditor(const std::string& profile, bool isUserPr
connect(
&editor,
&ProfileEdit::raiseExitWindow,
[this, &editor, &savePath, &p, &profile]() {
[&editor, &savePath, &p, &profile]() {
const std::string origPath = std::format("{}{}.profile", savePath, profile);
// If this is a new profile we want to prompt the user
if (!std::filesystem::exists(origPath)) {
@@ -858,7 +858,7 @@ openspace::HorizonsFile HorizonsDialog::handleAnswer(nlohmann::json& answer) {
auto it = answer.find("error");
if (it != answer.end()) {
_latestHorizonsError = *it;
_latestHorizonsError = it->get<std::string>();
}
HorizonsResultCode isValid = isValidHorizonsAnswer(answer);
@@ -108,7 +108,7 @@ namespace {
[quality](const std::pair<int, std::string>& p) { return p.first == quality; }
);
ghoul_assert(it != Quality.cend(), "Combobox has too many values");
return std::distance(Quality.cbegin(), it);
return static_cast<int>(std::distance(Quality.cbegin(), it));
}
} // namespace
@@ -54,8 +54,12 @@ local ToggleTrails = {
if currentFade < 1 then
newFade = 1
end
openspace.setPropertyValue("Scene.*Trail.Renderable.Fade", newFade, 2)
openspace.setPropertyValue("Scene.*trail.Renderable.Fade", newFade, 2)
if (#capList > 0) then
openspace.setPropertyValue("Scene.*Trail.Renderable.Fade", newFade, 2)
end
if (#list > 0) then
openspace.setPropertyValue("Scene.*trail.Renderable.Fade", newFade, 2)
end
openspace.setPropertyValue("Scene.*TrailEarth.Renderable.Fade", newFade, 2)
end
]],
@@ -84,8 +88,12 @@ local ToggleTrailsInstant = {
if currentFade < 1 then
newFade = 1
end
openspace.setPropertyValue("Scene.*Trail.Renderable.Fade", newFade)
openspace.setPropertyValue("Scene.*trail.Renderable.Fade", newFade)
if (#capList > 0) then
openspace.setPropertyValue("Scene.*Trail.Renderable.Fade", newFade)
end
if (#list > 0) then
openspace.setPropertyValue("Scene.*trail.Renderable.Fade", newFade)
end
end
]],
Documentation = "Toggle fade instantly for all trails in the Scene",
@@ -0,0 +1,16 @@
-- Basic
-- This example adds a dashboard item to the main dashboard that shows the current camera
-- orientation.
local Item = {
Identifier = "DashboardItemCameraOrientation_Example",
Type = "DashboardItemCameraOrientation"
}
asset.onInitialize(function()
openspace.dashboard.addDashboardItem(Item)
end)
asset.onDeinitialize(function()
openspace.dashboard.removeDashboardItem(Item)
end)
@@ -0,0 +1,37 @@
-- Time offset
-- This asset creates a rotation provided by a SPICE kernel and applies it to a
-- SceneGraphNode that only displays coordinate axes. The rotation of the coordinate axes
-- are determined by SPICE, in this case pretending that the coordinate axes are rotating
-- at the same rate as Earth. In this specific example, the orientation is offset 8h back
-- compared to the actual in-game time in OpenSpace.
-- Load the default SPICE kernels, which is the planetary constants and the DE430 kernel
asset.require("spice/core")
local Node = {
Identifier = "SpiceRotation_Example_TimeOffset",
Transform = {
Rotation = {
Type = "SpiceRotation",
SourceFrame = "IAU_EARTH",
DestinationFrame = "GALACTIC",
TimeOffset = -8 * 60 * 60
}
},
Renderable = {
Type = "RenderableCartesianAxes"
},
GUI = {
Name = "SpiceRotation - Time Offset",
Path = "/Examples"
}
}
asset.onInitialize(function()
openspace.addSceneGraphNode(Node)
end)
asset.onDeinitialize(function()
openspace.removeSceneGraphNode(Node)
end)
@@ -0,0 +1,37 @@
-- Fixed Date
-- This asset creates a time-varying translation with information from a SPICE kernel and
-- applies it to a SceneGraphNode that only displays coordinate axes. The position of the
-- coordinate axes are determined by SPICE, in this case pretending that the axes are
-- orbiting the same way the Moon does around Earth. In this specific example, the position
-- is offset 8h back compared to the actual in-game time in OpenSpace.
-- For more information about SPICE see: https://naif.jpl.nasa.gov/naif/
-- Load the default SPICE kernels, which are the planetary constants and the DE430 kernel
asset.require("spice/core")
local Node = {
Identifier = "SpiceTranslation_Example_TimeOffset",
Transform = {
Translation = {
Type = "SpiceTranslation",
Target = "MOON",
Observer = "EARTH",
TimeOffset = -8 * 60 * 60
}
},
Renderable = {
Type = "RenderableCartesianAxes"
},
GUI = {
Name = "SpiceTranslation - Time Offset",
Path = "/Examples"
}
}
asset.onInitialize(function()
openspace.addSceneGraphNode(Node)
end)
asset.onDeinitialize(function()
openspace.removeSceneGraphNode(Node)
end)
+12
View File
@@ -25,7 +25,9 @@
#ifndef __OPENSPACE_CORE___ACTION___H__
#define __OPENSPACE_CORE___ACTION___H__
#include <ghoul/glm.h>
#include <ghoul/misc/boolean.h>
#include <optional>
#include <string>
namespace openspace::interaction {
@@ -59,6 +61,16 @@ struct Action {
/// for the root path
std::string guiPath = "/";
/// This variable, if specified, will be used as a hint to any potential user
/// interface as a desired background color. This can be used, for example, by the
/// user to visually group similar Actions together
std::optional<glm::vec4> color;
/// This variable, if specified, will be used as a hint to any potential user
/// interface as a desired text color. This can be used, for example, by the user to
/// visually group similar Actions together
std::optional<glm::vec4> textColor;
/// If this value is set to `Yes`, the execution of this action is restricted to the
/// current OpenSpace instance. If it is `No`, it is synchronized to other OpenSpace
/// instances, for example other nodes in a cluster environment, or to other OpenSpace
@@ -244,7 +244,7 @@ private:
void cleanUpTimelinesAndKeyframes();
void checkIfScriptUsesScenegraphNode(std::string_view s) const;
void checkIfScriptUsesScenegraphNode(std::string_view script) const;
properties::BoolProperty _renderPlaybackInformation;
@@ -61,7 +61,7 @@ public:
*/
void setLuaValue(lua_State* state) override;
ghoul::lua::LuaTypes typeLua() const;
ghoul::lua::LuaTypes typeLua() const override;
/**
* Triggers this TriggerProperty.
+3 -2
View File
@@ -86,9 +86,10 @@ DistanceUnits = {
DistanceUnit::NauticalMile
};
// Note that the syntax here is required when initializing constexpr std::arrays with structs
// Note that the syntax here is required when initializing constexpr std::arrays with
// structs
constexpr std::array<DistanceUnitName, static_cast<int>(DistanceUnit::NauticalMile) + 1>
DistanceUnitNames{ {
DistanceUnitNames { {
{ "Nanometer", "Nanometers", "nm" },
{ "Micrometer", "Micrometers", "um" },
{ "Millimeter", "Millimeters", "mm" },
+2 -16
View File
@@ -389,6 +389,8 @@ constexpr std::array<KeyInfo, 120> KeyInfos = {
struct KeyWithModifier {
Key key = Key::Unknown;
KeyModifier modifier = KeyModifier::None;
auto operator<=>(const KeyWithModifier&) const = default;
};
constexpr inline bool isKeypadKey(Key key) noexcept {
@@ -403,22 +405,6 @@ constexpr inline bool isKeypadKey(Key key) noexcept {
KeyWithModifier stringToKey(const std::string& str);
std::string keyToString(KeyWithModifier keyWithModifier);
// @TODO (abock, 2021-08-12) This function should die
constexpr bool operator<(const KeyWithModifier& lhs, const KeyWithModifier& rhs) noexcept
{
if (lhs.modifier == rhs.modifier) {
return lhs.key < rhs.key;
}
else {
return lhs.modifier < rhs.modifier;
}
}
constexpr bool operator==(const KeyWithModifier& lhs, const KeyWithModifier& rhs) noexcept
{
return (lhs.key == rhs.key) && (lhs.modifier == rhs.modifier);
}
} // namespace openspace
namespace ghoul {
+44
View File
@@ -0,0 +1,44 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2025 *
* *
* 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___TIMECONSTANTS___H__
#define __OPENSPACE_CORE___TIMECONSTANTS___H__
#include <chrono>
namespace openspace::timeconstants {
constexpr double SecondsPerYear = 31556952; // seconds in average Gregorian year
constexpr double SecondsPerMonth = SecondsPerYear / 12;
constexpr double SecondsPerDay = static_cast<double>(
std::chrono::seconds(std::chrono::hours(24)).count()
);
constexpr double SecondsPerHour = static_cast<double>(
std::chrono::seconds(std::chrono::hours(1)).count()
);
constexpr double SecondsPerMinute = static_cast<double>(
std::chrono::seconds(std::chrono::minutes(1)).count()
);
} // openspace::timeconstants
#endif // __OPENSPACE_CORE___TIMECONSTANTS___H__
+93 -130
View File
@@ -25,27 +25,16 @@
#ifndef __OPENSPACE_CORE___TIMECONVERSION___H__
#define __OPENSPACE_CORE___TIMECONVERSION___H__
#include <openspace/util/timeconstants.h>
#include <ghoul/misc/assert.h>
#include <ghoul/misc/constexpr.h>
#include <algorithm>
#include <array>
#include <chrono>
#include <string>
namespace openspace {
constexpr double SecondsPerYear = 31556952; // seconds in average Gregorian year
constexpr double SecondsPerMonth = SecondsPerYear / 12;
constexpr double SecondsPerDay = static_cast<double>(
std::chrono::seconds(std::chrono::hours(24)).count()
);
constexpr double SecondsPerHour = static_cast<double>(
std::chrono::seconds(std::chrono::hours(1)).count()
);
constexpr double SecondsPerMinute = static_cast<double>(
std::chrono::seconds(std::chrono::minutes(1)).count()
);
// Assumption: static_cast<int>(TimeUnit) == position in the list
enum class TimeUnit {
Nanosecond = 0,
@@ -59,27 +48,11 @@ enum class TimeUnit {
Year
};
// Assumption: Unit names are sequential in memory
constexpr std::string_view TimeUnitNanosecond = "Nanosecond";
constexpr std::string_view TimeUnitMicrosecond = "Microsecond";
constexpr std::string_view TimeUnitMillisecond = "Millisecond";
constexpr std::string_view TimeUnitSecond = "Second";
constexpr std::string_view TimeUnitMinute = "Minute";
constexpr std::string_view TimeUnitHour = "Hour";
constexpr std::string_view TimeUnitDay = "Day";
constexpr std::string_view TimeUnitMonth = "Month";
constexpr std::string_view TimeUnitYear = "Year";
// Assumption: Unit names are sequential in memory
constexpr std::string_view TimeUnitNanoseconds = "Nanoseconds";
constexpr std::string_view TimeUnitMicroseconds = "Microseconds";
constexpr std::string_view TimeUnitMilliseconds = "Milliseconds";
constexpr std::string_view TimeUnitSeconds = "Seconds";
constexpr std::string_view TimeUnitMinutes = "Minutes";
constexpr std::string_view TimeUnitHours = "Hours";
constexpr std::string_view TimeUnitDays = "Days";
constexpr std::string_view TimeUnitMonths = "Months";
constexpr std::string_view TimeUnitYears = "Years";
struct TimeUnitName {
std::string_view singular;
std::string_view plural;
std::string_view abbreviation;
};
constexpr std::array<TimeUnit, static_cast<int>(TimeUnit::Year) + 1> TimeUnits = {
TimeUnit::Nanosecond, TimeUnit::Microsecond, TimeUnit::Millisecond,
@@ -87,81 +60,68 @@ constexpr std::array<TimeUnit, static_cast<int>(TimeUnit::Year) + 1> TimeUnits =
TimeUnit::Month, TimeUnit::Year
};
constexpr std::array<std::string_view, static_cast<int>(TimeUnit::Year) + 1>
TimeUnitNamesSingular = {
TimeUnitNanosecond, TimeUnitMicrosecond, TimeUnitMillisecond, TimeUnitSecond,
TimeUnitMinute, TimeUnitHour, TimeUnitDay, TimeUnitMonth, TimeUnitYear
};
constexpr std::array<std::string_view, static_cast<int>(TimeUnit::Year) + 1>
TimeUnitNamesPlural = {
TimeUnitNanoseconds, TimeUnitMicroseconds, TimeUnitMilliseconds, TimeUnitSeconds,
TimeUnitMinutes, TimeUnitHours, TimeUnitDays, TimeUnitMonths, TimeUnitYears
};
// Note that the syntax here is required when initializing constexpr std::arrays
// with structs
constexpr std::array<TimeUnitName, static_cast<int>(TimeUnit::Year) + 1>
TimeUnitNames { {
{ "Nanosecond", "Nanoseconds", "ns" },
{ "Microsecond", "Microseconds", "us" },
{ "Millisecond", "Milliseconds", "ms" },
{ "Second", "Seconds", "s" },
{ "Minute", "Minutes", "m" },
{ "Hour", "Hours", "h" },
{ "Day", "Days", "d" },
{ "Month", "Months", "M" },
{ "Year", "Years", "Y" }
} };
constexpr bool isValidTimeUnitName(std::string_view name) {
for (std::string_view val : TimeUnitNamesSingular) {
if (val == name) {
return true;
}
}
for (std::string_view val : TimeUnitNamesPlural) {
if (val == name) {
for (TimeUnit unit : TimeUnits) {
const TimeUnitName unitName = TimeUnitNames[static_cast<int>(unit)];
if (name == unitName.singular || name == unitName.plural ||
name == unitName.abbreviation)
{
return true;
}
}
return false;
}
constexpr std::string_view nameForTimeUnit(TimeUnit unit, bool pluralForm = false) {
switch (unit) {
case TimeUnit::Nanosecond:
case TimeUnit::Microsecond:
case TimeUnit::Millisecond:
case TimeUnit::Second:
case TimeUnit::Minute:
case TimeUnit::Hour:
case TimeUnit::Day:
case TimeUnit::Month:
case TimeUnit::Year:
if (pluralForm) {
return TimeUnitNamesPlural[static_cast<int>(unit)];
}
else {
return TimeUnitNamesSingular[static_cast<int>(unit)];
}
default:
throw ghoul::MissingCaseException();
}
constexpr std::string_view nameForTimeUnit(TimeUnit unit, bool usePluralForm = false) {
const TimeUnitName unitName = TimeUnitNames[static_cast<int>(unit)];
return usePluralForm ? unitName.plural : unitName.singular;
}
constexpr std::string_view abbreviationForDistanceUnit(TimeUnit unit) {
return TimeUnitNames[static_cast<int>(unit)].abbreviation;
}
constexpr TimeUnit timeUnitFromString(std::string_view unitName) {
int found = -1;
int i = 0;
for (std::string_view val : TimeUnitNamesSingular) {
if (val == unitName) {
found = i;
break;
for (TimeUnit unit : TimeUnits) {
const TimeUnitName name = TimeUnitNames[static_cast<int>(unit)];
if (name.singular == unitName || name.plural == unitName ||
name.abbreviation == unitName)
{
return static_cast<TimeUnit>(i);
}
i++;
}
i = 0;
for (std::string_view val : TimeUnitNamesPlural) {
if (val == unitName) {
found = i;
break;
}
i++;
}
throw ghoul::MissingCaseException();
}
if (found != -1) {
return static_cast<TimeUnit>(found);
}
else {
throw ghoul::MissingCaseException();
}
constexpr std::vector<std::string> timeUnitList() {
std::vector<std::string> res(TimeUnits.size());
std::transform(
TimeUnits.begin(),
TimeUnits.end(),
res.begin(),
[](TimeUnit unit) {
return std::string(nameForTimeUnit(unit));
}
);
return res;
}
std::pair<double, std::string_view> simplifyTime(double seconds,
@@ -170,38 +130,8 @@ std::pair<double, std::string_view> simplifyTime(double seconds,
std::vector<std::pair<double, std::string_view>> splitTime(double seconds,
bool forceSingularForm = false);
constexpr double convertTime(double t, TimeUnit sourceUnit, TimeUnit destinationUnit) {
double seconds = t;
switch (sourceUnit) {
case TimeUnit::Nanosecond:
seconds = t * 1e-9;
break;
case TimeUnit::Microsecond:
seconds = t * 1e-6;
break;
case TimeUnit::Millisecond:
seconds = t * 1e-3;
break;
case TimeUnit::Minute:
seconds = t * SecondsPerMinute;
break;
case TimeUnit::Hour:
seconds = t * SecondsPerHour;
break;
case TimeUnit::Day:
seconds = t * SecondsPerDay;
break;
case TimeUnit::Month:
seconds = t * SecondsPerMonth;
break;
case TimeUnit::Year:
seconds = t * SecondsPerYear;
break;
default:
break;
}
switch (destinationUnit) {
constexpr double convertSeconds(double seconds, TimeUnit requestedUnit) {
switch (requestedUnit) {
case TimeUnit::Nanosecond:
return seconds / 1e-9;
case TimeUnit::Microsecond:
@@ -211,20 +141,53 @@ constexpr double convertTime(double t, TimeUnit sourceUnit, TimeUnit destination
case TimeUnit::Second:
return seconds;
case TimeUnit::Minute:
return seconds / SecondsPerMinute;
return seconds / timeconstants::SecondsPerMinute;
case TimeUnit::Hour:
return seconds / SecondsPerHour;
return seconds / timeconstants::SecondsPerHour;
case TimeUnit::Day:
return seconds / SecondsPerDay;
return seconds / timeconstants::SecondsPerDay;
case TimeUnit::Month:
return seconds / SecondsPerMonth;
return seconds / timeconstants::SecondsPerMonth;
case TimeUnit::Year:
return seconds / SecondsPerYear;
return seconds / timeconstants::SecondsPerYear;
default:
throw ghoul::MissingCaseException();
}
}
constexpr double toSecond(TimeUnit unit) {
switch (unit) {
case TimeUnit::Nanosecond:
return 1e-9;
case TimeUnit::Microsecond:
return 1e-6;
case TimeUnit::Millisecond:
return 1e-3;
case TimeUnit::Second:
return 1.0;
case TimeUnit::Minute:
return timeconstants::SecondsPerMinute;
case TimeUnit::Hour:
return timeconstants::SecondsPerHour;
case TimeUnit::Day:
return timeconstants::SecondsPerDay;
case TimeUnit::Month:
return timeconstants::SecondsPerMonth;
case TimeUnit::Year:
return timeconstants::SecondsPerYear;
default:
throw ghoul::MissingCaseException();
}
}
constexpr double convertUnit(TimeUnit fromUnit, TimeUnit toUnit) {
return convertSeconds(toSecond(fromUnit), toUnit);
}
constexpr double convertTime(double time, TimeUnit fromUnit, TimeUnit toUnit) {
return time * convertUnit(fromUnit, toUnit);
}
} // namespace openspace
#endif // __OPENSPACE_CORE___TIMECONVERSION___H__
+1 -1
View File
@@ -49,7 +49,7 @@ if (WIN32)
elseif (UNIX)
set(SOLOUD_BACKEND_ALSA ON CACHE BOOL "")
endif ()
add_subdirectory(ext/soloud/contrib)
add_subdirectory(ext/soloud/contrib SYSTEM)
# Unfortunately, the soloud cmake tarket doesn't set the include directories correctly
target_include_directories(openspace-module-audio SYSTEM PRIVATE ext/soloud/include)
+2
View File
@@ -26,6 +26,7 @@ include(${PROJECT_SOURCE_DIR}/support/cmake/module_definition.cmake)
set(HEADER_FILES
dashboard/dashboarditemangle.h
dashboard/dashboarditemcameraorientation.h
dashboard/dashboarditemdate.h
dashboard/dashboarditemdistance.h
dashboard/dashboarditemelapsedtime.h
@@ -93,6 +94,7 @@ source_group("Header Files" FILES ${HEADER_FILES})
set(SOURCE_FILES
dashboard/dashboarditemangle.cpp
dashboard/dashboarditemcameraorientation.cpp
dashboard/dashboarditemdate.cpp
dashboard/dashboarditemdistance.cpp
dashboard/dashboarditemelapsedtime.cpp
+5
View File
@@ -25,6 +25,7 @@
#include <modules/base/basemodule.h>
#include <modules/base/dashboard/dashboarditemangle.h>
#include <modules/base/dashboard/dashboarditemcameraorientation.h>
#include <modules/base/dashboard/dashboarditemdate.h>
#include <modules/base/dashboard/dashboarditemdistance.h>
#include <modules/base/dashboard/dashboarditemelapsedtime.h>
@@ -115,6 +116,9 @@ void BaseModule::internalInitialize(const ghoul::Dictionary&) {
ghoul_assert(fDashboard, "Dashboard factory was not created");
fDashboard->registerClass<DashboardItemAngle>("DashboardItemAngle");
fDashboard->registerClass<DashboardItemCameraOrientation>(
"DashboardItemCameraOrientation"
);
fDashboard->registerClass<DashboardItemDate>("DashboardItemDate");
fDashboard->registerClass<DashboardItemDistance>("DashboardItemDistance");
fDashboard->registerClass<DashboardItemElapsedTime>("DashboardItemElapsedTime");
@@ -228,6 +232,7 @@ void BaseModule::internalDeinitializeGL() {
std::vector<documentation::Documentation> BaseModule::documentations() const {
return {
DashboardItemAngle::Documentation(),
DashboardItemCameraOrientation::Documentation(),
DashboardItemDate::Documentation(),
DashboardItemDistance::Documentation(),
DashboardItemElapsedTime::Documentation(),
@@ -0,0 +1,77 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2025 *
* *
* 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/dashboarditemcameraorientation.h>
#include <openspace/camera/camera.h>
#include <openspace/documentation/documentation.h>
#include <openspace/engine/globals.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scene.h>
#include <ghoul/font/font.h>
namespace {
// This `DashboardItem` shows the current camera orientation in the yaw, pitch, and
// roll directions in degrees. Note that the camera's orientation is relative to the
// global coordinate system used in the system.
struct [[codegen::Dictionary(DashboardItemCameraOrientation)]] Parameters {
};
#include "dashboarditemcameraorientation_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation DashboardItemCameraOrientation::Documentation() {
return codegen::doc<Parameters>(
"base_dashboarditem_cameraorientation",
DashboardTextItem::Documentation()
);
}
DashboardItemCameraOrientation::DashboardItemCameraOrientation(
const ghoul::Dictionary& dictionary)
: DashboardTextItem(dictionary)
{}
void DashboardItemCameraOrientation::update() {
ZoneScoped;
const Camera* camera = global::renderEngine->scene()->camera();
const glm::dquat orientation = camera->rotationQuaternion();
const glm::dvec3 pitchYawRoll = glm::eulerAngles(orientation);
const glm::dvec3 pitchYawRollDeg = glm::degrees(pitchYawRoll);
_buffer = std::format(
"Yaw: {:.2f}\nPitch: {:.2f}\nRoll: {:.2f}",
pitchYawRollDeg.y, pitchYawRollDeg.x, pitchYawRollDeg.z
);
}
glm::vec2 DashboardItemCameraOrientation::size() const {
ZoneScoped;
return _font->boundingBox("Yaw: 0.00\nPitch: 0.00\nRoll: 0.00");
}
} // namespace openspace
@@ -0,0 +1,46 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2025 *
* *
* 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___DASHBOARDITEMCAMERAORIENTATION___H__
#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMCAMERAORIENTATION___H__
#include <openspace/rendering/dashboardtextitem.h>
namespace openspace {
class DashboardItemCameraOrientation : public DashboardTextItem {
public:
explicit DashboardItemCameraOrientation(const ghoul::Dictionary& dictionary);
~DashboardItemCameraOrientation() override = default;
void update() override;
glm::vec2 size() const override;
static documentation::Documentation Documentation();
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMCAMERAORIENTATION___H__
@@ -55,8 +55,6 @@ void DashboardItemParallelConnection::update() {
const size_t nConnections = global::parallelPeer->nConnections();
const std::string& hostName = global::parallelPeer->hostName();
int nLines = 1;
int nClients = static_cast<int>(nConnections);
if (status == ParallelConnection::Status::Host) {
nClients--;
@@ -92,8 +90,6 @@ void DashboardItemParallelConnection::update() {
else if (nClients == 1) {
_buffer += "You are the only client";
}
nLines = 2;
}
}
@@ -54,7 +54,7 @@ namespace {
.synchronized = scripting::ScriptEngine::Script::ShouldBeSynchronized::No,
.sendToRemote = scripting::ScriptEngine::Script::ShouldSendToRemote::No
});
};
}
constexpr openspace::properties::Property::PropertyInfo InterpolationValueInfo = {
"Value",
@@ -796,7 +796,7 @@ RenderablePointCloud::RenderablePointCloud(const ghoul::Dictionary& dictionary)
}
bool RenderablePointCloud::isReady() const {
bool isReady = _program;
bool isReady = _program != nullptr;
if (_hasLabels) {
isReady = isReady && _labels->isReady();
}
+1 -1
View File
@@ -253,11 +253,11 @@ documentation::Documentation RenderableLabel::Documentation() {
RenderableLabel::RenderableLabel(const ghoul::Dictionary& dictionary)
: Renderable(dictionary, { .automaticallyUpdateRenderBin = false })
, _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown)
, _text(TextInfo, "")
, _color(ColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
, _fontSize(FontSizeInfo, 50.f, 1.f, 100.f)
, _size(SizeInfo, 8.f, 0.5f, 30.f)
, _minMaxSize(MinMaxSizeInfo, glm::ivec2(8, 20), glm::ivec2(0), glm::ivec2(100))
, _text(TextInfo, "")
, _enableFadingEffect(EnableFadingEffectInfo, false)
, _fadeWidths(FadeWidthsInfo, glm::vec2(1.f), glm::vec2(0.f), glm::vec2(100.f))
, _fadeDistances(FadeDistancesInfo, glm::vec2(1.f), glm::vec2(0.f), glm::vec2(100.f))
+9 -18
View File
@@ -316,14 +316,15 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
const std::string stringUnit = std::get<std::string>(*p.modelScale);
// Find matching unit name in list of supported unit names
try {
if (isValidDistanceUnitName(stringUnit)) {
DistanceUnit distanceUnit = distanceUnitFromString(stringUnit);
_modelScale = toMeter(distanceUnit);
}
catch (const ghoul::MissingCaseException& e) {
std::string message = std::format("The given unit name '{}' does not "
"match any currently supported unit names", stringUnit);
LERROR(message);
else {
LERROR(std::format(
"The given unit name '{}' does not match any currently supported "
"unit names", stringUnit
));
_modelScale = 1.0;
}
}
@@ -348,21 +349,11 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
if (std::holds_alternative<float>(*p.animationTimeScale)) {
_animationTimeScale = std::get<float>(*p.animationTimeScale);
}
else if (std::holds_alternative<std::string>(*p.animationTimeScale))
{
else if (std::holds_alternative<std::string>(*p.animationTimeScale)) {
const std::string stringUnit = std::get<std::string>(*p.animationTimeScale);
// Find matching unit name in list of supported unit names
TimeUnit timeUnit;
bool wasFound = false;
for (int i = 0; i < TimeUnitNamesSingular.size(); ++i) {
if (stringUnit == TimeUnitNamesSingular[i]) {
wasFound = true;
timeUnit = TimeUnits[i];
}
}
if (wasFound) {
if (isValidTimeUnitName(stringUnit)) {
TimeUnit timeUnit = timeUnitFromString(stringUnit);
_animationTimeScale = convertTime(1.0, timeUnit, TimeUnit::Second);
}
else {
@@ -251,7 +251,7 @@ namespace {
std::optional<float> width [[codegen::greaterequal(0.f)]];
// [[codegen::verbatim(ShadingEnabledInfo.description)]]
std::optional<float> performShading;
std::optional<bool> performShading;
// [[codegen::verbatim(AmbientIntensityInfo.description)]]
std::optional<float> ambientIntensity [[codegen::greaterequal(0.f)]];
@@ -385,7 +385,7 @@ void RenderableNodeArrow::deinitializeGL() {
}
bool RenderableNodeArrow::isReady() const {
return _shaderProgram;
return _shaderProgram != nullptr;
}
void RenderableNodeArrow::updateShapeTransforms(const RenderData& data) {
@@ -195,13 +195,13 @@ RenderablePlaneImageOnline::downloadImageToMemory(const std::string& url)
{
return global::downloadManager->fetchFile(
url,
[url](const DownloadManager::MemoryFile&) {
[](const DownloadManager::MemoryFile&) {
LDEBUGC(
"ScreenSpaceImageOnline",
"Download to memory finished for screen space image"
);
},
[url](const std::string& err) {
[](const std::string& err) {
LDEBUGC(
"ScreenSpaceImageOnline",
"Download to memory failer for screen space image: " + err
@@ -38,7 +38,6 @@
#include <optional>
namespace {
constexpr std::string_view KeyLazyLoading = "LazyLoading";
constexpr std::string_view _loggerCat = "RenderablePlaneTimeVaryingImage";
constexpr openspace::properties::Property::PropertyInfo SourceFolderInfo = {
@@ -28,7 +28,7 @@
#include <openspace/documentation/verifier.h>
#include <openspace/scene/translation.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/timeconversion.h>
#include <openspace/util/timeconstants.h>
#include <openspace/util/updatestructures.h>
#include <optional>
@@ -143,7 +143,7 @@ namespace {
std::optional<int> sweepChunkSize;
// [[codegen::verbatim(SweepChunkSizeInfo.description)]]
std::optional<int> enableSweepChunking;
std::optional<bool> enableSweepChunking;
// [[codegen::verbatim(AccurateTrailPositionsInfo.description)]]
std::optional<int> accurateTrailPositions;
@@ -193,7 +193,7 @@ RenderableTrailTrajectory::RenderableTrailTrajectory(const ghoul::Dictionary& di
}
else {
const double delta = Time::convertTime(_endTime) - Time::convertTime(_startTime);
_sampleInterval = delta / (openspace::SecondsPerYear * 2);
_sampleInterval = delta / (openspace::timeconstants::SecondsPerYear * 2);
}
_sampleInterval.onChange([this] { reset(); });
addProperty(_sampleInterval);
@@ -152,10 +152,10 @@ std::future<DownloadManager::MemoryFile> ScreenSpaceImageOnline::downloadImageTo
{
return global::downloadManager->fetchFile(
url,
[url](const DownloadManager::MemoryFile&) {
[](const DownloadManager::MemoryFile&) {
LDEBUG("Download to memory finished for screen space image");
},
[url](const std::string& err) {
[](const std::string& err) {
LDEBUG(std::format(
"Download to memory failed for screen space image: {}", err
));
@@ -1201,7 +1201,7 @@ void RenderableFieldlinesSequence::updateVertexPositionBuffer() {
);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
unbindGL();
}
@@ -1226,7 +1226,7 @@ void RenderableFieldlinesSequence::updateVertexColorBuffer() {
);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, 0, 0);
glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, 0, nullptr);
unbindGL();
}
@@ -1252,7 +1252,7 @@ void RenderableFieldlinesSequence::updateVertexMaskingBuffer() {
);
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 1, GL_FLOAT, GL_FALSE, 0, 0);
glVertexAttribPointer(2, 1, GL_FLOAT, GL_FALSE, 0, nullptr);
unbindGL();
}
-2
View File
@@ -38,8 +38,6 @@
#include <optional>
namespace {
constexpr std::string_view KeyFilterColumnNames = "FilterColumnNames";
constexpr std::string_view _loggerCat = "ReadFitsTask";
struct [[codegen::Dictionary(ReadFitsTask)]] Parameters {
@@ -93,7 +93,9 @@ void MilkywayPointsConversionTask::perform(const Task::ProgressCallback& progres
documentation::Documentation MilkywayPointsConversionTask::Documentation() {
return {
"MilkywayPointsConversionTask",
"galaxy_milkywaypointsconversiontask"
"galaxy_milkywaypointsconversiontask",
"",
{}
};
}
+1 -1
View File
@@ -142,7 +142,7 @@ double GeodeticPatch::edgeLatitudeNearestEquator() const {
return _center.lat + _halfSize.lat * (isNorthern() ? -1.0 : 1.0);
}
double GeodeticPatch::isNorthern() const {
bool GeodeticPatch::isNorthern() const {
return _center.lat > 0.0;
}
+1 -1
View File
@@ -53,7 +53,7 @@ public:
/**
* Returns `true` if the center above the equator.
*/
double isNorthern() const;
bool isNorthern() const;
Geodetic2 corner(Quad q) const;
@@ -51,12 +51,11 @@ private:
void internalDeinitialize() override final;
std::array<std::unique_ptr<ghoul::opengl::Texture>, 2> tileTexture;
std::array<GLuint, 2> fbo = { 0, 0 };
std::array<Tile, 2> tiles;
#ifdef OPENSPACE_HAS_SPOUT
std::array<GLuint, 2> fbo = { 0, 0 };
std::unique_ptr<spout::SpoutReceiverPropertyProxy> spoutReceiver;
#endif
#endif // OPENSPACE_HAS_SPOUT
bool spoutUpdate = false;
};
@@ -66,7 +66,6 @@ TileProviderByDate::TileProviderByDate(const ghoul::Dictionary& dictionary) {
if (dictionary.hasValue<std::string>("GlobeName")) {
prov.second.setValue("GlobeName", dictionary.value<std::string>("GlobeName"));
}
layers::Layer::ID typeID = layers::Layer::ID::DefaultTileProvider;
std::unique_ptr<TileProvider> tp = createFromDictionary(prov.second);
const std::string provId = prov.second.value<std::string>("Identifier");
+2 -2
View File
@@ -67,9 +67,9 @@ void GuiMemoryComponent::render() {
_isCollapsed = ImGui::IsWindowCollapsed();
uint64_t ram = global::openSpaceEngine->ramInUse();
ImGui::Text("RAM: %u (%f MiB)", ram, ram / (1024.f * 1024.f));
ImGui::Text("RAM: %lu (%f MiB)", ram, ram / (1024.f * 1024.f));
uint64_t vram = global::openSpaceEngine->vramInUse();
ImGui::Text("VRAM: %u (%f MiB)", vram, vram / (1024.f * 1024.f));
ImGui::Text("VRAM: %lu (%f MiB)", vram, vram / (1024.f * 1024.f));
ImGui::Spacing();
+7 -7
View File
@@ -32,7 +32,7 @@
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scenegraphnode.h>
#include <openspace/scene/scene.h>
#include <openspace/util/timeconversion.h>
#include <openspace/util/timeconstants.h>
#include <openspace/util/timemanager.h>
#include <openspace/scripting/scriptengine.h>
@@ -486,7 +486,7 @@ void GuiSpaceTimeComponent::render() {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(std::format(
"openspace.time.interpolateDeltaTime(-{})", SecondsPerDay
"openspace.time.interpolateDeltaTime(-{})", timeconstants::SecondsPerDay
));
}
ImGui::SameLine();
@@ -496,7 +496,7 @@ void GuiSpaceTimeComponent::render() {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(std::format(
"openspace.time.interpolateDeltaTime(-{})", SecondsPerHour
"openspace.time.interpolateDeltaTime(-{})", timeconstants::SecondsPerHour
));
}
ImGui::SameLine();
@@ -506,7 +506,7 @@ void GuiSpaceTimeComponent::render() {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(std::format(
"openspace.time.interpolateDeltaTime(-{})", SecondsPerMinute
"openspace.time.interpolateDeltaTime(-{})", timeconstants::SecondsPerMinute
));
}
ImGui::SameLine();
@@ -541,7 +541,7 @@ void GuiSpaceTimeComponent::render() {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(std::format(
"openspace.time.interpolateDeltaTime({})", SecondsPerMinute
"openspace.time.interpolateDeltaTime({})", timeconstants::SecondsPerMinute
));
}
ImGui::SameLine();
@@ -551,7 +551,7 @@ void GuiSpaceTimeComponent::render() {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(std::format(
"openspace.time.interpolateDeltaTime({})", SecondsPerHour
"openspace.time.interpolateDeltaTime({})", timeconstants::SecondsPerHour
));
}
ImGui::SameLine();
@@ -561,7 +561,7 @@ void GuiSpaceTimeComponent::render() {
// No sync or send because time settings are always synced and sent
// to the connected nodes and peers
global::scriptEngine->queueScript(std::format(
"openspace.time.interpolateDeltaTime({})", SecondsPerDay
"openspace.time.interpolateDeltaTime({})", timeconstants::SecondsPerDay
));
}
+2 -2
View File
@@ -60,7 +60,7 @@ IswaBaseGroup::IswaBaseGroup(std::string name, std::string type)
, _enabled(EnabledInfo, true)
, _alpha(AlphaInfo, 0.9f, 0.f, 1.f)
, _delete(DeleteInfo)
, _type(std::move(type))
, _iswaType(std::move(type))
{
addProperty(_enabled);
addProperty(_alpha);
@@ -72,7 +72,7 @@ IswaBaseGroup::IswaBaseGroup(std::string name, std::string type)
IswaBaseGroup::~IswaBaseGroup() {}
bool IswaBaseGroup::isType(const std::string& type) const {
return (_type == type);
return (_iswaType == type);
}
void IswaBaseGroup::updateGroup() {
+2 -1
View File
@@ -61,7 +61,8 @@ protected:
std::shared_ptr<DataProcessor> _dataProcessor;
bool _registered = false;
std::string _type;
private:
std::string _iswaType;
};
} //namespace openspace
+13 -10
View File
@@ -101,9 +101,9 @@ IswaManager::IswaManager()
: properties::PropertyOwner({ "IswaManager", "Iswa Manager" })
, _baseUrl("https://iswa-demo-server.herokuapp.com/")
{
_type[CygnetType::Texture] = "Texture";
_type[CygnetType::Data] = "Data";
_type[CygnetType::Kameleon] = "Kameleon";
_cygnetType[CygnetType::Texture] = "Texture";
_cygnetType[CygnetType::Data] = "Data";
_cygnetType[CygnetType::Kameleon] = "Kameleon";
_geom[CygnetGeometry::Plane] = "Plane";
_geom[CygnetGeometry::Sphere] = "Sphere";
@@ -124,7 +124,6 @@ IswaManager::~IswaManager() {
_cygnetInformation.clear();
}
void IswaManager::initialize() {
ghoul_assert(!isInitialized(), "IswaManager is already initialized");
_instance = new IswaManager;
@@ -156,10 +155,10 @@ void IswaManager::addIswaCygnet(int id, const std::string& type, std::string gro
metaFuture.group = std::move(group);
// Assign type of cygnet Texture/Data
if (type == _type[CygnetType::Texture]) {
if (type == _cygnetType[CygnetType::Texture]) {
metaFuture.type = CygnetType::Texture;
}
else if (type == _type[CygnetType::Data]) {
else if (type == _cygnetType[CygnetType::Data]) {
metaFuture.type = CygnetType::Data;
}
else {
@@ -389,7 +388,7 @@ std::string IswaManager::jsonPlaneToLuaTable(MetadataFuture& data) {
"Name = '" + data.name +"' , "
"Parent = '" + parent + "', "
"Renderable = {"
"Type = '" + _type[data.type] + _geom[data.geom] + "', "
"Type = '" + _cygnetType[data.type] + _geom[data.geom] + "', "
"Id = " + ghoul::to_string(data.id) + ", "
"Frame = '" + frame + "' , "
"GridMin = " + ghoul::to_string(min) + ", "
@@ -496,7 +495,7 @@ std::string IswaManager::jsonSphereToLuaTable(MetadataFuture& data) {
"Name = '" + data.name +"' , "
"Parent = '" + parent + "', "
"Renderable = {"
"Type = '" + _type[data.type] + _geom[data.geom] + "', "
"Type = '" + _cygnetType[data.type] + _geom[data.geom] + "', "
"Id = " + std::to_string(data.id) + ", "
"Frame = '" + frame + "' , "
"GridMin = " + ghoul::to_string(min) + ", "
@@ -513,7 +512,9 @@ std::string IswaManager::jsonSphereToLuaTable(MetadataFuture& data) {
void IswaManager::createPlane(MetadataFuture& data) {
// check if this plane already exist
std::string name = _type[data.type] + _geom[data.geom] + std::to_string(data.id);
std::string name = std::format(
"{}{}{}", _cygnetType[data.type], _geom[data.geom], data.id
);
if (!data.group.empty()) {
std::string type;
@@ -551,7 +552,9 @@ void IswaManager::createPlane(MetadataFuture& data) {
void IswaManager::createSphere(MetadataFuture& data) {
// check if this sphere already exist
std::string name = _type[data.type] + _geom[data.geom] + std::to_string(data.id);
std::string name = std::format(
"{}{}{}", _cygnetType[data.type], _geom[data.geom], data.id
);
if (!data.group.empty()) {
std::string type = typeid(DataSphere).name();
+1 -1
View File
@@ -116,7 +116,7 @@ private:
void fillCygnetInfo(std::string jsonString);
void registerGroup(std::string groupName, std::string type);
std::map<int, std::string> _type;
std::map<int, std::string> _cygnetType;
std::map<int, std::string> _geom;
std::shared_ptr<ccmc::Kameleon> _kameleon;
@@ -54,8 +54,6 @@
#endif // WIN32
namespace {
constexpr std::string_view _loggerCat = "KameleonVolumeReader";
template <typename T>
T globalAttribute(ccmc::Model&, const std::string&) {
static_assert(sizeof(T) == 0);
@@ -162,21 +162,21 @@ bool BrickManager::buildBrickList(BUFFER_INDEX bufferIndex,
{
// Keep track of number bricks used and number of bricks cached
// (for benchmarking)
int numBricks = 0;
int numCached = 0;
//int numBricks = 0;
//int numCached = 0;
// For every non-zero entry in the request list, assign a texture atlas
// coordinate. For zero entries, signal "no brick" using -1.
for (unsigned int i = 0; i < brickRequest.size(); i++) {
if (brickRequest[i] > 0) {
numBricks++;
//numBricks++;
//INFO("Checking brick " << i);
// If the brick is already in the atlas, keep the coordinate
if (_bricksInPBO[bufferIndex][i] != -1) {
numCached++;
//numCached++;
// Get the corresponding coordinates from index
int x, y, z;
@@ -31,8 +31,8 @@ namespace openspace {
class BrickSelector {
public:
virtual ~BrickSelector() {};
virtual bool initialize() { return true; };
virtual ~BrickSelector() {}
virtual bool initialize() { return true; }
virtual void selectBricks(int timestep, std::vector<int>& bricks) = 0;
};
@@ -96,7 +96,7 @@ bool ErrorHistogramManager::buildFromLeaf(unsigned int bstOffset,
int bstNode = bstOffset;
bool bstRightOnly = true;
unsigned int bstLevel = 0;
//unsigned int bstLevel = 0;
do {
glm::vec3 leafOffset(0.f); // Leaf offset in leaf sized voxels
@@ -173,7 +173,7 @@ bool ErrorHistogramManager::buildFromLeaf(unsigned int bstOffset,
bstRightOnly &= (bstNode % 2 == 0);
bstNode = parentOffset(bstNode, 2);
bstLevel++;
//bstLevel++;
} while (bstNode != -1);
return true;
@@ -177,9 +177,9 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
childSplitType
);
BrickSelection childSelection = bs.splitSpatially(
i % 2,
(i/2) % 2,
i/4,
i % 2 != 0,
(i/2) % 2 != 0,
i/4 != 0,
childBrickIndex,
childSplitType,
childSplitPoints
@@ -152,7 +152,7 @@ bool MultiresVolumeRaycaster::isCameraInside(const RenderData& data,
float divisor = 1.0;
for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) {
if (abs(modelTransform[i][j]) > divisor) {
if (std::abs(modelTransform[i][j]) > divisor) {
divisor = modelTransform[i][j];
}
}
@@ -59,7 +59,7 @@ void ShenBrickSelector::traverseOT(int timestep, unsigned int brickIndex,
int numTimeSteps = _tsp->header().numTimesteps;
for (unsigned int i = 0; i < 8; i++) {
unsigned int child = firstChild + i;
BrickCover cover = coveredBricks.split(i % 2, (i/2) % 2, (i/4));
BrickCover cover = coveredBricks.split(i % 2 != 0, (i/2) % 2 != 0, (i/4) != 0);
selectBricks(timestep, child, child, 0, numTimeSteps, cover, bricks);
}
}
@@ -175,9 +175,9 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks)
BrickSelection::SplitType childSplitType;
float childSplitPoints = splitPoints(childBrickIndex, childSplitType);
BrickSelection childSelection = bs.splitSpatially(
i % 2,
(i / 2) % 2, // abock: this is always 0?
i / 4,
i % 2 != 0,
(i / 2) % 2 != 0, // abock: this is always 0?
i / 4 != 0,
childBrickIndex,
childSplitType,
childSplitPoints
@@ -187,9 +187,9 @@ void TfBrickSelector::selectBricks(int timestep, std::vector<int>& bricks) {
float childSplitPoints = splitPoints(childBrickIndex, childSplitType);
//std::cout << "Splitting spatially" << std::endl;
BrickSelection childSelection = bs.splitSpatially(
i % 2,
(i / 2) % 2, // abock: isn't this always 0?
i / 4,
i % 2 != 0,
(i / 2) % 2 != 0, // abock: isn't this always 0?
i / 4 != 0,
childBrickIndex,
childSplitType,
childSplitPoints
+13 -13
View File
@@ -67,20 +67,20 @@ bool TSP::load() {
return false;
}
if (false) {
if (!calculateSpatialError()) {
LERROR("Could not calculate spatial error");
return false;
}
if (!calculateTemporalError()) {
LERROR("Could not calculate temporal error");
return false;
}
if (!writeCache()) {
LERROR("Could not write cache");
return false;
}
#if 0
if (!calculateSpatialError()) {
LERROR("Could not calculate spatial error");
return false;
}
if (!calculateTemporalError()) {
LERROR("Could not calculate temporal error");
return false;
}
if (!writeCache()) {
LERROR("Could not write cache");
return false;
}
#endif
}
initalizeSSO();
+1 -1
View File
@@ -178,7 +178,7 @@ void Browser::update() {
}
bool Browser::isReady() const {
return _texture.get();
return _texture != nullptr;
}
// Updates the browser size to match the size of the texture
+1 -1
View File
@@ -51,7 +51,7 @@ namespace {
bool hasAttribute(const tinyxml2::XMLElement* element, std::string_view name) {
const std::string n = std::string(name);
return element->FindAttribute(n.c_str());
return element->FindAttribute(n.c_str()) != nullptr;
}
std::string attribute(const tinyxml2::XMLElement* element, std::string_view name) {
@@ -290,7 +290,7 @@ void RenderableEclipseCone::deinitializeGL() {
}
bool RenderableEclipseCone::isReady() const {
return _shader;
return _shader != nullptr;
}
void RenderableEclipseCone::render(const RenderData& data, RendererTasks&) {
+16 -5
View File
@@ -63,6 +63,14 @@ namespace {
openspace::properties::Property::Visibility::AdvancedUser
};
constexpr openspace::properties::Property::PropertyInfo TimeOffsetInfo = {
"TimeOffset",
"Time Offset",
"A time offset, in seconds, added to the simulation time (or Fixed Date if any), "
"at which to compute the rotation.",
openspace::properties::Property::Visibility::User
};
struct [[codegen::Dictionary(SpiceRotation)]] Parameters {
// [[codegen::verbatim(SourceInfo.description)]]
std::string sourceFrame
@@ -80,6 +88,9 @@ namespace {
// [[codegen::verbatim(FixedDateInfo.description)]]
std::optional<std::string> fixedDate
[[codegen::annotation("A time to lock the rotation to")]];
// [[codegen::verbatim(TimeOffsetInfo.description)]]
std::optional<float> timeOffset;
};
#include "spicerotation_codegen.cpp"
} // namespace
@@ -94,6 +105,7 @@ SpiceRotation::SpiceRotation(const ghoul::Dictionary& dictionary)
: _sourceFrame(SourceInfo)
, _destinationFrame(DestinationInfo)
, _fixedDate(FixedDateInfo)
, _timeOffset(TimeOffsetInfo)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
@@ -111,6 +123,9 @@ SpiceRotation::SpiceRotation(const ghoul::Dictionary& dictionary)
_fixedDate = p.fixedDate.value_or(_fixedDate);
addProperty(_fixedDate);
_timeOffset = p.timeOffset.value_or(_timeOffset);
addProperty(_timeOffset);
if (p.timeFrame.has_value()) {
_timeFrame = TimeFrame::createFromDictionary(*p.timeFrame);
addPropertySubOwner(_timeFrame.get());
@@ -127,14 +142,10 @@ glm::dmat3 SpiceRotation::matrix(const UpdateData& data) const {
if (_timeFrame && !_timeFrame->isActive(data.time)) {
return glm::dmat3(1.0);
}
double time = data.time.j2000Seconds();
if (_fixedEphemerisTime.has_value()) {
time = *_fixedEphemerisTime;
}
return SpiceManager::ref().positionTransformMatrix(
_sourceFrame,
_destinationFrame,
time
_fixedEphemerisTime.value_or(data.time.j2000Seconds()) + _timeOffset
);
}
+2
View File
@@ -28,6 +28,7 @@
#include <openspace/scene/rotation.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/scene/timeframe.h>
#include <optional>
@@ -48,6 +49,7 @@ private:
properties::StringProperty _sourceFrame;
properties::StringProperty _destinationFrame;
properties::StringProperty _fixedDate;
properties::FloatProperty _timeOffset;
ghoul::mm_unique_ptr<TimeFrame> _timeFrame;
std::optional<double> _fixedEphemerisTime;
@@ -95,7 +95,7 @@ HorizonsTranslation::HorizonsTranslation(const ghoul::Dictionary& dictionary)
files.cbegin(),
files.cend(),
std::back_inserter(f),
[](const std::filesystem::path& p) { return p.string(); }
[](const std::filesystem::path& path) { return path.string(); }
);
_horizonsFiles = f;
}
+16 -1
View File
@@ -77,6 +77,14 @@ namespace {
openspace::properties::Property::Visibility::User
};
constexpr openspace::properties::Property::PropertyInfo TimeOffsetInfo = {
"TimeOffset",
"Time Offset",
"A time offset, in seconds, added to the simulation time (or Fixed Date if any), "
"at which to compute the translation.",
openspace::properties::Property::Visibility::User
};
struct [[codegen::Dictionary(SpiceTranslation)]] Parameters {
// [[codegen::verbatim(TargetInfo.description)]]
std::variant<std::string, int> target;
@@ -89,6 +97,9 @@ namespace {
// [[codegen::verbatim(FixedDateInfo.description)]]
std::optional<std::string> fixedDate;
// [[codegen::verbatim(TimeOffsetInfo.description)]]
std::optional<float> timeOffset;
};
#include "spicetranslation_codegen.cpp"
} // namespace
@@ -104,6 +115,7 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary)
, _observer(ObserverInfo)
, _frame(FrameInfo, "GALACTIC")
, _fixedDate(FixedDateInfo)
, _timeOffset(TimeOffsetInfo)
, _cachedFrame("GALACTIC")
{
const Parameters p = codegen::bake<Parameters>(dictionary);
@@ -140,6 +152,9 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary)
_fixedDate = p.fixedDate.value_or(_fixedDate);
addProperty(_fixedDate);
_timeOffset = p.timeOffset.value_or(_timeOffset);
addProperty(_timeOffset);
if (std::holds_alternative<std::string>(p.target)) {
_target = std::get<std::string>(p.target);
}
@@ -166,7 +181,7 @@ glm::dvec3 SpiceTranslation::position(const UpdateData& data) const {
_cachedObserver,
_cachedFrame,
{},
_fixedEphemerisTime.value_or(data.time.j2000Seconds()),
_fixedEphemerisTime.value_or(data.time.j2000Seconds()) + _timeOffset,
lightTime
) * 1000.0;
}
@@ -28,6 +28,7 @@
#include <openspace/scene/translation.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <optional>
namespace openspace {
@@ -45,6 +46,7 @@ private:
properties::StringProperty _observer;
properties::StringProperty _frame;
properties::StringProperty _fixedDate;
properties::FloatProperty _timeOffset;
// We are accessing these values every frame and when retrieving a string from the
// StringProperty, it allocates some new memory, which we want to prevent. Until the
@@ -257,7 +257,7 @@ void RenderableShadowCylinder::deinitializeGL() {
}
bool RenderableShadowCylinder::isReady() const {
return _shader;
return _shader != nullptr;
}
void RenderableShadowCylinder::render(const RenderData& data, RendererTasks&) {
-16
View File
@@ -40,22 +40,6 @@ namespace {
openspace::properties::Property::Visibility::AdvancedUser
};
constexpr openspace::properties::Property::PropertyInfo SelectionInfo = {
"SpoutSelection",
"Spout Selection",
"This property displays all available Spout sender on the system. If one them is "
"selected, its value is stored in the 'SpoutName' property, overwriting its "
"previous value.",
openspace::properties::Property::Visibility::AdvancedUser
};
constexpr openspace::properties::Property::PropertyInfo UpdateInfo = {
"UpdateSelection",
"Update Selection",
"If this property is trigged, the 'SpoutSelection' options will be refreshed.",
openspace::properties::Property::Visibility::AdvancedUser
};
struct [[codegen::Dictionary(ScreenSpaceSpout)]] Parameters {
// [[codegen::verbatim(NameInfo.description)]]
std::optional<std::string> spoutName;
+1 -1
View File
@@ -402,7 +402,7 @@ HttpSynchronization::trySyncFromUrl(std::string url) {
originalName.replace_extension().string();
struct zip_t* z = zip_open(source.c_str(), 0, 'r');
const bool is64 = zip_is64(z);
const bool is64 = zip_is64(z) == 1;
zip_close(z);
if (is64) {
+12 -8
View File
@@ -323,13 +323,13 @@ TouchInteraction::TouchInteraction()
glm::vec4(0.2f)
)
, _constTimeDecay_secs(ConstantTimeDecaySecsInfo, 1.75f, 0.1f, 4.f)
, _pinchInputs({ TouchInput(0, 0, 0.f, 0.f, 0.0), TouchInput(0, 0, 0.f, 0.f, 0.0) })
, _vel{ glm::dvec2(0.0), 0.0, 0.0, glm::dvec2(0.0) }
, _sensitivity{ glm::dvec2(0.08, 0.045), 12.0, 2.75, glm::dvec2(0.08, 0.045) }
// Calculated with two vectors with known diff in length, then
// projDiffLength/diffLength.
, _enableDirectManipulation(EnableDirectManipulationInfo, true)
, _directTouchDistanceThreshold(DirectManipulationThresholdInfo, 5.f, 0.f, 10.f)
, _pinchInputs({ TouchInput(0, 0, 0.f, 0.f, 0.0), TouchInput(0, 0, 0.f, 0.f, 0.0) })
, _vel{ glm::dvec2(0.0), 0.0, 0.0, glm::dvec2(0.0) }
, _sensitivity{ glm::dvec2(0.08, 0.045), 12.0, 2.75, glm::dvec2(0.08, 0.045) }
{
addProperty(_disableZoom);
addProperty(_disableRoll);
@@ -796,17 +796,17 @@ void TouchInteraction::computeVelocities(const std::vector<TouchInputHolder>& li
list.begin(),
list.end(),
0.0,
[this, &lastProcessed](double diff, const TouchInputHolder& inputHolder) {
[this, &lastProcessed](double diff, const TouchInputHolder& holder) {
TouchInput point = *std::find_if(
lastProcessed.begin(),
lastProcessed.end(),
[&inputHolder](const TouchInput& input) {
return inputHolder.holdsInput(input);
[&holder](const TouchInput& input) {
return holder.holdsInput(input);
}
);
double res = diff;
float lastAngle = point.angleToPos(_centroid.x, _centroid.y);
float currentAngle = inputHolder.latestInput().angleToPos(
float currentAngle = holder.latestInput().angleToPos(
_centroid.x,
_centroid.y
);
@@ -1210,7 +1210,11 @@ double FrameTimeAverage::averageFrameTime() const {
return 1.0 / 60.0;
}
else {
return std::accumulate(_samples, _samples + _nSamples, 0.0) / (double)(_nSamples);
return std::accumulate(
_samples,
_samples + _nSamples,
0.0
) / static_cast<double>(_nSamples);
}
}
@@ -33,8 +33,6 @@
#include <ghoul/logging/logmanager.h>
namespace {
constexpr std::string_view _loggerCat = "RenderableToyVolume";
constexpr openspace::properties::Property::PropertyInfo SizeInfo = {
"Size",
"Size",
+4 -2
View File
@@ -405,7 +405,9 @@ void VideoPlayer::initializeMpv() {
LINFO("mpv init failed");
}
mpv_opengl_init_params gl_init_params { getOpenGLProcAddress, nullptr };
mpv_opengl_init_params glInitParams;
glInitParams.get_proc_address = getOpenGLProcAddress;
glInitParams.get_proc_address_ctx = nullptr;
int adv = 1; // Use libmpv advanced mode since we will use the update callback
// Decouple mpv from waiting to get the correct fps. Use with flag video-timing-offset
// set to 0
@@ -413,7 +415,7 @@ void VideoPlayer::initializeMpv() {
mpv_render_param params[] = {
{ MPV_RENDER_PARAM_API_TYPE, const_cast<char*>(MPV_RENDER_API_TYPE_OPENGL) },
{ MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &gl_init_params },
{ MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &glInitParams },
{ MPV_RENDER_PARAM_ADVANCED_CONTROL, &adv },
{ MPV_RENDER_PARAM_BLOCK_FOR_TARGET_TIME, &blockTime },
{ MPV_RENDER_PARAM_INVALID, nullptr }
@@ -144,7 +144,6 @@ void GenerateRawVolumeFromFileTask::perform(const ProgressCallback& progressCall
progressCallback(0.5f);
// Write data into volume data structure
int k = 0;
for (const dataloader::Dataset::Entry& entry : data.entries) {
// Get the closest i, j , k voxel that should contain this data
glm::vec3 normalizedPos = (entry.position - _lowerDomainBound) /
@@ -163,7 +162,6 @@ void GenerateRawVolumeFromFileTask::perform(const ProgressCallback& progressCall
size_t index = rawVolume.coordsToIndex(cell);
rawVolume.set(index, value);
k++;
}
progressCallback(0.75f);
+10 -1
View File
@@ -90,7 +90,9 @@ add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper SYSTEM)
mark_as_advanced(CEF_DEBUG_INFO_FLAG USE_ATL USE_OFFICIAL_BUILD_SANDBOX USE_SANDBOX)
if (UNIX)
if (WIN32)
target_compile_options(libcef_dll_wrapper PRIVATE "/W0")
elseif (UNIX)
target_compile_options(libcef_dll_wrapper PRIVATE "-w")
endif ()
@@ -207,6 +209,13 @@ else()
message(STATUS "Setting up WebBrowser CEF helper executable: ${CEF_HELPER_TARGET}")
set_openspace_cef_target_out_dir()
add_executable(${CEF_HELPER_TARGET} ${WEBBROWSER_HELPER_SOURCES})
if (WIN32)
target_compile_options(${CEF_HELPER_TARGET} PRIVATE "/W0")
elseif (UNIX)
target_compile_options(${CEF_HELPER_TARGET} PRIVATE "-w")
endif ()
set_executable_target_properties(${CEF_HELPER_TARGET})
add_dependencies(${CEF_HELPER_TARGET} libcef_dll_wrapper)
# Logical target used to link the libcef library.
@@ -124,6 +124,7 @@ function(run_cef_windows_config CEF_TARGET CEF_ROOT MODULE_PATH)
# Executable target.
add_dependencies(${CEF_TARGET} libcef_dll_wrapper)
target_link_libraries(${CEF_TARGET} PUBLIC libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
include_directories(${CEF_ROOT})
add_dependencies(${CEF_TARGET} libcef_dll_wrapper "${CEF_HELPER_TARGET}")
@@ -25,18 +25,9 @@
#ifndef __OPENSPACE_MODULE_WEBBROWSER___WEBBROWSERAPP___H__
#define __OPENSPACE_MODULE_WEBBROWSER___WEBBROWSERAPP___H__
#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable : 4100)
#endif // _MSC_VER
#include <include/cef_app.h>
#include <include/wrapper/cef_helpers.h>
#ifdef _MSC_VER
#pragma warning (pop)
#endif // _MSC_VER
namespace openspace {
/**
@@ -26,9 +26,27 @@
// reserved. Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wshadow-field"
#pragma clang diagnostic ignored "-Wcomma"
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#endif
#include "include/cef_app.h"
#include "include/webbrowserapp.h"
#ifdef __clang__
#pragma clang diagnostic pop
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic pop
#endif
// Entry point function for all processes.
int main(int argc, char* argv[]) {
// Provide CEF with command-line arguments.
+1 -1
View File
@@ -289,7 +289,7 @@ bool WebRenderHandler::hasContent(int x, int y) {
}
int index = x + _browserBufferSize.x * (_browserBufferSize.y - y - 1);
index = glm::clamp(index, 0, static_cast<int>(_browserBuffer.size() - 1));
return _browserBuffer[index].a;
return _browserBuffer[index].a != 0;
}
}
+1
View File
@@ -389,6 +389,7 @@ set(OPENSPACE_HEADER
${PROJECT_SOURCE_DIR}/include/openspace/util/task.h
${PROJECT_SOURCE_DIR}/include/openspace/util/taskloader.h
${PROJECT_SOURCE_DIR}/include/openspace/util/time.h
${PROJECT_SOURCE_DIR}/include/openspace/util/timeconstants.h
${PROJECT_SOURCE_DIR}/include/openspace/util/timeconversion.h
${PROJECT_SOURCE_DIR}/include/openspace/util/timeline.h
${PROJECT_SOURCE_DIR}/include/openspace/util/timeline.inl
@@ -68,6 +68,8 @@ namespace {
constexpr const char* ActionTitle = "Actions";
constexpr const char* GuiNameKey = "guiName";
constexpr const char* CommandKey = "command";
constexpr const char* ColorKey = "color";
constexpr const char* TextColorKey = "textColor";
// Factory
constexpr const char* MembersKey = "members";
@@ -705,6 +707,12 @@ nlohmann::json DocumentationEngine::generateActionJson() const {
d[GuiNameKey] = action.name;
d[DocumentationKey] = action.documentation;
d[CommandKey] = action.command;
if (action.color.has_value()) {
d[ColorKey] = std::format("{}", action.color);
}
if (action.textColor.has_value()) {
d[TextColorKey] = std::format("{}", action.textColor);
}
res[DataKey].push_back(d);
}
sortJson(res[DataKey], NameKey);
+1 -7
View File
@@ -1036,13 +1036,7 @@ void OpenSpaceEngine::loadFonts() {
}
LDEBUG(std::format("Registering font '{}' with key '{}'", fontName, key));
const bool success = global::fontManager->registerFontPath(key, fontName);
if (!success) {
LERROR(std::format(
"Error registering font '{}' with key '{}'", fontName, key
));
}
global::fontManager->registerFontPath(key, fontName);
}
try {
+24
View File
@@ -88,6 +88,16 @@ struct [[codegen::Dictionary(Action)]] Action {
// not provided, the default value is /
std::optional<std::string> guiPath;
/// This parameter, if specified, will be used as a hint to any potential user
/// interface as a desired background color. This can be used, for example, to
/// visually group similar Actions together
std::optional<glm::vec4> color [[codegen::color()]];
/// This parameter, if specified, will be used as a hint to any potential user
/// interface as a desired text color. This can be used, for example, to visually
/// group similar Actions together
std::optional<glm::vec4> textColor [[codegen::color()]];
// Determines whether the provided command will be executed locally or will be sent to
// connected computers in a cluster or parallel connection environment
std::optional<bool> isLocal;
@@ -115,6 +125,8 @@ struct [[codegen::Dictionary(Action)]] Action {
a.command = std::move(action.command);
a.name = action.name.value_or(a.name);
a.documentation = action.documentation.value_or(a.documentation);
a.color = action.color;
a.textColor = action.textColor;
a.guiPath = action.guiPath.value_or(a.guiPath);
if (!a.guiPath.starts_with('/')) {
throw ghoul::RuntimeError(
@@ -151,6 +163,12 @@ struct [[codegen::Dictionary(Action)]] Action {
res.setValue("Command", action.command);
res.setValue("Name", action.name);
res.setValue("Documentation", action.documentation);
if (action.color.has_value()) {
res.setValue("Color", glm::dvec4(*action.color));
}
if (action.textColor.has_value()) {
res.setValue("TextColor", glm::dvec4(*action.textColor));
}
res.setValue("GuiPath", action.guiPath);
res.setValue("IsLocal", action.isLocal == interaction::Action::IsLocal::Yes);
return res;
@@ -172,6 +190,12 @@ struct [[codegen::Dictionary(Action)]] Action {
d.setValue("Command", a.command);
d.setValue("Name", a.name);
d.setValue("Documentation", a.documentation);
if (a.color.has_value()) {
d.setValue("Color", glm::dvec4(*a.color));
}
if (a.textColor.has_value()) {
d.setValue("TextColor", glm::dvec4(*a.textColor));
}
d.setValue("GuiPath", a.guiPath);
d.setValue("IsLocal", a.isLocal == interaction::Action::IsLocal::Yes);
res.push_back(d);
@@ -30,10 +30,6 @@
#include "keyframerecordinghandler_lua.inl"
namespace {
constexpr std::string_view _loggerCat = "KeyframeRecording";
} // namespace
namespace openspace::interaction {
KeyframeRecordingHandler::KeyframeRecordingHandler()
+1 -1
View File
@@ -72,7 +72,6 @@ namespace {
constexpr std::string_view FrameTypeCameraAscii = "camera";
constexpr std::string_view FrameTypeScriptAscii = "script";
constexpr std::string_view FrameTypeCommentAscii = "#";
constexpr char FrameTypeCameraBinary = 'c';
constexpr char FrameTypeScriptBinary = 's';
@@ -180,6 +179,7 @@ namespace {
template <DataMode mode>
std::optional<FrameType> readFrameType(std::istream&, int) {
static_assert(sizeof(int) == 0, "Unimplemented overload");
return std::nullopt;
}
template <>
+18 -14
View File
@@ -78,9 +78,6 @@ namespace {
openspace::properties::Property::Visibility::Developer
};
const std::string FileExtensionBinary = ".osrec";
const std::string FileExtensionAscii = ".osrectxt";
constexpr std::string_view ScriptReturnPrefix = "return ";
} // namespace
@@ -111,7 +108,7 @@ void SessionRecordingHandler::preSynchronization(double dt) {
if (_state != _lastState) {
using K = CallbackHandle;
using V = StateChangeCallback;
for (const std::pair<const K, V>& it : _stateChangeCallbacks) {
for (const std::pair<K, V>& it : _stateChangeCallbacks) {
it.second();
}
_lastState = _state;
@@ -450,8 +447,8 @@ void SessionRecordingHandler::seek(double recordingTime) {
_timeline.entries.begin(),
_timeline.entries.end(),
recordingTime,
[](double recordingTime, const SessionRecording::Entry& e) {
return recordingTime < e.timestamp;
[](double rt, const SessionRecording::Entry& e) {
return rt < e.timestamp;
}
);
_playback.elapsedTime = recordingTime;
@@ -633,7 +630,9 @@ double SessionRecordingHandler::currentApplicationInterpolationTime() const {
return _playback.saveScreenshots.currentApplicationTime;
}
void SessionRecordingHandler::checkIfScriptUsesScenegraphNode(std::string_view s) const {
void SessionRecordingHandler::checkIfScriptUsesScenegraphNode(
std::string_view script) const
{
auto isolateTermFromQuotes = [](std::string_view s) -> std::string_view {
// Remove any leading spaces
s.remove_prefix(s.find_first_not_of(" "));
@@ -660,26 +659,31 @@ void SessionRecordingHandler::checkIfScriptUsesScenegraphNode(std::string_view s
"NavigationHandler.OrbitalNavigator.Aim"
};
for (std::string_view script : NavScriptsUsingNodes) {
if (navTerm.find(script) != std::string::npos) {
for (std::string_view s : NavScriptsUsingNodes) {
if (navTerm.find(s) != std::string::npos) {
return true;
}
}
return false;
};
if (s.starts_with(ScriptReturnPrefix)) {
s.remove_prefix(ScriptReturnPrefix.length());
if (script.starts_with(ScriptReturnPrefix)) {
script.remove_prefix(ScriptReturnPrefix.length());
}
// This works for both setPropertyValue and setPropertyValueSingle
if (!s.starts_with("openspace.setPropertyValue") || s.find('(') == std::string::npos)
if (!script.starts_with("openspace.setPropertyValue") ||
script.find('(') == std::string::npos)
{
return;
}
std::string_view subjectOfSetProp = isolateTermFromQuotes(s.substr(s.find('(') + 1));
std::string_view subjectOfSetProp = isolateTermFromQuotes(
script.substr(script.find('(') + 1)
);
if (checkForScenegraphNodeAccessNav(subjectOfSetProp)) {
std::string_view navNode = isolateTermFromQuotes(s.substr(s.find(',') + 1));
std::string_view navNode = isolateTermFromQuotes(
script.substr(script.find(',') + 1)
);
if (navNode != "nil") {
auto it = std::find(_loadedNodes.begin(), _loadedNodes.end(), navNode);
if (it == _loadedNodes.end()) {
@@ -37,9 +37,6 @@
namespace {
constexpr std::string_view _loggerCat = "ConvertRecFormatTask";
constexpr std::string_view KeyInFilePath = "InputFilePath";
constexpr std::string_view KeyOutFilePath = "OutputFilePath";
struct [[codegen::Dictionary(ConvertRecFormatTask)]] Parameters {
std::filesystem::path inputFilePath;
std::filesystem::path outputFilePath;
+1 -1
View File
@@ -114,7 +114,7 @@ NavigationState::NavigationState(const nlohmann::json& json) {
position.y = json["position"]["y"].get<double>();
position.z = json["position"]["z"].get<double>();
anchor = json["anchor"];
anchor = json["anchor"].get<std::string>();
if (auto it = json.find("referenceframe"); it != json.end()) {
referenceFrame = it->get<std::string>();
+1 -1
View File
@@ -1044,7 +1044,7 @@ void createCustomProperty<openspace::properties::TriggerProperty>(
TriggerProperty* p = new TriggerProperty(info);
if (onChange.has_value() && !onChange->empty()) {
p->onChange(
[p, script = *onChange]() {
[script = *onChange]() {
using namespace ghoul::lua;
LuaState s;
openspace::global::scriptEngine->initializeLuaState(s);
+1 -1
View File
@@ -242,7 +242,7 @@ namespace {
}
struct zip_t* z = zip_open(source.c_str(), 0, 'r');
const bool is64 = zip_is64(z);
const bool is64 = zip_is64(z) == 1;
zip_close(z);
if (is64) {
+2 -2
View File
@@ -25,7 +25,7 @@
#include <openspace/util/distanceconversion.h>
#include <openspace/util/distanceconstants.h>
#include <openspace/util/timeconversion.h>
#include <openspace/util/timeconstants.h>
#include <ghoul/glm.h>
@@ -101,7 +101,7 @@ std::pair<double, std::string_view> simplifyDistance(double meters,
float convertMasPerYearToMeterPerSecond(float masPerYear, float parallax) {
const double degreeFromMas = 1.0 / 3600000.0;
const double radiusInMeter = (distanceconstants::Parsec * 1000.0) / parallax;
const double perYearToPerSecond = 1.0 / SecondsPerYear;
const double perYearToPerSecond = 1.0 / timeconstants::SecondsPerYear;
const double meterPerSecond =
masPerYear * degreeFromMas * radiusInMeter * perYearToPerSecond;
return static_cast<float>(meterPerSecond);
+2 -2
View File
@@ -485,7 +485,7 @@ std::vector<std::pair<int, std::string>> SpiceManager::spiceBodies(
}
bool SpiceManager::hasValue(int naifId, const std::string& item) const {
return bodfnd_c(naifId, item.c_str());
return bodfnd_c(naifId, item.c_str()) == SPICETRUE;
}
bool SpiceManager::hasValue(const std::string& body, const std::string& item) const {
@@ -515,7 +515,7 @@ bool SpiceManager::hasNaifId(const std::string& body) const {
SpiceInt id = 0;
bods2c_c(body.c_str(), &id, &success);
reset_c();
return success;
return success == SPICETRUE;
}
int SpiceManager::frameId(const std::string& frame) const {
+3 -3
View File
@@ -22,7 +22,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/util/timeconversion.h>
#include <openspace/util/timeconstants.h>
namespace {
@@ -480,7 +480,7 @@ namespace {
* \return The number of seconds in a day
*/
[[codegen::luawrap]] double secondsPerDay() {
return openspace::SecondsPerDay;
return openspace::timeconstants::SecondsPerDay;
}
/**
@@ -490,7 +490,7 @@ namespace {
*/
[[codegen::luawrap]] double secondsPerYear() {
// We could use a call to SPICE here, but the value is a constant anyway
return openspace::SecondsPerYear;
return openspace::timeconstants::SecondsPerYear;
}
#include "time_lua_codegen.cpp"
+10 -10
View File
@@ -49,27 +49,27 @@ namespace {
const double val = seconds / 1e-3;
return { val, TimeUnit::Millisecond };
}
else if (secondsVal <= SecondsPerMinute) {
else if (secondsVal <= timeconstants::SecondsPerMinute) {
return { seconds, TimeUnit::Second };
}
else if (secondsVal <= SecondsPerHour) {
const double val = seconds / SecondsPerMinute;
else if (secondsVal <= timeconstants::SecondsPerHour) {
const double val = seconds / timeconstants::SecondsPerMinute;
return { val, TimeUnit::Minute };
}
else if (secondsVal <= SecondsPerDay) {
const double val = seconds / SecondsPerHour;
else if (secondsVal <= timeconstants::SecondsPerDay) {
const double val = seconds / timeconstants::SecondsPerHour;
return { val, TimeUnit::Hour };
}
else if (secondsVal <= SecondsPerMonth) {
const double val = seconds / SecondsPerDay;
else if (secondsVal <= timeconstants::SecondsPerMonth) {
const double val = seconds / timeconstants::SecondsPerDay;
return { val, TimeUnit::Day };
}
else if (secondsVal <= SecondsPerYear) {
const double val = seconds / SecondsPerMonth;
else if (secondsVal <= timeconstants::SecondsPerYear) {
const double val = seconds / timeconstants::SecondsPerMonth;
return { val, TimeUnit::Month };
}
else {
const double val = seconds / SecondsPerYear;
const double val = seconds / timeconstants::SecondsPerYear;
return { val, TimeUnit::Year };
}
}
@@ -23,16 +23,60 @@
##########################################################################################
function (set_openspace_compile_settings target)
target_compile_features(${target} PUBLIC cxx_std_20)
target_compile_features(${target} PUBLIC cxx_std_23)
set(MSVC_WARNINGS
"/MP" # Multi-threading support
"/W4" # Highest warning level
"/w44062" # missing case label
"/w44165" # 'HRESULT' is being converted to 'bool'
"/w44242" # conversion from 'type1' to 'type2', possible loss of data
"/w44254" # conversion from 'type1' to 'type2', possible loss of data
"/w44263" # member function does not override any base class virtual member function
"/w44265" # class has virtual functions, but destructor is not virtual
"/w44287" # unsigned/negative constant mismatch
"/w44289" # using for-loop variable outside of loop
"/w44296" # expression is always true/false
"/w44437" # dynamic_cast could fail in some contexts
"/w44545" # expression before comma evaluates to a function missing an argument list
"/w44547" # operator before comma has no effect
"/w44548" # operator before comma has no effect
"/w44549" # operator before comma has no effect
"/w44555" # expression has no effect; expected expression with side-effect
"/w44574" # 'identifier' is defined to be '0': did you mean to use '#if identifier'?
"/w44619" # #pragma warning: there is no warning number 'number'
"/w44643" # Forward declaring 'identifier' in namespace std is not permitted
"/w44800" # Implicit conversion from 'type' to bool. Possible information loss
"/w44822" # local class member function does not have a body
"/w44841" # non-standard extension used: compound member designator used in offsetof
"/w44842" # the result of 'offsetof' applied to a type using multiple inheritance is
# not guaranteed to be consistent between compiler releases
"/w44946" # reinterpret_cast used between related classes: 'class1' and 'class2'
"/w44986" # exception specification does not match previous declaration
"/w44987" # nonstandard extension used: 'throw (...)'
"/w45022" # multiple move constructors specified
"/w45023" # multiple move assignment operators specified
"/w45031" # #pragma warning(pop): likely mismatch, popping warning state pushed in
# different file
"/w45032" # detected #pragma warning(push) with no #pragma warning(pop)
"/w45038" # data member 'member1' will be initialized after data member 'member2'
"/w45041" # out-of-line definition for constexpr data is deprecated
"/w45042" # function declarations at block scope cannot be specified 'inline'
"/w45204" # virtual class has non-virtual trivial destructor
"/w45233" # explicit lambda capture 'identifier' is not used
"/w45340" # attribute is ignored in this syntactic position
"/w45243" # using incomplete class 'class-name' can cause potential one definition
# rule violation due to ABI limitation
"/w45245" # unreferenced function with internal linkage has been removed
"/w45249" # 'bitfield' of type 'enumeration_name' has named enumerators with values
# that cannot be represented in the given bit field width of
# 'bitfield_width'.
"/w45258" # explicit capture of 'symbol' is not required for this use
"/w45259" # explicit specialization requires 'template <>'
"/w45262" # implicit fall-through occurs here
"/w45263" # calling 'std::move' on a temporary object prevents copy elision
"/w45264" # 'const' variable is not used
"/w45266" # 'const' qualifier on return type has no effect
"/wd4127" # conditional expression is constant [raised by: websocketpp]
"/wd4201" # nonstandard extension used : nameless struct/union [raised by: GLM]
"/wd5030" # attribute 'attribute' is not recognized [raised by: codegen]
@@ -146,7 +190,12 @@ function (set_openspace_compile_settings target)
"-Wno-deprecated-enum-enum-conversion"
"-Wno-missing-braces"
"-Wno-sign-compare"
"-Wno-suggest-destructor-override"
"-Wno-unknown-attributes"
# This should be removed as soon as https://github.com/g-truc/glm/issues/1349 is
# addressed
"-Wno-defaulted-function-deleted"
)
-7
View File
@@ -41,13 +41,6 @@
// compiler to agree
// NOLINTBEGIN(modernize-use-emplace)
namespace {
std::ostream& operator<<(std::ostream& os, const openspace::Profile& profile) {
os << profile.serialize();
return os;
}
} // namespace openspace
using namespace openspace;
//
-7
View File
@@ -37,13 +37,6 @@
using namespace openspace;
namespace {
std::string stringify(const std::filesystem::path& filename) {
const std::ifstream myfile = std::ifstream(filename);
std::stringstream buffer;
buffer << myfile.rdbuf();
return buffer.str();
}
void validate(std::string_view cfgString) {
const std::filesystem::path schemaDir = absPath("${TESTDIR}/../config/schema");
const std::filesystem::path schema = schemaDir / "sgcteditor.schema.json";
+122 -122
View File
@@ -33,102 +33,102 @@ TEST_CASE("TimeConversion: Simplify Time Round", "[timeconversion]") {
{
std::pair<double, std::string_view> p = simplifyTime(0.0, false);
CHECK(p.first == 0.0);
CHECK(p.second == "seconds");
CHECK(p.second == "Seconds");
}
{
std::pair<double, std::string_view> p = simplifyTime(0.0, true);
CHECK(p.first == 0.0);
CHECK(p.second == "second");
CHECK(p.second == "Second");
}
{
std::pair<double, std::string_view> p = simplifyTime(2e-9, false);
CHECK(p.first == 2.0);
CHECK(p.second == "nanoseconds");
CHECK(p.second == "Nanoseconds");
}
{
std::pair<double, std::string_view> p = simplifyTime(2e-9, true);
CHECK(p.first == 2.0);
CHECK(p.second == "nanosecond");
CHECK(p.second == "Nanosecond");
}
{
std::pair<double, std::string_view> p = simplifyTime(2e-6, false);
CHECK(p.first == 2.0);
CHECK(p.second == "microseconds");
CHECK(p.second == "Microseconds");
}
{
std::pair<double, std::string_view> p = simplifyTime(2e-6, true);
CHECK(p.first == 2.0);
CHECK(p.second == "microsecond");
CHECK(p.second == "Microsecond");
}
{
std::pair<double, std::string_view> p = simplifyTime(2e-3, false);
CHECK(p.first == 2.0);
CHECK(p.second == "milliseconds");
CHECK(p.second == "Milliseconds");
}
{
std::pair<double, std::string_view> p = simplifyTime(2e-3, true);
CHECK(p.first == 2.0);
CHECK(p.second == "millisecond");
CHECK(p.second == "Millisecond");
}
{
std::pair<double, std::string_view> p = simplifyTime(2.0, false);
CHECK(p.first == 2.0);
CHECK(p.second == "seconds");
CHECK(p.second == "Seconds");
}
{
std::pair<double, std::string_view> p = simplifyTime(2.0, true);
CHECK(p.first == 2.0);
CHECK(p.second == "second");
CHECK(p.second == "Second");
}
{
std::pair<double, std::string_view> p = simplifyTime(120.0, false);
CHECK(p.first == 2.0);
CHECK(p.second == "minutes");
CHECK(p.second == "Minutes");
}
{
std::pair<double, std::string_view> p = simplifyTime(120.0, true);
CHECK(p.first == 2.0);
CHECK(p.second == "minute");
CHECK(p.second == "Minute");
}
{
std::pair<double, std::string_view> p = simplifyTime(7200.0, false);
CHECK(p.first == 2.0);
CHECK(p.second == "hours");
CHECK(p.second == "Hours");
}
{
std::pair<double, std::string_view> p = simplifyTime(7200.0, true);
CHECK(p.first == 2.0);
CHECK(p.second == "hour");
CHECK(p.second == "Hour");
}
{
std::pair<double, std::string_view> p = simplifyTime(172800.0, false);
CHECK(p.first == 2.0);
CHECK(p.second == "days");
CHECK(p.second == "Days");
}
{
std::pair<double, std::string_view> p = simplifyTime(172800.0, true);
CHECK(p.first == 2.0);
CHECK(p.second == "day");
CHECK(p.second == "Day");
}
{
std::pair<double, std::string_view> p = simplifyTime(5259492.0, false);
CHECK(p.first == 2.0);
CHECK(p.second == "months");
CHECK(p.second == "Months");
}
{
std::pair<double, std::string_view> p = simplifyTime(5259492.0, true);
CHECK(p.first == 2.0);
CHECK(p.second == "month");
CHECK(p.second == "Month");
}
{
std::pair<double, std::string_view> p = simplifyTime(63113904.0, false);
CHECK(p.first == 2.0);
CHECK(p.second == "years");
CHECK(p.second == "Years");
}
{
std::pair<double, std::string_view> p = simplifyTime(63113904.0, true);
CHECK(p.first == 2.0);
CHECK(p.second == "year");
CHECK(p.second == "Year");
}
}
@@ -136,92 +136,92 @@ TEST_CASE("TimeConversion: Simplify Time Fractional", "[timeconversion]") {
{
std::pair<double, std::string_view> p = simplifyTime(32e-10, false);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "nanoseconds");
CHECK(p.second == "Nanoseconds");
}
{
std::pair<double, std::string_view> p = simplifyTime(32e-10, true);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "nanosecond");
CHECK(p.second == "Nanosecond");
}
{
std::pair<double, std::string_view> p = simplifyTime(32e-7, false);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "microseconds");
CHECK(p.second == "Microseconds");
}
{
std::pair<double, std::string_view> p = simplifyTime(32e-7, true);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "microsecond");
CHECK(p.second == "Microsecond");
}
{
std::pair<double, std::string_view> p = simplifyTime(32e-4, false);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "milliseconds");
CHECK(p.second == "Milliseconds");
}
{
std::pair<double, std::string_view> p = simplifyTime(32e-4, true);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "millisecond");
CHECK(p.second == "Millisecond");
}
{
std::pair<double, std::string_view> p = simplifyTime(3.2, false);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "seconds");
CHECK(p.second == "Seconds");
}
{
std::pair<double, std::string_view> p = simplifyTime(3.2, true);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "second");
CHECK(p.second == "Second");
}
{
std::pair<double, std::string_view> p = simplifyTime(192.0, false);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "minutes");
CHECK(p.second == "Minutes");
}
{
std::pair<double, std::string_view> p = simplifyTime(192.0, true);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "minute");
CHECK(p.second == "Minute");
}
{
std::pair<double, std::string_view> p = simplifyTime(11520.0, false);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "hours");
CHECK(p.second == "Hours");
}
{
std::pair<double, std::string_view> p = simplifyTime(11520.0, true);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "hour");
CHECK(p.second == "Hour");
}
{
std::pair<double, std::string_view> p = simplifyTime(276480.0, false);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "days");
CHECK(p.second == "Days");
}
{
std::pair<double, std::string_view> p = simplifyTime(276480.0, true);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "day");
CHECK(p.second == "Day");
}
{
std::pair<double, std::string_view> p = simplifyTime(8415187.2, false);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "months");
CHECK(p.second == "Months");
}
{
std::pair<double, std::string_view> p = simplifyTime(8415187.2, true);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "month");
CHECK(p.second == "Month");
}
{
std::pair<double, std::string_view> p = simplifyTime(100982246.4, false);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "years");
CHECK(p.second == "Years");
}
{
std::pair<double, std::string_view> p = simplifyTime(100982246.4, true);
CHECK(Catch::Approx(p.first) == 3.2);
CHECK(p.second == "year");
CHECK(p.second == "Year");
}
}
@@ -230,121 +230,121 @@ TEST_CASE("TimeConversion: Split Time Multiple Round", "[timeconversion]") {
std::vector<std::pair<double, std::string_view>> p = splitTime(0.0, false);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 0.0);
CHECK(p[0].second == "seconds");
CHECK(p[0].second == "Seconds");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(0.0, true);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 0.0);
CHECK(p[0].second == "second");
CHECK(p[0].second == "Second");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(2e-9, false);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "nanoseconds");
CHECK(p[0].second == "Nanoseconds");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(2e-9, true);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "nanosecond");
CHECK(p[0].second == "Nanosecond");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(2e-6, false);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "microseconds");
CHECK(p[0].second == "Microseconds");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(2e-6, true);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "microsecond");
CHECK(p[0].second == "Microsecond");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(2e-3, false);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "milliseconds");
CHECK(p[0].second == "Milliseconds");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(2e-3, true);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "millisecond");
CHECK(p[0].second == "Millisecond");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(2.0, false);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "seconds");
CHECK(p[0].second == "Seconds");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(2.0, true);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "second");
CHECK(p[0].second == "Second");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(120.0, false);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "minutes");
CHECK(p[0].second == "Minutes");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(120.0, true);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "minute");
CHECK(p[0].second == "Minute");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(7200.0, false);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "hours");
CHECK(p[0].second == "Hours");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(7200.0, true);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "hour");
CHECK(p[0].second == "Hour");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(172800.0, false);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "days");
CHECK(p[0].second == "Days");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(172800.0, true);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "day");
CHECK(p[0].second == "Day");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(5259492.0, false);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "months");
CHECK(p[0].second == "Months");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(5259492.0, true);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "month");
CHECK(p[0].second == "Month");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(63113904.0, false);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "years");
CHECK(p[0].second == "Years");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(63113904.0, true);
REQUIRE(p.size() == 1);
CHECK(p[0].first == 2.0);
CHECK(p[0].second == "year");
CHECK(p[0].second == "Year");
}
}
@@ -353,216 +353,216 @@ TEST_CASE("TimeConversion: Split Time Fractional", "[timeconversion]") {
std::vector<std::pair<double, std::string_view>> p = splitTime(32e-10, false);
REQUIRE(p.size() == 1);
CHECK(Catch::Approx(p[0].first) == 3.2);
CHECK(p[0].second == "nanoseconds");
CHECK(p[0].second == "Nanoseconds");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(32e-10, true);
REQUIRE(p.size() == 1);
CHECK(Catch::Approx(p[0].first) == 3.2);
CHECK(p[0].second == "nanosecond");
CHECK(p[0].second == "Nanosecond");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(32e-7, false);
REQUIRE(p.size() == 2);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "microseconds");
CHECK(p[0].second == "Microseconds");
CHECK(Catch::Approx(p[1].first) == 200.0);
CHECK(p[1].second == "nanoseconds");
CHECK(p[1].second == "Nanoseconds");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(32e-7, true);
REQUIRE(p.size() == 2);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "microsecond");
CHECK(p[0].second == "Microsecond");
CHECK(Catch::Approx(p[1].first) == 200.0);
CHECK(p[1].second == "nanosecond");
CHECK(p[1].second == "Nanosecond");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(32e-4, false);
REQUIRE(p.size() == 3);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "milliseconds");
CHECK(p[0].second == "Milliseconds");
CHECK(Catch::Approx(p[1].first) == 200.0);
CHECK(p[1].second == "microseconds");
CHECK(p[1].second == "Microseconds");
// This is some floating point inaccuracy
CHECK(p[2].first < 1e-3);
CHECK(p[2].second == "nanoseconds");
CHECK(p[2].second == "Nanoseconds");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(32e-4, true);
REQUIRE(p.size() == 3);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "millisecond");
CHECK(p[0].second == "Millisecond");
CHECK(Catch::Approx(p[1].first) == 200.0);
CHECK(p[1].second == "microsecond");
CHECK(p[1].second == "Microsecond");
// This is some floating point inaccuracy
CHECK(p[2].first < 1e-3);
CHECK(p[2].second == "nanosecond");
CHECK(p[2].second == "Nanosecond");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(3.2, false);
REQUIRE(p.size() == 3);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "seconds");
CHECK(p[0].second == "Seconds");
CHECK(Catch::Approx(p[1].first) == 200.0);
CHECK(p[1].second == "milliseconds");
CHECK(p[1].second == "Milliseconds");
// This is some floating point inaccuracy
CHECK(p[2].first < 1e-3);
CHECK(p[2].second == "nanoseconds");
CHECK(p[2].second == "Nanoseconds");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(3.2, true);
REQUIRE(p.size() == 3);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "second");
CHECK(p[0].second == "Second");
CHECK(Catch::Approx(p[1].first) == 200.0);
CHECK(p[1].second == "millisecond");
CHECK(p[1].second == "Millisecond");
// This is some floating point inaccuracy
CHECK(p[2].first < 1e-3);
CHECK(p[2].second == "nanosecond");
CHECK(p[2].second == "Nanosecond");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(192.0, false);
REQUIRE(p.size() == 2);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "minutes");
CHECK(p[0].second == "Minutes");
CHECK(Catch::Approx(p[1].first) == 12.0);
CHECK(p[1].second == "seconds");
CHECK(p[1].second == "Seconds");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(192.0, true);
REQUIRE(p.size() == 2);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "minute");
CHECK(p[0].second == "Minute");
CHECK(Catch::Approx(p[1].first) == 12.0);
CHECK(p[1].second == "second");
CHECK(p[1].second == "Second");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(11520.0, false);
REQUIRE(p.size() == 2);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "hours");
CHECK(p[0].second == "Hours");
CHECK(Catch::Approx(p[1].first) == 12.0);
CHECK(p[1].second == "minutes");
CHECK(p[1].second == "Minutes");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(11520.0, true);
REQUIRE(p.size() == 2);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "hour");
CHECK(p[0].second == "Hour");
CHECK(Catch::Approx(p[1].first) == 12.0);
CHECK(p[1].second == "minute");
CHECK(p[1].second == "Minute");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(276480.0, false);
REQUIRE(p.size() == 3);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "days");
CHECK(p[0].second == "Days");
CHECK(Catch::Approx(p[1].first) == 4);
CHECK(p[1].second == "hours");
CHECK(p[1].second == "Hours");
CHECK(Catch::Approx(p[2].first) == 48);
CHECK(p[2].second == "minutes");
CHECK(p[2].second == "Minutes");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(276480.0, true);
REQUIRE(p.size() == 3);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "day");
CHECK(p[0].second == "Day");
CHECK(Catch::Approx(p[1].first) == 4);
CHECK(p[1].second == "hour");
CHECK(p[1].second == "Hour");
CHECK(Catch::Approx(p[2].first) == 48);
CHECK(p[2].second == "minute");
CHECK(p[2].second == "Minute");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(8414838.0, false);
REQUIRE(p.size() == 3);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "months");
CHECK(p[0].second == "Months");
CHECK(Catch::Approx(p[1].first) == 6.0);
CHECK(p[1].second == "days");
CHECK(p[1].second == "Days");
CHECK(Catch::Approx(p[2].first) == 2.0);
CHECK(p[2].second == "hours");
CHECK(p[2].second == "Hours");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(8414838.0, true);
REQUIRE(p.size() == 3);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "month");
CHECK(p[0].second == "Month");
CHECK(Catch::Approx(p[1].first) == 6.0);
CHECK(p[1].second == "day");
CHECK(p[1].second == "Day");
CHECK(Catch::Approx(p[2].first) == 2.0);
CHECK(p[2].second == "hour");
CHECK(p[2].second == "Hour");
}
{
std::vector<std::pair<double, std::string_view>> p =
splitTime(100981548.0, false);
REQUIRE(p.size() == 4);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "years");
CHECK(p[0].second == "Years");
CHECK(Catch::Approx(p[1].first) == 2.0);
CHECK(p[1].second == "months");
CHECK(p[1].second == "Months");
CHECK(Catch::Approx(p[2].first) == 12.0);
CHECK(p[2].second == "days");
CHECK(p[2].second == "Days");
CHECK(Catch::Approx(p[3].first) == 4.0);
CHECK(p[3].second == "hours");
CHECK(p[3].second == "Hours");
}
{
std::vector<std::pair<double, std::string_view>> p = splitTime(100981548.0, true);
REQUIRE(p.size() == 4);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "year");
CHECK(p[0].second == "Year");
CHECK(Catch::Approx(p[1].first) == 2.0);
CHECK(p[1].second == "month");
CHECK(p[1].second == "Month");
CHECK(Catch::Approx(p[2].first) == 12.0);
CHECK(p[2].second == "day");
CHECK(p[2].second == "Day");
CHECK(Catch::Approx(p[3].first) == 4.0);
CHECK(p[3].second == "hour");
CHECK(p[3].second == "Hour");
}
{
std::vector<std::pair<double, std::string_view>> p =
splitTime(100981676.388, false);
REQUIRE(p.size() == 9);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "years");
CHECK(p[0].second == "Years");
CHECK(Catch::Approx(p[1].first) == 2.0);
CHECK(p[1].second == "months");
CHECK(p[1].second == "Months");
CHECK(Catch::Approx(p[2].first) == 12.0);
CHECK(p[2].second == "days");
CHECK(p[2].second == "Days");
CHECK(Catch::Approx(p[3].first) == 4.0);
CHECK(p[3].second == "hours");
CHECK(p[3].second == "Hours");
CHECK(Catch::Approx(p[4].first) == 2.0);
CHECK(p[4].second == "minutes");
CHECK(p[4].second == "Minutes");
CHECK(Catch::Approx(p[5].first) == 8.0);
CHECK(p[5].second == "seconds");
CHECK(p[5].second == "Seconds");
CHECK(Catch::Approx(p[6].first) == 387.0);
CHECK(p[6].second == "milliseconds");
CHECK(p[6].second == "Milliseconds");
CHECK(Catch::Approx(p[7].first) == 999.0);
CHECK(p[7].second == "microseconds");
CHECK(p[7].second == "Microseconds");
CHECK(Catch::Approx(p[8].first) == 996.54293059);
CHECK(p[8].second == "nanoseconds");
CHECK(p[8].second == "Nanoseconds");
}
{
std::vector<std::pair<double, std::string_view>> p =
splitTime(100981676.388, true);
REQUIRE(p.size() == 9);
CHECK(Catch::Approx(p[0].first) == 3.0);
CHECK(p[0].second == "year");
CHECK(p[0].second == "Year");
CHECK(Catch::Approx(p[1].first) == 2.0);
CHECK(p[1].second == "month");
CHECK(p[1].second == "Month");
CHECK(Catch::Approx(p[2].first) == 12.0);
CHECK(p[2].second == "day");
CHECK(p[2].second == "Day");
CHECK(Catch::Approx(p[3].first) == 4.0);
CHECK(p[3].second == "hour");
CHECK(p[3].second == "Hour");
CHECK(Catch::Approx(p[4].first) == 2.0);
CHECK(p[4].second == "minute");
CHECK(p[4].second == "Minute");
CHECK(Catch::Approx(p[5].first) == 8.0);
CHECK(p[5].second == "second");
CHECK(p[5].second == "Second");
CHECK(Catch::Approx(p[6].first) == 387.0);
CHECK(p[6].second == "millisecond");
CHECK(p[6].second == "Millisecond");
CHECK(Catch::Approx(p[7].first) == 999.0);
CHECK(p[7].second == "microsecond");
CHECK(p[7].second == "Microsecond");
CHECK(Catch::Approx(p[8].first) == 996.54293059);
CHECK(p[8].second == "nanosecond");
CHECK(p[8].second == "Nanosecond");
}
}