paper min size set to 1 inch (previously 0.1 inch, very small indeed)

Avoid using magic numbers in file pcb_parser.cpp.
Fixes #11807
https://gitlab.com/kicad/code/kicad/issues/11807
This commit is contained in:
jean-pierre charras 2022-06-13 17:51:29 +02:00
parent fa5150b05f
commit 9fd5ee5a2f
2 changed files with 12 additions and 10 deletions

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2007-2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2007-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2007-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -36,7 +36,7 @@
#include <base_units.h> // for IU_PER_MILS
/// Min and max page sizes for clamping, in mils.
#define MIN_PAGE_SIZE_MILS 100
#define MIN_PAGE_SIZE_MILS 1000
#define MAX_PAGE_SIZE_PCBNEW_MILS 48000
#define MAX_PAGE_SIZE_EESCHEMA_MILS 120000

View File

@ -1196,18 +1196,20 @@ void PCB_PARSER::parsePAGE_INFO()
{
double width = parseDouble( "width" ); // width in mm
const double Mils2mm = 0.0254;
// Perform some controls to avoid crashes if the size is edited by hands
if( width < 100.0 )
width = 100.0;
else if( width > 1200.0 )
width = 1200.0;
if( width < MIN_PAGE_SIZE_MILS*Mils2mm )
width = MIN_PAGE_SIZE_MILS*Mils2mm;
else if( width > MAX_PAGE_SIZE_PCBNEW_MILS*Mils2mm )
width = MAX_PAGE_SIZE_PCBNEW_MILS*Mils2mm;
double height = parseDouble( "height" ); // height in mm
if( height < 100.0 )
height = 100.0;
else if( height > 1200.0 )
height = 1200.0;
if( height < MIN_PAGE_SIZE_MILS*Mils2mm )
height = MIN_PAGE_SIZE_MILS*Mils2mm;
else if( height > MAX_PAGE_SIZE_PCBNEW_MILS*Mils2mm )
height = MAX_PAGE_SIZE_PCBNEW_MILS*Mils2mm;
pageInfo.SetWidthMils( Mm2mils( width ) );
pageInfo.SetHeightMils( Mm2mils( height ) );