From 6de8b99cf22261fb998bbd16682365a74336f83f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 28 Mar 2022 17:52:27 +0100 Subject: [PATCH] Don't default to Annotate All just because the selection is empty. Fixes https://gitlab.com/kicad/code/kicad/issues/11181 (cherry picked from commit 6fa8cab1889363a7e8b8221bee13e708a7aad22e) --- pcbnew/dialogs/dialog_board_reannotate.cpp | 39 ++++++++-------------- pcbnew/dialogs/dialog_board_reannotate.h | 16 ++++----- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/pcbnew/dialogs/dialog_board_reannotate.cpp b/pcbnew/dialogs/dialog_board_reannotate.cpp index 01e04dce77..a42741de52 100644 --- a/pcbnew/dialogs/dialog_board_reannotate.cpp +++ b/pcbnew/dialogs/dialog_board_reannotate.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Brian Piccioni brian@documenteddesigns.com - * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors. * @author Brian Piccioni * * This program is free software; you can redistribute it and/or @@ -30,14 +30,10 @@ #include #include #include -#include #include // StrNumCmp #include -#include #include #include -#include -#include #include #include @@ -136,16 +132,12 @@ DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE( PCB_EDIT_FRAME* aParentFrame ) m_selection = m_frame->GetToolManager()->GetTool()->GetSelection(); if( !m_selection.Empty() ) - m_annotationChoice = AnnotationChoice::AnnotateSelected; + m_annotationScope = AnnotateSelected; - for( wxRadioButton* button : AnnotateWhat ) + for( wxRadioButton* button : m_scopeRadioButtons ) button->SetValue( false ); - m_annotationChoice = ( m_sortCode >= (int) AnnotateWhat.size() ) ? - AnnotationChoice::AnnotateAll : - m_annotationChoice; - - AnnotateWhat[m_annotationChoice]->SetValue( true ); + m_scopeRadioButtons[m_annotationScope]->SetValue( true ); reannotate_down_right_bitmap->SetBitmap( KiBitmap( BITMAPS::reannotate_right_down ) ); reannotate_right_down_bitmap->SetBitmap( KiBitmap( BITMAPS::reannotate_left_down ) ); @@ -176,7 +168,7 @@ DIALOG_BOARD_REANNOTATE::~DIALOG_BOARD_REANNOTATE() cfg->m_Reannotate.grid_index = m_gridIndex; cfg->m_Reannotate.sort_code = m_sortCode; - cfg->m_Reannotate.annotation_choice = m_annotationChoice; + cfg->m_Reannotate.annotation_choice = m_annotationScope; cfg->m_Reannotate.report_severity = m_severity; cfg->m_Reannotate.front_refdes_start = m_FrontRefDesStart->GetValue(); @@ -198,7 +190,7 @@ void DIALOG_BOARD_REANNOTATE::InitValues( void ) m_gridIndex = cfg->m_Reannotate.grid_index ; m_sortCode = cfg->m_Reannotate.sort_code ; - m_annotationChoice = cfg->m_Reannotate.annotation_choice ; + m_annotationScope = cfg->m_Reannotate.annotation_choice ; m_severity = cfg->m_Reannotate.report_severity; m_FrontRefDesStart->SetValue( cfg->m_Reannotate.front_refdes_start ); @@ -311,7 +303,7 @@ void DIALOG_BOARD_REANNOTATE::MakeSampleText( wxString& aMessage ) wxString tmp; aMessage.Printf( _( "\n%s footprints will be reannotated." ), - _( AnnotateString[m_annotationChoice] ) ); + _( AnnotateString[m_annotationScope] ) ); if( !m_ExcludeList->GetValue().empty() ) { @@ -418,18 +410,16 @@ void DIALOG_BOARD_REANNOTATE::GetParameters() m_sortGridy = m_sortGridx; } - int i = 0; + m_annotationScope = AnnotateAll; - for( wxRadioButton* button : AnnotateWhat ) + for( wxRadioButton* button : m_scopeRadioButtons ) { if( button->GetValue() ) break; else - i++; + m_annotationScope++; } - m_annotationChoice = ( i >= (int) AnnotateWhat.size() ) ? AnnotationChoice::AnnotateAll : i; - m_MessageWindow->SetLazyUpdate( true ); } @@ -642,7 +632,7 @@ bool DIALOG_BOARD_REANNOTATE::ReannotateBoard() bool DIALOG_BOARD_REANNOTATE::BuildFootprintList( std::vector& aBadRefDes ) { - bool annotateSelected; + bool annotateSelected = m_AnnotateSelection->GetValue(); bool annotateFront = m_AnnotateFront->GetValue(); // Unless only doing back bool annotateBack = m_AnnotateBack->GetValue(); // Unless only doing front bool skipLocked = m_ExcludeLocked->GetValue(); @@ -657,7 +647,7 @@ bool DIALOG_BOARD_REANNOTATE::BuildFootprintList( std::vector& aBadR std::vector selected; - if( m_AnnotateSelection->GetValue() ) + if( annotateSelected ) { for( EDA_ITEM* item : m_selection ) { @@ -667,8 +657,6 @@ bool DIALOG_BOARD_REANNOTATE::BuildFootprintList( std::vector& aBadR } } - annotateSelected = !selected.empty(); - wxString exclude; // Break exclude list into words. @@ -799,7 +787,8 @@ bool DIALOG_BOARD_REANNOTATE::BuildFootprintList( std::vector& aBadR { if( m_changeArray[i].NewRefDes == m_changeArray[j].NewRefDes ) { - ShowReport( wxString::Format( _( "Duplicate instances of %s" ), m_changeArray[j].NewRefDes ), + ShowReport( wxString::Format( _( "Duplicate instances of %s" ), + m_changeArray[j].NewRefDes ), RPT_SEVERITY_ERROR ); if( errorcount++ > MAXERROR ) diff --git a/pcbnew/dialogs/dialog_board_reannotate.h b/pcbnew/dialogs/dialog_board_reannotate.h index aa5a757b6c..9cf8369882 100644 --- a/pcbnew/dialogs/dialog_board_reannotate.h +++ b/pcbnew/dialogs/dialog_board_reannotate.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Brian Piccioni brian@documenteddesigns.com - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * @author Brian Piccioni * * This program is free software; you can redistribute it and/or @@ -23,8 +23,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef DIALOG_BOARD_REANNOTATE_H_ -#define DIALOG_BOARD_REANNOTATE_H_ +#ifndef DIALOG_BOARD_REANNOTATE_H +#define DIALOG_BOARD_REANNOTATE_H #include #include @@ -60,9 +60,9 @@ enum ActionCode Exclude }; -enum AnnotationChoice +enum AnnotationScope { - AnnotateAll, + AnnotateAll = 0, AnnotateFront, AnnotateBack, AnnotateSelected @@ -115,7 +115,7 @@ private: m_Left_Up }; - std::vector AnnotateWhat = { + std::vector m_scopeRadioButtons = { m_AnnotateAll, m_AnnotateFront, m_AnnotateBack, @@ -200,7 +200,7 @@ private: int m_sortCode; int m_gridIndex; - int m_annotationChoice; + int m_annotationScope; int m_severity; double m_sortGridx; @@ -215,4 +215,4 @@ private: APP_SETTINGS_BASE* m_Config; }; -#endif /* DIALOG_BOARD_REANNOTATECLASSES_H_ */ +#endif /* DIALOG_BOARD_REANNOTATE_H */