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 <Jasuramme@gmail.com>
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>
26 #include <dialog_update_from_pcb.h>
27 #include <sch_edit_frame.h>
28 #include <sch_editor_control.h>
29 #include <wx_html_report_panel.h>
30 
31 // Saved dialog settings
33  DIALOG_UPDATE_FROM_PCB::s_savedDialogState{ true, true, true, true, false };
34 
35 
37  : DIALOG_UPDATE_FROM_PCB_BASE( aParent ),
38  m_frame( aParent ),
39  m_editorControl( m_frame->GetToolManager()->GetTool<SCH_EDITOR_CONTROL>() )
40 
41 {
42  m_messagePanel->SetLabel( _( "Changes To Be Applied" ) );
43  m_messagePanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
45  m_messagePanel->GetSizer()->SetSizeHints( this );
46 
48 
49  if( m_cbRelinkFootprints->GetValue() )
50  {
51  m_cbUpdateReferences->SetValue( false );
52  m_cbUpdateReferences->Enable( false );
53  }
54  else
55  {
57  m_cbUpdateReferences->Enable( true );
58  }
59 
63 
64  // We use a sdbSizer to get platform-dependent ordering of the action buttons, but
65  // that requires us to correct the button labels here.
66  m_sdbSizerOK->SetLabel( _( "Update Schematic" ) );
67  m_sdbSizerCancel->SetLabel( _( "Close" ) );
68  m_sdbSizer->Layout();
69 
70  m_sdbSizerOK->SetDefault();
72 }
73 
74 
76 {
77  bool successfulRun = false;
79  BACK_ANNOTATE backAnno( m_frame,
81  m_cbRelinkFootprints->GetValue(),
82  m_cbUpdateFootprints->GetValue(),
83  m_cbUpdateValues->GetValue(),
84  m_cbUpdateReferences->GetValue(),
85  m_cbUpdateNetNames->GetValue(),
86  true );
87  std::string netlist;
88 
89  if( backAnno.FetchNetlistFromPCB( netlist ) )
90  successfulRun = backAnno.BackAnnotateSymbols( netlist );
91 
92  m_sdbSizerOK->Enable( successfulRun );
93  m_messagePanel->Flush( false );
94 }
95 
96 
98 {
99  updateData();
100  return true;
101 }
102 
103 
105 {
106 }
107 
108 
109 void DIALOG_UPDATE_FROM_PCB::OnOptionChanged( wxCommandEvent& event )
110 {
111  if( event.GetEventObject() == m_cbRelinkFootprints )
112  {
113  if( m_cbRelinkFootprints->GetValue() )
114  {
115  m_cbUpdateReferences->SetValue( false );
116  m_cbUpdateReferences->Enable( false );
117  }
118  else
119  {
121  m_cbUpdateReferences->Enable( true );
122  }
123  }
124 
125  updateData();
126 
127  if( event.GetEventObject() == m_cbRelinkFootprints )
129  else if( event.GetEventObject() == m_cbUpdateReferences )
131  else if( event.GetEventObject() == m_cbUpdateFootprints )
133  else if( event.GetEventObject() == m_cbUpdateValues )
135  else if( event.GetEventObject() == m_cbUpdateNetNames )
137 }
138 
139 
140 void DIALOG_UPDATE_FROM_PCB::OnUpdateClick( wxCommandEvent& event )
141 {
142  std::string netlist;
144  BACK_ANNOTATE backAnno( m_frame,
146  m_cbRelinkFootprints->GetValue(),
147  m_cbUpdateFootprints->GetValue(),
148  m_cbUpdateValues->GetValue(),
149  m_cbUpdateReferences->GetValue(),
150  m_cbUpdateNetNames->GetValue(),
151  false );
152 
153  if( backAnno.FetchNetlistFromPCB( netlist ) && backAnno.BackAnnotateSymbols( netlist ) )
154  {
157  m_frame->SyncView();
158  m_frame->OnModify();
159  m_frame->GetCanvas()->Refresh();
160 
161  if( m_cbRelinkFootprints->GetValue() )
162  backAnno.PushNewLinksToPCB();
163 
164  m_sdbSizerCancel->SetDefault();
165  m_sdbSizerOK->Enable( false );
166  }
167 
168  m_messagePanel->Flush( false );
169 }
void SetLazyUpdate(bool aLazyUpdate)
Forces updating the HTML page, after the report is built in lazy mode If aSort = true,...
void Flush(bool aSort=false)
Set the visible severity filter.
DIALOG_UPDATE_FROM_PCB(SCH_EDIT_FRAME *aParent)
void OnOptionChanged(wxCommandEvent &event) override
Schematic editor (Eeschema) main window.
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
Handle actions specific to the schematic editor.
void SyncView()
Mark all items for refresh.
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 OnUpdateClick(wxCommandEvent &event) override
Class DIALOG_UPDATE_FROM_PCB_BASE.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
void Clear()
return the number of messages matching the given severity mask.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
#define _(s)
Definition: 3d_actions.cpp:33
Back annotation algorithm class used to receive, check, and apply a NETLIST from Pcbnew.
Definition: backannotate.h:55
static DIALOG_UPDATE_FROM_PCB_SAVED_STATE s_savedDialogState
SCH_SHEET_PATH & GetCurrentSheet() const
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void SetFileName(const wxString &aReportFileName)
void SetLabel(const wxString &aLabel) override
Sets the lazy update.