mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 10:40:09 -06:00
Merge branch 'master' into feature/general-performance
# Conflicts: # apps/OpenSpace/main.cpp # modules/server/src/topics/timetopic.cpp
This commit is contained in:
@@ -678,22 +678,21 @@ void mainDecodeFun(const std::vector<std::byte>& data, unsigned int) {
|
||||
|
||||
|
||||
|
||||
void mainLogCallback(Log::Level level, const char* message) {
|
||||
void mainLogCallback(Log::Level level, std::string_view message) {
|
||||
ZoneScoped
|
||||
|
||||
std::string_view msg = message;
|
||||
switch (level) {
|
||||
case Log::Level::Debug:
|
||||
LDEBUGC("SGCT", msg);
|
||||
LDEBUGC("SGCT", message);
|
||||
break;
|
||||
case Log::Level::Info:
|
||||
LINFOC("SGCT", msg);
|
||||
LINFOC("SGCT", message);
|
||||
break;
|
||||
case Log::Level::Warning:
|
||||
LWARNINGC("SGCT", msg);
|
||||
LWARNINGC("SGCT", message);
|
||||
break;
|
||||
case Log::Level::Error:
|
||||
LERRORC("SGCT", msg);
|
||||
LERRORC("SGCT", message);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ asset.require('./static_server')
|
||||
local guiCustomization = asset.require('customization/gui')
|
||||
|
||||
-- Select which commit hashes to use for the frontend and backend
|
||||
local frontendHash = "6673d083bf2629502ce7f809610509f29ad444b7"
|
||||
local frontendHash = "e520f14d3fffc915b7b900f4fc6d888070f458c4"
|
||||
local dataProvider = "data.openspaceproject.com/files/webgui"
|
||||
|
||||
local frontend = asset.syncedResource({
|
||||
|
||||
@@ -40,18 +40,18 @@ enum class Type : uint32_t {
|
||||
};
|
||||
|
||||
struct CameraKeyframe {
|
||||
CameraKeyframe() {}
|
||||
CameraKeyframe(const std::vector<char> &buffer) {
|
||||
CameraKeyframe() = default;
|
||||
CameraKeyframe(const std::vector<char>& buffer) {
|
||||
deserialize(buffer);
|
||||
}
|
||||
|
||||
glm::dvec3 _position = glm::dvec3(0.0);
|
||||
glm::dquat _rotation = glm::dquat(1.0, 0.0, 0.0, 0.0);
|
||||
bool _followNodeRotation;
|
||||
bool _followNodeRotation = false;
|
||||
std::string _focusNode;
|
||||
float _scale;
|
||||
float _scale = 0.f;
|
||||
|
||||
double _timestamp;
|
||||
double _timestamp = 0.0;
|
||||
|
||||
void serialize(std::vector<char> &buffer) const {
|
||||
// Add position
|
||||
@@ -104,28 +104,28 @@ struct CameraKeyframe {
|
||||
);
|
||||
};
|
||||
|
||||
size_t deserialize(const std::vector<char> &buffer, size_t offset = 0) {
|
||||
size_t deserialize(const std::vector<char>& buffer, size_t offset = 0) {
|
||||
int size = 0;
|
||||
|
||||
// Position
|
||||
size = sizeof(_position);
|
||||
memcpy(&_position, buffer.data() + offset, size);
|
||||
std::memcpy(&_position, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
// Orientation
|
||||
size = sizeof(_rotation);
|
||||
memcpy(&_rotation, buffer.data() + offset, size);
|
||||
std::memcpy(&_rotation, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
// Follow focus node rotation?
|
||||
size = sizeof(_followNodeRotation);
|
||||
memcpy(&_followNodeRotation, buffer.data() + offset, size);
|
||||
std::memcpy(&_followNodeRotation, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
// Focus node
|
||||
int nodeNameLength;
|
||||
size = sizeof(int);
|
||||
memcpy(&nodeNameLength, buffer.data() + offset, size);
|
||||
std::memcpy(&nodeNameLength, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
size = nodeNameLength;
|
||||
_focusNode = std::string(buffer.data() + offset, buffer.data() + offset + size);
|
||||
@@ -133,29 +133,20 @@ struct CameraKeyframe {
|
||||
|
||||
// Scale
|
||||
size = sizeof(_scale);
|
||||
memcpy(&_scale, buffer.data() + offset, size);
|
||||
std::memcpy(&_scale, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
// Timestamp
|
||||
size = sizeof(_timestamp);
|
||||
memcpy(&_timestamp, buffer.data() + offset, size);
|
||||
std::memcpy(&_timestamp, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
return offset;
|
||||
};
|
||||
|
||||
void write(std::ostream& out) const {
|
||||
// Write position
|
||||
out.write(
|
||||
reinterpret_cast<const char*>(&_position),
|
||||
sizeof(_position)
|
||||
);
|
||||
|
||||
// Write orientation
|
||||
out.write(
|
||||
reinterpret_cast<const char*>(&_rotation),
|
||||
sizeof(_rotation)
|
||||
);
|
||||
out.write(reinterpret_cast<const char*>(&_position), sizeof(_position));
|
||||
out.write(reinterpret_cast<const char*>(&_rotation), sizeof(_rotation));
|
||||
|
||||
// Write follow focus node rotation?
|
||||
out.write(
|
||||
@@ -166,88 +157,58 @@ struct CameraKeyframe {
|
||||
int nodeNameLength = static_cast<int>(_focusNode.size());
|
||||
|
||||
// Write focus node
|
||||
out.write(
|
||||
reinterpret_cast<const char*>(&nodeNameLength),
|
||||
sizeof(nodeNameLength)
|
||||
);
|
||||
out.write(
|
||||
_focusNode.c_str(),
|
||||
_focusNode.size()
|
||||
);
|
||||
out.write(reinterpret_cast<const char*>(&nodeNameLength), sizeof(nodeNameLength));
|
||||
out.write(_focusNode.c_str(), _focusNode.size());
|
||||
|
||||
//Write scale
|
||||
out.write(
|
||||
reinterpret_cast<const char*>(&_scale),
|
||||
sizeof(_scale)
|
||||
);
|
||||
// Write scale
|
||||
out.write(reinterpret_cast<const char*>(&_scale), sizeof(_scale));
|
||||
|
||||
// Write timestamp
|
||||
out.write(
|
||||
reinterpret_cast<const char*>(&_timestamp),
|
||||
sizeof(_timestamp)
|
||||
);
|
||||
out.write(reinterpret_cast<const char*>(&_timestamp), sizeof(_timestamp));
|
||||
};
|
||||
|
||||
void read(std::istream* in) {
|
||||
// Read position
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&_position),
|
||||
sizeof(_position)
|
||||
);
|
||||
in->read(reinterpret_cast<char*>(&_position), sizeof(_position));
|
||||
|
||||
// Read orientation
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&_rotation),
|
||||
sizeof(_rotation)
|
||||
);
|
||||
in->read(reinterpret_cast<char*>(&_rotation), sizeof(_rotation));
|
||||
|
||||
// Read follow focus node rotation
|
||||
unsigned char b;
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&b),
|
||||
sizeof(unsigned char)
|
||||
);
|
||||
in->read(reinterpret_cast<char*>(&b), sizeof(unsigned char));
|
||||
_followNodeRotation = (b == 1);
|
||||
|
||||
// Read focus node
|
||||
int nodeNameLength = static_cast<int>(_focusNode.size());
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&nodeNameLength),
|
||||
sizeof(nodeNameLength)
|
||||
);
|
||||
std::vector<char> temp(nodeNameLength + 1);
|
||||
in->read(reinterpret_cast<char*>(&nodeNameLength), sizeof(nodeNameLength));
|
||||
std::vector<char> temp(static_cast<size_t>(nodeNameLength) + 1);
|
||||
in->read(temp.data(), nodeNameLength);
|
||||
|
||||
temp[nodeNameLength] = '\0';
|
||||
_focusNode = temp.data();
|
||||
|
||||
// Read scale
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&_scale),
|
||||
sizeof(_scale)
|
||||
);
|
||||
in->read(reinterpret_cast<char*>(&_scale), sizeof(_scale));
|
||||
|
||||
// Read timestamp
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&_timestamp),
|
||||
sizeof(_timestamp)
|
||||
);
|
||||
in->read(reinterpret_cast<char*>(&_timestamp), sizeof(_timestamp));
|
||||
};
|
||||
};
|
||||
|
||||
struct TimeKeyframe {
|
||||
TimeKeyframe() {}
|
||||
TimeKeyframe(const std::vector<char> &buffer) {
|
||||
TimeKeyframe() = default;
|
||||
TimeKeyframe(const std::vector<char>& buffer) {
|
||||
deserialize(buffer);
|
||||
}
|
||||
|
||||
double _time;
|
||||
double _dt;
|
||||
bool _paused;
|
||||
bool _requiresTimeJump;
|
||||
double _timestamp;
|
||||
double _time = 0.0;
|
||||
double _dt = 0.0;
|
||||
bool _paused = false;
|
||||
bool _requiresTimeJump = false;
|
||||
double _timestamp = 0.0;
|
||||
|
||||
void serialize(std::vector<char> &buffer) const {
|
||||
void serialize(std::vector<char>& buffer) const {
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<const char*>(this),
|
||||
@@ -255,37 +216,31 @@ struct TimeKeyframe {
|
||||
);
|
||||
};
|
||||
|
||||
size_t deserialize(const std::vector<char> &buffer, size_t offset = 0){
|
||||
size_t deserialize(const std::vector<char>& buffer, size_t offset = 0) {
|
||||
*this = *reinterpret_cast<const TimeKeyframe*>(buffer.data() + offset);
|
||||
offset += sizeof(TimeKeyframe);
|
||||
return offset;
|
||||
};
|
||||
|
||||
void write(std::ostream* out) const {
|
||||
out->write(
|
||||
reinterpret_cast<const char*>(this),
|
||||
sizeof(TimeKeyframe)
|
||||
);
|
||||
out->write(reinterpret_cast<const char*>(this), sizeof(TimeKeyframe));
|
||||
};
|
||||
|
||||
void read(std::istream* in) {
|
||||
in->read(
|
||||
reinterpret_cast<char*>(this),
|
||||
sizeof(TimeKeyframe)
|
||||
);
|
||||
in->read(reinterpret_cast<char*>(this), sizeof(TimeKeyframe));
|
||||
};
|
||||
};
|
||||
|
||||
struct TimeTimeline {
|
||||
TimeTimeline() {}
|
||||
TimeTimeline(const std::vector<char> &buffer) {
|
||||
TimeTimeline() = default;
|
||||
TimeTimeline(const std::vector<char>& buffer) {
|
||||
deserialize(buffer);
|
||||
}
|
||||
|
||||
bool _clear = true;
|
||||
std::vector<TimeKeyframe> _keyframes;
|
||||
|
||||
void serialize(std::vector<char> &buffer) const {
|
||||
void serialize(std::vector<char>& buffer) const {
|
||||
buffer.insert(
|
||||
buffer.end(),
|
||||
reinterpret_cast<const char*>(&_clear),
|
||||
@@ -298,77 +253,65 @@ struct TimeTimeline {
|
||||
reinterpret_cast<const char*>(&nKeyframes),
|
||||
reinterpret_cast<const char*>(&nKeyframes) + sizeof(int64_t)
|
||||
);
|
||||
for (const auto& k : _keyframes) {
|
||||
for (const TimeKeyframe& k : _keyframes) {
|
||||
k.serialize(buffer);
|
||||
}
|
||||
};
|
||||
|
||||
size_t deserialize(const std::vector<char> &buffer, size_t offset = 0) {
|
||||
size_t deserialize(const std::vector<char>& buffer, size_t offset = 0) {
|
||||
int size = 0;
|
||||
|
||||
size = sizeof(_clear);
|
||||
memcpy(&_clear, buffer.data() + offset, size);
|
||||
std::memcpy(&_clear, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
int64_t nKeyframes = _keyframes.size();
|
||||
size = sizeof(nKeyframes);
|
||||
memcpy(&nKeyframes, buffer.data() + offset, size);
|
||||
std::memcpy(&nKeyframes, buffer.data() + offset, size);
|
||||
offset += size;
|
||||
|
||||
_keyframes.resize(nKeyframes);
|
||||
for (auto& k : _keyframes) {
|
||||
for (TimeKeyframe& k : _keyframes) {
|
||||
offset = k.deserialize(buffer, offset);
|
||||
}
|
||||
return offset;
|
||||
};
|
||||
|
||||
void write(std::ostream* out) const {
|
||||
out->write(
|
||||
reinterpret_cast<const char*>(&_clear),
|
||||
sizeof(bool)
|
||||
);
|
||||
out->write(reinterpret_cast<const char*>(&_clear), sizeof(bool));
|
||||
|
||||
int64_t nKeyframes = _keyframes.size();
|
||||
out->write(
|
||||
reinterpret_cast<const char*>(&nKeyframes),
|
||||
sizeof(int64_t)
|
||||
);
|
||||
for (const auto& k : _keyframes) {
|
||||
out->write(reinterpret_cast<const char*>(&nKeyframes), sizeof(int64_t));
|
||||
for (const TimeKeyframe& k : _keyframes) {
|
||||
k.write(out);
|
||||
}
|
||||
};
|
||||
|
||||
void read(std::istream* in) {
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&_clear),
|
||||
sizeof(bool)
|
||||
);
|
||||
in->read(reinterpret_cast<char*>(&_clear), sizeof(bool));
|
||||
|
||||
int64_t nKeyframes = _keyframes.size();
|
||||
in->read(
|
||||
reinterpret_cast<char*>(&nKeyframes),
|
||||
sizeof(int64_t)
|
||||
);
|
||||
for (auto& k : _keyframes) {
|
||||
in->read(reinterpret_cast<char*>(&nKeyframes), sizeof(int64_t));
|
||||
for (TimeKeyframe& k : _keyframes) {
|
||||
k.read(in);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
struct ScriptMessage {
|
||||
ScriptMessage() {}
|
||||
ScriptMessage(const std::vector<char> &buffer) {
|
||||
ScriptMessage() = default;
|
||||
ScriptMessage(const std::vector<char>& buffer) {
|
||||
deserialize(buffer);
|
||||
}
|
||||
|
||||
std::string _script;
|
||||
double _timestamp;
|
||||
double _timestamp = 0.0;
|
||||
|
||||
void serialize(std::vector<char> &buffer) const {
|
||||
void serialize(std::vector<char>& buffer) const {
|
||||
buffer.insert(buffer.end(), _script.begin(), _script.end());
|
||||
};
|
||||
|
||||
void deserialize(const std::vector<char> &buffer) {
|
||||
void deserialize(const std::vector<char>& buffer) {
|
||||
_script.assign(buffer.begin(), buffer.end());
|
||||
};
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
openspace.globebrowsing.documentation = {
|
||||
{
|
||||
Name = "createTemporalGibsGdalXml",
|
||||
Arguments = "string, string, string, string, string, string",
|
||||
Arguments = "string, string, string, string, string, string, [string]",
|
||||
Documentation =
|
||||
"Creates an XML configuration for a temporal GIBS dataset." ..
|
||||
"Arguments are: Name, Start date, end date, time resolution, time format," ..
|
||||
"resolution, file format. For all specifications, see " ..
|
||||
"resolution, file format. The last parameter is the temporal format and " ..
|
||||
"defaults to YYYY-MM-DD. For all specifications, see " ..
|
||||
"https://wiki.earthdata.nasa.gov/display/GIBS/GIBS+Available+Imagery+Products" ..
|
||||
"Usage:" ..
|
||||
"openspace.globebrowsing.addLayer(" ..
|
||||
@@ -115,13 +116,14 @@ openspace.globebrowsing.addGibsLayer = function(layer, resolution, format, start
|
||||
openspace.globebrowsing.addLayer('Earth', 'ColorLayers', { Identifier = layer, Type = "TemporalTileLayer", FilePath = xml })
|
||||
end
|
||||
|
||||
openspace.globebrowsing.createTemporalGibsGdalXml = function (layerName, startDate, endDate, timeResolution, resolution, format)
|
||||
openspace.globebrowsing.createTemporalGibsGdalXml = function (layerName, startDate, endDate, timeResolution, resolution, format, temporalFormat)
|
||||
temporalFormat = temporalFormat or 'YYYY-MM-DD'
|
||||
temporalTemplate =
|
||||
"<OpenSpaceTemporalGDALDataset>" ..
|
||||
"<OpenSpaceTimeStart>" .. startDate .. "</OpenSpaceTimeStart>" ..
|
||||
"<OpenSpaceTimeEnd>" .. endDate .. "</OpenSpaceTimeEnd>" ..
|
||||
"<OpenSpaceTimeResolution>" .. timeResolution .. "</OpenSpaceTimeResolution>" ..
|
||||
"<OpenSpaceTimeIdFormat>YYYY-MM-DD</OpenSpaceTimeIdFormat>" ..
|
||||
"<OpenSpaceTimeIdFormat>" .. temporalFormat .. "</OpenSpaceTimeIdFormat>" ..
|
||||
openspace.globebrowsing.createGibsGdalXml(layerName, "${OpenSpaceTimeId}", resolution, format) ..
|
||||
"</OpenSpaceTemporalGDALDataset>"
|
||||
return temporalTemplate
|
||||
|
||||
@@ -31,6 +31,7 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guiassetcomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guicomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guifilepathcomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guigibscomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guiglobebrowsingcomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guihelpcomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guijoystickcomponent.h
|
||||
@@ -51,6 +52,7 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guiassetcomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guicomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guifilepathcomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guigibscomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guiglobebrowsingcomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guihelpcomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guijoystickcomponent.cpp
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <modules/imgui/include/guiassetcomponent.h>
|
||||
#include <modules/imgui/include/guifilepathcomponent.h>
|
||||
#include <modules/imgui/include/guigibscomponent.h>
|
||||
#include <modules/imgui/include/guiglobebrowsingcomponent.h>
|
||||
#include <modules/imgui/include/guihelpcomponent.h>
|
||||
#include <modules/imgui/include/guiiswacomponent.h>
|
||||
@@ -63,7 +64,7 @@ namespace openspace::gui {
|
||||
|
||||
namespace detail {
|
||||
constexpr int nComponents() {
|
||||
const int nRegularComponents = 16;
|
||||
const int nRegularComponents = 17;
|
||||
int totalComponents = nRegularComponents;
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
@@ -105,6 +106,7 @@ public:
|
||||
GuiHelpComponent _help;
|
||||
GuiFilePathComponent _filePath;
|
||||
GuiAssetComponent _asset;
|
||||
GuiGIBSComponent _gibs;
|
||||
GuiGlobeBrowsingComponent _globeBrowsing;
|
||||
|
||||
GuiPropertyComponent _globalProperty;
|
||||
@@ -144,6 +146,7 @@ private:
|
||||
&_spaceTime,
|
||||
&_mission,
|
||||
&_parallel,
|
||||
&_gibs,
|
||||
&_globeBrowsing,
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
&_iswa,
|
||||
|
||||
@@ -22,36 +22,21 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_SERVER___DELTA_TIME_STEPS_TOPIC___H__
|
||||
#define __OPENSPACE_MODULE_SERVER___DELTA_TIME_STEPS_TOPIC___H__
|
||||
#ifndef __OPENSPACE_MODULE_IMGUI___GUIGIBSCOMPONENT___H__
|
||||
#define __OPENSPACE_MODULE_IMGUI___GUIGIBSCOMPONENT___H__
|
||||
|
||||
#include <modules/server/include/topics/topic.h>
|
||||
#include <optional>
|
||||
#include <modules/imgui/include/guicomponent.h>
|
||||
|
||||
namespace openspace {
|
||||
#include <string>
|
||||
|
||||
class DeltaTimeStepsTopic : public Topic {
|
||||
namespace openspace::gui {
|
||||
|
||||
class GuiGIBSComponent : public GuiComponent {
|
||||
public:
|
||||
DeltaTimeStepsTopic();
|
||||
virtual ~DeltaTimeStepsTopic();
|
||||
|
||||
void handleJson(const nlohmann::json& json) override;
|
||||
bool isDone() const override;
|
||||
|
||||
private:
|
||||
const int UnsetOnChangeHandle = -1;
|
||||
|
||||
bool dataHasChanged();
|
||||
void sendDeltaTimesData();
|
||||
|
||||
int _deltaTimeCallbackHandle = UnsetOnChangeHandle;
|
||||
int _deltaTimesListCallbackHandle = UnsetOnChangeHandle;
|
||||
bool _isDone = false;
|
||||
|
||||
std::optional<double> _lastNextDeltaTime = std::nullopt;
|
||||
std::optional<double> _lastPrevDeltaTime = std::nullopt;
|
||||
GuiGIBSComponent();
|
||||
void render() override;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
} // namespace openspace::gui
|
||||
|
||||
#endif // __OPENSPACE_MODULE_SERVER___DELTA_TIME_STEPS_TOPIC___H__
|
||||
#endif // __OPENSPACE_MODULE_IMGUI___GUIGIBSCOMPONENT___H__
|
||||
134
modules/imgui/src/guigibscomponent.cpp
Normal file
134
modules/imgui/src/guigibscomponent.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/imgui/include/guigibscomponent.h>
|
||||
|
||||
#include <modules/imgui/include/imgui_include.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <array>
|
||||
#pragma optimize ("", off)
|
||||
namespace {
|
||||
const ImVec2 WindowSize = ImVec2(350, 500);
|
||||
} // namespace
|
||||
|
||||
namespace openspace::gui {
|
||||
|
||||
GuiGIBSComponent::GuiGIBSComponent()
|
||||
: GuiComponent("GIBS", "GIBS")
|
||||
{}
|
||||
|
||||
void GuiGIBSComponent::render() {
|
||||
ImGui::SetNextWindowCollapsed(_isCollapsed);
|
||||
bool e = _isEnabled;
|
||||
ImGui::Begin("GIBS", &e, WindowSize, 0.5f);
|
||||
_isEnabled = e;
|
||||
_isCollapsed = ImGui::IsWindowCollapsed();
|
||||
|
||||
ImGui::Text("%s", "GIBS Layers");
|
||||
ImGui::Text("%s", "Find the information on the GIBS layer page at:");
|
||||
ImGui::Text(
|
||||
"%s",
|
||||
"https://wiki.earthdata.nasa.gov/display/GIBS/GIBS+Available+Imagery+Products"
|
||||
);
|
||||
ImGui::Separator();
|
||||
|
||||
static std::array<char, 256> LayerBuffer;
|
||||
ImGui::InputText("Layer Name", LayerBuffer.data(), LayerBuffer.size());
|
||||
|
||||
static std::array<char, 64> StartDateBuffer;
|
||||
ImGui::InputText("Start Date", StartDateBuffer.data(), StartDateBuffer.size());
|
||||
|
||||
static std::array<char, 64> EndDateBuffer = { "Yesterday" };
|
||||
ImGui::InputText("End Date", EndDateBuffer.data(), EndDateBuffer.size());
|
||||
|
||||
static std::array<char, 64> TemporalResolutionBuffer = { "1d" };
|
||||
ImGui::InputText(
|
||||
"Temporal Resolution",
|
||||
TemporalResolutionBuffer.data(),
|
||||
TemporalResolutionBuffer.size()
|
||||
);
|
||||
|
||||
//static std::array<char, 64> TemporalFormatBuffer;
|
||||
// @TODO Replace with dropdown menu
|
||||
constexpr std::array<const char*, 5> TemporalFormats = {
|
||||
// @FRAGILE: Synchronized with tileprovider.cpp `from_string` method
|
||||
"YYYY-MM-DD",
|
||||
"YYYY-MM-DDThh:mm:ssZ",
|
||||
"YYYY-MM-DDThh_mm_ssZ",
|
||||
"YYYYMMDD_hhmmss",
|
||||
"YYYYMMDD_hhmm"
|
||||
};
|
||||
static const char* currentTemporalFormat = "YYYY-MM-DD";
|
||||
if (ImGui::BeginCombo("##Temporal Format", currentTemporalFormat)) {
|
||||
for (const char* f : TemporalFormats) {
|
||||
bool isSelected = (f == currentTemporalFormat);
|
||||
if (ImGui::Selectable(f, &isSelected)) {
|
||||
currentTemporalFormat = f;
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
static std::array<char, 64> ImageResolutionBuffer = { "250m" };
|
||||
ImGui::InputText(
|
||||
"Image Resolution",
|
||||
ImageResolutionBuffer.data(),
|
||||
ImageResolutionBuffer.size()
|
||||
);
|
||||
|
||||
static std::array<char, 64> ImageFormatBuffer = { "png" };
|
||||
ImGui::InputText("Image Format", ImageFormatBuffer.data(), ImageFormatBuffer.size());
|
||||
|
||||
if (ImGui::Button("Add Layer")) {
|
||||
std::string layer = std::string(LayerBuffer.data());
|
||||
std::string startDate = std::string(StartDateBuffer.data());
|
||||
std::string endDate = std::string(EndDateBuffer.data());
|
||||
std::string temporalRes = std::string(TemporalResolutionBuffer.data());
|
||||
std::string temporalFormat = std::string(currentTemporalFormat);
|
||||
std::string imageRes = std::string(ImageResolutionBuffer.data());
|
||||
std::string imageFormat = std::string(ImageFormatBuffer.data());
|
||||
|
||||
std::string xmlFunc = fmt::format(
|
||||
"openspace.globebrowsing.createTemporalGibsGdalXml("
|
||||
"'{}', '{}', '{}', '{}', '{}', '{}', '{}')",
|
||||
layer, startDate, endDate, temporalRes, imageRes, imageFormat, temporalFormat
|
||||
);
|
||||
|
||||
std::string script = fmt::format(
|
||||
"openspace.globebrowsing.addLayer('Earth', 'ColorLayers', {{ "
|
||||
"Identifier = '{}', Enabled = true, Type = 'TemporalTileLayer', "
|
||||
"FilePath = {} }})",
|
||||
layer, xmlFunc
|
||||
);
|
||||
global::scriptEngine.queueScript(
|
||||
script,
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
} // namespace openspace::gui
|
||||
@@ -33,7 +33,6 @@ set(HEADER_FILES
|
||||
include/serverinterface.h
|
||||
include/topics/authorizationtopic.h
|
||||
include/topics/bouncetopic.h
|
||||
include/topics/deltatimestepstopic.h
|
||||
include/topics/documentationtopic.h
|
||||
include/topics/flightcontrollertopic.h
|
||||
include/topics/getpropertytopic.h
|
||||
@@ -57,7 +56,6 @@ set(SOURCE_FILES
|
||||
src/serverinterface.cpp
|
||||
src/topics/authorizationtopic.cpp
|
||||
src/topics/bouncetopic.cpp
|
||||
src/topics/deltatimestepstopic.cpp
|
||||
src/topics/documentationtopic.cpp
|
||||
src/topics/flightcontrollertopic.cpp
|
||||
src/topics/getpropertytopic.cpp
|
||||
|
||||
@@ -41,16 +41,21 @@ public:
|
||||
private:
|
||||
const int UnsetOnChangeHandle = -1;
|
||||
|
||||
const nlohmann::json getNextPrevDeltaTimeStepJson();
|
||||
|
||||
void sendCurrentTime();
|
||||
void sendFullTimeData();
|
||||
void sendDeltaTimeSteps();
|
||||
|
||||
int _timeCallbackHandle = UnsetOnChangeHandle;
|
||||
int _deltaTimeCallbackHandle = UnsetOnChangeHandle;
|
||||
int _deltaTimeStepsCallbackHandle = UnsetOnChangeHandle;
|
||||
bool _isDone = false;
|
||||
std::chrono::system_clock::time_point _lastUpdateTime;
|
||||
|
||||
bool _lastPauseState = false;
|
||||
double _lastTargetDeltaTime = 0.0;
|
||||
std::vector<double> _lastDeltaTimeSteps;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <modules/server/include/topics/authorizationtopic.h>
|
||||
#include <modules/server/include/topics/bouncetopic.h>
|
||||
#include <modules/server/include/topics/deltatimestepstopic.h>
|
||||
#include <modules/server/include/topics/documentationtopic.h>
|
||||
#include <modules/server/include/topics/flightcontrollertopic.h>
|
||||
#include <modules/server/include/topics/getpropertytopic.h>
|
||||
@@ -57,7 +56,6 @@ namespace {
|
||||
|
||||
constexpr const char* VersionTopicKey = "version";
|
||||
constexpr const char* AuthenticationTopicKey = "authorize";
|
||||
constexpr const char* DeltaTimeStepsTopicKey = "deltatimesteps";
|
||||
constexpr const char* DocumentationTopicKey = "documentation";
|
||||
constexpr const char* GetPropertyTopicKey = "get";
|
||||
constexpr const char* LuaScriptTopicKey = "luascript";
|
||||
@@ -97,7 +95,6 @@ Connection::Connection(std::unique_ptr<ghoul::io::Socket> s,
|
||||
);
|
||||
|
||||
_topicFactory.registerClass<DocumentationTopic>(DocumentationTopicKey);
|
||||
_topicFactory.registerClass<DeltaTimeStepsTopic>(DeltaTimeStepsTopicKey);
|
||||
_topicFactory.registerClass<GetPropertyTopic>(GetPropertyTopicKey);
|
||||
_topicFactory.registerClass<LuaScriptTopic>(LuaScriptTopicKey);
|
||||
_topicFactory.registerClass<SessionRecordingTopic>(SessionRecordingTopicKey);
|
||||
@@ -142,7 +139,7 @@ void Connection::handleMessage(const std::string& message) {
|
||||
message.end(),
|
||||
sanitizedString.begin(),
|
||||
[](wchar_t c) {
|
||||
return std::isprint(c, std::locale("")) ? c : ' ';
|
||||
return std::isprint(c, std::locale("")) ? char(c) : ' ';
|
||||
}
|
||||
);
|
||||
LERROR(fmt::format("Could not parse JSON: '{}'", sanitizedString));
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include "modules/server/include/topics/deltatimestepstopic.h"
|
||||
|
||||
#include <modules/server/include/connection.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/properties/property.h>
|
||||
#include <openspace/query/query.h>
|
||||
#include <openspace/util/timemanager.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* EventKey = "event";
|
||||
constexpr const char* SubscribeEvent = "start_subscription";
|
||||
constexpr const char* UnsubscribeEvent = "stop_subscription";
|
||||
} // namespace
|
||||
|
||||
using nlohmann::json;
|
||||
|
||||
namespace openspace {
|
||||
|
||||
DeltaTimeStepsTopic::DeltaTimeStepsTopic() {}
|
||||
|
||||
DeltaTimeStepsTopic::~DeltaTimeStepsTopic() {
|
||||
if (_deltaTimeCallbackHandle != UnsetOnChangeHandle) {
|
||||
global::timeManager.removeDeltaTimeChangeCallback(
|
||||
_deltaTimeCallbackHandle
|
||||
);
|
||||
}
|
||||
if (_deltaTimesListCallbackHandle != UnsetOnChangeHandle) {
|
||||
global::timeManager.removeDeltaTimeStepsChangeCallback(
|
||||
_deltaTimesListCallbackHandle
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
bool DeltaTimeStepsTopic::isDone() const {
|
||||
return _isDone;
|
||||
}
|
||||
|
||||
bool DeltaTimeStepsTopic::dataHasChanged() {
|
||||
std::optional<double> nextStep = global::timeManager.nextDeltaTimeStep();
|
||||
std::optional<double> prevStep = global::timeManager.previousDeltaTimeStep();
|
||||
|
||||
return (nextStep != _lastNextDeltaTime || prevStep != _lastPrevDeltaTime);
|
||||
}
|
||||
|
||||
void DeltaTimeStepsTopic::handleJson(const nlohmann::json& json) {
|
||||
std::string event = json.at(EventKey).get<std::string>();
|
||||
if (event == UnsubscribeEvent) {
|
||||
_isDone = true;
|
||||
return;
|
||||
}
|
||||
|
||||
sendDeltaTimesData();
|
||||
|
||||
if (event != SubscribeEvent) {
|
||||
_isDone = true;
|
||||
return;
|
||||
}
|
||||
|
||||
_deltaTimeCallbackHandle = global::timeManager.addDeltaTimeChangeCallback(
|
||||
[this]() {
|
||||
if (dataHasChanged()) {
|
||||
sendDeltaTimesData();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
_deltaTimesListCallbackHandle = global::timeManager.addDeltaTimeStepsChangeCallback(
|
||||
[this]() {
|
||||
if (dataHasChanged()) {
|
||||
sendDeltaTimesData();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void DeltaTimeStepsTopic::sendDeltaTimesData() {
|
||||
std::optional<double> nextStep = global::timeManager.nextDeltaTimeStep();
|
||||
std::optional<double> prevStep = global::timeManager.previousDeltaTimeStep();
|
||||
|
||||
bool hasNext = nextStep.has_value();
|
||||
bool hasPrev = prevStep.has_value();
|
||||
|
||||
json deltaTimesListJson = {
|
||||
{ "hasNextStep", hasNext },
|
||||
{ "hasPrevStep", hasPrev }
|
||||
};
|
||||
|
||||
if (hasNext) {
|
||||
deltaTimesListJson["nextStep"] = nextStep.value();
|
||||
}
|
||||
|
||||
if (hasPrev) {
|
||||
deltaTimesListJson["prevStep"] = prevStep.value();
|
||||
}
|
||||
|
||||
_connection->sendJson(wrappedPayload(deltaTimesListJson));
|
||||
|
||||
_lastNextDeltaTime = nextStep;
|
||||
_lastPrevDeltaTime = prevStep;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
@@ -303,12 +303,10 @@ void FlightControllerTopic::changeFocus(const nlohmann::json& json) const {
|
||||
fmt::format("Could not find {} key in JSON. JSON was:\n{}", FocusKey, j)
|
||||
);
|
||||
if (json.find(AimKey) == json.end()) {
|
||||
const std::string j = json;
|
||||
LWARNING(
|
||||
fmt::format("Could not find {} key in JSON. JSON was:\n{}", AimKey, j)
|
||||
);
|
||||
if (json.find(AnchorKey) == json.end()) {
|
||||
const std::string j = json;
|
||||
LWARNING(fmt::format(
|
||||
"Could not find {} key in JSON. JSON was:\n{}", AnchorKey, j
|
||||
));
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <openspace/query/query.h>
|
||||
#include <openspace/util/timemanager.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* EventKey = "event";
|
||||
@@ -54,6 +53,9 @@ TimeTopic::~TimeTopic() {
|
||||
if (_deltaTimeCallbackHandle != UnsetOnChangeHandle) {
|
||||
global::timeManager.removeDeltaTimeChangeCallback(_deltaTimeCallbackHandle);
|
||||
}
|
||||
if (_deltaTimeStepsCallbackHandle != UnsetOnChangeHandle) {
|
||||
global::timeManager.removeDeltaTimeStepsChangeCallback(_deltaTimeStepsCallbackHandle);
|
||||
}
|
||||
}
|
||||
|
||||
bool TimeTopic::isDone() const {
|
||||
@@ -68,6 +70,7 @@ void TimeTopic::handleJson(const nlohmann::json& json) {
|
||||
}
|
||||
|
||||
sendFullTimeData();
|
||||
sendDeltaTimeSteps();
|
||||
|
||||
if (event != SubscribeEvent) {
|
||||
_isDone = true;
|
||||
@@ -95,6 +98,37 @@ void TimeTopic::handleJson(const nlohmann::json& json) {
|
||||
sendFullTimeData();
|
||||
}
|
||||
});
|
||||
|
||||
_deltaTimeStepsCallbackHandle = global::timeManager.addDeltaTimeStepsChangeCallback(
|
||||
[this]() {
|
||||
const std::vector<double> steps = global::timeManager.deltaTimeSteps();
|
||||
if (steps != _lastDeltaTimeSteps) {
|
||||
sendDeltaTimeSteps();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const json TimeTopic::getNextPrevDeltaTimeStepJson() {
|
||||
const std::optional<double> nextStep = global::timeManager.nextDeltaTimeStep();
|
||||
const std::optional<double> prevStep = global::timeManager.previousDeltaTimeStep();
|
||||
const bool hasNext = nextStep.has_value();
|
||||
const bool hasPrev = prevStep.has_value();
|
||||
|
||||
json nextPrevJson = {
|
||||
{ "hasNextStep", hasNext },
|
||||
{ "hasPrevStep", hasPrev }
|
||||
};
|
||||
|
||||
if (hasNext) {
|
||||
nextPrevJson["nextStep"] = nextStep.value();
|
||||
}
|
||||
|
||||
if (hasPrev) {
|
||||
nextPrevJson["prevStep"] = prevStep.value();
|
||||
}
|
||||
|
||||
return nextPrevJson;
|
||||
}
|
||||
|
||||
void TimeTopic::sendCurrentTime() {
|
||||
@@ -114,17 +148,34 @@ void TimeTopic::sendFullTimeData() {
|
||||
const double targetDeltaTime = global::timeManager.targetDeltaTime();
|
||||
const bool isPaused = global::timeManager.isPaused();
|
||||
|
||||
const json timeJson = {
|
||||
json timeJson = {
|
||||
{ "time", currentTime },
|
||||
{ "deltaTime", deltaTime},
|
||||
{ "targetDeltaTime", targetDeltaTime},
|
||||
{ "isPaused", isPaused },
|
||||
{ "isPaused", isPaused }
|
||||
};
|
||||
|
||||
const json nextPrevJson = getNextPrevDeltaTimeStepJson();
|
||||
timeJson.insert(nextPrevJson.begin(), nextPrevJson.end());
|
||||
|
||||
_connection->sendJson(wrappedPayload(timeJson));
|
||||
_lastUpdateTime = std::chrono::system_clock::now();
|
||||
_lastPauseState = isPaused;
|
||||
_lastTargetDeltaTime = targetDeltaTime;
|
||||
}
|
||||
|
||||
void TimeTopic::sendDeltaTimeSteps() {
|
||||
const std::vector<double>& steps = global::timeManager.deltaTimeSteps();
|
||||
|
||||
json deltaTimeStepsJson = {
|
||||
{ "deltaTimeSteps", steps }
|
||||
};
|
||||
|
||||
const json nextPrevJson = getNextPrevDeltaTimeStepJson();
|
||||
deltaTimeStepsJson.insert(nextPrevJson.begin(), nextPrevJson.end());
|
||||
|
||||
_connection->sendJson(wrappedPayload(deltaTimeStepsJson));
|
||||
_lastDeltaTimeSteps = steps;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -335,7 +335,6 @@ glm::vec2 DashboardItemInstruments::size() const {
|
||||
|
||||
if (remaining > 0) {
|
||||
using FR = ghoul::fontrendering::FontRenderer;
|
||||
FR& renderer = FR::defaultRenderer();
|
||||
std::string progress = progressToStr(25, t);
|
||||
|
||||
size = addToBoundingbox(
|
||||
|
||||
@@ -25,7 +25,16 @@
|
||||
#ifndef __OPENSPACE_MODULE_WEBBROWSER___CEF_HOST___H__
|
||||
#define __OPENSPACE_MODULE_WEBBROWSER___CEF_HOST___H__
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4100)
|
||||
#endif // WIN32
|
||||
|
||||
#include <include/wrapper/cef_helpers.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning(pop)
|
||||
#endif // WIN32
|
||||
#include <string>
|
||||
|
||||
struct CefSettingsTraits;
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
#include <fmt/format.h>
|
||||
#include <include/wrapper/cef_helpers.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <include/wrapper/cef_library_loader.h>
|
||||
|
||||
@@ -997,10 +997,7 @@ void OpenSpaceEngine::loadFonts() {
|
||||
}
|
||||
|
||||
try {
|
||||
bool initSuccess = ghoul::fontrendering::FontRenderer::initialize();
|
||||
if (!initSuccess) {
|
||||
LERROR("Error initializing default font renderer");
|
||||
}
|
||||
ghoul::fontrendering::FontRenderer::initialize();
|
||||
}
|
||||
catch (const ghoul::RuntimeError& err) {
|
||||
LERRORC(err.component, err.message);
|
||||
|
||||
Reference in New Issue
Block a user