mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-03 09:20:26 -05:00
Merged master into NewAtmosphere.
This commit is contained in:
@@ -189,7 +189,10 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
|
||||
|
||||
OsEng.registerModuleKeyboardCallback(
|
||||
[&](Key key, KeyModifier mod, KeyAction action) -> bool {
|
||||
if (gui.isEnabled() || gui._performance.isEnabled()) {
|
||||
// A list of all the windows that can show up by themselves
|
||||
if (gui.isEnabled() || gui._performance.isEnabled() ||
|
||||
gui._property.isEnabled())
|
||||
{
|
||||
return gui.keyCallback(key, mod, action);
|
||||
}
|
||||
else {
|
||||
@@ -200,7 +203,10 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
|
||||
|
||||
OsEng.registerModuleCharCallback(
|
||||
[&](unsigned int codepoint, KeyModifier modifier) -> bool {
|
||||
if (gui.isEnabled() || gui._performance.isEnabled()) {
|
||||
// A list of all the windows that can show up by themselves
|
||||
if (gui.isEnabled() || gui._performance.isEnabled() ||
|
||||
gui._property.isEnabled())
|
||||
{
|
||||
return gui.charCallback(codepoint, modifier);
|
||||
}
|
||||
else {
|
||||
@@ -211,7 +217,10 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
|
||||
|
||||
OsEng.registerModuleMouseButtonCallback(
|
||||
[&](MouseButton button, MouseAction action) -> bool {
|
||||
if (gui.isEnabled() || gui._performance.isEnabled()) {
|
||||
// A list of all the windows that can show up by themselves
|
||||
if (gui.isEnabled() || gui._performance.isEnabled() ||
|
||||
gui._property.isEnabled())
|
||||
{
|
||||
return gui.mouseButtonCallback(button, action);
|
||||
}
|
||||
else {
|
||||
@@ -222,7 +231,10 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) {
|
||||
|
||||
OsEng.registerModuleMouseScrollWheelCallback(
|
||||
[&](double, double posY) -> bool {
|
||||
if (gui.isEnabled() || gui._performance.isEnabled()) {
|
||||
// A list of all the windows that can show up by themselves
|
||||
if (gui.isEnabled() || gui._performance.isEnabled() ||
|
||||
gui._property.isEnabled())
|
||||
{
|
||||
return gui.mouseWheelCallback(posY);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -94,6 +94,8 @@ private:
|
||||
|
||||
properties::Property::Visibility _currentVisibility;
|
||||
|
||||
properties::BoolProperty _allHidden;
|
||||
|
||||
std::vector<ImGuiContext*> _contexts;
|
||||
};
|
||||
|
||||
|
||||
@@ -72,6 +72,9 @@ public:
|
||||
protected:
|
||||
/// <code>true</code> if this component is enabled and visible on the screen
|
||||
properties::BoolProperty _isEnabled;
|
||||
/// if <code>true</code> this window is currently collapsed. This setting mirrors the
|
||||
/// ImGui internal state of the window
|
||||
properties::BoolProperty _isCollapsed;
|
||||
};
|
||||
|
||||
} // namespace openspace::gui
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <modules/imgui/include/guicomponent.h>
|
||||
|
||||
#include <openspace/properties/property.h>
|
||||
#include <openspace/properties/stringlistproperty.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
|
||||
#include <ghoul/misc/boolean.h>
|
||||
|
||||
@@ -47,11 +49,9 @@ public:
|
||||
using SourceFunction = std::function<std::vector<properties::PropertyOwner*>()>;
|
||||
|
||||
using UseTreeLayout = ghoul::Boolean;
|
||||
using IsTopLevelWindow = ghoul::Boolean;
|
||||
|
||||
|
||||
GuiPropertyComponent(std::string name, UseTreeLayout useTree = UseTreeLayout::No,
|
||||
IsTopLevelWindow isTopLevel = IsTopLevelWindow::No);
|
||||
GuiPropertyComponent(std::string name, UseTreeLayout useTree = UseTreeLayout::No);
|
||||
|
||||
// This is the function that evaluates to the list of Propertyowners that this
|
||||
// component should render
|
||||
@@ -74,9 +74,10 @@ 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;
|
||||
|
||||
properties::BoolProperty _useTreeLayout;
|
||||
properties::StringListProperty _treeOrdering;
|
||||
|
||||
bool _showHelpTooltip;
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
#include <modules/imgui/include/guicomponent.h>
|
||||
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
|
||||
namespace openspace::gui {
|
||||
|
||||
class GuiSpaceTimeComponent : public GuiComponent {
|
||||
@@ -34,6 +36,10 @@ public:
|
||||
GuiSpaceTimeComponent();
|
||||
|
||||
void render() override;
|
||||
|
||||
private:
|
||||
properties::FloatProperty _minMaxDeltaTime;
|
||||
float _localMinMaxDeltatime; // We don't want the default display inside the component
|
||||
};
|
||||
|
||||
} // namespace openspace::gui
|
||||
|
||||
@@ -57,6 +57,10 @@ void renderStringProperty(properties::Property* prop, const std::string& ownerNa
|
||||
IsRegularProperty isRegular = IsRegularProperty::Yes,
|
||||
ShowToolTip showTooltip = ShowToolTip::Yes);
|
||||
|
||||
void renderStringListProperty(properties::Property* prop, const std::string& ownerName,
|
||||
IsRegularProperty isRegular = IsRegularProperty::Yes,
|
||||
ShowToolTip showTooltip = ShowToolTip::Yes);
|
||||
|
||||
void renderDoubleProperty(properties::Property* prop, const std::string& ownerName,
|
||||
IsRegularProperty isRegular = IsRegularProperty::Yes,
|
||||
ShowToolTip showTooltip = ShowToolTip::Yes);
|
||||
|
||||
@@ -253,6 +253,13 @@ static const openspace::properties::Property::PropertyInfo ShowHelpInfo = {
|
||||
"explaining what impact they have on the visuals."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo HiddenInfo = {
|
||||
"IsHidden",
|
||||
"Is Hidden",
|
||||
"If this value is true, all GUI items will not be rendered, regardless of their "
|
||||
"status"
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace openspace::gui {
|
||||
@@ -272,23 +279,25 @@ GUI::GUI()
|
||||
)
|
||||
, _screenSpaceProperty("ScreenSpace Properties")
|
||||
, _virtualProperty("Virtual Properties")
|
||||
, _featuredProperties("Featured Properties",
|
||||
GuiPropertyComponent::UseTreeLayout::No,
|
||||
GuiPropertyComponent::IsTopLevelWindow::Yes)
|
||||
, _featuredProperties("Featured Properties", GuiPropertyComponent::UseTreeLayout::No)
|
||||
, _showInternals(false)
|
||||
, _showHelpText(ShowHelpInfo, true)
|
||||
, _currentVisibility(properties::Property::Visibility::Developer)
|
||||
, _allHidden(HiddenInfo, true)
|
||||
{
|
||||
addPropertySubOwner(_help);
|
||||
addPropertySubOwner(_performance);
|
||||
addPropertySubOwner(_globalProperty);
|
||||
addPropertySubOwner(_property);
|
||||
addPropertySubOwner(_screenSpaceProperty);
|
||||
_featuredProperties.setEnabled(true);
|
||||
addPropertySubOwner(_featuredProperties);
|
||||
addPropertySubOwner(_virtualProperty);
|
||||
#ifdef GLOBEBROWSING_USE_GDAL
|
||||
addPropertySubOwner(_globeBrowsing);
|
||||
#endif // GLOBEBROWSING_USE_GDAL
|
||||
addPropertySubOwner(_filePath);
|
||||
_spaceTime.setEnabled(true);
|
||||
addPropertySubOwner(_spaceTime);
|
||||
addPropertySubOwner(_mission);
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
@@ -302,6 +311,8 @@ GUI::GUI()
|
||||
_screenSpaceProperty.setShowHelpTooltip(_showHelpText);
|
||||
_virtualProperty.setShowHelpTooltip(_showHelpText);
|
||||
});
|
||||
|
||||
addProperty(_allHidden);
|
||||
}
|
||||
|
||||
void GUI::initialize() {
|
||||
@@ -626,8 +637,11 @@ void GUI::endFrame() {
|
||||
_performance.render();
|
||||
}
|
||||
|
||||
if (_isEnabled) {
|
||||
render();
|
||||
if (!_allHidden) {
|
||||
|
||||
if (_isEnabled) {
|
||||
render();
|
||||
}
|
||||
|
||||
if (_globalProperty.isEnabled()) {
|
||||
_globalProperty.render();
|
||||
@@ -666,11 +680,13 @@ void GUI::endFrame() {
|
||||
_mission.render();
|
||||
}
|
||||
|
||||
// We always want to render the Space/Time component
|
||||
_spaceTime.render();
|
||||
if (_spaceTime.isEnabled()) {
|
||||
_spaceTime.render();
|
||||
}
|
||||
|
||||
// We always want to render the featured properties component
|
||||
_featuredProperties.render();
|
||||
if (_featuredProperties.isEnabled()) {
|
||||
_featuredProperties.render();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Render();
|
||||
@@ -744,7 +760,11 @@ bool GUI::charCallback(unsigned int character, KeyModifier) {
|
||||
}
|
||||
|
||||
void GUI::render() {
|
||||
ImGui::SetNextWindowCollapsed(_isCollapsed);
|
||||
|
||||
ImGui::Begin("OpenSpace GUI", nullptr);
|
||||
|
||||
_isCollapsed = ImGui::IsWindowCollapsed();
|
||||
|
||||
bool property = _property.isEnabled();
|
||||
ImGui::Checkbox("Scene Graph Properties", &property);
|
||||
@@ -754,10 +774,18 @@ void GUI::render() {
|
||||
ImGui::Checkbox("ScreenSpace Properties", &screenSpaceProperty);
|
||||
_screenSpaceProperty.setEnabled(screenSpaceProperty);
|
||||
|
||||
bool featuredProperties = _featuredProperties.isEnabled();
|
||||
ImGui::Checkbox("Featured Properties", &featuredProperties);
|
||||
_featuredProperties.setEnabled(featuredProperties);
|
||||
|
||||
bool globalProperty = _globalProperty.isEnabled();
|
||||
ImGui::Checkbox("Global Properties", &globalProperty);
|
||||
_globalProperty.setEnabled(globalProperty);
|
||||
|
||||
bool spacetime = _spaceTime.isEnabled();
|
||||
ImGui::Checkbox("Space/Time", &spacetime);
|
||||
_spaceTime.setEnabled(spacetime);
|
||||
|
||||
bool parallel = _parallel.isEnabled();
|
||||
ImGui::Checkbox("Parallel Connection", ¶llel);
|
||||
_parallel.setEnabled(parallel);
|
||||
|
||||
@@ -30,6 +30,12 @@ namespace {
|
||||
"Is Enabled",
|
||||
"This setting determines whether this object will be visible or not."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo CollapsedInfo = {
|
||||
"Collapsed",
|
||||
"Is Collapsed",
|
||||
"This setting determines whether this window is collapsed or not."
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace::gui {
|
||||
@@ -37,8 +43,10 @@ namespace openspace::gui {
|
||||
GuiComponent::GuiComponent(std::string name)
|
||||
: properties::PropertyOwner({ std::move(name) })
|
||||
, _isEnabled(EnabledInfo, false)
|
||||
, _isCollapsed(CollapsedInfo, false)
|
||||
{
|
||||
addProperty(_isEnabled);
|
||||
addProperty(_isCollapsed);
|
||||
}
|
||||
|
||||
bool GuiComponent::isEnabled() const {
|
||||
|
||||
@@ -35,8 +35,11 @@ GuiFilePathComponent::GuiFilePathComponent()
|
||||
{}
|
||||
|
||||
void GuiFilePathComponent::render() {
|
||||
ImGui::SetNextWindowCollapsed(_isCollapsed);
|
||||
|
||||
bool v = _isEnabled;
|
||||
ImGui::Begin("File Path", &v);
|
||||
_isCollapsed = ImGui::IsWindowCollapsed();
|
||||
|
||||
ImGui::Text(
|
||||
"%s",
|
||||
|
||||
@@ -63,10 +63,13 @@ void GuiGlobeBrowsingComponent::render() {
|
||||
using Capabilities = GlobeBrowsingModule::Capabilities;
|
||||
using Layer = GlobeBrowsingModule::Layer;
|
||||
|
||||
ImGui::SetNextWindowCollapsed(_isCollapsed);
|
||||
|
||||
bool e = _isEnabled;
|
||||
|
||||
ImGui::Begin("Globe Browsing", &e, WindowSize, 0.5f);
|
||||
_isEnabled = e;
|
||||
_isCollapsed = ImGui::IsWindowCollapsed();
|
||||
OnExit([]() {ImGui::End(); }); // We escape early from this function in a few places
|
||||
|
||||
|
||||
|
||||
@@ -37,9 +37,12 @@ GuiHelpComponent::GuiHelpComponent()
|
||||
{}
|
||||
|
||||
void GuiHelpComponent::render() {
|
||||
ImGui::SetNextWindowCollapsed(_isCollapsed);
|
||||
|
||||
bool v = _isEnabled;
|
||||
ImGui::Begin("Help", &v, size, 0.5f);
|
||||
_isEnabled = v;
|
||||
_isCollapsed = ImGui::IsWindowCollapsed();
|
||||
ImGui::ShowUserGuide();
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
@@ -54,11 +54,12 @@ void GuiIswaComponent::render() {
|
||||
bool oldGmImageValue = _gmImage;
|
||||
bool oldIonDataValue = _ionData;
|
||||
|
||||
ImGui::SetNextWindowCollapsed(_isCollapsed);
|
||||
|
||||
bool e = _isEnabled;
|
||||
|
||||
ImGui::Begin("ISWA", &e, WindowSize, 0.5f);
|
||||
|
||||
_isEnabled = e;
|
||||
_isCollapsed = ImGui::IsWindowCollapsed();
|
||||
|
||||
ImGui::Text("Global Magnetosphere");
|
||||
ImGui::Checkbox("Gm From Data", &_gmData); ImGui::SameLine();
|
||||
|
||||
@@ -98,9 +98,12 @@ namespace openspace::gui {
|
||||
GuiMissionComponent::GuiMissionComponent() : GuiComponent("Mission Information") {}
|
||||
|
||||
void GuiMissionComponent::render() {
|
||||
ImGui::SetNextWindowCollapsed(_isCollapsed);
|
||||
bool v = _isEnabled;
|
||||
ImGui::Begin(name().c_str(), &v, Size, 0.75f);
|
||||
_isEnabled = v;
|
||||
|
||||
_isCollapsed = ImGui::IsWindowCollapsed();
|
||||
|
||||
ghoul_assert(
|
||||
MissionManager::ref().hasCurrentMission(),
|
||||
|
||||
@@ -159,9 +159,11 @@ void GuiParallelComponent::renderHost() {
|
||||
|
||||
|
||||
void GuiParallelComponent::render() {
|
||||
ImGui::SetNextWindowCollapsed(_isCollapsed);
|
||||
bool v = _isEnabled;
|
||||
ImGui::Begin("Parallel Connection", &v);
|
||||
_isEnabled = v;
|
||||
_isCollapsed = ImGui::IsWindowCollapsed();
|
||||
|
||||
ParallelConnection::Status status = OsEng.parallelConnection().status();
|
||||
|
||||
|
||||
@@ -97,9 +97,12 @@ void GuiPerformanceComponent::render() {
|
||||
using ghoul::SharedMemory;
|
||||
using namespace performance;
|
||||
|
||||
ImGui::SetNextWindowCollapsed(_isCollapsed);
|
||||
bool v = _isEnabled;
|
||||
ImGui::Begin("Performance", &v);
|
||||
_isEnabled = v;
|
||||
_isCollapsed = ImGui::IsWindowCollapsed();
|
||||
|
||||
RenderEngine& re = OsEng.renderEngine();
|
||||
PerformanceLayout* layout = re.performanceManager()->performanceData();
|
||||
|
||||
|
||||
@@ -37,6 +37,22 @@
|
||||
namespace {
|
||||
const ImVec2 size = ImVec2(350, 500);
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo UseTreeInfo = {
|
||||
"TreeLayout",
|
||||
"Use Tree Layout",
|
||||
"If this value is checked, this component will display the properties using a "
|
||||
"tree layout, rather than using a flat map. This value should only be set on "
|
||||
"property windows that display SceneGraphNodes, or the application might crash."
|
||||
};
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo OrderingInfo = {
|
||||
"Ordering",
|
||||
"Tree Ordering",
|
||||
"This list determines the order of the first tree layer if it is used. Elements "
|
||||
"present in this list will be shown first, with an alphabetical ordering for "
|
||||
"elements not listed."
|
||||
};
|
||||
|
||||
int nVisibleProperties(const std::vector<openspace::properties::Property*>& props,
|
||||
openspace::properties::Property::Visibility visibility)
|
||||
{
|
||||
@@ -146,13 +162,14 @@ namespace {
|
||||
|
||||
namespace openspace::gui {
|
||||
|
||||
GuiPropertyComponent::GuiPropertyComponent(std::string name, UseTreeLayout useTree,
|
||||
IsTopLevelWindow topLevel)
|
||||
GuiPropertyComponent::GuiPropertyComponent(std::string name, UseTreeLayout useTree)
|
||||
: GuiComponent(std::move(name))
|
||||
, _useTreeLayout(useTree)
|
||||
, _currentUseTreeLayout(useTree)
|
||||
, _isTopLevel(topLevel)
|
||||
{}
|
||||
, _useTreeLayout(UseTreeInfo, useTree)
|
||||
, _treeOrdering(OrderingInfo)
|
||||
{
|
||||
addProperty(_useTreeLayout);
|
||||
addProperty(_treeOrdering);
|
||||
}
|
||||
|
||||
void GuiPropertyComponent::setSource(SourceFunction function) {
|
||||
_function = std::move(function);
|
||||
@@ -236,21 +253,16 @@ void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner)
|
||||
}
|
||||
|
||||
void GuiPropertyComponent::render() {
|
||||
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;
|
||||
}
|
||||
ImGui::SetNextWindowCollapsed(_isCollapsed);
|
||||
|
||||
bool v = _isEnabled;
|
||||
ImGui::Begin(name().c_str(), &v, size, 0.75f);
|
||||
_isEnabled = v;
|
||||
|
||||
_isCollapsed = ImGui::IsWindowCollapsed();
|
||||
using namespace properties;
|
||||
|
||||
if (_function) {
|
||||
if (_useTreeLayout) {
|
||||
ImGui::Checkbox("Use Tree layout", &_currentUseTreeLayout);
|
||||
}
|
||||
|
||||
|
||||
std::vector<properties::PropertyOwner*> owners = _function();
|
||||
|
||||
std::sort(
|
||||
@@ -261,7 +273,7 @@ void GuiPropertyComponent::render() {
|
||||
}
|
||||
);
|
||||
|
||||
if (_currentUseTreeLayout) {
|
||||
if (_useTreeLayout) {
|
||||
for (properties::PropertyOwner* owner : owners) {
|
||||
ghoul_assert(
|
||||
dynamic_cast<SceneGraphNode*>(owner),
|
||||
@@ -271,12 +283,14 @@ void GuiPropertyComponent::render() {
|
||||
}
|
||||
|
||||
// Sort:
|
||||
// if guigrouping, sort by name and shortest first
|
||||
// if guigrouping, sort by name and shortest first, but respect the user
|
||||
// specified ordering
|
||||
// then all w/o guigroup
|
||||
const std::vector<std::string>& ordering = _treeOrdering;
|
||||
std::stable_sort(
|
||||
owners.begin(),
|
||||
owners.end(),
|
||||
[](properties::PropertyOwner* lhs, properties::PropertyOwner* rhs) {
|
||||
[&ordering](PropertyOwner* lhs, PropertyOwner* rhs) {
|
||||
std::string lhsGroup = static_cast<SceneGraphNode*>(lhs)->guiPath();
|
||||
std::string rhsGroup = static_cast<SceneGraphNode*>(rhs)->guiPath();
|
||||
|
||||
@@ -286,7 +300,40 @@ void GuiPropertyComponent::render() {
|
||||
if (rhsGroup.empty()) {
|
||||
return true;
|
||||
}
|
||||
return lhsGroup < rhsGroup;
|
||||
|
||||
if (ordering.empty()) {
|
||||
return lhsGroup < rhsGroup;
|
||||
}
|
||||
|
||||
std::vector<std::string> lhsToken = ghoul::tokenizeString(
|
||||
lhsGroup,
|
||||
'/'
|
||||
);
|
||||
// The first token is always empty
|
||||
auto lhsIt = std::find(ordering.begin(), ordering.end(), lhsToken[1]);
|
||||
|
||||
std::vector<std::string> rhsToken = ghoul::tokenizeString(
|
||||
rhsGroup,
|
||||
'/'
|
||||
);
|
||||
// The first token is always empty
|
||||
auto rhsIt = std::find(ordering.begin(), ordering.end(), rhsToken[1]);
|
||||
|
||||
if (lhsIt != ordering.end() && rhsIt != ordering.end()) {
|
||||
// If both top-level groups are in the ordering list, the order
|
||||
// of the iterators gives us the order of the groups
|
||||
return lhsIt < rhsIt;
|
||||
}
|
||||
else if (lhsIt != ordering.end() && rhsIt == ordering.end()) {
|
||||
// If only one of them is in the list, we have a sorting
|
||||
return true;
|
||||
}
|
||||
else if (lhsIt == ordering.end() && rhsIt != ordering.end()) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return lhsGroup < rhsGroup;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -329,7 +376,7 @@ void GuiPropertyComponent::render() {
|
||||
}
|
||||
};
|
||||
|
||||
if (!_currentUseTreeLayout || noGuiGroups) {
|
||||
if (!_useTreeLayout || noGuiGroups) {
|
||||
std::for_each(owners.begin(), owners.end(), renderProp);
|
||||
}
|
||||
else { // _useTreeLayout && gui groups exist
|
||||
@@ -398,6 +445,7 @@ void GuiPropertyComponent::renderProperty(properties::Property* prop,
|
||||
{ "DMat3Property", &renderDMat3Property },
|
||||
{ "DMat4Property", &renderDMat4Property },
|
||||
{ "StringProperty", &renderStringProperty },
|
||||
{ "StringListProperty", &renderStringListProperty },
|
||||
{ "OptionProperty", &renderOptionProperty },
|
||||
{ "TriggerProperty", &renderTriggerProperty },
|
||||
{ "SelectionProperty", &renderSelectionProperty }
|
||||
|
||||
@@ -38,14 +38,34 @@
|
||||
|
||||
namespace {
|
||||
static const ImVec2 Size = ImVec2(350, 500);
|
||||
|
||||
static const openspace::properties::Property::PropertyInfo MinMaxInfo = {
|
||||
"MinMax",
|
||||
"Minimum/Maximum value for delta time",
|
||||
"This value determines the minimum and maximum value for the delta time slider."
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace openspace::gui {
|
||||
|
||||
GuiSpaceTimeComponent::GuiSpaceTimeComponent() : GuiComponent("Space/Time") {}
|
||||
GuiSpaceTimeComponent::GuiSpaceTimeComponent()
|
||||
: GuiComponent("Space/Time")
|
||||
, _minMaxDeltaTime(MinMaxInfo, 100000.f, 0.f, 1e8f, 1.f, 5.f)
|
||||
, _localMinMaxDeltatime(100000.f)
|
||||
{
|
||||
_minMaxDeltaTime.onChange([this]() {
|
||||
_localMinMaxDeltatime = _minMaxDeltaTime;
|
||||
});
|
||||
addProperty(_minMaxDeltaTime);
|
||||
}
|
||||
|
||||
void GuiSpaceTimeComponent::render() {
|
||||
ImGui::Begin(name().c_str(), nullptr, Size, 0.5f, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
ImGui::SetNextWindowCollapsed(_isCollapsed);
|
||||
bool v = _isEnabled;
|
||||
ImGui::Begin(name().c_str(), &v, Size, 0.5f, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
_isEnabled = v;
|
||||
_isCollapsed = ImGui::IsWindowCollapsed();
|
||||
|
||||
std::vector<SceneGraphNode*> nodes =
|
||||
OsEng.renderEngine().scene()->allSceneGraphNodes();
|
||||
@@ -58,15 +78,6 @@ void GuiSpaceTimeComponent::render() {
|
||||
}
|
||||
);
|
||||
|
||||
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);
|
||||
@@ -117,8 +128,6 @@ void GuiSpaceTimeComponent::render() {
|
||||
);
|
||||
}
|
||||
|
||||
ImGui::EndGroup();
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 20.f);
|
||||
|
||||
ImGui::Separator();
|
||||
@@ -127,15 +136,6 @@ void GuiSpaceTimeComponent::render() {
|
||||
|
||||
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);
|
||||
|
||||
@@ -253,17 +253,24 @@ void GuiSpaceTimeComponent::render() {
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 20.f);
|
||||
|
||||
bool minMaxChanged = ImGui::InputFloat(
|
||||
"Time slider range",
|
||||
&_localMinMaxDeltatime
|
||||
);
|
||||
if (minMaxChanged) {
|
||||
_minMaxDeltaTime = _localMinMaxDeltatime;
|
||||
}
|
||||
|
||||
float deltaTime = static_cast<float>(OsEng.timeManager().time().deltaTime());
|
||||
bool changed = ImGui::SliderFloat(
|
||||
bool deltaChanged = ImGui::SliderFloat(
|
||||
"Delta Time",
|
||||
&deltaTime,
|
||||
-100000.f,
|
||||
100000.f,
|
||||
"%.3f",
|
||||
-_minMaxDeltaTime,
|
||||
_minMaxDeltaTime,
|
||||
"%.6f",
|
||||
5.f
|
||||
);
|
||||
if (changed) {
|
||||
if (deltaChanged) {
|
||||
OsEng.scriptEngine().queueScript(
|
||||
"openspace.time.setDeltaTime(" + std::to_string(deltaTime) + ")",
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
@@ -373,9 +380,6 @@ void GuiSpaceTimeComponent::render() {
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
|
||||
ImGui::EndGroup();
|
||||
|
||||
ImGui::End();
|
||||
|
||||
}
|
||||
|
||||
@@ -32,11 +32,13 @@
|
||||
#include <openspace/properties/optionproperty.h>
|
||||
#include <openspace/properties/selectionproperty.h>
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/properties/stringlistproperty.h>
|
||||
#include <openspace/properties/vectorproperty.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <glm/ext.hpp>
|
||||
#include <ghoul/misc/misc.h>
|
||||
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
@@ -247,6 +249,56 @@ void renderStringProperty(Property* prop, const std::string& ownerName,
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
void renderStringListProperty(Property* prop, const std::string& ownerName,
|
||||
IsRegularProperty isRegular, ShowToolTip showTooltip)
|
||||
{
|
||||
ghoul_assert(prop, "prop must not be nullptr");
|
||||
StringListProperty* p = static_cast<StringListProperty*>(prop);
|
||||
std::string name = p->guiName();
|
||||
ImGui::PushID((ownerName + "." + name).c_str());
|
||||
|
||||
std::string value;
|
||||
p->getStringValue(value);
|
||||
// const std::string value = p->value();
|
||||
|
||||
static const int bufferSize = 512;
|
||||
static char buffer[bufferSize];
|
||||
#ifdef _MSC_VER
|
||||
strcpy_s(buffer, value.length() + 1, value.c_str());
|
||||
#else
|
||||
strcpy(buffer, value.c_str());
|
||||
#endif
|
||||
bool hasNewValue = ImGui::InputText(
|
||||
name.c_str(),
|
||||
buffer,
|
||||
bufferSize,
|
||||
ImGuiInputTextFlags_EnterReturnsTrue
|
||||
);
|
||||
if (showTooltip) {
|
||||
renderTooltip(prop);
|
||||
}
|
||||
|
||||
if (hasNewValue) {
|
||||
std::vector<std::string> tokens = ghoul::tokenizeString(std::string(buffer), ',');
|
||||
std::string script = "{";
|
||||
for (std::string& token : tokens) {
|
||||
if (!token.empty()) {
|
||||
ghoul::trimWhitespace(token);
|
||||
script += "[[" + token + "]],";
|
||||
}
|
||||
}
|
||||
script += "}";
|
||||
|
||||
executeScript(
|
||||
p->fullyQualifiedIdentifier(),
|
||||
std::move(script),
|
||||
isRegular
|
||||
);
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
void renderDoubleProperty(properties::Property* prop, const std::string& ownerName,
|
||||
IsRegularProperty isRegular, ShowToolTip showTooltip)
|
||||
{
|
||||
@@ -259,7 +311,7 @@ void renderDoubleProperty(properties::Property* prop, const std::string& ownerNa
|
||||
float min = static_cast<float>(p->minValue());
|
||||
float max = static_cast<float>(p->maxValue());
|
||||
|
||||
ImGui::SliderFloat(name.c_str(), &value, min, max, "%.5f");
|
||||
ImGui::SliderFloat(name.c_str(), &value, min, max, "%.5f", p->exponent());
|
||||
if (showTooltip) {
|
||||
renderTooltip(prop);
|
||||
}
|
||||
@@ -402,7 +454,7 @@ void renderFloatProperty(Property* prop, const std::string& ownerName,
|
||||
FloatProperty::ValueType value = *p;
|
||||
float min = p->minValue();
|
||||
float max = p->maxValue();
|
||||
ImGui::SliderFloat(name.c_str(), &value, min, max, "%.5f");
|
||||
ImGui::SliderFloat(name.c_str(), &value, min, max, "%.5f", p->exponent());
|
||||
if (showTooltip) {
|
||||
renderTooltip(prop);
|
||||
}
|
||||
@@ -431,7 +483,8 @@ void renderVec2Property(Property* prop, const std::string& ownerName,
|
||||
&value.x,
|
||||
min,
|
||||
max,
|
||||
"%.5f"
|
||||
"%.5f",
|
||||
p->exponent()
|
||||
);
|
||||
if (showTooltip) {
|
||||
renderTooltip(prop);
|
||||
@@ -472,7 +525,8 @@ void renderVec3Property(Property* prop, const std::string& ownerName,
|
||||
glm::value_ptr(value),
|
||||
min,
|
||||
max,
|
||||
"%.5f"
|
||||
"%.5f",
|
||||
p->exponent()
|
||||
);
|
||||
}
|
||||
if (showTooltip) {
|
||||
@@ -514,7 +568,8 @@ void renderVec4Property(Property* prop, const std::string& ownerName,
|
||||
glm::value_ptr(value),
|
||||
min,
|
||||
max,
|
||||
"%.5f"
|
||||
"%.5f",
|
||||
p->exponent()
|
||||
);
|
||||
}
|
||||
if (showTooltip) {
|
||||
@@ -548,7 +603,8 @@ void renderDVec2Property(Property* prop, const std::string& ownerName,
|
||||
&value.x,
|
||||
min,
|
||||
max,
|
||||
"%.5f"
|
||||
"%.5f",
|
||||
p->exponent()
|
||||
);
|
||||
if (showTooltip) {
|
||||
renderTooltip(prop);
|
||||
@@ -582,7 +638,8 @@ void renderDVec3Property(Property* prop, const std::string& ownerName,
|
||||
glm::value_ptr(value),
|
||||
min,
|
||||
max,
|
||||
"%.5f"
|
||||
"%.5f",
|
||||
p->exponent()
|
||||
);
|
||||
if (showTooltip) {
|
||||
renderTooltip(prop);
|
||||
@@ -616,7 +673,8 @@ void renderDVec4Property(Property* prop, const std::string& ownerName,
|
||||
&value.x,
|
||||
min,
|
||||
max,
|
||||
"%.5f"
|
||||
"%.5f",
|
||||
p->exponent()
|
||||
);
|
||||
if (showTooltip) {
|
||||
renderTooltip(prop);
|
||||
@@ -656,8 +714,8 @@ void renderDMat2Property(Property* prop, const std::string& ownerName,
|
||||
};
|
||||
float max = static_cast<float>(glm::compMax(maxValues));
|
||||
|
||||
ImGui::SliderFloat2("[0]", glm::value_ptr(value[0]), min, max);
|
||||
ImGui::SliderFloat2("[1]", glm::value_ptr(value[1]), min, max);
|
||||
ImGui::SliderFloat2("[0]", glm::value_ptr(value[0]), min, max, "%.5f", p->exponent());
|
||||
ImGui::SliderFloat2("[1]", glm::value_ptr(value[1]), min, max, "%.5f", p->exponent());
|
||||
|
||||
if (showTooltip) {
|
||||
renderTooltip(prop);
|
||||
@@ -700,9 +758,9 @@ void renderDMat3Property(Property* prop, const std::string& ownerName,
|
||||
float max = static_cast<float>(glm::compMax(maxValues));
|
||||
|
||||
|
||||
ImGui::SliderFloat3("[0]", glm::value_ptr(value[0]), min, max);
|
||||
ImGui::SliderFloat3("[1]", glm::value_ptr(value[1]), min, max);
|
||||
ImGui::SliderFloat3("[2]", glm::value_ptr(value[2]), min, max);
|
||||
ImGui::SliderFloat3("[0]", glm::value_ptr(value[0]), min, max, "%.5f", p->exponent());
|
||||
ImGui::SliderFloat3("[1]", glm::value_ptr(value[1]), min, max, "%.5f", p->exponent());
|
||||
ImGui::SliderFloat3("[2]", glm::value_ptr(value[2]), min, max, "%.5f", p->exponent());
|
||||
|
||||
if (showTooltip) {
|
||||
renderTooltip(prop);
|
||||
@@ -747,10 +805,10 @@ void renderDMat4Property(Property* prop, const std::string& ownerName,
|
||||
float max = static_cast<float>(glm::compMax(maxValues));
|
||||
|
||||
|
||||
ImGui::SliderFloat4("[0]", glm::value_ptr(value[0]), min, max);
|
||||
ImGui::SliderFloat4("[1]", glm::value_ptr(value[1]), min, max);
|
||||
ImGui::SliderFloat4("[2]", glm::value_ptr(value[2]), min, max);
|
||||
ImGui::SliderFloat4("[3]", glm::value_ptr(value[3]), min, max);
|
||||
ImGui::SliderFloat4("[0]", glm::value_ptr(value[0]), min, max, "%.5f", p->exponent());
|
||||
ImGui::SliderFloat4("[1]", glm::value_ptr(value[1]), min, max, "%.5f", p->exponent());
|
||||
ImGui::SliderFloat4("[2]", glm::value_ptr(value[2]), min, max, "%.5f", p->exponent());
|
||||
ImGui::SliderFloat4("[3]", glm::value_ptr(value[3]), min, max, "%.5f", p->exponent());
|
||||
|
||||
if (showTooltip) {
|
||||
renderTooltip(prop);
|
||||
|
||||
Reference in New Issue
Block a user