mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-01 08:19:51 -05:00
Adjust selected sample code to take in SPICE id instead of filename
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/lightsource.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/timemanager.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
@@ -51,6 +52,7 @@ namespace {
|
||||
constexpr std::string_view _loggerCat = "RenderableTube";
|
||||
constexpr int8_t CurrentMajorVersion = 0;
|
||||
constexpr int8_t CurrentMinorVersion = 1;
|
||||
constexpr int SpiceIdOffset = 1000000;
|
||||
|
||||
constexpr int NearestInterpolation = 0;
|
||||
constexpr int LinearInterpolation = 1;
|
||||
@@ -557,7 +559,7 @@ RenderableTube::ColorSettingsCutplane::ColorSettingsCutplane(
|
||||
addProperty(fixedColor);
|
||||
}
|
||||
|
||||
void RenderableTube::initialize() {
|
||||
void RenderableTube::initializeGL() {
|
||||
readDataFile();
|
||||
createTube();
|
||||
|
||||
@@ -569,9 +571,7 @@ void RenderableTube::initialize() {
|
||||
for (const std::unique_ptr<LightSource>& ls : _lightSources) {
|
||||
ls->initialize();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableTube::initializeGL() {
|
||||
_shader = global::renderEngine->buildRenderProgram(
|
||||
"TubeProgram",
|
||||
absPath("${MODULE_BASE}/shaders/tube_vs.glsl"),
|
||||
@@ -1265,19 +1265,31 @@ void RenderableTube::loadSelectedSample() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find information for the scen graph nodes, filenames start from 000001
|
||||
std::string filename = std::format(
|
||||
"{:06}.bsp",
|
||||
std::stoi(_selectedSample.value()) + 1
|
||||
);
|
||||
// Find information for the scen graph nodes.
|
||||
int sample = std::stoi(_selectedSample.value());
|
||||
|
||||
// Filenames start from 000001
|
||||
// Identifier starts at 1000000
|
||||
// SPICE ids start from 1000000
|
||||
std::string filename;
|
||||
std::string identifier;
|
||||
std::string target;
|
||||
|
||||
if (sample >= SpiceIdOffset) {
|
||||
// Convert the SPICE id to a filename
|
||||
filename = std::format("{:06}.bsp", sample - SpiceIdOffset + 1);
|
||||
identifier = std::to_string(sample);
|
||||
target = identifier;
|
||||
}
|
||||
else {
|
||||
filename = std::format("{:06}.bsp", sample);
|
||||
identifier = std::format("1{:06}", sample);
|
||||
target = identifier;
|
||||
}
|
||||
|
||||
std::string kernelPath = absPath(_kernelsDirectory / filename).string();
|
||||
std::replace(kernelPath.begin(), kernelPath.end(), '\\', '/');
|
||||
|
||||
// Identifier starts at 000001
|
||||
std::string identifier = std::format("{:06}", std::stoi(_selectedSample.value()) + 1);
|
||||
|
||||
// Target starts at 1000000
|
||||
std::string target = std::format("1{:06}", std::stoi(_selectedSample.value()));
|
||||
std::string start = std::string(Time(_data.front().timestamp).ISO8601());
|
||||
std::string end = std::string(Time(_data.back().timestamp).ISO8601());
|
||||
|
||||
|
||||
@@ -50,7 +50,6 @@ class RenderableTube : public Renderable {
|
||||
public:
|
||||
RenderableTube(const ghoul::Dictionary& dictionary);
|
||||
|
||||
void initialize() override;
|
||||
void initializeGL() override;
|
||||
void deinitializeGL() override;
|
||||
|
||||
|
||||
@@ -236,7 +236,7 @@ void FindImpactsTask::findImpacts(const Task::ProgressCallback& progressCallback
|
||||
if (failed_c()) {
|
||||
// If not, then there is probably a missing kernel file and we need to skip to
|
||||
// the next valid variant
|
||||
LWARNING(std::format("Missing kernel file {:07}", variantId - IdOffset + 1));
|
||||
LWARNING(std::format("Missing kernel file {:06}", variantId - IdOffset + 1));
|
||||
variantId += 2;
|
||||
|
||||
SpiceManager::ref().unloadKernel(managerKernelId);
|
||||
@@ -338,6 +338,19 @@ void FindImpactsTask::writeImpactCoordinates(
|
||||
++impactCounter;
|
||||
progressCallback(impactCounter / static_cast<float>(_impactCoordinates.size()));
|
||||
}
|
||||
file << "\n";
|
||||
|
||||
// Make it easier to add the samples to the tube by also printing the add sample scripts
|
||||
impactCounter = 0;
|
||||
for (const ImpactCoordinate& impact : _impactCoordinates) {
|
||||
file << std::format(
|
||||
"\"openspace.setPropertyValueSingle(\\\"Scene.{}.Renderable.SelectedSample\\\", '{}')\",\n",
|
||||
_asteroidName, impact.id
|
||||
);
|
||||
|
||||
++impactCounter;
|
||||
progressCallback(impactCounter / static_cast<float>(_impactCoordinates.size()));
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ void ImpactCorridorTask::readImpactFile() {
|
||||
}
|
||||
|
||||
ImpactCoordinate impact = readImpactCoordinate(file);
|
||||
while (file) {
|
||||
while (file && impact.id > 0) {
|
||||
_impactCoordinates.push_back(impact);
|
||||
impact = readImpactCoordinate(file);
|
||||
}
|
||||
@@ -301,8 +301,11 @@ ImpactCorridorTask::ImpactCoordinate ImpactCorridorTask::readImpactCoordinate(
|
||||
std::string line;
|
||||
|
||||
ghoul::getline(file, line);
|
||||
std::stringstream ss(line);
|
||||
if (line.empty()) {
|
||||
return impact;
|
||||
}
|
||||
|
||||
std::stringstream ss(line);
|
||||
ss >> impact.id >> impact.latitude >> impact.longitude;
|
||||
std::getline(ss >> std::ws, impact.time);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user