summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DEMO25
-rw-r--r--Makefile91
-rw-r--r--TODO24
-rw-r--r--cro.c461
-rw-r--r--cro.h31
-rw-r--r--diff.c279
-rw-r--r--diff.h22
-rw-r--r--dwg.c463
-rw-r--r--dwg.h46
-rw-r--r--fig.c293
-rw-r--r--fig.h22
-rw-r--r--file.c76
-rw-r--r--file.h22
-rw-r--r--gfx.c120
-rw-r--r--gfx.h72
-rw-r--r--git-file.c371
-rw-r--r--git-file.h22
-rw-r--r--lib-parse.c268
-rw-r--r--lib-render.c396
-rw-r--r--lib.h124
-rw-r--r--main.c172
-rw-r--r--main.h31
-rw-r--r--misc.c114
-rw-r--r--misc.h51
-rw-r--r--neo900-template.fig15
-rw-r--r--record.c342
-rw-r--r--record.h58
-rw-r--r--sch-parse.c562
-rw-r--r--sch-render.c174
-rw-r--r--sch.h123
-rwxr-xr-xsch2pdf92
-rw-r--r--style.c31
-rw-r--r--style.h91
-rw-r--r--test.lib62
-rw-r--r--test.pro34
-rw-r--r--test.sch372
-rw-r--r--test/README24
-rwxr-xr-xtest/comp29
-rwxr-xr-xtest/genpng37
-rw-r--r--text.c158
-rw-r--r--text.h58
-rw-r--r--util.h52
42 files changed, 5910 insertions, 0 deletions
diff --git a/DEMO b/DEMO
new file mode 100644
index 0000000..dc307db
--- /dev/null
+++ b/DEMO
@@ -0,0 +1,25 @@
+# Prerequisites (depends on distribution)
+
+apt-get install libcairo2-dev
+apt-get install libgit2-dev
+apt-get install qiv
+
+# Get all the things we need
+
+git clone http://neo900.org/git/ee.git newdir
+cd newdir/hw
+git clone git://projects.qi-hardware.com/kicad-libs.git
+git clone git://projects.qi-hardware.com/eda-tools.git
+make -C eda-tools/eeshow
+
+# Generate PNG for old, new, and difference
+
+LIBS="neo900.lib kicad-libs/components/powered.lib"
+eda-tools/eeshow/eeshow $LIBS 6a9f71:neo900_SS_5.sch -- png -s 2 -o old.png
+eda-tools/eeshow/eeshow $LIBS neo900_SS_5.sch -- png -s 2 -o new.png
+eda-tools/eeshow/eeshow $LIBS 6a9f71:neo900_SS_5.sch -- \
+ diff -s 2 -o diff.png $LIBS neo900_SS_5.sch
+
+# View the result
+
+qiv -t diff.png old.png new.png
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1fa2b28
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,91 @@
+#
+# Makefile - build eeshow
+#
+# Written 2016 by Werner Almesberger
+# Copyright 2016 by Werner Almesberger
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+
+NAME = eeshow
+OBJS = main.o sch-parse.o sch-render.o lib-parse.o lib-render.o \
+ file.o git-file.o \
+ style.o fig.o record.o cro.o diff.o gfx.o dwg.o text.o misc.o
+
+CFLAGS = -g -Wall -Wextra -Wno-unused-parameter -Wshadow \
+ -Wmissing-prototypes -Wmissing-declarations \
+ `pkg-config --cflags cairo` \
+ `pkg-config --cflags libgit2`
+LDLIBS = -lm \
+ `pkg-config --libs cairo` \
+ `pkg-config --libs libgit2`
+
+include ../common/Makefile.c-common
+
+.PHONY: test neo900 sch test testref png pngref diff view newref
+
+all:: $(NAME)
+
+$(NAME): $(OBJS)
+ $(CC) -o $(NAME) $(OBJS) $(LDLIBS)
+
+#----- Test sheet -------------------------------------------------------------
+
+sch:
+ eeschema test.sch
+
+test: $(NAME)
+ ./$(NAME) test.lib test.sch >out.fig
+ fig2dev -L png -m 2 out.fig _out.png
+ [ ! -r ref.png ] || \
+ compare -metric AE ref.png _out.png _diff.png || \
+ qiv -t -R -D _diff.png ref.png _out.png
+
+testref: $(NAME)
+ ./$(NAME) test.lib test.sch | fig2dev -L png -m 2 >ref.png
+
+png: $(NAME)
+ ./$(NAME) test.lib test.sch -- png -o _out.png -s 2
+ [ ! -r pngref.png ] || \
+ compare -metric AE pngref.png _out.png _diff.png || \
+ qiv -t -R -D _diff.png pngref.png _out.png
+
+pngref: $(NAME)
+ ./$(NAME) test.lib test.sch -- png -o pngref.png -s 2
+
+clean::
+ rm -f out.fig _out.png _diff.png
+
+#----- Render Neo900 schematics -----------------------------------------------
+
+NEO900_HW = ../../../n9/ee/hw
+KICAD_LIBS = ../../kicad-libs/components
+
+SHEET ?= 12
+
+neo900: $(NAME)
+ ./$(NAME) $(NEO900_HW)/neo900.lib \
+ $(KICAD_LIBS)/powered.lib \
+ $(NEO900_HW)/neo900_SS_$(SHEET).sch \
+ >out.fig
+
+neo900.pdf: $(NAME) sch2pdf neo900-template.fig
+ ./sch2pdf -o $@ -t neo900-template.fig \
+ $(NEO900_HW)/neo900.lib $(KICAD_LIBS)/powered.lib \
+ $(NEO900_HW)/neo900.sch
+
+#----- Regression test based on Neo900 schematics -----------------------------
+
+diff: $(NAME)
+ test/genpng test out
+ test/comp test || $(MAKE) view
+
+view:
+ qiv -t -R -D `echo test/_diff*.png | \
+ sed 's/\([^ ]*\)_diff\([^ ]*\)/\1_diff\2 \1ref\2 \1out\2/g'`
+
+newref:
+ test/genpng test ref
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..a2e2899
--- /dev/null
+++ b/TODO
@@ -0,0 +1,24 @@
+- better text size guessing also for FIG
+- unify alignment, direction
+- support fonts attributes ?
+- support line thickness ?
+- ~ as overline (grep for ~ in out.fig)
+- glabel: build for "right" style, then rotate poly (like hlabel)
+- show open pins / wires
+- check remaining alignment / direction / rotation cases in switch statements
+- support mirroring (and detect-complain if unexpected) [should be done now]
+- pin shapes (inverted, clock, etc.)
+- optionally display pin type
+- find libraries (e.g., from .pro)
+- PDF TOC
+- let user set PNG size or zoom level
+- parse .kicad_wks
+- on parse error, politely complain, don't terminate;
+ convert abort / assert(0) to proper error indications
+- implement destructors
+- check for memory leaks
+- record.c (bb_rot): implement bounding boxes for text
+- nesting gfx in diff is a huge kludge, caused by global vars in gfx.c
+- move path name guessing into file.c
+- return indication of whether diff found any differences
+- in diff, pass only options understood by cairo_png
diff --git a/cro.c b/cro.c
new file mode 100644
index 0000000..8ede2b9
--- /dev/null
+++ b/cro.c
@@ -0,0 +1,461 @@
+/*
+ * cro.c - Cairo graphics back-end
+ *
+ * Written 2016 by Werner Almesberger
+ * Copyright 2016 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as publish