From 31fd3763d237f6011752afb97604f5a26ece1909 Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Sun, 10 May 2020 20:11:24 +0200 Subject: [PATCH] altium: detect barcode objects, improve binary documentation for text objects --- .../altium2kicadpcb_plugin/altium_parser.ksy | 36 +++++++++++++++++-- .../altium_parser_pcb.cpp | 2 +- .../altium_parser_pcb.h | 12 ++++++- pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp | 10 +++++- 4 files changed, 54 insertions(+), 6 deletions(-) diff --git a/pcbnew/altium2kicadpcb_plugin/altium_parser.ksy b/pcbnew/altium2kicadpcb_plugin/altium_parser.ksy index 3656375ebf..9d12ded4f5 100644 --- a/pcbnew/altium2kicadpcb_plugin/altium_parser.ksy +++ b/pcbnew/altium2kicadpcb_plugin/altium_parser.ksy @@ -461,18 +461,39 @@ types: - id: is_inverted type: u1 enum: boolean - - size: 21 + - id: margin + type: s4 + - id: use_offset # use margin otherwise + type: u1 + enum: boolean + - size: 16 - id: position type: u1 enum: text_position - - size: 27 - - id: truetype + - id: offset + type: s4 + - id: barcode_full_size # TODO: also for non-barcode? + type: xy + - id: barcode_margin # TODO: also for non-barcode? + type: xy + - size: 4 + - id: barcode_type + type: u1 + enum: text_barcode_type + - size: 1 + - id: barcode_inverted type: u1 enum: boolean + - id: font_type + type: u1 + enum: text_font_type - id: barcode_name size: 64 type: str # TODO: terminates with [0, 0] encoding: UTF-16 + - id: barcode_show_text + type: u1 + enum: boolean text_sub2: seq: @@ -684,6 +705,15 @@ enums: 8: right_center 9: right_bottom + text_font_type: + 0: stroke + 1: truetype + 2: barcode + + text_barcode_type: + 0: code39 + 1: code128 + layer: 1: f_cu 32: b_cu diff --git a/pcbnew/altium2kicadpcb_plugin/altium_parser_pcb.cpp b/pcbnew/altium2kicadpcb_plugin/altium_parser_pcb.cpp index 8830ec9c0f..5e6b354fc3 100644 --- a/pcbnew/altium2kicadpcb_plugin/altium_parser_pcb.cpp +++ b/pcbnew/altium2kicadpcb_plugin/altium_parser_pcb.cpp @@ -905,7 +905,7 @@ ATEXT6::ATEXT6( ALTIUM_PARSER& aReader ) textposition = ALTIUM_TEXT_POSITION::LEFT_BOTTOM; } aReader.Skip( 27 ); - isTruetype = aReader.Read() != 0; + fonttype = static_cast( aReader.Read() ); aReader.SkipSubrecord(); diff --git a/pcbnew/altium2kicadpcb_plugin/altium_parser_pcb.h b/pcbnew/altium2kicadpcb_plugin/altium_parser_pcb.h index f01fc2e3cf..2873de5403 100644 --- a/pcbnew/altium2kicadpcb_plugin/altium_parser_pcb.h +++ b/pcbnew/altium2kicadpcb_plugin/altium_parser_pcb.h @@ -191,6 +191,15 @@ enum class ALTIUM_TEXT_POSITION RIGHT_BOTTOM = 9 }; +enum class ALTIUM_TEXT_TYPE +{ + UNKNOWN = -1, + + STROKE = 0, + TRUETYPE = 1, + BARCODE = 2 +}; + struct ALTIUM_VERTICE { const bool isRound; @@ -638,7 +647,8 @@ struct ATEXT6 bool isComment; bool isDesignator; - bool isTruetype; + + ALTIUM_TEXT_TYPE fonttype; wxString text; diff --git a/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp b/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp index 217fc8ec55..b91b037c40 100644 --- a/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp +++ b/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp @@ -2222,6 +2222,14 @@ void ALTIUM_PCB::ParseTexts6Data( { ATEXT6 elem( reader ); + if( elem.fonttype == ALTIUM_TEXT_TYPE::BARCODE ) + { + wxLogWarning( wxString::Format( + _( "Ignore Barcode on Altium layer %d because it is not supported right now." ), + elem.layer ) ); + continue; + } + // TODO: better approach to select if item belongs to a MODULE EDA_TEXT* tx = nullptr; BOARD_ITEM* itm = nullptr; @@ -2306,7 +2314,7 @@ void ALTIUM_PCB::ParseTexts6Data( } itm->SetLayer( klayer ); - if( elem.isTruetype ) + if( elem.fonttype == ALTIUM_TEXT_TYPE::TRUETYPE ) { // TODO: why is this required? Somehow, truetype size is calculated differently tx->SetTextSize( wxSize( elem.height / 2, elem.height / 2 ) );