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 6fa8cab188
)
This commit is contained in:
parent
c9829cf9a8
commit
6de8b99cf2
|
@ -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) 2020 Brian Piccioni brian@documenteddesigns.com
|
* 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 <brian@documenteddesigns.com>
|
* @author Brian Piccioni <brian@documenteddesigns.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -30,14 +30,10 @@
|
||||||
#include <confirm.h>
|
#include <confirm.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <dialog_board_reannotate.h>
|
#include <dialog_board_reannotate.h>
|
||||||
#include <fstream>
|
|
||||||
#include <string_utils.h> // StrNumCmp
|
#include <string_utils.h> // StrNumCmp
|
||||||
#include <kiface_base.h>
|
#include <kiface_base.h>
|
||||||
#include <mail_type.h>
|
|
||||||
#include <pcbnew_settings.h>
|
#include <pcbnew_settings.h>
|
||||||
#include <refdes_utils.h>
|
#include <refdes_utils.h>
|
||||||
#include <sstream>
|
|
||||||
#include <tool/tool_manager.h>
|
|
||||||
#include <tool/grid_menu.h>
|
#include <tool/grid_menu.h>
|
||||||
#include <wx/valtext.h>
|
#include <wx/valtext.h>
|
||||||
|
|
||||||
|
@ -136,16 +132,12 @@ DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE( PCB_EDIT_FRAME* aParentFrame )
|
||||||
m_selection = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
m_selection = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
||||||
|
|
||||||
if( !m_selection.Empty() )
|
if( !m_selection.Empty() )
|
||||||
m_annotationChoice = AnnotationChoice::AnnotateSelected;
|
m_annotationScope = AnnotateSelected;
|
||||||
|
|
||||||
for( wxRadioButton* button : AnnotateWhat )
|
for( wxRadioButton* button : m_scopeRadioButtons )
|
||||||
button->SetValue( false );
|
button->SetValue( false );
|
||||||
|
|
||||||
m_annotationChoice = ( m_sortCode >= (int) AnnotateWhat.size() ) ?
|
m_scopeRadioButtons[m_annotationScope]->SetValue( true );
|
||||||
AnnotationChoice::AnnotateAll :
|
|
||||||
m_annotationChoice;
|
|
||||||
|
|
||||||
AnnotateWhat[m_annotationChoice]->SetValue( true );
|
|
||||||
|
|
||||||
reannotate_down_right_bitmap->SetBitmap( KiBitmap( BITMAPS::reannotate_right_down ) );
|
reannotate_down_right_bitmap->SetBitmap( KiBitmap( BITMAPS::reannotate_right_down ) );
|
||||||
reannotate_right_down_bitmap->SetBitmap( KiBitmap( BITMAPS::reannotate_left_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.grid_index = m_gridIndex;
|
||||||
cfg->m_Reannotate.sort_code = m_sortCode;
|
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.report_severity = m_severity;
|
||||||
|
|
||||||
cfg->m_Reannotate.front_refdes_start = m_FrontRefDesStart->GetValue();
|
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_gridIndex = cfg->m_Reannotate.grid_index ;
|
||||||
m_sortCode = cfg->m_Reannotate.sort_code ;
|
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_severity = cfg->m_Reannotate.report_severity;
|
||||||
|
|
||||||
m_FrontRefDesStart->SetValue( cfg->m_Reannotate.front_refdes_start );
|
m_FrontRefDesStart->SetValue( cfg->m_Reannotate.front_refdes_start );
|
||||||
|
@ -311,7 +303,7 @@ void DIALOG_BOARD_REANNOTATE::MakeSampleText( wxString& aMessage )
|
||||||
wxString tmp;
|
wxString tmp;
|
||||||
|
|
||||||
aMessage.Printf( _( "\n%s footprints will be reannotated." ),
|
aMessage.Printf( _( "\n%s footprints will be reannotated." ),
|
||||||
_( AnnotateString[m_annotationChoice] ) );
|
_( AnnotateString[m_annotationScope] ) );
|
||||||
|
|
||||||
if( !m_ExcludeList->GetValue().empty() )
|
if( !m_ExcludeList->GetValue().empty() )
|
||||||
{
|
{
|
||||||
|
@ -418,18 +410,16 @@ void DIALOG_BOARD_REANNOTATE::GetParameters()
|
||||||
m_sortGridy = m_sortGridx;
|
m_sortGridy = m_sortGridx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
m_annotationScope = AnnotateAll;
|
||||||
|
|
||||||
for( wxRadioButton* button : AnnotateWhat )
|
for( wxRadioButton* button : m_scopeRadioButtons )
|
||||||
{
|
{
|
||||||
if( button->GetValue() )
|
if( button->GetValue() )
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
i++;
|
m_annotationScope++;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_annotationChoice = ( i >= (int) AnnotateWhat.size() ) ? AnnotationChoice::AnnotateAll : i;
|
|
||||||
|
|
||||||
m_MessageWindow->SetLazyUpdate( true );
|
m_MessageWindow->SetLazyUpdate( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,7 +632,7 @@ bool DIALOG_BOARD_REANNOTATE::ReannotateBoard()
|
||||||
|
|
||||||
bool DIALOG_BOARD_REANNOTATE::BuildFootprintList( std::vector<RefDesInfo>& aBadRefDes )
|
bool DIALOG_BOARD_REANNOTATE::BuildFootprintList( std::vector<RefDesInfo>& aBadRefDes )
|
||||||
{
|
{
|
||||||
bool annotateSelected;
|
bool annotateSelected = m_AnnotateSelection->GetValue();
|
||||||
bool annotateFront = m_AnnotateFront->GetValue(); // Unless only doing back
|
bool annotateFront = m_AnnotateFront->GetValue(); // Unless only doing back
|
||||||
bool annotateBack = m_AnnotateBack->GetValue(); // Unless only doing front
|
bool annotateBack = m_AnnotateBack->GetValue(); // Unless only doing front
|
||||||
bool skipLocked = m_ExcludeLocked->GetValue();
|
bool skipLocked = m_ExcludeLocked->GetValue();
|
||||||
|
@ -657,7 +647,7 @@ bool DIALOG_BOARD_REANNOTATE::BuildFootprintList( std::vector<RefDesInfo>& aBadR
|
||||||
|
|
||||||
std::vector<KIID> selected;
|
std::vector<KIID> selected;
|
||||||
|
|
||||||
if( m_AnnotateSelection->GetValue() )
|
if( annotateSelected )
|
||||||
{
|
{
|
||||||
for( EDA_ITEM* item : m_selection )
|
for( EDA_ITEM* item : m_selection )
|
||||||
{
|
{
|
||||||
|
@ -667,8 +657,6 @@ bool DIALOG_BOARD_REANNOTATE::BuildFootprintList( std::vector<RefDesInfo>& aBadR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
annotateSelected = !selected.empty();
|
|
||||||
|
|
||||||
wxString exclude;
|
wxString exclude;
|
||||||
|
|
||||||
// Break exclude list into words.
|
// Break exclude list into words.
|
||||||
|
@ -799,7 +787,8 @@ bool DIALOG_BOARD_REANNOTATE::BuildFootprintList( std::vector<RefDesInfo>& aBadR
|
||||||
{
|
{
|
||||||
if( m_changeArray[i].NewRefDes == m_changeArray[j].NewRefDes )
|
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 );
|
RPT_SEVERITY_ERROR );
|
||||||
|
|
||||||
if( errorcount++ > MAXERROR )
|
if( errorcount++ > MAXERROR )
|
||||||
|
|
|
@ -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) 2020 Brian Piccioni brian@documenteddesigns.com
|
* 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 <brian@documenteddesigns.com>
|
* @author Brian Piccioni <brian@documenteddesigns.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* 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
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DIALOG_BOARD_REANNOTATE_H_
|
#ifndef DIALOG_BOARD_REANNOTATE_H
|
||||||
#define DIALOG_BOARD_REANNOTATE_H_
|
#define DIALOG_BOARD_REANNOTATE_H
|
||||||
|
|
||||||
#include <board.h>
|
#include <board.h>
|
||||||
#include <footprint.h>
|
#include <footprint.h>
|
||||||
|
@ -60,9 +60,9 @@ enum ActionCode
|
||||||
Exclude
|
Exclude
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AnnotationChoice
|
enum AnnotationScope
|
||||||
{
|
{
|
||||||
AnnotateAll,
|
AnnotateAll = 0,
|
||||||
AnnotateFront,
|
AnnotateFront,
|
||||||
AnnotateBack,
|
AnnotateBack,
|
||||||
AnnotateSelected
|
AnnotateSelected
|
||||||
|
@ -115,7 +115,7 @@ private:
|
||||||
m_Left_Up
|
m_Left_Up
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<wxRadioButton*> AnnotateWhat = {
|
std::vector<wxRadioButton*> m_scopeRadioButtons = {
|
||||||
m_AnnotateAll,
|
m_AnnotateAll,
|
||||||
m_AnnotateFront,
|
m_AnnotateFront,
|
||||||
m_AnnotateBack,
|
m_AnnotateBack,
|
||||||
|
@ -200,7 +200,7 @@ private:
|
||||||
|
|
||||||
int m_sortCode;
|
int m_sortCode;
|
||||||
int m_gridIndex;
|
int m_gridIndex;
|
||||||
int m_annotationChoice;
|
int m_annotationScope;
|
||||||
int m_severity;
|
int m_severity;
|
||||||
|
|
||||||
double m_sortGridx;
|
double m_sortGridx;
|
||||||
|
@ -215,4 +215,4 @@ private:
|
||||||
APP_SETTINGS_BASE* m_Config;
|
APP_SETTINGS_BASE* m_Config;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* DIALOG_BOARD_REANNOTATECLASSES_H_ */
|
#endif /* DIALOG_BOARD_REANNOTATE_H */
|
||||||
|
|
Loading…
Reference in New Issue