Loading common/CMakeLists.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ set(COMMON_SRCS class_bitmap_base.cpp class_bitmap_base.cpp class_colors_design_settings.cpp class_colors_design_settings.cpp class_marker_base.cpp class_marker_base.cpp class_page_info.cpp class_plotter.cpp class_plotter.cpp class_undoredo_container.cpp class_undoredo_container.cpp common.cpp common.cpp Loading common/class_page_info.cpp 0 → 100644 +222 −0 Original line number Original line Diff line number Diff line /* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 KiCad Developers, see CHANGELOG.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 * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, you may find one here: * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * or you may search the http://www.gnu.org website for the version 2 license, * or you may write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include <common.h> const wxString PAGE_INFO::Custom( wxT( "User" ) ); // Standard page sizes in mils, all constants #if defined(KICAD_GOST) const PAGE_INFO PAGE_INFO::pageA4( wxSize( 8283, 11700 ), wxT( "A4" ) ); #else const PAGE_INFO PAGE_INFO::pageA4( wxSize( 11700, 8267 ), wxT( "A4" ) ); #endif const PAGE_INFO PAGE_INFO::pageA3( wxSize( 16535, 11700 ), wxT( "A3" ) ); const PAGE_INFO PAGE_INFO::pageA2( wxSize( 23400, 16535 ), wxT( "A2" ) ); const PAGE_INFO PAGE_INFO::pageA1( wxSize( 33070, 23400 ), wxT( "A1" ) ); const PAGE_INFO PAGE_INFO::pageA0( wxSize( 46800, 33070 ), wxT( "A0" ) ); const PAGE_INFO PAGE_INFO::pageA( wxSize( 11000, 8500 ), wxT( "A" ) ); const PAGE_INFO PAGE_INFO::pageB( wxSize( 17000, 11000 ), wxT( "B" ) ); const PAGE_INFO PAGE_INFO::pageC( wxSize( 22000, 17000 ), wxT( "C" ) ); const PAGE_INFO PAGE_INFO::pageD( wxSize( 34000, 22000 ), wxT( "D" ) ); const PAGE_INFO PAGE_INFO::pageE( wxSize( 44000, 34000 ), wxT( "E" ) ); const PAGE_INFO PAGE_INFO::pageGERBER(wxSize( 32000, 32000 ), wxT( "GERBER" ) ); const PAGE_INFO PAGE_INFO::pageUser( wxSize( 17000, 11000 ), Custom ); int PAGE_INFO::s_user_width = 17000; int PAGE_INFO::s_user_height = 11000; /* wxArrayString PAGE_INFO::GetStandardSizes() { wxArrayString ret; static const PAGE_INFO* stdPageSizes[] = { &pageA4, &pageA3, &pageA2, &pageA1, &pageA0, &pageA, &pageB, &pageC, &pageD, &pageE, // &pageGERBER, // standard? &pageUser, }; for( unsigned i=0; i < DIM( stdPageSizes ); ++i ) ret.Add( stdPageSizes[i]->GetType() ); return ret; } */ PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) : m_type( aType ), m_size( aSizeMils ), m_portrait( false ) { #if defined(KICAD_GOST) m_left_margin = GOST_LEFTMARGIN; m_right_margin = GOST_RIGHTMARGIN; m_top_margin = GOST_TOPMARGIN; m_bottom_margin = GOST_BOTTOMMARGIN; #else m_left_margin = m_right_margin = m_top_margin = m_bottom_margin = 400; #endif } PAGE_INFO::PAGE_INFO( const wxString& aType ) { SetType( aType ); } bool PAGE_INFO::SetType( const wxString& aType ) { bool rc = true; if( aType == pageA4.GetType() ) *this = pageA4; else if( aType == pageA3.GetType() ) *this = pageA3; else if( aType == pageA2.GetType() ) *this = pageA2; else if( aType == pageA1.GetType() ) *this = pageA1; else if( aType == pageA0.GetType() ) *this = pageA0; else if( aType == pageA.GetType() ) *this = pageA; else if( aType == pageB.GetType() ) *this = pageB; else if( aType == pageC.GetType() ) *this = pageC; else if( aType == pageD.GetType() ) *this = pageD; else if( aType == pageE.GetType() ) *this = pageE; else if( aType == pageGERBER.GetType() ) *this = pageGERBER; else if( aType == pageUser.GetType() ) { // pageUser is const, and may not and does not hold the custom size, // so customize *this later *this = pageUser; // customize: m_size.x = s_user_width; m_size.y = s_user_height; } else rc = false; return rc; } bool PAGE_INFO::IsCustom() const { return m_type == Custom; } void PAGE_INFO::SetPortrait( bool isPortrait ) { if( m_portrait != isPortrait ) { // swap x and y in m_size m_size = wxSize( m_size.y, m_size.x ); m_portrait = isPortrait; // margins are not touched. } } static int clampWidth( int aWidthInMils ) { if( aWidthInMils < 4000 ) // 4" is about a baseball card aWidthInMils = 4000; else if( aWidthInMils > 44000 ) //44" is plotter size aWidthInMils = 44000; return aWidthInMils; } static int clampHeight( int aHeightInMils ) { if( aHeightInMils < 4000 ) aHeightInMils = 4000; else if( aHeightInMils > 44000 ) aHeightInMils = 44000; return aHeightInMils; } void PAGE_INFO::SetUserWidthMils( int aWidthInMils ) { s_user_width = clampWidth( aWidthInMils ); } void PAGE_INFO::SetUserHeightMils( int aHeightInMils ) { s_user_height = clampHeight( aHeightInMils ); } void PAGE_INFO::SetWidthMils( int aWidthInMils ) { m_size.x = clampWidth( aWidthInMils ); } int PAGE_INFO::GetWidthMils() const { return m_size.x; } void PAGE_INFO::SetHeightMils( int aHeightInMils ) { m_size.y = clampHeight( aHeightInMils ); } int PAGE_INFO::GetHeightMils() const { return m_size.y; } const wxSize& PAGE_INFO::GetSizeMils() const { return m_size; } common/common.cpp +0 −192 Original line number Original line Diff line number Diff line Loading @@ -174,198 +174,6 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString ) } } //-----<PAGE_INFO>------------------------------------------------------------- // Standard page sizes in mils, all constants #if defined(KICAD_GOST) const PAGE_INFO PAGE_INFO::pageA4( wxSize( 8283, 11700 ), wxT( "A4" ) ); #else const PAGE_INFO PAGE_INFO::pageA4( wxSize( 11700, 8267 ), wxT( "A4" ) ); #endif const PAGE_INFO PAGE_INFO::pageA3( wxSize( 16535, 11700 ), wxT( "A3" ) ); const PAGE_INFO PAGE_INFO::pageA2( wxSize( 23400, 16535 ), wxT( "A2" ) ); const PAGE_INFO PAGE_INFO::pageA1( wxSize( 33070, 23400 ), wxT( "A1" ) ); const PAGE_INFO PAGE_INFO::pageA0( wxSize( 46800, 33070 ), wxT( "A0" ) ); const PAGE_INFO PAGE_INFO::pageA( wxSize( 11000, 8500 ), wxT( "A" ) ); const PAGE_INFO PAGE_INFO::pageB( wxSize( 17000, 11000 ), wxT( "B" ) ); const PAGE_INFO PAGE_INFO::pageC( wxSize( 22000, 17000 ), wxT( "C" ) ); const PAGE_INFO PAGE_INFO::pageD( wxSize( 34000, 22000 ), wxT( "D" ) ); const PAGE_INFO PAGE_INFO::pageE( wxSize( 44000, 34000 ), wxT( "E" ) ); const PAGE_INFO PAGE_INFO::pageGERBER(wxSize( 32000, 32000 ), wxT( "GERBER" ) ); const PAGE_INFO PAGE_INFO::pageUser( wxSize( 17000, 11000 ), wxT( "User" ) ); int PAGE_INFO::s_user_width = 17000; int PAGE_INFO::s_user_height = 11000; /* wxArrayString PAGE_INFO::GetStandardSizes() { wxArrayString ret; static const PAGE_INFO* stdPageSizes[] = { &pageA4, &pageA3, &pageA2, &pageA1, &pageA0, &pageA, &pageB, &pageC, &pageD, &pageE, // &pageGERBER, // standard? &pageUser, }; for( unsigned i=0; i < DIM( stdPageSizes ); ++i ) ret.Add( stdPageSizes[i]->GetType() ); return ret; } */ PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) : m_type( aType ), m_size( aSizeMils ), m_portrait( false ) { #if defined(KICAD_GOST) m_left_margin = GOST_LEFTMARGIN; m_right_margin = GOST_RIGHTMARGIN; m_top_margin = GOST_TOPMARGIN; m_bottom_margin = GOST_BOTTOMMARGIN; #else m_left_margin = m_right_margin = m_top_margin = m_bottom_margin = 400; #endif } PAGE_INFO::PAGE_INFO( const wxString& aType ) { SetType( aType ); } bool PAGE_INFO::SetType( const wxString& aType ) { bool rc = true; if( aType == pageA4.GetType() ) *this = pageA4; else if( aType == pageA3.GetType() ) *this = pageA3; else if( aType == pageA2.GetType() ) *this = pageA2; else if( aType == pageA1.GetType() ) *this = pageA1; else if( aType == pageA0.GetType() ) *this = pageA0; else if( aType == pageA.GetType() ) *this = pageA; else if( aType == pageB.GetType() ) *this = pageB; else if( aType == pageC.GetType() ) *this = pageC; else if( aType == pageD.GetType() ) *this = pageD; else if( aType == pageE.GetType() ) *this = pageE; else if( aType == pageGERBER.GetType() ) *this = pageGERBER; else if( aType == pageUser.GetType() ) { // pageUser is const, and may not and does not hold the custom size, // so customize *this later *this = pageUser; // customize: m_size.x = s_user_width; m_size.y = s_user_height; } else rc = false; return rc; } void PAGE_INFO::SetPortrait( bool isPortrait ) { if( m_portrait != isPortrait ) { // swap x and y in m_size m_size = wxSize( m_size.y, m_size.x ); m_portrait = isPortrait; // margins are not touched. } } static int clampWidth( int aWidthInMils ) { if( aWidthInMils < 4000 ) // 4" is about a baseball card aWidthInMils = 4000; else if( aWidthInMils > 44000 ) //44" is plotter size aWidthInMils = 44000; return aWidthInMils; } static int clampHeight( int aHeightInMils ) { if( aHeightInMils < 4000 ) aHeightInMils = 4000; else if( aHeightInMils > 44000 ) aHeightInMils = 44000; return aHeightInMils; } void PAGE_INFO::SetUserWidthMils( int aWidthInMils ) { s_user_width = clampWidth( aWidthInMils ); } void PAGE_INFO::SetUserHeightMils( int aHeightInMils ) { s_user_height = clampHeight( aHeightInMils ); } void PAGE_INFO::SetWidthMils( int aWidthInMils ) { m_size.x = clampWidth( aWidthInMils ); } int PAGE_INFO::GetWidthMils() const { return m_size.x; } void PAGE_INFO::SetHeightMils( int aHeightInMils ) { m_size.y = clampHeight( aHeightInMils ); } int PAGE_INFO::GetHeightMils() const { return m_size.y; } const wxSize& PAGE_INFO::GetSizeMils() const { return m_size; } //-----</PAGE_INFO>------------------------------------------------------------ wxString ReturnUnitSymbol( EDA_UNITS_T aUnit, const wxString& formatString ) wxString ReturnUnitSymbol( EDA_UNITS_T aUnit, const wxString& formatString ) { { wxString tmp; wxString tmp; Loading common/common_plotPS_functions.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -392,12 +392,12 @@ bool PS_PLOTTER::start_plot( FILE* fout ) // converted to internal units. // converted to internal units. wxSize pageSize = pageInfo.GetSizeMils(); wxSize pageSize = pageInfo.GetSizeMils(); if( pageInfo.GetType().Cmp( wxT( "User" ) ) == 0 ) if( pageInfo.IsCustom() ) fprintf( output_file, "%%%%DocumentMedia: Custom %d %d 0 () ()\n", fprintf( output_file, "%%%%DocumentMedia: Custom %d %d 0 () ()\n", wxRound( pageSize.y * 10 * CONV_SCALE ), wxRound( pageSize.y * 10 * CONV_SCALE ), wxRound( pageSize.x * 10 * CONV_SCALE ) ); wxRound( pageSize.x * 10 * CONV_SCALE ) ); else // ( if sheet->m_Name does not equal "User" ) else // a standard paper size fprintf( output_file, "%%%%DocumentMedia: %s %d %d 0 () ()\n", fprintf( output_file, "%%%%DocumentMedia: %s %d %d 0 () ()\n", TO_UTF8( pageInfo.GetType() ), TO_UTF8( pageInfo.GetType() ), wxRound( pageSize.y * 10 * CONV_SCALE ), wxRound( pageSize.y * 10 * CONV_SCALE ), Loading common/dialogs/dialog_page_settings.cpp +5 −5 Original line number Original line Diff line number Diff line Loading @@ -37,7 +37,7 @@ void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event ) DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent ) : DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent ) : DIALOG_PAGES_SETTINGS_BASE( parent ), DIALOG_PAGES_SETTINGS_BASE( parent ), m_user_size( wxT( "User" ) ) m_user_size( PAGE_INFO::Custom ) { { m_Parent = parent; m_Parent = parent; m_Screen = m_Parent->GetScreen(); m_Screen = m_Parent->GetScreen(); Loading Loading @@ -74,7 +74,7 @@ void DIALOG_PAGES_SETTINGS::initDialog() const PAGE_INFO& pageInfo = m_Parent->GetPageSettings(); const PAGE_INFO& pageInfo = m_Parent->GetPageSettings(); if( wxT( "User" ) != pageInfo.GetType() ) if( !pageInfo.IsCustom() ) m_landscapeCheckbox->SetValue( !pageInfo.IsPortrait() ); m_landscapeCheckbox->SetValue( !pageInfo.IsPortrait() ); setCurrentPageSizeSelection( pageInfo.GetType() ); setCurrentPageSizeSelection( pageInfo.GetType() ); Loading Loading @@ -177,7 +177,7 @@ void DIALOG_PAGES_SETTINGS::OnCancelClick( wxCommandEvent& event ) void DIALOG_PAGES_SETTINGS::onRadioButtonSelected() void DIALOG_PAGES_SETTINGS::onRadioButtonSelected() { { if( wxT( "User" ) == m_PageSizeBox->GetStringSelection() ) if( PAGE_INFO::Custom == m_PageSizeBox->GetStringSelection() ) { { m_landscapeCheckbox->Enable( false ); m_landscapeCheckbox->Enable( false ); } } Loading Loading @@ -246,10 +246,10 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event ) wxString paperType = m_PageSizeBox->GetString( radioSelection ); wxString paperType = m_PageSizeBox->GetString( radioSelection ); // construct pageInfo _after_ user settings have been established in case the // construct pageInfo _after_ user settings have been established in case the // paperType is "User", otherwise User with and height will not go into effect right away. // paperType is custom, otherwise User width and height will not go into effect right away. PAGE_INFO pageInfo( paperType ); PAGE_INFO pageInfo( paperType ); if( wxT( "User" ) != paperType ) if( PAGE_INFO::Custom != paperType ) pageInfo.SetPortrait( !m_landscapeCheckbox->IsChecked() ); pageInfo.SetPortrait( !m_landscapeCheckbox->IsChecked() ); m_Parent->SetPageSettings( pageInfo ); m_Parent->SetPageSettings( pageInfo ); Loading Loading
common/CMakeLists.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ set(COMMON_SRCS class_bitmap_base.cpp class_bitmap_base.cpp class_colors_design_settings.cpp class_colors_design_settings.cpp class_marker_base.cpp class_marker_base.cpp class_page_info.cpp class_plotter.cpp class_plotter.cpp class_undoredo_container.cpp class_undoredo_container.cpp common.cpp common.cpp Loading
common/class_page_info.cpp 0 → 100644 +222 −0 Original line number Original line Diff line number Diff line /* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 KiCad Developers, see CHANGELOG.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 * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, you may find one here: * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * or you may search the http://www.gnu.org website for the version 2 license, * or you may write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include <common.h> const wxString PAGE_INFO::Custom( wxT( "User" ) ); // Standard page sizes in mils, all constants #if defined(KICAD_GOST) const PAGE_INFO PAGE_INFO::pageA4( wxSize( 8283, 11700 ), wxT( "A4" ) ); #else const PAGE_INFO PAGE_INFO::pageA4( wxSize( 11700, 8267 ), wxT( "A4" ) ); #endif const PAGE_INFO PAGE_INFO::pageA3( wxSize( 16535, 11700 ), wxT( "A3" ) ); const PAGE_INFO PAGE_INFO::pageA2( wxSize( 23400, 16535 ), wxT( "A2" ) ); const PAGE_INFO PAGE_INFO::pageA1( wxSize( 33070, 23400 ), wxT( "A1" ) ); const PAGE_INFO PAGE_INFO::pageA0( wxSize( 46800, 33070 ), wxT( "A0" ) ); const PAGE_INFO PAGE_INFO::pageA( wxSize( 11000, 8500 ), wxT( "A" ) ); const PAGE_INFO PAGE_INFO::pageB( wxSize( 17000, 11000 ), wxT( "B" ) ); const PAGE_INFO PAGE_INFO::pageC( wxSize( 22000, 17000 ), wxT( "C" ) ); const PAGE_INFO PAGE_INFO::pageD( wxSize( 34000, 22000 ), wxT( "D" ) ); const PAGE_INFO PAGE_INFO::pageE( wxSize( 44000, 34000 ), wxT( "E" ) ); const PAGE_INFO PAGE_INFO::pageGERBER(wxSize( 32000, 32000 ), wxT( "GERBER" ) ); const PAGE_INFO PAGE_INFO::pageUser( wxSize( 17000, 11000 ), Custom ); int PAGE_INFO::s_user_width = 17000; int PAGE_INFO::s_user_height = 11000; /* wxArrayString PAGE_INFO::GetStandardSizes() { wxArrayString ret; static const PAGE_INFO* stdPageSizes[] = { &pageA4, &pageA3, &pageA2, &pageA1, &pageA0, &pageA, &pageB, &pageC, &pageD, &pageE, // &pageGERBER, // standard? &pageUser, }; for( unsigned i=0; i < DIM( stdPageSizes ); ++i ) ret.Add( stdPageSizes[i]->GetType() ); return ret; } */ PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) : m_type( aType ), m_size( aSizeMils ), m_portrait( false ) { #if defined(KICAD_GOST) m_left_margin = GOST_LEFTMARGIN; m_right_margin = GOST_RIGHTMARGIN; m_top_margin = GOST_TOPMARGIN; m_bottom_margin = GOST_BOTTOMMARGIN; #else m_left_margin = m_right_margin = m_top_margin = m_bottom_margin = 400; #endif } PAGE_INFO::PAGE_INFO( const wxString& aType ) { SetType( aType ); } bool PAGE_INFO::SetType( const wxString& aType ) { bool rc = true; if( aType == pageA4.GetType() ) *this = pageA4; else if( aType == pageA3.GetType() ) *this = pageA3; else if( aType == pageA2.GetType() ) *this = pageA2; else if( aType == pageA1.GetType() ) *this = pageA1; else if( aType == pageA0.GetType() ) *this = pageA0; else if( aType == pageA.GetType() ) *this = pageA; else if( aType == pageB.GetType() ) *this = pageB; else if( aType == pageC.GetType() ) *this = pageC; else if( aType == pageD.GetType() ) *this = pageD; else if( aType == pageE.GetType() ) *this = pageE; else if( aType == pageGERBER.GetType() ) *this = pageGERBER; else if( aType == pageUser.GetType() ) { // pageUser is const, and may not and does not hold the custom size, // so customize *this later *this = pageUser; // customize: m_size.x = s_user_width; m_size.y = s_user_height; } else rc = false; return rc; } bool PAGE_INFO::IsCustom() const { return m_type == Custom; } void PAGE_INFO::SetPortrait( bool isPortrait ) { if( m_portrait != isPortrait ) { // swap x and y in m_size m_size = wxSize( m_size.y, m_size.x ); m_portrait = isPortrait; // margins are not touched. } } static int clampWidth( int aWidthInMils ) { if( aWidthInMils < 4000 ) // 4" is about a baseball card aWidthInMils = 4000; else if( aWidthInMils > 44000 ) //44" is plotter size aWidthInMils = 44000; return aWidthInMils; } static int clampHeight( int aHeightInMils ) { if( aHeightInMils < 4000 ) aHeightInMils = 4000; else if( aHeightInMils > 44000 ) aHeightInMils = 44000; return aHeightInMils; } void PAGE_INFO::SetUserWidthMils( int aWidthInMils ) { s_user_width = clampWidth( aWidthInMils ); } void PAGE_INFO::SetUserHeightMils( int aHeightInMils ) { s_user_height = clampHeight( aHeightInMils ); } void PAGE_INFO::SetWidthMils( int aWidthInMils ) { m_size.x = clampWidth( aWidthInMils ); } int PAGE_INFO::GetWidthMils() const { return m_size.x; } void PAGE_INFO::SetHeightMils( int aHeightInMils ) { m_size.y = clampHeight( aHeightInMils ); } int PAGE_INFO::GetHeightMils() const { return m_size.y; } const wxSize& PAGE_INFO::GetSizeMils() const { return m_size; }
common/common.cpp +0 −192 Original line number Original line Diff line number Diff line Loading @@ -174,198 +174,6 @@ bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString ) } } //-----<PAGE_INFO>------------------------------------------------------------- // Standard page sizes in mils, all constants #if defined(KICAD_GOST) const PAGE_INFO PAGE_INFO::pageA4( wxSize( 8283, 11700 ), wxT( "A4" ) ); #else const PAGE_INFO PAGE_INFO::pageA4( wxSize( 11700, 8267 ), wxT( "A4" ) ); #endif const PAGE_INFO PAGE_INFO::pageA3( wxSize( 16535, 11700 ), wxT( "A3" ) ); const PAGE_INFO PAGE_INFO::pageA2( wxSize( 23400, 16535 ), wxT( "A2" ) ); const PAGE_INFO PAGE_INFO::pageA1( wxSize( 33070, 23400 ), wxT( "A1" ) ); const PAGE_INFO PAGE_INFO::pageA0( wxSize( 46800, 33070 ), wxT( "A0" ) ); const PAGE_INFO PAGE_INFO::pageA( wxSize( 11000, 8500 ), wxT( "A" ) ); const PAGE_INFO PAGE_INFO::pageB( wxSize( 17000, 11000 ), wxT( "B" ) ); const PAGE_INFO PAGE_INFO::pageC( wxSize( 22000, 17000 ), wxT( "C" ) ); const PAGE_INFO PAGE_INFO::pageD( wxSize( 34000, 22000 ), wxT( "D" ) ); const PAGE_INFO PAGE_INFO::pageE( wxSize( 44000, 34000 ), wxT( "E" ) ); const PAGE_INFO PAGE_INFO::pageGERBER(wxSize( 32000, 32000 ), wxT( "GERBER" ) ); const PAGE_INFO PAGE_INFO::pageUser( wxSize( 17000, 11000 ), wxT( "User" ) ); int PAGE_INFO::s_user_width = 17000; int PAGE_INFO::s_user_height = 11000; /* wxArrayString PAGE_INFO::GetStandardSizes() { wxArrayString ret; static const PAGE_INFO* stdPageSizes[] = { &pageA4, &pageA3, &pageA2, &pageA1, &pageA0, &pageA, &pageB, &pageC, &pageD, &pageE, // &pageGERBER, // standard? &pageUser, }; for( unsigned i=0; i < DIM( stdPageSizes ); ++i ) ret.Add( stdPageSizes[i]->GetType() ); return ret; } */ PAGE_INFO::PAGE_INFO( const wxSize& aSizeMils, const wxString& aType ) : m_type( aType ), m_size( aSizeMils ), m_portrait( false ) { #if defined(KICAD_GOST) m_left_margin = GOST_LEFTMARGIN; m_right_margin = GOST_RIGHTMARGIN; m_top_margin = GOST_TOPMARGIN; m_bottom_margin = GOST_BOTTOMMARGIN; #else m_left_margin = m_right_margin = m_top_margin = m_bottom_margin = 400; #endif } PAGE_INFO::PAGE_INFO( const wxString& aType ) { SetType( aType ); } bool PAGE_INFO::SetType( const wxString& aType ) { bool rc = true; if( aType == pageA4.GetType() ) *this = pageA4; else if( aType == pageA3.GetType() ) *this = pageA3; else if( aType == pageA2.GetType() ) *this = pageA2; else if( aType == pageA1.GetType() ) *this = pageA1; else if( aType == pageA0.GetType() ) *this = pageA0; else if( aType == pageA.GetType() ) *this = pageA; else if( aType == pageB.GetType() ) *this = pageB; else if( aType == pageC.GetType() ) *this = pageC; else if( aType == pageD.GetType() ) *this = pageD; else if( aType == pageE.GetType() ) *this = pageE; else if( aType == pageGERBER.GetType() ) *this = pageGERBER; else if( aType == pageUser.GetType() ) { // pageUser is const, and may not and does not hold the custom size, // so customize *this later *this = pageUser; // customize: m_size.x = s_user_width; m_size.y = s_user_height; } else rc = false; return rc; } void PAGE_INFO::SetPortrait( bool isPortrait ) { if( m_portrait != isPortrait ) { // swap x and y in m_size m_size = wxSize( m_size.y, m_size.x ); m_portrait = isPortrait; // margins are not touched. } } static int clampWidth( int aWidthInMils ) { if( aWidthInMils < 4000 ) // 4" is about a baseball card aWidthInMils = 4000; else if( aWidthInMils > 44000 ) //44" is plotter size aWidthInMils = 44000; return aWidthInMils; } static int clampHeight( int aHeightInMils ) { if( aHeightInMils < 4000 ) aHeightInMils = 4000; else if( aHeightInMils > 44000 ) aHeightInMils = 44000; return aHeightInMils; } void PAGE_INFO::SetUserWidthMils( int aWidthInMils ) { s_user_width = clampWidth( aWidthInMils ); } void PAGE_INFO::SetUserHeightMils( int aHeightInMils ) { s_user_height = clampHeight( aHeightInMils ); } void PAGE_INFO::SetWidthMils( int aWidthInMils ) { m_size.x = clampWidth( aWidthInMils ); } int PAGE_INFO::GetWidthMils() const { return m_size.x; } void PAGE_INFO::SetHeightMils( int aHeightInMils ) { m_size.y = clampHeight( aHeightInMils ); } int PAGE_INFO::GetHeightMils() const { return m_size.y; } const wxSize& PAGE_INFO::GetSizeMils() const { return m_size; } //-----</PAGE_INFO>------------------------------------------------------------ wxString ReturnUnitSymbol( EDA_UNITS_T aUnit, const wxString& formatString ) wxString ReturnUnitSymbol( EDA_UNITS_T aUnit, const wxString& formatString ) { { wxString tmp; wxString tmp; Loading
common/common_plotPS_functions.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -392,12 +392,12 @@ bool PS_PLOTTER::start_plot( FILE* fout ) // converted to internal units. // converted to internal units. wxSize pageSize = pageInfo.GetSizeMils(); wxSize pageSize = pageInfo.GetSizeMils(); if( pageInfo.GetType().Cmp( wxT( "User" ) ) == 0 ) if( pageInfo.IsCustom() ) fprintf( output_file, "%%%%DocumentMedia: Custom %d %d 0 () ()\n", fprintf( output_file, "%%%%DocumentMedia: Custom %d %d 0 () ()\n", wxRound( pageSize.y * 10 * CONV_SCALE ), wxRound( pageSize.y * 10 * CONV_SCALE ), wxRound( pageSize.x * 10 * CONV_SCALE ) ); wxRound( pageSize.x * 10 * CONV_SCALE ) ); else // ( if sheet->m_Name does not equal "User" ) else // a standard paper size fprintf( output_file, "%%%%DocumentMedia: %s %d %d 0 () ()\n", fprintf( output_file, "%%%%DocumentMedia: %s %d %d 0 () ()\n", TO_UTF8( pageInfo.GetType() ), TO_UTF8( pageInfo.GetType() ), wxRound( pageSize.y * 10 * CONV_SCALE ), wxRound( pageSize.y * 10 * CONV_SCALE ), Loading
common/dialogs/dialog_page_settings.cpp +5 −5 Original line number Original line Diff line number Diff line Loading @@ -37,7 +37,7 @@ void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event ) DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent ) : DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent ) : DIALOG_PAGES_SETTINGS_BASE( parent ), DIALOG_PAGES_SETTINGS_BASE( parent ), m_user_size( wxT( "User" ) ) m_user_size( PAGE_INFO::Custom ) { { m_Parent = parent; m_Parent = parent; m_Screen = m_Parent->GetScreen(); m_Screen = m_Parent->GetScreen(); Loading Loading @@ -74,7 +74,7 @@ void DIALOG_PAGES_SETTINGS::initDialog() const PAGE_INFO& pageInfo = m_Parent->GetPageSettings(); const PAGE_INFO& pageInfo = m_Parent->GetPageSettings(); if( wxT( "User" ) != pageInfo.GetType() ) if( !pageInfo.IsCustom() ) m_landscapeCheckbox->SetValue( !pageInfo.IsPortrait() ); m_landscapeCheckbox->SetValue( !pageInfo.IsPortrait() ); setCurrentPageSizeSelection( pageInfo.GetType() ); setCurrentPageSizeSelection( pageInfo.GetType() ); Loading Loading @@ -177,7 +177,7 @@ void DIALOG_PAGES_SETTINGS::OnCancelClick( wxCommandEvent& event ) void DIALOG_PAGES_SETTINGS::onRadioButtonSelected() void DIALOG_PAGES_SETTINGS::onRadioButtonSelected() { { if( wxT( "User" ) == m_PageSizeBox->GetStringSelection() ) if( PAGE_INFO::Custom == m_PageSizeBox->GetStringSelection() ) { { m_landscapeCheckbox->Enable( false ); m_landscapeCheckbox->Enable( false ); } } Loading Loading @@ -246,10 +246,10 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings( wxCommandEvent& event ) wxString paperType = m_PageSizeBox->GetString( radioSelection ); wxString paperType = m_PageSizeBox->GetString( radioSelection ); // construct pageInfo _after_ user settings have been established in case the // construct pageInfo _after_ user settings have been established in case the // paperType is "User", otherwise User with and height will not go into effect right away. // paperType is custom, otherwise User width and height will not go into effect right away. PAGE_INFO pageInfo( paperType ); PAGE_INFO pageInfo( paperType ); if( wxT( "User" ) != paperType ) if( PAGE_INFO::Custom != paperType ) pageInfo.SetPortrait( !m_landscapeCheckbox->IsChecked() ); pageInfo.SetPortrait( !m_landscapeCheckbox->IsChecked() ); m_Parent->SetPageSettings( pageInfo ); m_Parent->SetPageSettings( pageInfo ); Loading