30 #include <glib/gstdio.h>
33 write_line(FILE* fd,
gerbv_net_t* net,
double thick,
double dx_p,
double dy_m,
const char* sflags) {
34 dx_p = COORD2MILS(dx_p);
35 dy_m = COORD2MILS(dy_m);
39 "\tLine[%.2fmil %.2fmil %.2fmil %.2fmil "
40 "%.2fmil %.2fmil \"%s\"]\n",
41 dx_p + COORD2MILS(net->
stop_x), dy_m - COORD2MILS(net->
stop_y), dx_p + COORD2MILS(net->
start_x),
42 dy_m - COORD2MILS(net->
start_y), COORD2MILS(thick), 100.0, sflags
47 write_element_with_pad(FILE* fd,
gerbv_net_t* net,
double thick,
double dx_p,
double dy_m,
const char* sflags) {
49 static unsigned int element_num = 1;
51 dx_p = COORD2MILS(dx_p);
52 dy_m = COORD2MILS(dy_m);
59 "Element[\"\" \"\" \"pad%d\" \"\" "
60 "%.2fmil %.2fmil 0mil 0mil 0 100 \"\"]\n(\n",
61 element_num++, dx_p + xc, dy_m - yc
65 "\tPad[%.2fmil %.2fmil %.2fmil %.2fmil "
66 "%.2fmil 0mil %.2fmil "
67 "\"%s\" \"%s\" \"%s\"]\n)\n",
69 yc - COORD2MILS(net->
start_y), COORD2MILS(thick),
78 write_polygon(FILE* fd,
gerbv_net_t* net,
double dx_p,
double dy_m,
const char* sflags) {
79 dx_p = COORD2MILS(dx_p);
80 dy_m = COORD2MILS(dy_m);
82 fprintf(fd,
"\tPolygon(\"%s\")\n\t(", sflags);
89 fd,
"%s[%.2fmil %.2fmil] ", !(i % 5) ?
"\n\t\t" :
"", dx_p + COORD2MILS(net->
stop_x),
90 dy_m - COORD2MILS(net->
stop_y)
97 fprintf(fd,
"\n\t)\n");
104 gerbv_aperture_t* apert;
111 if ((fd = g_fopen(file_name,
"w")) == NULL) {
112 GERB_MESSAGE(_(
"Can't open file for writing: %s"), file_name);
117 setlocale(LC_NUMERIC,
"C");
123 fputs(
"# Generated with gerbv\n\n", fd);
124 fputs(
"FileVersion[20091103]\n", fd);
126 dx_p = (img->
info->max_x - img->
info->min_x) - img->
info->min_x;
127 dy_m = 2 * (img->
info->max_y - img->
info->min_y) + img->
info->min_y;
131 fd,
"PCB[\"%s\" %.2fmil %.2fmil]\n", img->
info->name, 3 * COORD2MILS(img->
info->max_x - img->
info->min_x),
132 3 * COORD2MILS(img->
info->max_y - img->
info->min_y)
135 fputs(
"Grid[1000.000000 0.0000 0.0000 0]\n", fd);
139 for (net = img->
netlist; net != NULL; net = net->
next) {
155 switch (apert->type) {
160 write_element_with_pad(fd, net, apert->parameter[0], dx_p, dy_m,
"");
165 if (apert->parameter[0] > apert->parameter[1]) {
167 len = apert->parameter[0];
168 thick = apert->parameter[1];
171 net->
stop_x += len / 2 - thick / 2;
175 len = apert->parameter[1];
176 thick = apert->parameter[0];
180 net->
stop_y += len / 2 - thick / 2;
183 write_element_with_pad(
189 GERB_COMPILE_WARNING(
190 "%s:%d: aperture type %d is "
192 __func__, __LINE__, apert->type
202 GERB_COMPILE_WARNING(
203 "%s:%d: aperture type %d is "
205 __func__, __LINE__, apert->type
212 fputs(
"Layer(1 \"top\")\n(\n", fd);
214 for (net = img->
netlist; net != NULL; net = net->
next) {
220 write_polygon(fd, net, dx_p, dy_m,
"clearpoly");
236 switch (apert->type) {
237 case GERBV_APTYPE_CIRCLE: write_line(fd, net, apert->parameter[0], dx_p, dy_m,
"clearline");
break;
239 GERB_COMPILE_WARNING(
240 "%s:%d: aperture type %d is "
242 __func__, __LINE__, apert->type
248 GERB_COMPILE_WARNING(
249 "%s:%d: aperture state %d type %d is "
260 fputs(
"Layer(7 \"outline\")\n(\n)\n", fd);
265 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