Loading common/class_page_info.cpp +16 −12 Original line number Diff line number Diff line Loading @@ -250,12 +250,14 @@ void PAGE_INFO::SetPortrait( bool isPortrait ) static int clampWidth( int aWidthInMils ) { /* was giving EESCHEMA single component SVG plotter grief However a minimal test is made to avoid values that crashes Kicad if( aWidthInMils < 4000 ) // 4" is about a baseball card aWidthInMils = 4000; else if( aWidthInMils > 44000 ) //44" is plotter size aWidthInMils = 44000; */ if( aWidthInMils < 10 ) aWidthInMils = 10; return aWidthInMils; } Loading @@ -264,11 +266,14 @@ static int clampHeight( int aHeightInMils ) { /* was giving EESCHEMA single component SVG plotter grief clamping is best done at the UI, i.e. dialog, levels However a minimal test is made to avoid values that crashes Kicad if( aHeightInMils < 4000 ) aHeightInMils = 4000; else if( aHeightInMils > 44000 ) aHeightInMils = 44000; */ if( aHeightInMils < 10 ) aHeightInMils = 10; return aHeightInMils; } Loading Loading @@ -315,19 +320,18 @@ void PAGE_INFO::SetHeightMils( int aHeightInMils ) void PAGE_INFO::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const throw( IO_ERROR ) { // If page is A3 landscape, then it is assumed to be the default and is not written. if( !IsDefault() ) { aFormatter->Print( aNestLevel, "(page %s", aFormatter->Quotew( GetType() ).c_str() ); // The page dimensions are only required for user defined page sizes. // Internally, the page size is in mils if( GetType() == PAGE_INFO::Custom ) aFormatter->Print( aNestLevel, " %d %d", GetWidthIU(), GetHeightIU() ); aFormatter->Print( 0, " %g %g", GetCustomWidthMils() * 25.4 / 1000.0, GetCustomHeightMils() * 25.4 / 1000.0 ); if( IsCustom() && IsPortrait() ) aFormatter->Print( aNestLevel, " portrait" ); aFormatter->Print( 0, " portrait" ); aFormatter->Print( aNestLevel, ")\n" ); } aFormatter->Print( 0, ")\n" ); } pcbnew/pcb_parser.cpp +28 −15 Original line number Diff line number Diff line Loading @@ -431,7 +431,7 @@ void PCB_PARSER::parseHeader() throw( IO_ERROR, PARSE_ERROR ) Expecting( GetTokenText( T_version ) ); // Get the file version. m_board->SetFileFormatVersionAtLoad( NeedNUMBER( GetTokenText( T_version ) ) ); m_board->SetFileFormatVersionAtLoad( parseInt( GetTokenText( T_version ) ) ); // Skip the host name and host build version information. NeedRIGHT(); Loading Loading @@ -489,23 +489,45 @@ void PCB_PARSER::parsePAGE_INFO() throw( IO_ERROR, PARSE_ERROR ) wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a PAGE_INFO." ) ); T token; bool isPortrait = false; PAGE_INFO pageInfo; NeedSYMBOL(); wxString pageType = FromUTF8(); if( !pageInfo.SetType( pageType ) ) { wxString err; err.Printf( _( "page type \"%s\" is not valid " ), GetChars( FromUTF8() ) ); THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); } if( pageType == PAGE_INFO::Custom ) { PAGE_INFO::SetCustomWidthMils( Iu2Mils( NeedNUMBER( "width" ) ) ); PAGE_INFO::SetCustomHeightMils( Iu2Mils( NeedNUMBER( "height" ) ) ); double width = parseDouble( "width" ); // width in mm // 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; double height = parseDouble( "height" ); // height in mm if( height < 100.0 ) height = 100.0; else if( height > 1200.0 ) height = 1200.0; pageInfo.SetWidthMils( Mm2mils( width ) ); pageInfo.SetHeightMils( Mm2mils( height ) ); } token = NextTok(); if( token == T_portrait ) { isPortrait = true; pageInfo.SetPortrait( true ); NeedRIGHT(); } else if( token != T_RIGHT ) Loading @@ -513,15 +535,6 @@ void PCB_PARSER::parsePAGE_INFO() throw( IO_ERROR, PARSE_ERROR ) Expecting( "portrait|)" ); } PAGE_INFO pageInfo; if( !pageInfo.SetType( pageType, isPortrait ) ) { wxString err; err.Printf( _( "page type \"%s\" is not valid " ), GetChars( FromUTF8() ) ); THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); } m_board->SetPageSettings( pageInfo ); } Loading Loading @@ -566,7 +579,7 @@ void PCB_PARSER::parseTITLE_BLOCK() throw( IO_ERROR, PARSE_ERROR ) case T_comment: { int commentNumber = NeedNUMBER( "comment" ); int commentNumber = parseInt( "comment" ); switch( commentNumber ) { Loading Loading
common/class_page_info.cpp +16 −12 Original line number Diff line number Diff line Loading @@ -250,12 +250,14 @@ void PAGE_INFO::SetPortrait( bool isPortrait ) static int clampWidth( int aWidthInMils ) { /* was giving EESCHEMA single component SVG plotter grief However a minimal test is made to avoid values that crashes Kicad if( aWidthInMils < 4000 ) // 4" is about a baseball card aWidthInMils = 4000; else if( aWidthInMils > 44000 ) //44" is plotter size aWidthInMils = 44000; */ if( aWidthInMils < 10 ) aWidthInMils = 10; return aWidthInMils; } Loading @@ -264,11 +266,14 @@ static int clampHeight( int aHeightInMils ) { /* was giving EESCHEMA single component SVG plotter grief clamping is best done at the UI, i.e. dialog, levels However a minimal test is made to avoid values that crashes Kicad if( aHeightInMils < 4000 ) aHeightInMils = 4000; else if( aHeightInMils > 44000 ) aHeightInMils = 44000; */ if( aHeightInMils < 10 ) aHeightInMils = 10; return aHeightInMils; } Loading Loading @@ -315,19 +320,18 @@ void PAGE_INFO::SetHeightMils( int aHeightInMils ) void PAGE_INFO::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControlBits ) const throw( IO_ERROR ) { // If page is A3 landscape, then it is assumed to be the default and is not written. if( !IsDefault() ) { aFormatter->Print( aNestLevel, "(page %s", aFormatter->Quotew( GetType() ).c_str() ); // The page dimensions are only required for user defined page sizes. // Internally, the page size is in mils if( GetType() == PAGE_INFO::Custom ) aFormatter->Print( aNestLevel, " %d %d", GetWidthIU(), GetHeightIU() ); aFormatter->Print( 0, " %g %g", GetCustomWidthMils() * 25.4 / 1000.0, GetCustomHeightMils() * 25.4 / 1000.0 ); if( IsCustom() && IsPortrait() ) aFormatter->Print( aNestLevel, " portrait" ); aFormatter->Print( 0, " portrait" ); aFormatter->Print( aNestLevel, ")\n" ); } aFormatter->Print( 0, ")\n" ); }
pcbnew/pcb_parser.cpp +28 −15 Original line number Diff line number Diff line Loading @@ -431,7 +431,7 @@ void PCB_PARSER::parseHeader() throw( IO_ERROR, PARSE_ERROR ) Expecting( GetTokenText( T_version ) ); // Get the file version. m_board->SetFileFormatVersionAtLoad( NeedNUMBER( GetTokenText( T_version ) ) ); m_board->SetFileFormatVersionAtLoad( parseInt( GetTokenText( T_version ) ) ); // Skip the host name and host build version information. NeedRIGHT(); Loading Loading @@ -489,23 +489,45 @@ void PCB_PARSER::parsePAGE_INFO() throw( IO_ERROR, PARSE_ERROR ) wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as a PAGE_INFO." ) ); T token; bool isPortrait = false; PAGE_INFO pageInfo; NeedSYMBOL(); wxString pageType = FromUTF8(); if( !pageInfo.SetType( pageType ) ) { wxString err; err.Printf( _( "page type \"%s\" is not valid " ), GetChars( FromUTF8() ) ); THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); } if( pageType == PAGE_INFO::Custom ) { PAGE_INFO::SetCustomWidthMils( Iu2Mils( NeedNUMBER( "width" ) ) ); PAGE_INFO::SetCustomHeightMils( Iu2Mils( NeedNUMBER( "height" ) ) ); double width = parseDouble( "width" ); // width in mm // 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; double height = parseDouble( "height" ); // height in mm if( height < 100.0 ) height = 100.0; else if( height > 1200.0 ) height = 1200.0; pageInfo.SetWidthMils( Mm2mils( width ) ); pageInfo.SetHeightMils( Mm2mils( height ) ); } token = NextTok(); if( token == T_portrait ) { isPortrait = true; pageInfo.SetPortrait( true ); NeedRIGHT(); } else if( token != T_RIGHT ) Loading @@ -513,15 +535,6 @@ void PCB_PARSER::parsePAGE_INFO() throw( IO_ERROR, PARSE_ERROR ) Expecting( "portrait|)" ); } PAGE_INFO pageInfo; if( !pageInfo.SetType( pageType, isPortrait ) ) { wxString err; err.Printf( _( "page type \"%s\" is not valid " ), GetChars( FromUTF8() ) ); THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); } m_board->SetPageSettings( pageInfo ); } Loading Loading @@ -566,7 +579,7 @@ void PCB_PARSER::parseTITLE_BLOCK() throw( IO_ERROR, PARSE_ERROR ) case T_comment: { int commentNumber = NeedNUMBER( "comment" ); int commentNumber = parseInt( "comment" ); switch( commentNumber ) { Loading