KiCad PCB EDA Suite
dialog_update_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) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #include <pcb_edit_frame.h>
25 #include <pcbnew_settings.h>
26 #include <dialog_update_pcb.h>
27 #include <ratsnest/ratsnest_data.h>
28 #include <wx_html_report_panel.h>
31 #include <tool/tool_manager.h>
32 #include <tools/pcb_actions.h>
33 #include <kiface_i.h>
34 #include <kiplatform/ui.h>
35 
37 
38 
40  DIALOG_UPDATE_PCB_BASE( aParent ),
41  m_frame( aParent ),
42  m_netlist( aNetlist ),
43  m_initialized( false )
44 {
45  auto cfg = m_frame->GetPcbNewSettings();
46 
47  m_cbRelinkFootprints->SetValue( cfg->m_NetlistDialog.associate_by_ref_sch );
48  m_cbUpdateFootprints->SetValue( cfg->m_NetlistDialog.update_footprints );
49  m_cbDeleteExtraFootprints->SetValue( cfg->m_NetlistDialog.delete_extra_footprints );
50  m_cbDeleteSinglePadNets->SetValue( cfg->m_NetlistDialog.delete_single_pad_nets );
52 
53  m_messagePanel->SetLabel( _("Changes To Be Applied") );
54  m_messagePanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
57 
58  m_messagePanel->SetVisibleSeverities( cfg->m_NetlistDialog.report_filter );
59 
60  m_messagePanel->GetSizer()->SetSizeHints( this );
61  m_messagePanel->Layout();
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_sdbSizer1OK->SetLabel( _( "Update PCB" ) );
66  m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
67  m_sdbSizer1->Layout();
68 
69  m_sdbSizer1OK->SetDefault();
71 
72  m_initialized = true;
73  PerformUpdate( true );
74 }
75 
76 
78 {
80 
81  auto cfg = m_frame->GetPcbNewSettings();
82 
84  cfg->m_NetlistDialog.update_footprints = m_cbUpdateFootprints->GetValue();
85  cfg->m_NetlistDialog.delete_extra_footprints = m_cbDeleteExtraFootprints->GetValue();
86  cfg->m_NetlistDialog.delete_single_pad_nets = m_cbDeleteSinglePadNets->GetValue();
87  cfg->m_NetlistDialog.report_filter = m_messagePanel->GetVisibleSeverities();
88 
89  if( m_runDragCommand )
90  {
92  controls->SetCursorPosition( controls->GetMousePosition() );
94  }
95 }
96 
97 
99 {
101 
102  REPORTER& reporter = m_messagePanel->Reporter();
103 
104  m_runDragCommand = false;
105 
108 
110  updater.SetReporter ( &reporter );
111  updater.SetIsDryRun( aDryRun );
112  updater.SetLookupByTimestamp( !m_cbRelinkFootprints->GetValue() );
113  updater.SetDeleteUnusedFootprints( m_cbDeleteExtraFootprints->GetValue());
114  updater.SetReplaceFootprints( m_cbUpdateFootprints->GetValue() );
115  updater.SetDeleteSinglePadNets( m_cbDeleteSinglePadNets->GetValue() );
116  updater.SetWarnPadNoNetInNetlist( m_warnForNoNetPads );
117  updater.UpdateNetlist( *m_netlist );
118 
119  m_messagePanel->Flush( true );
120 
121  if( aDryRun )
122  return;
123 
125 }
126 
127 
128 void DIALOG_UPDATE_PCB::OnOptionChanged( wxCommandEvent& event )
129 {
130  if( m_initialized )
131  {
132  PerformUpdate( true );
133  m_sdbSizer1OK->Enable( true );
134  m_sdbSizer1OK->SetDefault();
135  }
136 }
137 
138 
139 void DIALOG_UPDATE_PCB::OnUpdateClick( wxCommandEvent& event )
140 {
141  m_messagePanel->SetLabel( _( "Changes Applied to PCB" ) );
142  PerformUpdate( false );
143 
144  m_sdbSizer1Cancel->SetDefault();
145  // Widgets has a tendency to keep both buttons highlighted without the following:
146  m_sdbSizer1OK->Enable( false );
147 }
void SetVisibleSeverities(int aSeverities)
void SetLazyUpdate(bool aLazyUpdate)
Forces updating the HTML page, after the report is built in lazy mode If aSort = true,...
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:92
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
void OnOptionChanged(wxCommandEvent &event) override
Update the BOARD with a new netlist.
Class DIALOG_UPDATE_PCB_BASE.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Class that computes missing connections on a PCB.
void Flush(bool aSort=false)
Set the visible severity filter.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
BOARD_NETLIST_UPDATER class definition.
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
void SetFindByTimeStamp(bool aFindByTimeStamp)
Definition: pcb_netlist.h:267
void SetReporter(REPORTER *aReporter)
Enable dry run mode (just report, no changes to PCB).
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
void OnNetlistChanged(BOARD_NETLIST_UPDATER &aUpdater, bool *aRunDragCommand)
Called after netlist is updated.
Definition: netlist.cpp:89
PCB_EDIT_FRAME * m_frame
void SortByReference()
void OnUpdateClick(wxCommandEvent &event) override
void SetReplaceFootprints(bool aReplace)
Definition: pcb_netlist.h:270
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:206
DIALOG_NETLIST m_NetlistDialog
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
An interface for classes handling user events controlling the view behavior such as zooming,...
#define _(s)
WX_HTML_REPORT_PANEL * m_messagePanel
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.
The main frame for Pcbnew.
PCBNEW_SETTINGS * GetPcbNewSettings() const
static bool m_warnForNoNetPads
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
BOARD * GetBoard() const
void SetFileName(const wxString &aReportFileName)
DIALOG_UPDATE_PCB(PCB_EDIT_FRAME *aParent, NETLIST *aNetlist)
void SetLabel(const wxString &aLabel) override
Sets the lazy update.
wxStdDialogButtonSizer * m_sdbSizer1
void PerformUpdate(bool aDryRun)