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 (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, true, true };
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
66
67 SetupStandardButtons( { { wxID_OK, _( "Update Schematic" ) },
68 { wxID_CANCEL, _( "Close" ) } } );
69
71}
72
73
75{
76 bool successfulRun = false;
78 BACK_ANNOTATE backAnno( m_frame,
80 m_cbRelinkFootprints->GetValue(),
81 m_cbUpdateFootprints->GetValue(),
82 m_cbUpdateValues->GetValue(),
83 m_cbUpdateReferences->GetValue(),
84 m_cbUpdateNetNames->GetValue(),
85 m_cbUpdateAttributes->GetValue(),
86 m_cbUpdateOtherFields->GetValue(),
87 true );
88 std::string netlist;
89
90 if( backAnno.FetchNetlistFromPCB( netlist ) )
91 successfulRun = backAnno.BackAnnotateSymbols( netlist );
92
93 m_sdbSizerOK->Enable( successfulRun );
94 m_messagePanel->Flush( false );
95}
96
97
99{
100 updateData();
101 return true;
102}
103
104
106{
107}
108
109
110void DIALOG_UPDATE_FROM_PCB::OnOptionChanged( wxCommandEvent& event )
111{
112 if( event.GetEventObject() == m_cbRelinkFootprints )
113 {
114 if( m_cbRelinkFootprints->GetValue() )
115 {
116 m_cbUpdateReferences->SetValue( false );
117 m_cbUpdateReferences->Enable( false );
118 }
119 else
120 {
122 m_cbUpdateReferences->Enable( true );
123 }
124 }
125
126 updateData();
127
128 if( event.GetEventObject() == m_cbRelinkFootprints )
130 else if( event.GetEventObject() == m_cbUpdateReferences )
132 else if( event.GetEventObject() == m_cbUpdateFootprints )
134 else if( event.GetEventObject() == m_cbUpdateValues )
136 else if( event.GetEventObject() == m_cbUpdateNetNames )
138 else if( event.GetEventObject() == m_cbUpdateAttributes )
140 else if( event.GetEventObject() == m_cbUpdateOtherFields )
142}
143
144
145void DIALOG_UPDATE_FROM_PCB::OnUpdateClick( wxCommandEvent& event )
146{
147 std::string netlist;
149 BACK_ANNOTATE backAnno( m_frame,
151 m_cbRelinkFootprints->GetValue(),
152 m_cbUpdateFootprints->GetValue(),
153 m_cbUpdateValues->GetValue(),
154 m_cbUpdateReferences->GetValue(),
155 m_cbUpdateNetNames->GetValue(),
156 m_cbUpdateAttributes->GetValue(),
157 m_cbUpdateOtherFields->GetValue(),
158 false );
159
160 if( backAnno.FetchNetlistFromPCB( netlist ) && backAnno.BackAnnotateSymbols( netlist ) )
161 {
164 m_frame->SyncView();
165 m_frame->OnModify();
167
168 if( m_cbRelinkFootprints->GetValue() )
169 backAnno.PushNewLinksToPCB();
170
171 m_sdbSizerCancel->SetDefault();
172 m_sdbSizerOK->Enable( false );
173 }
174
175 m_messagePanel->Flush( false );
176}
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
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 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()
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)