2 * collectd - src/sn-tex.c
3 * Copyright (C) 2008 Florian octo Forster
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Florian octo Forster <octo at verplant.org>
26 #define INNER_SPACING 0.35
27 #define OUTER_SPACING 1.5
29 #include "sn_network.h"
31 static double x_offset = OUTER_SPACING;
32 static int next_vertex_number = 0;
34 static int tex_show_stage (sn_stage_t *s)
36 int lines[s->comparators_num];
37 int right[s->comparators_num];
41 for (i = 0; i < s->comparators_num; i++)
47 for (i = 0; i < s->comparators_num; i++)
50 sn_comparator_t *c = s->comparators + i;
55 min_num = next_vertex_number;
58 max_num = next_vertex_number;
61 for (j = 0; j < lines_used; j++)
62 if (SN_COMP_LEFT (c) > right[j])
66 right[j] = SN_COMP_RIGHT (c);
70 printf ("\\node[vertex] (v%i) at (%.2f,%i) {};\n"
71 "\\node[vertex] (v%i) at (%.2f,%i) {};\n"
72 "\\path[comp] (v%i) -- (v%i);\n"
74 min_num, x_offset + (j * INNER_SPACING), c->min,
75 max_num, x_offset + (j * INNER_SPACING), c->max,
79 x_offset = x_offset + ((lines_used - 1) * INNER_SPACING) + OUTER_SPACING;
82 } /* int tex_show_stage */
84 int main (int argc, char **argv)
93 fh = fopen (argv[1], "r");
97 printf ("fh == NULL!\n");
101 n = sn_network_read (fh);
105 printf ("n == NULL!\n");
109 printf ("\\begin{tikzpicture}[scale=%.2f,auto]\n", SCALE);
111 for (i = 0; i < SN_NETWORK_STAGE_NUM (n); i++)
112 tex_show_stage (SN_NETWORK_STAGE_GET (n, i));
114 for (i = 0; i < SN_NETWORK_INPUT_NUM (n); i++)
115 printf ("\\path[edge] (0,%i) -- (%.2f,%i);\n",
118 printf ("\\end{tikzpicture}\n");
123 /* vim: set shiftwidth=2 softtabstop=2 : */