Merge branch 'master' into feature/getting-started-tour

This commit is contained in:
Ylva Selling
2022-07-12 15:09:00 -04:00
74 changed files with 4550 additions and 211 deletions

View File

@@ -168,11 +168,6 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
{ Type::Focus, "Focus" },
{ Type::Camera, "Camera" }
});
_source.type.onChange([this]() {
_source.nodeName.setVisibility(
properties::Property::Visibility(_source.type == Type::Node)
);
});
if (p.sourceType.has_value()) {
_source.type = codegen::map<Type>(*p.sourceType);
}
@@ -201,11 +196,6 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
{ Type::Focus, "Focus" },
{ Type::Camera, "Camera" }
});
_reference.type.onChange([this]() {
_reference.nodeName.setVisibility(
properties::Property::Visibility(_reference.type == Type::Node)
);
});
_reference.type = codegen::map<Type>(p.referenceType);
addProperty(_reference.type);
@@ -228,11 +218,6 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
{ Type::Focus, "Focus" },
{ Type::Camera, "Camera" }
});
_destination.type.onChange([this]() {
_destination.nodeName.setVisibility(
properties::Property::Visibility(_source.type == Type::Node)
);
});
if (p.destinationType.has_value()) {
_destination.type = codegen::map<Type>(*p.destinationType);
}

View File

@@ -270,6 +270,7 @@ void RenderablePlane::render(const RenderData& data, RendererTasks&) {
glDepthMask(false);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
}
glDisable(GL_CULL_FACE);
glBindVertexArray(_quad);
glDrawArrays(GL_TRIANGLES, 0, 6);

View File

@@ -28,13 +28,24 @@
#include <openspace/documentation/verifier.h>
#include <openspace/util/updatestructures.h>
#include <openspace/util/time.h>
#include <optional>
namespace {
constexpr openspace::properties::Property::PropertyInfo ShouldInterpolateInfo = {
"ShouldInterpolate",
"Should Interpolate",
"If this value is set to 'true', an interpolation is applied between the given "
"keyframes. If this value is set to 'false', the interpolation is not applied."
};
struct [[codegen::Dictionary(TimelineRotation)]] Parameters {
// A table of keyframes, with keys formatted as YYYY-MM-DDTHH:MM:SS and values
// that are valid Rotation objects
std::map<std::string, ghoul::Dictionary> keyframes
[[codegen::reference("core_transform_rotation")]];
// [[codegen::verbatim(ShouldInterpolateInfo.description)]]
std::optional<bool> shouldInterpolate;
};
#include "timelinerotation_codegen.cpp"
} // namespace
@@ -45,7 +56,9 @@ documentation::Documentation TimelineRotation::Documentation() {
return codegen::doc<Parameters>("base_transform_rotation_keyframe");
}
TimelineRotation::TimelineRotation(const ghoul::Dictionary& dictionary) {
TimelineRotation::TimelineRotation(const ghoul::Dictionary& dictionary)
: _shouldInterpolate(ShouldInterpolateInfo, true)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
for (const std::pair<const std::string, ghoul::Dictionary>& kf : p.keyframes) {
@@ -58,6 +71,9 @@ TimelineRotation::TimelineRotation(const ghoul::Dictionary& dictionary) {
_timeline.addKeyframe(t, std::move(rotation));
}
}
_shouldInterpolate = p.shouldInterpolate.value_or(_shouldInterpolate);
addProperty(_shouldInterpolate);
}
glm::dmat3 TimelineRotation::matrix(const UpdateData& data) const {
@@ -78,16 +94,26 @@ glm::dmat3 TimelineRotation::matrix(const UpdateData& data) const {
}
const double prevTime = prev->timestamp;
const double nextTime = next->timestamp;
if (_shouldInterpolate) {
double t = 0.0;
if (nextTime - prevTime > 0.0) {
t = (now - prevTime) / (nextTime - prevTime);
}
double t = 0.0;
if (nextTime - prevTime > 0.0) {
t = (now - prevTime) / (nextTime - prevTime);
const glm::dquat nextRot = glm::quat_cast(next->data->matrix(data));
const glm::dquat prevRot = glm::quat_cast(prev->data->matrix(data));
return glm::dmat3(glm::slerp(prevRot, nextRot, t));
}
const glm::dquat nextRot = glm::quat_cast(next->data->matrix(data));
const glm::dquat prevRot = glm::quat_cast(prev->data->matrix(data));
return glm::dmat3(glm::slerp(prevRot, nextRot, t));
else {
if (prevTime <= now && now < nextTime) {
return prev->data->matrix(data);
}
else if (nextTime <= now) {
return next->data->matrix(data);
}
}
return glm::dmat3(0.0);
}
} // namespace openspace

View File

@@ -26,6 +26,8 @@
#define __OPENSPACE_MODULE_BASE___TIMELINEROTATION___H__
#include <openspace/scene/rotation.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/util/timeline.h>
namespace openspace {
@@ -42,6 +44,7 @@ public:
private:
Timeline<ghoul::mm_unique_ptr<Rotation>> _timeline;
properties::BoolProperty _shouldInterpolate;
};
} // namespace openspace

View File

@@ -32,6 +32,7 @@ uniform sampler2D tex;
uniform vec3 color = vec3(1.0);
uniform float opacity = 1.0;
uniform vec4 backgroundColor = vec4(0.0);
uniform float gamma = 1.0;
Fragment getFragment() {
Fragment frag;
@@ -44,5 +45,6 @@ Fragment getFragment() {
}
frag.depth = vs_depth;
frag.color.rgb = pow(frag.color.rgb, vec3(1.0/(gamma)));
return frag;
}

View File

@@ -25,8 +25,9 @@
#ifndef __OPENSPACE_MODULE_BASE___TIMELINETRANSLATION___H__
#define __OPENSPACE_MODULE_BASE___TIMELINETRANSLATION___H__
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/scene/translation.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/util/timeline.h>
#include <ghoul/misc/managedmemoryuniqueptr.h>

View File

@@ -550,9 +550,6 @@ fls::Model stringToModel(std::string str) {
bool RenderableFieldlinesSequence::loadJsonStatesIntoRAM() {
fls::Model model = stringToModel(_modelStr);
if (model == fls::Model::Invalid) {
return false;
}
for (const std::string& filePath : _sourceFiles) {
FieldlinesState newState;
const bool loadedSuccessfully = newState.loadStateFromJson(
@@ -1079,6 +1076,12 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
if (!_hasBeenUpdated) {
updateVertexPositionBuffer();
}
if (_states[_activeStateIndex].nExtraQuantities() > 0) {
_shouldUpdateColorBuffer = true;
_shouldUpdateMaskingBuffer = true;
}
_hasBeenUpdated = true;
}
else {

View File

@@ -490,18 +490,6 @@ void ImGUIModule::renderFrame(float deltaTime, const glm::vec2& windowSize,
comp->setEnabled(enabled);
}
// Render and Update property visibility
// Fragile! Keep this in sync with properties::Property::Visibility
using V = properties::Property::Visibility;
int t = static_cast<std::underlying_type_t<V>>(_currentVisibility);
// Array is sorted by importance
std::array<const char*, 4> items = { "User", "Developer", "Hidden", "All" };
ImGui::Combo("PropertyVisibility", &t, items.data(), static_cast<int>(items.size()));
_currentVisibility = static_cast<V>(t);
_property.setVisibility(_currentVisibility);
#ifdef SHOW_IMGUI_HELPERS
ImGui::Checkbox("ImGUI Internals", &_showInternals);
if (_showInternals) {

View File

@@ -124,9 +124,6 @@ private:
UniformCache(tex, ortho) _uniformCache;
std::unique_ptr<ghoul::opengl::Texture> _fontTexture;
properties::Property::Visibility _currentVisibility =
properties::Property::Visibility::Developer;
std::vector<ImGuiContext*> _contexts;
std::vector<TouchInput> _validTouchStates;

View File

@@ -52,22 +52,17 @@ public:
void setPropertyOwnerFunction(
std::function<std::vector<properties::PropertyOwner*>()> func);
void setVisibility(properties::Property::Visibility visibility);
void render() override;
protected:
void renderPropertyOwner(properties::PropertyOwner* owner);
void renderProperty(properties::Property* prop, properties::PropertyOwner* owner);
properties::Property::Visibility _visibility = properties::Property::Visibility::User;
std::vector<properties::PropertyOwner*> _propertyOwners;
std::function<std::vector<properties::PropertyOwner*>()> _propertyOwnerFunction;
properties::BoolProperty _useTreeLayout;
properties::StringListProperty _treeOrdering;
properties::BoolProperty _ignoreHiddenHint;
};
} // namespace openspace::gui

View File

@@ -42,7 +42,6 @@ namespace openspace::gui {
GuiParallelComponent::GuiParallelComponent()
: GuiPropertyComponent("Parallel", "Parallel Connection")
{
setVisibility(properties::Property::Visibility::All);
}
void GuiParallelComponent::renderDisconnected() {

View File

@@ -26,6 +26,8 @@
#include <modules/imgui/include/imgui_include.h>
#include <modules/imgui/include/renderproperties.h>
#include <openspace/engine/globals.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/scene/scenegraphnode.h>
#include <ghoul/misc/misc.h>
#include <algorithm>
@@ -59,15 +61,17 @@ namespace {
"the hidden hints are followed."
};
int nVisibleProperties(const std::vector<openspace::properties::Property*>& props,
openspace::properties::Property::Visibility visibility)
int nVisibleProperties(const std::vector<openspace::properties::Property*>& props)
{
using Visibility = openspace::properties::Property::Visibility;
Visibility visibilityFilter = openspace::global::openSpaceEngine->visibility();
return static_cast<int>(std::count_if(
props.begin(),
props.end(),
[visibility](openspace::properties::Property* p) {
[visibilityFilter](openspace::properties::Property* p) {
using V = openspace::properties::Property::Visibility;
return static_cast<std::underlying_type_t<V>>(visibility) >=
return static_cast<std::underlying_type_t<V>>(visibilityFilter) >=
static_cast<std::underlying_type_t<V>>(p->visibility());
}
));
@@ -187,11 +191,9 @@ GuiPropertyComponent::GuiPropertyComponent(std::string identifier, std::string g
: GuiComponent(std::move(identifier), std::move(guiName))
, _useTreeLayout(UseTreeInfo, useTree)
, _treeOrdering(OrderingInfo)
, _ignoreHiddenHint(IgnoreHiddenInfo)
{
addProperty(_useTreeLayout);
addProperty(_treeOrdering);
addProperty(_ignoreHiddenHint);
}
void GuiPropertyComponent::setPropertyOwners(
@@ -206,10 +208,6 @@ void GuiPropertyComponent::setPropertyOwnerFunction(
_propertyOwnerFunction = std::move(func);
}
void GuiPropertyComponent::setVisibility(properties::Property::Visibility visibility) {
_visibility = visibility;
}
void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner) {
using namespace properties;
@@ -217,12 +215,12 @@ void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner)
return;
}
const int nThisProperty = nVisibleProperties(owner->properties(), _visibility);
const int nThisProperty = nVisibleProperties(owner->properties());
ImGui::PushID(owner->identifier().c_str());
const std::vector<PropertyOwner*>& subOwners = owner->propertySubOwners();
for (PropertyOwner* subOwner : subOwners) {
const std::vector<Property*>& properties = subOwner->propertiesRecursive();
int count = nVisibleProperties(properties, _visibility);
int count = nVisibleProperties(properties);
if (count == 0) {
continue;
}
@@ -286,6 +284,7 @@ void GuiPropertyComponent::render() {
ImGui::SetNextWindowBgAlpha(0.75f);
ImGui::Begin(guiName().c_str(), &v);
_isEnabled = v;
bool showHiddenNode = openspace::global::openSpaceEngine->showHiddenSceneGraphNodes();
_isCollapsed = ImGui::IsWindowCollapsed();
using namespace properties;
@@ -373,12 +372,14 @@ void GuiPropertyComponent::render() {
dynamic_cast<SceneGraphNode*>(*owners.begin())->guiPath().empty());
auto renderProp = [&](properties::PropertyOwner* pOwner) {
const int count = nVisibleProperties(pOwner->propertiesRecursive(), _visibility);
const int count = nVisibleProperties(pOwner->propertiesRecursive());
if (count == 0) {
return;
}
auto header = [&]() -> bool {
if (owners.size() > 1) {
// Create a header in case we have multiple owners
@@ -402,7 +403,7 @@ void GuiPropertyComponent::render() {
};
if (!_useTreeLayout || noGuiGroups) {
if (!_ignoreHiddenHint) {
if (!showHiddenNode) {
// Remove all of the nodes that we want hidden first
owners.erase(
std::remove_if(
@@ -424,7 +425,7 @@ void GuiPropertyComponent::render() {
for (properties::PropertyOwner* pOwner : owners) {
// We checked above that pOwner is a SceneGraphNode
SceneGraphNode* nOwner = static_cast<SceneGraphNode*>(pOwner);
if (!_ignoreHiddenHint && nOwner->hasGuiHintHidden()) {
if (!showHiddenNode && nOwner->hasGuiHintHidden()) {
continue;
}
const std::string gui = nOwner->guiPath();
@@ -491,7 +492,9 @@ void GuiPropertyComponent::renderProperty(properties::Property* prop,
// Check if the visibility of the property is high enough to be displayed
using V = properties::Property::Visibility;
const auto v = static_cast<std::underlying_type_t<V>>(_visibility);
using Visibility = openspace::properties::Property::Visibility;
Visibility visibilityFilter = openspace::global::openSpaceEngine->visibility();
const auto v = static_cast<std::underlying_type_t<V>>(visibilityFilter);
const auto propV = static_cast<std::underlying_type_t<V>>(prop->visibility());
if (v >= propV) {
auto it = FunctionMapping.find(prop->className());

View File

@@ -63,7 +63,7 @@ void DataPlane::initializeGL() {
// else if autofilter is turned off, register backgroundValues
}
else {
_backgroundValues.setVisibility(properties::Property::Visibility::All);
_backgroundValues.setVisibility(properties::Property::Visibility::Always);
}
});
}

View File

@@ -74,7 +74,7 @@ void DataSphere::initializeGL() {
// else if autofilter is turned off, register backgroundValues
}
else {
_backgroundValues.setVisibility(properties::Property::Visibility::All);
_backgroundValues.setVisibility(properties::Property::Visibility::Always);
//_backgroundValues.setVisible(true);
}
});

View File

@@ -134,7 +134,7 @@ void IswaDataGroup::registerProperties() {
// else if autofilter is turned off, register backgroundValues
}
else {
_backgroundValues.setVisibility(properties::Property::Visibility::All);
_backgroundValues.setVisibility(properties::Property::Visibility::Always);
//_backgroundValues.setVisible(true);
}
ghoul::Dictionary d;

View File

@@ -151,7 +151,7 @@ void KameleonPlane::initializeGL() {
// else if autofilter is turned off, register backgroundValues
}
else {
_backgroundValues.setVisibility(properties::Property::Visibility::All);
_backgroundValues.setVisibility(properties::Property::Visibility::Always);
//_backgroundValues.setVisible(true);
}
});

View File

@@ -300,6 +300,9 @@ void SkyBrowserModule::lookAtTarget(const std::string& id) {
void SkyBrowserModule::setHoverCircle(SceneGraphNode* circle) {
_hoverCircle = circle;
// Always disable it per default. It should only be visible on interaction
disableHoverCircle();
}
void SkyBrowserModule::moveHoverCircle(int i, bool useScript) {

View File

@@ -87,6 +87,12 @@ namespace {
using namespace openspace;
SceneGraphNode* circle = global::renderEngine->scene()->sceneGraphNode(identifier);
if (!circle) {
throw ghoul::lua::LuaError(fmt::format(
"Could not find node to set as hover circle: '{}'", identifier
));
}
global::moduleEngine->module<SkyBrowserModule>()->setHoverCircle(circle);
}
@@ -435,6 +441,7 @@ namespace {
"Name = '" + nameBrowser + "',"
"Url = '" + url + "',"
"FaceCamera = false,"
"Gamma = 2.2,"
"CartesianPosition = " + ghoul::to_string(positionBrowser) +
"}";

View File

@@ -24,6 +24,7 @@
#include <modules/space/horizonsfile.h>
#include <openspace/util/httprequest.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/time.h>
#include <ghoul/filesystem/filesystem.h>
@@ -167,11 +168,53 @@ std::string constructHorizonsUrl(HorizonsType type, const std::string& target,
return url;
}
json sendHorizonsRequest(const std::string& url, std::filesystem::path filePath) {
// Set up HTTP request and download result
std::unique_ptr<HttpFileDownload> download = std::make_unique<HttpFileDownload>(
url,
filePath,
HttpFileDownload::Overwrite::Yes
);
HttpFileDownload* dl = download.get();
dl->start();
bool failed = false;
dl->wait();
if (!dl->hasSucceeded()) {
LERROR(fmt::format("Error downloading horizons file with URL {}", dl->url()));
failed = true;
}
if (failed) {
dl->cancel();
}
return convertHorizonsDownloadToJson(filePath);
}
nlohmann::json convertHorizonsDownloadToJson(std::filesystem::path filePath) {
// Read the entire file into a string
constexpr size_t readSize = std::size_t(4096);
std::ifstream stream = std::ifstream(filePath);
stream.exceptions(std::ios_base::badbit);
std::string answer;
std::string buf = std::string(readSize, '\0');
while (stream.read(buf.data(), readSize)) {
answer.append(buf, 0, stream.gcount());
}
answer.append(buf, 0, stream.gcount());
// convert to a json object
return json::parse(answer);
}
HorizonsResultCode isValidHorizonsAnswer(const json& answer) {
// Signature, source and version
if (auto signature = answer.find("signature"); signature != answer.end()) {
if (auto signature = answer.find("signature"); signature != answer.end()) {
if (auto source = signature->find("source"); source != signature->end()) {
if (auto source = signature->find("source"); source != signature->end()) {
if (*source != static_cast<std::string>(ApiSource)) {
LWARNING(fmt::format("Horizons answer from unkown source '{}'", *source));
}
@@ -180,7 +223,7 @@ HorizonsResultCode isValidHorizonsAnswer(const json& answer) {
LWARNING("Could not find source information, source might not be acceptable");
}
if (auto version = signature->find("version"); version != signature->end()) {
if (auto version = signature->find("version"); version != signature->end()) {
if (*version != static_cast<std::string>(CurrentVersion)) {
LWARNING(fmt::format(
"Unknown Horizons version '{}' found. The currently supported "

View File

@@ -127,6 +127,8 @@ std::string constructHorizonsUrl(HorizonsType type, const std::string& target,
const std::string& observer, const std::string& startTime,
const std::string& stopTime, const std::string& stepSize,
const std::string& unit);
nlohmann::json sendHorizonsRequest(const std::string& url, std::filesystem::path filePath);
nlohmann::json convertHorizonsDownloadToJson(std::filesystem::path filePath);
HorizonsResultCode isValidHorizonsAnswer(const nlohmann::json& answer);
HorizonsResultCode isValidHorizonsFile(std::filesystem::path file);
HorizonsResult readHorizonsFile(std::filesystem::path file);

View File

@@ -25,26 +25,22 @@
#ifndef __OPENSPACE_MODULE_TOUCH___TUIO_EAR___H__
#define __OPENSPACE_MODULE_TOUCH___TUIO_EAR___H__
// -Wold-style-cast
#if (defined(__GNUC__) && !defined(__clang__))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
#endif // defined(__GNUC__) && !defined(__clang__)
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wold-style-cast"
#endif // __clang__
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
#include <modules/touch/ext/libTUIO11/TUIO/TuioListener.h>
#include <modules/touch/ext/libTUIO11/TUIO/TuioClient.h>
#if (defined(__GNUC__) && !defined(__clang__))
#pragma GCC diagnostic pop
#endif // defined(__GNUC__) && !defined(__clang__)
#ifdef __clang__
#pragma clang diagnostic pop
#endif // __clang__
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
#include <openspace/util/touch.h>
#include <ghoul/glm.h>