private bool ExpandNode(LayoutNode node) { bool ret = node.Collapsed; node.Collapsed = false; return(ret); }
private void RenderLabelSimple(DrawingContext drawingContext, LayoutNode node) { if (node.RenderData.Text != null && node.RenderData.TextPosition != null) { drawingContext.DrawText(node.RenderData.Text, node.RenderData.TextPosition); } }
private void RenderBasicShape(DrawingContext drawingContext, LayoutNode node, Brush color) { Point[] p = node.RenderData.Points; switch (node.RenderData.Category) { case RenderData.ShapeCategory.Simple: drawingContext.DrawRectangle(color, nodeBorderPen, new Rect(p[0].X, p[0].Y, p[1].X, p[1].Y)); break; case RenderData.ShapeCategory.Split: drawingContext.DrawRectangle(color, null, new Rect(p[1].X, p[0].Y, p[3].X - p[1].X, p[4].X)); drawingContext.DrawRectangle(color, null, new Rect(p[0].X, p[2].Y, p[2].X - p[0].X, p[4].Y)); drawingContext.DrawLine(nodeBorderPen, new Point(p[3].X, p[0].Y), new Point(p[1].X, p[0].Y)); drawingContext.DrawLine(nodeBorderPen, new Point(p[3].X, p[1].Y), new Point(p[1].X, p[1].Y)); drawingContext.DrawLine(nodeBorderPen, new Point(p[1].X, p[0].Y), new Point(p[1].X, p[1].Y)); drawingContext.DrawLine(nodeBorderPen, new Point(p[0].X, p[2].Y), new Point(p[2].X, p[2].Y)); drawingContext.DrawLine(nodeBorderPen, new Point(p[0].X, p[3].Y), new Point(p[2].X, p[3].Y)); drawingContext.DrawLine(nodeBorderPen, new Point(p[2].X, p[2].Y), new Point(p[2].X, p[3].Y)); break; case RenderData.ShapeCategory.Blob: DrawingHalpers.DrawPolygon(drawingContext, color, nodeBorderPen, p, FillRule.Nonzero); break; } }
private void FixEmptyBaseOptim(LayoutNode node) { ThreadHelper.ThrowIfNotOnUIThread(); for (int i = 1; i < node.Children.Count;) { var thisNode = node.Children[i]; var prevNode = node.Children[i - 1]; if (thisNode.Offset == prevNode.Offset) { if (prevNode.IsBaseCategory() && prevNode.Size == 1) { //Empty base optimization node.Extra.Add(prevNode); node.Children.RemoveAt(i - 1); } else { //Found unknown overlap OutputLog.Log("Found type overlap without known explanation"); ++i; } } else { ++i; } } }
private LayoutNode GetNodeAtPositionImpl(LayoutNode node, Point localPos, uint offset) { if (IsOffsetInside(node, offset) && IsPointInside(node.RenderData, localPos)) { if (node.IsExpanded) { if (node.ExpansionIndex.HasValue) { LayoutNode found = GetNodeAtPositionImpl(node.Children[node.ExpansionIndex.Value], localPos, offset); if (found != null) { return(found); } } else { foreach (LayoutNode child in node.Children) { LayoutNode found = GetNodeAtPositionImpl(child, localPos, offset); if (found != null) { return(found); } } } } return((GetSelectedDisplayMode() == DisplayMode.Stack || !node.IsExpanded)? node : null); } return(null); }
private void FixSharedMemory(LayoutNode node) { for (int i = 1; i < node.Children.Count;) { var thisNode = node.Children[i]; var prevNode = node.Children[i - 1]; if (thisNode.Offset == prevNode.Offset) { if (prevNode.IsBaseCategory() && prevNode.Size == 1) { //Empty base optimization node.Extra.Add(prevNode); node.Children.RemoveAt(i - 1); } else { ShareNodes(prevNode, thisNode); } } else { ++i; } } }
private void FixUnions(LayoutNode node) { if (node.Type.Length > 0 && node.Type.StartsWith("union")) { node.Category = LayoutNode.LayoutCategory.Union; } }
private void FinalizeNodeRecursive(LayoutNode node) { node.Offset += node.Parent != null ? node.Parent.Offset : 0; node.RenderData.Background = Colors.GetCategoryBackground(node.Category); node.RealSize = node.Children.Count == 0? node.Size : 0; uint realSizeOffset = node.Offset; foreach (LayoutNode child in node.Children) { FinalizeNodeRecursive(child); node.RealSize += realSizeOffset <= child.Offset ? child.RealSize : 0; realSizeOffset = Math.Max(child.Offset + child.Size, realSizeOffset); } //For shared memory nodes, children will be overlaped if (node.Category == LayoutNode.LayoutCategory.Shared || node.Category == LayoutNode.LayoutCategory.Union) { foreach (LayoutNode child in node.Children) { node.RealSize = Math.Max(child.RealSize, node.RealSize); } } }
public void FinalizeNode(LayoutNode node) { FixOverlaps(node); node.Expand(); FinalizeNodeRecursive(node); }
private void FixUnions(LayoutNode node) { if (node.Type.Length > 0 && node.Type.StartsWith("union")) { node.Category = LayoutNode.LayoutCategory.Union; node.Extra = node.Children; node.Children = new List <LayoutNode>(); } }
private void ComputeRenderData(LayoutNode node) { ComputeRenderShape(node); foreach (LayoutNode child in node.Children) { ComputeRenderData(child); } }
public void FinalizeNode(LayoutNode node) { ThreadHelper.ThrowIfNotOnUIThread(); FixOverlaps(node); node.Collapsed = false; FinalizeNodeRecursive(node); }
public void FinalizeNodeRecursive(LayoutNode node) { node.Offset += node.Parent != null ? node.Parent.Offset : 0; node.RenderData.Background = Colors.GetCategoryBackground(node.Category); foreach (LayoutNode child in node.Children) { FinalizeNodeRecursive(child); } }
private void ComputeTextLabelImpl(LayoutNode node, double posX, double posY, double sizeX, double sizeY) { if (sizeX >= textRenderMinWidth && sizeY >= textRenderMinHeight) { node.RenderData.Text = new FormattedText(GetNodeLabel(node), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Font, 12, Colors.GetCategoryForeground(), VisualTreeHelper.GetDpi(this).PixelsPerDip); node.RenderData.Text.MaxTextWidth = Math.Min(sizeX, node.RenderData.Text.Width); node.RenderData.Text.MaxTextHeight = NodeHeight; node.RenderData.TextPosition = new Point(posX + (sizeX - node.RenderData.Text.Width) * 0.5, posY + (sizeY - node.RenderData.Text.Height) * 0.5); } }
private void ComputeTextLabel(LayoutNode node) { Point[] p = node.RenderData.Points; node.RenderData.Text = null; switch (node.RenderData.Category) { case RenderData.ShapeCategory.Simple: ComputeTextLabelImpl(node, p[0].X, p[0].Y, p[1].X, p[1].Y); break; case RenderData.ShapeCategory.Split: double sizeA = p[3].X - p[1].X; double sizeB = p[2].X - p[0].X; if (sizeA >= sizeB) { ComputeTextLabelImpl(node, p[1].X, p[0].Y, sizeA, p[4].X); } else { ComputeTextLabelImpl(node, p[0].X, p[2].Y, sizeB, p[4].Y); } break; case RenderData.ShapeCategory.Blob: uint startRow = GetRow(node.Offset); uint lastRow = GetRow(node.Offset + node.Size - 1); uint startCol = GetCol(node.Offset); uint endCol = GetCol(node.Offset + node.Size); if (startRow + 1 == lastRow && startCol != 0 && endCol != 0) { //no full line if (DisplayGridColumns - startCol >= endCol) { ComputeTextLabelImpl(node, p[0].X, p[0].Y, p[2].X - p[0].X, p[2].Y - p[0].Y); } else { ComputeTextLabelImpl(node, p[6].X, p[6].Y, p[4].X - p[6].X, p[4].Y - p[6].Y); } } else { //center to the lines that take the whole alignment double startY = startCol == 0? p[0].Y : p[6].Y; double endY = endCol == 0? p[5].Y : p[2].Y; ComputeTextLabelImpl(node, p[5].X, startY, p[1].X - p[5].X, endY - startY); } break; } }
private void ExpandAllNodes(LayoutNode node) { if (node.Children.Count > 0) { node.Collapsed = false; foreach (LayoutNode child in node.Children) { ExpandAllNodes(child); } } }
private void BuildTypeStack(LayoutNode node) { var entry = new TextBlock(); entry.Text = "- " + (node.Type.Length > 0? node.Type : node.Category.ToString()); typeStack.Children.Add(entry); if (node.Parent != null) { BuildTypeStack(node.Parent); } }
private void AdjustBitfieldNode(LayoutNode node) { node.Extra = node.Children; node.Children = new List <LayoutNode>(); foreach (LayoutNode child in node.Extra) { child.Name = node.Name; child.Type = node.Type; child.Category = node.Category; } }
private void MergeBitfieldNodes(LayoutNode source, LayoutNode target) { foreach (LayoutNode child in source.Extra) { target.Extra.Add(child); } if (target.Extra.Count > 1) { target.Name = "Bitfield"; } }
private void RenderNodeStack(DrawingContext drawingContext, LayoutNode node) { RenderBasicShape(drawingContext, node, node.RenderData.Background); if (!node.Collapsed) { foreach (LayoutNode child in node.Children) { RenderNodeStack(drawingContext, child); } } }
private bool CollapseNode(LayoutNode node) { if (!node.Collapsed) { node.Collapsed = true; foreach (LayoutNode child in node.Children) { CollapseNode(child); } return(true); } return(false); }
private bool CollapseNode(LayoutNode node) { if (node.IsExpanded) { node.Collapse(); foreach (LayoutNode child in node.Children) { CollapseNode(child); } return(true); } return(false); }
private void RenderNodeFlat(DrawingContext drawingContext, LayoutNode node) { if (node.Children.Count == 0) { RenderBasicShape(drawingContext, node, node.RenderData.Background); } else { foreach (LayoutNode child in node.Children) { RenderNodeFlat(drawingContext, child); } } }
private void RenderLabel(DrawingContext drawingContext, LayoutNode node) { if (node.Collapsed) { RenderLabelSimple(drawingContext, node); } else { foreach (LayoutNode child in node.Children) { RenderLabel(drawingContext, child); } } }
private void PrepareRenderDataFlat(LayoutNode node) { var paddings = node.RenderData.Paddings; foreach (RenderData.PaddingSide side in (RenderData.PaddingSide[])Enum.GetValues(typeof(RenderData.PaddingSide))) { paddings[(int)side] = 0; } foreach (LayoutNode child in node.Children) { PrepareRenderDataFlat(child); } }
private void CreateChildSelectionMenu(LayoutNode node) { System.Windows.Forms.ContextMenuStrip contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(); for (int i = 0; i < node.Children.Count; ++i) { int index = i; //Copy to local variable in order to work for the click callback LayoutNode child = node.Children[index]; var element = new System.Windows.Forms.ToolStripMenuItem(); element.Text = String.IsNullOrEmpty(child.Name)? (String.IsNullOrEmpty(child.Type)? child.Category.ToString() : child.Type) : child.Name; element.Click += (sender, e) => TriggerNodeExpansion(node, index); contextMenuStrip.Items.Add(element); } contextMenuStrip.Show(System.Windows.Forms.Control.MousePosition); }
private void FixOverlaps(LayoutNode node) { ThreadHelper.ThrowIfNotOnUIThread(); FixUnions(node); FixBitfields(node); FixEmptyBaseOptim(node); //continue recursion foreach (LayoutNode child in node.Children) { FixOverlaps(child); } }
public void SetLayout(LayoutNode root) { Root = root; SetHoverNode(null); uint displayAlignment = Root != null && GetSelectedDisplayAlignment() == DisplayAlignmentType.Struct? Root.Align : DisplayGridColumns; if (!SetDisplayGridColumns(displayAlignment)) { RefreshNodeRenderData(); SetupCanvas(); RenderGrid(); RefreshShapes(); } }
private void FixOverlaps(LayoutNode node) { FixUnions(node); if (!node.IsSharedMemory()) { FixBitfields(node); FixSharedMemory(node); } //continue recursion foreach (LayoutNode child in node.Children) { FixOverlaps(child); } }
private void FinalizeNodeRecursive(LayoutNode node) { node.Offset += node.Parent != null ? node.Parent.Offset : 0; node.RenderData.Background = Colors.GetCategoryBackground(node.Category); node.RealSize = node.Children.Count == 0? node.Size : 0; uint realSizeOffset = node.Offset; foreach (LayoutNode child in node.Children) { FinalizeNodeRecursive(child); node.RealSize += realSizeOffset <= child.Offset ? child.RealSize : 0; realSizeOffset = Math.Max(child.Offset + child.Size, realSizeOffset); } }