Move to a fixed enum for page sizes as well as well as holding a list of types accessible in a vector.

Drops some hardcoded size names in places among other bits.

Woooo committed pushed at 36000 feet.
This commit is contained in:
Mark Roszko 2025-09-13 20:08:38 +02:00
parent ca7059b487
commit 1e9025a4dc
24 changed files with 185 additions and 281 deletions

View File

@ -51,33 +51,6 @@
#define MAX_PAGE_EXAMPLE_SIZE 200 #define MAX_PAGE_EXAMPLE_SIZE 200
// List of page formats.
// they are prefixed by "_HKI" (already in use for hotkeys) instead of "_",
// because we need both the translated and the not translated version.
// when displayed in dialog we should explicitly call wxGetTranslation()
// to show the translated version.
// See hotkeys_basic.h for more info
#define _HKI( x ) wxT( x )
static const wxString pageFmts[] =
{
_HKI("A5 148x210mm"),
_HKI("A4 210x297mm"),
_HKI("A3 297x420mm"),
_HKI("A2 420x594mm"),
_HKI("A1 594x841mm"),
_HKI("A0 841x1189mm"),
_HKI("A 8.5x11in"),
_HKI("B 11x17in"),
_HKI("C 17x22in"),
_HKI("D 22x34in"),
_HKI("E 34x44in"),
_HKI("USLetter 8.5x11in"), // USLetter without space is correct
_HKI("USLegal 8.5x14in"), // USLegal without space is correct
_HKI("USLedger 11x17in"), // USLedger without space is correct
_HKI("User (Custom)"), // size defined by user. The string must contain "Custom"
// to be recognized in code
};
DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* aParent, EMBEDDED_FILES* aEmbeddedFiles, DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* aParent, EMBEDDED_FILES* aEmbeddedFiles,
double aIuPerMils, const VECTOR2D& aMaxUserSizeMils ) : double aIuPerMils, const VECTOR2D& aMaxUserSizeMils ) :
DIALOG_PAGES_SETTINGS_BASE( aParent ), DIALOG_PAGES_SETTINGS_BASE( aParent ),
@ -141,17 +114,25 @@ bool DIALOG_PAGES_SETTINGS::TransferDataToWindow()
// The first shows translated strings, the second contains not translated strings // The first shows translated strings, the second contains not translated strings
m_paperSizeComboBox->Clear(); m_paperSizeComboBox->Clear();
for( const wxString& pageFmt : pageFmts ) int selectedIdx = -1;
m_pageInfo = m_parent->GetPageSettings();
for( const PAGE_INFO& pageFmt : PAGE_INFO::GetPageFormatsList() )
{ {
m_pageFmt.Add( pageFmt ); int idx = m_paperSizeComboBox->Append( wxGetTranslation( pageFmt.GetPageFormatDescription() ),
m_paperSizeComboBox->Append( wxGetTranslation( pageFmt ) ); reinterpret_cast<void*>( static_cast<intptr_t>( pageFmt.GetType() ) ) );
if( pageFmt.GetType() == m_pageInfo.GetType() )
{
selectedIdx = idx;
}
} }
m_paperSizeComboBox->SetSelection( selectedIdx );
// initialize the drawing sheet filename // initialize the drawing sheet filename
SetWksFileName( BASE_SCREEN::m_DrawingSheetFileName ); SetWksFileName( BASE_SCREEN::m_DrawingSheetFileName );
m_pageInfo = m_parent->GetPageSettings();
SetCurrentPageSizeSelection( m_pageInfo.GetType() );
m_orientationComboBox->SetSelection( m_pageInfo.IsPortrait() ); m_orientationComboBox->SetSelection( m_pageInfo.IsPortrait() );
// only a click fires the "selection changed" event, so have to fabricate this check // only a click fires the "selection changed" event, so have to fabricate this check
@ -217,9 +198,10 @@ bool DIALOG_PAGES_SETTINGS::TransferDataToWindow()
bool DIALOG_PAGES_SETTINGS::TransferDataFromWindow() bool DIALOG_PAGES_SETTINGS::TransferDataFromWindow()
{ {
int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 ); int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
const wxString paperType = m_pageFmt[idx]; void* clientData = m_paperSizeComboBox->GetClientData( idx );
PAGE_SIZE_TYPE pageType = static_cast<PAGE_SIZE_TYPE>( reinterpret_cast<intptr_t>( clientData ) );
if( paperType.Contains( PAGE_INFO::Custom ) ) if( pageType == PAGE_SIZE_TYPE::User )
{ {
if( !m_customSizeX.Validate( MIN_PAGE_SIZE_MILS, m_maxPageSizeMils.x, EDA_UNITS::MILS ) ) if( !m_customSizeX.Validate( MIN_PAGE_SIZE_MILS, m_maxPageSizeMils.x, EDA_UNITS::MILS ) )
return false; return false;
@ -250,9 +232,10 @@ void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )
if( idx < 0 ) if( idx < 0 )
idx = 0; idx = 0;
const wxString paperType = m_pageFmt[idx]; void* clientData = m_paperSizeComboBox->GetClientData( idx );
PAGE_SIZE_TYPE pageType = static_cast<PAGE_SIZE_TYPE>( reinterpret_cast<intptr_t>( clientData ) );
if( paperType.Contains( PAGE_INFO::Custom ) ) if( pageType == PAGE_SIZE_TYPE::User )
{ {
m_staticTextOrient->Enable( false ); m_staticTextOrient->Enable( false );
m_orientationComboBox->Enable( false ); m_orientationComboBox->Enable( false );
@ -482,14 +465,15 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
m_localPrjConfigChanged = true; m_localPrjConfigChanged = true;
int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 ); int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
const wxString paperType = m_pageFmt[idx]; void* clientData = m_paperSizeComboBox->GetClientData( idx );
PAGE_SIZE_TYPE pageType = static_cast<PAGE_SIZE_TYPE>( reinterpret_cast<intptr_t>( clientData ) );
if( paperType.Contains( PAGE_INFO::Custom ) ) if( pageType == PAGE_SIZE_TYPE::User )
{ {
GetCustomSizeMilsFromDialog(); GetCustomSizeMilsFromDialog();
success = m_pageInfo.SetType( PAGE_INFO::Custom ); success = m_pageInfo.SetType( PAGE_SIZE_TYPE::User );
if( success ) if( success )
{ {
@ -502,22 +486,7 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
} }
else else
{ {
// search for longest common string first, e.g. A4 before A success = m_pageInfo.SetType( pageType );
if( paperType.Contains( PAGE_INFO::USLetter ) ) success = m_pageInfo.SetType( PAGE_INFO::USLetter );
else if( paperType.Contains( PAGE_INFO::USLegal ) ) success = m_pageInfo.SetType( PAGE_INFO::USLegal );
else if( paperType.Contains( PAGE_INFO::USLedger ) ) success = m_pageInfo.SetType( PAGE_INFO::USLedger );
else if( paperType.Contains( PAGE_INFO::GERBER ) ) success = m_pageInfo.SetType( PAGE_INFO::GERBER );
else if( paperType.Contains( PAGE_INFO::A5 ) ) success = m_pageInfo.SetType( PAGE_INFO::A5 );
else if( paperType.Contains( PAGE_INFO::A4 ) ) success = m_pageInfo.SetType( PAGE_INFO::A4 );
else if( paperType.Contains( PAGE_INFO::A3 ) ) success = m_pageInfo.SetType( PAGE_INFO::A3 );
else if( paperType.Contains( PAGE_INFO::A2 ) ) success = m_pageInfo.SetType( PAGE_INFO::A2 );
else if( paperType.Contains( PAGE_INFO::A1 ) ) success = m_pageInfo.SetType( PAGE_INFO::A1 );
else if( paperType.Contains( PAGE_INFO::A0 ) ) success = m_pageInfo.SetType( PAGE_INFO::A0 );
else if( paperType.Contains( PAGE_INFO::A ) ) success = m_pageInfo.SetType( PAGE_INFO::A );
else if( paperType.Contains( PAGE_INFO::B ) ) success = m_pageInfo.SetType( PAGE_INFO::B );
else if( paperType.Contains( PAGE_INFO::C ) ) success = m_pageInfo.SetType( PAGE_INFO::C );
else if( paperType.Contains( PAGE_INFO::D ) ) success = m_pageInfo.SetType( PAGE_INFO::D );
else if( paperType.Contains( PAGE_INFO::E ) ) success = m_pageInfo.SetType( PAGE_INFO::E );
if( success ) if( success )
{ {
@ -529,7 +498,7 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
if( !success ) if( !success )
{ {
wxFAIL_MSG( "The translation for paper size must preserve original spellings" ); wxFAIL_MSG( "The translation for paper size must preserve original spellings" );
m_pageInfo.SetType( PAGE_INFO::A4 ); m_pageInfo.SetType( PAGE_SIZE_TYPE::A4 );
} }
m_parent->SetPageSettings( m_pageInfo ); m_parent->SetPageSettings( m_pageInfo );
@ -554,26 +523,6 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings()
} }
void DIALOG_PAGES_SETTINGS::SetCurrentPageSizeSelection( const wxString& aPaperSize )
{
// search all the not translated label list containing our paper type
for( unsigned i = 0; i < m_pageFmt.GetCount(); ++i )
{
// parse each label looking for aPaperSize within it
wxStringTokenizer st( m_pageFmt[i] );
while( st.HasMoreTokens() )
{
if( st.GetNextToken() == aPaperSize )
{
m_paperSizeComboBox->SetSelection( i );
return;
}
}
}
}
void DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample() void DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample()
{ {
int lyWidth, lyHeight; int lyWidth, lyHeight;
@ -629,9 +578,11 @@ void DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample()
if( idx < 0 ) if( idx < 0 )
idx = 0; idx = 0;
wxString pageFmtName = m_pageFmt[idx].BeforeFirst( ' ' ); void* clientData = m_paperSizeComboBox->GetClientData( idx );
PAGE_SIZE_TYPE pageType = static_cast<PAGE_SIZE_TYPE>( reinterpret_cast<intptr_t>( clientData ) );
bool portrait = clamped_layout_size.x < clamped_layout_size.y; bool portrait = clamped_layout_size.x < clamped_layout_size.y;
pageDUMMY.SetType( pageFmtName, portrait ); pageDUMMY.SetType( pageType, portrait );
if( m_customFmt ) if( m_customFmt )
{ {
@ -681,11 +632,11 @@ void DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample()
void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog() void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog()
{ {
int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 ); int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
const wxString paperType = m_pageFmt[idx]; void* clientData = m_paperSizeComboBox->GetClientData( idx );
PAGE_SIZE_TYPE pageType = static_cast<PAGE_SIZE_TYPE>( reinterpret_cast<intptr_t>( clientData ) );
// here we assume translators will keep original paper size spellings if( pageType == PAGE_SIZE_TYPE::User )
if( paperType.Contains( PAGE_INFO::Custom ) )
{ {
GetCustomSizeMilsFromDialog(); GetCustomSizeMilsFromDialog();
@ -701,36 +652,7 @@ void DIALOG_PAGES_SETTINGS::GetPageLayoutInfoFromDialog()
{ {
PAGE_INFO pageInfo; // SetType() later to lookup size PAGE_INFO pageInfo; // SetType() later to lookup size
static const wxChar* papers[] = { pageInfo.SetType( pageType );
// longest common string first, since sequential search below
PAGE_INFO::A5,
PAGE_INFO::A4,
PAGE_INFO::A3,
PAGE_INFO::A2,
PAGE_INFO::A1,
PAGE_INFO::A0,
PAGE_INFO::A,
PAGE_INFO::B,
PAGE_INFO::C,
PAGE_INFO::D,
PAGE_INFO::E,
PAGE_INFO::USLetter,
PAGE_INFO::USLegal,
PAGE_INFO::USLedger,
};
unsigned i;
for( i=0; i < arrayDim( papers ); ++i )
{
if( paperType.Contains( papers[i] ) )
{
pageInfo.SetType( papers[i] );
break;
}
}
wxASSERT( i != arrayDim(papers) ); // dialog UI match the above list?
VECTOR2D sz = pageInfo.GetSizeMils(); VECTOR2D sz = pageInfo.GetSizeMils();
m_layout_size = VECTOR2D( sz.x, sz.y ); m_layout_size = VECTOR2D( sz.x, sz.y );

View File

@ -549,7 +549,7 @@ void DS_DRAW_ITEM_LIST::BuildDrawItemsList( const PAGE_INFO& aPageInfo,
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance(); DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
m_titleBlock = &aTitleBlock; m_titleBlock = &aTitleBlock;
m_paperFormat = aPageInfo.GetType(); m_paperFormat = aPageInfo.GetTypeAsString();
// Build the basic layout shape, if the layout list is empty // Build the basic layout shape, if the layout list is empty
if( model.GetCount() == 0 && !model.VoidListAllowed() ) if( model.GetCount() == 0 && !model.VoidListAllowed() )

View File

@ -27,36 +27,7 @@
#include <eda_units.h> #include <eda_units.h>
#include <richio.h> // for OUTPUTFORMATTER and IO_ERROR #include <richio.h> // for OUTPUTFORMATTER and IO_ERROR
#include <string_utils.h> #include <string_utils.h>
#include <magic_enum.hpp>
// late arriving wxPAPER_A0, wxPAPER_A1
#if wxABI_VERSION >= 20999
#define PAPER_A0 wxPAPER_A0
#define PAPER_A1 wxPAPER_A1
#else
#define PAPER_A0 wxPAPER_A2
#define PAPER_A1 wxPAPER_A2
#endif
// Standard paper sizes nicknames.
const wxChar PAGE_INFO::A5[] = wxT( "A5" );
const wxChar PAGE_INFO::A4[] = wxT( "A4" );
const wxChar PAGE_INFO::A3[] = wxT( "A3" );
const wxChar PAGE_INFO::A2[] = wxT( "A2" );
const wxChar PAGE_INFO::A1[] = wxT( "A1" );
const wxChar PAGE_INFO::A0[] = wxT( "A0" );
const wxChar PAGE_INFO::A[] = wxT( "A" );
const wxChar PAGE_INFO::B[] = wxT( "B" );
const wxChar PAGE_INFO::C[] = wxT( "C" );
const wxChar PAGE_INFO::D[] = wxT( "D" );
const wxChar PAGE_INFO::E[] = wxT( "E" );
const wxChar PAGE_INFO::GERBER[] = wxT( "GERBER" );
const wxChar PAGE_INFO::USLetter[] = wxT( "USLetter" );
const wxChar PAGE_INFO::USLegal[] = wxT( "USLegal" );
const wxChar PAGE_INFO::USLedger[] = wxT( "USLedger" );
const wxChar PAGE_INFO::Custom[] = wxT( "User" );
// Standard page sizes in mils, all constants // Standard page sizes in mils, all constants
@ -66,29 +37,34 @@ const wxChar PAGE_INFO::Custom[] = wxT( "User" );
// local readability macro for millimeter wxSize // local readability macro for millimeter wxSize
#define MMsize( x, y ) VECTOR2D( EDA_UNIT_UTILS::Mm2mils( x ), EDA_UNIT_UTILS::Mm2mils( y ) ) #define MMsize( x, y ) VECTOR2D( EDA_UNIT_UTILS::Mm2mils( x ), EDA_UNIT_UTILS::Mm2mils( y ) )
// All MUST be defined as landscape. // List of page formats.
const PAGE_INFO PAGE_INFO::pageA5( MMsize( 210, 148 ), wxT( "A5" ), wxPAPER_A5 ); // they are prefixed by "_HKI" (already in use for hotkeys) instead of "_",
const PAGE_INFO PAGE_INFO::pageA4( MMsize( 297, 210 ), wxT( "A4" ), wxPAPER_A4 ); // because we need both the translated and the not translated version.
const PAGE_INFO PAGE_INFO::pageA3( MMsize( 420, 297 ), wxT( "A3" ), wxPAPER_A3 ); // when displayed in dialog we should explicitly call wxGetTranslation()
const PAGE_INFO PAGE_INFO::pageA2( MMsize( 594, 420 ), wxT( "A2" ), wxPAPER_A2 ); #define _HKI( x ) wxT( x )
const PAGE_INFO PAGE_INFO::pageA1( MMsize( 841, 594 ), wxT( "A1" ), PAPER_A1 );
const PAGE_INFO PAGE_INFO::pageA0( MMsize( 1189, 841 ), wxT( "A0" ), PAPER_A0 );
const PAGE_INFO PAGE_INFO::pageA( VECTOR2D( 11000, 8500 ), wxT( "A" ), wxPAPER_LETTER ); std::vector<PAGE_INFO> PAGE_INFO::standardPageSizes = {
const PAGE_INFO PAGE_INFO::pageB( VECTOR2D( 17000, 11000 ), wxT( "B" ), wxPAPER_TABLOID ); // All MUST be defined as landscape.
const PAGE_INFO PAGE_INFO::pageC( VECTOR2D( 22000, 17000 ), wxT( "C" ), wxPAPER_CSHEET ); PAGE_INFO( MMsize( 210, 148 ), PAGE_SIZE_TYPE::A5, wxPAPER_A5, _HKI( "A5 148 x 210mm" ) ),
const PAGE_INFO PAGE_INFO::pageD( VECTOR2D( 34000, 22000 ), wxT( "D" ), wxPAPER_DSHEET ); PAGE_INFO( MMsize( 297, 210 ), PAGE_SIZE_TYPE::A4, wxPAPER_A4, _HKI( "A4 210 x 297mm" ) ),
const PAGE_INFO PAGE_INFO::pageE( VECTOR2D( 44000, 34000 ), wxT( "E" ), wxPAPER_ESHEET ); PAGE_INFO( MMsize( 420, 297 ), PAGE_SIZE_TYPE::A3, wxPAPER_A3, _HKI( "A3 297 x 420mm" ) ),
PAGE_INFO( MMsize( 594, 420 ), PAGE_SIZE_TYPE::A2, wxPAPER_A2, _HKI( "A2 420 x 594mm" ) ),
PAGE_INFO( MMsize( 841, 594 ), PAGE_SIZE_TYPE::A1, wxPAPER_A1, _HKI( "A1 594 x 841mm" ) ),
PAGE_INFO( MMsize( 1189, 841 ), PAGE_SIZE_TYPE::A0, wxPAPER_A0, _HKI( "A0 841 x 1189mm" ) ),
PAGE_INFO( VECTOR2D( 11000, 8500 ), PAGE_SIZE_TYPE::A, wxPAPER_LETTER, _HKI( "A 8.5 x 11in" ) ),
PAGE_INFO( VECTOR2D( 17000, 11000 ), PAGE_SIZE_TYPE::B, wxPAPER_TABLOID, _HKI( "B 11 x 17in" ) ),
PAGE_INFO( VECTOR2D( 22000, 17000 ), PAGE_SIZE_TYPE::C, wxPAPER_CSHEET, _HKI( "C 17 x 22in" ) ),
PAGE_INFO( VECTOR2D( 34000, 22000 ), PAGE_SIZE_TYPE::D, wxPAPER_DSHEET, _HKI( "D 22 x 34in" ) ),
PAGE_INFO( VECTOR2D( 44000, 34000 ), PAGE_SIZE_TYPE::E, wxPAPER_ESHEET, _HKI( "E 34 x 44in" ) ),
const PAGE_INFO PAGE_INFO::pageGERBER( VECTOR2D( 32000, 32000 ), wxT( "GERBER" ), wxPAPER_NONE ); // US paper sizes
const PAGE_INFO PAGE_INFO::pageUser( VECTOR2D( 17000, 11000 ), Custom, wxPAPER_NONE ); PAGE_INFO( VECTOR2D( 32000, 32000 ), PAGE_SIZE_TYPE::GERBER, wxPAPER_NONE ),
PAGE_INFO( VECTOR2D( 17000, 11000 ), PAGE_SIZE_TYPE::User, wxPAPER_NONE, _HKI( "User (Custom)" ) ),
// US paper sizes PAGE_INFO( VECTOR2D( 11000, 8500 ), PAGE_SIZE_TYPE::USLetter, wxPAPER_LETTER, _HKI("US Letter 8.5 x 11in") ),
const PAGE_INFO PAGE_INFO::pageUSLetter( VECTOR2D( 11000, 8500 ), wxT( "USLetter" ), PAGE_INFO( VECTOR2D( 14000, 8500 ), PAGE_SIZE_TYPE::USLegal, wxPAPER_LEGAL, _HKI("US Legal 8.5 x 14in") ),
wxPAPER_LETTER ); PAGE_INFO( VECTOR2D( 17000, 11000 ), PAGE_SIZE_TYPE::USLedger, wxPAPER_TABLOID, _HKI("US Ledger 11 x 17in") )
const PAGE_INFO PAGE_INFO::pageUSLegal( VECTOR2D( 14000, 8500 ), wxT( "USLegal" ), wxPAPER_LEGAL ); };
const PAGE_INFO PAGE_INFO::pageUSLedger( VECTOR2D( 17000, 11000 ), wxT( "USLedger" ),
wxPAPER_TABLOID );
// Custom paper size for next instantiation of type "User" // Custom paper size for next instantiation of type "User"
double PAGE_INFO::s_user_width = 17000; double PAGE_INFO::s_user_width = 17000;
@ -102,8 +78,12 @@ inline void PAGE_INFO::updatePortrait()
} }
PAGE_INFO::PAGE_INFO( const VECTOR2D& aSizeMils, const wxString& aType, wxPaperSize aPaperId ) : PAGE_INFO::PAGE_INFO( const VECTOR2D& aSizeMils, PAGE_SIZE_TYPE aType, wxPaperSize aPaperId,
m_type( aType ), m_size( aSizeMils ), m_paper_id( aPaperId ) const wxString& aDescription ) :
m_type( aType ),
m_size( aSizeMils ),
m_paper_id( aPaperId ),
m_description( aDescription )
{ {
updatePortrait(); updatePortrait();
@ -113,61 +93,52 @@ PAGE_INFO::PAGE_INFO( const VECTOR2D& aSizeMils, const wxString& aType, wxPaperS
} }
PAGE_INFO::PAGE_INFO( const wxString& aType, bool aIsPortrait ) PAGE_INFO::PAGE_INFO( PAGE_SIZE_TYPE aType, bool aIsPortrait )
{ {
SetType( aType, aIsPortrait ); SetType( aType, aIsPortrait );
} }
bool PAGE_INFO::SetType( const wxString& aType, bool aIsPortrait ) bool PAGE_INFO::SetType( const wxString& aPageSize, bool aIsPortrait )
{
auto type =
magic_enum::enum_cast<PAGE_SIZE_TYPE>( aPageSize.ToStdString(), magic_enum::case_insensitive );
if( !type.has_value() )
return false;
return SetType( type.value(), aIsPortrait );
}
bool PAGE_INFO::SetType( PAGE_SIZE_TYPE aType, bool aIsPortrait )
{ {
bool rc = true; bool rc = true;
// all are landscape initially auto result = std::find_if( standardPageSizes.begin(), standardPageSizes.end(),
if( aType == pageA5.GetType() ) [aType]( const PAGE_INFO& p )
*this = pageA5; {
else if( aType == pageA4.GetType() ) return p.m_type == aType;
*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 == pageUSLetter.GetType() )
*this = pageUSLetter;
else if( aType == pageUSLegal.GetType() )
*this = pageUSLegal;
else if( aType == pageUSLedger.GetType() )
*this = pageUSLedger;
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: if( result != standardPageSizes.end() )
{
*this = *result;
}
else
{
rc = false;
}
if( aType == PAGE_SIZE_TYPE::User )
{
m_type = PAGE_SIZE_TYPE::User;
m_paper_id = wxPAPER_NONE;
m_size.x = s_user_width; m_size.x = s_user_width;
m_size.y = s_user_height; m_size.y = s_user_height;
updatePortrait(); updatePortrait();
} }
else
rc = false;
if( aIsPortrait ) if( aIsPortrait )
{ {
@ -180,9 +151,16 @@ bool PAGE_INFO::SetType( const wxString& aType, bool aIsPortrait )
} }
wxString PAGE_INFO::GetTypeAsString() const
{
std::string typeStr( magic_enum::enum_name( m_type ) );
return wxString( typeStr );
}
bool PAGE_INFO::IsCustom() const bool PAGE_INFO::IsCustom() const
{ {
return m_type == Custom; return m_type == PAGE_SIZE_TYPE::User;
} }
@ -251,7 +229,7 @@ void PAGE_INFO::SetWidthMils( double aWidthInMils )
{ {
m_size.x = clampWidth( aWidthInMils ); m_size.x = clampWidth( aWidthInMils );
m_type = Custom; m_type = PAGE_SIZE_TYPE::User;
m_paper_id = wxPAPER_NONE; m_paper_id = wxPAPER_NONE;
updatePortrait(); updatePortrait();
@ -265,7 +243,7 @@ void PAGE_INFO::SetHeightMils( double aHeightInMils )
{ {
m_size.y = clampHeight( aHeightInMils ); m_size.y = clampHeight( aHeightInMils );
m_type = Custom; m_type = PAGE_SIZE_TYPE::User;
m_paper_id = wxPAPER_NONE; m_paper_id = wxPAPER_NONE;
updatePortrait(); updatePortrait();
@ -275,11 +253,12 @@ void PAGE_INFO::SetHeightMils( double aHeightInMils )
void PAGE_INFO::Format( OUTPUTFORMATTER* aFormatter ) const void PAGE_INFO::Format( OUTPUTFORMATTER* aFormatter ) const
{ {
aFormatter->Print( "(paper %s", aFormatter->Quotew( GetType() ).c_str() ); std::string typeStr( magic_enum::enum_name( GetType() ) );
aFormatter->Print( "(paper %s", aFormatter->Quotew( typeStr ).c_str() );
// The page dimensions are only required for user defined page sizes. // The page dimensions are only required for user defined page sizes.
// Internally, the page size is in mils // Internally, the page size is in mils
if( GetType() == PAGE_INFO::Custom ) if( GetType() == PAGE_SIZE_TYPE::User )
{ {
aFormatter->Print( " %s %s", aFormatter->Print( " %s %s",
FormatDouble2Str( GetWidthMils() * 25.4 / 1000.0 ).c_str(), FormatDouble2Str( GetWidthMils() * 25.4 / 1000.0 ).c_str(),
@ -291,3 +270,9 @@ void PAGE_INFO::Format( OUTPUTFORMATTER* aFormatter ) const
aFormatter->Print( ")" ); aFormatter->Print( ")" );
} }
const std::vector<PAGE_INFO>& PAGE_INFO::GetPageFormatsList()
{
return PAGE_INFO::standardPageSizes;
}

View File

@ -828,7 +828,7 @@ bool PS_PLOTTER::StartPlot( const wxString& aPageNumber )
// Also note pageSize is given in mils, not in internal units and must be // Also note pageSize is given in mils, not in internal units and must be
// converted to internal units. // converted to internal units.
wxString pageType = m_pageInfo.GetType(); wxString pageType = m_pageInfo.GetTypeAsString();
if( m_pageInfo.IsCustom() ) if( m_pageInfo.IsCustom() )
pageType = "Custom"; pageType = "Custom";

View File

@ -247,7 +247,7 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems()
std::vector<DANGLING_END_ITEM> endPointsByType; std::vector<DANGLING_END_ITEM> endPointsByType;
m_page = new PAGE_INFO( PAGE_INFO::Custom ); m_page = new PAGE_INFO( PAGE_SIZE_TYPE::User );
m_titleBlock = new TITLE_BLOCK; m_titleBlock = new TITLE_BLOCK;
m_titleBlock->SetTitle( _( "Color Preview" ) ); m_titleBlock->SetTitle( _( "Color Preview" ) );
m_titleBlock->SetDate( wxDateTime::Now().FormatDate() ); m_titleBlock->SetDate( wxDateTime::Now().FormatDate() );

View File

@ -888,7 +888,7 @@ int EESCHEMA_JOBS_HANDLER::doSymExportSvg( JOB_SYM_EXPORT_SVG* aSvgJob, SCH_REND
// Get the symbol bounding box to fit the plot page to it // Get the symbol bounding box to fit the plot page to it
BOX2I symbolBB = symbol->Flatten()->GetUnitBoundingBox( unit, bodyStyle, BOX2I symbolBB = symbol->Flatten()->GetUnitBoundingBox( unit, bodyStyle,
!aSvgJob->m_includeHiddenFields ); !aSvgJob->m_includeHiddenFields );
PAGE_INFO pageInfo( PAGE_INFO::Custom ); PAGE_INFO pageInfo( PAGE_SIZE_TYPE::User );
pageInfo.SetHeightMils( schIUScale.IUToMils( symbolBB.GetHeight() * 1.2 ) ); pageInfo.SetHeightMils( schIUScale.IUToMils( symbolBB.GetHeight() * 1.2 ) );
pageInfo.SetWidthMils( schIUScale.IUToMils( symbolBB.GetWidth() * 1.2 ) ); pageInfo.SetWidthMils( schIUScale.IUToMils( symbolBB.GetWidth() * 1.2 ) );

View File

@ -4040,7 +4040,7 @@ void SCH_IO_ALTIUM::ParseSheet( const std::map<wxString, wxString>& aProperties
{ {
PAGE_INFO::SetCustomWidthMils( schIUScale.IUToMils( m_altiumSheet->customSize.x ) ); PAGE_INFO::SetCustomWidthMils( schIUScale.IUToMils( m_altiumSheet->customSize.x ) );
PAGE_INFO::SetCustomHeightMils( schIUScale.IUToMils( m_altiumSheet->customSize.y ) ); PAGE_INFO::SetCustomHeightMils( schIUScale.IUToMils( m_altiumSheet->customSize.y ) );
pageInfo.SetType( PAGE_INFO::Custom, isPortrait ); pageInfo.SetType( PAGE_SIZE_TYPE::User, isPortrait );
} }
else else
{ {

View File

@ -424,7 +424,7 @@ void SCH_IO_KICAD_LEGACY::loadPageSettings( LINE_READER& aReader, SCH_SCREEN* aS
int pagew = parseInt( aReader, line, &line ); int pagew = parseInt( aReader, line, &line );
int pageh = parseInt( aReader, line, &line ); int pageh = parseInt( aReader, line, &line );
if( buf == PAGE_INFO::Custom ) if( pageInfo.GetType() == PAGE_SIZE_TYPE::User )
{ {
pageInfo.SetWidthMils( pagew ); pageInfo.SetWidthMils( pagew );
pageInfo.SetHeightMils( pageh ); pageInfo.SetHeightMils( pageh );
@ -1541,7 +1541,7 @@ void SCH_IO_KICAD_LEGACY::Format( SCH_SHEET* aSheet )
const TITLE_BLOCK& tb = screen->GetTitleBlock(); const TITLE_BLOCK& tb = screen->GetTitleBlock();
const PAGE_INFO& page = screen->GetPageSettings(); const PAGE_INFO& page = screen->GetPageSettings();
m_out->Print( 0, "$Descr %s %d %d%s\n", TO_UTF8( page.GetType() ), m_out->Print( 0, "$Descr %s %d %d%s\n", TO_UTF8( page.GetTypeAsString() ),
(int)page.GetWidthMils(), (int)page.GetWidthMils(),
(int)page.GetHeightMils(), (int)page.GetHeightMils(),
!page.IsCustom() && page.IsPortrait() ? " portrait" : "" ); !page.IsCustom() && page.IsPortrait() ? " portrait" : "" );

View File

@ -2120,7 +2120,7 @@ void SCH_IO_KICAD_SEXPR_PARSER::parsePAGE_INFO( PAGE_INFO& aPageInfo )
CurOffset() ); CurOffset() );
} }
if( pageType == PAGE_INFO::Custom ) if( aPageInfo.GetType() == PAGE_SIZE_TYPE::User )
{ {
double width = parseDouble( "width" ); double width = parseDouble( "width" );

View File

@ -80,7 +80,7 @@ static const wxChar DanglingProfileMask[] = wxT( "DANGLING_PROFILE" );
SCH_SCREEN::SCH_SCREEN( EDA_ITEM* aParent ) : SCH_SCREEN::SCH_SCREEN( EDA_ITEM* aParent ) :
BASE_SCREEN( aParent, SCH_SCREEN_T ), BASE_SCREEN( aParent, SCH_SCREEN_T ),
m_fileFormatVersionAtLoad( 0 ), m_fileFormatVersionAtLoad( 0 ),
m_paper( wxT( "A4" ) ), m_paper( PAGE_SIZE_TYPE::A4 ),
m_isReadOnly( false ), m_isReadOnly( false ),
m_fileExists( false ) m_fileExists( false )
{ {

View File

@ -130,7 +130,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SetIcons( icon_bundle ); SetIcons( icon_bundle );
// Be sure a page info is set. this default value will be overwritten later. // Be sure a page info is set. this default value will be overwritten later.
PAGE_INFO pageInfo( wxT( "GERBER" ) ); PAGE_INFO pageInfo( PAGE_SIZE_TYPE::GERBER );
SetLayout( new GBR_LAYOUT() ); SetLayout( new GBR_LAYOUT() );
SetPageSettings( pageInfo ); SetPageSettings( pageInfo );
@ -327,7 +327,7 @@ void GERBVIEW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
SetElementVisibility( LAYER_GERBVIEW_DRAWINGSHEET, cfg->m_Appearance.show_border_and_titleblock ); SetElementVisibility( LAYER_GERBVIEW_DRAWINGSHEET, cfg->m_Appearance.show_border_and_titleblock );
SetElementVisibility( LAYER_GERBVIEW_PAGE_LIMITS, cfg->m_Display.m_DisplayPageLimits ); SetElementVisibility( LAYER_GERBVIEW_PAGE_LIMITS, cfg->m_Display.m_DisplayPageLimits );
PAGE_INFO pageInfo( wxT( "GERBER" ) ); PAGE_INFO pageInfo( PAGE_SIZE_TYPE::GERBER );
pageInfo.SetType( cfg->m_Appearance.page_type ); pageInfo.SetType( cfg->m_Appearance.page_type );
SetPageSettings( pageInfo ); SetPageSettings( pageInfo );
@ -346,7 +346,7 @@ void GERBVIEW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
if( GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg ) ) if( GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg ) )
{ {
cfg->m_Appearance.page_type = GetPageSettings().GetType(); cfg->m_Appearance.page_type = GetPageSettings().GetTypeAsString();
m_drillFileHistory.Save( &cfg->m_DrillFileHistory ); m_drillFileHistory.Save( &cfg->m_DrillFileHistory );
m_zipFileHistory.Save( &cfg->m_ZipFileHistory ); m_zipFileHistory.Save( &cfg->m_ZipFileHistory );
@ -1196,7 +1196,10 @@ void GERBVIEW_FRAME::CommonSettingsChanged( int aFlags )
{ {
GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window ); GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
SetPageSettings( PAGE_INFO( cfg->m_Appearance.page_type ) ); PAGE_INFO pgInfo;
pgInfo.SetType( cfg->m_Appearance.page_type );
SetPageSettings( pgInfo );
SetElementVisibility( LAYER_DCODES, cfg->m_Appearance.show_dcodes ); SetElementVisibility( LAYER_DCODES, cfg->m_Appearance.show_dcodes );
} }

View File

@ -102,8 +102,6 @@ private:
// return true if changes are made, or false if not // return true if changes are made, or false if not
bool SavePageSettings(); bool SavePageSettings();
void SetCurrentPageSizeSelection( const wxString& aPaperSize );
// Update drawing sheet example // Update drawing sheet example
void UpdateDrawingSheetExample(); void UpdateDrawingSheetExample();
@ -121,7 +119,6 @@ protected:
EDA_DRAW_FRAME* m_parent; EDA_DRAW_FRAME* m_parent;
BASE_SCREEN* m_screen; BASE_SCREEN* m_screen;
wxString m_projectPath; // the curr project path wxString m_projectPath; // the curr project path
wxArrayString m_pageFmt; /// list of page sizes (not translated)
bool m_initialized; bool m_initialized;
bool m_localPrjConfigChanged; /// the page layuout filename was changed bool m_localPrjConfigChanged; /// the page layuout filename was changed
wxBitmap* m_pageBitmap; /// Temporary bitmap for the drawing sheet example. wxBitmap* m_pageBitmap; /// Temporary bitmap for the drawing sheet example.

View File

@ -30,6 +30,7 @@
#ifndef PAGE_INFO_H #ifndef PAGE_INFO_H
#define PAGE_INFO_H #define PAGE_INFO_H
#include <map>
#include <kicommon.h> #include <kicommon.h>
#include <wx/string.h> #include <wx/string.h>
#include <math/vector2d.h> #include <math/vector2d.h>
@ -46,6 +47,30 @@
class OUTPUTFORMATTER; class OUTPUTFORMATTER;
/*
* @brief Standard paper sizes nicknames
* Do not rename entires as these names are saved to file and parsed back
*/
enum class PAGE_SIZE_TYPE
{
A5,
A4,
A3,
A2,
A1,
A0,
A,
B,
C,
D,
E,
GERBER,
USLetter,
USLegal,
USLedger,
User
};
/** /**
* Describe the page size and margins of a paper page on which to eventually print or plot. * Describe the page size and margins of a paper page on which to eventually print or plot.
* *
@ -58,29 +83,11 @@ class OUTPUTFORMATTER;
class KICOMMON_API PAGE_INFO class KICOMMON_API PAGE_INFO
{ {
public: public:
PAGE_INFO( const wxString& aType = PAGE_INFO::A3, bool IsPortrait = false ); PAGE_INFO( PAGE_SIZE_TYPE aType = PAGE_SIZE_TYPE::A3, bool IsPortrait = false );
// paper size names which are part of the public API, pass to SetType() or // paper size names which are part of the public API, pass to SetType() or
// above constructor. // above constructor.
// these were once wxStrings, but it caused static construction sequence problems:
static const wxChar A5[];
static const wxChar A4[];
static const wxChar A3[];
static const wxChar A2[];
static const wxChar A1[];
static const wxChar A0[];
static const wxChar A[];
static const wxChar B[];
static const wxChar C[];
static const wxChar D[];
static const wxChar E[];
static const wxChar GERBER[];
static const wxChar USLetter[];
static const wxChar USLegal[];
static const wxChar USLedger[];
static const wxChar Custom[]; ///< "User" defined page type
/** /**
* Set the name of the page type and also the sizes and margins commonly associated with * Set the name of the page type and also the sizes and margins commonly associated with
@ -95,13 +102,17 @@ public:
* @param aIsPortrait Set to true to set page orientation to portrait mode. * @param aIsPortrait Set to true to set page orientation to portrait mode.
* @return true if @a aStandarePageDescription was a recognized type. * @return true if @a aStandarePageDescription was a recognized type.
*/ */
bool SetType( const wxString& aStandardPageDescriptionName, bool aIsPortrait = false ); bool SetType( PAGE_SIZE_TYPE aPageSize, bool aIsPortrait = false );
const wxString& GetType() const { return m_type; } bool SetType( const wxString& aPageSize, bool aIsPortrait = false );
const PAGE_SIZE_TYPE& GetType() const { return m_type; }
wxString GetTypeAsString() const;
const wxString& GetPageFormatDescription() const { return m_description; }
/** /**
* @return True if the object has the default page settings which are A3, landscape. * @return True if the object has the default page settings which are A3, landscape.
*/ */
bool IsDefault() const { return m_type == PAGE_INFO::A3 && !m_portrait; } bool IsDefault() const { return m_type == PAGE_SIZE_TYPE::A3 && !m_portrait; }
/** /**
* @return true if the type is Custom. * @return true if the type is Custom.
@ -203,39 +214,25 @@ public:
*/ */
void Format( OUTPUTFORMATTER* aFormatter ) const; void Format( OUTPUTFORMATTER* aFormatter ) const;
static const std::vector<PAGE_INFO>& GetPageFormatsList();
protected: protected:
// only the class implementation(s) may use this constructor // only the class implementation(s) may use this constructor
PAGE_INFO( const VECTOR2D& aSizeMils, const wxString& aName, wxPaperSize aPaperId ); PAGE_INFO( const VECTOR2D& aSizeMils, const PAGE_SIZE_TYPE aType, wxPaperSize aPaperId,
const wxString& aDescription = wxEmptyString );
private: private:
// standard pre-defined sizes static std::vector<PAGE_INFO> standardPageSizes;
static const PAGE_INFO pageA5;
static const PAGE_INFO pageA4;
static const PAGE_INFO pageA3;
static const PAGE_INFO pageA2;
static const PAGE_INFO pageA1;
static const PAGE_INFO pageA0;
static const PAGE_INFO pageA;
static const PAGE_INFO pageB;
static const PAGE_INFO pageC;
static const PAGE_INFO pageD;
static const PAGE_INFO pageE;
static const PAGE_INFO pageGERBER;
static const PAGE_INFO pageUSLetter;
static const PAGE_INFO pageUSLegal;
static const PAGE_INFO pageUSLedger;
static const PAGE_INFO pageUser;
// all dimensions here are in mils // all dimensions here are in mils
wxString m_type; ///< paper type: A4, A3, etc. PAGE_SIZE_TYPE m_type; ///< paper type: A4, A3, etc.
VECTOR2D m_size; ///< mils VECTOR2D m_size; ///< mils
bool m_portrait; ///< true if portrait, false if landscape bool m_portrait; ///< true if portrait, false if landscape
wxPaperSize m_paper_id; ///< wx' style paper id. wxPaperSize m_paper_id; ///< wx' style paper id.
wxString m_description; ///< more human friendly description of page size
static double s_user_height; static double s_user_height;
static double s_user_width; static double s_user_width;

View File

@ -226,7 +226,7 @@ void DIALOG_INSPECTOR::ReCreateDesignList()
GetGridList()->SetCellValue( row, COL_TYPENAME, _( "Layout" ) ); GetGridList()->SetCellValue( row, COL_TYPENAME, _( "Layout" ) );
// Display page format name. // Display page format name.
GetGridList()->SetCellValue( row, COL_COMMENT, page_info.GetType() ); GetGridList()->SetCellValue( row, COL_COMMENT, page_info.GetTypeAsString() );
GetGridList()->SetCellValue( row, COL_REPEAT_NUMBER, "-" ); GetGridList()->SetCellValue( row, COL_REPEAT_NUMBER, "-" );
VECTOR2I page_sizeIU = m_editorFrame->GetPageSizeIU(); VECTOR2I page_sizeIU = m_editorFrame->GetPageSizeIU();
GetGridList()->SetCellValue( row, COL_TEXTSTRING, GetGridList()->SetCellValue( row, COL_TEXTSTRING,

View File

@ -98,7 +98,7 @@ void PL_DRAW_PANEL_GAL::DisplayDrawingSheet()
// To show the formatted texts instead of raw texts in drawing sheet editor, we need // To show the formatted texts instead of raw texts in drawing sheet editor, we need
// a dummy DS_DRAW_ITEM_LIST. // a dummy DS_DRAW_ITEM_LIST.
DS_DRAW_ITEM_LIST dummy( drawSheetIUScale ); DS_DRAW_ITEM_LIST dummy( drawSheetIUScale );
dummy.SetPaperFormat( m_edaFrame->GetPageSettings().GetType() ); dummy.SetPaperFormat( m_edaFrame->GetPageSettings().GetTypeAsString() );
dummy.SetTitleBlock( &m_edaFrame->GetTitleBlock() ); dummy.SetTitleBlock( &m_edaFrame->GetTitleBlock() );
dummy.SetProject( &m_edaFrame->Prj() ); dummy.SetProject( &m_edaFrame->Prj() );

View File

@ -559,7 +559,7 @@ void PL_EDITOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
cfg->m_PropertiesFrameWidth = m_propertiesFrameWidth; cfg->m_PropertiesFrameWidth = m_propertiesFrameWidth;
cfg->m_CornerOrigin = m_originSelectChoice; cfg->m_CornerOrigin = m_originSelectChoice;
cfg->m_BlackBackground = GetDrawBgColor() == BLACK; cfg->m_BlackBackground = GetDrawBgColor() == BLACK;
cfg->m_LastPaperSize = GetPageSettings().GetType(); cfg->m_LastPaperSize = GetPageSettings().GetTypeAsString();
cfg->m_LastWasPortrait = GetPageSettings().IsPortrait(); cfg->m_LastWasPortrait = GetPageSettings().IsPortrait();
cfg->m_LastCustomWidth = PAGE_INFO::GetCustomWidthMils(); cfg->m_LastCustomWidth = PAGE_INFO::GetCustomWidthMils();
cfg->m_LastCustomHeight = PAGE_INFO::GetCustomHeightMils(); cfg->m_LastCustomHeight = PAGE_INFO::GetCustomHeightMils();

View File

@ -29,7 +29,7 @@
PL_EDITOR_LAYOUT::PL_EDITOR_LAYOUT() : PL_EDITOR_LAYOUT::PL_EDITOR_LAYOUT() :
m_drawItemList( drawSheetIUScale ) m_drawItemList( drawSheetIUScale )
{ {
PAGE_INFO pageInfo( wxT( "A4" ) ); PAGE_INFO pageInfo( PAGE_SIZE_TYPE::A4 );
SetPageSettings( pageInfo ); SetPageSettings( pageInfo );
} }

View File

@ -84,7 +84,7 @@ BOARD::BOARD() :
m_LegacyNetclassesLoaded( false ), m_LegacyNetclassesLoaded( false ),
m_boardUse( BOARD_USE::NORMAL ), m_boardUse( BOARD_USE::NORMAL ),
m_timeStamp( 1 ), m_timeStamp( 1 ),
m_paper( PAGE_INFO::A4 ), m_paper( PAGE_SIZE_TYPE::A4 ),
m_project( nullptr ), m_project( nullptr ),
m_userUnits( EDA_UNITS::MM ), m_userUnits( EDA_UNITS::MM ),
m_designSettings( new BOARD_DESIGN_SETTINGS( nullptr, "board.design_settings" ) ), m_designSettings( new BOARD_DESIGN_SETTINGS( nullptr, "board.design_settings" ) ),

View File

@ -796,7 +796,7 @@ void PANEL_PCBNEW_COLOR_SETTINGS::onNewThemeSelected()
void PANEL_PCBNEW_COLOR_SETTINGS::createPreviewItems() void PANEL_PCBNEW_COLOR_SETTINGS::createPreviewItems()
{ {
m_page = new PAGE_INFO( PAGE_INFO::Custom ); m_page = new PAGE_INFO( PAGE_SIZE_TYPE::User );
m_titleBlock = new TITLE_BLOCK; m_titleBlock = new TITLE_BLOCK;
m_titleBlock->SetTitle( _( "Color Preview" ) ); m_titleBlock->SetTitle( _( "Color Preview" ) );
m_titleBlock->SetDate( wxDateTime::Now().FormatDate() ); m_titleBlock->SetDate( wxDateTime::Now().FormatDate() );

View File

@ -94,7 +94,7 @@ bool GENDRILL_WRITER_BASE::genDrillMapFile( const wxString& aFullFileName, PLOT_
double scale = 1.0; double scale = 1.0;
VECTOR2I offset = GetOffset(); VECTOR2I offset = GetOffset();
PLOTTER* plotter = nullptr; PLOTTER* plotter = nullptr;
PAGE_INFO dummy( PAGE_INFO::A4, false ); PAGE_INFO dummy( PAGE_SIZE_TYPE::A4, false );
int bottom_limit = 0; // Y coord limit of page. 0 mean do not use int bottom_limit = 0; // Y coord limit of page. 0 mean do not use
PCB_PLOT_PARAMS plot_opts; // starts plotting with default options PCB_PLOT_PARAMS plot_opts; // starts plotting with default options

View File

@ -156,7 +156,7 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
GetGalDisplayOptions().m_axesEnabled = true; GetGalDisplayOptions().m_axesEnabled = true;
// In Footprint Editor, set the default paper size to A4 for plot/print // In Footprint Editor, set the default paper size to A4 for plot/print
SetPageSettings( PAGE_INFO( PAGE_INFO::A4 ) ); SetPageSettings( PAGE_INFO( PAGE_SIZE_TYPE::A4 ) );
SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU( pcbIUScale.IU_PER_MILS ) ) ); SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU( pcbIUScale.IU_PER_MILS ) ) );
// Create the manager and dispatcher & route draw panel events to the dispatcher // Create the manager and dispatcher & route draw panel events to the dispatcher

View File

@ -801,7 +801,7 @@ void PCB_IO_KICAD_LEGACY::loadSHEET()
char* orient = strtok_r( nullptr, delims, &data ); char* orient = strtok_r( nullptr, delims, &data );
// only parse the width and height if page size is custom ("User") // only parse the width and height if page size is custom ("User")
if( wname == PAGE_INFO::Custom ) if( page.GetType() == PAGE_SIZE_TYPE::User )
{ {
if( width && height ) if( width && height )
{ {

View File

@ -1445,7 +1445,7 @@ void PCB_IO_KICAD_SEXPR_PARSER::parsePAGE_INFO()
THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
} }
if( pageType == PAGE_INFO::Custom ) if( pageInfo.GetType() == PAGE_SIZE_TYPE::User )
{ {
double width = parseDouble( "width" ); // width in mm double width = parseDouble( "width" ); // width in mm

View File

@ -1088,7 +1088,7 @@ void GenerateLayerPoly( SHAPE_POLY_SET* aResult, BOARD *aBoard, PCB_LAYER_ID aLa
*/ */
static void initializePlotter( PLOTTER* aPlotter, const BOARD* aBoard, const PCB_PLOT_PARAMS* aPlotOpts ) static void initializePlotter( PLOTTER* aPlotter, const BOARD* aBoard, const PCB_PLOT_PARAMS* aPlotOpts )
{ {
PAGE_INFO pageA4( wxT( "A4" ) ); PAGE_INFO pageA4( PAGE_SIZE_TYPE::A4 );
const PAGE_INFO& pageInfo = aBoard->GetPageSettings(); const PAGE_INFO& pageInfo = aBoard->GetPageSettings();
const PAGE_INFO* sheet_info; const PAGE_INFO* sheet_info;
double paperscale; // Page-to-paper ratio double paperscale; // Page-to-paper ratio