30 #include <glib/gstdio.h>
33 write_line(FILE *fd,
gerbv_net_t *net,
double thick,
34 double dx_p,
double dy_m,
const char *sflags)
36 dx_p = COORD2MILS(dx_p);
37 dy_m = COORD2MILS(dy_m);
39 fprintf(fd,
"\tLine[%.2fmil %.2fmil %.2fmil %.2fmil "
40 "%.2fmil %.2fmil \"%s\"]\n",
41 dx_p + COORD2MILS(net->
stop_x),
42 dy_m - COORD2MILS(net->
stop_y),
43 dx_p + COORD2MILS(net->
start_x),
44 dy_m - COORD2MILS(net->
start_y),
45 COORD2MILS(thick), 100.0, sflags);
49 write_element_with_pad(FILE *fd,
gerbv_net_t *net,
double thick,
50 double dx_p,
double dy_m,
const char *sflags)
53 static unsigned int element_num = 1;
55 dx_p = COORD2MILS(dx_p);
56 dy_m = COORD2MILS(dy_m);
61 fprintf(fd,
"Element[\"\" \"\" \"pad%d\" \"\" "
62 "%.2fmil %.2fmil 0mil 0mil 0 100 \"\"]\n(\n",
63 element_num++, dx_p + xc, dy_m - yc);
64 fprintf(fd,
"\tPad[%.2fmil %.2fmil %.2fmil %.2fmil "
65 "%.2fmil 0mil %.2fmil "
66 "\"%s\" \"%s\" \"%s\"]\n)\n",
67 xc - COORD2MILS(net->
stop_x),
68 yc - COORD2MILS(net->
stop_y),
80 double dx_p,
double dy_m,
const char *sflags)
82 dx_p = COORD2MILS(dx_p);
83 dy_m = COORD2MILS(dy_m);
85 fprintf(fd,
"\tPolygon(\"%s\")\n\t(", sflags);
92 fprintf(fd,
"%s[%.2fmil %.2fmil] ",
94 dx_p + COORD2MILS(net->
stop_x),
95 dy_m - COORD2MILS(net->
stop_y));
101 fprintf(fd,
"\n\t)\n");
109 gerbv_aperture_t *apert;
116 if ((fd = g_fopen(file_name,
"w")) == NULL) {
117 GERB_MESSAGE(_(
"Can't open file for writing: %s"), file_name);
122 setlocale(LC_NUMERIC,
"C");
128 fputs(
"# Generated with gerbv\n\n", fd);
129 fputs(
"FileVersion[20091103]\n", fd);
131 dx_p = (img->
info->max_x - img->
info->min_x) - img->
info->min_x;
132 dy_m = 2*(img->
info->max_y - img->
info->min_y) + img->
info->min_y;
135 fprintf(fd,
"PCB[\"%s\" %.2fmil %.2fmil]\n",
137 3*COORD2MILS(img->
info->max_x - img->
info->min_x),
138 3*COORD2MILS(img->
info->max_y - img->
info->min_y));
140 fputs(
"Grid[1000.000000 0.0000 0.0000 0]\n", fd);
144 for (net = img->
netlist; net != NULL; net = net->
next) {
161 switch (apert->type) {
166 write_element_with_pad(fd, net,
173 if (apert->parameter[0] > apert->parameter[1]) {
175 len = apert->parameter[0];
176 thick = apert->parameter[1];
180 net->
stop_x += len/2 - thick/2;
184 len = apert->parameter[1];
185 thick = apert->parameter[0];
190 net->
stop_y += len/2 - thick/2;
193 write_element_with_pad(fd, net, thick,
200 GERB_COMPILE_WARNING(
201 "%s:%d: aperture type %d is "
213 GERB_COMPILE_WARNING(
214 "%s:%d: aperture type %d is "
223 fputs(
"Layer(1 \"top\")\n(\n", fd);
225 for (net = img->
netlist; net != NULL; net = net->
next) {
231 write_polygon(fd, net, dx_p, dy_m,
"clearpoly");
248 switch (apert->type) {
250 write_line(fd, net, apert->parameter[0],
251 dx_p, dy_m,
"clearline");
254 GERB_COMPILE_WARNING(
255 "%s:%d: aperture type %d is "
263 GERB_COMPILE_WARNING(
264 "%s:%d: aperture state %d type %d is "
275 fputs(
"Layer(7 \"outline\")\n(\n)\n", fd);
280 setlocale(LC_NUMERIC,
"");
gboolean gerbv_export_geda_pcb_file_from_image(const gchar *file_name, gerbv_image_t *input_img, gerbv_user_transformation_t *trans)
Export an image to a new file in gEDA PCB format.
void gerbv_destroy_image(gerbv_image_t *image)
Free an image structure.
gerbv_image_t * gerbv_image_duplicate_image(gerbv_image_t *sourceImage, gerbv_user_transformation_t *transform)
Duplicate an existing image and return the new copy.
The main header file for the libgerbv library.
@ GERBV_APERTURE_STATE_ON
@ GERBV_APERTURE_STATE_FLASH
@ GERBV_INTERPOLATION_PAREA_START
@ GERBV_INTERPOLATION_PAREA_END
gerbv_aperture_t * aperture[APERTURE_MAX]
gerbv_image_info_t * info
gerbv_aperture_state_t aperture_state
gerbv_interpolation_t interpolation