@@ -2739,7 +2739,13 @@ proc optimize_rows {row col endrow} {
2739
2739
set isarrow 1
2740
2740
}
2741
2741
}
2742
+ # Looking at lines from this row to the previous row,
2743
+ # make them go straight up if they end in an arrow on
2744
+ # the previous row; otherwise make them go straight up
2745
+ # or at 45 degrees.
2742
2746
if {$z < -1 || ($z < 0 && $isarrow )} {
2747
+ # Line currently goes left too much;
2748
+ # insert pads in the previous row, then optimize it
2743
2749
set npad [expr {-1 - $z + $isarrow }]
2744
2750
set offs [incrange $offs $col $npad ]
2745
2751
insert_pad $y0 $x0 $npad
@@ -2750,6 +2756,8 @@ proc optimize_rows {row col endrow} {
2750
2756
set x0 [expr {$col + $z }]
2751
2757
set z0 [lindex $rowoffsets $y0 $x0 ]
2752
2758
} elseif {$z > 1 || ($z > 0 && $isarrow )} {
2759
+ # Line currently goes right too much;
2760
+ # insert pads in this line and adjust the next's rowoffsets
2753
2761
set npad [expr {$z - 1 + $isarrow }]
2754
2762
set y1 [expr {$row + 1}]
2755
2763
set offs2 [lindex $rowoffsets $y1 ]
@@ -2780,6 +2788,7 @@ proc optimize_rows {row col endrow} {
2780
2788
set z0 [expr {$xc - $x0 }]
2781
2789
}
2782
2790
}
2791
+ # avoid lines jigging left then immediately right
2783
2792
if {$z0 ne {} && $z < 0 && $z0 > 0} {
2784
2793
insert_pad $y0 $x0 1
2785
2794
set offs [incrange $offs $col 1]
@@ -2788,6 +2797,7 @@ proc optimize_rows {row col endrow} {
2788
2797
}
2789
2798
if {!$haspad } {
2790
2799
set o {}
2800
+ # Find the first column that doesn't have a line going right
2791
2801
for {set col [llength $idlist ]} {[incr col -1] >= 0} {} {
2792
2802
set o [lindex $offs $col ]
2793
2803
if {$o eq {}} {
@@ -2806,6 +2816,8 @@ proc optimize_rows {row col endrow} {
2806
2816
}
2807
2817
if {$o eq {} || $o <= 0} break
2808
2818
}
2819
+ # Insert a pad at that column as long as it has a line and
2820
+ # isn't the last column, and adjust the next row' offsets
2809
2821
if {$o ne {} && [incr col] < [llength $idlist ]} {
2810
2822
set y1 [expr {$row + 1}]
2811
2823
set offs2 [lindex $rowoffsets $y1 ]
0 commit comments