mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-02 08:49:20 -05:00
Merge branch 'master' of github.com:OpenSpace/OpenSpace into feature/data-management
This commit is contained in:
@@ -32,11 +32,11 @@ 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/guiorigincomponent.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
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guitimecomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guispacetimecomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guiiswacomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/imgui_include.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/renderproperties.h
|
||||
@@ -45,16 +45,15 @@ source_group("Header Files" FILES ${HEADER_FILES})
|
||||
|
||||
set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/gui.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/gui_lua.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guicomponent.cpp
|
||||
${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/guiorigincomponent.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
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guitimecomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guispacetimecomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guiiswacomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/renderproperties.cpp
|
||||
|
||||
|
||||
@@ -103,6 +103,27 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
|
||||
return res;
|
||||
}
|
||||
);
|
||||
|
||||
gui._featuredProperties.setSource(
|
||||
[](){
|
||||
std::vector<SceneGraphNode*> nodes =
|
||||
OsEng.renderEngine().scene()->allSceneGraphNodes();
|
||||
|
||||
nodes.erase(
|
||||
std::remove_if(
|
||||
nodes.begin(),
|
||||
nodes.end(),
|
||||
[](SceneGraphNode* n) {
|
||||
const std::vector<std::string>& tags = n->tags();
|
||||
auto it = std::find(tags.begin(), tags.end(), "GUI.Interesting");
|
||||
return it == tags.end();
|
||||
}
|
||||
),
|
||||
nodes.end()
|
||||
);
|
||||
return std::vector<properties::PropertyOwner*>(nodes.begin(), nodes.end());
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -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/guitimecomponent.h>
|
||||
#include <modules/imgui/include/guiiswacomponent.h>
|
||||
#include <modules/imgui/include/guiparallelcomponent.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/properties/property.h>
|
||||
#include <modules/imgui/include/guispacetimecomponent.h>
|
||||
|
||||
#include <openspace/properties/property.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/util/keys.h>
|
||||
#include <openspace/util/mouse.h>
|
||||
|
||||
@@ -70,17 +70,18 @@ public:
|
||||
#ifdef GLOBEBROWSING_USE_GDAL
|
||||
GuiGlobeBrowsingComponent _globeBrowsing;
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
GuiOriginComponent _origin;
|
||||
GuiPerformanceComponent _performance;
|
||||
GuiPropertyComponent _globalProperty;
|
||||
GuiPropertyComponent _property;
|
||||
GuiPropertyComponent _screenSpaceProperty;
|
||||
GuiPropertyComponent _virtualProperty;
|
||||
GuiTimeComponent _time;
|
||||
GuiSpaceTimeComponent _spaceTime;
|
||||
GuiMissionComponent _mission;
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
GuiIswaComponent _iswa;
|
||||
#endif // OPENSPACE_MODULE_ISWA_ENABLED
|
||||
GuiParallelComponent _parallel;
|
||||
GuiPropertyComponent _featuredProperties;
|
||||
|
||||
bool _showInternals;
|
||||
|
||||
@@ -91,6 +92,8 @@ private:
|
||||
|
||||
};
|
||||
|
||||
void CaptionText(const char* text);
|
||||
|
||||
} // namespace openspace::gui
|
||||
|
||||
#endif // __OPENSPACE_MODULE_IMGUI___GUI___H__
|
||||
|
||||
+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__
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
#include <openspace/properties/property.h>
|
||||
|
||||
#include <ghoul/misc/boolean.h>
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -44,7 +46,12 @@ class GuiPropertyComponent : public GuiComponent {
|
||||
public:
|
||||
using SourceFunction = std::function<std::vector<properties::PropertyOwner*>()>;
|
||||
|
||||
GuiPropertyComponent(std::string name);
|
||||
using UseTreeLayout = ghoul::Boolean;
|
||||
using IsTopLevelWindow = ghoul::Boolean;
|
||||
|
||||
|
||||
GuiPropertyComponent(std::string name, UseTreeLayout useTree = UseTreeLayout::No,
|
||||
IsTopLevelWindow isTopLevel = IsTopLevelWindow::No);
|
||||
|
||||
// This is the function that evaluates to the list of Propertyowners that this
|
||||
// component should render
|
||||
@@ -66,6 +73,9 @@ protected:
|
||||
/// are regular, i.e., not containing wildcards, regex, or groups
|
||||
/// This variable only has an impact on which \c setPropertyValue function is called
|
||||
bool _hasOnlyRegularProperties = false;
|
||||
UseTreeLayout _useTreeLayout;
|
||||
bool _currentUseTreeLayout;
|
||||
IsTopLevelWindow _isTopLevel;
|
||||
};
|
||||
|
||||
} // namespace openspace::gui
|
||||
|
||||
@@ -22,55 +22,19 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/engine/moduleengine.h>
|
||||
#ifndef __OPENSPACE_MODULE_IMGUI___GUISPACETIMECOMPONENT___H__
|
||||
#define __OPENSPACE_MODULE_IMGUI___GUISPACETIMECOMPONENT___H__
|
||||
|
||||
namespace openspace::gui::luascriptfunctions {
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* show():
|
||||
* Shows the GUI
|
||||
*/
|
||||
int show(lua_State* L) {
|
||||
int nArguments = lua_gettop(L);
|
||||
if (nArguments != 0) {
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
|
||||
}
|
||||
#include <modules/imgui/include/guicomponent.h>
|
||||
|
||||
OsEng.moduleEngine().module<ImGUIModule>()->gui.setEnabled(true);
|
||||
return 0;
|
||||
}
|
||||
namespace openspace::gui {
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* hide():
|
||||
* Hides the console
|
||||
*/
|
||||
int hide(lua_State* L) {
|
||||
int nArguments = lua_gettop(L);
|
||||
if (nArguments != 0) {
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
|
||||
}
|
||||
class GuiSpaceTimeComponent : public GuiComponent {
|
||||
public:
|
||||
GuiSpaceTimeComponent();
|
||||
void render() override;
|
||||
};
|
||||
|
||||
OsEng.moduleEngine().module<ImGUIModule>()->gui.setEnabled(false);
|
||||
return 0;
|
||||
}
|
||||
} // namespace openspace::gui
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* toggle():
|
||||
* Toggles the console
|
||||
*/
|
||||
int toggle(lua_State* L) {
|
||||
int nArguments = lua_gettop(L);
|
||||
if (nArguments != 0) {
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
|
||||
}
|
||||
|
||||
OsEng.moduleEngine().module<ImGUIModule>()->gui.setEnabled(
|
||||
!OsEng.moduleEngine().module<ImGUIModule>()->gui.isEnabled()
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace openspace::gui::luascriptfunctions
|
||||
#endif // __OPENSPACE_MODULE_IMGUI___GUISPACETIMECOMPONENT___H__
|
||||
+73
-34
@@ -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>
|
||||
|
||||
@@ -39,8 +40,6 @@
|
||||
|
||||
#include <modules/imgui/include/imgui_include.h>
|
||||
|
||||
#include "gui_lua.inl"
|
||||
|
||||
//#define SHOW_IMGUI_HELPERS
|
||||
|
||||
namespace {
|
||||
@@ -62,6 +61,8 @@ std::unique_ptr<ghoul::opengl::ProgramObject> _program;
|
||||
std::unique_ptr<ghoul::opengl::Texture> _fontTexture;
|
||||
char* iniFileBuffer = nullptr;
|
||||
|
||||
ImFont* captionFont = nullptr;
|
||||
|
||||
static void RenderDrawLists(ImDrawData* drawData) {
|
||||
// Avoid rendering when minimized, scale coordinates for retina displays
|
||||
// (screen coordinates != framebuffer coordinates)
|
||||
@@ -236,17 +237,28 @@ void addScreenSpaceRenderableOnline(std::string texturePath) {
|
||||
|
||||
namespace openspace::gui {
|
||||
|
||||
void CaptionText(const char* text) {
|
||||
ImGui::PushFont(captionFont);
|
||||
ImGui::Text("%s", text);
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
GUI::GUI()
|
||||
: GuiComponent("Main")
|
||||
, _globalProperty("Global")
|
||||
, _property("Properties")
|
||||
, _property(
|
||||
"Properties",
|
||||
GuiPropertyComponent::UseTreeLayout::Yes
|
||||
)
|
||||
, _screenSpaceProperty("ScreenSpace Properties")
|
||||
, _virtualProperty("Virtual Properties")
|
||||
, _featuredProperties("Featured Properties",
|
||||
GuiPropertyComponent::UseTreeLayout::No,
|
||||
GuiPropertyComponent::IsTopLevelWindow::Yes)
|
||||
, _showInternals(false)
|
||||
, _currentVisibility(properties::Property::Visibility::Developer)
|
||||
{
|
||||
addPropertySubOwner(_help);
|
||||
addPropertySubOwner(_origin);
|
||||
addPropertySubOwner(_performance);
|
||||
addPropertySubOwner(_globalProperty);
|
||||
addPropertySubOwner(_property);
|
||||
@@ -256,7 +268,8 @@ GUI::GUI()
|
||||
addPropertySubOwner(_globeBrowsing);
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
addPropertySubOwner(_filePath);
|
||||
addPropertySubOwner(_time);
|
||||
addPropertySubOwner(_spaceTime);
|
||||
addPropertySubOwner(_mission);
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
addPropertySubOwner(_iswa);
|
||||
#endif // OPENSPACE_MODULE_ISWA_ENABLED
|
||||
@@ -302,6 +315,11 @@ void GUI::initialize() {
|
||||
FontSize
|
||||
);
|
||||
|
||||
captionFont = io.Fonts->AddFontFromFileTTF(
|
||||
absPath(GuiFont).c_str(),
|
||||
FontSize * 1.5f
|
||||
);
|
||||
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
style.WindowPadding = { 4.f, 4.f };
|
||||
style.WindowRounding = 0.f;
|
||||
@@ -316,49 +334,50 @@ void GUI::initialize() {
|
||||
style.GrabMinSize = 10.f;
|
||||
style.GrabRounding = 16.f;
|
||||
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
style.Colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
|
||||
style.Colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
|
||||
style.Colors[ImGuiCol_WindowBg] = ImVec4(0.13f, 0.13f, 0.13f, 0.96f);
|
||||
style.Colors[ImGuiCol_ChildWindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
style.Colors[ImGuiCol_PopupBg] = ImVec4(0.05f, 0.05f, 0.10f, 0.90f);
|
||||
style.Colors[ImGuiCol_Border] = ImVec4(0.65f, 0.65f, 0.65f, 0.59f);
|
||||
style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
style.Colors[ImGuiCol_FrameBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.30f);
|
||||
style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.91f, 0.94f, 0.99f, 0.40f);
|
||||
style.Colors[ImGuiCol_FrameBgActive] = ImVec4(0.90f, 0.90f, 0.90f, 0.45f);
|
||||
style.Colors[ImGuiCol_TitleBg] = ImVec4(0.71f, 0.81f, 1.00f, 0.45f);
|
||||
style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.71f, 0.81f, 1.00f, 0.45f);
|
||||
style.Colors[ImGuiCol_TitleBgActive] = ImVec4(0.51f, 0.69f, 1.00f, 0.63f);
|
||||
style.Colors[ImGuiCol_MenuBarBg] = ImVec4(0.26f, 0.27f, 0.33f, 0.80f);
|
||||
style.Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.12f, 0.71f, 0.80f, 0.43f);
|
||||
style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.75f, 0.80f, 0.43f);
|
||||
style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.75f, 0.80f, 0.65f);
|
||||
style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.40f, 0.75f, 0.80f, 0.65f);
|
||||
style.Colors[ImGuiCol_ComboBg] = ImVec4(0.18f, 0.51f, 0.78f, 1.00f);
|
||||
style.Colors[ImGuiCol_ComboBg] = ImVec4(0.36f, 0.46f, 0.56f, 1.00f);
|
||||
style.Colors[ImGuiCol_CheckMark] = ImVec4(1.00f, 1.00f, 1.00f, 0.50f);
|
||||
style.Colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
|
||||
style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.50f, 0.80f, 0.76f, 1.00f);
|
||||
style.Colors[ImGuiCol_Button] = ImVec4(0.36f, 0.54f, 0.68f, 0.62f);
|
||||
style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.00f, 0.51f, 0.94f, 1.00f);
|
||||
style.Colors[ImGuiCol_ButtonActive] = ImVec4(0.00f, 0.43f, 0.80f, 1.00f);
|
||||
style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.36f, 0.54f, 0.68f, 1.00f);
|
||||
style.Colors[ImGuiCol_ButtonActive] = ImVec4(0.36f, 0.61f, 0.81f, 1.00f);
|
||||
style.Colors[ImGuiCol_Header] = ImVec4(0.69f, 0.69f, 0.69f, 0.45f);
|
||||
style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.36f, 0.54f, 0.68f, 0.62f);
|
||||
style.Colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.63f, 0.87f, 0.80f);
|
||||
style.Colors[ImGuiCol_Column] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
|
||||
style.Colors[ImGuiCol_ColumnHovered] = ImVec4(0.70f, 0.60f, 0.60f, 1.00f);
|
||||
style.Colors[ImGuiCol_ColumnActive] = ImVec4(0.90f, 0.70f, 0.70f, 1.00f);
|
||||
style.Colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
||||
style.Colors[ImGuiCol_ResizeGripHovered] = ImVec4(1.00f, 1.00f, 1.00f, 0.60f);
|
||||
style.Colors[ImGuiCol_ResizeGripActive] = ImVec4(1.00f, 1.00f, 1.00f, 0.90f);
|
||||
style.Colors[ImGuiCol_CloseButton] = ImVec4(0.75f, 0.75f, 0.75f, 1.00f);
|
||||
style.Colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.52f, 0.52f, 0.52f, 0.60f);
|
||||
style.Colors[ImGuiCol_CloseButtonActive] = ImVec4(0.52f, 0.52f, 0.52f, 1.00f);
|
||||
|
||||
//style.Colors[ImGuiCol_WindowBg] = ImVec4(0.0f, 0.21f, 0.24f, 1.0f);
|
||||
//style.Colors[ImGuiCol_Border] = ImVec4(0.1f, 0.39f, 0.42f, 0.59f);
|
||||
//style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
//style.Colors[ImGuiCol_TitleBg] = ImVec4(0.5f, 0.94f, 1.0f, 0.45f);
|
||||
//style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.5f, 0.94f, 1.0f, 0.45f);
|
||||
//style.Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
//style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.12f, 0.71f, 0.8f, 0.43f);
|
||||
//style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.4f, 0.75f, 0.8f, 0.65f);
|
||||
//style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.4f, 0.75f, 0.8f, 0.65f);
|
||||
//style.Colors[ImGuiCol_ComboBg] = ImVec4(0.18f, 0.51f, 0.78f, 1.f);
|
||||
//style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.5f, 0.8f, 0.76f, 1.0f);
|
||||
//style.Colors[ImGuiCol_Button] = ImVec4(0.0f, 0.36f, 0.67f, 0.6f);
|
||||
//style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.0f, 0.51f, 0.94f, 1.0f);
|
||||
//style.Colors[ImGuiCol_ButtonActive] = ImVec4(0.0f, 0.43f, 0.8f, 1.0f);
|
||||
//style.Colors[ImGuiCol_Header] = ImVec4(0.f, 0.36f, 0.67f, 0.45f);
|
||||
//style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.f, 0.54f, 1.0f, 0.8f);
|
||||
//style.Colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.63f, 0.87f, 0.8f);
|
||||
//style.Colors[ImGuiCol_ResizeGrip] = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
//style.Colors[ImGuiCol_CloseButton] = ImVec4(0.75f, 0.75f, 0.75f, 1.0f);
|
||||
//style.Colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.52f, 0.52f, 0.52f, 0.6f);
|
||||
//style.Colors[ImGuiCol_CloseButtonActive] = ImVec4(0.52f, 0.52f, 0.52f, 1.0f);
|
||||
style.Colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
||||
style.Colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||
style.Colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||
style.Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
|
||||
style.Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.44f, 0.63f, 1.00f, 0.35f);
|
||||
style.Colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
|
||||
|
||||
_property.initialize();
|
||||
_property.setHasRegularProperties(true);
|
||||
@@ -366,6 +385,7 @@ void GUI::initialize() {
|
||||
_screenSpaceProperty.setHasRegularProperties(true);
|
||||
_globalProperty.initialize();
|
||||
_globalProperty.setHasRegularProperties(true);
|
||||
_featuredProperties.initialize();
|
||||
_virtualProperty.initialize();
|
||||
_filePath.initialize();
|
||||
#ifdef GLOBEBROWSING_USE_GDAL
|
||||
@@ -374,6 +394,7 @@ void GUI::initialize() {
|
||||
_performance.initialize();
|
||||
_help.initialize();
|
||||
_parallel.initialize();
|
||||
_mission.initialize();
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
_iswa.initialize();
|
||||
#endif // OPENSPACE_MODULE_ISWA_ENABLED
|
||||
@@ -385,10 +406,12 @@ void GUI::deinitialize() {
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
_iswa.deinitialize();
|
||||
#endif // OPENSPACE_MODULE_ISWA_ENABLED
|
||||
_mission.deinitialize();
|
||||
_parallel.deinitialize();
|
||||
_help.deinitialize();
|
||||
_performance.deinitialize();
|
||||
_globalProperty.deinitialize();
|
||||
_featuredProperties.deinitialize();
|
||||
_screenSpaceProperty.deinitialize();
|
||||
_virtualProperty.deinitialize();
|
||||
_filePath.deinitialize();
|
||||
@@ -468,6 +491,7 @@ void GUI::initializeGL() {
|
||||
_property.initializeGL();
|
||||
_screenSpaceProperty.initializeGL();
|
||||
_globalProperty.initializeGL();
|
||||
_featuredProperties.initializeGL();
|
||||
_performance.initializeGL();
|
||||
_help.initializeGL();
|
||||
#ifdef GLOBEBROWSING_USE_GDAL
|
||||
@@ -475,6 +499,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
|
||||
@@ -498,9 +523,11 @@ void GUI::deinitializeGL() {
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
_iswa.deinitializeGL();
|
||||
#endif // OPENSPACE_MODULE_ISWA_ENABLED
|
||||
_mission.deinitializeGL();
|
||||
_parallel.deinitializeGL();
|
||||
_help.deinitializeGL();
|
||||
_performance.deinitializeGL();
|
||||
_featuredProperties.deinitializeGL();
|
||||
_globalProperty.deinitializeGL();
|
||||
_screenSpaceProperty.deinitializeGL();
|
||||
#ifdef GLOBEBROWSING_USE_GDAL
|
||||
@@ -571,6 +598,16 @@ void GUI::endFrame() {
|
||||
_globeBrowsing.render();
|
||||
}
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
|
||||
if (_mission.isEnabled() && MissionManager::ref().hasCurrentMission()) {
|
||||
_mission.render();
|
||||
}
|
||||
|
||||
// We always want to render the Space/Time component
|
||||
_spaceTime.render();
|
||||
|
||||
// We always want to render the featured properties component
|
||||
_featuredProperties.render();
|
||||
}
|
||||
|
||||
ImGui::Render();
|
||||
@@ -666,6 +703,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);
|
||||
@@ -682,9 +723,6 @@ void GUI::render() {
|
||||
_iswa.setEnabled(iswa);
|
||||
#endif // OPENSPACE_MODULE_ISWA_ENABLED
|
||||
|
||||
_origin.render();
|
||||
_time.render();
|
||||
|
||||
bool help = _help.isEnabled();
|
||||
ImGui::Checkbox("Help", &help);
|
||||
_help.setEnabled(help);
|
||||
@@ -747,6 +785,7 @@ void GUI::renderAndUpdatePropertyVisibility() {
|
||||
_property.setVisibility(_currentVisibility);
|
||||
_screenSpaceProperty.setVisibility(_currentVisibility);
|
||||
_virtualProperty.setVisibility(_currentVisibility);
|
||||
_featuredProperties.setVisibility(_currentVisibility);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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());
|
||||
}
|
||||
|
||||
openspace::TimeRange range = mission.timeRange();
|
||||
openspace::Time startTime = openspace::Time(range.start);
|
||||
openspace::Time endTime = openspace::Time(range.end);
|
||||
|
||||
openspace::gui::CaptionText("Mission Progress");
|
||||
|
||||
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, OsEng.timeManager().time().UTC().c_str());
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("%s", endTime.UTC().c_str());
|
||||
|
||||
openspace::gui::CaptionText("Phases");
|
||||
|
||||
for (const openspace::Mission& m : mission.phases()) {
|
||||
renderMission(m);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
} // namespace openspace gui
|
||||
@@ -1,81 +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();
|
||||
|
||||
Scene* scene = OsEng.renderEngine().scene();
|
||||
std::vector<SceneGraphNode*> nodes = scene ?
|
||||
scene->allSceneGraphNodes() :
|
||||
std::vector<SceneGraphNode*>();
|
||||
|
||||
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
|
||||
@@ -28,6 +28,9 @@
|
||||
#include <modules/imgui/include/renderproperties.h>
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
|
||||
#include <ghoul/misc/misc.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -57,12 +60,95 @@ namespace {
|
||||
ImGui::SetTooltip("%s", propOwner->description().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
struct TreeNode {
|
||||
TreeNode(std::string p) : path(std::move(p)) {}
|
||||
std::string path;
|
||||
std::vector<std::unique_ptr<TreeNode>> children;
|
||||
std::vector<openspace::SceneGraphNode*> nodes;
|
||||
};
|
||||
|
||||
void addPathToTree(TreeNode& node, const std::vector<std::string>& path,
|
||||
openspace::SceneGraphNode* owner)
|
||||
{
|
||||
if (path.empty()) {
|
||||
// No more path, so we have reached a leaf
|
||||
node.nodes.push_back(owner);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if any of the children's paths contains the first part of the path
|
||||
auto it = std::find_if(
|
||||
node.children.begin(),
|
||||
node.children.end(),
|
||||
[p = *path.begin()](const std::unique_ptr<TreeNode>& c) {
|
||||
return c.get()->path == p;
|
||||
}
|
||||
);
|
||||
|
||||
TreeNode* n;
|
||||
if (it != node.children.end()) {
|
||||
// We have a child, so we use it
|
||||
n = it->get();
|
||||
}
|
||||
else {
|
||||
// We don't have a child, so we must generate it
|
||||
std::unique_ptr<TreeNode> newNode = std::make_unique<TreeNode>(*path.begin());
|
||||
n = newNode.get();
|
||||
node.children.push_back(std::move(newNode));
|
||||
|
||||
}
|
||||
|
||||
// Recurse into the tree and chop off the first path
|
||||
addPathToTree(
|
||||
*n,
|
||||
std::vector<std::string>(path.begin() + 1, path.end()),
|
||||
owner
|
||||
);
|
||||
};
|
||||
|
||||
void simplifyTree(TreeNode& node) {
|
||||
// Merging consecutive nodes if they only have a single child
|
||||
|
||||
for (const std::unique_ptr<TreeNode>& c : node.children) {
|
||||
simplifyTree(*c);
|
||||
}
|
||||
|
||||
if ((node.children.size() == 1) && (node.nodes.empty())) {
|
||||
node.path = node.path + "/" + node.children[0]->path;
|
||||
node.nodes = std::move(node.children[0]->nodes);
|
||||
std::vector<std::unique_ptr<TreeNode>> cld = std::move(
|
||||
node.children[0]->children
|
||||
);
|
||||
node.children = std::move(cld);
|
||||
}
|
||||
}
|
||||
|
||||
void renderTree(const TreeNode& node, const std::function<void (openspace::properties::PropertyOwner*)>& renderFunc) {
|
||||
if (node.path.empty() || ImGui::TreeNode(node.path.c_str())) {
|
||||
for (const std::unique_ptr<TreeNode>& c : node.children) {
|
||||
renderTree(*c, renderFunc);
|
||||
}
|
||||
|
||||
for (openspace::SceneGraphNode* n : node.nodes) {
|
||||
renderFunc(n);
|
||||
}
|
||||
|
||||
if (!node.path.empty()) {
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace openspace::gui {
|
||||
|
||||
GuiPropertyComponent::GuiPropertyComponent(std::string name)
|
||||
GuiPropertyComponent::GuiPropertyComponent(std::string name, UseTreeLayout useTree, IsTopLevelWindow topLevel)
|
||||
: GuiComponent(std::move(name))
|
||||
, _useTreeLayout(useTree)
|
||||
, _isTopLevel(topLevel)
|
||||
, _currentUseTreeLayout(useTree)
|
||||
{}
|
||||
|
||||
void GuiPropertyComponent::setSource(SourceFunction function) {
|
||||
@@ -142,12 +228,23 @@ void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner)
|
||||
}
|
||||
|
||||
void GuiPropertyComponent::render() {
|
||||
bool v = _isEnabled;
|
||||
ImGui::Begin(name().c_str(), &v, size, 0.5f);
|
||||
_isEnabled = v;
|
||||
if (_isTopLevel) {
|
||||
ImGui::Begin(name().c_str(), nullptr, size, 0.75f);
|
||||
}
|
||||
else {
|
||||
bool v = _isEnabled;
|
||||
ImGui::Begin(name().c_str(), &v, size, 0.75f);
|
||||
_isEnabled = v;
|
||||
}
|
||||
|
||||
if (_function) {
|
||||
if (_useTreeLayout) {
|
||||
ImGui::Checkbox("Use Tree layout", &_currentUseTreeLayout);
|
||||
}
|
||||
|
||||
|
||||
std::vector<properties::PropertyOwner*> owners = _function();
|
||||
|
||||
std::sort(
|
||||
owners.begin(),
|
||||
owners.end(),
|
||||
@@ -156,11 +253,49 @@ void GuiPropertyComponent::render() {
|
||||
}
|
||||
);
|
||||
|
||||
for (properties::PropertyOwner* pOwner : owners) {
|
||||
if (_currentUseTreeLayout) {
|
||||
for (properties::PropertyOwner* owner : owners) {
|
||||
ghoul_assert(
|
||||
dynamic_cast<SceneGraphNode*>(owner),
|
||||
"When using the tree layout, all owners must be SceneGraphNodes"
|
||||
);
|
||||
}
|
||||
|
||||
// Sort:
|
||||
// if guigrouping, sort by name and shortest first
|
||||
// then all w/o guigroup
|
||||
std::stable_sort(
|
||||
owners.begin(),
|
||||
owners.end(),
|
||||
[](properties::PropertyOwner* lhs, properties::PropertyOwner* rhs) {
|
||||
std::string lhsGroup = static_cast<SceneGraphNode*>(lhs)->guiPath();
|
||||
std::string rhsGroup = static_cast<SceneGraphNode*>(rhs)->guiPath();
|
||||
|
||||
if (lhsGroup.empty()) {
|
||||
return false;
|
||||
}
|
||||
if (rhsGroup.empty()) {
|
||||
return true;
|
||||
}
|
||||
return lhsGroup < rhsGroup;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// If the owners list is empty, we wnat to do the normal thing (-> nothing)
|
||||
// Otherwise, check if the first owner has a GUI group
|
||||
// This makes the assumption that the tree layout is only used if the owners are
|
||||
// SceenGraphNodes (checked above)
|
||||
bool noGuiGroups =
|
||||
owners.empty() ||
|
||||
(dynamic_cast<SceneGraphNode*>(*owners.begin()) &&
|
||||
dynamic_cast<SceneGraphNode*>(*owners.begin())->guiPath().empty());
|
||||
|
||||
auto renderProp = [&](properties::PropertyOwner* pOwner) {
|
||||
int count = nVisibleProperties(pOwner->propertiesRecursive(), _visibility);
|
||||
|
||||
if (count == 0) {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
auto header = [&]() -> bool {
|
||||
@@ -182,6 +317,47 @@ void GuiPropertyComponent::render() {
|
||||
|
||||
if (header()) {
|
||||
renderPropertyOwner(pOwner);
|
||||
}
|
||||
};
|
||||
|
||||
if (!_currentUseTreeLayout || noGuiGroups) {
|
||||
std::for_each(owners.begin(), owners.end(), renderProp);
|
||||
}
|
||||
else { // _useTreeLayout && gui groups exist
|
||||
TreeNode root("");
|
||||
|
||||
for (properties::PropertyOwner* pOwner : owners) {
|
||||
// We checked above that pOwner is a SceneGraphNode
|
||||
SceneGraphNode* nOwner = static_cast<SceneGraphNode*>(pOwner);
|
||||
|
||||
if (nOwner->guiPath().empty()) {
|
||||
// We know that we are done now since we stable_sort:ed them above
|
||||
break;
|
||||
}
|
||||
|
||||
std::vector<std::string> paths = ghoul::tokenizeString(
|
||||
nOwner->guiPath().substr(1),
|
||||
'/'
|
||||
);
|
||||
|
||||
addPathToTree(root, paths, nOwner);
|
||||
}
|
||||
|
||||
simplifyTree(root);
|
||||
|
||||
renderTree(root, renderProp);
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 20.f);
|
||||
|
||||
for (properties::PropertyOwner* pOwner : owners) {
|
||||
// We checked above that pOwner is a SceneGraphNode
|
||||
SceneGraphNode* nOwner = static_cast<SceneGraphNode*>(pOwner);
|
||||
|
||||
if (!nOwner->guiPath().empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
renderProp(pOwner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,361 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* 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/guispacetimecomponent.h>
|
||||
|
||||
#include <modules/imgui/include/gui.h>
|
||||
#include <modules/imgui/include/imgui_include.h>
|
||||
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/util/timemanager.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
|
||||
namespace {
|
||||
const ImVec2 size = ImVec2(350, 500);
|
||||
} // namespace
|
||||
|
||||
namespace openspace::gui {
|
||||
|
||||
GuiSpaceTimeComponent::GuiSpaceTimeComponent() : GuiComponent("Space/Time") {}
|
||||
|
||||
void GuiSpaceTimeComponent::render() {
|
||||
ImGui::Begin(name().c_str(), nullptr, size, 0.5f, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user