Commit 921dad88 authored by Chad Barb's avatar Chad Barb

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.
parent e4eb9868
...@@ -133,6 +133,7 @@ sub combineloss { ...@@ -133,6 +133,7 @@ sub combineloss {
sub gvclean { sub gvclean {
my $n = shift; my $n = shift;
$n =~ s/\W/_/g; $n =~ s/\W/_/g;
$n = "_x1823Y_" . $n;
return $n; return $n;
} }
......
...@@ -15,7 +15,7 @@ use Getopt::Std; ...@@ -15,7 +15,7 @@ use Getopt::Std;
sub usage() sub usage()
{ {
print STDOUT print STDOUT
"Usage: vistoplogy [-o <outputfile>] [-z <zoomfactor>] [-d <detaillevel>] <pid> <eid>\n"; "Usage: dbvistoplogy [-o <outputfile>] [-z <zoomfactor>] [-d <detaillevel>] <pid> <eid>\n";
exit(-1); exit(-1);
} }
my $optlist = "o:z:d:"; my $optlist = "o:z:d:";
......
...@@ -261,8 +261,18 @@ $im->fill( 1, 1, $bgcolor ); ...@@ -261,8 +261,18 @@ $im->fill( 1, 1, $bgcolor );
foreach $i (keys %nodes) { foreach $i (keys %nodes) {
($x, $y) = ($nodepos{ $i }[0], $nodepos{ $i }[1]); ($x, $y) = ($nodepos{ $i }[0], $nodepos{ $i }[1]);
$im->filledRectangle( $x - 12, $y - 12, $cname = $nodes{$i}{"color"};
$x + 20, $y + 20, $colors{"gray80"}); 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 # render links
...@@ -323,13 +333,23 @@ foreach $i (keys %nodes) { ...@@ -323,13 +333,23 @@ foreach $i (keys %nodes) {
if ($cname eq "red") { if ($cname eq "red") {
$im->rectangle( $x - 16, $y - 16, $x + 16, $y + 16, $colors{"darkred"} ); $im->rectangle( $x - 16, $y - 16, $x + 16, $y + 16, $colors{"darkred"} );
$im->rectangle( $x - 15, $y - 15, $x + 15, $y + 15, $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 { } else {
$im->rectangle( $x - 16, $y - 16, $x + 16, $y + 16, $colors{"gray25"} ); $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->rectangle( $x - 15, $y - 15, $x + 15, $y + 15, $colors{"gray25"} );
} }
$im->filledRectangle( $x - 14, $y - 14, if ($cname eq "green") {
$x + 14, $y + 14, $colors{"white"} ); 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" || if ($nodeicon && ($cname eq "skyblue" ||
$cname eq "steelblue" || $cname eq "steelblue" ||
...@@ -339,8 +359,8 @@ foreach $i (keys %nodes) { ...@@ -339,8 +359,8 @@ foreach $i (keys %nodes) {
} elsif ($lanicon && $cname eq "green") { } elsif ($lanicon && $cname eq "green") {
$im->copy($lanicon, $x-16, $y-16, 0, 0, 32, 32); $im->copy($lanicon, $x-16, $y-16, 0, 0, 32, 32);
} else { } else {
$im->filledRectangle( $x - 6, $y - 6, $im->filledRectangle( $x - 6, $y - 6,
$x + 6, $y + 6, $c ); $x + 6, $y + 6, $c );
} }
} }
...@@ -356,7 +376,9 @@ foreach $i (@links) { ...@@ -356,7 +376,9 @@ foreach $i (@links) {
($x, $y) = ( ($x1 + $x2) / 2, ($y1 + $y2) / 2 ); ($x, $y) = ( ($x1 + $x2) / 2, ($y1 + $y2) / 2 );
$linklabels{ $i } =~ s/^\!..//; $linklabels{ $i } =~ s/^\!..//;
# axe prefix added to avoid reserved-word collide:
$linklabels{ $i } =~ s/_x1823Y_//;
my @lines = split " ", $linklabels{ $i }; my @lines = split " ", $linklabels{ $i };
$y -= (0.5 * (@lines * gdTinyFont->height)); $y -= (0.5 * (@lines * gdTinyFont->height));
...@@ -391,7 +413,7 @@ foreach $i (keys %nodes) { ...@@ -391,7 +413,7 @@ foreach $i (keys %nodes) {
$nm .= " "; $nm .= " ";
$nm =~ s/^(\S+)//; $nm =~ s/^(\S+)//;
$nm =~ s/_x1823Y_//;
push @lines, $1; push @lines, $1;
while ( $nm =~ s/^(.{1,12})\s// ) { while ( $nm =~ s/^(.{1,12})\s// ) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment