kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #43449
Re: Internal units in the KiCAD source code
-
To:
kicad-developers@xxxxxxxxxxxxxxxxxxx
-
From:
Thomas Pointhuber <thomas.pointhuber@xxxxxx>
-
Date:
Thu, 13 Feb 2020 16:06:27 +0100
-
Autocrypt:
addr=thomas.pointhuber@xxxxxx; prefer-encrypt=mutual; keydata= mQINBFKxhfoBEADDCVK/vsBRi6BnOVSNa+2+xDQt+rBZt7D7BiTm6vaH/NYh+MFyujViIwIt dducp1y09Bkheqfy1tZVBznAC9L/+scePboOeTRTOMtghp041RXC6K7B4J3RMO0++9XdgDlC KLkNhpyPhb2uKVtGBzZjAPyV9udScv5AnQGrPvE1fIs7CreUPj+sSnRYb0sp5qZRaSpXSmKU NyTFEQtuaR1RXl0Dekj4BfXOr+RBdy8oewvGL64uJYd1ddsJ+uKLURbAZCd4n76g/7y1M+T+ Z0fsO7JT8HPA/4O9FrYHEl6dQTgCos3HsWqqP0xHzW9eR/xTXtNGJ8NSMO11Fla6U27Fb6os XFutSczwkoF3bkhLufodg1y9z+MZ3G5hBidYKRJMxFBLcKqtmcgwfSFI9IP50XH0RY1aOLXJ YsSO/1U+h5LHIYWirLvy6UvWdPD/+cSZgG6JxrHnd/gz0YxzNy8RNo9eGZx34+UTVw6OlKfP CnHvT56Dd9ntRxZ+okKvxSE2/Lc97/xrQj/L1Lgqo6QeHRRmn0V7tAGQR5iYTTVzitjnwGxm St8W4rUJRGdOhpig4r5vy8tZvZ9sJlNkQ2ah1iVTCV1+YBivuKi9EtMCEIoks9AfAPs9iFgl ftmT+5GKq5AA6QuXH9wwlgzJZKQi1UeB4i8RxKnN0De1tINesQARAQABtCxUaG9tYXMgUG9p bnRodWJlciA8dGhvbWFzLnBvaW50aHViZXJAZ214LmF0PokCVAQTAQgAPgIbIwULCQgHAgYV CAkKCwIEFgIDAQIeAQIXgBYhBFeMngIV9HTw3olSRscJ2HTtryVWBQJd1AEYBQkQxhWbAAoJ E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JrkiaIDw42dCsmuSCDU7prYgGD5PP 3ePoYjjOId0=
-
In-reply-to:
<5e6efa02-80d4-8616-f633-baad820e0121@gmail.com>
-
User-agent:
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2
Hi Wayne,
I think, I was present at FOSDEM 2019 when talking about this issue.
From what I understand, the current approach requires KiCad to compile
the units for each package separately (because e.g. mapping IU<->mm is
always different). This has two big problems:
1. the same code has to be compiled multiple times.
2. there is no "true" mapping from IU to other units. When I for example
want to create a python API with one type of geometric primitives, this
is a real problem. When I want to script into eeschema and pcbnew at the
same time, how to choose the correct units?
The solution discussed was to move to 64bit and to use
constexpr/templates handling unit conversion. So a programmer can for
example enter 2mm and the compiler automatically converts it into the
internal unit like nm.
I'm still in favour of improving this. The same with angles.
Regards,
Thomas
Am 13.02.20 um 15:46 schrieb Wayne Stambaugh:
> Hi Johannes,
>
> Thank you for your suggestion but the internal units for each format
> were chosen for a specific reason. There really is no justifiable
> reason to change them as they have been carefully selected based on the
> requirements of the objects they represent. Conversion code is provided
> for each internal unit so plotting to standard units such as
> millimeters, inches, etc is trivial. I'm not opposed to adding support
> for changing the plot units. I am opposed to changing the internal units.
>
> Cheers,
>
> Wayne
>
> On 2/13/20 9:32 AM, Johannes Pfister wrote:
>> The KiCAD code uses all kinds of different units for distances.
>> Amongst other things I found:
>> nm: pcbnew internal units
>> 10nm: Gerbview internal units
>> 100nm EEschema internal units
>> 1um: PL-Editor internal units
>> 0.1mil (2.54um): SetViewport
>> 1mil (25.4 um): WS_DRAW_ITEM_BASE and GetSizeMils
>> And the native File formats use mm (pcbnew) and mil (EEschema).
>> Something like SVG exports in 0.1 mil steps. I think that this is not
>> very consistent and something like a PLOTTER class needs to handle
>> different IU-sizes.
>>
>> My idea is to rewrite the internal units so that nm are used
>> everywhere inside the source code, and only parts that write or read
>> files and display data to or read data from the user should convert it
>> to another unit system. I don't want to change any file formats.
>> That would make it a bit more straightforward, more consistent, metric
>> and an SVG-Plotter would use a metric step size. The disadvantage
>> would be that there would be an about 2m or 4m limit in every
>> direction, assuming int is 32 bit, which is AFAIK true for all
>> platforms KiCAD current supports.
>>
>> Before i rewrite code, can you say what you guys think about it?
>>
>>
>> Johannes Pfister
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~kicad-developers
>> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~kicad-developers
>> More help : https://help.launchpad.net/ListHelp
>>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
>
Attachment:
signature.asc
Description: OpenPGP digital signature
Follow ups
References