mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-24 04:58:59 -05:00
Move the mapping target->frame from SpiceManager to SpacecraftInstrumentModule (#closes 21)
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/moduleengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
@@ -151,7 +152,6 @@ namespace {
|
||||
return 0.5 * bisect(p1, half, testFunction, half);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
@@ -294,7 +294,10 @@ RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary)
|
||||
if (dictionary.hasKey(KeyFrameConversions)) {
|
||||
ghoul::Dictionary fc = dictionary.value<ghoul::Dictionary>(KeyFrameConversions);
|
||||
for (const std::string& key : fc.keys()) {
|
||||
openspace::SpiceManager::ref().addFrame(key, fc.value<std::string>(key));
|
||||
global::moduleEngine.module<SpacecraftInstrumentsModule>()->addFrame(
|
||||
key,
|
||||
fc.value<std::string>(key)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -524,7 +527,12 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string&
|
||||
{
|
||||
const bool convert = (ref.find("IAU_") == std::string::npos);
|
||||
if (convert) {
|
||||
return { SpiceManager::ref().frameFromBody(target), true };
|
||||
return {
|
||||
global::moduleEngine.module<SpacecraftInstrumentsModule>()->frameFromBody(
|
||||
target
|
||||
),
|
||||
true
|
||||
};
|
||||
}
|
||||
else {
|
||||
return { ref, false };
|
||||
@@ -917,6 +925,7 @@ std::pair<std::string, bool> RenderableFov::determineTarget(double time) {
|
||||
bool inFOV = SpiceManager::ref().isTargetInFieldOfView(
|
||||
pt,
|
||||
_instrument.spacecraft,
|
||||
global::moduleEngine.module<SpacecraftInstrumentsModule>()->frameFromBody(pt),
|
||||
_instrument.name,
|
||||
SpiceManager::FieldOfViewMethod::Ellipsoid,
|
||||
_instrument.aberrationCorrection,
|
||||
|
||||
@@ -24,8 +24,10 @@
|
||||
|
||||
#include <modules/spacecraftinstruments/rendering/renderableplaneprojection.h>
|
||||
|
||||
#include <modules/spacecraftinstruments/spacecraftinstrumentsmodule.h>
|
||||
#include <modules/spacecraftinstruments/util/imagesequencer.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/moduleengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
@@ -309,7 +311,8 @@ void RenderablePlaneProjection::setTarget(std::string body) {
|
||||
return;
|
||||
}
|
||||
|
||||
_target.frame = SpiceManager::ref().frameFromBody(body);
|
||||
_target.frame =
|
||||
global::moduleEngine.module<SpacecraftInstrumentsModule>()->frameFromBody(body);
|
||||
_target.body = std::move(body);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,4 +94,31 @@ SpacecraftInstrumentsModule::documentations() const
|
||||
};
|
||||
}
|
||||
|
||||
bool SpacecraftInstrumentsModule::addFrame(std::string body, std::string frame) {
|
||||
if (body.empty() || frame.empty()) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
_frameByBody.emplace_back(body, frame);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::string SpacecraftInstrumentsModule::frameFromBody(const std::string& body) {
|
||||
for (const std::pair<std::string, std::string>& pair : _frameByBody) {
|
||||
if (pair.first == body) {
|
||||
return pair.second;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr const char* unionPrefix = "IAU_";
|
||||
|
||||
if (body.find(unionPrefix) == std::string::npos) {
|
||||
return unionPrefix + body;
|
||||
}
|
||||
else {
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -41,10 +41,16 @@ public:
|
||||
|
||||
static ghoul::opengl::ProgramObjectManager ProgramObjectManager;
|
||||
|
||||
bool addFrame(std::string body, std::string frame);
|
||||
std::string frameFromBody(const std::string& body);
|
||||
|
||||
protected:
|
||||
void internalInitialize(const ghoul::Dictionary&) override;
|
||||
void internalDeinitialize() override;
|
||||
void internalDeinitializeGL() override;
|
||||
|
||||
private:
|
||||
std::vector<std::pair<std::string, std::string>> _frameByBody;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user