← Back to team overview

kicad-developers team mailing list archive

Re: Converting KiCAD to metric units: The approach

 

On Fri, 24 Jun 2011, Dick Hollenbeck wrote:

First better soultion is to make this function take second parameter
    unit2internal(what, unit_from); // use it like x = (x_in_mm,millimeter)
    internal2unit(what, unit_to);

Most of kicad does this today! look out for ReturnStringFromValue and
ReturnValueFromString (strings because units are needed only for the
UI, also it handles the unit name in printing and reading). Only the
'unit' is implicitly from the current unit in most helpers.

As I already said 'real' units are needed only in the UI and during
plotting.

Only two functions (and several constants, one per unit).
Or even one function, taking 3 paramters:
    unit2unit(what, unit_from, unit_to);
    q = unit2unit(q_in_mm, mm, internal_u);

Not needed. There should be no need for a external-to-external unit
since everything is computed in internal units...

Ater all, is you think it is so simple, why didn't you already made it all?

Because decimils are already quite good in their work... only some
draconic DRC found issues because of roundings.

int is fine, without the typedef, that way I don't have to go unwrap LENGTH,
mentally or by compiler.

And the *storage* overhead because of the associated unit (and VPTR too,
maybe) and the implicit construction/deconstruction of all these
objects. And the the flyweight pattern is the biggest way ever devised
for putting round stuff in squared holes IMHO :P

I do not ever see a need to keepmore than one unit supproted.
Where?  What context are you talking about?  I think we need to store board
and footprint files in both imperial and metric both.

Why both? Save it in internal units and present them to the user in the
unit (s)he want...

Actually the mils and the mm are human readable.  That is their value.   The
ASCII Kicad files have always been able to make this claim.  Storing things in
nanometers will lead to big numbers, and there will be a lot of zeros.

As a non-US resident I'd have some comments about the readability of
decimils :D

Personally I could even keep the decimils if it wasn't for the DRC
issues; simply switching from decimils to a smaller unit give a fast
solution and solves the problem.

--
Lorenzo Marcantonio
Logos Srl


Follow ups

References