diff --git a/data/assets/scene/solarsystem/missions/rosetta/mission.asset b/data/assets/scene/solarsystem/missions/rosetta/mission.asset index 32041c36a1..77161111a7 100644 --- a/data/assets/scene/solarsystem/missions/rosetta/mission.asset +++ b/data/assets/scene/solarsystem/missions/rosetta/mission.asset @@ -54,7 +54,7 @@ local Mission = { Name = "Perihelion passage ", Date = "2015 AUG 13 00:00:00", Description = "At 10:00 CET the spacecraft woke up and started post-hibernation procedures. Rosetta restored communications with ESA's Operations Centre through NASA’s Goldstone ground station at 18:17 CET. Greets the Earth with a 'Hello World' message. The message was received on a very low bit level. Over the next months ESA's job will be to raise communication speed through a software update.", - Media = { Image = "https://www.esa.int/var/esa/storage/images/esa_multimedia/images/2015/08/approaching_perihelion_animation/15556093-1-eng-GB/Approaching_perihelion_Animation_pillars.gif" } + Image = "https://www.esa.int/var/esa/storage/images/esa_multimedia/images/2015/08/approaching_perihelion_animation/15556093-1-eng-GB/Approaching_perihelion_Animation_pillars.gif" } }, Phases = { diff --git a/include/openspace/mission/mission.h b/include/openspace/mission/mission.h index a05cfee870..c221275058 100644 --- a/include/openspace/mission/mission.h +++ b/include/openspace/mission/mission.h @@ -37,6 +37,13 @@ namespace openspace { namespace documentation { struct Documentation; } +struct ImportantDate { + std::string name; + Time date; + std::optional description; + std::optional image; +}; + /** * Used to represent a named period of time within a mission. Allows nested phases, i.e. * phases within phases. Designed for WORM usage (Write Once, Read Multiple), and, @@ -102,7 +109,7 @@ public: * * \return All important dates */ - const std::vector>& importantDates() const; + const std::vector& importantDates() const; /** @@ -160,7 +167,7 @@ protected: /// Actions associated with the phase std::vector _actions; /// Important dates - std::vector> _importantDates; + std::vector _importantDates; }; /** diff --git a/modules/server/src/topics/missiontopic.cpp b/modules/server/src/topics/missiontopic.cpp index 40d7c82e0c..289fc43895 100644 --- a/modules/server/src/topics/missiontopic.cpp +++ b/modules/server/src/topics/missiontopic.cpp @@ -80,14 +80,22 @@ nlohmann::json MissionTopic::createPhaseJson(const MissionPhase& phase) const { json subphaseJson = createPhaseJson(missionPhase); phases.push_back(subphaseJson); } - - json importandDates = json::array(); - for (const std::pair date : phase.importantDates()) { + + json importantDates = json::array(); + const std::vector& dates = phase.importantDates(); + for (const ImportantDate& date : dates) { json jsonDate = { - { "date", std::string(date.second.ISO8601())}, - { "name", date.first } + { "date", std::string(date.date.ISO8601())}, + { "name", date.name } }; - importandDates.push_back(jsonDate); + + if (date.description.has_value()) { + jsonDate["description"] = date.description.value(); + } + if (date.image.has_value()) { + jsonDate["image"] = date.image.value(); + } + importantDates.push_back(jsonDate); } std::string startTimeString = std::string(Time(phase.timeRange().start).ISO8601()); @@ -105,7 +113,7 @@ nlohmann::json MissionTopic::createPhaseJson(const MissionPhase& phase) const { { "media",{ { "image", phase.image() } }}, - { "importantDates" , importandDates } + { "importantDates" , importantDates } }; return phaseJson; diff --git a/src/mission/mission.cpp b/src/mission/mission.cpp index c91ab07908..f4a71876d9 100644 --- a/src/mission/mission.cpp +++ b/src/mission/mission.cpp @@ -58,6 +58,7 @@ namespace { struct Media { // An image that can be presented to the user during this phase of a mission std::optional image; + std::optional link; }; std::optional media; @@ -67,9 +68,10 @@ namespace { // Important dates struct ImportantDates { // An image that can be presented to the user during this phase of a mission - std::optional date - [[codegen::annotation("A string representing a valid date")]]; + std::optional date; std::optional name; + std::optional description; + std::optional image; }; std::optional> importantDates; }; @@ -160,10 +162,17 @@ MissionPhase::MissionPhase(const ghoul::Dictionary& dictionary) { if (p.importantDates.has_value()) { _importantDates.reserve(p.importantDates->size()); - for (const auto& date : *p.importantDates) { - std::string name = date.name.value(); - Time time = Time(date.date.value()); - _importantDates.emplace_back(std::pair( name , time )); + for (int i = 0; i < p.importantDates->size(); i++) { + std::string name = p.importantDates.value()[i].name.value(); + Time newTime = Time(p.importantDates.value()[i].date.value()); + ImportantDate newDate = { name, newTime }; + if (p.importantDates.value()[i].description.has_value()) { + newDate.description = p.importantDates.value()[i].description.value(); + } + if (p.importantDates.value()[i].image.has_value()) { + newDate.image = p.importantDates.value()[i].image.value(); + } + _importantDates.emplace_back(newDate); } } } @@ -184,7 +193,7 @@ const std::string& MissionPhase::image() const { return _image; } -const std::vector>& MissionPhase::importantDates() const { +const std::vector& MissionPhase::importantDates() const { return _importantDates; }