mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-12 22:39:09 -05:00
Fix static initialization fiasco with touch input
Restore backwards compatibility of mod files Provide better feedback about specification errors
This commit is contained in:
@@ -347,7 +347,7 @@ return {
|
||||
Type = "SpiceTranslation",
|
||||
Body = "OSIRIS-REX",
|
||||
Frame = "IAU_EARTH",
|
||||
Observer = "EARTH",
|
||||
Observer = "EARTH",
|
||||
},
|
||||
Color = { 0.9, 0.9, 0.0 },
|
||||
StartTime = "2016 SEP 8 23:05:00.50",
|
||||
|
||||
@@ -42,9 +42,6 @@
|
||||
|
||||
namespace openspace {
|
||||
|
||||
gui::GUI OnScreenGUIModule::gui;
|
||||
Touch OnScreenGUIModule::touchInput;
|
||||
|
||||
OnScreenGUIModule::OnScreenGUIModule() : OpenSpaceModule(Name) {
|
||||
addPropertySubOwner(gui);
|
||||
|
||||
@@ -59,7 +56,7 @@ OnScreenGUIModule::OnScreenGUIModule() : OpenSpaceModule(Name) {
|
||||
|
||||
OsEng.registerModuleCallback(
|
||||
OpenSpaceEngine::CallbackOption::Initialize,
|
||||
[](){
|
||||
[&](){
|
||||
LDEBUGC("OnScreenGUIModule", "Initializing GUI");
|
||||
gui.initialize();
|
||||
|
||||
@@ -107,7 +104,7 @@ OnScreenGUIModule::OnScreenGUIModule() : OpenSpaceModule(Name) {
|
||||
|
||||
OsEng.registerModuleCallback(
|
||||
OpenSpaceEngine::CallbackOption::Deinitialize,
|
||||
[](){
|
||||
[&](){
|
||||
LDEBUGC("OnScreenGui", "Deinitialize GUI");
|
||||
gui.deinitialize();
|
||||
}
|
||||
@@ -115,7 +112,7 @@ OnScreenGUIModule::OnScreenGUIModule() : OpenSpaceModule(Name) {
|
||||
|
||||
OsEng.registerModuleCallback(
|
||||
OpenSpaceEngine::CallbackOption::InitializeGL,
|
||||
[](){
|
||||
[&](){
|
||||
LDEBUGC("OnScreenGui", "Initializing GUI OpenGL");
|
||||
gui.initializeGL();
|
||||
}
|
||||
@@ -123,7 +120,7 @@ OnScreenGUIModule::OnScreenGUIModule() : OpenSpaceModule(Name) {
|
||||
|
||||
OsEng.registerModuleCallback(
|
||||
OpenSpaceEngine::CallbackOption::DeinitializeGL,
|
||||
[](){
|
||||
[&](){
|
||||
LDEBUGC("OnScreenGui", "Deinitialize GUI OpenGL");
|
||||
gui.deinitializeGL();
|
||||
}
|
||||
@@ -134,7 +131,7 @@ OnScreenGUIModule::OnScreenGUIModule() : OpenSpaceModule(Name) {
|
||||
// everything else in the case of fisheyes. With this being in the Render callback
|
||||
// the GUI would be rendered on top of each of the cube faces
|
||||
OpenSpaceEngine::CallbackOption::PostDraw,
|
||||
[](){
|
||||
[&](){
|
||||
WindowWrapper& wrapper = OsEng.windowWrapper();
|
||||
bool showGui = wrapper.hasGuiWindow() ? wrapper.isGuiWindow() : true;
|
||||
if (wrapper.isMaster() && showGui ) {
|
||||
@@ -164,7 +161,7 @@ OnScreenGUIModule::OnScreenGUIModule() : OpenSpaceModule(Name) {
|
||||
);
|
||||
|
||||
OsEng.registerModuleKeyboardCallback(
|
||||
[](Key key, KeyModifier mod, KeyAction action) -> bool {
|
||||
[&](Key key, KeyModifier mod, KeyAction action) -> bool {
|
||||
if (gui.isEnabled()) {
|
||||
return gui.keyCallback(key, mod, action);
|
||||
}
|
||||
@@ -175,7 +172,7 @@ OnScreenGUIModule::OnScreenGUIModule() : OpenSpaceModule(Name) {
|
||||
);
|
||||
|
||||
OsEng.registerModuleCharCallback(
|
||||
[](unsigned int codepoint, KeyModifier modifier) -> bool {
|
||||
[&](unsigned int codepoint, KeyModifier modifier) -> bool {
|
||||
if (gui.isEnabled()) {
|
||||
return gui.charCallback(codepoint, modifier);
|
||||
}
|
||||
@@ -186,7 +183,7 @@ OnScreenGUIModule::OnScreenGUIModule() : OpenSpaceModule(Name) {
|
||||
);
|
||||
|
||||
OsEng.registerModuleMouseButtonCallback(
|
||||
[](MouseButton button, MouseAction action) -> bool {
|
||||
[&](MouseButton button, MouseAction action) -> bool {
|
||||
if (gui.isEnabled()) {
|
||||
return gui.mouseButtonCallback(button, action);
|
||||
}
|
||||
@@ -197,7 +194,7 @@ OnScreenGUIModule::OnScreenGUIModule() : OpenSpaceModule(Name) {
|
||||
);
|
||||
|
||||
OsEng.registerModuleMouseScrollWheelCallback(
|
||||
[](double, double posY) -> bool {
|
||||
[&](double, double posY) -> bool {
|
||||
if (gui.isEnabled()) {
|
||||
return gui.mouseWheelCallback(posY);
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ public:
|
||||
|
||||
OnScreenGUIModule();
|
||||
|
||||
static gui::GUI gui;
|
||||
static Touch touchInput;
|
||||
gui::GUI gui;
|
||||
Touch touchInput = { false, glm::vec2(0), 0 };
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/engine/moduleengine.h>
|
||||
|
||||
namespace openspace::gui::luascriptfunctions {
|
||||
|
||||
/**
|
||||
@@ -35,7 +37,7 @@ int show(lua_State* L) {
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
|
||||
}
|
||||
|
||||
OnScreenGUIModule::gui.setEnabled(true);
|
||||
OsEng.moduleEngine().module<OnScreenGUIModule>()->gui.setEnabled(true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -50,7 +52,7 @@ int hide(lua_State* L) {
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
|
||||
}
|
||||
|
||||
OnScreenGUIModule::gui.setEnabled(false);
|
||||
OsEng.moduleEngine().module<OnScreenGUIModule>()->gui.setEnabled(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -65,7 +67,9 @@ int toggle(lua_State* L) {
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
|
||||
}
|
||||
|
||||
OnScreenGUIModule::gui.setEnabled(!OnScreenGUIModule::gui.isEnabled());
|
||||
OsEng.moduleEngine().module<OnScreenGUIModule>()->gui.setEnabled(
|
||||
!OsEng.moduleEngine().module<OnScreenGUIModule>()->gui.isEnabled()
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,19 +32,17 @@
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
namespace {
|
||||
const char* KeySourceFrame = "SourceFrame";
|
||||
const char* KeyDestinationFrame = "DestinationFrame";
|
||||
const char* KeyKernels = "Kernels";
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo SourceInfo = {
|
||||
"Source",
|
||||
"SourceFrame",
|
||||
"Source",
|
||||
"This value specifies the source frame that is used as the basis for the "
|
||||
"coordinate transformation. This has to be a valid SPICE name."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo DestinationInfo = {
|
||||
"Destination",
|
||||
"DestinationFrame",
|
||||
"Destination",
|
||||
"This value specifies the destination frame that is used for the coordinate "
|
||||
"transformation. This has to be a valid SPICE name."
|
||||
|
||||
@@ -36,6 +36,8 @@ namespace {
|
||||
const char* KeyBody = "Body";
|
||||
const char* KeyKernels = "Kernels";
|
||||
|
||||
const char* DefaultReferenceFrame = "GALACTIC";
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo TargetInfo = {
|
||||
"Target",
|
||||
"Target",
|
||||
@@ -44,9 +46,9 @@ namespace {
|
||||
"or a NAIF integer id code (such as '399')."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo OriginInfo = {
|
||||
"Origin",
|
||||
"Origin",
|
||||
static const openspace::properties::Property::PropertyInfo ObserverInfo = {
|
||||
"Observer",
|
||||
"Observer",
|
||||
"This is the SPICE NAIF name for the parent of the body whose translation is to "
|
||||
"be computed by the SpiceTranslation. It can either be a fully qualified name "
|
||||
"(such as 'SOLAR SYSTEM BARYCENTER') or a NAIF integer id code (such as '0')."
|
||||
@@ -65,7 +67,7 @@ namespace openspace {
|
||||
documentation::Documentation SpiceTranslation::Documentation() {
|
||||
using namespace openspace::documentation;
|
||||
|
||||
return{
|
||||
return {
|
||||
"Spice Translation",
|
||||
"space_translation_spicetranslation",
|
||||
{
|
||||
@@ -84,9 +86,9 @@ documentation::Documentation SpiceTranslation::Documentation() {
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
OriginInfo.identifier,
|
||||
ObserverInfo.identifier,
|
||||
new StringAnnotationVerifier("A valid SPICE NAIF name or identifier"),
|
||||
OriginInfo.description,
|
||||
ObserverInfo.description,
|
||||
Optional::No
|
||||
},
|
||||
{
|
||||
@@ -95,7 +97,7 @@ documentation::Documentation SpiceTranslation::Documentation() {
|
||||
"A valid SPICE NAIF name for a reference frame"
|
||||
),
|
||||
FrameInfo.description,
|
||||
Optional::No
|
||||
Optional::Yes
|
||||
},
|
||||
{
|
||||
KeyKernels,
|
||||
@@ -115,8 +117,8 @@ documentation::Documentation SpiceTranslation::Documentation() {
|
||||
|
||||
SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary)
|
||||
: _target(TargetInfo)
|
||||
, _origin(OriginInfo)
|
||||
, _frame(FrameInfo)
|
||||
, _observer(ObserverInfo)
|
||||
, _frame(FrameInfo, DefaultReferenceFrame)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
@@ -124,9 +126,12 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary)
|
||||
"SpiceTranslation"
|
||||
);
|
||||
|
||||
_target = dictionary.value<std::string>(TargetInfo.identifier);
|
||||
_origin = dictionary.value<std::string>(OriginInfo.identifier);
|
||||
_frame = dictionary.value<std::string>(FrameInfo.identifier);
|
||||
_target = dictionary.value<std::string>(KeyBody);
|
||||
_observer = dictionary.value<std::string>(ObserverInfo.identifier);
|
||||
|
||||
if (dictionary.hasKey(FrameInfo.identifier)) {
|
||||
_frame = dictionary.value<std::string>(FrameInfo.identifier);
|
||||
}
|
||||
|
||||
auto loadKernel = [](const std::string& kernel) {
|
||||
if (!FileSys.fileExists(kernel)) {
|
||||
@@ -163,8 +168,8 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary)
|
||||
_target.onChange(update);
|
||||
addProperty(_target);
|
||||
|
||||
_origin.onChange(update);
|
||||
addProperty(_origin);
|
||||
_observer.onChange(update);
|
||||
addProperty(_observer);
|
||||
|
||||
_frame.onChange(update);
|
||||
addProperty(_frame);
|
||||
@@ -177,7 +182,12 @@ glm::dvec3 SpiceTranslation::position() const {
|
||||
void SpiceTranslation::update(const UpdateData& data) {
|
||||
double lightTime = 0.0;
|
||||
_position = SpiceManager::ref().targetPosition(
|
||||
_target, _origin, _frame, {}, data.time.j2000Seconds(), lightTime
|
||||
_target,
|
||||
_observer,
|
||||
_frame,
|
||||
{},
|
||||
data.time.j2000Seconds(),
|
||||
lightTime
|
||||
) * glm::pow(10.0, 3.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
|
||||
private:
|
||||
properties::StringProperty _target;
|
||||
properties::StringProperty _origin;
|
||||
properties::StringProperty _observer;
|
||||
properties::StringProperty _frame;
|
||||
|
||||
glm::dvec3 _position;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <modules/onscreengui/onscreenguimodule.h>
|
||||
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/engine/moduleengine.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/query/query.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
@@ -213,7 +214,8 @@ TouchInteraction::TouchInteraction()
|
||||
});
|
||||
|
||||
levmarq_init(&_lmstat);
|
||||
OnScreenGUIModule::touchInput = { false, glm::vec2(0), 0 };
|
||||
|
||||
|
||||
_time.initSession();
|
||||
}
|
||||
|
||||
@@ -248,17 +250,20 @@ bool TouchInteraction::guiMode(const std::vector<TuioCursor>& list) {
|
||||
WindowWrapper& wrapper = OsEng.windowWrapper();
|
||||
glm::ivec2 res = wrapper.currentWindowSize();
|
||||
glm::dvec2 pos = glm::vec2(list.at(0).getScreenX(res.x), list.at(0).getScreenY(res.y)); // mouse pixel position
|
||||
_guiON = OnScreenGUIModule::gui.isEnabled();
|
||||
|
||||
OnScreenGUIModule& module = *(OsEng.moduleEngine().module<OnScreenGUIModule>());
|
||||
_guiON = module.gui.isEnabled();
|
||||
|
||||
if (_tap && list.size() == 1 && std::abs(pos.x) < _guiButton.value().x && std::abs(pos.y) < _guiButton.value().y) { // pressed invisible button
|
||||
_guiON = !_guiON;
|
||||
OnScreenGUIModule::gui.setEnabled(_guiON);
|
||||
module.gui.setEnabled(_guiON);
|
||||
|
||||
std::string mode = (_guiON) ? "" : "de";
|
||||
LINFO("GUI mode is " << mode << "activated. Inside box by: (" <<
|
||||
static_cast<int>(100 * (pos.x / _guiButton.value().x)) << "%, " << static_cast<int>(100 * (pos.y / _guiButton.value().y)) << "%)\n");
|
||||
}
|
||||
else if (_guiON) {
|
||||
OnScreenGUIModule::touchInput = { _guiON, pos, 1 }; // emulate touch input as a mouse
|
||||
module.touchInput = { _guiON, pos, 1 }; // emulate touch input as a mouse
|
||||
}
|
||||
return _guiON;
|
||||
}
|
||||
@@ -450,7 +455,7 @@ void TouchInteraction::directControl(const std::vector<TuioCursor>& list) {
|
||||
_vel.pan = glm::dvec2(0.0, 0.0);
|
||||
}
|
||||
else { // prevents touch to infinitely be active (due to windows bridge case where event doesnt get consumed sometimes when LMA fails to converge)
|
||||
OnScreenGUIModule::touchInput = { 1, glm::dvec2(0.0, 0.0), 1 };
|
||||
OsEng.moduleEngine().module<OnScreenGUIModule>()->touchInput = { 1, glm::dvec2(0.0, 0.0), 1 };
|
||||
resetAfterInput();
|
||||
}
|
||||
}
|
||||
@@ -809,22 +814,23 @@ void TouchInteraction::resetAfterInput() {
|
||||
}
|
||||
}
|
||||
// Reset emulated mouse values
|
||||
OnScreenGUIModule& module = *(OsEng.moduleEngine().module<OnScreenGUIModule>());
|
||||
if (_guiON) {
|
||||
bool activeLastFrame = OnScreenGUIModule::touchInput.action;
|
||||
OnScreenGUIModule::touchInput.active = false;
|
||||
bool activeLastFrame = module.touchInput.action;
|
||||
module.touchInput.active = false;
|
||||
if (activeLastFrame) {
|
||||
OnScreenGUIModule::touchInput.active = true;
|
||||
OnScreenGUIModule::touchInput.action = 0;
|
||||
module.touchInput.active = true;
|
||||
module.touchInput.action = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
OnScreenGUIModule::touchInput.active = false;
|
||||
OnScreenGUIModule::touchInput.action = 0;
|
||||
module.touchInput.active = false;
|
||||
module.touchInput.action = 0;
|
||||
}
|
||||
|
||||
_lmSuccess = true;
|
||||
// Ensure that _guiON is consistent with properties in OnScreenGUI and
|
||||
_guiON = OnScreenGUIModule::gui.isEnabled();
|
||||
_guiON = module.gui.isEnabled();
|
||||
|
||||
// Reset variables
|
||||
_lastVel.orbit = glm::dvec2(0.0, 0.0);
|
||||
|
||||
@@ -276,7 +276,24 @@ std::vector<SceneLoader::LoadedNode> SceneLoader::loadModule(const std::string&
|
||||
}
|
||||
try {
|
||||
loadedNodes.push_back(loadNode(nodeDictionary));
|
||||
} catch (ghoul::RuntimeError& e) {
|
||||
}
|
||||
catch (documentation::SpecificationError& e) {
|
||||
LERROR("Specification error in node from " << path);
|
||||
LERRORC(e.component, e.message);
|
||||
for (const documentation::TestResult::Offense& offense : e.result.offenses) {
|
||||
LERRORC(
|
||||
e.component,
|
||||
offense.offender + ": " + std::to_string(offense.reason)
|
||||
);
|
||||
}
|
||||
for (const documentation::TestResult::Warning& warning : e.result.warnings) {
|
||||
LWARNINGC(
|
||||
e.component,
|
||||
warning.offender + ": " + std::to_string(warning.reason)
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (ghoul::RuntimeError& e) {
|
||||
LERROR("Failed loading node from " << path << ": " << e.message << ", " << e.component);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user