Пример #1
0
    private void CheckForConflicts(DependencyViewerNode node, int depth, DependencyViewerNode.NodeInputSide treeSide)
    {
        float minDistance = node.GetHeight() + DependencyViewerGraphDrawer.DistanceBetweenNodes.y;
        float shiftValue  = 0.0f;

        var nodeContour = new Dictionary <int, float>();

        TreeLayout.GetStartContour(node, depth, treeSide, 0, ref nodeContour);

        var sibling = node.GetFirstSibling(treeSide);

        while (sibling != null && sibling != node)
        {
            var siblingContour = new Dictionary <int, float>();
            TreeLayout.GetEndContour(sibling, depth, treeSide, 0, ref siblingContour);

            int maxContourDepth = Mathf.Min(siblingContour.Keys.Max(), nodeContour.Keys.Max());
            for (int level = depth + 1; level <= maxContourDepth; ++level)
            {
                float distance = nodeContour[level] - siblingContour[level];
                if (distance + shiftValue < minDistance)
                {
                    shiftValue = minDistance - distance;
                }
            }

            if (shiftValue > 0)
            {
                node.SetPositionY(node.Position.y + shiftValue);
                node.Mod += shiftValue;

                CenterNodesBetween(node, sibling, treeSide, depth);

                shiftValue = 0;
            }

            sibling = sibling.GetNextSibling(treeSide);
        }
    }