2020-01-29 16:33:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 Alexander Shuklin <Jasuramme@gmail.com>
|
2021-02-09 16:35:43 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-01-29 16:33:57 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <backannotate.h>
|
|
|
|
#include <dialog_update_from_pcb.h>
|
|
|
|
#include <sch_edit_frame.h>
|
|
|
|
#include <sch_editor_control.h>
|
|
|
|
#include <wx_html_report_panel.h>
|
|
|
|
|
|
|
|
// Saved dialog settings
|
|
|
|
DIALOG_UPDATE_FROM_PCB::DIALOG_UPDATE_FROM_PCB_SAVED_STATE
|
2020-09-30 22:32:30 +00:00
|
|
|
DIALOG_UPDATE_FROM_PCB::s_savedDialogState{ true, true, true, true, false };
|
2020-01-29 16:33:57 +00:00
|
|
|
|
2020-11-23 23:54:34 +00:00
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
DIALOG_UPDATE_FROM_PCB::DIALOG_UPDATE_FROM_PCB( SCH_EDIT_FRAME* aParent )
|
|
|
|
: DIALOG_UPDATE_FROM_PCB_BASE( aParent ),
|
|
|
|
m_frame( aParent ),
|
|
|
|
m_editorControl( m_frame->GetToolManager()->GetTool<SCH_EDITOR_CONTROL>() )
|
|
|
|
|
|
|
|
{
|
|
|
|
m_messagePanel->SetLabel( _( "Changes To Be Applied" ) );
|
2021-02-25 15:05:26 +00:00
|
|
|
m_messagePanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
|
2020-01-29 16:33:57 +00:00
|
|
|
m_messagePanel->SetLazyUpdate( true );
|
|
|
|
m_messagePanel->GetSizer()->SetSizeHints( this );
|
|
|
|
|
2020-07-16 17:31:36 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
m_cbUpdateFootprints->SetValue( s_savedDialogState.UpdateFootprints );
|
|
|
|
m_cbUpdateValues->SetValue( s_savedDialogState.UpdateValues );
|
2020-06-08 18:36:25 +00:00
|
|
|
m_cbUpdateNetNames->SetValue( s_savedDialogState.UpdateNetNames );
|
2020-01-29 16:33:57 +00:00
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons( { { wxID_OK, _( "Update Schematic" ) },
|
|
|
|
{ wxID_CANCEL, _( "Close" ) } } );
|
2020-01-29 16:33:57 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
|
|
|
|
2020-11-23 23:54:34 +00:00
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
void DIALOG_UPDATE_FROM_PCB::updateData()
|
|
|
|
{
|
|
|
|
bool successfulRun = false;
|
|
|
|
m_messagePanel->Clear();
|
2021-02-09 16:35:43 +00:00
|
|
|
BACK_ANNOTATE backAnno( m_frame,
|
2020-06-08 18:36:25 +00:00
|
|
|
m_messagePanel->Reporter(),
|
2020-07-16 17:31:36 +00:00
|
|
|
m_cbRelinkFootprints->GetValue(),
|
2020-06-08 18:36:25 +00:00
|
|
|
m_cbUpdateFootprints->GetValue(),
|
|
|
|
m_cbUpdateValues->GetValue(),
|
|
|
|
m_cbUpdateReferences->GetValue(),
|
|
|
|
m_cbUpdateNetNames->GetValue(),
|
|
|
|
true );
|
2020-01-29 16:33:57 +00:00
|
|
|
std::string netlist;
|
|
|
|
|
|
|
|
if( backAnno.FetchNetlistFromPCB( netlist ) )
|
|
|
|
successfulRun = backAnno.BackAnnotateSymbols( netlist );
|
2020-06-08 18:36:25 +00:00
|
|
|
|
2020-01-30 08:22:21 +00:00
|
|
|
m_sdbSizerOK->Enable( successfulRun );
|
2020-01-29 16:33:57 +00:00
|
|
|
m_messagePanel->Flush( false );
|
|
|
|
}
|
|
|
|
|
2020-11-23 23:54:34 +00:00
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
bool DIALOG_UPDATE_FROM_PCB::TransferDataToWindow()
|
|
|
|
{
|
|
|
|
updateData();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-11-23 23:54:34 +00:00
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
DIALOG_UPDATE_FROM_PCB::~DIALOG_UPDATE_FROM_PCB()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-11-23 23:54:34 +00:00
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
void DIALOG_UPDATE_FROM_PCB::OnOptionChanged( wxCommandEvent& event )
|
|
|
|
{
|
2020-07-16 17:31:36 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
updateData();
|
2020-07-16 17:31:36 +00:00
|
|
|
|
|
|
|
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();
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
|
|
|
|
2020-11-23 23:54:34 +00:00
|
|
|
|
2020-01-29 16:33:57 +00:00
|
|
|
void DIALOG_UPDATE_FROM_PCB::OnUpdateClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
std::string netlist;
|
|
|
|
m_messagePanel->Clear();
|
2020-06-08 18:36:25 +00:00
|
|
|
BACK_ANNOTATE backAnno( m_frame,
|
|
|
|
m_messagePanel->Reporter(),
|
2020-07-16 17:31:36 +00:00
|
|
|
m_cbRelinkFootprints->GetValue(),
|
2020-06-08 18:36:25 +00:00
|
|
|
m_cbUpdateFootprints->GetValue(),
|
|
|
|
m_cbUpdateValues->GetValue(),
|
|
|
|
m_cbUpdateReferences->GetValue(),
|
|
|
|
m_cbUpdateNetNames->GetValue(),
|
|
|
|
false );
|
2020-01-29 16:33:57 +00:00
|
|
|
|
|
|
|
if( backAnno.FetchNetlistFromPCB( netlist ) && backAnno.BackAnnotateSymbols( netlist ) )
|
|
|
|
{
|
2020-05-13 02:00:37 +00:00
|
|
|
m_frame->GetCurrentSheet().UpdateAllScreenReferences();
|
2020-01-29 16:33:57 +00:00
|
|
|
m_frame->SetSheetNumberAndCount();
|
|
|
|
m_frame->SyncView();
|
|
|
|
m_frame->OnModify();
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
2020-07-16 17:31:36 +00:00
|
|
|
|
|
|
|
if( m_cbRelinkFootprints->GetValue() )
|
|
|
|
backAnno.PushNewLinksToPCB();
|
2020-11-26 15:43:48 +00:00
|
|
|
|
|
|
|
m_sdbSizerCancel->SetDefault();
|
|
|
|
m_sdbSizerOK->Enable( false );
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|
2020-07-16 17:31:36 +00:00
|
|
|
|
2020-11-23 23:54:34 +00:00
|
|
|
m_messagePanel->Flush( false );
|
2020-01-29 16:33:57 +00:00
|
|
|
}
|