Bug Description

Yesterday I talked to a man who made PCBs
at one of my workplaces. He told me all
their devices were metric. Also he required
outline in every layer. So I took the patch
from feature request 1663208, cleaned it up
and added some more flexibility.

Changes from the original patch:
(1) empty drills are exported, too
(2) assembly and "invisible" layers are not exported
(3) an (unneeded) aperture added to empty Gerbers so
gerbv wouldn't tell they are RS-274D.

I think the best to apply is gerber.options.quater.diff; but I'm not sure it should be applied to the CVS at all; I'd test it once more before; also, I'd cut my name from the files: it should remain rather in VCS logs. I'll post a revised patch by the end of this week.

As of tests and scripts, it's you who knows better whether and how to add them; probably they should go to example/?

This is the latest version of the patch.
I removed notes on my changes from gerber.c, so the patch
could be applied to CVS. I also corrected some spaces and
added maximum coordinates detection (e.g. when mm units are
requested and the board is larger than 100 mm, it is incorrect
to write `%FSLAX24Y24*%' - there should be something like
`%FSLAX34Y34*%').

Tests showed that --outline-gerbers option
was buggy: it used to output a lot of unused (and invalid)
apertures into every Gerber file; I fixed this issue, too.

The resulting commit message could look like this:

Add more output options:

(1) metric output (separately in Gerbers and Excellons)
(2) 0..6 precision both in metric Excellon output
and (separately for X and Y axes) in Gerber
(3) decimal point in Excellon output
(4) outline every Gerber
(5) don't round drill diameters
(6) export empty layers, too
(based on Bert Timmerman lambert63 patch 1833934)
(7) digits before the decimal point are autodetected
(e.g. specify 3.x format when the maximum coordinates are
less than 1000 and more than 100)

This is a set of tests. I'm not sure
if they should be added to PCB sources.
I think they are not automatic enough; actually
I have no sane idea on how to compare
gerber/drill files produced with different
precision/units specifications. I just did it visually
with XOR mode of gerbv.

Thank you for your interest in this patch. once it was useful for me
and I want it to be as best as possible.

> Looks like some good features, although it does potentially increase the
> number of ways to get gerber output wrong for the user!

If the code is correct, it produces valid output only.

> Perhaps we should add some default button to the exporter which greys out
> the other options, and retains PCB's old ways for exporting.

Isn't it really enough that the default settings result in the output
identical to the output of the unpatched version? (actually there no
buttons in command line)

Frankly speaking, I just don't imagine neither what it
might look like to be convenient for users,
nor what work it will get.

> Now we're using GIT, it should be really easy to produce a rebased patch
> series for these changes, complete with log entries

Agreed, it should.

> (no /*... */ history comments in the code please!)

I still believe it is a formal requirement of the GNU GPL
for the contributor. It does not take too much time for
a developer to delete them, e.g. via requesting the
contributor; and if it is not a mainstream version,
these comments don't harm, do they?

> Looking at the code, and the list of features added, I think this could
> sensibly be more than one patch.

Yes, it could.

> Refactor output precision code,

I shall try.

> Add externally visible options for adjusting the output precision

To force invalid output? whoever is _that_ special,
this person certainly knows it can easily be made
with sed postprocessing.

I don't refuse, I just need a reason to know
how to implement it properly.

> Option to add outline to all layers
> "disable drills output in outline layers" (Isn't this was already done?)

"disable drills.." was a bug in earlier versions of the patch;
"outline all layers" had not been done yet when I posted it;
IIRC it was synchronised with mainstream in the latest patch version.

> I've never personally come across any requirement to have X and Y axis
> resolutions different in the gerber file. I'm not sure it is a useful
> option to export

I had never personally come across any requirement to have any
of these features until Oct 2008. I just read the specification and tried
to provide more flexibility.

The GPL does not require you to put changelog comments in sources when you submit patches. It only requires you to ensure that the END USER who receives a modified version of the WHOLE WORK is well informed that they do not have an official version, and how it differs from the official version.

Please do not put changelog comments in the source files. The sources describe what *is*, not what *was*.

patch 0001-add-outline-gerbers-option-to-gerber-exporter.patch is no longer needed.

In 0002, why did you take out the logic to select all groups and layers when all_layers?

I don't think we should have separate X and Y precision. Better would be to have an enum option with the available "formats" (like 3.2in, 5.3mm/tz, etc) that users are used to seeing, rather than making them figure out the various parts of the format individually. Also, having it be one option lets us put in "shortcuts" for popular fabs.

Why did you add find_option() ? The values are hard-coded at compile time, there should be no reason to have to search for them at runtime. Also, the fprintf() there should be an abort() - the error is for the developer, not the user, and returning a *valid* index leads to subtle bugs.

Also, I suspect the nanometer work will require changes to these patches as well.