From 00374f0a7506b09636afa3e2f07389524adbd52a Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 10 Feb 2023 11:50:20 +0100 Subject: [PATCH] Gerbview: code refactor: change name of a member: GERBER_DRAW_ITEM::m_Polygon -> m_ShapeAsPolygon No actual code change. --- gerbview/export_to_pcbnew.cpp | 6 +++--- gerbview/gerber_draw_item.cpp | 21 +++++++++++---------- gerbview/gerber_draw_item.h | 4 ++-- gerbview/gerbview_painter.cpp | 6 +++--- gerbview/rs274d.cpp | 20 ++++++++++---------- 5 files changed, 29 insertions(+), 28 deletions(-) diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index 956648baf5..6eb146bb50 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -166,7 +166,7 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( const GERBER_DRAW_ITEM* aGbrIt switch( aGbrItem->m_ShapeType ) { case GBR_POLYGON: - writePcbPolygon( aGbrItem->m_Polygon, aLayer ); + writePcbPolygon( aGbrItem->m_ShapeAsPolygon, aLayer ); break; case GBR_SPOT_CIRCLE: @@ -307,7 +307,7 @@ void GBR_TO_PCB_EXPORTER::export_copper_item( const GERBER_DRAW_ITEM* aGbrItem, // The current way is use a polygon, as the zone export // is experimental and only for tests. #if 1 - writePcbPolygon( aGbrItem->m_Polygon, aLayer ); + writePcbPolygon( aGbrItem->m_ShapeAsPolygon, aLayer ); #else // Only for tests: writePcbZoneItem( aGbrItem, aLayer ); @@ -548,7 +548,7 @@ void GBR_TO_PCB_EXPORTER::writePcbPolygon( const SHAPE_POLY_SET& aPolys, int aLa void GBR_TO_PCB_EXPORTER::writePcbZoneItem( const GERBER_DRAW_ITEM* aGbrItem, int aLayer ) { - SHAPE_POLY_SET polys = aGbrItem->m_Polygon.CloneDropTriangulation(); + SHAPE_POLY_SET polys = aGbrItem->m_ShapeAsPolygon.CloneDropTriangulation(); polys.Simplify( SHAPE_POLY_SET::PM_FAST ); if( polys.OutlineCount() == 0 ) diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp index bf76c7a007..bf6fe03e1b 100644 --- a/gerbview/gerber_draw_item.cpp +++ b/gerbview/gerber_draw_item.cpp @@ -260,7 +260,7 @@ const BOX2I GERBER_DRAW_ITEM::GetBoundingBox() const { case GBR_POLYGON: { - BOX2I bb = m_Polygon.BBox(); + BOX2I bb = m_ShapeAsPolygon.BBox(); bbox.Inflate( bb.GetWidth() / 2, bb.GetHeight() / 2 ); bbox.SetOrigin( bb.GetOrigin() ); break; @@ -337,9 +337,9 @@ const BOX2I GERBER_DRAW_ITEM::GetBoundingBox() const { if( code && code->m_ApertType == APT_RECT ) { - if( m_Polygon.OutlineCount() == 0 ) + if( m_ShapeAsPolygon.OutlineCount() == 0 ) { - // We cannot initialize m_Polygon, because we are in a const function. + // We cannot initialize m_ShapeAsPolygon, because we are in a const function. // So use a temporary polygon SHAPE_POLY_SET poly_shape; ConvertSegmentToPolygon( &poly_shape ); @@ -348,7 +348,7 @@ const BOX2I GERBER_DRAW_ITEM::GetBoundingBox() const else { - bbox = m_Polygon.BBox(); + bbox = m_ShapeAsPolygon.BBox(); } } else @@ -390,7 +390,7 @@ void GERBER_DRAW_ITEM::MoveXY( const VECTOR2I& aMoveVector ) m_End += aMoveVector; m_ArcCentre += aMoveVector; - m_Polygon.Move( aMoveVector ); + m_ShapeAsPolygon.Move( aMoveVector ); } @@ -494,7 +494,7 @@ void GERBER_DRAW_ITEM::Print( wxDC* aDC, const VECTOR2I& aOffset, GBR_DISPLAY_OP */ if( d_codeDescr->m_ApertType == APT_RECT ) { - if( m_Polygon.OutlineCount() == 0 ) + if( m_ShapeAsPolygon.OutlineCount() == 0 ) ConvertSegmentToPolygon(); PrintGerberPoly( aDC, color, aOffset, isFilled ); @@ -589,7 +589,7 @@ void GERBER_DRAW_ITEM::ConvertSegmentToPolygon( SHAPE_POLY_SET* aPolygon ) const void GERBER_DRAW_ITEM::ConvertSegmentToPolygon() { - ConvertSegmentToPolygon( &m_Polygon ); + ConvertSegmentToPolygon( &m_ShapeAsPolygon ); } @@ -597,7 +597,7 @@ void GERBER_DRAW_ITEM::PrintGerberPoly( wxDC* aDC, const COLOR4D& aColor, const bool aFilledShape ) { std::vector points; - SHAPE_LINE_CHAIN& poly = m_Polygon.Outline( 0 ); + SHAPE_LINE_CHAIN& poly = m_ShapeAsPolygon.Outline( 0 ); int pointCount = poly.PointCount() - 1; points.reserve( pointCount ); @@ -775,7 +775,7 @@ bool GERBER_DRAW_ITEM::HitTest( const VECTOR2I& aRefPos, int aAccuracy ) const switch( m_ShapeType ) { case GBR_POLYGON: - poly = m_Polygon; + poly = m_ShapeAsPolygon; return poly.Contains( VECTOR2I( ref_pos ), 0, aAccuracy ); case GBR_SPOT_POLY: @@ -863,7 +863,8 @@ bool GERBER_DRAW_ITEM::HitTest( const VECTOR2I& aRefPos, int aAccuracy ) const case GBR_SPOT_MACRO: { // Aperture macro polygons are already in absolute coordinates - auto p = GetDcodeDescr()->GetMacro()->GetApertureMacroShape( this, m_Start ); + SHAPE_POLY_SET* p = + GetDcodeDescr()->GetMacro()->GetApertureMacroShape( this, m_Start ); return p->Contains( VECTOR2I( aRefPos ), -1, aAccuracy ); } diff --git a/gerbview/gerber_draw_item.h b/gerbview/gerber_draw_item.h index e9f32c0d70..c8d6583e75 100644 --- a/gerbview/gerber_draw_item.h +++ b/gerbview/gerber_draw_item.h @@ -229,12 +229,12 @@ public: public: bool m_UnitsMetric; // store here the gerber units (inch/mm). Used // only to calculate aperture macros shapes sizes - GBR_BASIC_SHAPE_TYPE m_ShapeType; // Shape type of this gerber item + GBR_BASIC_SHAPE_TYPE m_ShapeType; // Shape type of this gerber item VECTOR2I m_Start; // Line or arc start point or position of the shape // for flashed items VECTOR2I m_End; // Line or arc end point VECTOR2I m_ArcCentre; // for arcs only: Center of arc - SHAPE_POLY_SET m_Polygon; // Polygon shape data (G36 to G37 coordinates) + SHAPE_POLY_SET m_ShapeAsPolygon; // Polygon shape data from G36 to G37 coordinates // or for complex shapes which are converted to polygon wxSize m_Size; // Flashed shapes: size of the shape // Lines : m_Size.x = m_Size.y = line width diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp index 9c8512090e..43da97bbe8 100644 --- a/gerbview/gerbview_painter.cpp +++ b/gerbview/gerbview_painter.cpp @@ -263,7 +263,7 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer ) if( aItem->m_AbsolutePolygon.OutlineCount() == 0 ) { - std::vector pts = aItem->m_Polygon.COutline( 0 ).CPoints(); + std::vector pts = aItem->m_ShapeAsPolygon.COutline( 0 ).CPoints(); for( auto& pt : pts ) pt = aItem->GetABPosition( pt ); @@ -386,10 +386,10 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer ) D_CODE* code = aItem->GetDcodeDescr(); if( code && code->m_ApertType == APT_RECT ) { - if( aItem->m_Polygon.OutlineCount() == 0 ) + if( aItem->m_ShapeAsPolygon.OutlineCount() == 0 ) aItem->ConvertSegmentToPolygon(); - drawPolygon( aItem, aItem->m_Polygon, isFilled ); + drawPolygon( aItem, aItem->m_ShapeAsPolygon, isFilled ); } else { diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index f1e65dee57..f53b62dbcf 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -372,8 +372,8 @@ static void fillArcPOLY( GERBER_DRAW_ITEM* aGbrItem, const VECTOR2I& aStart, con EDA_ANGLE increment_angle = ANGLE_360 / 36; int count = std::abs( arc_angle.AsDegrees() / increment_angle.AsDegrees() ); - if( aGbrItem->m_Polygon.OutlineCount() == 0 ) - aGbrItem->m_Polygon.NewOutline(); + if( aGbrItem->m_ShapeAsPolygon.OutlineCount() == 0 ) + aGbrItem->m_ShapeAsPolygon.NewOutline(); // calculate polygon corners // when arc is counter-clockwise, dummyGbrItem arc goes from end to start @@ -393,7 +393,7 @@ static void fillArcPOLY( GERBER_DRAW_ITEM* aGbrItem, const VECTOR2I& aStart, con else // last point end_arc = aClockwise ? end : start; - aGbrItem->m_Polygon.Append( end_arc + center ); + aGbrItem->m_ShapeAsPolygon.Append( end_arc + center ); } } @@ -527,8 +527,8 @@ bool GERBER_FILE_IMAGE::Execute_G_Command( char*& text, int G_command ) { GERBER_DRAW_ITEM * gbritem = GetLastItemInList(); - if( gbritem->m_Polygon.VertexCount() ) - gbritem->m_Polygon.Append( gbritem->m_Polygon.CVertex( 0 ) ); + if( gbritem->m_ShapeAsPolygon.VertexCount() ) + gbritem->m_ShapeAsPolygon.Append( gbritem->m_ShapeAsPolygon.CVertex( 0 ) ); StepAndRepeatItem( *gbritem ); } @@ -637,14 +637,14 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande ) gbritem->m_Start = m_PreviousPos; // m_Start is used as temporary storage - if( gbritem->m_Polygon.OutlineCount() == 0 ) + if( gbritem->m_ShapeAsPolygon.OutlineCount() == 0 ) { - gbritem->m_Polygon.NewOutline(); - gbritem->m_Polygon.Append( VECTOR2I( gbritem->m_Start ) ); + gbritem->m_ShapeAsPolygon.NewOutline(); + gbritem->m_ShapeAsPolygon.Append( VECTOR2I( gbritem->m_Start ) ); } gbritem->m_End = m_CurrentPos; // m_End is used as temporary storage - gbritem->m_Polygon.Append( VECTOR2I( gbritem->m_End ) ); + gbritem->m_ShapeAsPolygon.Append( VECTOR2I( gbritem->m_End ) ); break; } @@ -656,7 +656,7 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande ) if( m_Exposure && GetLastItemInList() ) // End of polygon { gbritem = GetLastItemInList(); - gbritem->m_Polygon.Append( gbritem->m_Polygon.CVertex( 0 ) ); + gbritem->m_ShapeAsPolygon.Append( gbritem->m_ShapeAsPolygon.CVertex( 0 ) ); StepAndRepeatItem( *gbritem ); }