mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GT-3161 - Function Graph - fixed 3 bugs that caused some edges to get
clipped by vertices
This commit is contained in:
parent
c10939cb63
commit
99ded59e84
2 changed files with 26 additions and 16 deletions
|
@ -253,14 +253,11 @@ public class DecompilerNestedLayout extends AbstractFGLayout {
|
||||||
|
|
||||||
Vertex2d start = vertex2dFactory.get(startVertex);
|
Vertex2d start = vertex2dFactory.get(startVertex);
|
||||||
Vertex2d end = vertex2dFactory.get(endVertex);
|
Vertex2d end = vertex2dFactory.get(endVertex);
|
||||||
|
boolean goingUp = start.rowIndex > end.rowIndex;
|
||||||
Address startAddress = startVertex.getVertexAddress();
|
|
||||||
Address endAddress = endVertex.getVertexAddress();
|
|
||||||
int compareResult = startAddress.compareTo(endAddress);
|
|
||||||
boolean goingUp = compareResult > 0;
|
|
||||||
|
|
||||||
if (goingUp) {
|
if (goingUp) {
|
||||||
|
// we paint loops going back up differently than other edges so the user can
|
||||||
|
// visually pick out the loops much easier
|
||||||
DecompilerBlock block = blockGraphRoot.getBlock(endVertex);
|
DecompilerBlock block = blockGraphRoot.getBlock(endVertex);
|
||||||
DecompilerBlock loop = block.getParentLoop();
|
DecompilerBlock loop = block.getParentLoop();
|
||||||
|
|
||||||
|
@ -383,8 +380,7 @@ public class DecompilerNestedLayout extends AbstractFGLayout {
|
||||||
double y2 = y1;
|
double y2 = y1;
|
||||||
articulations.add(new Point2D.Double(x2, y2));
|
articulations.add(new Point2D.Double(x2, y2));
|
||||||
|
|
||||||
Column column = vertex2dFactory.getColumn(x1);
|
routeAroundColumnVertices(start, end, vertex2dFactory, articulations, x2);
|
||||||
routeAroundColumnVertices(start, end, column.index, vertex2dFactory, articulations, x2);
|
|
||||||
|
|
||||||
double x3 = x2;
|
double x3 = x2;
|
||||||
double y3 = end.getBottom() - VERTEX_BORDER_THICKNESS;
|
double y3 = end.getBottom() - VERTEX_BORDER_THICKNESS;
|
||||||
|
@ -424,6 +420,11 @@ public class DecompilerNestedLayout extends AbstractFGLayout {
|
||||||
routeAroundColumnVertices(start, end, vertex2dFactory, articulations, x3);
|
routeAroundColumnVertices(start, end, vertex2dFactory, articulations, x3);
|
||||||
|
|
||||||
articulations.add(new Point2D.Double(x3, y3));
|
articulations.add(new Point2D.Double(x3, y3));
|
||||||
|
|
||||||
|
double x4 = end.getX();
|
||||||
|
double y4 = y3;
|
||||||
|
articulations.add(new Point2D.Double(x4, y4)); // point is hidden behind the vertex
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void routeToTheLeft(Vertex2d start, Vertex2d end, FGEdge e,
|
private void routeToTheLeft(Vertex2d start, Vertex2d end, FGEdge e,
|
||||||
|
@ -538,19 +539,28 @@ public class DecompilerNestedLayout extends AbstractFGLayout {
|
||||||
y2 = Math.min(y2, endYLimit);
|
y2 = Math.min(y2, endYLimit);
|
||||||
articulations.add(new Point2D.Double(x2, y2));
|
articulations.add(new Point2D.Double(x2, y2));
|
||||||
|
|
||||||
// have not yet seen an example of vertex/edge clipping when routing to the right
|
routeAroundColumnVertices(start, end, vertex2dFactory, articulations, x2);
|
||||||
// routeAroundColumnVertices(start, end, vertex2dFactory, articulations, x2);
|
|
||||||
|
|
||||||
double x3 = end.getX();
|
double x3 = x2;
|
||||||
double y3 = y2;
|
double y3 = end.getY();
|
||||||
articulations.add(new Point2D.Double(x3, y3)); // point is hidden behind the vertex
|
articulations.add(new Point2D.Double(x3, y3)); // point is hidden behind the vertex
|
||||||
|
|
||||||
|
double x4 = end.getX();
|
||||||
|
double y4 = y3;
|
||||||
|
articulations.add(new Point2D.Double(x4, y4)); // point is hidden behind the vertex
|
||||||
}
|
}
|
||||||
|
|
||||||
private void routeAroundColumnVertices(Vertex2d start, Vertex2d end,
|
private void routeAroundColumnVertices(Vertex2d start, Vertex2d end,
|
||||||
Vertex2dFactory vertex2dFactory, List<Point2D> articulations, double edgeX) {
|
Vertex2dFactory vertex2dFactory, List<Point2D> articulations, double edgeX) {
|
||||||
|
|
||||||
int column = end.columnIndex;
|
Column column = vertex2dFactory.getColumn(edgeX);
|
||||||
routeAroundColumnVertices(start, end, column, vertex2dFactory, articulations, edgeX);
|
int columnIndex = 0;
|
||||||
|
if (column != null) {
|
||||||
|
// a null column happens with a negative x value that is outside of any column
|
||||||
|
columnIndex = column.index;
|
||||||
|
}
|
||||||
|
|
||||||
|
routeAroundColumnVertices(start, end, columnIndex, vertex2dFactory, articulations, edgeX);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void routeAroundColumnVertices(Vertex2d start, Vertex2d end, int column,
|
private void routeAroundColumnVertices(Vertex2d start, Vertex2d end, int column,
|
||||||
|
|
|
@ -103,10 +103,10 @@ public class LayoutLocationMap<V, E> {
|
||||||
Column column = null;
|
Column column = null;
|
||||||
Collection<Column> values = columnsByIndex.values();
|
Collection<Column> values = columnsByIndex.values();
|
||||||
for (Column nextColumn : values) {
|
for (Column nextColumn : values) {
|
||||||
column = nextColumn;
|
if (x < nextColumn.x) {
|
||||||
if (x < column.x) {
|
|
||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
column = nextColumn;
|
||||||
}
|
}
|
||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue