# kicad-developers team mailing list archive

## Re: PCBNEW NANOMETRES build zoom crash

```On 5/6/2012 7:41 PM, Dick Hollenbeck wrote:
>
>
>>>
>>> The largest distance that wx can support is INT_MAX, since it represents
>>> distance often in a wxCoord or wxSize. As a scalar, a distance is always
>>> positive. On most machines which run KiCad, int is 32 bits and INT_MAX is
>>> 2147483647. The most difficult distance for a virtual (world) cartesian
>>> space is the hypotenuse, or diagonal measurement at a 45 degree angle. This
>>> puts the most stress on the distance magnitude within the bounded virtual
>>> space. So if we allow this distance to be our constraint of <= INT_MAX, this
>>> constraint then propagates to the maximum distance in X and in Y that can be
>>> supported on each axis. Remember that the hypotenuse of a 1x1 square is
>>> sqrt( 1x1 + 1x1 ) = sqrt(2) = 1.41421356.
>>>
>>> hypotenuse of any square = sqrt(2) * deltaX;
>>>
>>> Let maximum supported hypotenuse be INT_MAX, then:
>>>
>>> MAX_AXIS = INT_MAX / sqrt(2) = 2147483647 / 1.41421356 = 1518500251
>>>
>>> This maximum distance is imposed by wxWidgets, not by KiCad. The imposition
>>> comes in the form of the data structures used in the graphics API at the
>>> wxDC level. Obviously when we are not interacting with wx we can use double
>>> to compute distances larger than this. For example the computation of the
>>> total length of a net, can and should be done in double, since it might
>>> actually be longer than a single diagonal line.
>>>
>>> The next choice is what to use for internal units (IU), sometimes called
>>> world units.  If nanometers, then the virtual space must be limited to
>>> about 1.5 x 1.5 meters square.  This is 1518500251 divided by 1e9 nm/meter.
>>>
>>> The maximum zoom factor then depends on the client window size.  If we ask
>>> wx to handle something outside INT_MIN to INT_MAX, there are unreported
>>> problems in the non-Debug build because wxRound() goes silent.
>>>
>>> Let:
>>> const double MAX_AXIS = 1518500251;
>>>
>>> Then a maximum zoom factor for a screen of 1920 pixels wide is
>>>     1518500251 / 1920 = 790885.
>>>
>>> The largest ZOOM_FACTOR in above table is ZOOM_FACTOR( 300 ), which computes
>>> out to 762000 just below 790885.
>
>
> If we don't drop the bucket on our toes, proceed carefully, watch where we are going, it
> looks like it will hold water using a virtual world sized at 2.14 meters x 2.14 meters.
>
> So far so good.
>
> Dick

Great work Dick!  Thanks for taking the lead on this.  I really
appreciate it.

Wayne

>
>
> _______________________________________________