From fa1591d021a14f668b4e5c761b0db76988b48cf9 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 10 Feb 2023 11:18:09 +0100 Subject: [PATCH] Gerbview: code refactor: change name of a D_CODE member: D_CODE::m_Shape -> m_ApertType (it is not a shape, it is a aperture type) Fix also an outdated/incorrect comment No actual code change. --- gerbview/dcode.cpp | 8 ++++---- gerbview/dcode.h | 7 ++++--- gerbview/excellon_read_drill_file.cpp | 6 +++--- gerbview/gerber_draw_item.cpp | 4 ++-- gerbview/gerber_draw_item.h | 2 +- gerbview/gerbview_painter.cpp | 2 +- gerbview/rs274d.cpp | 4 ++-- gerbview/rs274x.cpp | 8 ++++---- gerbview/toolbars_gerber.cpp | 4 ++-- gerbview/tools/gerbview_inspection_tool.cpp | 2 +- 10 files changed, 24 insertions(+), 23 deletions(-) diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp index 5c619fe2b3..3d7dafc120 100644 --- a/gerbview/dcode.cpp +++ b/gerbview/dcode.cpp @@ -71,7 +71,7 @@ void D_CODE::Clear_D_CODE_Data() { m_Size.x = DCODE_DEFAULT_SIZE; m_Size.y = DCODE_DEFAULT_SIZE; - m_Shape = APT_CIRCLE; + m_ApertType = APT_CIRCLE; m_Drill.x = m_Drill.y = 0; m_DrillShape = APT_DEF_NO_HOLE; m_InUse = false; @@ -116,7 +116,7 @@ int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent ) { int dim = 0; - switch( m_Shape ) + switch( m_ApertType ) { case APT_CIRCLE: dim = m_Size.x; @@ -155,7 +155,7 @@ void D_CODE::DrawFlashedShape( const GERBER_DRAW_ITEM* aParent, wxDC* aDC, const { int radius; - switch( m_Shape ) + switch( m_ApertType ) { case APT_CIRCLE: radius = m_Size.x >> 1; @@ -301,7 +301,7 @@ void D_CODE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent ) m_Polygon.RemoveAllContours(); - switch( m_Shape ) + switch( m_ApertType ) { case APT_CIRCLE: // creates only a circle with rectangular hole TransformCircleToPolygon( m_Polygon, initialpos, m_Size.x >> 1, ARC_HIGH_DEF, diff --git a/gerbview/dcode.h b/gerbview/dcode.h index c75c137a1a..b7a36734a1 100644 --- a/gerbview/dcode.h +++ b/gerbview/dcode.h @@ -42,8 +42,8 @@ class GERBER_DRAW_ITEM; /** - * The set of all gerber aperture types allowed, according to page 16 of - * http://gerbv.sourceforge.net/docs/rs274xrevd_e.pdf + * The set of all gerber aperture types allowed + * from ADD dcode command, like %ADD11C,0.304800*% to add a DCode number 11, circle shape */ enum APERTURE_T { APT_CIRCLE = 'C', // Flashed shape: Circle with or without hole @@ -187,7 +187,8 @@ public: public: wxSize m_Size; ///< Horizontal and vertical dimensions. - APERTURE_T m_Shape; ///< shape ( Line, rectangle, circle , oval .. ) + APERTURE_T m_ApertType; ///< Aperture type ( Line, rectangle, circle, + ///< oval poly, macro ) int m_Num_Dcode; ///< D code value ( >= 10 ) wxSize m_Drill; ///< dimension of the hole (if any) (drill file) APERTURE_DEF_HOLETYPE m_DrillShape; ///< shape of the hole (0 = no hole, round = 1, diff --git a/gerbview/excellon_read_drill_file.cpp b/gerbview/excellon_read_drill_file.cpp index 1a358e15b4..67dbd9c07b 100644 --- a/gerbview/excellon_read_drill_file.cpp +++ b/gerbview/excellon_read_drill_file.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2016 Jean-Pierre Charras - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -799,7 +799,7 @@ bool EXCELLON_IMAGE::readToolInformation( char*& aText ) conv_scale /= 25.4; dcode->m_Size.x = dcode->m_Size.y = KiROUND( dprm * conv_scale ); - dcode->m_Shape = APT_CIRCLE; + dcode->m_ApertType = APT_CIRCLE; dcode->m_Defined = true; return true; @@ -877,7 +877,7 @@ bool EXCELLON_IMAGE::Execute_Drill_Command( char*& text ) } else { - fillFlashedGBRITEM( gbritem, tool->m_Shape, tool->m_Num_Dcode, + fillFlashedGBRITEM( gbritem, tool->m_ApertType, tool->m_Num_Dcode, m_CurrentPos, tool->m_Size, false ); } diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp index 35340433c3..bf76c7a007 100644 --- a/gerbview/gerber_draw_item.cpp +++ b/gerbview/gerber_draw_item.cpp @@ -335,7 +335,7 @@ const BOX2I GERBER_DRAW_ITEM::GetBoundingBox() const case GBR_SEGMENT: { - if( code && code->m_Shape == APT_RECT ) + if( code && code->m_ApertType == APT_RECT ) { if( m_Polygon.OutlineCount() == 0 ) { @@ -492,7 +492,7 @@ void GERBER_DRAW_ITEM::Print( wxDC* aDC, const VECTOR2I& aOffset, GBR_DISPLAY_OP * In fact, any aperture can be used to plot a line. * currently: only a square pen is handled (I believe using a polygon gives a strange plot). */ - if( d_codeDescr->m_Shape == APT_RECT ) + if( d_codeDescr->m_ApertType == APT_RECT ) { if( m_Polygon.OutlineCount() == 0 ) ConvertSegmentToPolygon(); diff --git a/gerbview/gerber_draw_item.h b/gerbview/gerber_draw_item.h index fcb157ef97..e9f32c0d70 100644 --- a/gerbview/gerber_draw_item.h +++ b/gerbview/gerber_draw_item.h @@ -57,7 +57,7 @@ enum GBR_BASIC_SHAPE_TYPE GBR_SPOT_RECT, // flashed shape: rectangular shape can have hole) GBR_SPOT_OVAL, // flashed shape: oval shape GBR_SPOT_POLY, // flashed shape: regular polygon, 3 to 12 edges - GBR_SPOT_MACRO // complex shape described by a macro + GBR_SPOT_MACRO // complex shape described by a macro }; class GERBER_DRAW_ITEM : public EDA_ITEM diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp index eb58d9fa11..9c8512090e 100644 --- a/gerbview/gerbview_painter.cpp +++ b/gerbview/gerbview_painter.cpp @@ -384,7 +384,7 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer ) // TODO(JE) Refactor this to allow const aItem D_CODE* code = aItem->GetDcodeDescr(); - if( code && code->m_Shape == APT_RECT ) + if( code && code->m_ApertType == APT_RECT ) { if( aItem->m_Polygon.OutlineCount() == 0 ) aItem->ConvertSegmentToPolygon(); diff --git a/gerbview/rs274d.cpp b/gerbview/rs274d.cpp index efc4452bb1..f1e65dee57 100644 --- a/gerbview/rs274d.cpp +++ b/gerbview/rs274d.cpp @@ -682,7 +682,7 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande ) { size = tool->m_Size; dcode = tool->m_Num_Dcode; - aperture = tool->m_Shape; + aperture = tool->m_ApertType; } switch( m_Iterpolation ) @@ -741,7 +741,7 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande ) { size = tool->m_Size; dcode = tool->m_Num_Dcode; - aperture = tool->m_Shape; + aperture = tool->m_ApertType; } gbritem = new GERBER_DRAW_ITEM( this ); diff --git a/gerbview/rs274x.cpp b/gerbview/rs274x.cpp index bdb765f626..146fe6a6bf 100644 --- a/gerbview/rs274x.cpp +++ b/gerbview/rs274x.cpp @@ -735,7 +735,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff, switch( stdAperture ) // Aperture desceiption has optional parameters. Read them { case 'C': // Circle - dcode->m_Shape = APT_CIRCLE; + dcode->m_ApertType = APT_CIRCLE; while( *aText == ' ' ) aText++; @@ -763,7 +763,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff, case 'O': // oval case 'R': // rect - dcode->m_Shape = (stdAperture == 'O') ? APT_OVAL : APT_RECT; + dcode->m_ApertType = (stdAperture == 'O') ? APT_OVAL : APT_RECT; while( *aText == ' ' ) aText++; @@ -805,7 +805,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff, /* Regular polygon: a command line like %ADD12P,0.040X10X25X0.025X0.025X0.0150*% * params are: , X, X, X, X */ - dcode->m_Shape = APT_POLYGON; + dcode->m_ApertType = APT_POLYGON; while( *aText == ' ' ) aText++; @@ -897,7 +897,7 @@ bool GERBER_FILE_IMAGE::ExecuteRS274XCommand( int aCommand, char* aBuff, break; } - dcode->m_Shape = APT_MACRO; + dcode->m_ApertType = APT_MACRO; dcode->SetMacro( pam ); dcode->m_Defined = true; } diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 2f8511624e..3b20605980 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 Wayne Stambaugh - * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -352,7 +352,7 @@ void GERBVIEW_FRAME::updateDCodeSelectBox() dcode->m_Num_Dcode, dcode->m_Size.x / scale, dcode->m_Size.y / scale, units, - D_CODE::ShowApertureType( dcode->m_Shape ) ); + D_CODE::ShowApertureType( dcode->m_ApertType ) ); if( !dcode->m_AperFunction.IsEmpty() ) msg << wxT( ", " ) << dcode->m_AperFunction; diff --git a/gerbview/tools/gerbview_inspection_tool.cpp b/gerbview/tools/gerbview_inspection_tool.cpp index 60c3228d47..ee670ddf15 100644 --- a/gerbview/tools/gerbview_inspection_tool.cpp +++ b/gerbview/tools/gerbview_inspection_tool.cpp @@ -129,7 +129,7 @@ int GERBVIEW_INSPECTION_TOOL::ShowDCodes( const TOOL_EVENT& aEvent ) pt_D_code->m_Num_Dcode, pt_D_code->m_Size.y / scale, units, pt_D_code->m_Size.x / scale, units, - D_CODE::ShowApertureType( pt_D_code->m_Shape ), + D_CODE::ShowApertureType( pt_D_code->m_ApertType ), pt_D_code->m_AperFunction.IsEmpty()? wxT( "none" ) : pt_D_code->m_AperFunction );