]> git.proxmox.com Git - mirror_ovs.git/blame - ovsdb/dot2pic
Add read-only option to ovs-dpctl and ovs-ofctl commands.
[mirror_ovs.git] / ovsdb / dot2pic
CommitLineData
fca64c12
BP
1#! /usr/bin/perl
2
86c65682 3# Copyright (c) 2009, 2010, 2011, 2013 Nicira, Inc.
fca64c12
BP
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
17use strict;
18use warnings;
19
86c65682
BP
20use Getopt::Long;
21
22my $font_scale = 0;
23GetOptions("f=i" => \$font_scale) || exit 1;
24
fca64c12 25my ($scale) = 1;
86c65682 26printf ".ps %+d\n", -$font_scale if $font_scale;
fca64c12
BP
27print ".PS\n";
28print "linethick = 1;\n";
29while (<>) {
73ffb8e8
BP
30 if (/^graph/) {
31 (undef, $scale) = split;
32 } elsif (/^node/) {
33 my (undef, $name, $x, $y, $width, $height, $label, $style, $shape, $color, $fillcolor) = split;
fca64c12
BP
34 $x *= $scale;
35 $y *= $scale;
36 $width *= $scale;
37 $height *= $scale;
c5f341ab 38 print "linethick = ", ($style eq 'bold' ? 0.5 : 1.0), ";\n";
fca64c12 39 print "box at $x,$y wid $width height $height \"$name\"\n";
c5f341ab
BP
40 if ($style eq 'bold') {
41 my $inset = 2.0 / 72.0;
42 $width -= $inset * 2;
43 $height -= $inset * 2;
44 print "box at $x,$y wid $width height $height\n";
45 }
fca64c12
BP
46 } elsif (/edge/) {
47 my (undef, $tail, $head, $n, $rest) = split(' ', $_, 5);
48 my @xy;
49 for (1...$n) {
50 my ($x, $y);
51 ($x, $y, $rest) = split(' ', $rest, 3);
52 push(@xy, [$x * $scale, $y * $scale]);
53 }
54 my ($label, $xl, $yl);
55 if (scalar(my @junk = split(' ', $rest)) > 2) {
56 if ($rest =~ s/^"([^"]*)"\s+//) {
57 $label = $1;
58 } else {
59 ($label, $rest) = split(' ', $rest, 2);
60 }
61 ($xl, $yl, $rest) = split(' ', $rest, 3);
62 $xl *= $scale;
63 $yl *= $scale;
64 }
65 my ($style, $color) = split(' ', $rest);
66
c5f341ab
BP
67 print "linethick = ", ($style eq 'dotted' ? 0.5 : 1), ";\n";
68
fca64c12
BP
69 print "spline -> from $xy[0][0],$xy[0][1]";
70 for (my ($i) = 0; $i <= $#xy; $i++) {
71 print " to $xy[$i][0],$xy[$i][1]";
72 }
73 print "\n";
74
75 print "\"$label\" at $xl,$yl\n" if defined($label);
76 }
77
78}
86c65682 79printf ".ps %+d\n", $font_scale if $font_scale;
fca64c12 80print ".PE\n";