Allow Update Schematic from PCB to re-link based on refdes.

Fixes https://gitlab.com/kicad/code/kicad/issues/4306
This commit is contained in:
Jeff Young 2020-07-16 18:31:36 +01:00
parent 11ef147a36
commit 944c9eac7c
11 changed files with 292 additions and 81 deletions

View File

@ -178,6 +178,18 @@ int SCH_REFERENCE_LIST::FindRefByPath( const wxString& aPath ) const
}
int SCH_REFERENCE_LIST::FindRef( const wxString& aRef ) const
{
for( size_t i = 0; i < flatList.size(); ++i )
{
if( flatList[i].GetRef() == aRef )
return i;
}
return -1;
}
void SCH_REFERENCE_LIST::GetRefsInUse( int aIndex, std::vector< int >& aIdList, int aMinRefId )
{
aIdList.clear();

View File

@ -42,7 +42,19 @@ DIALOG_UPDATE_FROM_PCB::DIALOG_UPDATE_FROM_PCB( SCH_EDIT_FRAME* aParent )
m_messagePanel->SetLazyUpdate( true );
m_messagePanel->GetSizer()->SetSizeHints( this );
m_cbRelinkFootprints->SetValue( s_savedDialogState.MatchByReference );
if( m_cbRelinkFootprints->GetValue() )
{
m_cbUpdateReferences->SetValue( false );
m_cbUpdateReferences->Enable( false );
}
else
{
m_cbUpdateReferences->SetValue( s_savedDialogState.UpdateReferences );
m_cbUpdateReferences->Enable( true );
}
m_cbUpdateFootprints->SetValue( s_savedDialogState.UpdateFootprints );
m_cbUpdateValues->SetValue( s_savedDialogState.UpdateValues );
m_cbUpdateNetNames->SetValue( s_savedDialogState.UpdateNetNames );
@ -64,6 +76,7 @@ void DIALOG_UPDATE_FROM_PCB::updateData()
m_messagePanel->Clear();
BACK_ANNOTATE backAnno( this->m_frame,
m_messagePanel->Reporter(),
m_cbRelinkFootprints->GetValue(),
m_cbUpdateFootprints->GetValue(),
m_cbUpdateValues->GetValue(),
m_cbUpdateReferences->GetValue(),
@ -91,11 +104,33 @@ DIALOG_UPDATE_FROM_PCB::~DIALOG_UPDATE_FROM_PCB()
void DIALOG_UPDATE_FROM_PCB::OnOptionChanged( wxCommandEvent& event )
{
if( event.GetEventObject() == m_cbRelinkFootprints )
{
if( m_cbRelinkFootprints->GetValue() )
{
m_cbUpdateReferences->SetValue( false );
m_cbUpdateReferences->Enable( false );
}
else
{
m_cbUpdateReferences->SetValue( s_savedDialogState.UpdateReferences );
m_cbUpdateReferences->Enable( true );
}
}
updateData();
if( event.GetEventObject() == m_cbRelinkFootprints )
s_savedDialogState.MatchByReference = m_cbRelinkFootprints->GetValue();
else if( event.GetEventObject() == m_cbUpdateReferences )
s_savedDialogState.UpdateReferences = m_cbUpdateReferences->GetValue();
else if( event.GetEventObject() == m_cbUpdateFootprints )
s_savedDialogState.UpdateFootprints = m_cbUpdateFootprints->GetValue();
else if( event.GetEventObject() == m_cbUpdateValues )
s_savedDialogState.UpdateValues = m_cbUpdateValues->GetValue();
else if( event.GetEventObject() == m_cbUpdateNetNames )
s_savedDialogState.UpdateNetNames = m_cbUpdateNetNames->GetValue();
else if( event.GetEventObject() == m_cbIgnoreOtherProjects )
s_savedDialogState.IgnoreOtherProjectsErrors = m_cbIgnoreOtherProjects->GetValue();
}
@ -105,6 +140,7 @@ void DIALOG_UPDATE_FROM_PCB::OnUpdateClick( wxCommandEvent& event )
m_messagePanel->Clear();
BACK_ANNOTATE backAnno( m_frame,
m_messagePanel->Reporter(),
m_cbRelinkFootprints->GetValue(),
m_cbUpdateFootprints->GetValue(),
m_cbUpdateValues->GetValue(),
m_cbUpdateReferences->GetValue(),
@ -119,6 +155,10 @@ void DIALOG_UPDATE_FROM_PCB::OnUpdateClick( wxCommandEvent& event )
m_frame->SyncView();
m_frame->OnModify();
m_frame->GetCanvas()->Refresh();
if( m_cbRelinkFootprints->GetValue() )
backAnno.PushNewLinksToPCB();
}
m_messagePanel->Flush( true );
}

View File

@ -40,6 +40,7 @@ class DIALOG_UPDATE_FROM_PCB : public DIALOG_UPDATE_FROM_PCB_BASE
struct DIALOG_UPDATE_FROM_PCB_SAVED_STATE
{
// Flags to remember last checkboxes state
bool MatchByReference;
bool UpdateReferences;
bool UpdateFootprints;
bool UpdateValues;

View File

@ -25,53 +25,68 @@ DIALOG_UPDATE_FROM_PCB_BASE::DIALOG_UPDATE_FROM_PCB_BASE( wxWindow* parent, wxWi
sbSizerOptions = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options") ), wxVERTICAL );
wxFlexGridSizer* fgSizer1;
fgSizer1 = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSizer1 = new wxFlexGridSizer( 0, 1, 0, 0 );
fgSizer1->SetFlexibleDirection( wxVERTICAL );
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_cbUpdateReferences = new wxCheckBox( sbSizerOptions->GetStaticBox(), wxID_ANY, _("Update reference designators"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbUpdateReferences->SetValue(true);
m_cbUpdateReferences->SetToolTip( _("Update references of symbols that have been changed in the PCB editor.") );
m_cbRelinkFootprints = new wxCheckBox( sbSizerOptions->GetStaticBox(), wxID_ANY, _("Re-link footprints to schematic symbols based on their reference designators"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbRelinkFootprints->SetToolTip( _("Normally footprints are linked to their symbols via their Unique IDs. Select this option only if you want to reset the footprint linkages based on their reference designators.") );
fgSizer1->Add( m_cbUpdateReferences, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( m_cbRelinkFootprints, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_cbIgnoreOtherProjects = new wxCheckBox( sbSizerOptions->GetStaticBox(), wxID_ANY, _("Ignore errors in shared schematic sheets"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbIgnoreOtherProjects->SetToolTip( _("Shared schematic sheets used in complex hierarchies have constraints. They are not always compatible with back annotation when updating footprints and values . \nIf this option is selected, errors generated by sharing will be disabled.") );
fgSizer1->Add( m_cbIgnoreOtherProjects, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_cbUpdateValues = new wxCheckBox( sbSizerOptions->GetStaticBox(), wxID_ANY, _("Update values"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbUpdateValues->SetToolTip( _("Update symbols values that have been replaced in the PCB editor.") );
fgSizer1->Add( m_cbUpdateValues, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
m_cbUpdateFootprints = new wxCheckBox( sbSizerOptions->GetStaticBox(), wxID_ANY, _("Update footprint assingments"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbUpdateFootprints->SetToolTip( _("Update footprint associations of symbols whose footprints have been replaced with different footprints in PCB.") );
fgSizer1->Add( m_cbUpdateFootprints, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
m_cbUpdateNetNames = new wxCheckBox( sbSizerOptions->GetStaticBox(), wxID_ANY, _("Update net names"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer1->Add( m_cbUpdateNetNames, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
sbSizerOptions->Add( fgSizer1, 1, wxEXPAND, 5 );
sbSizerOptions->Add( fgSizer1, 1, wxEXPAND|wxBOTTOM, 5 );
bUpperSizer->Add( sbSizerOptions, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* sbSizer2;
sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Update") ), wxVERTICAL );
wxFlexGridSizer* fgSizer2;
fgSizer2 = new wxFlexGridSizer( 0, 2, 0, 0 );
fgSizer2->AddGrowableCol( 0 );
fgSizer2->AddGrowableCol( 1 );
fgSizer2->SetFlexibleDirection( wxBOTH );
fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_cbUpdateReferences = new wxCheckBox( sbSizer2->GetStaticBox(), wxID_ANY, _("Reference designators"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbUpdateReferences->SetValue(true);
m_cbUpdateReferences->SetToolTip( _("Update references of symbols that have been changed in the PCB editor.") );
fgSizer2->Add( m_cbUpdateReferences, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_cbUpdateFootprints = new wxCheckBox( sbSizer2->GetStaticBox(), wxID_ANY, _("Footprint assignments"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbUpdateFootprints->SetToolTip( _("Update footprint associations of symbols whose footprints have been replaced with different footprints in PCB.") );
fgSizer2->Add( m_cbUpdateFootprints, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_cbUpdateValues = new wxCheckBox( sbSizer2->GetStaticBox(), wxID_ANY, _("Values"), wxDefaultPosition, wxDefaultSize, 0 );
m_cbUpdateValues->SetToolTip( _("Update symbols values that have been replaced in the PCB editor.") );
fgSizer2->Add( m_cbUpdateValues, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_cbUpdateNetNames = new wxCheckBox( sbSizer2->GetStaticBox(), wxID_ANY, _("Net names"), wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_cbUpdateNetNames, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
sbSizer2->Add( fgSizer2, 1, wxEXPAND, 5 );
bUpperSizer->Add( sbSizer2, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
bMainSizer->Add( bUpperSizer, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* bLowerSizer;
bLowerSizer = new wxBoxSizer( wxVERTICAL );
bLowerSizer->SetMinSize( wxSize( 660,300 ) );
bLowerSizer->SetMinSize( wxSize( 600,260 ) );
m_messagePanel = new WX_HTML_REPORT_PANEL( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
bLowerSizer->Add( m_messagePanel, 1, wxEXPAND | wxALL, 5 );
@ -93,10 +108,11 @@ DIALOG_UPDATE_FROM_PCB_BASE::DIALOG_UPDATE_FROM_PCB_BASE( wxWindow* parent, wxWi
bMainSizer->Fit( this );
// Connect Events
m_cbUpdateReferences->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_cbRelinkFootprints->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_cbIgnoreOtherProjects->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_cbUpdateValues->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_cbUpdateReferences->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_cbUpdateFootprints->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_cbUpdateValues->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_cbUpdateNetNames->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnUpdateClick ), NULL, this );
}
@ -104,10 +120,11 @@ DIALOG_UPDATE_FROM_PCB_BASE::DIALOG_UPDATE_FROM_PCB_BASE( wxWindow* parent, wxWi
DIALOG_UPDATE_FROM_PCB_BASE::~DIALOG_UPDATE_FROM_PCB_BASE()
{
// Disconnect Events
m_cbUpdateReferences->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_cbRelinkFootprints->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_cbIgnoreOtherProjects->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_cbUpdateValues->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_cbUpdateReferences->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_cbUpdateFootprints->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_cbUpdateValues->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_cbUpdateNetNames->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnOptionChanged ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_UPDATE_FROM_PCB_BASE::OnUpdateClick ), NULL, this );

View File

@ -81,10 +81,10 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="flag">wxEXPAND|wxBOTTOM</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">2</property>
<property name="cols">1</property>
<property name="flexible_direction">wxVERTICAL</property>
<property name="growablecols"></property>
<property name="growablerows"></property>
@ -99,7 +99,7 @@
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -113,7 +113,7 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">1</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
@ -128,7 +128,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Update reference designators</property>
<property name="label">Re-link footprints to schematic symbols based on their reference designators</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -136,7 +136,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbUpdateReferences</property>
<property name="name">m_cbRelinkFootprints</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -149,7 +149,7 @@
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Update references of symbols that have been changed in the PCB editor.</property>
<property name="tooltip">Normally footprints are linked to their symbols via their Unique IDs. Select this option only if you want to reset the footprint linkages based on their reference designators.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
@ -225,6 +225,38 @@
<event name="OnCheckBox">OnOptionChanged</event>
</object>
</object>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Update</property>
<property name="minimum_size"></property>
<property name="name">sbSizer2</property>
<property name="orient">wxVERTICAL</property>
<property name="parent">1</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">2</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">0,1</property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size"></property>
<property name="name">fgSizer2</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
@ -243,7 +275,7 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="checked">1</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
@ -258,7 +290,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Update values</property>
<property name="label">Reference designators</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -266,7 +298,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbUpdateValues</property>
<property name="name">m_cbUpdateReferences</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -277,9 +309,9 @@
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Update symbols values that have been replaced in the PCB editor.</property>
<property name="tooltip">Update references of symbols that have been changed in the PCB editor.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
@ -290,16 +322,6 @@
<event name="OnCheckBox">OnOptionChanged</event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
@ -333,7 +355,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Update footprint assingments</property>
<property name="label">Footprint assignments</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -367,12 +389,67 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Values</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbUpdateValues</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="width">0</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Update symbols values that have been replaced in the PCB editor.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnCheckBox">OnOptionChanged</event>
</object>
</object>
<object class="sizeritem" expanded="1">
@ -408,7 +485,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Update net names</property>
<property name="label">Net names</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -451,7 +528,7 @@
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size">660,300</property>
<property name="minimum_size">600,260</property>
<property name="name">bLowerSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>

View File

@ -35,10 +35,11 @@ class DIALOG_UPDATE_FROM_PCB_BASE : public DIALOG_SHIM
private:
protected:
wxCheckBox* m_cbUpdateReferences;
wxCheckBox* m_cbRelinkFootprints;
wxCheckBox* m_cbIgnoreOtherProjects;
wxCheckBox* m_cbUpdateValues;
wxCheckBox* m_cbUpdateReferences;
wxCheckBox* m_cbUpdateFootprints;
wxCheckBox* m_cbUpdateValues;
wxCheckBox* m_cbUpdateNetNames;
WX_HTML_REPORT_PANEL* m_messagePanel;
wxStdDialogButtonSizer* m_sdbSizer;

View File

@ -422,6 +422,13 @@ public:
sort( flatList.begin(), flatList.end(), sortByReferenceOnly );
}
/**
* searches the list for a component with a given reference.
* @param aPath
* @return
*/
int FindRef( const wxString& aPath ) const;
/**
* searches the sorted list of components for a another component with the same
* reference and a given part unit. Use this method to manage components with
@ -433,7 +440,7 @@ public:
int FindUnit( size_t aIndex, int aUnit );
/**
* @brief Searches unit with designated path
* searches the list for a component with the given KIID path
* @param aPath path to search
* @return index in aComponentsList if found or -1 if not found
*/

View File

@ -35,11 +35,12 @@
#include <kiface_i.h>
#include <wildcards_and_files_ext.h>
BACK_ANNOTATE::BACK_ANNOTATE( SCH_EDIT_FRAME* aFrame, REPORTER& aReporter,
BACK_ANNOTATE::BACK_ANNOTATE( SCH_EDIT_FRAME* aFrame, REPORTER& aReporter, bool aRelinkFootprints,
bool aProcessFootprints, bool aProcessValues,
bool aProcessReferences, bool aProcessNetNames,
bool aIgnoreOtherProjects, bool aDryRun ) :
m_reporter( aReporter ),
m_matchByReference( aRelinkFootprints ),
m_processFootprints( aProcessFootprints ),
m_processValues( aProcessValues ),
m_processReferences( aProcessReferences ),
@ -113,6 +114,14 @@ bool BACK_ANNOTATE::FetchNetlistFromPCB( std::string& aNetlist )
}
void BACK_ANNOTATE::PushNewLinksToPCB()
{
std::string nullPayload;
m_frame->Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_PCB_UPDATE_LINKS, nullPayload );
}
void BACK_ANNOTATE::getPcbModulesFromString( const std::string& aPayload )
{
auto getStr = []( const PTREE& pt ) -> wxString
@ -142,6 +151,9 @@ void BACK_ANNOTATE::getPcbModulesFromString( const std::string& aPayload )
try
{
if( m_matchByReference )
path = ref;
else
path = getStr( item.second.get_child( "timestamp" ) );
if( path == "" )
@ -198,15 +210,20 @@ void BACK_ANNOTATE::getChangeList()
{
const wxString& pcbPath = module.first;
auto& pcbData = module.second;
int refIndex;
bool foundInMultiunit = false;
for( auto& item : m_multiUnitsRefs )
for( std::pair<const wxString, SCH_REFERENCE_LIST>& item : m_multiUnitsRefs )
{
SCH_REFERENCE_LIST& refList = item.second;
if( refList.FindRefByPath( pcbPath ) >= 0 )
{
if( m_matchByReference )
refIndex = refList.FindRef( pcbPath );
else
refIndex = refList.FindRefByPath( pcbPath );
if( refIndex >= 0 )
{
// If module linked to multi unit symbol, we add all symbol's units to
// the change list
foundInMultiunit = true;
@ -224,7 +241,10 @@ void BACK_ANNOTATE::getChangeList()
if( foundInMultiunit )
continue;
int refIndex = m_refs.FindRefByPath( pcbPath );
if( m_matchByReference )
refIndex = m_refs.FindRef( pcbPath );
else
refIndex = m_refs.FindRefByPath( pcbPath );
if( refIndex >= 0 )
{
@ -266,6 +286,12 @@ void BACK_ANNOTATE::checkForUnusedSymbols()
++i;
}
if( m_matchByReference && !m_frame->ReadyToNetlist() )
{
m_reporter.ReportTail( _( "Cannot relink footprints because schematic is not fully annotated" ),
RPT_SEVERITY_ERROR );
}
}

View File

@ -79,9 +79,9 @@ public:
using CHANGELIST_ITEM = std::pair<SCH_REFERENCE, std::shared_ptr<PCB_MODULE_DATA>>;
BACK_ANNOTATE( SCH_EDIT_FRAME* aFrame, REPORTER& aReporter, bool aProcessFootprints,
bool aProcessValues, bool aProcessReferences, bool aProcessNetNames,
bool aIgnoreOtherProjects, bool aDryRun );
BACK_ANNOTATE( SCH_EDIT_FRAME* aFrame, REPORTER& aReporter, bool aRelinkFootprints,
bool aProcessFootprints, bool aProcessValues, bool aProcessReferences,
bool aProcessNetNames, bool aIgnoreOtherProjects, bool aDryRun );
~BACK_ANNOTATE();
/**
@ -91,6 +91,8 @@ public:
*/
bool FetchNetlistFromPCB( std::string& aNetlist );
void PushNewLinksToPCB();
/**
* @brief Run back annotation algorithm. If any errors, back annotation doesn't run.
* only report
@ -102,6 +104,7 @@ public:
private:
REPORTER& m_reporter;
bool m_matchByReference;
bool m_processFootprints;
bool m_processValues;
bool m_processReferences;

View File

@ -45,6 +45,7 @@ enum MAIL_T
MAIL_IMPORT_FILE, // Import a different format file
MAIL_SCH_GET_NETLIST, // Fetch a netlist from schematics
MAIL_PCB_GET_NETLIST, // Fetch a netlist from PCB layout
MAIL_PCB_UPDATE_LINKS, // Update the schematic symbol paths in the PCB's footprints
MAIL_SCH_REFRESH, // Tell the schematic editor to refresh the display.
MAIL_SCH_CLEAN_NETCLASSES, // Tell the schematic editor to clean stale nets out of

View File

@ -41,11 +41,13 @@
#include <kiway_express.h>
#include <macros.h>
#include <netlist_reader/pcb_netlist.h>
#include <netlist_reader/board_netlist_updater.h>
#include <pcb_edit_frame.h>
#include <pcbnew_settings.h>
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>
#include <tools/selection_tool.h>
#include <netlist_reader/netlist_reader.h>
/* Execute a remote command send by Eeschema via a socket,
* port KICAD_PCB_PORT_SERVICE_NUMBER
@ -416,8 +418,33 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
netlist.Format( "pcb_netlist", &sf, 0, CTL_OMIT_FILTERS );
payload = sf.GetString();
break;
}
break;
case MAIL_PCB_UPDATE_LINKS:
try
{
NETLIST netlist;
FetchNetlistFromSchematic( netlist, NO_ANNOTATION );
BOARD_NETLIST_UPDATER updater( this, GetBoard() );
updater.SetLookupByTimestamp( false );
updater.SetDeleteUnusedComponents ( false );
updater.SetReplaceFootprints( false );
updater.SetDeleteSinglePadNets( false );
updater.SetWarnPadNoNetInNetlist( false );
updater.UpdateNetlist( netlist );
bool dummy;
OnNetlistChanged( updater, &dummy );
}
catch( const IO_ERROR& )
{
assert( false ); // should never happen
return;
}
break;
case MAIL_CROSS_PROBE:
ExecuteRemoteCommand( payload.c_str() );
break;
@ -448,9 +475,8 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
if( importFormat >= 0 )
importFile( path, importFormat );
break;
}
break;
// many many others.
default: