From 2bc10d58b51152b9a651441299d7cdc7812a6963 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 8 Mar 2021 12:57:33 +0000 Subject: [PATCH] Fix some cases where PCB_FP_ZONE_T was left out. Fixes https://gitlab.com/kicad/code/kicad/issues/7615 --- pcbnew/pcb_painter.cpp | 7 ++-- pcbnew/tools/pcb_point_editor.cpp | 52 +++++++++++++++++------------ pcbnew/tools/pcb_selection_tool.cpp | 4 +-- pcbnew/tools/zone_filler_tool.cpp | 2 +- pcbnew/zone.cpp | 2 +- 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 310c955bae..690e4ae03d 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -250,8 +250,11 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons } // Zones should pull from the copper layer - if( item && item->Type() == PCB_ZONE_T && IsZoneLayer( aLayer ) ) - aLayer = aLayer - LAYER_ZONE_START; + if( item && ( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T ) ) + { + if( IsZoneLayer( aLayer ) ) + aLayer = aLayer - LAYER_ZONE_START; + } // Hole walls should pull from the copper layer if( aLayer == LAYER_PAD_HOLEWALLS ) diff --git a/pcbnew/tools/pcb_point_editor.cpp b/pcbnew/tools/pcb_point_editor.cpp index 1337407c4c..dd9d11a128 100644 --- a/pcbnew/tools/pcb_point_editor.cpp +++ b/pcbnew/tools/pcb_point_editor.cpp @@ -1790,19 +1790,23 @@ void PCB_POINT_EDITOR::setAltConstraint( bool aEnabled ) if( aEnabled ) { EDIT_LINE* line = dynamic_cast( m_editedPoint ); - bool isPoly = false; + bool isPoly; - if( m_editPoints->GetParent()->Type() == PCB_ZONE_T - || m_editPoints->GetParent()->Type() == PCB_FP_ZONE_T ) + switch( m_editPoints->GetParent()->Type() ) { + case PCB_ZONE_T: + case PCB_FP_ZONE_T: isPoly = true; - } + break; - else if( m_editPoints->GetParent()->Type() == PCB_SHAPE_T - || m_editPoints->GetParent()->Type() == PCB_FP_SHAPE_T ) - { - PCB_SHAPE* shape = static_cast( m_editPoints->GetParent() ); - isPoly = shape->GetShape() == S_POLYGON; + case PCB_SHAPE_T: + case PCB_FP_SHAPE_T: + isPoly = static_cast( m_editPoints->GetParent() )->GetShape() == S_POLYGON; + break; + + default: + isPoly = false; + break; } if( line && isPoly ) @@ -1929,26 +1933,32 @@ bool PCB_POINT_EDITOR::removeCornerCondition( const SELECTION& ) if( !m_editPoints || !m_editedPoint ) return false; - EDA_ITEM* item = m_editPoints->GetParent(); + EDA_ITEM* item = m_editPoints->GetParent(); + SHAPE_POLY_SET* polyset = nullptr; if( !item ) return false; - if( !( item->Type() == PCB_ZONE_T - || item->Type() == PCB_FP_ZONE_T - || ( ( item->Type() == PCB_FP_SHAPE_T || item->Type() == PCB_SHAPE_T ) - && static_cast( item )->GetShape() == S_POLYGON ) ) ) + switch( item->Type() ) { + case PCB_ZONE_T: + case PCB_FP_ZONE_T: + polyset = static_cast( item )->Outline(); + break; + + case PCB_SHAPE_T: + case PCB_FP_SHAPE_T: + if( static_cast( item )->GetShape() == S_POLYGON ) + polyset = &static_cast( item )->GetPolyShape(); + else + return false; + + break; + + default: return false; } - SHAPE_POLY_SET *polyset; - - if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T ) - polyset = static_cast( item )->Outline(); - else - polyset = &static_cast( item )->GetPolyShape(); - auto vertex = findVertex( *polyset, *m_editedPoint ); if( !vertex.first ) diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index 57f61e83d5..18963ff3bd 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -378,7 +378,7 @@ int PCB_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) for( EDA_ITEM* item : aCollector ) { - if( item->Type() == PCB_ZONE_T ) + if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T ) { ZONE* zone = static_cast( item ); @@ -2419,7 +2419,7 @@ void PCB_SELECTION_TOOL::GuessSelectionCandidates( GENERAL_COLLECTOR& aCollector BOARD_ITEM* item = aCollector[i]; double area; - if( item->Type() == PCB_ZONE_T + if( ( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T ) && static_cast( item )->HitTestForEdge( where, MAX_SLOP * pixel / 2 ) ) { // Zone borders are very specific, so make them "small" diff --git a/pcbnew/tools/zone_filler_tool.cpp b/pcbnew/tools/zone_filler_tool.cpp index 2a8128e35a..dc22d3be24 100644 --- a/pcbnew/tools/zone_filler_tool.cpp +++ b/pcbnew/tools/zone_filler_tool.cpp @@ -198,7 +198,7 @@ int ZONE_FILLER_TOOL::ZoneUnfill( const TOOL_EVENT& aEvent ) for( EDA_ITEM* item : selection() ) { - assert( item->Type() == PCB_ZONE_T ); + assert( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T ); ZONE* zone = static_cast( item ); diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 63d62a815c..2f1563d4da 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -1095,7 +1095,7 @@ BITMAP_DEF ZONE::GetMenuImage() const void ZONE::SwapData( BOARD_ITEM* aImage ) { - assert( aImage->Type() == PCB_ZONE_T ); + assert( aImage->Type() == PCB_ZONE_T || aImage->Type() == PCB_FP_ZONE_T ); std::swap( *((ZONE*) this), *((ZONE*) aImage) ); }