Gerbview: code refactor: change name and type of a member:

GERBER_DRAW_ITEM::m_Shape -> m_ShapeType of type GBR_BASIC_SHAPES
Minor coding style fix.
This commit is contained in:
jean-pierre charras 2023-02-10 10:04:52 +01:00
parent c22fb390ec
commit 0d0c9aee3a
6 changed files with 44 additions and 38 deletions

View File

@ -163,7 +163,7 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( const GERBER_DRAW_ITEM* aGbrIt
if( d_codeDescr == nullptr ) if( d_codeDescr == nullptr )
d_codeDescr = &dummyD_CODE; d_codeDescr = &dummyD_CODE;
switch( aGbrItem->m_Shape ) switch( aGbrItem->m_ShapeType )
{ {
case GBR_POLYGON: case GBR_POLYGON:
writePcbPolygon( aGbrItem->m_Polygon, aLayer ); writePcbPolygon( aGbrItem->m_Polygon, aLayer );
@ -287,7 +287,7 @@ void GBR_TO_PCB_EXPORTER::export_via( const EXPORT_VIA& aVia )
void GBR_TO_PCB_EXPORTER::export_copper_item( const GERBER_DRAW_ITEM* aGbrItem, int aLayer ) void GBR_TO_PCB_EXPORTER::export_copper_item( const GERBER_DRAW_ITEM* aGbrItem, int aLayer )
{ {
switch( aGbrItem->m_Shape ) switch( aGbrItem->m_ShapeType )
{ {
case GBR_SPOT_CIRCLE: case GBR_SPOT_CIRCLE:
case GBR_SPOT_RECT: case GBR_SPOT_RECT:
@ -412,7 +412,7 @@ void GBR_TO_PCB_EXPORTER::export_flashed_copper_item( const GERBER_DRAW_ITEM* aG
if( d_codeDescr == nullptr ) if( d_codeDescr == nullptr )
d_codeDescr = &flashed_item_D_CODE; d_codeDescr = &flashed_item_D_CODE;
if( aGbrItem->m_Shape == GBR_SPOT_CIRCLE ) if( aGbrItem->m_ShapeType == GBR_SPOT_CIRCLE )
{ {
// See if there's a via that we can enlarge to fit this flashed item // See if there's a via that we can enlarge to fit this flashed item
for( EXPORT_VIA& via : m_vias ) for( EXPORT_VIA& via : m_vias )
@ -427,8 +427,8 @@ void GBR_TO_PCB_EXPORTER::export_flashed_copper_item( const GERBER_DRAW_ITEM* aG
VECTOR2I offset = aGbrItem->GetABPosition( aGbrItem->m_Start ); VECTOR2I offset = aGbrItem->GetABPosition( aGbrItem->m_Start );
if( aGbrItem->m_Shape == GBR_SPOT_CIRCLE || if( aGbrItem->m_ShapeType == GBR_SPOT_CIRCLE ||
( aGbrItem->m_Shape == GBR_SPOT_OVAL && d_codeDescr->m_Size.x == d_codeDescr->m_Size.y ) ) ( aGbrItem->m_ShapeType == GBR_SPOT_OVAL && d_codeDescr->m_Size.x == d_codeDescr->m_Size.y ) )
{ {
// export it as filled circle // export it as filled circle
VECTOR2I center = offset; VECTOR2I center = offset;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2017 <Jean-Pierre Charras> * Copyright (C) 1992-2017 <Jean-Pierre Charras>
* 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -42,7 +42,7 @@ GERBER_DRAW_ITEM::GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberImageFile ) :
EDA_ITEM( nullptr, GERBER_DRAW_ITEM_T ) EDA_ITEM( nullptr, GERBER_DRAW_ITEM_T )
{ {
m_GerberImageFile = aGerberImageFile; m_GerberImageFile = aGerberImageFile;
m_Shape = GBR_SEGMENT; m_ShapeType = GBR_SEGMENT;
m_Flashed = false; m_Flashed = false;
m_DCode = 0; m_DCode = 0;
m_UnitsMetric = false; m_UnitsMetric = false;
@ -92,7 +92,7 @@ bool GERBER_DRAW_ITEM::GetTextD_CodePrms( int& aSize, VECTOR2I& aPos, EDA_ANGLE&
if( m_DCode <= 0 ) if( m_DCode <= 0 )
return false; // No D_Code for this item return false; // No D_Code for this item
if( m_Flashed || m_Shape == GBR_ARC ) if( m_Flashed || m_ShapeType == GBR_ARC )
aPos = m_Start; aPos = m_Start;
else // it is a line: else // it is a line:
aPos = ( m_Start + m_End) / 2; aPos = ( m_Start + m_End) / 2;
@ -207,7 +207,7 @@ void GERBER_DRAW_ITEM::SetLayerParameters()
wxString GERBER_DRAW_ITEM::ShowGBRShape() const wxString GERBER_DRAW_ITEM::ShowGBRShape() const
{ {
switch( m_Shape ) switch( m_ShapeType )
{ {
case GBR_SEGMENT: return _( "Line" ); case GBR_SEGMENT: return _( "Line" );
case GBR_ARC: return _( "Arc" ); case GBR_ARC: return _( "Arc" );
@ -256,7 +256,7 @@ const BOX2I GERBER_DRAW_ITEM::GetBoundingBox() const
// Until/unless that is changed, we need to do different things depending on // Until/unless that is changed, we need to do different things depending on
// what is actually being represented by this GERBER_DRAW_ITEM. // what is actually being represented by this GERBER_DRAW_ITEM.
switch( m_Shape ) switch( m_ShapeType )
{ {
case GBR_POLYGON: case GBR_POLYGON:
{ {
@ -432,7 +432,7 @@ void GERBER_DRAW_ITEM::Print( wxDC* aDC, const VECTOR2I& aOffset, GBR_DISPLAY_OP
isFilled = aOptions->m_DisplayLinesFill; isFilled = aOptions->m_DisplayLinesFill;
switch( m_Shape ) switch( m_ShapeType )
{ {
case GBR_POLYGON: case GBR_POLYGON:
isFilled = aOptions->m_DisplayPolygonsFill; isFilled = aOptions->m_DisplayPolygonsFill;
@ -622,7 +622,7 @@ void GERBER_DRAW_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_
aList.emplace_back( _( "Type" ), msg ); aList.emplace_back( _( "Type" ), msg );
// Display D_Code value with its attributes for items using a DCode: // 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 if( m_ShapeType == GBR_POLYGON ) // Has no DCode, but can have an attribute
{ {
msg = _( "Attribute" ); msg = _( "Attribute" );
@ -739,7 +739,7 @@ BITMAPS GERBER_DRAW_ITEM::GetMenuImage() const
if( m_Flashed ) if( m_Flashed )
return BITMAPS::pad; return BITMAPS::pad;
switch( m_Shape ) switch( m_ShapeType )
{ {
case GBR_SEGMENT: case GBR_SEGMENT:
case GBR_ARC: case GBR_ARC:
@ -772,7 +772,7 @@ bool GERBER_DRAW_ITEM::HitTest( const VECTOR2I& aRefPos, int aAccuracy ) const
SHAPE_POLY_SET poly; SHAPE_POLY_SET poly;
switch( m_Shape ) switch( m_ShapeType )
{ {
case GBR_POLYGON: case GBR_POLYGON:
poly = m_Polygon; poly = m_Polygon;
@ -861,11 +861,18 @@ bool GERBER_DRAW_ITEM::HitTest( const VECTOR2I& aRefPos, int aAccuracy ) const
} }
case GBR_SPOT_MACRO: case GBR_SPOT_MACRO:
{
// Aperture macro polygons are already in absolute coordinates // Aperture macro polygons are already in absolute coordinates
auto p = GetDcodeDescr()->GetMacro()->GetApertureMacroShape( this, m_Start ); auto p = GetDcodeDescr()->GetMacro()->GetApertureMacroShape( this, m_Start );
return p->Contains( VECTOR2I( aRefPos ), -1, aAccuracy ); return p->Contains( VECTOR2I( aRefPos ), -1, aAccuracy );
} }
case GBR_SEGMENT:
case GBR_CIRCLE:
case GBR_SPOT_CIRCLE:
break; // handled below.
}
// TODO: a better analyze of the shape (perhaps create a D_CODE::HitTest for flashed items) // TODO: a better analyze of the shape (perhaps create a D_CODE::HitTest for flashed items)
int radius = std::min( m_Size.x, m_Size.y ) >> 1; int radius = std::min( m_Size.x, m_Size.y ) >> 1;
@ -900,7 +907,7 @@ bool GERBER_DRAW_ITEM::HitTest( const BOX2I& aRefArea, bool aContained, int aAcc
void GERBER_DRAW_ITEM::Show( int nestLevel, std::ostream& os ) const void GERBER_DRAW_ITEM::Show( int nestLevel, std::ostream& os ) const
{ {
NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() <<
" shape=\"" << m_Shape << '"' << " shape=\"" << m_ShapeType << '"' <<
" addr=\"" << std::hex << this << std::dec << '"' << " addr=\"" << std::hex << this << std::dec << '"' <<
" layer=\"" << GetLayer() << '"' << " layer=\"" << GetLayer() << '"' <<
" size=\"" << m_Size << '"' << " size=\"" << m_Size << '"' <<
@ -940,7 +947,7 @@ double GERBER_DRAW_ITEM::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{ {
int size = 0; int size = 0;
switch( m_Shape ) switch( m_ShapeType )
{ {
case GBR_SPOT_MACRO: case GBR_SPOT_MACRO:
size = GetDcodeDescr()->m_Polygon.BBox().GetWidth(); size = GetDcodeDescr()->m_Polygon.BBox().GetWidth();

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2016 <Jean-Pierre Charras> * Copyright (C) 1992-2016 <Jean-Pierre Charras>
* 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -46,8 +46,8 @@ namespace KIGFX
} }
/* Shapes id for basic shapes ( .m_Shape member ) */ /* Shapes id for basic shapes ( .m_ShapeType member ) */
enum Gbr_Basic_Shapes enum GBR_BASIC_SHAPE_TYPE
{ {
GBR_SEGMENT = 0, // usual segment : line with rounded ends GBR_SEGMENT = 0, // usual segment : line with rounded ends
GBR_ARC, // Arcs (with rounded ends) GBR_ARC, // Arcs (with rounded ends)
@ -57,8 +57,7 @@ enum Gbr_Basic_Shapes
GBR_SPOT_RECT, // flashed shape: rectangular shape can have hole) GBR_SPOT_RECT, // flashed shape: rectangular shape can have hole)
GBR_SPOT_OVAL, // flashed shape: oval shape GBR_SPOT_OVAL, // flashed shape: oval shape
GBR_SPOT_POLY, // flashed shape: regular polygon, 3 to 12 edges 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
GBR_LAST // last value for this list
}; };
class GERBER_DRAW_ITEM : public EDA_ITEM class GERBER_DRAW_ITEM : public EDA_ITEM
@ -172,7 +171,7 @@ public:
void PrintGerberPoly( wxDC* aDC, const COLOR4D& aColor, const VECTOR2I& aOffset, void PrintGerberPoly( wxDC* aDC, const COLOR4D& aColor, const VECTOR2I& aOffset,
bool aFilledShape ); bool aFilledShape );
int Shape() const { return m_Shape; } GBR_BASIC_SHAPE_TYPE ShapeType() const { return m_ShapeType; }
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
@ -230,7 +229,7 @@ public:
public: public:
bool m_UnitsMetric; // store here the gerber units (inch/mm). Used bool m_UnitsMetric; // store here the gerber units (inch/mm). Used
// only to calculate aperture macros shapes sizes // only to calculate aperture macros shapes sizes
int m_Shape; // Shape and 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 VECTOR2I m_Start; // Line or arc start point or position of the shape
// for flashed items // for flashed items
VECTOR2I m_End; // Line or arc end point VECTOR2I m_End; // Line or arc end point

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2017 Jon Evans <jon@craftyjon.com> * Copyright (C) 2017 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the
@ -244,7 +244,7 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
m_gal->SetIsFill( isFilled ); m_gal->SetIsFill( isFilled );
m_gal->SetIsStroke( !isFilled ); m_gal->SetIsStroke( !isFilled );
switch( aItem->m_Shape ) switch( aItem->m_ShapeType )
{ {
case GBR_POLYGON: case GBR_POLYGON:
{ {
@ -459,7 +459,7 @@ void GERBVIEW_PAINTER::drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled )
m_gal->SetIsStroke( !aFilled ); m_gal->SetIsStroke( !aFilled );
m_gal->SetLineWidth( m_gerbviewSettings.m_outlineWidth ); m_gal->SetLineWidth( m_gerbviewSettings.m_outlineWidth );
switch( aItem->m_Shape ) switch( aItem->m_ShapeType )
{ {
case GBR_SPOT_CIRCLE: case GBR_SPOT_CIRCLE:
{ {

View File

@ -6,7 +6,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -114,24 +114,24 @@ void fillFlashedGBRITEM( GERBER_DRAW_ITEM* aGbrItem,
switch( aAperture ) switch( aAperture )
{ {
case APT_POLYGON: // flashed regular polygon case APT_POLYGON: // flashed regular polygon
aGbrItem->m_Shape = GBR_SPOT_POLY; aGbrItem->m_ShapeType = GBR_SPOT_POLY;
break; break;
case APT_CIRCLE: case APT_CIRCLE:
aGbrItem->m_Shape = GBR_SPOT_CIRCLE; aGbrItem->m_ShapeType = GBR_SPOT_CIRCLE;
aGbrItem->m_Size.y = aGbrItem->m_Size.x; aGbrItem->m_Size.y = aGbrItem->m_Size.x;
break; break;
case APT_OVAL: case APT_OVAL:
aGbrItem->m_Shape = GBR_SPOT_OVAL; aGbrItem->m_ShapeType = GBR_SPOT_OVAL;
break; break;
case APT_RECT: case APT_RECT:
aGbrItem->m_Shape = GBR_SPOT_RECT; aGbrItem->m_ShapeType = GBR_SPOT_RECT;
break; break;
case APT_MACRO: case APT_MACRO:
aGbrItem->m_Shape = GBR_SPOT_MACRO; aGbrItem->m_ShapeType = GBR_SPOT_MACRO;
// Cache the bounding box for aperture macros // Cache the bounding box for aperture macros
aGbrItem->GetDcodeDescr()->GetMacro()->GetApertureMacroShape( aGbrItem, aPos ); aGbrItem->GetDcodeDescr()->GetMacro()->GetApertureMacroShape( aGbrItem, aPos );
@ -205,7 +205,7 @@ void fillArcGBRITEM( GERBER_DRAW_ITEM* aGbrItem, int Dcode_index, const VECTOR2I
{ {
VECTOR2I center, delta; VECTOR2I center, delta;
aGbrItem->m_Shape = GBR_ARC; aGbrItem->m_ShapeType = GBR_ARC;
aGbrItem->m_Size = aPenSize; aGbrItem->m_Size = aPenSize;
aGbrItem->m_Flashed = false; aGbrItem->m_Flashed = false;
@ -598,7 +598,7 @@ bool GERBER_FILE_IMAGE::Execute_DCODE_Command( char*& text, int D_commande )
m_Exposure = true; m_Exposure = true;
gbritem = new GERBER_DRAW_ITEM( this ); gbritem = new GERBER_DRAW_ITEM( this );
AddItemToList( gbritem ); AddItemToList( gbritem );
gbritem->m_Shape = GBR_POLYGON; gbritem->m_ShapeType = GBR_POLYGON;
gbritem->m_Flashed = false; gbritem->m_Flashed = false;
gbritem->m_DCode = 0; // No DCode for a Polygon (Region in Gerber dialect) gbritem->m_DCode = 0; // No DCode for a Polygon (Region in Gerber dialect)

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2017 Jon Evans <jon@craftyjon.com> * Copyright (C) 2017 Jon Evans <jon@craftyjon.com>
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License as published by the
@ -244,7 +244,7 @@ int GERBVIEW_CONTROL::DisplayControl( const TOOL_EVENT& aEvent )
{ {
GERBER_DRAW_ITEM* item = static_cast<GERBER_DRAW_ITEM*>( aItem ); GERBER_DRAW_ITEM* item = static_cast<GERBER_DRAW_ITEM*>( aItem );
switch( item->m_Shape ) switch( item->m_ShapeType )
{ {
case GBR_CIRCLE: case GBR_CIRCLE:
case GBR_ARC: case GBR_ARC:
@ -265,7 +265,7 @@ int GERBVIEW_CONTROL::DisplayControl( const TOOL_EVENT& aEvent )
{ {
GERBER_DRAW_ITEM* item = static_cast<GERBER_DRAW_ITEM*>( aItem ); GERBER_DRAW_ITEM* item = static_cast<GERBER_DRAW_ITEM*>( aItem );
switch( item->m_Shape ) switch( item->m_ShapeType )
{ {
case GBR_SPOT_CIRCLE: case GBR_SPOT_CIRCLE:
case GBR_SPOT_RECT: case GBR_SPOT_RECT:
@ -288,7 +288,7 @@ int GERBVIEW_CONTROL::DisplayControl( const TOOL_EVENT& aEvent )
{ {
GERBER_DRAW_ITEM* item = static_cast<GERBER_DRAW_ITEM*>( aItem ); GERBER_DRAW_ITEM* item = static_cast<GERBER_DRAW_ITEM*>( aItem );
return ( item->m_Shape == GBR_POLYGON ); return ( item->m_ShapeType == GBR_POLYGON );
} ); } );
} }
else if( aEvent.IsAction( &GERBVIEW_ACTIONS::negativeObjectDisplay ) ) else if( aEvent.IsAction( &GERBVIEW_ACTIONS::negativeObjectDisplay ) )