KiCad PCB EDA Suite
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 (C) 1992-2021 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
32// Saved dialog settings
34 DIALOG_UPDATE_FROM_PCB::s_savedDialogState{ false, true, true, true, false };
35
36
38 : DIALOG_UPDATE_FROM_PCB_BASE( aParent ),
39 m_frame( aParent ),
40 m_editorControl( m_frame->GetToolManager()->GetTool<SCH_EDITOR_CONTROL>() )
41
42{
43 m_messagePanel->SetLabel( _( "Changes To Be Applied" ) );
44 m_messagePanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
46 m_messagePanel->GetSizer()->SetSizeHints( this );
47
49
50 if( m_cbRelinkFootprints->GetValue() )
51 {
52 m_cbUpdateReferences->SetValue( false );
53 m_cbUpdateReferences->Enable( false );
54 }
55 else
56 {
58 m_cbUpdateReferences->Enable( true );
59 }
60
64
65 SetupStandardButtons( { { wxID_OK, _( "Update Schematic" ) },
66 { wxID_CANCEL, _( "Close" ) } } );
67
69}
70
71
73{
74 bool successfulRun = false;
76 BACK_ANNOTATE backAnno( m_frame,
78 m_cbRelinkFootprints->GetValue(),
79 m_cbUpdateFootprints->GetValue(),
80 m_cbUpdateValues->GetValue(),
81 m_cbUpdateReferences->GetValue(),
82 m_cbUpdateNetNames->GetValue(),
83 true );
84 std::string netlist;
85
86 if( backAnno.FetchNetlistFromPCB( netlist ) )
87 successfulRun = backAnno.BackAnnotateSymbols( netlist );
88
89 m_sdbSizerOK->Enable( successfulRun );
90 m_messagePanel->Flush( false );
91}
92
93
95{
96 updateData();
97 return true;
98}
99
100
102{
103}
104
105
106void DIALOG_UPDATE_FROM_PCB::OnOptionChanged( wxCommandEvent& event )
107{
108 if( event.GetEventObject() == m_cbRelinkFootprints )
109 {
110 if( m_cbRelinkFootprints->GetValue() )
111 {
112 m_cbUpdateReferences->SetValue( false );
113 m_cbUpdateReferences->Enable( false );
114 }
115 else
116 {
118 m_cbUpdateReferences->Enable( true );
119 }
120 }
121
122 updateData();
123
124 if( event.GetEventObject() == m_cbRelinkFootprints )
126 else if( event.GetEventObject() == m_cbUpdateReferences )
128 else if( event.GetEventObject() == m_cbUpdateFootprints )
130 else if( event.GetEventObject() == m_cbUpdateValues )
132 else if( event.GetEventObject() == m_cbUpdateNetNames )
134}
135
136
137void DIALOG_UPDATE_FROM_PCB::OnUpdateClick( wxCommandEvent& event )
138{
139 std::string netlist;
141 BACK_ANNOTATE backAnno( m_frame,
143 m_cbRelinkFootprints->GetValue(),
144 m_cbUpdateFootprints->GetValue(),
145 m_cbUpdateValues->GetValue(),
146 m_cbUpdateReferences->GetValue(),
147 m_cbUpdateNetNames->GetValue(),
148 false );
149
150 if( backAnno.FetchNetlistFromPCB( netlist ) && backAnno.BackAnnotateSymbols( netlist ) )
151 {
154 m_frame->SyncView();
155 m_frame->OnModify();
157
158 if( m_cbRelinkFootprints->GetValue() )
159 backAnno.PushNewLinksToPCB();
160
161 m_sdbSizerCancel->SetDefault();
162 m_sdbSizerOK->Enable( false );
163 }
164
165 m_messagePanel->Flush( false );
166}
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)
static DIALOG_UPDATE_FROM_PCB_SAVED_STATE s_savedDialogState
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
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.
Handle actions specific to the schematic editor.
Schematic editor (Eeschema) main window.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
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()
return the number of messages matching the given severity mask.
void SetLazyUpdate(bool aLazyUpdate)
Forces updating the HTML page, after the report is built in lazy mode If aSort = true,...
void SetLabel(const wxString &aLabel) override
Sets the lazy update.
void SetFileName(const wxString &aReportFileName)
void Flush(bool aSort=false)
Set the visible severity filter.
#define _(s)