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" ) );
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;
62 BACK_ANNOTATE backAnno( m_frame,
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;
112 BACK_ANNOTATE backAnno( m_frame,
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 {
127 m_frame->SyncView();
128 m_frame->OnModify();
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.
Definition: backannotate.h:56
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...
Class DIALOG_UPDATE_FROM_PCB_BASE.
void OnUpdateClick(wxCommandEvent &event) override
void OnOptionChanged(wxCommandEvent &event) override
DIALOG_UPDATE_FROM_PCB(SCH_EDIT_FRAME *aParent)
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SyncView()
Mark all items for refresh.
Schematic editor (Eeschema) main window.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
SCH_SHEET_PATH & GetCurrentSheet() const
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
void Clear()
Clears the report panel.
void SetLazyUpdate(bool aLazyUpdate)
Set the lazy update.
void SetLabel(const wxString &aLabel) override
Set the frame label.
void SetFileName(const wxString &aReportFileName)
Set the report full file name to the string.
void Flush(bool aSort=false)
Force updating the HTML page, after the report is built in lazy mode If aSort = true,...
REPORTER & Reporter()
Return the reporter object that reports to this panel.
#define _(s)