private void DrawRelations(VisualizationNodeBase node, int depth, RelationType relationType)
        {
            List <VisualizationConnection> visualizationConnections = node.GetRelations(relationType);

            foreach (VisualizationConnection childConnection in visualizationConnections)
            {
                DrawConnectionForNodes(node, childConnection, relationType, false, visualizationConnections.Count);

                VisualizationNodeBase childNode = childConnection.VNode;

                if (_viewAreaData.IsRectInDrawArea(childNode.TreeBounds.Rect, new Color(0.1f, 0.2f, 0.5f, 0.3f)))
                {
                    DrawRelations(childNode, depth + 1, relationType);

                    float positionOffset = childNode.GetPositionOffset(_viewAreaData);
                    Rect  r = childNode.Bounds.Rect;
                    r.Set(r.x, r.y + positionOffset, r.width, r.height);

                    if (_viewAreaData.IsRectInDrawArea(r, new Color(0.6f, 0.2f, 0.1f, 0.3f)))
                    {
                        childNode.Draw(depth, relationType, this, this, DisplayData, _viewAreaData);
                    }
                }
            }

            List <VisualizationConnection> childConnections = node.GetRelations(InvertRelationType(relationType), false, true);

            foreach (VisualizationConnection childConnection in childConnections)
            {
                DrawConnectionForNodes(node, childConnection, InvertRelationType(relationType), true, childConnections.Count);
            }
        }
        private void DrawConnectionForNodes(VisualizationNodeBase node, VisualizationConnection childConnection, RelationType relationType, bool isRecursion, int connectionCount)
        {
            VisualizationNodeBase childNode = childConnection.VNode;
            VisualizationNodeBase current   = relationType == RelationType.DEPENDENCY ? node : childNode;
            VisualizationNodeBase target    = relationType == RelationType.DEPENDENCY ? childNode : node;

            Vector2 currentPos = current.GetPosition(_viewAreaData);
            Vector2 targetPos  = target.GetPosition(_viewAreaData);

            float distanceBlend = 1;

            if (connectionCount > 20)
            {
                distanceBlend = Mathf.Pow(1 - Mathf.Clamp01(Mathf.Abs(currentPos.y - targetPos.y) / 20000.0f), 3);
            }

            float alphaAmount = (isRecursion ? 0.15f : 1.0f) * distanceBlend;

            DrawRecursionButton(isRecursion, node, childNode, relationType);

            if (childConnection.IsIndicator)
            {
                return;
            }

            if (alphaAmount > 0.01)
            {
                DrawConnection(currentPos.x + current.Bounds.Width, currentPos.y, targetPos.x, targetPos.y, GetConnectionColorForType(childConnection.Datas[0].Type), alphaAmount);
            }
        }
        /// <summary>
        /// Scrolls the view to a position where the main asset is centered
        /// </summary>
        private void JumpToNode(VisualizationNodeBase node)
        {
            Vector2 nodePos = node.GetPosition(_viewAreaData);

            _viewAreaData.ScrollPosition.x = -_viewAreaData.Bounds.MinX - _viewAreaData.ViewArea.width / 2 + nodePos.x + node.Bounds.Width;
            _viewAreaData.ScrollPosition.y = -_viewAreaData.Bounds.MinY - _viewAreaData.ViewArea.height / 2 + nodePos.y + node.Bounds.Height;
        }
Beispiel #4
0
        public void CalculateYData(RelationType connectionType)
        {
            List <VisualizationConnection> connections = GetRelations(connectionType);

            int[] offsets     = new int[connections.Count];
            int   totalHeight = 0;

            foreach (VisualizationConnection childConnection in connections)
            {
                childConnection.VNode.CalculateYData(connectionType);
            }

            for (var i = 0; i < connections.Count - 1; i++)
            {
                int w1     = connections[i].VNode.TreeBounds.MaxY;
                int w2     = connections[i + 1].VNode.TreeBounds.MinY;
                int height = w1 - w2;
                offsets[i + 1] = height + totalHeight;
                totalHeight   += height;
            }

            for (var i = 0; i < connections.Count; i++)
            {
                VisualizationNodeBase childNode = connections[i].VNode;
                childNode.ShiftY(offsets[i] - totalHeight / 2, connectionType);
                TreeBounds.Enclose(childNode.TreeBounds);
            }
        }
 private void ApplyNodeWidths(VisualizationNodeBase node, int[] maxPositions, RelationType relationType, int depth)
 {
     node.ExtendedNodeWidth = maxPositions[depth];
     foreach (VisualizationConnection childConnection in node.GetRelations(relationType))
     {
         ApplyNodeWidths(childConnection.VNode, maxPositions, relationType, depth + 1);
     }
 }
        private void GetNodeWidths(VisualizationNodeBase node, int[] maxWidths, RelationType relationType, int depth)
        {
            maxWidths[depth] = Math.Max(maxWidths[depth], node.Bounds.Width);

            foreach (VisualizationConnection childConnection in node.GetRelations(relationType))
            {
                GetNodeWidths(childConnection.VNode, maxWidths, relationType, depth + 1);
            }
        }
        private void InvalidateNodePositionData(VisualizationNodeBase node, RelationType relationType)
        {
            node.InvalidatePositionData();

            foreach (VisualizationConnection childConnection in node.GetRelations(relationType))
            {
                InvalidateNodePositionData(childConnection.VNode, relationType);
            }
        }
        private void DrawRecursionButton(bool isRecursion, VisualizationNodeBase node, VisualizationNodeBase childNode, RelationType relationType)
        {
            int     offset   = relationType == RelationType.REFERENCER ? childNode.Bounds.Width :  -16;
            Vector2 position = childNode.GetPosition(_viewAreaData);

            if (isRecursion && GUI.Button(new Rect(position.x + offset, position.y, 16, 16), ">"))
            {
                JumpToNode(node);
            }
        }
        private void AddBidirConnection(RelationType relationType, VisualizationNodeBase node, VisualizationNodeBase target,
                                        List <VisualizationConnection.Data> datas, bool isRecursion)
        {
            if (_nodeDisplayOptions.ShowPropertyPathes)
            {
                PathVisualizationNode pathVisualizationNode = new PathVisualizationNode();

                if (!VisualizationConnection.HasPathSegments(datas))
                {
                    datas = new List <VisualizationConnection.Data>();
                    datas.Add(new VisualizationConnection.Data("UnknownPath", new [] { new PathSegment("Unknown Path", PathSegmentType.Unknown) }));
                }

                node.AddRelation(relationType, new VisualizationConnection(datas, pathVisualizationNode, false));
                pathVisualizationNode.AddRelation(InvertRelationType(relationType), new VisualizationConnection(datas, node, false));

                node = pathVisualizationNode;
            }

            node.AddRelation(relationType, new VisualizationConnection(datas, target, isRecursion));
            target.AddRelation(InvertRelationType(relationType), new VisualizationConnection(datas, node, isRecursion));
        }
Beispiel #10
0
 public VisualizationConnection(List <Data> datas, VisualizationNodeBase node, bool isRecursion)
 {
     Datas       = datas;
     VNode       = node;
     IsRecursion = isRecursion;
 }