10#include "../system/system_utils.h"
22 json j = json::object();
42 if (
j.contains(
"id") &&
j[
"id"].is_number_integer())
43 g.
id =
j[
"id"].get<
int>();
45 if (
j.contains(
"name") &&
j[
"name"].is_string())
46 g.name =
j[
"name"].get<std::string>();
48 if (
j.contains(
"isCollapsed") &&
j[
"isCollapsed"].is_boolean())
49 g.isCollapsed =
j[
"isCollapsed"].get<
bool>();
51 if (
j.contains(
"collapsedPosX") &&
j[
"collapsedPosX"].is_number())
52 g.collapsedPosX =
j[
"collapsedPosX"].get<
float>();
54 if (
j.contains(
"collapsedPosY") &&
j[
"collapsedPosY"].is_number())
55 g.collapsedPosY =
j[
"collapsedPosY"].get<
float>();
57 if (
j.contains(
"headerColor") &&
j[
"headerColor"].is_number_integer())
58 g.headerColor =
j[
"headerColor"].get<
unsigned int>();
60 if (
j.contains(
"nodeIds") &&
j[
"nodeIds"].is_array())
65 if (
it->is_number_integer())
66 g.nodeIds.push_back(
it->get<
int>());
118 g->isCollapsed =
true;
125 g->isCollapsed =
false;
140 return static_cast<int>(
m_Groups.size());
164 if (!
j.contains(
"groups") || !
j[
"groups"].is_array())
ComponentTypeID GetComponentTypeID_Static()
Node grouping and collapse system for node graphs (Phase 9).
Singleton that owns all NodeGroup instances for the active graph.
static GroupManager & Get()
Returns the single shared instance.
void LoadFromJson(const nlohmann::json &j)
void ExpandGroup(int groupId)
Marks the group as expanded.
void Clear()
Removes all groups and resets the ID counter.
void DeleteGroup(int groupId)
Deletes the group with the given ID.
NodeGroup * GetGroup(int groupId)
Returns a pointer to the group with the given ID.
int CreateGroup(const std::string &name, const std::vector< int > &nodeIds)
Creates a new group from the given node IDs.
int GetGroupCount() const
Returns the total number of groups.
std::vector< NodeGroup > m_Groups
void CollapseGroup(int groupId)
Marks the group as collapsed.
void SaveToJson(nlohmann::json &j) const
< Provides AssetID and INVALID_ASSET_ID
A named set of node IDs that can be collapsed into a single header.
unsigned int headerColor
RGBA packed (default: blue)
bool isCollapsed
True = render as header only.
float collapsedPosX
Position used when collapsed.
static NodeGroup FromJson(const nlohmann::json &j)
std::string name
Display name for the group.
nlohmann::json ToJson() const
std::vector< int > nodeIds
IDs of member nodes.