GroupManager
GroupManager
Manages groups for data visualization with colors and point assignments. More…
#include <GroupManager.hpp>
Inherits from QObject
Public Classes
| Name | |
|---|---|
| struct | Group |
Public Signals
| Name | |
|---|---|
| void | groupCreated(int group_id) Emitted when a new group is created. |
| void | groupRemoved(int group_id) Emitted when a group is removed. |
| void | groupModified(int group_id) Emitted when group properties change (name or color). |
Public Functions
| Name | |
|---|---|
| GroupManager(EntityGroupManager * entity_group_manager, std::shared_ptr< DataManager > data_manager, QObject * parent =[nullptr]) | |
| ~GroupManager() override | |
| int | createGroup(QString const & name) Create a new group with auto-generated color. |
| int | createGroup(QString const & name, QColor const & color) Create a new group with specified color. |
| bool | removeGroup(int group_id) Remove a group and unassign all its points. |
| bool | deleteGroupAndEntities(int group_id) Delete a group and all entities in it from their respective data objects. |
| QMap< int, Group > | getGroups() const Get all groups. |
| std::optional< Group > | getGroup(int group_id) const Get a specific group by ID. |
| bool | setGroupName(int group_id, QString const & name) Update group name. |
| bool | setGroupColor(int group_id, QColor const & color) Update group color. |
| bool | setGroupVisibility(int group_id, bool visible) Update group visibility. |
| bool | assignEntitiesToGroup(int group_id, std::unordered_set< EntityId > const & entity_ids) Assign entities (EntityId) to a group. |
| bool | removeEntitiesFromGroup(int group_id, std::unordered_set< EntityId > const & entity_ids) Remove entities (EntityId) from a group. |
| void | ungroupEntities(std::unordered_set< EntityId > const & entity_ids) Ungroup a set of entities. |
| int | getEntityGroup(EntityId id) const Get which group an entity belongs to. |
| QColor | getEntityColor(EntityId id, QColor const & default_color) const Get the color for an entity based on its group assignment. |
| bool | isEntityGroupVisible(EntityId id) const Check if an entity’s group is visible. |
| int | getGroupMemberCount(int group_id) const Get the number of entities assigned to a specific group. |
| void | clearAllGroups() Clear all groups and assignments. |
| uint64_t | generation() const Get the generation counter for group changes. |
| int | createGroupWithEntities(std::unordered_set< EntityId > const & entity_ids) Create a new group and assign the given entities to it. |
| std::vector< std::pair< int, QString > > | getGroupsForContextMenu() const Get a list of groups that can be used in context menus. |
| bool | mergeGroups(int target_group_id, std::vector< int > const & source_group_ids) Merge multiple groups into a target group. |
Detailed Description
class GroupManager;Manages groups for data visualization with colors and point assignments.
This class provides a centralized system for managing groups of data points across different visualization widgets. Each group has a unique ID, name, and color.
Public Signals Documentation
signal groupCreated
void groupCreated(
int group_id
)Emitted when a new group is created.
Parameters:
- group_id The ID of the created group
signal groupRemoved
void groupRemoved(
int group_id
)Emitted when a group is removed.
Parameters:
- group_id The ID of the removed group
signal groupModified
void groupModified(
int group_id
)Emitted when group properties change (name or color).
Parameters:
- group_id The ID of the modified group
Public Functions Documentation
function GroupManager
explicit GroupManager(
EntityGroupManager * entity_group_manager,
std::shared_ptr< DataManager > data_manager,
QObject * parent =nullptr
)function ~GroupManager
~GroupManager() overridefunction createGroup
int createGroup(
QString const & name
)Create a new group with auto-generated color.
Parameters:
- name The name for the new group
Return: The ID of the created group
function createGroup
int createGroup(
QString const & name,
QColor const & color
)Create a new group with specified color.
Parameters:
- name The name for the new group
- color The color for the new group
Return: The ID of the created group
function removeGroup
bool removeGroup(
int group_id
)Remove a group and unassign all its points.
Parameters:
- group_id The ID of the group to remove
Return: True if the group was removed, false if it didn’t exist
function deleteGroupAndEntities
bool deleteGroupAndEntities(
int group_id
)Delete a group and all entities in it from their respective data objects.
Parameters:
- group_id The ID of the group to delete
Return: True if the group and entities were deleted, false if group didn’t exist
function getGroups
QMap< int, Group > getGroups() constGet all groups.
Return: Map of group ID to Group object
function getGroup
std::optional< Group > getGroup(
int group_id
) constGet a specific group by ID.
Parameters:
- group_id The group ID
Return: Optional Group object if found
function setGroupName
bool setGroupName(
int group_id,
QString const & name
)Update group name.
Parameters:
- group_id The group ID
- name The new name
Return: True if successful, false if group doesn’t exist
function setGroupColor
bool setGroupColor(
int group_id,
QColor const & color
)Update group color.
Parameters:
- group_id The group ID
- color The new color
Return: True if successful, false if group doesn’t exist
function setGroupVisibility
bool setGroupVisibility(
int group_id,
bool visible
)Update group visibility.
Parameters:
- group_id The group ID
- visible The new visibility state
Return: True if successful, false if group doesn’t exist
function assignEntitiesToGroup
bool assignEntitiesToGroup(
int group_id,
std::unordered_set< EntityId > const & entity_ids
)Assign entities (EntityId) to a group.
function removeEntitiesFromGroup
bool removeEntitiesFromGroup(
int group_id,
std::unordered_set< EntityId > const & entity_ids
)Remove entities (EntityId) from a group.
function ungroupEntities
void ungroupEntities(
std::unordered_set< EntityId > const & entity_ids
)Ungroup a set of entities.
function getEntityGroup
int getEntityGroup(
EntityId id
) constGet which group an entity belongs to.
function getEntityColor
QColor getEntityColor(
EntityId id,
QColor const & default_color
) constGet the color for an entity based on its group assignment.
function isEntityGroupVisible
bool isEntityGroupVisible(
EntityId id
) constCheck if an entity’s group is visible.
Parameters:
- id The entity ID
Return: True if the entity’s group is visible, false if not in a group or group is hidden
function getGroupMemberCount
int getGroupMemberCount(
int group_id
) constGet the number of entities assigned to a specific group.
Parameters:
- group_id The group ID
Return: Number of entities in the group, 0 if group doesn’t exist
function clearAllGroups
void clearAllGroups()Clear all groups and assignments.
function generation
uint64_t generation() constGet the generation counter for group changes.
Return: Current generation counter value
Monotonically increasing counter incremented on every group change. Useful for widgets to efficiently detect when group membership or properties have changed without connecting to individual signals.
function createGroupWithEntities
int createGroupWithEntities(
std::unordered_set< EntityId > const & entity_ids
)Create a new group and assign the given entities to it.
Parameters:
- entity_ids Set of EntityIds to assign to the new group
Return: The ID of the created group, or -1 if failed
function mergeGroups
bool mergeGroups(
int target_group_id,
std::vector< int > const & source_group_ids
)Merge multiple groups into a target group.
Parameters:
- target_group_id The group to merge into
- source_group_ids The groups to merge from (will be deleted)
Return: True if merge was successful, false otherwise
Updated on 2026-11-13 at 20:25:40 +0000