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 true );
72 std::string netlist;
73
74 if( backAnno.FetchNetlistFromPCB( netlist ) )
75 successfulRun = backAnno.BackAnnotateSymbols( netlist );
76
77 m_sdbSizerOK->Enable( successfulRun );
78 m_messagePanel->Flush( false );
79}
80
81
83{
84 updateData();
85 return true;
86}
87
88
89void DIALOG_UPDATE_FROM_PCB::OnOptionChanged( wxCommandEvent& event )
90{
91 if( event.GetEventObject() == m_cbRelinkFootprints )
92 {
93 if( m_cbRelinkFootprints->GetValue() )
94 {
95 m_cbUpdateReferences->SetValue( false );
96 m_cbUpdateReferences->Enable( false );
97 }
98 else
99 {
100 m_cbUpdateReferences->Enable( true );
101 }
102 }
103
104 updateData();
105}
106
107
108void DIALOG_UPDATE_FROM_PCB::OnUpdateClick( wxCommandEvent& event )
109{
110 std::string netlist;
111 m_messagePanel->Clear();
112 BACK_ANNOTATE backAnno( m_frame,
113 m_messagePanel->Reporter(),
114 m_cbRelinkFootprints->GetValue(),
115 m_cbUpdateFootprints->GetValue(),
116 m_cbUpdateValues->GetValue(),
117 m_cbUpdateReferences->GetValue(),
118 m_cbUpdateNetNames->GetValue(),
119 m_cbUpdateAttributes->GetValue(),
120 m_cbUpdateOtherFields->GetValue(),
121 false );
122
123 if( backAnno.FetchNetlistFromPCB( netlist ) && backAnno.BackAnnotateSymbols( netlist ) )
124 {
125 m_frame->GetCurrentSheet().UpdateAllScreenReferences();
126 m_frame->SetSheetNumberAndCount();
127 m_frame->SyncView();
128 m_frame->OnModify();
129 m_frame->GetCanvas()->Refresh();
130
131 if( m_cbRelinkFootprints->GetValue() )
132 backAnno.PushNewLinksToPCB();
133
134 m_sdbSizerCancel->SetDefault();
135 m_sdbSizerOK->Enable( false );
136 }
137
138 m_messagePanel->Flush( false );
139}
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)