b381290f34
Pure-Dart P2c slice: interval-aware ports and corridors, label-aware lane spacing, measured label placement with fallback shelf, skipped diagnostics and routing bounds. 20 focused tests plus existing suite and web build pass.
65 lines
2.2 KiB
Dart
65 lines
2.2 KiB
Dart
/// Caller-supplied measurements and clearances for graph-edge routing.
|
|
///
|
|
/// No font, widget style, device class or CSS value is assumed: every size is
|
|
/// measured or chosen by the caller.
|
|
library;
|
|
|
|
void _requireFiniteNonNegative(String name, double value) {
|
|
if (!value.isFinite || value < 0) {
|
|
throw ArgumentError.value(value, name, 'must be finite and non-negative');
|
|
}
|
|
}
|
|
|
|
void _requireFinitePositive(String name, double value) {
|
|
if (!value.isFinite || value <= 0) {
|
|
throw ArgumentError.value(value, name, 'must be finite and positive');
|
|
}
|
|
}
|
|
|
|
/// A caller-measured edge label extent, in logical pixels.
|
|
class LabelExtent {
|
|
LabelExtent({required this.width, required this.height}) {
|
|
_requireFiniteNonNegative('width', width);
|
|
_requireFiniteNonNegative('height', height);
|
|
}
|
|
|
|
final double width;
|
|
final double height;
|
|
}
|
|
|
|
/// Clearances and spacings a caller reserves for edge geometry.
|
|
///
|
|
/// [nodeClearance] is the distance a lane or corridor keeps from every node
|
|
/// edge. [laneSpacing] separates the horizontal tracks used by wrapping
|
|
/// routes, [corridorSpacing] separates vertical tracks inside one column gap,
|
|
/// and [portSpacing] separates ports on a node side. [labelGap] keeps a label
|
|
/// box off its wire; [boundsPadding] is added to the returned bounds.
|
|
///
|
|
/// The router may widen a lane step beyond [laneSpacing] when the measured
|
|
/// label heights need the room. Inside a narrow column gap it compresses
|
|
/// corridor or port spacing rather than routing a track into a node column.
|
|
class RoutingConfig {
|
|
RoutingConfig({
|
|
required this.nodeClearance,
|
|
required this.laneSpacing,
|
|
required this.corridorSpacing,
|
|
required this.portSpacing,
|
|
required this.labelGap,
|
|
this.boundsPadding = 0,
|
|
}) {
|
|
_requireFiniteNonNegative('nodeClearance', nodeClearance);
|
|
_requireFinitePositive('laneSpacing', laneSpacing);
|
|
_requireFinitePositive('corridorSpacing', corridorSpacing);
|
|
_requireFinitePositive('portSpacing', portSpacing);
|
|
_requireFiniteNonNegative('labelGap', labelGap);
|
|
_requireFiniteNonNegative('boundsPadding', boundsPadding);
|
|
}
|
|
|
|
final double nodeClearance;
|
|
final double laneSpacing;
|
|
final double corridorSpacing;
|
|
final double portSpacing;
|
|
final double labelGap;
|
|
final double boundsPadding;
|
|
}
|