mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
exposed renderable type to gui, fixed path for milkyway items (#866)
* exposed renderable type to gui, fixed path for miklyway items * Changes to session recording topic * Update webgui
This commit is contained in:
committed by
Emil Axelsson
parent
915d57f6f0
commit
0eabffe752
@@ -41,12 +41,15 @@ public:
|
||||
private:
|
||||
const int UnsetOnChangeHandle = -1;
|
||||
|
||||
//Provides the idle/recording/playback state int value in json message
|
||||
nlohmann::json state();
|
||||
bool _sendState;
|
||||
bool _sendFiles;
|
||||
|
||||
// Provides the idle/recording/playback state int value in json message
|
||||
void sendJsonData();
|
||||
|
||||
interaction::SessionRecording::SessionState _lastState;
|
||||
int _stateCallbackHandle = UnsetOnChangeHandle;
|
||||
bool _isDone = false;
|
||||
interaction::SessionRecording::SessionState _lastState;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -72,11 +72,6 @@ void GetPropertyTopic::handleJson(const nlohmann::json& json) {
|
||||
else if (requestedKey == RootPropertyOwner) {
|
||||
response = wrappedPayload(global::rootPropertyOwner);
|
||||
}
|
||||
else if (requestedKey == SessionRecordingPlaybackList) {
|
||||
std::string fileList = global::sessionRecording.playbackList();
|
||||
nlohmann::json getJson = { { SessionRecordingPlaybackList, fileList } };
|
||||
response = wrappedPayload(getJson);
|
||||
}
|
||||
else {
|
||||
response = propertyFromKey(requestedKey);
|
||||
}
|
||||
|
||||
@@ -32,10 +32,14 @@
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "SessionRecordingTopic";
|
||||
constexpr const char* PropertyKey = "property";
|
||||
constexpr const char* EventKey = "event";
|
||||
constexpr const char* SubscribeEvent = "start_subscription";
|
||||
constexpr const char* UnsubscribeEvent = "stop_subscription";
|
||||
constexpr const char* StateKey = "recState";
|
||||
constexpr const char* RefreshEvent = "refresh";
|
||||
|
||||
constexpr const char* PropertiesKey = "properties";
|
||||
constexpr const char* FilesKey = "files";
|
||||
constexpr const char* StateKey = "state";
|
||||
} // namespace
|
||||
|
||||
using nlohmann::json;
|
||||
@@ -59,37 +63,87 @@ bool SessionRecordingTopic::isDone() const {
|
||||
}
|
||||
|
||||
void SessionRecordingTopic::handleJson(const nlohmann::json& json) {
|
||||
std::string event = json.at(EventKey).get<std::string>();
|
||||
using SessionRecording = openspace::interaction::SessionRecording;
|
||||
|
||||
const std::string event = json.at(EventKey).get<std::string>();
|
||||
if (event != SubscribeEvent &&
|
||||
event != UnsubscribeEvent &&
|
||||
event != RefreshEvent)
|
||||
{
|
||||
LERROR("Unsupported event.");
|
||||
_isDone = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (event == UnsubscribeEvent) {
|
||||
_isDone = true;
|
||||
return;
|
||||
}
|
||||
|
||||
std::string requestedKey = json.at(PropertyKey).get<std::string>();
|
||||
LDEBUG("Subscribing to " + requestedKey);
|
||||
|
||||
if (requestedKey == StateKey) {
|
||||
_stateCallbackHandle = global::sessionRecording.addStateChangeCallback(
|
||||
[this]() {
|
||||
openspace::interaction::SessionRecording::SessionState nowState =
|
||||
global::sessionRecording.state();
|
||||
if (nowState != _lastState) {
|
||||
_connection->sendJson(state());
|
||||
_lastState = nowState;
|
||||
}
|
||||
if (json.find(PropertiesKey) != json.end()) {
|
||||
if (!json.at(PropertiesKey).is_array()) {
|
||||
LERROR("Properties must be an array of strings.");
|
||||
}
|
||||
nlohmann::json requestedProperties = json.at(PropertiesKey).get<nlohmann::json>();
|
||||
for (const auto& p : requestedProperties) {
|
||||
if (!p.is_string()) {
|
||||
_isDone = true;
|
||||
LERROR("Properties must be an array of strings.");
|
||||
return;
|
||||
}
|
||||
);
|
||||
_connection->sendJson(state());
|
||||
const std::string v = p.get<std::string>();
|
||||
if (v == FilesKey) {
|
||||
_sendFiles = true;
|
||||
}
|
||||
if (v == StateKey) {
|
||||
_sendState = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
LWARNING("Cannot get " + requestedKey);
|
||||
_isDone = true;
|
||||
|
||||
sendJsonData();
|
||||
|
||||
if (event == SubscribeEvent) {
|
||||
if (_sendState) {
|
||||
_stateCallbackHandle = global::sessionRecording.addStateChangeCallback(
|
||||
[this]() {
|
||||
SessionRecording::SessionState currentState =
|
||||
global::sessionRecording.state();
|
||||
if (currentState != _lastState) {
|
||||
sendJsonData();
|
||||
_lastState = currentState;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
json SessionRecordingTopic::state() {
|
||||
json statJson = { { "state", static_cast<int>(global::sessionRecording.state()) } };
|
||||
return wrappedPayload(statJson);
|
||||
void SessionRecordingTopic::sendJsonData() {
|
||||
json stateJson;
|
||||
using SessionRecording = openspace::interaction::SessionRecording;
|
||||
if (_sendState) {
|
||||
SessionRecording::SessionState state = global::sessionRecording.state();
|
||||
std::string stateString;
|
||||
switch (state) {
|
||||
case SessionRecording::SessionState::Recording:
|
||||
stateString = "recording";
|
||||
break;
|
||||
case SessionRecording::SessionState::Playback:
|
||||
stateString = "playing";
|
||||
break;
|
||||
default:
|
||||
stateString = "idle";
|
||||
break;
|
||||
}
|
||||
stateJson[StateKey] = stateString;
|
||||
};
|
||||
if (_sendFiles) {
|
||||
stateJson[FilesKey] = global::sessionRecording.playbackList();
|
||||
}
|
||||
if (stateJson.size() > 0) {
|
||||
_connection->sendJson(wrappedPayload(stateJson));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user