diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp index c5bb698d..d60262d0 100644 --- a/src/lib/component/controller/GraphController.cpp +++ b/src/lib/component/controller/GraphController.cpp @@ -10,6 +10,7 @@ #include "component/view/GraphViewStyle.h" #include "data/access/StorageAccess.h" #include "data/graph/Graph.h" +#include "data/graph/token_component/TokenComponentAggregation.h" GraphController::GraphController(StorageAccess* storageAccess) : m_storageAccess(storageAccess) @@ -262,6 +263,11 @@ void GraphController::setActiveAndVisibility(const std::vector& activeTokenI for (DummyEdge& edge : m_dummyEdges) { + if (edge.data->isType(Edge::EDGE_AGGREGATION)) + { + continue; + } + edge.active = false; if (find(activeTokenIds.begin(), activeTokenIds.end(), edge.data->getId()) != activeTokenIds.end()) { @@ -274,17 +280,42 @@ void GraphController::setActiveAndVisibility(const std::vector& activeTokenI if (from && to && (from->active || to->active || edge.active)) { edge.visible = true; + from->connected = true; + to->connected = true; + } + } - if (edge.data->isType(Edge::EDGE_AGGREGATION)) + for (DummyEdge& edge : m_dummyEdges) + { + if (!edge.data->isType(Edge::EDGE_AGGREGATION)) + { + continue; + } + + DummyNode* from = findDummyNodeRecursive(m_dummyNodes, edge.ownerId); + DummyNode* to = findDummyNodeRecursive(m_dummyNodes, edge.targetId); + + if (from && to && (from->active || to->active)) + { + TokenComponentAggregation* component = edge.data->getComponent(); + std::set ids = component->getAggregationIds(); + for (Id id : ids) { + for (DummyEdge& e : m_dummyEdges) + { + if (e.visible && e.data->getId() == id) + { + component->removeAggregationId(id); + } + } + } + + if (component->getAggregationCount() > 0) + { + edge.visible = true; from->aggregated = true; to->aggregated = true; } - else - { - from->connected = true; - to->connected = true; - } } } diff --git a/src/lib/data/graph/token_component/TokenComponentAggregation.cpp b/src/lib/data/graph/token_component/TokenComponentAggregation.cpp index 5110d06d..42147371 100644 --- a/src/lib/data/graph/token_component/TokenComponentAggregation.cpp +++ b/src/lib/data/graph/token_component/TokenComponentAggregation.cpp @@ -18,12 +18,17 @@ int TokenComponentAggregation::getAggregationCount() const return m_ids.size(); } +const std::set& TokenComponentAggregation::getAggregationIds() const +{ + return m_ids; +} + void TokenComponentAggregation::addAggregationId(Id id) { m_ids.insert(id); } -const std::set& TokenComponentAggregation::getAggregationIds() const +void TokenComponentAggregation::removeAggregationId(Id id) { - return m_ids; + m_ids.erase(id); } diff --git a/src/lib/data/graph/token_component/TokenComponentAggregation.h b/src/lib/data/graph/token_component/TokenComponentAggregation.h index c384994e..d5a8be14 100644 --- a/src/lib/data/graph/token_component/TokenComponentAggregation.h +++ b/src/lib/data/graph/token_component/TokenComponentAggregation.h @@ -17,9 +17,11 @@ public: virtual std::shared_ptr copy() const; int getAggregationCount() const; - void addAggregationId(Id id); const std::set& getAggregationIds() const; + void addAggregationId(Id id); + void removeAggregationId(Id id); + private: std::set m_ids; };