From 4e08d86602b28f649948d3da8f09e131b4a1e2f9 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Mon, 23 May 2016 15:58:31 +0200 Subject: [PATCH] logic: Fixed base and derived classes not correctly at top or bottom Prioritize inheritance and override over all other edges. --- .../component/controller/GraphController.cpp | 12 ++++++++++++ .../controller/helper/BucketGrid.cpp | 19 ++++++++++++++----- src/lib/utility/Cache.h | 2 +- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp index c50bd8b9..dce2b9a2 100644 --- a/src/lib/component/controller/GraphController.cpp +++ b/src/lib/component/controller/GraphController.cpp @@ -537,13 +537,25 @@ void GraphController::bundleNodes() bundleInfo->isDefined = true; } + if (bundleInfo->layoutVertical) + { + return; + } + n->forEachEdgeOfType( ~Edge::EDGE_MEMBER, [&bundleInfo, &n](Edge* e) { + if (bundleInfo->layoutVertical) + { + return; + } + if (e->isType(Edge::EDGE_INHERITANCE | Edge::EDGE_OVERRIDE)) { bundleInfo->layoutVertical = true; + bundleInfo->isReferenced = false; + bundleInfo->isReferencing = false; } if (e->isType(Edge::EDGE_AGGREGATION)) diff --git a/src/lib/component/controller/helper/BucketGrid.cpp b/src/lib/component/controller/helper/BucketGrid.cpp index c617ea9a..3d4e1b46 100644 --- a/src/lib/component/controller/helper/BucketGrid.cpp +++ b/src/lib/component/controller/helper/BucketGrid.cpp @@ -172,11 +172,6 @@ void BucketGrid::createBuckets( DummyNode* owner = findTopMostDummyNodeRecursive(nodes, edge->ownerId); DummyNode* target = findTopMostDummyNodeRecursive(nodes, edge->targetId); - if (edge->getDirection() == TokenComponentAggregation::DIRECTION_BACKWARD) - { - std::swap(owner, target); - } - bool removeEdge = false; if (!owner || !target) { @@ -185,6 +180,20 @@ void BucketGrid::createBuckets( else { bool horizontal = !owner->bundleInfo.layoutVertical && !target->bundleInfo.layoutVertical; + + if (!horizontal) + { + if ((owner->bundleInfo.layoutVertical && owner->bundleInfo.isReferenced) || + (target->bundleInfo.layoutVertical && target->bundleInfo.isReferencing)) + { + std::swap(owner, target); + } + } + else if (edge->getDirection() == TokenComponentAggregation::DIRECTION_BACKWARD) + { + std::swap(owner, target); + } + removeEdge = addNode(owner, target, horizontal); } diff --git a/src/lib/utility/Cache.h b/src/lib/utility/Cache.h index 93a9dd82..3ee702f1 100644 --- a/src/lib/utility/Cache.h +++ b/src/lib/utility/Cache.h @@ -22,7 +22,7 @@ Cache::Cache(std::function calculato { } -template > +template ValType Cache::getValue(KeyType key) { typename std::unordered_map::const_iterator it = m_map.find(key);