Add possiblity to sort SGNs in GUI based on numerical value (#3340)

* Add possiblity to sort SGNs in GUI based on numerical value

And apply to grids

* Fix mistake in docs

* Apply suggestions from code review

Co-authored-by: Ylva Selling <ylva.selling@gmail.com>

* Rename Order -> Ordering and remove unused getter functions

* Update GUI hash to match the UI changes

---------

Co-authored-by: Ylva Selling <ylva.selling@gmail.com>
This commit is contained in:
Emma Broman
2024-07-17 09:54:59 +02:00
committed by GitHub
parent f10a2b1a22
commit cca2f7e272
4 changed files with 66 additions and 16 deletions
+26 -13
View File
@@ -270,7 +270,8 @@ local Plane1lh = {
},
GUI = {
Name = "1lh Grid",
Path = "/Other/Grids"
Path = "/Other/Grids",
OrderingNumber = LightHour
}
}
@@ -301,7 +302,8 @@ local Plane1ld = {
},
GUI = {
Name = "1ld Grid",
Path = "/Other/Grids"
Path = "/Other/Grids",
OrderingNumber = LightDay
}
}
@@ -332,7 +334,8 @@ local Plane1lm = {
},
GUI = {
Name = "1lm Grid",
Path = "/Other/Grids"
Path = "/Other/Grids",
OrderingNumber = LightMonth
}
}
@@ -363,7 +366,8 @@ local Plane1ly = {
},
GUI = {
Name = "1ly Grid",
Path = "/Other/Grids"
Path = "/Other/Grids",
OrderingNumber = LightYear
}
}
@@ -394,7 +398,8 @@ local Plane10ly = {
},
GUI = {
Name = "10ly Grid",
Path = "/Other/Grids"
Path = "/Other/Grids",
OrderingNumber = 10 * LightYear
}
}
@@ -425,7 +430,8 @@ local Plane100ly = {
},
GUI = {
Name = "100ly Grid",
Path = "/Other/Grids"
Path = "/Other/Grids",
OrderingNumber = 100 * LightYear
}
}
@@ -456,7 +462,8 @@ local Plane1kly = {
},
GUI = {
Name = "1kly Grid",
Path = "/Other/Grids"
Path = "/Other/Grids",
OrderingNumber = 1000 * LightYear
}
}
@@ -487,7 +494,8 @@ local Plane10kly = {
},
GUI = {
Name = "10kly Grid",
Path = "/Other/Grids"
Path = "/Other/Grids",
OrderingNumber = 10000 * LightYear
}
}
@@ -513,7 +521,8 @@ local Plane100kly = {
},
GUI = {
Name = "100kly Grid",
Path = "/Other/Grids"
Path = "/Other/Grids",
OrderingNumber = 100000 * LightYear
}
}
@@ -539,7 +548,8 @@ local Plane1Mly = {
},
GUI = {
Name = "1Mly Grid",
Path = "/Other/Grids"
Path = "/Other/Grids",
OrderingNumber = 1E6 * LightYear
}
}
@@ -565,7 +575,8 @@ local Plane10Mly = {
},
GUI = {
Name = "10Mly Grid",
Path = "/Other/Grids"
Path = "/Other/Grids",
OrderingNumber = 10E6 * LightYear
}
}
@@ -591,7 +602,8 @@ local Plane100Mly = {
},
GUI = {
Name = "100Mly Grid",
Path = "/Other/Grids"
Path = "/Other/Grids",
OrderingNumber = 100E6 * LightYear
}
}
@@ -617,7 +629,8 @@ local Plane20Gly = {
},
GUI = {
Name = "20Gly Grid",
Path = "/Other/Grids"
Path = "/Other/Grids",
OrderingNumber = 20E9 * LightYear
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ local guiCustomization = asset.require("customization/gui")
-- Select which commit hashes to use for the frontend and backend
local frontendHash = "67262b3edb3c33580d73e0bb5a61a0321a0b218e"
local frontendHash = "654c79e7f30e61249b93be509758ac675022e5f3"
local frontend = asset.resource({
Identifier = "WebGuiFrontend",
+4 -2
View File
@@ -170,15 +170,17 @@ private:
std::vector<std::string> _onRecedeAction;
std::vector<std::string> _onExitAction;
ghoul::mm_unique_ptr<Renderable> _renderable;
// If this value is 'true' GUIs are asked to hide this node from collections, as it
// might be a node that is not very interesting (for example barycenters)
properties::BoolProperty _guiHidden;
ghoul::mm_unique_ptr<Renderable> _renderable;
properties::StringProperty _guiPath;
properties::StringProperty _guiDisplayName;
properties::StringProperty _guiDescription;
properties::FloatProperty _guiOrderingNumber;
properties::BoolProperty _useGuiOrdering;
// Transformation defined by translation, rotation and scale
struct {
+35
View File
@@ -175,6 +175,23 @@ namespace {
openspace::properties::Property::Visibility::Hidden
};
constexpr openspace::properties::Property::PropertyInfo GuiOrderInfo = {
"GuiOrderingNumber",
"Gui Ordering Number",
"This is an optional numerical value that will affect the sorting of this scene "
"graph node in relation to its neighbors in the GUI. Nodes with the same value "
"will be sorted alphabetically.",
openspace::properties::Property::Visibility::Hidden
};
constexpr openspace::properties::Property::PropertyInfo UseGuiOrderInfo = {
"UseGuiOrdering",
"Use Gui Ordering",
"If true, use the 'GuiOrderingNumber' to place this scene graph node in a "
"sorted way in relation to its neighbors in the GUI",
openspace::properties::Property::Visibility::Hidden
};
constexpr openspace::properties::Property::PropertyInfo ShowDebugSphereInfo = {
"ShowDebugSphere",
"Show Debug Sphere",
@@ -309,6 +326,15 @@ namespace {
// scene graph node. This is most useful to trim collective lists of nodes and
// not display, for example, barycenters
std::optional<bool> hidden;
// If this value is specified, the scene graph node will be ordered in
// relation to its neighbors in the GUI based on this value, so that nodes
// with a higher value appear later in the list. Scene graph nodes with the
// same value will be sorted alphabetically.
//
// The nodes without a given value will be placed at the bottom of the list
// and sorted alphabetically.
std::optional<double> orderingNumber;
};
// Additional information that is passed to GUI applications. These are all hints
// and do not have any impact on the actual function of the scene graph node
@@ -362,6 +388,11 @@ ghoul::mm_unique_ptr<SceneGraphNode> SceneGraphNode::createFromDictionary(
}
result->_guiPath = *p.gui->path;
}
result->_useGuiOrdering = p.gui->orderingNumber.has_value();
if (p.gui->orderingNumber.has_value()) {
result->_guiOrderingNumber = *p.gui->orderingNumber;
}
}
result->_boundingSphere = p.boundingSphere.value_or(result->_boundingSphere);
@@ -512,6 +543,8 @@ SceneGraphNode::SceneGraphNode()
, _guiPath(GuiPathInfo, "/")
, _guiDisplayName(GuiNameInfo)
, _guiDescription(GuiDescriptionInfo)
, _guiOrderingNumber(GuiOrderInfo, 0.f)
, _useGuiOrdering(UseGuiOrderInfo, false)
, _transform {
ghoul::mm_unique_ptr<Translation>(
global::memoryManager->PersistentMemory.alloc<StaticTranslation>()
@@ -593,6 +626,8 @@ SceneGraphNode::SceneGraphNode()
addProperty(_guiDescription);
addProperty(_guiHidden);
addProperty(_guiPath);
addProperty(_guiOrderingNumber);
addProperty(_useGuiOrdering);
}
SceneGraphNode::~SceneGraphNode() {}