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-2020 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 
36  : DIALOG_UPDATE_FROM_PCB_BASE( aParent ),
37  m_frame( aParent ),
38  m_editorControl( m_frame->GetToolManager()->GetTool<SCH_EDITOR_CONTROL>() )
39 
40 {
41  m_messagePanel->SetLabel( _( "Changes To Be Applied" ) );
43  m_messagePanel->GetSizer()->SetSizeHints( this );
44 
46 
47  if( m_cbRelinkFootprints->GetValue() )
48  {
49  m_cbUpdateReferences->SetValue( false );
50  m_cbUpdateReferences->Enable( false );
51  }
52  else
53  {
55  m_cbUpdateReferences->Enable( true );
56  }
57 
61 
62  // We use a sdbSizer to get platform-dependent ordering of the action buttons, but
63  // that requires us to correct the button labels here.
64  m_sdbSizerOK->SetLabel( _( "Update Schematic" ) );
65  m_sdbSizerCancel->SetLabel( _( "Close" ) );
66  m_sdbSizer->Layout();
67 
68  m_sdbSizerOK->SetDefault();
70 }
71 
73 {
74  bool successfulRun = false;
76  BACK_ANNOTATE backAnno( this->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 
94 {
95  updateData();
96  return true;
97 }
98 
100 {
101 }
102 
103 void DIALOG_UPDATE_FROM_PCB::OnOptionChanged( wxCommandEvent& event )
104 {
105  if( event.GetEventObject() == m_cbRelinkFootprints )
106  {
107  if( m_cbRelinkFootprints->GetValue() )
108  {
109  m_cbUpdateReferences->SetValue( false );
110  m_cbUpdateReferences->Enable( false );
111  }
112  else
113  {
115  m_cbUpdateReferences->Enable( true );
116  }
117  }
118 
119  updateData();
120 
121  if( event.GetEventObject() == m_cbRelinkFootprints )
123  else if( event.GetEventObject() == m_cbUpdateReferences )
125  else if( event.GetEventObject() == m_cbUpdateFootprints )
127  else if( event.GetEventObject() == m_cbUpdateValues )
129  else if( event.GetEventObject() == m_cbUpdateNetNames )
131 }
132 
133 void DIALOG_UPDATE_FROM_PCB::OnUpdateClick( wxCommandEvent& event )
134 {
135  std::string netlist;
137  BACK_ANNOTATE backAnno( m_frame,
139  m_cbRelinkFootprints->GetValue(),
140  m_cbUpdateFootprints->GetValue(),
141  m_cbUpdateValues->GetValue(),
142  m_cbUpdateReferences->GetValue(),
143  m_cbUpdateNetNames->GetValue(),
144  false );
145 
146  if( backAnno.FetchNetlistFromPCB( netlist ) && backAnno.BackAnnotateSymbols( netlist ) )
147  {
150  m_frame->SyncView();
151  m_frame->OnModify();
152  m_frame->GetCanvas()->Refresh();
153 
154  if( m_cbRelinkFootprints->GetValue() )
155  backAnno.PushNewLinksToPCB();
156  }
157 
158  m_messagePanel->Flush( true );
159 }
void SetLazyUpdate(bool aLazyUpdate)
Sets the lasy update.
Struct containing the dialog last saved state.
void Flush(bool aSort=false)
Forces updating the HTML page, after the report is built in lazy mode If aSort = true,...
DIALOG_UPDATE_FROM_PCB(SCH_EDIT_FRAME *aParent)
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
void OnOptionChanged(wxCommandEvent &event) override
Schematic editor (Eeschema) main window.
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
bool BackAnnotateSymbols(const std::string &aNetlist)
Run back annotation algorithm.
SCH_EDITOR_CONTROL.
void SyncView()
Mark all items for refresh.
REPORTER & Reporter()
returns the reporter object that reports to this panel
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 Clear()
clears the report panel
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 recieve, 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 SetLabel(const wxString &aLabel) override
sets the frame label