← Back to team overview

kicad-developers team mailing list archive

Re: Where is the PCBNEW define coming from??

 

On Wed, Aug 15, 2012 at 09:40:33AM -0500, Dick Hollenbeck wrote:
> Please narrow down "the common"
> 
> a) common.cpp
> b) common lib

I don't remember if the whole common lib was compiled twice with
different parameters or only some files...

But today it only get compiled once (with neither PCBNEW or EESCHEMA
defined, it seems)

> If you mean class SCREEN, please say that.  Thanks.

I need to know how big is the current BIU in the common_plot functions
(which are shared to both eeschema and pcbnew); when they are build they
see 1 BIU = 1 mil. The whole plot machinery works in BIUs (and the
scaling factor is indeed passed when establishing the viewport); however
the page sizes (defined in the common lib, too) are in mils, not BIUs,
so the border function need the 'right' constant to convert the page in
BIUs.

Where do it takes that constant? it comes from
BASE_SCREEN::MilsToIuScalar() which is virtual and replaced in pcbnew!

Luckily the same value can be easily stored in the plotter object during
initialization since otherwise I'd have to pass it down from the top as
a parameter!

I've done some analysis on the related constants (IU_PER_MM,
IU_PER_MILS, IU_PER_DECIMILS): they ultimately are conditionally defined in
convert_to_biu.h (btw convert_from_iu.h which seems to contain the
inverse constants is *only* used in pcb_parser.cpp); from this they are
'distributed' with base_units.h and pcbnew.h. The page size is also
available in the PAGE_SIZE accessors but *only* for code compiled inside
pcbnew/eeschema/gerbview.

In short I think that using the IU_ constant in common code is an error
and the only ways to get it from common code are:
1) as a parameter
2) from BASE_SCREEN::MilsToIuScalar

... yet another thing polymorphed for the sake of polymorphing (the
problem you mentioned - making eeschema and pcbnew alike even when they
are different)

-- 
Lorenzo Marcantonio
Logos Srl


References