From 6ee909b95809527f8a6bed0178142ee162e2e868 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Mon, 11 Sep 2023 10:02:59 +0300 Subject: [PATCH] Altium schematic: support custom sheet sizes. (cherry picked from commit 16062bbe33309d6252ee66df83c54d634f427fff) --- .../sch_plugins/altium/altium_parser_sch.cpp | 5 ++ .../sch_plugins/altium/altium_parser_sch.h | 3 ++ .../sch_plugins/altium/sch_altium_plugin.cpp | 49 +++++++++++-------- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/eeschema/sch_plugins/altium/altium_parser_sch.cpp b/eeschema/sch_plugins/altium/altium_parser_sch.cpp index b9321de47e..dc33f734ea 100644 --- a/eeschema/sch_plugins/altium/altium_parser_sch.cpp +++ b/eeschema/sch_plugins/altium/altium_parser_sch.cpp @@ -800,6 +800,11 @@ ASCH_SHEET::ASCH_SHEET( const std::map& aProps ) for( int i = 1; i <= fontidcount; i++ ) fonts.emplace_back( aProps, i ); + useCustomSheet = ALTIUM_PARSER::ReadBool( aProps, "USECUSTOMSHEET", false ); + + customSize = VECTOR2I( ReadKiCadUnitFrac( aProps, "CUSTOMX" ), + ReadKiCadUnitFrac( aProps, "CUSTOMY" ) ); + sheetSize = ReadEnum( aProps, "SHEETSTYLE", 0, 17, ASCH_SHEET_SIZE::A4 ); sheetOrientation = ReadEnum( aProps, "WORKSPACEORIENTATION", 0, 1, ASCH_SHEET_WORKSPACEORIENTATION::LANDSCAPE ); diff --git a/eeschema/sch_plugins/altium/altium_parser_sch.h b/eeschema/sch_plugins/altium/altium_parser_sch.h index 6325ec6b57..864ae3618f 100644 --- a/eeschema/sch_plugins/altium/altium_parser_sch.h +++ b/eeschema/sch_plugins/altium/altium_parser_sch.h @@ -773,6 +773,9 @@ struct ASCH_SHEET { std::vector fonts; + bool useCustomSheet; + VECTOR2I customSize; + ASCH_SHEET_SIZE sheetSize; ASCH_SHEET_WORKSPACEORIENTATION sheetOrientation; diff --git a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp index c35756ab07..5d37654c46 100644 --- a/eeschema/sch_plugins/altium/sch_altium_plugin.cpp +++ b/eeschema/sch_plugins/altium/sch_altium_plugin.cpp @@ -2788,27 +2788,36 @@ void SCH_ALTIUM_PLUGIN::ParseSheet( const std::map& aPropert bool isPortrait = m_altiumSheet->sheetOrientation == ASCH_SHEET_WORKSPACEORIENTATION::PORTRAIT; - switch( m_altiumSheet->sheetSize ) + if( m_altiumSheet->useCustomSheet ) { - default: - case ASCH_SHEET_SIZE::A4: pageInfo.SetType( "A4", isPortrait ); break; - case ASCH_SHEET_SIZE::A3: pageInfo.SetType( "A3", isPortrait ); break; - case ASCH_SHEET_SIZE::A2: pageInfo.SetType( "A2", isPortrait ); break; - case ASCH_SHEET_SIZE::A1: pageInfo.SetType( "A1", isPortrait ); break; - case ASCH_SHEET_SIZE::A0: pageInfo.SetType( "A0", isPortrait ); break; - case ASCH_SHEET_SIZE::A: pageInfo.SetType( "A", isPortrait ); break; - case ASCH_SHEET_SIZE::B: pageInfo.SetType( "B", isPortrait ); break; - case ASCH_SHEET_SIZE::C: pageInfo.SetType( "C", isPortrait ); break; - case ASCH_SHEET_SIZE::D: pageInfo.SetType( "D", isPortrait ); break; - case ASCH_SHEET_SIZE::E: pageInfo.SetType( "E", isPortrait ); break; - case ASCH_SHEET_SIZE::LETTER: pageInfo.SetType( "USLetter", isPortrait ); break; - case ASCH_SHEET_SIZE::LEGAL: pageInfo.SetType( "USLegal", isPortrait ); break; - case ASCH_SHEET_SIZE::TABLOID: pageInfo.SetType( "A3", isPortrait ); break; - case ASCH_SHEET_SIZE::ORCAD_A: pageInfo.SetType( "A", isPortrait ); break; - case ASCH_SHEET_SIZE::ORCAD_B: pageInfo.SetType( "B", isPortrait ); break; - case ASCH_SHEET_SIZE::ORCAD_C: pageInfo.SetType( "C", isPortrait ); break; - case ASCH_SHEET_SIZE::ORCAD_D: pageInfo.SetType( "D", isPortrait ); break; - case ASCH_SHEET_SIZE::ORCAD_E: pageInfo.SetType( "E", isPortrait ); break; + PAGE_INFO::SetCustomWidthMils( schIUScale.IUToMils( m_altiumSheet->customSize.x ) ); + PAGE_INFO::SetCustomHeightMils( schIUScale.IUToMils( m_altiumSheet->customSize.y ) ); + pageInfo.SetType( PAGE_INFO::Custom, isPortrait ); + } + else + { + switch( m_altiumSheet->sheetSize ) + { + default: + case ASCH_SHEET_SIZE::A4: pageInfo.SetType( "A4", isPortrait ); break; + case ASCH_SHEET_SIZE::A3: pageInfo.SetType( "A3", isPortrait ); break; + case ASCH_SHEET_SIZE::A2: pageInfo.SetType( "A2", isPortrait ); break; + case ASCH_SHEET_SIZE::A1: pageInfo.SetType( "A1", isPortrait ); break; + case ASCH_SHEET_SIZE::A0: pageInfo.SetType( "A0", isPortrait ); break; + case ASCH_SHEET_SIZE::A: pageInfo.SetType( "A", isPortrait ); break; + case ASCH_SHEET_SIZE::B: pageInfo.SetType( "B", isPortrait ); break; + case ASCH_SHEET_SIZE::C: pageInfo.SetType( "C", isPortrait ); break; + case ASCH_SHEET_SIZE::D: pageInfo.SetType( "D", isPortrait ); break; + case ASCH_SHEET_SIZE::E: pageInfo.SetType( "E", isPortrait ); break; + case ASCH_SHEET_SIZE::LETTER: pageInfo.SetType( "USLetter", isPortrait ); break; + case ASCH_SHEET_SIZE::LEGAL: pageInfo.SetType( "USLegal", isPortrait ); break; + case ASCH_SHEET_SIZE::TABLOID: pageInfo.SetType( "A3", isPortrait ); break; + case ASCH_SHEET_SIZE::ORCAD_A: pageInfo.SetType( "A", isPortrait ); break; + case ASCH_SHEET_SIZE::ORCAD_B: pageInfo.SetType( "B", isPortrait ); break; + case ASCH_SHEET_SIZE::ORCAD_C: pageInfo.SetType( "C", isPortrait ); break; + case ASCH_SHEET_SIZE::ORCAD_D: pageInfo.SetType( "D", isPortrait ); break; + case ASCH_SHEET_SIZE::ORCAD_E: pageInfo.SetType( "E", isPortrait ); break; + } } screen->SetPageSettings( pageInfo );