From 921dad88adc87ccf04238c25bbdc7d8653c8ecce Mon Sep 17 00:00:00 2001 From: Chad Barb Date: Fri, 2 Aug 2002 22:32:35 +0000 Subject: [PATCH] Added a prefix for node names when fed to neato, so they don't collide with reserved words (e.g. "node"). Prefix is removed by renderer. Also made LAN icons round, as per Jay's request. --- vis/dbtopper.in | 1 + vis/dbvistopology.in | 2 +- vis/render.in | 38 ++++++++++++++++++++++++++++++-------- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/vis/dbtopper.in b/vis/dbtopper.in index ee91ba509..14ac257cf 100755 --- a/vis/dbtopper.in +++ b/vis/dbtopper.in @@ -133,6 +133,7 @@ sub combineloss { sub gvclean { my $n = shift; $n =~ s/\W/_/g; + $n = "_x1823Y_" . $n; return $n; } diff --git a/vis/dbvistopology.in b/vis/dbvistopology.in index d95caad7c..6b4f27b5a 100755 --- a/vis/dbvistopology.in +++ b/vis/dbvistopology.in @@ -15,7 +15,7 @@ use Getopt::Std; sub usage() { print STDOUT - "Usage: vistoplogy [-o ] [-z ] [-d ] \n"; + "Usage: dbvistoplogy [-o ] [-z ] [-d ] \n"; exit(-1); } my $optlist = "o:z:d:"; diff --git a/vis/render.in b/vis/render.in index a9472dd1d..30c6b45ce 100755 --- a/vis/render.in +++ b/vis/render.in @@ -261,8 +261,18 @@ $im->fill( 1, 1, $bgcolor ); foreach $i (keys %nodes) { ($x, $y) = ($nodepos{ $i }[0], $nodepos{ $i }[1]); - $im->filledRectangle( $x - 12, $y - 12, - $x + 20, $y + 20, $colors{"gray80"}); + $cname = $nodes{$i}{"color"}; + if ($cname eq "green") { + for ($i = 1; $i < 18; $i++) { + $im->arc( $x + 4, $y + 4, + $i * 2, $i * 2, + 0, 360, + $colors{"gray80"} ); + } + } else { + $im->filledRectangle( $x - 12, $y - 12, + $x + 20, $y + 20, $colors{"gray80"}); + } } # render links @@ -323,13 +333,23 @@ foreach $i (keys %nodes) { if ($cname eq "red") { $im->rectangle( $x - 16, $y - 16, $x + 16, $y + 16, $colors{"darkred"} ); $im->rectangle( $x - 15, $y - 15, $x + 15, $y + 15, $colors{"darkred"} ); + } elsif ($cname eq "green") { + $im->arc( $x, $y, 36, 36, 0, 360, $colors{"gray50"} ); + $im->arc( $x, $y, 34, 34, 0, 360, $colors{"gray25"} ); + $im->arc( $x, $y, 32, 32, 0, 360, $colors{"gray75"} ); } else { $im->rectangle( $x - 16, $y - 16, $x + 16, $y + 16, $colors{"gray25"} ); $im->rectangle( $x - 15, $y - 15, $x + 15, $y + 15, $colors{"gray25"} ); } - $im->filledRectangle( $x - 14, $y - 14, - $x + 14, $y + 14, $colors{"white"} ); + if ($cname eq "green") { + for ($i = 1; $i < 16; $i++) { + $im->arc( $x, $y, $i * 2, $i * 2, 0, 360, $colors{"white"} ); + } + } else { + $im->filledRectangle( $x - 14, $y - 14, + $x + 14, $y + 14, $colors{"white"} ); + } if ($nodeicon && ($cname eq "skyblue" || $cname eq "steelblue" || @@ -339,8 +359,8 @@ foreach $i (keys %nodes) { } elsif ($lanicon && $cname eq "green") { $im->copy($lanicon, $x-16, $y-16, 0, 0, 32, 32); } else { - $im->filledRectangle( $x - 6, $y - 6, - $x + 6, $y + 6, $c ); + $im->filledRectangle( $x - 6, $y - 6, + $x + 6, $y + 6, $c ); } } @@ -356,7 +376,9 @@ foreach $i (@links) { ($x, $y) = ( ($x1 + $x2) / 2, ($y1 + $y2) / 2 ); $linklabels{ $i } =~ s/^\!..//; - + # axe prefix added to avoid reserved-word collide: + $linklabels{ $i } =~ s/_x1823Y_//; + my @lines = split " ", $linklabels{ $i }; $y -= (0.5 * (@lines * gdTinyFont->height)); @@ -391,7 +413,7 @@ foreach $i (keys %nodes) { $nm .= " "; $nm =~ s/^(\S+)//; - + $nm =~ s/_x1823Y_//; push @lines, $1; while ( $nm =~ s/^(.{1,12})\s// ) { -- GitLab