Browse Source
fix syntax error in kicad_plugin.cpp, carve out class_page_info.cpp, and add PAGE_INFO::Custom
pull/1/head
fix syntax error in kicad_plugin.cpp, carve out class_page_info.cpp, and add PAGE_INFO::Custom
pull/1/head
10 changed files with 251 additions and 211 deletions
-
1common/CMakeLists.txt
-
222common/class_page_info.cpp
-
192common/common.cpp
-
4common/common_plotPS_functions.cpp
-
10common/dialogs/dialog_page_settings.cpp
-
4eeschema/load_one_schematic_file.cpp
-
2eeschema/sch_screen.cpp
-
9include/common.h
-
8pcbnew/ioascii.cpp
-
10pcbnew/kicad_plugin.cpp
@ -0,0 +1,222 @@ |
|||
/*
|
|||
* 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; |
|||
} |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue