From ba2e34682e1da9f7a40be1430d114ba187771b8a Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 6 Oct 2019 17:34:35 +0200 Subject: [PATCH] Gerbview: enhancement: show attributes for polygons (Regions in Gerber dialect) that have no DCode This change is needed to follow current specifications in Gerber X2 --- gerbview/gerber_draw_item.cpp | 25 +++++++++++++++++++------ gerbview/gerber_draw_item.h | 9 +++++++-- gerbview/rs274d.cpp | 9 +++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp index a8e98c1773..f049217428 100644 --- a/gerbview/gerber_draw_item.cpp +++ b/gerbview/gerber_draw_item.cpp @@ -691,14 +691,27 @@ void GERBER_DRAW_ITEM::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PAN msg = ShowGBRShape(); aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) ); - // Display D_Code value with its attributes: - msg.Printf( _( "D Code %d" ), m_DCode ); - D_CODE* apertDescr = GetDcodeDescr(); - if( !apertDescr || apertDescr->m_AperFunction.IsEmpty() ) - text = _( "No attribute" ); + // Display D_Code value with its attributes for items using a DCode: + if( m_Shape == GBR_POLYGON ) // Has no DCode, but can have an attribute + { + msg = _( "Attribut" ); + + if( m_AperFunction.IsEmpty() ) + text = _( "No attribute" ); + else + text = m_AperFunction; + } else - text = apertDescr->m_AperFunction; + { + msg.Printf( _( "D Code %d" ), m_DCode ); + D_CODE* apertDescr = GetDcodeDescr(); + + if( !apertDescr || apertDescr->m_AperFunction.IsEmpty() ) + text = _( "No attribute" ); + else + text = apertDescr->m_AperFunction; + } aList.push_back( MSG_PANEL_ITEM( msg, text, RED ) ); diff --git a/gerbview/gerber_draw_item.h b/gerbview/gerber_draw_item.h index 77e26fe6e7..304b890cbb 100644 --- a/gerbview/gerber_draw_item.h +++ b/gerbview/gerber_draw_item.h @@ -88,9 +88,14 @@ public: // Lines : m_Size.x = m_Size.y = line width bool m_Flashed; // True for flashed items int m_DCode; // DCode used to draw this item. - // 0 for items that do not use DCodes (polygons) - // or when unknown and normal values are 10 to 999 + // Allowed values are >= 10. 0 when unknown // values 0 to 9 can be used for special purposes + // Regions (polygons) doo not use DCode, + // so it is set to 0 + wxString m_AperFunction; // the aperture function set by a %TA.AperFunction, xxx + // (stores thre xxx value). + // used for regions that do not have a attached DCode, but + // have a TA.AperFunction defined GERBER_FILE_IMAGE* m_GerberImageFile; /* Gerber file image source of this item * Note: some params stored in this class are common * to the whole gerber file (i.e) the whole graphic diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index de0c605cf9..0fce16b5dc 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -619,6 +619,14 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande ) m_Drawings.Append( gbritem ); gbritem->m_Shape = GBR_POLYGON; gbritem->m_Flashed = false; + gbritem->m_DCode = 0; // No DCode for a Polygon (Region in Gerber dialect) + + + if( gbritem->m_GerberImageFile ) + { + gbritem->SetNetAttributes( gbritem->m_GerberImageFile->m_NetAttributeDict ); + gbritem->m_AperFunction = gbritem->m_GerberImageFile->m_AperFunction; + } } switch( m_Iterpolation ) @@ -676,6 +684,7 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande ) m_Exposure = true; tool = GetDCODE( m_Current_Tool ); + if( tool ) { size = tool->m_Size;