Merge branch 'master' into thesis/2021/skybrowser

This commit is contained in:
Ylva Selling
2021-03-18 09:35:56 +01:00
16 changed files with 110 additions and 60 deletions

View File

@@ -1,6 +1,6 @@
local assetHelper = asset.require('util/asset_helper')
local colorLUT = asset.require('./stars_colormap').BvColorLUT
local textures = asset.syncedResource({
Name = "Stars Textures",
@@ -23,13 +23,6 @@ local sunspeck = asset.syncedResource({
Version = 1
})
local colorLUT = asset.syncedResource({
Name = "Stars Color Table",
Type = "HttpSynchronization",
Identifier = "stars_colormap",
Version = 2
})
local stars = {
Identifier = "Stars",
Renderable = {

View File

@@ -0,0 +1,22 @@
local assetHelper = asset.require('util/asset_helper')
local BvColorLUT = asset.syncedResource({
Name = "Stars Color Table",
Type = "HttpSynchronization",
Identifier = "stars_colormap",
Version = 2
})
asset.export("BvColorLUT", BvColorLUT)
asset.meta = {
Name = "Stars B-V Colormap",
Version = "2.0",
Description = [[A lookup table that maps a B-V color index to an RGB color.
The B-V values are in the range (-0.4, 2.0) and each line maps a value
in that range to a color]],
Author = "OpenSpace Team",
URL = "https://www.amnh.org/research/hayden-planetarium/digital-universe",
License = "AMNH Digital Universe"
}

View File

@@ -1,3 +1,5 @@
local bvColorLUT = asset.require('scene/digitaluniverse/stars_colormap').BvColorLUT
local DataPath = asset.syncedResource({
Name = "Exoplanet Data Files",
Type = "HttpSynchronization",
@@ -7,9 +9,14 @@ local DataPath = asset.syncedResource({
asset.onInitialize(function ()
local p = "Modules.Exoplanets.DataFolder";
if(openspace.getPropertyValue(p) == "") then
if (openspace.getPropertyValue(p) == "") then
openspace.setPropertyValueSingle(p, DataPath)
end
p = "Modules.Exoplanets.BvColormap";
if (openspace.getPropertyValue(p) == "") then
openspace.setPropertyValueSingle(p, bvColorLUT .. "/colorbv.cmap")
end
end)
asset.export("DataPath", DataPath)
@@ -22,5 +29,5 @@ asset.meta = {
Archive]],
Author = "OpenSpace Team",
URL = "https://exoplanetarchive.ipac.caltech.edu/docs/data.html",
License = "MIT license",
License = "MIT license"
}

View File

@@ -13,7 +13,7 @@ local models = asset.syncedResource({
Name = "ISS Models",
Type = "HttpSynchronization",
Identifier = "iss_model",
Version = 2
Version = 3
})
local initializeAndAddNodes = function()
@@ -59,37 +59,7 @@ local initializeAndAddNodes = function()
},
Renderable = {
Type = "RenderableModel",
GeometryFile = {
models .. "/0.obj",
models .. "/1.obj",
models .. "/2.obj",
models .. "/3.obj",
models .. "/4.obj",
models .. "/5.obj",
models .. "/6.obj",
models .. "/7.obj",
models .. "/8.obj",
models .. "/10.obj",
models .. "/11.obj",
models .. "/13.obj",
models .. "/14.obj",
models .. "/15.obj",
models .. "/16.obj",
models .. "/17.obj",
models .. "/19.obj",
models .. "/21.obj",
models .. "/22.obj",
models .. "/23.obj",
models .. "/24.obj",
models .. "/25.obj",
models .. "/foilsilver.obj",
models .. "/olive.obj",
models .. "/basemetal.obj",
models .. "/white_20.obj",
models .. "/plasticblack.obj",
models .. "/ecostresswhite.obj",
models .. "/plain.obj"
},
GeometryFile = models .. "/ISS.fbx",
LightSources = {
{
Type = "SceneGraphLightSource",

View File

@@ -29,6 +29,7 @@
#include <ghoul/glm.h>
#include <functional>
#include <type_traits>
#include <variant>
namespace openspace::documentation {
@@ -994,8 +995,15 @@ struct OrVerifier : public Verifier {
* \param values The list of Verifiers that are to be tested
*
* \pre values must contain at least two values
*
* \todo: The use of the variant to use both raw pointers and shared pointers is
* definitely undesired. At the momement we are not handling the ownership of
* the verifiers very well and this must be cleaned up when doing a pass over
* the entire ownership model of the documentation/verifiers. For now it was
* necessary to make the codegen work in all cases without complications there
*/
OrVerifier(const std::vector<Verifier*> values);
OrVerifier(const std::vector<std::variant<Verifier*,
std::shared_ptr<Verifier>>> values);
/**
* Checks whether the \p dictionary contains the \p key and whether this key passes

View File

@@ -148,7 +148,8 @@ namespace {
struct [[codegen::Dictionary(RenderableTrail)]] Parameters {
// This object is used to compute locations along the path. Any Translation object
// can be used here
std::monostate translation [[codegen::reference("core_transform_translation")]];
ghoul::Dictionary translation
[[codegen::reference("core_transform_translation")]];
// [[codegen::verbatim(LineColorInfo.description)]]
glm::vec3 color [[codegen::color()]];

View File

@@ -41,7 +41,8 @@ namespace {
struct [[codegen::Dictionary(TimeFrameUnion)]] Parameters {
// [[codegen::verbatim(TimeFramesInfo.description)]]
std::vector<std::monostate> timeFrames [[codegen::reference("core_time_frame")]];
std::vector<ghoul::Dictionary> timeFrames
[[codegen::reference("core_time_frame")]];
};
#include "timeframeunion_codegen.cpp"
} // namespace

View File

@@ -24,6 +24,9 @@
#include <modules/exoplanets/exoplanetshelper.h>
#include <modules/exoplanets/exoplanetsmodule.h>
#include <openspace/engine/globals.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/util/spicemanager.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/fmt.h>
@@ -36,8 +39,6 @@
namespace {
constexpr const char* _loggerCat = "ExoplanetsModule";
constexpr const char* BvColormapPath = "${SYNC}/http/stars_colormap/2/colorbv.cmap";
}
namespace openspace::exoplanets {
@@ -57,19 +58,37 @@ bool hasSufficientData(const ExoplanetDataEntry& p) {
}
glm::vec3 computeStarColor(float bv) {
std::ifstream colorMap(absPath(BvColormapPath), std::ios::in);
const ExoplanetsModule* module = global::moduleEngine->module<ExoplanetsModule>();
const std::string bvColormapPath = module->bvColormapPath();
std::ifstream colorMap(absPath(bvColormapPath), std::ios::in);
if (!colorMap.good()) {
LERROR(fmt::format(
"Failed to open colormap data file: '{}'",
absPath(BvColormapPath)
absPath(bvColormapPath)
));
return glm::vec3(0.f, 0.f, 0.f);
return glm::vec3(0.f);
}
const int t = static_cast<int>(round(((bv + 0.4) / (2.0 + 0.4)) * 255));
// Interpret the colormap cmap file
std::string line;
while (std::getline(colorMap, line)) {
if (line.empty() || (line[0] == '#')) {
continue;
}
break;
}
// The first line is the width of the image, i.e number of values
std::istringstream ss(line);
int nValues;
ss >> nValues;
// Find the line matching the input B-V value (B-V is in [-0.4,2.0])
const int t = static_cast<int>(round(((bv + 0.4) / (2.0 + 0.4)) * (nValues - 1)));
std::string color;
for (int i = 0; i < t + 12; i++) {
for (int i = 0; i < t + 1; i++) {
getline(colorMap, color);
}
colorMap.close();

View File

@@ -44,6 +44,12 @@ namespace {
"The path to the folder containing the exoplanets data and lookup table"
};
constexpr const openspace::properties::Property::PropertyInfo BvColorMapInfo = {
"BvColormap",
"B-V Colormap",
"The path to a cmap file that maps a B-V color index to an RGB color"
};
constexpr const openspace::properties::Property::PropertyInfo StarTextureInfo = {
"StarTexture",
"Star Texture",
@@ -123,6 +129,9 @@ namespace {
// [[codegen::verbatim(DataFolderInfo.description)]]
std::optional<std::filesystem::path> dataFolder [[codegen::directory()]];
// [[codegen::verbatim(BvColorMapInfo.description)]]
std::optional<std::filesystem::path> bvColormap;
// [[codegen::verbatim(StarTextureInfo.description)]]
std::optional<std::filesystem::path> starTexture;
@@ -160,6 +169,7 @@ using namespace exoplanets;
ExoplanetsModule::ExoplanetsModule()
: OpenSpaceModule(Name)
, _exoplanetsDataFolder(DataFolderInfo)
, _bvColorMapPath(BvColorMapInfo)
, _starTexturePath(StarTextureInfo)
, _starGlareTexturePath(StarGlareTextureInfo)
, _noDataTexturePath(NoDataTextureInfo)
@@ -173,6 +183,7 @@ ExoplanetsModule::ExoplanetsModule()
_exoplanetsDataFolder.setReadOnly(true);
addProperty(_exoplanetsDataFolder);
addProperty(_bvColorMapPath);
addProperty(_starTexturePath);
addProperty(_starGlareTexturePath);
addProperty(_noDataTexturePath);
@@ -198,6 +209,10 @@ std::string ExoplanetsModule::lookUpTablePath() const {
);
};
std::string ExoplanetsModule::bvColormapPath() const {
return _bvColorMapPath;
}
std::string ExoplanetsModule::starTexturePath() const {
return _starTexturePath;
}
@@ -280,6 +295,10 @@ void ExoplanetsModule::internalInitialize(const ghoul::Dictionary& dict) {
_exoplanetsDataFolder = p.dataFolder.value().string();
}
if (p.bvColormap.has_value()) {
_bvColorMapPath = p.bvColormap.value().string();
}
if (p.starTexture.has_value()) {
_starTexturePath = p.starTexture.value().string();
}

View File

@@ -43,6 +43,7 @@ public:
std::string exoplanetsDataPath() const;
std::string lookUpTablePath() const;
std::string bvColormapPath() const;
std::string starTexturePath() const;
std::string starGlareTexturePath() const;
std::string noDataTexturePath() const;
@@ -60,6 +61,7 @@ protected:
void internalInitialize(const ghoul::Dictionary& dict) override;
properties::StringProperty _exoplanetsDataFolder;
properties::StringProperty _bvColorMapPath;
properties::StringProperty _starTexturePath;
properties::StringProperty _starGlareTexturePath;
properties::StringProperty _noDataTexturePath;

View File

@@ -172,7 +172,7 @@ namespace {
std::optional<BlendMode> blendMode;
// If the primary layer creation fails, this layer is used as a fallback
std::optional<std::monostate>
std::optional<ghoul::Dictionary>
fallback [[codegen::reference("globebrowsing_layer")]];
};
#include "layer_codegen.cpp"

View File

@@ -64,7 +64,8 @@ namespace {
std::optional<std::variant<std::vector<std::string>, std::string>> kernels;
// [[codegen::verbatim(TimeFrameInfo.description)]]
std::optional<std::monostate> timeFrame [[codegen::reference("core_time_frame")]];
std::optional<ghoul::Dictionary> timeFrame
[[codegen::reference("core_time_frame")]];
};
#include "spicerotation_codegen.cpp"
} // namespace

View File

@@ -584,10 +584,17 @@ std::string AndVerifier::documentation() const {
return ghoul::join(documentations, ", ");
}
OrVerifier::OrVerifier(const std::vector<Verifier*> values_) {
OrVerifier::OrVerifier(
const std::vector<std::variant<Verifier*, std::shared_ptr<Verifier>>> values_)
{
ghoul_assert(!values_.empty(), "values must not be empty");
for (Verifier* v : values_) {
this->values.push_back(std::shared_ptr<Verifier>(v));
for (const std::variant<Verifier*, std::shared_ptr<Verifier>>& v : values_) {
if (std::holds_alternative<Verifier*>(v)) {
this->values.push_back(std::shared_ptr<Verifier>(std::get<Verifier*>(v)));
}
else {
this->values.push_back(std::get<std::shared_ptr<Verifier>>(v));
}
}
}