Add BoolProperty to SpaceModule to control SpiceManager exception handling (closes #661)

Add debugging indices to SceneGraphNodes
Rename ImGui indices debugging definition
This commit is contained in:
Alexander Bock
2018-07-12 17:48:34 -04:00
parent d20bb6d634
commit 12c87969a7
8 changed files with 51 additions and 21 deletions

View File

@@ -34,6 +34,8 @@
#include <memory>
#include <vector>
//#define Debugging_Core_SceneGraphNode_Indices
namespace ghoul { class Dictionary; }
namespace openspace {
@@ -180,6 +182,11 @@ private:
glm::dmat4 _modelTransformCached;
glm::dmat4 _inverseModelTransformCached;
#ifdef Debugging_Core_SceneGraphNode_Indices
int index = 0;
static int nextIndex;
#endif // Debugging_Core_SceneGraphNode_Indices
};
} // namespace openspace

View File

@@ -30,7 +30,7 @@
#include <ghoul/misc/misc.h>
#include <algorithm>
//#define Debugging_ImGui_TreeNode
//#define Debugging_ImGui_TreeNode_Indices
namespace {
const ImVec2 Size = ImVec2(350, 500);
@@ -85,26 +85,26 @@ namespace {
struct TreeNode {
TreeNode(std::string p)
: path(std::move(p))
#ifdef Debugging_ImGui_TreeNode
#ifdef Debugging_ImGui_TreeNode_Indices
, index(nextIndex++)
#endif // Debugging_ImGui_TreeNode
#endif // Debugging_ImGui_TreeNode_Indices
{}
std::string path;
std::vector<std::unique_ptr<TreeNode>> children;
std::vector<openspace::SceneGraphNode*> nodes;
#ifdef Debugging_ImGui_TreeNode
#ifdef Debugging_ImGui_TreeNode_Indices
int index = 0;
static int nextIndex;
#endif // Debugging_ImGui_TreeNode
#endif // Debugging_ImGui_TreeNode_Indices
};
#ifdef Debugging_ImGui_TreeNode
#ifdef Debugging_ImGui_TreeNode_Indices
int TreeNode::nextIndex = 0;
#endif // Debugging_ImGui_TreeNode
#endif // Debugging_ImGui_TreeNode_Indices
void addPathToTree(TreeNode& node, const std::vector<std::string>& path,
openspace::SceneGraphNode* owner)

View File

@@ -124,16 +124,11 @@ SpiceRotation::SpiceRotation(const ghoul::Dictionary& dictionary)
}
glm::dmat3 SpiceRotation::matrix(const Time& time) const {
try {
return SpiceManager::ref().positionTransformMatrix(
_sourceFrame,
_destinationFrame,
time.j2000Seconds()
);
}
catch (const SpiceManager::SpiceException&) {
return glm::dmat3(1.0);
}
return SpiceManager::ref().positionTransformMatrix(
_sourceFrame,
_destinationFrame,
time.j2000Seconds()
);
}
} // namespace openspace

View File

@@ -37,14 +37,32 @@
#include <openspace/rendering/renderable.h>
#include <openspace/rendering/screenspacerenderable.h>
#include <openspace/util/factorymanager.h>
#include <openspace/util/spicemanager.h>
#include <ghoul/misc/assert.h>
#include <ghoul/misc/templatefactory.h>
namespace {
constexpr openspace::properties::Property::PropertyInfo SpiceExceptionInfo = {
"ShowExceptions",
"Show Exceptions",
"If enabled, errors from SPICE will be thrown and show up in the log. If "
"disabled, the errors will be ignored silently."
};
} // namespace
namespace openspace {
ghoul::opengl::ProgramObjectManager SpaceModule::ProgramObjectManager;
SpaceModule::SpaceModule() : OpenSpaceModule(Name) {}
SpaceModule::SpaceModule()
: OpenSpaceModule(Name)
, _showSpiceExceptions(SpiceExceptionInfo, true)
{
_showSpiceExceptions.onChange([&t = _showSpiceExceptions](){
SpiceManager::ref().setExceptionHandling(SpiceManager::UseException(t));
});
addProperty(_showSpiceExceptions);
}
void SpaceModule::internalInitialize(const ghoul::Dictionary&) {
FactoryManager::ref().addFactory(

View File

@@ -27,6 +27,7 @@
#include <openspace/util/openspacemodule.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <ghoul/opengl/programobjectmanager.h>
namespace openspace {
@@ -44,6 +45,8 @@ public:
private:
void internalInitialize(const ghoul::Dictionary&) override;
void internalDeinitializeGL() override;
properties::BoolProperty _showSpiceExceptions;
};
} // namespace openspace

View File

@@ -52,6 +52,10 @@ namespace {
namespace openspace {
#ifdef Debugging_Core_SceneGraphNode_Indices
int SceneGraphNode::nextIndex = 0;
#endif // Debugging_Core_SceneGraphNode_Indices
std::unique_ptr<SceneGraphNode> SceneGraphNode::createFromDictionary(
const ghoul::Dictionary& dictionary)
{
@@ -62,6 +66,9 @@ std::unique_ptr<SceneGraphNode> SceneGraphNode::createFromDictionary(
);
std::unique_ptr<SceneGraphNode> result = std::make_unique<SceneGraphNode>();
#ifdef Debugging_Core_SceneGraphNode_Indices
result->index = nextIndex++;
#endif // Debugging_Core_SceneGraphNode_Indices
std::string identifier = dictionary.value<std::string>(KeyIdentifier);
result->setIdentifier(std::move(identifier));
@@ -614,7 +621,7 @@ glm::dvec3 SceneGraphNode::calculateWorldPosition() const {
}
bool SceneGraphNode::isTimeFrameActive(const Time& time) const {
for (const auto& dep : _dependencies) {
for (SceneGraphNode* dep : _dependencies) {
if (!dep->isTimeFrameActive(time)) {
return false;
}

View File

@@ -401,7 +401,7 @@ bool SpiceManager::hasFrameId(const std::string& frame) const {
}
void getValueInternal(const std::string& body, const std::string& value, int size,
double* v)
double* v)
{
ghoul_assert(!body.empty(), "Empty body");
ghoul_assert(!value.empty(), "Empty value");