diff --git a/pcbnew/edit_zone_helpers.cpp b/pcbnew/edit_zone_helpers.cpp index 29a70c2e3e..e4bb630394 100644 --- a/pcbnew/edit_zone_helpers.cpp +++ b/pcbnew/edit_zone_helpers.cpp @@ -47,7 +47,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( ZONE* aZone ) // note the net name and the layer can be changed, so we must save all zones deletedList.ClearListAndDeleteItems(); pickedList.ClearListAndDeleteItems(); - SaveCopyOfZones( pickedList, GetBoard(), -1, UNDEFINED_LAYER ); + SaveCopyOfZones( pickedList, GetBoard() ); if( aZone->GetIsRuleArea() ) { diff --git a/pcbnew/pcbnew_printout.cpp b/pcbnew/pcbnew_printout.cpp index 362c4a2516..dd0017245c 100644 --- a/pcbnew/pcbnew_printout.cpp +++ b/pcbnew/pcbnew_printout.cpp @@ -48,7 +48,7 @@ void PCBNEW_PRINTOUT_SETTINGS::Load( APP_SETTINGS_BASE* aConfig ) { BOARD_PRINTOUT_SETTINGS::Load( aConfig ); - if( auto cfg = dynamic_cast( aConfig ) ) + if( PCBNEW_SETTINGS* cfg = dynamic_cast( aConfig ) ) { m_DrillMarks = static_cast( cfg->m_Plot.pads_drill_mode ); m_Pagination = static_cast( cfg->m_Plot.all_layers_on_one_page ); @@ -62,7 +62,7 @@ void PCBNEW_PRINTOUT_SETTINGS::Save( APP_SETTINGS_BASE* aConfig ) { BOARD_PRINTOUT_SETTINGS::Save( aConfig ); - if( auto cfg = dynamic_cast( aConfig ) ) + if( PCBNEW_SETTINGS* cfg = dynamic_cast( aConfig ) ) { cfg->m_Plot.pads_drill_mode = m_DrillMarks; cfg->m_Plot.all_layers_on_one_page = m_Pagination; @@ -73,7 +73,7 @@ void PCBNEW_PRINTOUT_SETTINGS::Save( APP_SETTINGS_BASE* aConfig ) PCBNEW_PRINTOUT::PCBNEW_PRINTOUT( BOARD* aBoard, const PCBNEW_PRINTOUT_SETTINGS& aParams, - const KIGFX::VIEW* aView, const wxString& aTitle ) : + const KIGFX::VIEW* aView, const wxString& aTitle ) : BOARD_PRINTOUT( aParams, aView, aTitle ), m_pcbnewSettings( aParams ) { m_board = aBoard; @@ -296,8 +296,8 @@ int KIGFX::PCB_PRINT_PAINTER::getDrillShape( const PAD* aPad ) const VECTOR2D KIGFX::PCB_PRINT_PAINTER::getDrillSize( const PAD* aPad ) const { - return m_drillMarkReal ? KIGFX::PCB_PAINTER::getDrillSize( aPad ) : - VECTOR2D( m_drillMarkSize, m_drillMarkSize ); + return m_drillMarkReal ? KIGFX::PCB_PAINTER::getDrillSize( aPad ) + : VECTOR2D( m_drillMarkSize, m_drillMarkSize ); } diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index fe18d644ec..c2e21a56c3 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -738,8 +738,8 @@ void BRDITEMS_PLOTTER::PlotFootprintShape( const FP_SHAPE* aShape ) for( int jj = 0; jj < tmpPoly.OutlineCount(); ++jj ) { SHAPE_LINE_CHAIN &poly = tmpPoly.Outline( jj ); - m_plotter->PlotPoly( poly, aShape->IsFilled() ? - FILL_T::FILLED_SHAPE : FILL_T::NO_FILL, + m_plotter->PlotPoly( poly, aShape->IsFilled() ? FILL_T::FILLED_SHAPE + : FILL_T::NO_FILL, thickness, &gbr_metadata ); } } diff --git a/pcbnew/plugin.cpp b/pcbnew/plugin.cpp index decdf0d542..c5fd48cb61 100644 --- a/pcbnew/plugin.cpp +++ b/pcbnew/plugin.cpp @@ -94,10 +94,8 @@ bool PLUGIN::FootprintExists( const wxString& aLibraryPath, const wxString& aFoo } -FOOTPRINT* PLUGIN::FootprintLoad( const wxString& aLibraryPath, - const wxString& aFootprintName, - bool aKeepUUID, - const PROPERTIES* aProperties ) +FOOTPRINT* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, + bool aKeepUUID, const PROPERTIES* aProperties ) { // not pure virtual so that plugins only have to implement subset of the PLUGIN interface. not_implemented( this, __FUNCTION__ ); diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 48fe17092b..5e49a71da8 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -906,12 +906,10 @@ void ZONE::HatchBorder() // Iterate through all vertices for( auto iterator = m_Poly->IterateSegmentsWithHoles(); iterator; iterator++ ) { - double x, y; + const SEG seg = *iterator; + double x, y; - SEG segment = *iterator; - - if( FindLineSegmentIntersection( a, slope, segment.A.x, segment.A.y, segment.B.x, - segment.B.y, x, y ) ) + if( FindLineSegmentIntersection( a, slope, seg.A.x, seg.A.y, seg.B.x, seg.B.y, x, y ) ) pointbuffer.emplace_back( KiROUND( x ), KiROUND( y ) ); } @@ -976,7 +974,7 @@ void ZONE::SwapData( BOARD_ITEM* aImage ) { assert( aImage->Type() == PCB_ZONE_T || aImage->Type() == PCB_FP_ZONE_T ); - std::swap( *((ZONE*) this), *((ZONE*) aImage) ); + std::swap( *static_cast( this ), *static_cast( aImage) ); } @@ -984,8 +982,8 @@ void ZONE::CacheTriangulation( PCB_LAYER_ID aLayer ) { if( aLayer == UNDEFINED_LAYER ) { - for( std::pair>& pair : m_FilledPolysList ) - pair.second->CacheTriangulation(); + for( auto& [ layer, poly ] : m_FilledPolysList ) + poly->CacheTriangulation(); m_Poly->CacheTriangulation( false ); } @@ -1070,9 +1068,11 @@ bool ZONE::BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly, PCB_LAYER_ID aLayer bool smooth_requested = m_cornerSmoothingType == ZONE_SETTINGS::SMOOTHING_CHAMFER || m_cornerSmoothingType == ZONE_SETTINGS::SMOOTHING_FILLET; - if( IsTeardropArea() ) // We use teardrop shapes with no smoothing - // these shapes are already optimized + if( IsTeardropArea() ) + { + // We use teardrop shapes with no smoothing; these shapes are already optimized smooth_requested = false; + } if( board ) { diff --git a/pcbnew/zones_functions_for_undo_redo.cpp b/pcbnew/zones_functions_for_undo_redo.cpp index a959eee4da..4c6b9157a4 100644 --- a/pcbnew/zones_functions_for_undo_redo.cpp +++ b/pcbnew/zones_functions_for_undo_redo.cpp @@ -1,12 +1,8 @@ -/** - * @file zones_functions_for_undo_redo.cpp - */ - /* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2009 Jean-Pierre Charras - * Copyright (C) 2007-2015 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2007-2022 KiCad Developers, see change_log.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 @@ -45,8 +41,6 @@ #include #include - -#include #include #include @@ -138,36 +132,17 @@ bool ZONE::IsSame( const ZONE& aZoneToCompare ) * Later, UpdateCopyOfZonesList will change and update these pickers after a zone editing * @param aPickList = the pick list * @param aPcb = the Board - * @param aNetCode = the reference netcode. if aNetCode < 0 all netcodes are used - * @param aLayer = the layer of zones. if aLayer < 0, all layers are used - * @return the count of saved copies */ -int SaveCopyOfZones( PICKED_ITEMS_LIST& aPickList, BOARD* aPcb, int aNetCode, int aLayer ) +void SaveCopyOfZones( PICKED_ITEMS_LIST& aPickList, BOARD* aPcb ) { - int copyCount = 0; - - for( unsigned ii = 0; ; ii++ ) + for( ZONE* zone : aPcb->Zones() ) { - ZONE* zone = aPcb->GetArea( ii ); - - if( zone == nullptr ) // End of list - break; - - if( aNetCode >= 0 && aNetCode != zone->GetNetCode() ) - continue; - - if( aLayer >= 0 && !zone->GetLayerSet().test( aLayer ) ) - continue; - ZONE* zoneDup = new ZONE( *zone ); zoneDup->SetParent( aPcb ); ITEM_PICKER picker( nullptr, zone, UNDO_REDO::CHANGED ); picker.SetLink( zoneDup ); aPickList.PushItem( picker ); - copyCount++; } - - return copyCount; } @@ -206,9 +181,8 @@ int SaveCopyOfZones( PICKED_ITEMS_LIST& aPickList, BOARD* aPcb, int aNetCode, in * must have been removed (removed for new and deleted zones, or moved in aPickList.) * If not an error is set. */ -void UpdateCopyOfZonesList( PICKED_ITEMS_LIST& aPickList, - PICKED_ITEMS_LIST& aAuxiliaryList, - BOARD* aPcb ) +void UpdateCopyOfZonesList( PICKED_ITEMS_LIST& aPickList, PICKED_ITEMS_LIST& aAuxiliaryList, + BOARD* aPcb ) { for( unsigned kk = 0; kk < aPickList.GetCount(); kk++ ) { @@ -266,12 +240,13 @@ void UpdateCopyOfZonesList( PICKED_ITEMS_LIST& aPickList, if( notfound ) // happens when the new zone overlaps an existing zone // and these zones are combined { - #if defined(DEBUG) +#if defined(DEBUG) printf( "UpdateCopyOfZonesList(): item not found in aAuxiliaryList," "combined with another zone\n" ); fflush(nullptr); - #endif +#endif } + break; } @@ -309,7 +284,9 @@ void UpdateCopyOfZonesList( PICKED_ITEMS_LIST& aPickList, aAuxiliaryList.RemovePicker( ii ); } else + { ii++; + } } // Should not occur: diff --git a/pcbnew/zones_functions_for_undo_redo.h b/pcbnew/zones_functions_for_undo_redo.h index ab86f364c3..c7aeddefb1 100644 --- a/pcbnew/zones_functions_for_undo_redo.h +++ b/pcbnew/zones_functions_for_undo_redo.h @@ -51,11 +51,8 @@ * and fill a pick list with pickers to handle these copies * @param aPickList = the pick list * @param aPcb = the Board - * @param aNetCode = the reference netcode. if aNetCode < 0 all netcodes are used - * @param aLayer = the layer of zones. if aLayer < 0, all layers are used - * @return the count of saved copies */ -int SaveCopyOfZones(PICKED_ITEMS_LIST & aPickList, BOARD* aPcb, int aNetCode, int aLayer ); +void SaveCopyOfZones(PICKED_ITEMS_LIST & aPickList, BOARD* aPcb ); /**