[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: pcb.git: branch: master updated (0adead1b4f810e066d547e7f603060348e45eef1)
The branch, master has been updated
via 0adead1b4f810e066d547e7f603060348e45eef1 (commit)
from c2f52c71e6b199ae2196924b0d1cfd4fa8f23446 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
=========
Summary
=========
src/hid/common/flags.c | 32 +++++++++++--
src/hid/gcode/gcode.c | 6 +-
src/hid/gerber/gerber.c | 118 +++++++++++++++++++++++++++++++++++++++++-----
src/hid/hidint.h | 12 ++++-
src/hid/nelma/nelma.c | 10 ++--
src/hid/ps/ps.c | 8 ++--
6 files changed, 155 insertions(+), 31 deletions(-)
=================
Commit Messages
=================
commit 0adead1b4f810e066d547e7f603060348e45eef1
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>
Add option to specify gerber output file style.
--name-style <fixed|single|first|eagle>
Naming style for individual gerber files
Default is "fixed" which uses a fixed name (foo.top.gbr) for each layer.
"single" uses the layer's name if there's exactly one layer in that
group, else the fixed name. "first" always uses the layer name,
choosing the first layer in each group for the name. "eagle" mode adds
a three-character suffix instead of a separate type and extension.
Affects-bug: lp-700877
:100644 100644 15e77ad... 669b2ab... M src/hid/common/flags.c
:100644 100644 2f26c8e... 8c545ea... M src/hid/gcode/gcode.c
:100644 100644 7737444... 1e5b7f5... M src/hid/gerber/gerber.c
:100644 100644 8302745... b986f78... M src/hid/hidint.h
:100644 100644 8c78a53... 4f5f748... M src/hid/nelma/nelma.c
:100644 100644 7f2c3d7... c1a62ab... M src/hid/ps/ps.c
=========
Changes
=========
commit 0adead1b4f810e066d547e7f603060348e45eef1
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>
Add option to specify gerber output file style.
--name-style <fixed|single|first|eagle>
Naming style for individual gerber files
Default is "fixed" which uses a fixed name (foo.top.gbr) for each layer.
"single" uses the layer's name if there's exactly one layer in that
group, else the fixed name. "first" always uses the layer name,
choosing the first layer in each group for the name. "eagle" mode adds
a three-character suffix instead of a separate type and extension.
Affects-bug: lp-700877
diff --git a/src/hid/common/flags.c b/src/hid/common/flags.c
index 15e77ad..669b2ab 100644
--- a/src/hid/common/flags.c
+++ b/src/hid/common/flags.c
@@ -148,9 +148,11 @@ hid_restore_layer_ons (int *save_array)
}
const char *
-layer_type_to_file_name (int idx)
+layer_type_to_file_name (int idx, int style)
{
int group;
+ int nlayers;
+ const char *single_name;
switch (idx)
{
@@ -180,17 +182,37 @@ layer_type_to_file_name (int idx)
return "bottomassembly";
default:
group = GetLayerGroupNumberByNumber(idx);
+ nlayers = PCB->LayerGroups.Number[group];
+ single_name = PCB->Data->Layer[idx].Name;
if (group == GetLayerGroupNumberByNumber(component_silk_layer))
- return "top";
+ {
+ if (style == FNS_first
+ || (style == FNS_single
+ && nlayers == 2))
+ return single_name;
+ return "top";
+ }
else if (group == GetLayerGroupNumberByNumber(solder_silk_layer))
- return "bottom";
- else if (PCB->LayerGroups.Number[group] == 1
+ {
+ if (style == FNS_first
+ || (style == FNS_single
+ && nlayers == 2))
+ return single_name;
+ return "bottom";
+ }
+ else if (nlayers == 1
&& (strcmp (PCB->Data->Layer[idx].Name, "route") == 0 ||
strcmp (PCB->Data->Layer[idx].Name, "outline") == 0))
- return "outline";
+ {
+ return "outline";
+ }
else
{
static char buf[20];
+ if (style == FNS_first
+ || (style == FNS_single
+ && nlayers == 1))
+ return single_name;
sprintf (buf, "group%d", group);
return buf;
}
diff --git a/src/hid/gcode/gcode.c b/src/hid/gcode/gcode.c
index 2f26c8e..8c545ea 100644
--- a/src/hid/gcode/gcode.c
+++ b/src/hid/gcode/gcode.c
@@ -462,12 +462,12 @@ gcode_do_export (HID_Attr_Val * options)
/* magic */
idx = (i >= 0 && i < max_group) ?
PCB->LayerGroups.Entries[i][0] : i;
- printf ("idx=%d %s\n", idx, layer_type_to_file_name (idx));
+ printf ("idx=%d %s\n", idx, layer_type_to_file_name (idx, FNS_fixed));
is_solder =
(GetLayerGroupNumberByNumber (idx) ==
GetLayerGroupNumberByNumber (solder_silk_layer)) ? 1 : 0;
save_drill = is_solder; /* save drills for one layer only */
- gcode_start_png (gcode_basename, layer_type_to_file_name (idx));
+ gcode_start_png (gcode_basename, layer_type_to_file_name (idx, FNS_fixed));
hid_save_and_show_layer_ons (save_ons);
gcode_start_png_export ();
hid_restore_layer_ons (save_ons);
@@ -496,7 +496,7 @@ gcode_do_export (HID_Attr_Val * options)
gdImageDestroy (temp_im);
}
sprintf (filename, "%s.%s.cnc", gcode_basename,
- layer_type_to_file_name (idx));
+ layer_type_to_file_name (idx, FNS_fixed));
for (r = 0; r < gdImageSX (gcode_im); r++)
{
for (c = 0; c < gdImageSY (gcode_im); c++)
diff --git a/src/hid/gerber/gerber.c b/src/hid/gerber/gerber.c
index 7737444..1e5b7f5 100644
--- a/src/hid/gerber/gerber.c
+++ b/src/hid/gerber/gerber.c
@@ -92,6 +92,7 @@ static int is_drill;
static int current_mask;
static int flash_drills;
static int copy_outline_mode;
+static int name_style;
static LayerTypePtr outline_layer;
enum ApertureShape
@@ -315,6 +316,18 @@ static const char *copy_outline_names[] = {
0
};
+static const char *name_style_names[] = {
+#define NAME_STYLE_FIXED 0
+ "fixed",
+#define NAME_STYLE_SINGLE 1
+ "single",
+#define NAME_STYLE_FIRST 2
+ "first",
+#define NAME_STYLE_EAGLE 3
+ "eagle",
+ 0
+};
+
static HID_Attribute gerber_options[] = {
{"gerberfile", "Gerber output file base",
HID_String, 0, 0, {0, 0, 0}, 0, 0},
@@ -328,6 +341,9 @@ static HID_Attribute gerber_options[] = {
{"copy-outline", "Copy outline onto other layers",
HID_Enum, 0, 0, {0, 0, 0}, copy_outline_names, 0},
#define HA_copy_outline 3
+ {"name-style", "Naming style for individual gerber files",
+ HID_Enum, 0, 0, {0, 0, 0}, name_style_names, 0},
+#define HA_name_style 4
};
#define NUM_OPTIONS (sizeof(gerber_options)/sizeof(gerber_options[0]))
@@ -381,6 +397,90 @@ maybe_close_f ()
static BoxType region;
+/* Very similar to layer_type_to_file_name() but appends only a
+ three-character suffix compatible with Eagle's defaults. */
+static void
+assign_eagle_file_suffix (int idx)
+{
+ int group;
+ int nlayers;
+ char *suff = "out";
+
+ switch (idx)
+ {
+ case SL (SILK, TOP): suff = "plc"; break;
+ case SL (SILK, BOTTOM): suff = "pls"; break;
+ case SL (MASK, TOP): suff = "stc"; break;
+ case SL (MASK, BOTTOM): suff = "sts"; break;
+ case SL (PDRILL, 0): suff = "drd"; break;
+ case SL (UDRILL, 0): suff = "dru"; break;
+ case SL (PASTE, TOP): suff = "crc"; break;
+ case SL (PASTE, BOTTOM): suff = "crs"; break;
+ case SL (INVISIBLE, 0): suff = "inv"; break;
+ case SL (FAB, 0): suff = "fab"; break;
+ case SL (ASSY, TOP): suff = "ast"; break;
+ case SL (ASSY, BOTTOM): suff = "asb"; break;
+
+ default:
+ group = GetLayerGroupNumberByNumber(idx);
+ nlayers = PCB->LayerGroups.Number[group];
+ if (group == GetLayerGroupNumberByNumber(component_silk_layer))
+ {
+ suff = "cmp";
+ }
+ else if (group == GetLayerGroupNumberByNumber(solder_silk_layer))
+ {
+ suff = "sol";
+ }
+ else if (nlayers == 1
+ && (strcmp (PCB->Data->Layer[idx].Name, "route") == 0 ||
+ strcmp (PCB->Data->Layer[idx].Name, "outline") == 0))
+ {
+ suff = "oln";
+ }
+ else
+ {
+ static char buf[20];
+ sprintf (buf, "ly%d", group);
+ suff = buf;
+ }
+ break;
+ }
+
+ strcpy (filesuff, suff);
+}
+
+static void
+assign_file_suffix (int idx)
+{
+ int fns_style;
+ const char *sext = ".gbr";
+
+ switch (name_style)
+ {
+ default:
+ case NAME_STYLE_FIXED: fns_style = FNS_fixed; break;
+ case NAME_STYLE_SINGLE: fns_style = FNS_single; break;
+ case NAME_STYLE_FIRST: fns_style = FNS_first; break;
+ case NAME_STYLE_EAGLE:
+ assign_eagle_file_suffix (idx);
+ return;
+ }
+
+ switch (idx)
+ {
+ case SL (PDRILL, 0):
+ sext = ".cnc";
+ break;
+ case SL (UDRILL, 0):
+ sext = ".cnc";
+ break;
+ }
+
+ strcpy (filesuff, layer_type_to_file_name (idx, fns_style));
+ strcat (filesuff, sext);
+}
+
static void
gerber_do_export (HID_Attr_Val * options)
{
@@ -410,6 +510,7 @@ gerber_do_export (HID_Attr_Val * options)
all_layers = options[HA_all_layers].int_value;
copy_outline_mode = options[HA_copy_outline].int_value;
+ name_style = options[HA_name_style].int_value;
outline_layer = NULL;
@@ -568,7 +669,6 @@ gerber_set_layer (const char *name, int group, int empty)
#ifdef HAVE_GETPWUID
struct passwd *pwentry;
#endif
- char *sext=".gbr";
int i;
int some_apertures = 0;
@@ -591,17 +691,7 @@ gerber_set_layer (const char *name, int group, int empty)
maybe_close_f ();
pagecount++;
- switch (idx)
- {
- case SL (PDRILL, 0):
- sext = ".cnc";
- break;
- case SL (UDRILL, 0):
- sext = ".cnc";
- break;
- }
- strcpy (filesuff, layer_type_to_file_name (idx));
- strcat (filesuff, sext);
+ assign_file_suffix (idx);
f = fopen (filename, "w");
if (f == NULL)
{
@@ -670,7 +760,9 @@ gerber_set_layer (const char *name, int group, int empty)
if (layername)
free (layername);
layername = strdup (filesuff);
- layername[strlen(layername) - strlen(sext)] = 0;
+ if (strrchr (layername, '.'))
+ * strrchr (layername, '.') = 0;
+
for (cp=layername; *cp; cp++)
{
if (isalnum((int) *cp))
diff --git a/src/hid/hidint.h b/src/hid/hidint.h
index 8302745..b986f78 100644
--- a/src/hid/hidint.h
+++ b/src/hid/hidint.h
@@ -51,8 +51,18 @@ void hid_save_and_show_layer_ons (int *save_array);
/* Use this to restore them. */
void hid_restore_layer_ons (int *save_array);
+enum File_Name_Style {
+ /* Files for copper layers are named top, groupN, bottom. */
+ FNS_fixed,
+ /* Groups with multiple layers are named as above, else the single
+ layer name is used. */
+ FNS_single,
+ /* The name of the first layer in each group is used. */
+ FNS_first,
+};
+
/* Returns a filename base that can be used to output the layer. */
-const char *layer_type_to_file_name (int idx);
+const char *layer_type_to_file_name (int idx, int style);
#ifdef __GLOBAL_INCLUDED__
diff --git a/src/hid/nelma/nelma.c b/src/hid/nelma/nelma.c
index 8c78a53..4f5f748 100644
--- a/src/hid/nelma/nelma.c
+++ b/src/hid/nelma/nelma.c
@@ -256,7 +256,7 @@ nelma_write_space(FILE * out)
if (nelma_export_group[i]) {
idx = (i >= 0 && i < max_group) ?
PCB->LayerGroups.Entries[i][0] : i;
- ext = layer_type_to_file_name(idx);
+ ext = layer_type_to_file_name(idx, FNS_fixed);
if (z != 10) {
fprintf(out, ",\n");
@@ -326,7 +326,7 @@ nelma_write_nets(FILE * out)
if (nelma_export_group[i]) {
idx = (i >= 0 && i < max_group) ?
PCB->LayerGroups.Entries[i][0] : i;
- ext = layer_type_to_file_name(idx);
+ ext = layer_type_to_file_name(idx, FNS_fixed);
if (m != 0 || i != 0)
fprintf(out, ",\n");
@@ -404,7 +404,7 @@ nelma_write_layers(FILE * out)
if (nelma_export_group[i]) {
idx = (i >= 0 && i < max_group) ?
PCB->LayerGroups.Entries[i][0] : i;
- ext = layer_type_to_file_name(idx);
+ ext = layer_type_to_file_name(idx, FNS_fixed);
if (z != 10) {
sprintf(buf, "substrate-%d", z);
@@ -444,7 +444,7 @@ nelma_write_object(FILE * out, LibraryEntryTypePtr pin)
if (nelma_export_group[i]) {
idx = (i >= 0 && i < max_group) ?
PCB->LayerGroups.Entries[i][0] : i;
- ext = layer_type_to_file_name(idx);
+ ext = layer_type_to_file_name(idx, FNS_fixed);
fprintf(out, "object %s-%s {\n", pin->ListEntry, ext);
fprintf(out, "\tposition = { 0, 0 }\n");
@@ -668,7 +668,7 @@ nelma_do_export(HID_Attr_Val * options)
PCB->LayerGroups.Entries[i][0] : i;
nelma_start_png(nelma_basename,
- layer_type_to_file_name(idx));
+ layer_type_to_file_name(idx, FNS_fixed));
hid_save_and_show_layer_ons(save_ons);
nelma_start_png_export();
diff --git a/src/hid/ps/ps.c b/src/hid/ps/ps.c
index 7f2c3d7..c1a62ab 100644
--- a/src/hid/ps/ps.c
+++ b/src/hid/ps/ps.c
@@ -716,7 +716,7 @@ ps_set_layer (const char *name, int group, int empty)
ps_end_file (f);
fclose (f);
}
- f = psopen (filename, layer_type_to_file_name (idx));
+ f = psopen (filename, layer_type_to_file_name (idx, FNS_fixed));
if (!f)
{
perror(filename);
@@ -734,7 +734,7 @@ ps_set_layer (const char *name, int group, int empty)
* ordinal page number must reflect the position of that page in
* the body of the PostScript file and must start with 1, not 0.
*/
- fprintf (f, "%%%%Page: %s %d\n", layer_type_to_file_name(idx), pagecount);
+ fprintf (f, "%%%%Page: %s %d\n", layer_type_to_file_name(idx, FNS_fixed), pagecount);
if (mirror)
mirror_this = 1 - mirror_this;
@@ -750,10 +750,10 @@ ps_set_layer (const char *name, int group, int empty)
fprintf (f, "30 30 moveto (%s) show\n", PCB->Filename);
if (PCB->Name)
fprintf (f, "30 41 moveto (%s, %s) show\n",
- PCB->Name, layer_type_to_file_name (idx));
+ PCB->Name, layer_type_to_file_name (idx, FNS_fixed));
else
fprintf (f, "30 41 moveto (%s) show\n",
- layer_type_to_file_name (idx));
+ layer_type_to_file_name (idx, FNS_fixed));
if (mirror_this)
fprintf (f, "( \\(mirrored\\)) show\n");
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs