]> git.proxmox.com Git - ovs.git/blob - ovsdb/dot2pic
Global replace of Nicira Networks.
[ovs.git] / ovsdb / dot2pic
1 #! /usr/bin/perl
2
3 # Copyright (c) 2009, 2010, 2011 Nicira, Inc.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at:
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 use strict;
18 use warnings;
19
20 my ($scale) = 1;
21 print ".PS\n";
22 print "linethick = 1;\n";
23 while (<>) {
24 if (/^graph/) {
25 (undef, $scale) = split;
26 } elsif (/^node/) {
27 my (undef, $name, $x, $y, $width, $height, $label, $style, $shape, $color, $fillcolor) = split;
28 $x *= $scale;
29 $y *= $scale;
30 $width *= $scale;
31 $height *= $scale;
32 print "linethick = ", ($style eq 'bold' ? 0.5 : 1.0), ";\n";
33 print "box at $x,$y wid $width height $height \"$name\"\n";
34 if ($style eq 'bold') {
35 my $inset = 2.0 / 72.0;
36 $width -= $inset * 2;
37 $height -= $inset * 2;
38 print "box at $x,$y wid $width height $height\n";
39 }
40 } elsif (/edge/) {
41 my (undef, $tail, $head, $n, $rest) = split(' ', $_, 5);
42 my @xy;
43 for (1...$n) {
44 my ($x, $y);
45 ($x, $y, $rest) = split(' ', $rest, 3);
46 push(@xy, [$x * $scale, $y * $scale]);
47 }
48 my ($label, $xl, $yl);
49 if (scalar(my @junk = split(' ', $rest)) > 2) {
50 if ($rest =~ s/^"([^"]*)"\s+//) {
51 $label = $1;
52 } else {
53 ($label, $rest) = split(' ', $rest, 2);
54 }
55 ($xl, $yl, $rest) = split(' ', $rest, 3);
56 $xl *= $scale;
57 $yl *= $scale;
58 }
59 my ($style, $color) = split(' ', $rest);
60
61 print "linethick = ", ($style eq 'dotted' ? 0.5 : 1), ";\n";
62
63 print "spline -> from $xy[0][0],$xy[0][1]";
64 for (my ($i) = 0; $i <= $#xy; $i++) {
65 print " to $xy[$i][0],$xy[$i][1]";
66 }
67 print "\n";
68
69 print "\"$label\" at $xl,$yl\n" if defined($label);
70 }
71
72 }
73 print ".PE\n";