2016-10-25 13:34:59 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2020-11-26 11:57:40 +00:00
|
|
|
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-10-25 13:34:59 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pcbnew_settings.h>
|
2016-01-29 10:24:39 +00:00
|
|
|
#include <dialog_update_pcb.h>
|
2020-06-16 18:15:14 +00:00
|
|
|
#include <ratsnest/ratsnest_data.h>
|
2022-09-03 18:29:02 +00:00
|
|
|
#include "widgets/wx_html_report_panel.h"
|
2019-11-17 12:58:38 +00:00
|
|
|
#include <netlist_reader/pcb_netlist.h>
|
|
|
|
#include <netlist_reader/board_netlist_updater.h>
|
2016-01-29 10:24:39 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2017-02-21 12:42:08 +00:00
|
|
|
#include <tools/pcb_actions.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2020-11-26 15:43:48 +00:00
|
|
|
#include <kiplatform/ui.h>
|
2018-02-28 09:44:22 +00:00
|
|
|
|
|
|
|
|
2018-02-15 08:49:53 +00:00
|
|
|
DIALOG_UPDATE_PCB::DIALOG_UPDATE_PCB( PCB_EDIT_FRAME* aParent, NETLIST* aNetlist ) :
|
|
|
|
DIALOG_UPDATE_PCB_BASE( aParent ),
|
|
|
|
m_frame( aParent ),
|
2018-02-28 09:44:22 +00:00
|
|
|
m_netlist( aNetlist ),
|
|
|
|
m_initialized( false )
|
2016-01-29 10:24:39 +00:00
|
|
|
{
|
2020-05-06 01:43:37 +00:00
|
|
|
auto cfg = m_frame->GetPcbNewSettings();
|
2018-02-28 09:44:22 +00:00
|
|
|
|
2020-05-05 13:20:02 +00:00
|
|
|
m_cbRelinkFootprints->SetValue( cfg->m_NetlistDialog.associate_by_ref_sch );
|
2020-01-13 01:44:19 +00:00
|
|
|
m_cbUpdateFootprints->SetValue( cfg->m_NetlistDialog.update_footprints );
|
|
|
|
m_cbDeleteExtraFootprints->SetValue( cfg->m_NetlistDialog.delete_extra_footprints );
|
2018-02-28 09:44:22 +00:00
|
|
|
|
|
|
|
m_messagePanel->SetLabel( _("Changes To Be Applied") );
|
2021-02-25 15:05:26 +00:00
|
|
|
m_messagePanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
|
2016-09-02 13:53:51 +00:00
|
|
|
m_messagePanel->SetLazyUpdate( true );
|
2016-01-29 10:24:39 +00:00
|
|
|
m_netlist->SortByReference();
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_messagePanel->SetVisibleSeverities( cfg->m_NetlistDialog.report_filter );
|
2018-03-10 17:19:52 +00:00
|
|
|
|
2018-05-22 20:27:51 +00:00
|
|
|
m_messagePanel->GetSizer()->SetSizeHints( this );
|
2020-03-16 22:42:51 +00:00
|
|
|
m_messagePanel->Layout();
|
2018-02-28 09:44:22 +00:00
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons( { { wxID_OK, _( "Update PCB" ) },
|
|
|
|
{ wxID_CANCEL, _( "Close" ) } } );
|
2018-02-28 09:44:22 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2018-02-28 09:44:22 +00:00
|
|
|
|
|
|
|
m_initialized = true;
|
|
|
|
PerformUpdate( true );
|
2016-01-29 10:24:39 +00:00
|
|
|
}
|
|
|
|
|
2016-09-02 13:53:51 +00:00
|
|
|
|
2016-01-29 10:24:39 +00:00
|
|
|
DIALOG_UPDATE_PCB::~DIALOG_UPDATE_PCB()
|
|
|
|
{
|
2023-10-16 21:04:01 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = nullptr;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
cfg = m_frame->GetPcbNewSettings();
|
|
|
|
}
|
|
|
|
catch( const std::runtime_error& e )
|
|
|
|
{
|
|
|
|
wxFAIL_MSG( e.what() );
|
|
|
|
}
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2023-10-16 21:04:01 +00:00
|
|
|
if( cfg )
|
|
|
|
{
|
|
|
|
cfg->m_NetlistDialog.associate_by_ref_sch = m_cbRelinkFootprints->GetValue();
|
|
|
|
cfg->m_NetlistDialog.update_footprints = m_cbUpdateFootprints->GetValue();
|
|
|
|
cfg->m_NetlistDialog.delete_extra_footprints = m_cbDeleteExtraFootprints->GetValue();
|
|
|
|
cfg->m_NetlistDialog.report_filter = m_messagePanel->GetVisibleSeverities();
|
|
|
|
}
|
2018-12-10 19:34:08 +00:00
|
|
|
|
|
|
|
if( m_runDragCommand )
|
2019-08-12 21:17:25 +00:00
|
|
|
{
|
|
|
|
KIGFX::VIEW_CONTROLS* controls = m_frame->GetCanvas()->GetViewControls();
|
|
|
|
controls->SetCursorPosition( controls->GetMousePosition() );
|
2023-06-26 22:16:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::move );
|
2019-08-12 21:17:25 +00:00
|
|
|
}
|
2016-01-29 10:24:39 +00:00
|
|
|
}
|
|
|
|
|
2016-09-02 13:53:51 +00:00
|
|
|
|
2016-01-29 10:24:39 +00:00
|
|
|
void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
|
|
|
|
{
|
|
|
|
m_messagePanel->Clear();
|
|
|
|
|
2016-09-13 08:06:49 +00:00
|
|
|
REPORTER& reporter = m_messagePanel->Reporter();
|
2016-01-29 10:24:39 +00:00
|
|
|
|
2018-12-10 19:34:08 +00:00
|
|
|
m_runDragCommand = false;
|
2016-01-29 10:24:39 +00:00
|
|
|
|
2020-03-13 17:28:17 +00:00
|
|
|
m_netlist->SetFindByTimeStamp( !m_cbRelinkFootprints->GetValue() );
|
2018-02-28 09:44:22 +00:00
|
|
|
m_netlist->SetReplaceFootprints( m_cbUpdateFootprints->GetValue() );
|
2016-01-29 10:31:26 +00:00
|
|
|
|
2021-09-20 19:20:41 +00:00
|
|
|
if( !aDryRun )
|
|
|
|
{
|
|
|
|
m_frame->GetToolManager()->DeactivateTool();
|
2023-06-26 22:16:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear );
|
2021-09-20 19:20:41 +00:00
|
|
|
}
|
|
|
|
|
2016-01-29 10:24:39 +00:00
|
|
|
BOARD_NETLIST_UPDATER updater( m_frame, m_frame->GetBoard() );
|
|
|
|
updater.SetReporter ( &reporter );
|
2018-02-15 08:49:53 +00:00
|
|
|
updater.SetIsDryRun( aDryRun );
|
2020-03-13 17:28:17 +00:00
|
|
|
updater.SetLookupByTimestamp( !m_cbRelinkFootprints->GetValue() );
|
2021-05-23 21:21:34 +00:00
|
|
|
updater.SetDeleteUnusedFootprints( m_cbDeleteExtraFootprints->GetValue());
|
2018-02-28 09:44:22 +00:00
|
|
|
updater.SetReplaceFootprints( m_cbUpdateFootprints->GetValue() );
|
2016-01-29 10:24:39 +00:00
|
|
|
updater.UpdateNetlist( *m_netlist );
|
|
|
|
|
2018-05-21 22:28:26 +00:00
|
|
|
m_messagePanel->Flush( true );
|
2016-01-29 10:24:39 +00:00
|
|
|
|
|
|
|
if( aDryRun )
|
|
|
|
return;
|
|
|
|
|
2019-04-18 02:10:56 +00:00
|
|
|
m_frame->OnNetlistChanged( updater, &m_runDragCommand );
|
2018-02-28 09:44:22 +00:00
|
|
|
}
|
2016-03-17 03:05:08 +00:00
|
|
|
|
2018-02-28 09:44:22 +00:00
|
|
|
|
|
|
|
void DIALOG_UPDATE_PCB::OnOptionChanged( wxCommandEvent& event )
|
2016-01-29 10:24:39 +00:00
|
|
|
{
|
2018-02-28 09:44:22 +00:00
|
|
|
if( m_initialized )
|
2020-11-26 15:43:48 +00:00
|
|
|
{
|
2018-02-28 09:44:22 +00:00
|
|
|
PerformUpdate( true );
|
2020-11-26 15:43:48 +00:00
|
|
|
m_sdbSizer1OK->Enable( true );
|
|
|
|
m_sdbSizer1OK->SetDefault();
|
|
|
|
}
|
2016-01-29 10:24:39 +00:00
|
|
|
}
|
|
|
|
|
2016-09-02 13:53:51 +00:00
|
|
|
|
2016-01-29 10:24:39 +00:00
|
|
|
void DIALOG_UPDATE_PCB::OnUpdateClick( wxCommandEvent& event )
|
|
|
|
{
|
2020-11-26 15:43:48 +00:00
|
|
|
m_messagePanel->SetLabel( _( "Changes Applied to PCB" ) );
|
2016-01-29 10:24:39 +00:00
|
|
|
PerformUpdate( false );
|
2020-11-26 15:43:48 +00:00
|
|
|
|
2018-02-28 09:44:22 +00:00
|
|
|
m_sdbSizer1Cancel->SetDefault();
|
2024-01-10 17:23:29 +00:00
|
|
|
// wxWidgets has a tendency to keep both buttons highlighted without the following:
|
2020-11-26 15:43:48 +00:00
|
|
|
m_sdbSizer1OK->Enable( false );
|
2016-01-29 10:24:39 +00:00
|
|
|
}
|