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