KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_update_from_pcb.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2019 Alexander Shuklin <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <backannotate.h>
27#include <sch_edit_frame.h>
28#include <sch_editor_control.h>
30
31
34 m_frame( aParent )
35{
36 m_messagePanel->SetLabel( _( "Changes to Be Applied" ) );
37 m_messagePanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
38 m_messagePanel->SetLazyUpdate( true );
39 m_messagePanel->GetSizer()->SetSizeHints( this );
40
41 if( m_cbRelinkFootprints->GetValue() )
42 {
43 m_cbUpdateReferences->SetValue( false );
44 m_cbUpdateReferences->Enable( false );
45 }
46 else
47 {
48 m_cbUpdateReferences->Enable( true );
49 }
50
51 SetupStandardButtons( { { wxID_OK, _( "Update Schematic" ) },
52 { wxID_CANCEL, _( "Close" ) } } );
53
55}
56
57
59{
60 bool successfulRun = false;
61 m_messagePanel->Clear();
62 BACK_ANNOTATE backAnno( m_frame,
63 m_messagePanel->Reporter(),
64 m_cbRelinkFootprints->GetValue(),
65 m_cbUpdateFootprints->GetValue(),
66 m_cbUpdateValues->GetValue(),
67 m_cbUpdateReferences->GetValue(),
68 m_cbUpdateNetNames->GetValue(),
69 m_cbUpdateAttributes->GetValue(),
70 m_cbUpdateOtherFields->GetValue(),
71 m_cbPreferUnitSwaps->GetValue(),
72 m_cbPreferPinSwaps->GetValue(),
73 true );
74 std::string netlist;
75
76 if( backAnno.FetchNetlistFromPCB( netlist ) )
77 successfulRun = backAnno.BackAnnotateSymbols( netlist );
78
79 m_sdbSizerOK->Enable( successfulRun );
80 m_messagePanel->Flush( false );
81}
82
83
85{
86 updateData();
87 return true;
88}
89
90
91void DIALOG_UPDATE_FROM_PCB::OnOptionChanged( wxCommandEvent& event )
92{
93 if( event.GetEventObject() == m_cbRelinkFootprints )
94 {
95 if( m_cbRelinkFootprints->GetValue() )
96 {
97 m_cbUpdateReferences->SetValue( false );
98 m_cbUpdateReferences->Enable( false );
99 }
100 else
101 {
102 m_cbUpdateReferences->Enable( true );
103 }
104 }
105
106 updateData();
107}
108
109
110void DIALOG_UPDATE_FROM_PCB::OnUpdateClick( wxCommandEvent& event )
111{
112 std::string netlist;
113 m_messagePanel->Clear();
114 BACK_ANNOTATE backAnno( m_frame,
115 m_messagePanel->Reporter(),
116 m_cbRelinkFootprints->GetValue(),
117 m_cbUpdateFootprints->GetValue(),
118 m_cbUpdateValues->GetValue(),
119 m_cbUpdateReferences->GetValue(),
120 m_cbUpdateNetNames->GetValue(),
121 m_cbUpdateAttributes->GetValue(),
122 m_cbUpdateOtherFields->GetValue(),
123 m_cbPreferUnitSwaps->GetValue(),
124 m_cbPreferPinSwaps->GetValue(),
125 false );
126
127 if( backAnno.FetchNetlistFromPCB( netlist ) && backAnno.BackAnnotateSymbols( netlist ) )
128 {
129 m_frame->GetCurrentSheet().UpdateAllScreenReferences();
130 m_frame->SetSheetNumberAndCount();
131 m_frame->SyncView();
132 m_frame->OnModify();
133 m_frame->GetCanvas()->Refresh();
134
135 if( m_cbRelinkFootprints->GetValue() )
136 backAnno.PushNewLinksToPCB();
137
138 m_sdbSizerCancel->SetDefault();
139 m_sdbSizerOK->Enable( false );
140 }
141
142 m_messagePanel->Flush( false );
143}
Back annotation algorithm class used to receive, check, and apply a NETLIST from Pcbnew.
bool BackAnnotateSymbols(const std::string &aNetlist)
Run back annotation algorithm.
bool FetchNetlistFromPCB(std::string &aNetlist)
Get netlist from the Pcbnew.
void PushNewLinksToPCB()
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
DIALOG_UPDATE_FROM_PCB_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Update Schematic from PCB"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void OnUpdateClick(wxCommandEvent &event) override
void OnOptionChanged(wxCommandEvent &event) override
DIALOG_UPDATE_FROM_PCB(SCH_EDIT_FRAME *aParent)
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Schematic editor (Eeschema) main window.
#define _(s)