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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <backannotate.h>
23#include <sch_edit_frame.h>
24#include <sch_editor_control.h>
26
27
30 m_frame( aParent )
31{
32 m_messagePanel->SetLabel( _( "Changes to Be Applied" ) );
33 m_messagePanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
34 m_messagePanel->SetLazyUpdate( true );
35 m_messagePanel->GetSizer()->SetSizeHints( this );
36
37 if( m_cbRelinkFootprints->GetValue() )
38 {
39 m_cbUpdateReferences->SetValue( false );
40 m_cbUpdateReferences->Enable( false );
41 }
42 else
43 {
44 m_cbUpdateReferences->Enable( true );
45 }
46
47 SetupStandardButtons( { { wxID_OK, _( "Update Schematic" ) },
48 { wxID_CANCEL, _( "Close" ) } } );
49
51}
52
53
55{
56 bool successfulRun = false;
57 m_messagePanel->Clear();
58 BACK_ANNOTATE backAnno( m_frame,
59 m_messagePanel->Reporter(),
60 m_cbRelinkFootprints->GetValue(),
61 m_cbUpdateFootprints->GetValue(),
62 m_cbUpdateValues->GetValue(),
63 m_cbUpdateReferences->GetValue(),
64 m_cbUpdateNetNames->GetValue(),
65 m_cbUpdateAttributes->GetValue(),
66 m_cbUpdateOtherFields->GetValue(),
67 m_cbPreferUnitSwaps->GetValue(),
68 m_cbPreferPinSwaps->GetValue(),
69 true );
70 std::string netlist;
71
72 if( backAnno.FetchNetlistFromPCB( netlist ) )
73 successfulRun = backAnno.BackAnnotateSymbols( netlist );
74
75 m_sdbSizerOK->Enable( successfulRun );
76 m_messagePanel->Flush( false );
77}
78
79
81{
82 updateData();
83 return true;
84}
85
86
87void DIALOG_UPDATE_FROM_PCB::OnOptionChanged( wxCommandEvent& event )
88{
89 if( event.GetEventObject() == m_cbRelinkFootprints )
90 {
91 if( m_cbRelinkFootprints->GetValue() )
92 {
93 m_cbUpdateReferences->SetValue( false );
94 m_cbUpdateReferences->Enable( false );
95 }
96 else
97 {
98 m_cbUpdateReferences->Enable( true );
99 }
100 }
101
102 updateData();
103}
104
105
106void DIALOG_UPDATE_FROM_PCB::OnUpdateClick( wxCommandEvent& event )
107{
108 std::string netlist;
109 m_messagePanel->Clear();
110 BACK_ANNOTATE backAnno( m_frame,
111 m_messagePanel->Reporter(),
112 m_cbRelinkFootprints->GetValue(),
113 m_cbUpdateFootprints->GetValue(),
114 m_cbUpdateValues->GetValue(),
115 m_cbUpdateReferences->GetValue(),
116 m_cbUpdateNetNames->GetValue(),
117 m_cbUpdateAttributes->GetValue(),
118 m_cbUpdateOtherFields->GetValue(),
119 m_cbPreferUnitSwaps->GetValue(),
120 m_cbPreferPinSwaps->GetValue(),
121 false );
122
123 if( backAnno.FetchNetlistFromPCB( netlist ) && backAnno.BackAnnotateSymbols( netlist ) )
124 {
125 for( SCH_SHEET_PATH& sheet : m_frame->Schematic().Hierarchy() )
126 sheet.UpdateAllScreenReferences();
127
128 m_frame->SetSheetNumberAndCount();
129 m_frame->SyncView();
130 m_frame->OnModify();
131 m_frame->GetCanvas()->Refresh();
132
133 if( m_cbRelinkFootprints->GetValue() )
134 backAnno.PushNewLinksToPCB();
135
136 m_sdbSizerCancel->SetDefault();
137 m_sdbSizerOK->Enable( false );
138 }
139
140 m_messagePanel->Flush( false );
141}
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.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
#define _(s)
std::string netlist