feat(app): finish measured native graph canvas and clear labels from wires
This commit is contained in:
@@ -16,6 +16,7 @@ EdgeLabelBox placeEdgeLabel({
|
||||
required LabelExtent extent,
|
||||
required List<GraphNodeBox> nodes,
|
||||
required List<EdgeLabelBox> placed,
|
||||
required List<EdgeRoute> routes,
|
||||
required RoutingConfig config,
|
||||
required double floorY,
|
||||
}) {
|
||||
@@ -29,7 +30,7 @@ EdgeLabelBox placeEdgeLabel({
|
||||
width: width,
|
||||
height: height,
|
||||
);
|
||||
if (_fits(box, nodes, placed, config)) return box;
|
||||
if (_fits(box, nodes, placed, routes, config)) return box;
|
||||
}
|
||||
|
||||
// The fallback shelf is below every route and every existing label, so it
|
||||
@@ -50,7 +51,7 @@ EdgeLabelBox placeEdgeLabel({
|
||||
width: width,
|
||||
height: height,
|
||||
);
|
||||
if (_fits(box, nodes, placed, config)) return box;
|
||||
if (_fits(box, nodes, placed, routes, config)) return box;
|
||||
top += step;
|
||||
}
|
||||
// A zero-sized label cannot collide; this is unreachable for real extents.
|
||||
@@ -67,9 +68,35 @@ bool _fits(
|
||||
EdgeLabelBox box,
|
||||
List<GraphNodeBox> nodes,
|
||||
List<EdgeLabelBox> placed,
|
||||
List<EdgeRoute> routes,
|
||||
RoutingConfig config,
|
||||
) {
|
||||
if (box.x < 0 || box.y < 0) return false;
|
||||
// A label clear of nodes can still sit across its self-loop's vertical leg
|
||||
// or another edge. Keep its measured text rectangle clear of every wire.
|
||||
final left = box.x - config.labelGap;
|
||||
final right = box.right + config.labelGap;
|
||||
final top = box.y - config.labelGap;
|
||||
final bottom = box.bottom + config.labelGap;
|
||||
for (final route in routes) {
|
||||
for (var index = 1; index < route.points.length; index++) {
|
||||
final a = route.points[index - 1], b = route.points[index];
|
||||
if (a.x == b.x &&
|
||||
a.x > left &&
|
||||
a.x < right &&
|
||||
math.max(a.y, b.y) > top &&
|
||||
math.min(a.y, b.y) < bottom) {
|
||||
return false;
|
||||
}
|
||||
if (a.y == b.y &&
|
||||
a.y > top &&
|
||||
a.y < bottom &&
|
||||
math.max(a.x, b.x) > left &&
|
||||
math.min(a.x, b.x) < right) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final node in nodes) {
|
||||
if (boxIntersectsNode(
|
||||
x: box.x,
|
||||
|
||||
@@ -106,6 +106,7 @@ GraphRouting routeGraphEdges({
|
||||
extent: labelExtents[routes[index].id]!,
|
||||
nodes: layout.nodes,
|
||||
placed: labels,
|
||||
routes: routes,
|
||||
config: config,
|
||||
floorY: floorY,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user