mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-06 11:29:55 -05:00
Added first version of mission visualization
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
-- Source: http://pluto.jhuapl.edu/Mission/index.php
|
||||
-- Many of the values (especially days of the month if 01 or 30 or 31 and hh::mm::ss if all 0)
|
||||
-- are approximate and need fixing
|
||||
|
||||
return {
|
||||
Name = "New Horizons",
|
||||
Phases = {
|
||||
{
|
||||
Name = "Cruise Phase",
|
||||
TimeRange = { Start = "2006 JAN 19 00:00:00", End = "2015 JAN 15 00:00:00" },
|
||||
Phases = {
|
||||
{
|
||||
Name = "Jupiter fly-by",
|
||||
TimeRange = { Start = "2007 FEB 28 00:00:00", End = "2007 FEB 28 23:59:59" }
|
||||
},
|
||||
{
|
||||
Name = "Annual checkout 1",
|
||||
TimeRange = { Start = "2007 SEP 01 00:00:00", End = "2007 NOV 30 00:00:00" }
|
||||
},
|
||||
{
|
||||
Name = "Annual checkout 2",
|
||||
TimeRange = { Start = "2008 JUL 01 00:00:00", End = "2008 AUG 31 00:00:00" }
|
||||
},
|
||||
{
|
||||
Name = "Annual checkout 3",
|
||||
TimeRange = { Start = "2009 JUL 01 00:00:00", End = "2009 AUG 31 00:00:00" }
|
||||
},
|
||||
{
|
||||
Name = "Annual checkout 4",
|
||||
TimeRange = { Start = "2010 MAY 01 00:00:00", End = "2010 JUL 31 00:00:00" }
|
||||
},
|
||||
{
|
||||
Name = "Annual checkout 5",
|
||||
TimeRange = { Start = "2011 MAY 01 00:00:00", End = "2011 JUL 31 00:00:00" }
|
||||
},
|
||||
{
|
||||
Name = "Annual checkout 6",
|
||||
TimeRange = { Start = "2012 MAY 01 00:00:00", End = "2012 JUL 31 00:00:00" }
|
||||
},
|
||||
{
|
||||
Name = "Annual checkout 7",
|
||||
TimeRange = { Start = "2013 MAY 01 00:00:00", End = "2013 AUG 31 00:00:00" }
|
||||
},
|
||||
{
|
||||
Name = "Annual checkout 8 and Optical Navigation campaign 1",
|
||||
TimeRange = { Start = "2014 JUN 01 00:00:00", End = "2014 AUG 31 00:00:00" }
|
||||
},
|
||||
{
|
||||
Name = "Final Wakeup from Hibernation",
|
||||
TimeRange = { Start = "2014 DEC 06 00:00:00", End = "2014 DEC 06 23:59:59" }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
Name = "Pluto Encounter/Approach Phase 1",
|
||||
TimeRange = { Start = "2015 JAN 15 00:00:00", End = "2015 APR 01 00:00:00" },
|
||||
Phases = {
|
||||
{
|
||||
Name = "Optical nagivation campaign 2",
|
||||
TimeRange = { Start = "2015 JAN 25 00:00:00", End = "2015 APR 01 00:00:00" }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
Name = "Pluto Encounter/Approach Phase 2",
|
||||
TimeRange = { Start = "2015 APR 01 00:00:00", End = "2015 JUN 01 00:00:00" },
|
||||
Phases = {
|
||||
{
|
||||
Name = "Best-ever images of Pluto",
|
||||
TimeRange = { Start = "2015 MAY 01 00:00:00", End = "2015 JUN 01 00:00:00" }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
Name = "Pluto Encounter/Approach Phase 3",
|
||||
TimeRange = { Start = "2015 JUN 01 00:00:00", End = "2015 JUL 15 00:00:00" },
|
||||
Phases = {
|
||||
{
|
||||
Name = "Closest approach to Pluto",
|
||||
TimeRange = { Start = "2015 JUL 14 11:49:57", End = "2015 JUL 14 11:49:58" }
|
||||
},
|
||||
{
|
||||
Name = "Closest approach to Charon",
|
||||
TimeRange = { Start = "2015 JUL 14 12:03:50", End = "2015 JUL 14 12:03:51" }
|
||||
},
|
||||
{
|
||||
Name = "Pluto-Sun Occultation",
|
||||
TimeRange = { Start = "2015 JUL 14 12:51:25", End = "2015 JUL 14 12:52:00" }
|
||||
},
|
||||
{
|
||||
Name = "Pluto-Earth Occultation",
|
||||
TimeRange = { Start = "2015 JUL 14 12:52:27", End = "2015 JUL 14 12:53:00" }
|
||||
},
|
||||
{
|
||||
Name = "Charon-Sun Occultation",
|
||||
TimeRange = { Start = "2015 JUL 14 14:17:40", End = "2015 JUL 14 14:18:00" }
|
||||
},
|
||||
{
|
||||
Name = "Charon-Earth Occultation",
|
||||
TimeRange = { Start = "2015 JUL 14 14:20:00", End = "2015 JUL 14 14:21:00" }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
Name = "Departure Phase 1",
|
||||
TimeRange = { Start = "2015 JUL 15 00:00:00", End = "2015 AUG 01 00:00:00" }
|
||||
},
|
||||
{
|
||||
Name = "Departure Phase 2",
|
||||
TimeRange = { Start = "2015 AUG 01 00:00:00", End = "2015 OCT 01 00:00:00" }
|
||||
},
|
||||
{
|
||||
Name = "Departure Phase 3",
|
||||
TimeRange = { Start = "2015 OCT 01 00:00:00", End = "2016 JAN 01 00:00:00" }
|
||||
},
|
||||
{
|
||||
Name = "Data Playback Ends",
|
||||
TimeRange = { Start = "2016 OCT 01 00:00:00", End = "2016 DEC 01 00:00:00" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +188,8 @@ function postInitialization()
|
||||
|
||||
openspace.printInfo("Done setting default values")
|
||||
|
||||
openspace.loadMission("${OPENSPACE_DATA}/scene/missions/newhorizons/newhorizons/newhorizons.mission")
|
||||
|
||||
-- Defined in scene_helper.lua
|
||||
-- Used to create focus buttons for a subset of scenegraph nodes
|
||||
mark_interesting_nodes({
|
||||
|
||||
@@ -32,6 +32,7 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guifilepathcomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guiglobebrowsingcomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guihelpcomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guimissioncomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guiperformancecomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guiparallelcomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guipropertycomponent.h
|
||||
@@ -48,6 +49,7 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guifilepathcomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guiglobebrowsingcomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guihelpcomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guimissioncomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guiperformancecomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guiparallelcomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guipropertycomponent.cpp
|
||||
|
||||
@@ -29,15 +29,15 @@
|
||||
#include <modules/imgui/include/guifilepathcomponent.h>
|
||||
#include <modules/imgui/include/guiglobebrowsingcomponent.h>
|
||||
#include <modules/imgui/include/guihelpcomponent.h>
|
||||
#include <modules/imgui/include/guiiswacomponent.h>
|
||||
#include <modules/imgui/include/guimissioncomponent.h>
|
||||
#include <modules/imgui/include/guiparallelcomponent.h>
|
||||
#include <modules/imgui/include/guiperformancecomponent.h>
|
||||
#include <modules/imgui/include/guipropertycomponent.h>
|
||||
#include <modules/imgui/include/guiorigincomponent.h>
|
||||
#include <modules/imgui/include/guispacetimecomponent.h>
|
||||
#include <modules/imgui/include/guiiswacomponent.h>
|
||||
#include <modules/imgui/include/guiparallelcomponent.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/properties/property.h>
|
||||
|
||||
#include <openspace/properties/property.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/util/keys.h>
|
||||
#include <openspace/util/mouse.h>
|
||||
|
||||
@@ -77,6 +77,7 @@ public:
|
||||
GuiPropertyComponent _screenSpaceProperty;
|
||||
GuiPropertyComponent _virtualProperty;
|
||||
GuiSpaceTimeComponent _spaceTime;
|
||||
GuiMissionComponent _mission;
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
GuiIswaComponent _iswa;
|
||||
#endif // OPENSPACE_MODULE_ISWA_ENABLED
|
||||
|
||||
+5
-5
@@ -22,20 +22,20 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_MODULE_IMGUI___GUIORIGINCOMPONENT___H__
|
||||
#define __OPENSPACE_MODULE_IMGUI___GUIORIGINCOMPONENT___H__
|
||||
#ifndef __OPENSPACE_MODULE_IMGUI___GUIMISSIONCOMPONENT___H__
|
||||
#define __OPENSPACE_MODULE_IMGUI___GUIMISSIONCOMPONENT___H__
|
||||
|
||||
#include <modules/imgui/include/guicomponent.h>
|
||||
|
||||
namespace openspace::gui {
|
||||
|
||||
class GuiOriginComponent : public GuiComponent {
|
||||
class GuiMissionComponent: public GuiComponent {
|
||||
public:
|
||||
GuiOriginComponent();
|
||||
GuiMissionComponent();
|
||||
|
||||
void render() override;
|
||||
};
|
||||
|
||||
} // namespace openspace::gui
|
||||
|
||||
#endif // __OPENSPACE_MODULE_IMGUI___GUIORIGINCOMPONENT___H__
|
||||
#endif // __OPENSPACE_MODULE_IMGUI___GUIMISSIONCOMPONENT___H__
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <modules/imgui/imguimodule.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/mission/missionmanager.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/keys.h>
|
||||
|
||||
@@ -268,6 +269,7 @@ GUI::GUI()
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
addPropertySubOwner(_filePath);
|
||||
addPropertySubOwner(_spaceTime);
|
||||
addPropertySubOwner(_mission);
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
addPropertySubOwner(_iswa);
|
||||
#endif // OPENSPACE_MODULE_ISWA_ENABLED
|
||||
@@ -391,6 +393,7 @@ void GUI::initialize() {
|
||||
_performance.initialize();
|
||||
_help.initialize();
|
||||
_parallel.initialize();
|
||||
_mission.initialize();
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
_iswa.initialize();
|
||||
#endif // OPENSPACE_MODULE_ISWA_ENABLED
|
||||
@@ -402,6 +405,7 @@ void GUI::deinitialize() {
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
_iswa.deinitialize();
|
||||
#endif // OPENSPACE_MODULE_ISWA_ENABLED
|
||||
_mission.deinitialize();
|
||||
_parallel.deinitialize();
|
||||
_help.deinitialize();
|
||||
_performance.deinitialize();
|
||||
@@ -494,6 +498,7 @@ void GUI::initializeGL() {
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
_filePath.initializeGL();
|
||||
_parallel.initializeGL();
|
||||
_mission.initializeGL();
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
_iswa.initializeGL();
|
||||
#endif // OPENSPACE_MODULE_ISWA_ENABLED
|
||||
@@ -517,6 +522,7 @@ void GUI::deinitializeGL() {
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
_iswa.deinitializeGL();
|
||||
#endif // OPENSPACE_MODULE_ISWA_ENABLED
|
||||
_mission.deinitializeGL();
|
||||
_parallel.deinitializeGL();
|
||||
_help.deinitializeGL();
|
||||
_performance.deinitializeGL();
|
||||
@@ -592,6 +598,10 @@ void GUI::endFrame() {
|
||||
}
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
|
||||
if (_mission.isEnabled() && MissionManager::ref().hasCurrentMission()) {
|
||||
_mission.render();
|
||||
}
|
||||
|
||||
// We always want to render the Space/Time component
|
||||
_spaceTime.render();
|
||||
|
||||
@@ -692,6 +702,10 @@ void GUI::render() {
|
||||
ImGui::Checkbox("Virtual Properties", &virtualProperty);
|
||||
_virtualProperty.setEnabled(virtualProperty);
|
||||
|
||||
bool mission = _mission.isEnabled();
|
||||
ImGui::Checkbox("Mission Information", &mission);
|
||||
_mission.setEnabled(mission);
|
||||
|
||||
bool filePath = _filePath.isEnabled();
|
||||
ImGui::Checkbox("File Paths", &filePath);
|
||||
_filePath.setEnabled(filePath);
|
||||
|
||||
@@ -0,0 +1,409 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/imgui/include/guimissioncomponent.h>
|
||||
|
||||
#include <modules/imgui/include/gui.h>
|
||||
#include <modules/imgui/include/imgui_include.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/mission/mission.h>
|
||||
#include <openspace/mission/missionmanager.h>
|
||||
#include <openspace/util/timerange.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/timemanager.h>
|
||||
|
||||
namespace {
|
||||
const ImVec2 size = ImVec2(350, 500);
|
||||
|
||||
void renderMission(const openspace::Mission& mission) {
|
||||
// The hashname is necessary since ImGui computes a hash based off the name of the
|
||||
// elements. This does not play well with using %s as the name
|
||||
std::string missionHashname = "##" + mission.name();
|
||||
|
||||
|
||||
double currentTime = OsEng.timeManager().time().j2000Seconds();
|
||||
openspace::MissionPhase::Trace t = mission.phaseTrace(currentTime, 0);
|
||||
|
||||
int treeOption = t.empty() ? 0 : ImGuiTreeNodeFlags_DefaultOpen;
|
||||
if (ImGui::TreeNodeEx(("%s" + missionHashname).c_str(), treeOption, mission.name().c_str())) {
|
||||
if (!mission.description().empty()) {
|
||||
ImGui::Text("%s", mission.description().c_str());
|
||||
}
|
||||
|
||||
for (const openspace::Mission& m : mission.phases()) {
|
||||
renderMission(m);
|
||||
}
|
||||
|
||||
openspace::TimeRange range = mission.timeRange();
|
||||
openspace::Time startTime = openspace::Time(range.start);
|
||||
openspace::Time endTime = openspace::Time(range.end);
|
||||
|
||||
ImGui::Text("%s", startTime.UTC().c_str());
|
||||
ImGui::SameLine();
|
||||
float v = static_cast<float>(currentTime);
|
||||
float s = static_cast<float>(startTime.j2000Seconds());
|
||||
float e = static_cast<float>(endTime.j2000Seconds());
|
||||
|
||||
ImGui::SliderFloat(missionHashname.c_str(), &v, s, e);
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("%s", endTime.UTC().c_str());
|
||||
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace openspace::gui {
|
||||
|
||||
GuiMissionComponent::GuiMissionComponent() : GuiComponent("Mission Information") {}
|
||||
|
||||
void GuiMissionComponent::render() {
|
||||
bool v = _isEnabled;
|
||||
ImGui::Begin(name().c_str(), &v, size, 0.75f);
|
||||
_isEnabled = v;
|
||||
|
||||
ghoul_assert(
|
||||
MissionManager::ref().hasCurrentMission(),
|
||||
"Must have a current mission"
|
||||
);
|
||||
|
||||
const Mission& currentMission = MissionManager::ref().currentMission();
|
||||
renderMission(currentMission);
|
||||
|
||||
|
||||
//std::vector<SceneGraphNode*> nodes =
|
||||
// OsEng.renderEngine().scene()->allSceneGraphNodes();
|
||||
|
||||
//std::sort(
|
||||
// nodes.begin(),
|
||||
// nodes.end(),
|
||||
// [](SceneGraphNode* lhs, SceneGraphNode* rhs) {
|
||||
// return lhs->name() < rhs->name();
|
||||
// }
|
||||
//);
|
||||
|
||||
//ImGui::BeginGroup();
|
||||
//if (ImGui::IsItemHovered()) {
|
||||
// ImGui::SetTooltip(
|
||||
// "%s",
|
||||
// "These buttons and the dropdown menu determine the focus object in the scene "
|
||||
// "that is the center of all camera movement"
|
||||
// );
|
||||
//}
|
||||
|
||||
//CaptionText("Focus Selection");
|
||||
|
||||
//ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.f);
|
||||
|
||||
//ImGui::Text("%s", "Focus on:");
|
||||
//ImGui::SameLine();
|
||||
//// Buttons for important SceneGraphNodes
|
||||
//for (SceneGraphNode* n : nodes) {
|
||||
// const std::vector<std::string>& tags = n->tags();
|
||||
// auto it = std::find(tags.begin(), tags.end(), "GUI.Interesting");
|
||||
// if (it != tags.end()) {
|
||||
// bool pressed = ImGui::Button(n->name().c_str());
|
||||
// ImGui::SameLine();
|
||||
// if (pressed) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.setPropertyValue('NavigationHandler.Origin', '" +
|
||||
// n->name() + "');",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//ImGui::NewLine();
|
||||
//ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.f);
|
||||
|
||||
//SceneGraphNode* currentFocus = OsEng.navigationHandler().focusNode();
|
||||
|
||||
//std::string nodeNames = "";
|
||||
//for (SceneGraphNode* n : nodes) {
|
||||
// nodeNames += n->name() + '\0';
|
||||
//}
|
||||
|
||||
//auto iCurrentFocus = std::find(nodes.begin(), nodes.end(), currentFocus);
|
||||
//if (!nodes.empty()) {
|
||||
// // Only check if we found the current focus node if we have any nodes at all
|
||||
// // only then it would be a real error
|
||||
// ghoul_assert(iCurrentFocus != nodes.end(), "Focus node not found");
|
||||
//}
|
||||
//int currentPosition = static_cast<int>(std::distance(nodes.begin(), iCurrentFocus));
|
||||
|
||||
//bool hasChanged = ImGui::Combo("Focus Node", ¤tPosition, nodeNames.c_str());
|
||||
//if (hasChanged) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.setPropertyValue('NavigationHandler.Origin', '" +
|
||||
// nodes[currentPosition]->name() + "');",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//}
|
||||
|
||||
//ImGui::EndGroup();
|
||||
|
||||
//ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 20.f);
|
||||
|
||||
//ImGui::Separator();
|
||||
//ImGui::Separator();
|
||||
//ImGui::Separator();
|
||||
|
||||
//ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 20.f);
|
||||
|
||||
|
||||
//ImGui::BeginGroup();
|
||||
//if (ImGui::IsItemHovered()) {
|
||||
// ImGui::SetTooltip(
|
||||
// "%s",
|
||||
// "These elements determine the simulation time inside OpenSpace."
|
||||
// );
|
||||
//}
|
||||
|
||||
//CaptionText("Time Controls");
|
||||
//ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.f);
|
||||
|
||||
//constexpr int BufferSize = 256;
|
||||
//static char Buffer[BufferSize];
|
||||
//bool dateChanged = ImGui::InputText(
|
||||
// "Date",
|
||||
// Buffer,
|
||||
// BufferSize,
|
||||
// ImGuiInputTextFlags_EnterReturnsTrue
|
||||
//);
|
||||
//if (dateChanged) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.time.setTime(\"" + std::string(Buffer) + "\")",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//}
|
||||
//if (ImGui::IsItemHovered()) {
|
||||
// ImGui::SetTooltip(
|
||||
// "%s",
|
||||
// "Entering a date here and confirming with ENTER sets the current simulation "
|
||||
// "time to the entered date. The format of the date has to be either ISO 8601 "
|
||||
// "YYYY-MM-DDThh:mm:ss (2017-08-27T04:00:00) or YYYY MMM DD hh:mm:ss "
|
||||
// "(2017 MAY 01 12:00:00). The hours are in 24h and specified as UTC."
|
||||
// );
|
||||
//}
|
||||
|
||||
//auto incrementTime = [](int days) {
|
||||
// using namespace std::chrono;
|
||||
// double j2000 = OsEng.timeManager().time().j2000Seconds();
|
||||
|
||||
// long long seconds = duration_cast<std::chrono::seconds>(
|
||||
// std::chrono::hours(24) * std::abs(days)
|
||||
// ).count();
|
||||
|
||||
// double newTime = [days, j2000, seconds](){
|
||||
// if (days < 0) {
|
||||
// return static_cast<double>(j2000 - seconds);
|
||||
// }
|
||||
// else {
|
||||
// return static_cast<double>(j2000 + seconds);
|
||||
// }
|
||||
// }();
|
||||
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.time.setTime(" + std::to_string(newTime) + ")",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//};
|
||||
|
||||
//bool minusMonth = ImGui::Button("-Month");
|
||||
//if (ImGui::IsItemHovered()) {
|
||||
// ImGui::SetTooltip(
|
||||
// "%s",
|
||||
// "OBS: A month here equals 30 days."
|
||||
// );
|
||||
//}
|
||||
//if (minusMonth) {
|
||||
// incrementTime(-30);
|
||||
//}
|
||||
//ImGui::SameLine();
|
||||
//bool minusWeek = ImGui::Button("-Week");
|
||||
//if (minusWeek) {
|
||||
// incrementTime(-7);
|
||||
//}
|
||||
//ImGui::SameLine();
|
||||
//bool minusDay = ImGui::Button("-Day");
|
||||
//if (minusDay) {
|
||||
// incrementTime(-1);
|
||||
//}
|
||||
//ImGui::SameLine();
|
||||
//
|
||||
//ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 55.f);
|
||||
|
||||
//bool plusDay = ImGui::Button("+Day");
|
||||
//if (plusDay) {
|
||||
// incrementTime(1);
|
||||
//}
|
||||
//ImGui::SameLine();
|
||||
//bool plusWeek = ImGui::Button("+Week");
|
||||
//if (plusWeek) {
|
||||
// incrementTime(7);
|
||||
//}
|
||||
//ImGui::SameLine();
|
||||
//bool plusMonth = ImGui::Button("+Month");
|
||||
//if (plusMonth) {
|
||||
// incrementTime(30);
|
||||
//}
|
||||
//if (ImGui::IsItemHovered()) {
|
||||
// ImGui::SetTooltip(
|
||||
// "%s",
|
||||
// "OBS: A month here equals 30 days."
|
||||
// );
|
||||
//}
|
||||
|
||||
//ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 20.f);
|
||||
|
||||
|
||||
//float deltaTime = static_cast<float>(OsEng.timeManager().time().deltaTime());
|
||||
//bool changed = ImGui::SliderFloat("Delta Time", &deltaTime, -100000.f, 100000.f, "%.3f", 5.f);
|
||||
//if (changed) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.time.setDeltaTime(" + std::to_string(deltaTime) + ")",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//}
|
||||
//if (ImGui::IsItemHovered()) {
|
||||
// ImGui::SetTooltip(
|
||||
// "%s",
|
||||
// "This determines the simulation time increment, that is the passage "
|
||||
// "of time in OpenSpace relative to a wall clock. Times are expressed as "
|
||||
// "simulation time / real world time."
|
||||
// );
|
||||
//}
|
||||
|
||||
//bool isPaused = OsEng.timeManager().time().paused();
|
||||
|
||||
//
|
||||
//bool pauseChanged = ImGui::Button(isPaused ? "Resume" : "Pause", { ImGui::GetWindowWidth() - 7.5f, 0.f } );
|
||||
//if (pauseChanged) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.time.togglePause()",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//}
|
||||
|
||||
//auto setDeltaTime = [](std::chrono::seconds dt) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.time.setDeltaTime(" + std::to_string(dt.count()) + ")",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//};
|
||||
|
||||
//bool minusDs = ImGui::Button("-1d/s");
|
||||
//if (minusDs) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.time.setDeltaTime(" + std::to_string(-24 * 60 * 60) + ")",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//}
|
||||
//ImGui::SameLine();
|
||||
|
||||
//bool minusHs = ImGui::Button("-1h/s");
|
||||
//if (minusHs) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.time.setDeltaTime(" + std::to_string(-60 * 60) + ")",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//}
|
||||
//ImGui::SameLine();
|
||||
|
||||
//bool minusMs = ImGui::Button("-1min/s");
|
||||
//if (minusMs) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.time.setDeltaTime(" + std::to_string(-60) + ")",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//}
|
||||
//ImGui::SameLine();
|
||||
|
||||
//bool minusSs = ImGui::Button("-1s/s");
|
||||
//if (minusSs) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.time.setDeltaTime(" + std::to_string(-1) + ")",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//}
|
||||
//ImGui::SameLine();
|
||||
|
||||
//bool zero = ImGui::Button("0");
|
||||
//if (zero) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.time.setDeltaTime(" + std::to_string(0) + ")",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//}
|
||||
//ImGui::SameLine();
|
||||
|
||||
|
||||
//bool plusSs = ImGui::Button("+1s/s");
|
||||
//if (plusSs) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.time.setDeltaTime(" + std::to_string(1) + ")",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//}
|
||||
//ImGui::SameLine();
|
||||
|
||||
//bool plusMs = ImGui::Button("1min/s");
|
||||
//if (plusMs) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.time.setDeltaTime(" + std::to_string(60) + ")",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//}
|
||||
//ImGui::SameLine();
|
||||
|
||||
//bool plusHs = ImGui::Button("1h/s");
|
||||
//if (plusHs) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.time.setDeltaTime(" + std::to_string(60 * 60) + ")",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//}
|
||||
//ImGui::SameLine();
|
||||
|
||||
//bool plusDs = ImGui::Button("1d/s");
|
||||
//if (plusDs) {
|
||||
// OsEng.scriptEngine().queueScript(
|
||||
// "openspace.time.setDeltaTime(" + std::to_string(24 * 60 * 60) + ")",
|
||||
// scripting::ScriptEngine::RemoteScripting::Yes
|
||||
// );
|
||||
//}
|
||||
//ImGui::SameLine();
|
||||
|
||||
|
||||
//ImGui::EndGroup();
|
||||
|
||||
ImGui::End();
|
||||
|
||||
}
|
||||
|
||||
} // namespace openspace gui
|
||||
@@ -1,79 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/imgui/include/guiorigincomponent.h>
|
||||
|
||||
#include <modules/imgui/include/imgui_include.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
namespace openspace::gui {
|
||||
|
||||
GuiOriginComponent::GuiOriginComponent()
|
||||
: GuiComponent("Origin")
|
||||
{}
|
||||
|
||||
void GuiOriginComponent::render() {
|
||||
SceneGraphNode* currentFocus = OsEng.navigationHandler().focusNode();
|
||||
|
||||
std::vector<SceneGraphNode*> nodes =
|
||||
OsEng.renderEngine().scene()->allSceneGraphNodes();
|
||||
|
||||
std::sort(
|
||||
nodes.begin(),
|
||||
nodes.end(),
|
||||
[](SceneGraphNode* lhs, SceneGraphNode* rhs) {
|
||||
return lhs->name() < rhs->name();
|
||||
}
|
||||
);
|
||||
std::string nodeNames = "";
|
||||
for (SceneGraphNode* n : nodes) {
|
||||
nodeNames += n->name() + '\0';
|
||||
}
|
||||
|
||||
auto iCurrentFocus = std::find(nodes.begin(), nodes.end(), currentFocus);
|
||||
if (!nodes.empty()) {
|
||||
// Only check if we found the current focus node if we have any nodes at all
|
||||
// only then it would be a real error
|
||||
ghoul_assert(iCurrentFocus != nodes.end(), "Focus node not found");
|
||||
}
|
||||
int currentPosition = static_cast<int>(std::distance(nodes.begin(), iCurrentFocus));
|
||||
|
||||
bool hasChanged = ImGui::Combo("Origin", ¤tPosition, nodeNames.c_str());
|
||||
if (hasChanged) {
|
||||
OsEng.scriptEngine().queueScript(
|
||||
"openspace.setPropertyValue('NavigationHandler.Origin', '" +
|
||||
nodes[currentPosition]->name() + "');",
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace::gui
|
||||
@@ -70,7 +70,13 @@ documentation::Documentation MissionPhase::Documentation() {
|
||||
},
|
||||
{
|
||||
KeyPhases,
|
||||
new ReferencingVerifier("core_mission_mission"),
|
||||
new TableVerifier({
|
||||
{
|
||||
"*",
|
||||
new ReferencingVerifier("core_mission_mission"),
|
||||
Optional::Yes
|
||||
}
|
||||
}),
|
||||
Optional::Yes,
|
||||
"The phases into which this mission or mission phase is separated."
|
||||
}
|
||||
@@ -164,7 +170,7 @@ MissionPhase::Trace MissionPhase::phaseTrace(double time, int maxDepth) const {
|
||||
}
|
||||
|
||||
void MissionPhase::phaseTrace(double time, Trace& trace, int maxDepth) const {
|
||||
ghoul_assert(maxDepth >= 0, "maxDepth must not be negative");
|
||||
//ghoul_assert(maxDepth >= 0, "maxDepth must not be negative");
|
||||
|
||||
if (maxDepth == 0) {
|
||||
return;
|
||||
|
||||
@@ -1035,81 +1035,81 @@ void RenderEngine::renderInformation() {
|
||||
bool hasNewHorizons = scene()->sceneGraphNode("NewHorizons");
|
||||
double currentTime = OsEng.timeManager().time().j2000Seconds();
|
||||
|
||||
if (MissionManager::ref().hasCurrentMission()) {
|
||||
//if (MissionManager::ref().hasCurrentMission()) {
|
||||
|
||||
const Mission& mission = MissionManager::ref().currentMission();
|
||||
// const Mission& mission = MissionManager::ref().currentMission();
|
||||
|
||||
if (mission.phases().size() > 0) {
|
||||
static const glm::vec4 nextMissionColor(0.7, 0.3, 0.3, 1);
|
||||
//static const glm::vec4 missionProgressColor(0.4, 1.0, 1.0, 1);
|
||||
static const glm::vec4 currentMissionColor(0.0, 0.5, 0.5, 1);
|
||||
static const glm::vec4 missionProgressColor = currentMissionColor;// (0.4, 1.0, 1.0, 1);
|
||||
// static const glm::vec4 currentLeafMissionColor = missionProgressColor;
|
||||
static const glm::vec4 nonCurrentMissionColor(0.3, 0.3, 0.3, 1);
|
||||
// if (mission.phases().size() > 0) {
|
||||
// static const glm::vec4 nextMissionColor(0.7, 0.3, 0.3, 1);
|
||||
// //static const glm::vec4 missionProgressColor(0.4, 1.0, 1.0, 1);
|
||||
// static const glm::vec4 currentMissionColor(0.0, 0.5, 0.5, 1);
|
||||
// static const glm::vec4 missionProgressColor = currentMissionColor;// (0.4, 1.0, 1.0, 1);
|
||||
// // static const glm::vec4 currentLeafMissionColor = missionProgressColor;
|
||||
// static const glm::vec4 nonCurrentMissionColor(0.3, 0.3, 0.3, 1);
|
||||
|
||||
// Add spacing
|
||||
RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, " ");
|
||||
// // Add spacing
|
||||
// RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, " ");
|
||||
|
||||
auto phaseTrace = mission.phaseTrace(currentTime);
|
||||
// auto phaseTrace = mission.phaseTrace(currentTime);
|
||||
|
||||
if (phaseTrace.size()) {
|
||||
const MissionPhase& phase = phaseTrace.back().get();
|
||||
std::string title = "Current Mission Phase: " + phase.name();
|
||||
RenderFontCr(*_fontInfo, penPosition, missionProgressColor, title.c_str());
|
||||
double remaining = phase.timeRange().end - currentTime;
|
||||
float t = static_cast<float>(1.0 - remaining / phase.timeRange().duration());
|
||||
std::string progress = progressToStr(25, t);
|
||||
//RenderFontCr(*_fontInfo, penPosition, missionProgressColor,
|
||||
// "%.0f s %s %.1f %%", remaining, progress.c_str(), t * 100);
|
||||
}
|
||||
else {
|
||||
RenderFontCr(*_fontInfo, penPosition, nextMissionColor, "Next Mission:");
|
||||
double remaining = mission.timeRange().start - currentTime;
|
||||
RenderFontCr(*_fontInfo, penPosition, nextMissionColor,
|
||||
"%.0f s", remaining);
|
||||
}
|
||||
// if (phaseTrace.size()) {
|
||||
// const MissionPhase& phase = phaseTrace.back().get();
|
||||
// std::string title = "Current Mission Phase: " + phase.name();
|
||||
// RenderFontCr(*_fontInfo, penPosition, missionProgressColor, title.c_str());
|
||||
// double remaining = phase.timeRange().end - currentTime;
|
||||
// float t = static_cast<float>(1.0 - remaining / phase.timeRange().duration());
|
||||
// std::string progress = progressToStr(25, t);
|
||||
// //RenderFontCr(*_fontInfo, penPosition, missionProgressColor,
|
||||
// // "%.0f s %s %.1f %%", remaining, progress.c_str(), t * 100);
|
||||
// }
|
||||
// else {
|
||||
// RenderFontCr(*_fontInfo, penPosition, nextMissionColor, "Next Mission:");
|
||||
// double remaining = mission.timeRange().start - currentTime;
|
||||
// RenderFontCr(*_fontInfo, penPosition, nextMissionColor,
|
||||
// "%.0f s", remaining);
|
||||
// }
|
||||
|
||||
bool showAllPhases = false;
|
||||
// bool showAllPhases = false;
|
||||
|
||||
typedef std::pair<const MissionPhase*, int> PhaseWithDepth;
|
||||
std::stack<PhaseWithDepth> S;
|
||||
int pixelIndentation = 20;
|
||||
S.push({ &mission, 0 });
|
||||
while (!S.empty()) {
|
||||
const MissionPhase* phase = S.top().first;
|
||||
int depth = S.top().second;
|
||||
S.pop();
|
||||
// typedef std::pair<const MissionPhase*, int> PhaseWithDepth;
|
||||
// std::stack<PhaseWithDepth> S;
|
||||
// int pixelIndentation = 20;
|
||||
// S.push({ &mission, 0 });
|
||||
// while (!S.empty()) {
|
||||
// const MissionPhase* phase = S.top().first;
|
||||
// int depth = S.top().second;
|
||||
// S.pop();
|
||||
|
||||
bool isCurrentPhase = phase->timeRange().includes(currentTime);
|
||||
// bool isCurrentPhase = phase->timeRange().includes(currentTime);
|
||||
|
||||
penPosition.x += depth * pixelIndentation;
|
||||
if (isCurrentPhase) {
|
||||
double remaining = phase->timeRange().end - currentTime;
|
||||
float t = static_cast<float>(1.0 - remaining / phase->timeRange().duration());
|
||||
std::string progress = progressToStr(25, t);
|
||||
RenderFontCr(*_fontInfo, penPosition, currentMissionColor,
|
||||
"%s %s %.1f %%",
|
||||
phase->name().c_str(),
|
||||
progress.c_str(),
|
||||
t * 100
|
||||
);
|
||||
}
|
||||
else {
|
||||
RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, phase->name().c_str());
|
||||
}
|
||||
penPosition.x -= depth * pixelIndentation;
|
||||
// penPosition.x += depth * pixelIndentation;
|
||||
// if (isCurrentPhase) {
|
||||
// double remaining = phase->timeRange().end - currentTime;
|
||||
// float t = static_cast<float>(1.0 - remaining / phase->timeRange().duration());
|
||||
// std::string progress = progressToStr(25, t);
|
||||
// RenderFontCr(*_fontInfo, penPosition, currentMissionColor,
|
||||
// "%s %s %.1f %%",
|
||||
// phase->name().c_str(),
|
||||
// progress.c_str(),
|
||||
// t * 100
|
||||
// );
|
||||
// }
|
||||
// else {
|
||||
// RenderFontCr(*_fontInfo, penPosition, nonCurrentMissionColor, phase->name().c_str());
|
||||
// }
|
||||
// penPosition.x -= depth * pixelIndentation;
|
||||
|
||||
if (isCurrentPhase || showAllPhases) {
|
||||
// phases are sorted increasingly by start time, and will be popped
|
||||
// last-in-first-out from the stack, so add them in reversed order.
|
||||
int indexLastPhase = static_cast<int>(phase->phases().size()) - 1;
|
||||
for (int i = indexLastPhase; 0 <= i; --i) {
|
||||
S.push({ &phase->phases()[i], depth + 1 });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (isCurrentPhase || showAllPhases) {
|
||||
// // phases are sorted increasingly by start time, and will be popped
|
||||
// // last-in-first-out from the stack, so add them in reversed order.
|
||||
// int indexLastPhase = static_cast<int>(phase->phases().size()) - 1;
|
||||
// for (int i = indexLastPhase; 0 <= i; --i) {
|
||||
// S.push({ &phase->phases()[i], depth + 1 });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user