From a970acd0bcc529378f040299788599eb3f4c3fe2 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 3 Feb 2022 13:55:37 +0100 Subject: [PATCH] Fix some issues related to new textboxes and python: - Fix duplicate class names returned by GetClass(). - replace MTEXT name (in GetClass) by better name (FP_TEXT, FP_TEXTBOX...) - Add missing Cast_to_PCB_TEXTBOX and Cast_to_FP_TEXTBOX --- pcbnew/fp_text.h | 2 +- pcbnew/fp_textbox.h | 2 +- pcbnew/python/swig/board_item.i | 16 ++++++++++++++-- pcbnew/python/swig/fp_text.i | 2 ++ pcbnew/python/swig/pcb_text.i | 2 ++ qa/testcases/test_001_pcb_load.py | 2 +- 6 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pcbnew/fp_text.h b/pcbnew/fp_text.h index fa051e1e94..94866bab86 100644 --- a/pcbnew/fp_text.h +++ b/pcbnew/fp_text.h @@ -173,7 +173,7 @@ public: wxString GetClass() const override { - return wxT( "MTEXT" ); + return wxT( "FP_TEXT" ); } wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; diff --git a/pcbnew/fp_textbox.h b/pcbnew/fp_textbox.h index 8523c9eec8..7dad41e09a 100644 --- a/pcbnew/fp_textbox.h +++ b/pcbnew/fp_textbox.h @@ -115,7 +115,7 @@ public: wxString GetClass() const override { - return wxT( "MTEXT" ); + return wxT( "FP_TEXTBOX" ); } wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; diff --git a/pcbnew/python/swig/board_item.i b/pcbnew/python/swig/board_item.i index 03c8ea4f4f..8e0433cae9 100644 --- a/pcbnew/python/swig/board_item.i +++ b/pcbnew/python/swig/board_item.i @@ -43,6 +43,7 @@ %{ class PCB_TEXT; +class PCB_TEXTBOX; class PCB_DIM_ALIGNED; class PCB_DIM_ORTHOGONAL; class PCB_DIM_LEADER; @@ -50,6 +51,7 @@ class PCB_DIM_CENTER; class FOOTPRINT; class PCB_GROUP; class FP_TEXT; +class FP_TEXTBOX; class PCB_SHAPE; class MARKER_PCB; class BOARD; @@ -69,6 +71,7 @@ extern "C" { #endif static PCB_TEXT* Cast_to_PCB_TEXT( BOARD_ITEM* ); +static PCB_TEXTBOX* Cast_to_PCB_TEXTBOX( BOARD_ITEM* ); static PCB_DIM_ALIGNED* Cast_to_PCB_DIM_ALIGNED( BOARD_ITEM* ); static PCB_DIM_ORTHOGONAL* Cast_to_PCB_DIM_ORTHOGONAL( BOARD_ITEM* ); static PCB_DIM_LEADER* Cast_to_PCB_DIM_LEADER( BOARD_ITEM* ); @@ -76,6 +79,7 @@ static PCB_DIM_CENTER* Cast_to_PCB_DIM_CENTER( BOARD_ITEM* ); static FOOTPRINT* Cast_to_FOOTPRINT( BOARD_ITEM* ); static PCB_GROUP* Cast_to_PCB_GROUP( BOARD_ITEM* ); static FP_TEXT* Cast_to_FP_TEXT( BOARD_ITEM* ); +static FP_TEXTBOX* Cast_to_FP_TEXTBOX( BOARD_ITEM* ); static PCB_SHAPE* Cast_to_PCB_SHAPE( BOARD_ITEM* ); static PCB_MARKER* Cast_to_PCB_MARKER( BOARD_ITEM* ); static BOARD* Cast_to_BOARD( BOARD_ITEM* ); @@ -95,6 +99,7 @@ static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* ); static PCB_TEXT* Cast_to_PCB_TEXT( BOARD_ITEM* ); +static PCB_TEXTBOX* Cast_to_PCB_TEXTBOX( BOARD_ITEM* ); static PCB_DIM_ALIGNED* Cast_to_PCB_DIM_ALIGNED( BOARD_ITEM* ); static PCB_DIM_ORTHOGONAL* Cast_to_PCB_DIM_ORTHOGONAL( BOARD_ITEM* ); static PCB_DIM_LEADER* Cast_to_PCB_DIM_LEADER( BOARD_ITEM* ); @@ -102,6 +107,7 @@ static PCB_DIM_CENTER* Cast_to_PCB_DIM_CENTER( BOARD_ITEM* ); static FOOTPRINT* Cast_to_FOOTPRINT( BOARD_ITEM* ); static PCB_GROUP* Cast_to_PCB_GROUP( BOARD_ITEM* ); static FP_TEXT* Cast_to_FP_TEXT( BOARD_ITEM* ); +static FP_TEXTBOX* Cast_to_FP_TEXTBOX( BOARD_ITEM* ); static PCB_SHAPE* Cast_to_PCB_SHAPE( BOARD_ITEM* ); static PCB_MARKER* Cast_to_PCB_MARKER( BOARD_ITEM* ); static BOARD* Cast_to_BOARD( BOARD_ITEM* ); @@ -123,8 +129,10 @@ static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* ); ct = self.GetClass() - if ct=="PTEXT": + if ct=="PCB_TEXT": return Cast_to_PCB_TEXT(self) + if ct=="PCB_TEXTBOX": + return Cast_to_PCB_TEXTBOX(self) elif ct=="BOARD": return Cast_to_BOARD(self) elif ct=="PCB_DIM_ALIGNED": @@ -145,8 +153,10 @@ static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* ); return Cast_to_PCB_GROUP(self) elif ct=="PAD": return Cast_to_PAD(self) - elif ct=="MTEXT": + elif ct=="FP_TEXT": return Cast_to_FP_TEXT(self) + elif ct=="FP_TEXTBOX": + return Cast_to_FP_TEXTBOX(self) elif ct=="PCB_VIA": return Cast_to_PCB_VIA(self) elif ct=="PCB_TRACK": @@ -186,6 +196,7 @@ static PCB_TARGET* Cast_to_PCB_TARGET( BOARD_ITEM* ); // the %header section. See section 5.6.2 of SWIG 3.0 documentation. %wrapper %{ static PCB_TEXT* Cast_to_PCB_TEXT( BOARD_ITEM* self ) { return dynamic_cast(self); } +static PCB_TEXTBOX* Cast_to_PCB_TEXTBOX( BOARD_ITEM* self ) { return dynamic_cast(self); } static PCB_DIM_ALIGNED* Cast_to_PCB_DIM_ALIGNED( BOARD_ITEM* self ) { return dynamic_cast(self); } static PCB_DIM_ORTHOGONAL* Cast_to_PCB_DIM_ORTHOGONAL( BOARD_ITEM* self ) { return dynamic_cast(self); } static PCB_DIM_LEADER* Cast_to_PCB_DIM_LEADER( BOARD_ITEM* self ) { return dynamic_cast(self); } @@ -193,6 +204,7 @@ static PCB_DIM_CENTER* Cast_to_PCB_DIM_CENTER( BOARD_ITEM* self ) { static FOOTPRINT* Cast_to_FOOTPRINT( BOARD_ITEM* self ) { return dynamic_cast(self); } static PCB_GROUP* Cast_to_PCB_GROUP( BOARD_ITEM* self ) { return dynamic_cast(self); } static FP_TEXT* Cast_to_FP_TEXT( BOARD_ITEM* self ) { return dynamic_cast(self); } +static FP_TEXTBOX* Cast_to_FP_TEXTBOX( BOARD_ITEM* self ) { return dynamic_cast(self); } static PCB_SHAPE* Cast_to_PCB_SHAPE( BOARD_ITEM* self ) { return dynamic_cast(self); } static PCB_MARKER* Cast_to_PCB_MARKER( BOARD_ITEM* self ) { return dynamic_cast(self); } static BOARD* Cast_to_BOARD( BOARD_ITEM* self ) { return dynamic_cast(self); } diff --git a/pcbnew/python/swig/fp_text.i b/pcbnew/python/swig/fp_text.i index 289b69e5d7..5dbcd91cd6 100644 --- a/pcbnew/python/swig/fp_text.i +++ b/pcbnew/python/swig/fp_text.i @@ -1,6 +1,8 @@ %include fp_text.h +%include fp_textbox.h %{ #include +#include %} diff --git a/pcbnew/python/swig/pcb_text.i b/pcbnew/python/swig/pcb_text.i index df1d511023..313536fd3c 100644 --- a/pcbnew/python/swig/pcb_text.i +++ b/pcbnew/python/swig/pcb_text.i @@ -1,7 +1,9 @@ %include pcb_text.h +%include pcb_textbox.h %{ #include +#include %} diff --git a/qa/testcases/test_001_pcb_load.py b/qa/testcases/test_001_pcb_load.py index 2d0916e770..6ddf57e804 100644 --- a/qa/testcases/test_001_pcb_load.py +++ b/qa/testcases/test_001_pcb_load.py @@ -54,7 +54,7 @@ class TestPCBLoad(unittest.TestCase): def test_pcb_text(self): drawings = list(self.pcb.GetDrawings()) - text = [d for d in drawings if d.GetClass() == "PTEXT"] + text = [d for d in drawings if d.GetClass() == "PCB_TEXT"] self.verify_text(text[0], 173355000, 68453000, pcbnew.F_Cu, u'Actionneur\nPiezo New Amp\nV02') self.verify_text(text[1], 176149000, 64643000, pcbnew.B_Cu,