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, 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 
62 
63  // We use a sdbSizer to get platform-dependent ordering of the action buttons, but
64  // that requires us to correct the button labels here.
65  m_sdbSizerOK->SetLabel( _( "Update Schematic" ) );
66  m_sdbSizerCancel->SetLabel( _( "Close" ) );
67  m_sdbSizer->Layout();
68 
69  m_sdbSizerOK->SetDefault();
71 }
72 
74 {
75  bool successfulRun = false;
77  BACK_ANNOTATE backAnno( this->m_frame,
79  m_cbRelinkFootprints->GetValue(),
80  m_cbUpdateFootprints->GetValue(),
81  m_cbUpdateValues->GetValue(),
82  m_cbUpdateReferences->GetValue(),
83  m_cbUpdateNetNames->GetValue(),
84  m_cbIgnoreOtherProjects->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 
96 {
97  updateData();
98  return true;
99 }
100 
102 {
103 }
104 
105 void DIALOG_UPDATE_FROM_PCB::OnOptionChanged( wxCommandEvent& event )
106 {
107  if( event.GetEventObject() == m_cbRelinkFootprints )
108  {
109  if( m_cbRelinkFootprints->GetValue() )
110  {
111  m_cbUpdateReferences->SetValue( false );
112  m_cbUpdateReferences->Enable( false );
113  }
114  else
115  {
117  m_cbUpdateReferences->Enable( true );
118  }
119  }
120 
121  updateData();
122 
123  if( event.GetEventObject() == m_cbRelinkFootprints )
125  else if( event.GetEventObject() == m_cbUpdateReferences )
127  else if( event.GetEventObject() == m_cbUpdateFootprints )
129  else if( event.GetEventObject() == m_cbUpdateValues )
131  else if( event.GetEventObject() == m_cbUpdateNetNames )
133  else if( event.GetEventObject() == m_cbIgnoreOtherProjects )
135 }
136 
137 void 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  m_cbIgnoreOtherProjects->GetValue(),
149  false );
150 
151  if( backAnno.FetchNetlistFromPCB( netlist ) && backAnno.BackAnnotateSymbols( netlist ) )
152  {
155  m_frame->SyncView();
156  m_frame->OnModify();
157  m_frame->GetCanvas()->Refresh();
158 
159  if( m_cbRelinkFootprints->GetValue() )
160  backAnno.PushNewLinksToPCB();
161  }
162 
163  m_messagePanel->Flush( true );
164 }
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()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
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