KiCad PCB EDA Suite
dialog_update_pcb.cpp
Go to the documentation of this file.
1 
5 /*
6  * This program source code file is part of KiCad, a free EDA CAD application.
7  *
8  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, you may find one here:
22  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23  * or you may search the http://www.gnu.org website for the version 2 license,
24  * or you may write to the Free Software Foundation, Inc.,
25  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26  */
27 
28 #include <pcb_edit_frame.h>
29 #include <pcbnew_settings.h>
30 #include <dialog_update_pcb.h>
31 
32 #include <ratsnest/ratsnest_data.h>
33 #include <wx_html_report_panel.h>
36 #include <tool/tool_manager.h>
37 #include <tools/pcb_actions.h>
38 #include <tools/selection_tool.h>
39 #include <class_board.h>
40 #include <kiface_i.h>
41 
42 using namespace std::placeholders;
43 
44 
46 
47 
49  DIALOG_UPDATE_PCB_BASE( aParent ),
50  m_frame( aParent ),
51  m_netlist( aNetlist ),
52  m_initialized( false )
53 {
54  auto cfg = m_frame->GetPcbNewSettings();
55 
56  m_cbRelinkFootprints->SetValue( cfg->m_NetlistDialog.associate_by_ref_sch );
57  m_cbUpdateFootprints->SetValue( cfg->m_NetlistDialog.update_footprints );
58  m_cbDeleteExtraFootprints->SetValue( cfg->m_NetlistDialog.delete_extra_footprints );
59  m_cbDeleteSinglePadNets->SetValue( cfg->m_NetlistDialog.delete_single_pad_nets );
61 
62  m_messagePanel->SetLabel( _("Changes To Be Applied") );
65 
66  m_messagePanel->SetVisibleSeverities( cfg->m_NetlistDialog.report_filter );
67 
68  m_messagePanel->GetSizer()->SetSizeHints( this );
69  m_messagePanel->Layout();
70 
71  // We use a sdbSizer to get platform-dependent ordering of the action buttons, but
72  // that requires us to correct the button labels here.
73  m_sdbSizer1OK->SetLabel( _( "Update PCB" ) );
74  m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
75  m_sdbSizer1->Layout();
76 
77  m_sdbSizer1OK->SetDefault();
79 
80  m_initialized = true;
81  PerformUpdate( true );
82 }
83 
84 
86 {
88 
89  auto cfg = m_frame->GetPcbNewSettings();
90 
92  cfg->m_NetlistDialog.update_footprints = m_cbUpdateFootprints->GetValue();
93  cfg->m_NetlistDialog.delete_extra_footprints = m_cbDeleteExtraFootprints->GetValue();
94  cfg->m_NetlistDialog.delete_single_pad_nets = m_cbDeleteSinglePadNets->GetValue();
95  cfg->m_NetlistDialog.report_filter = m_messagePanel->GetVisibleSeverities();
96 
97  if( m_runDragCommand )
98  {
100  controls->SetCursorPosition( controls->GetMousePosition() );
102  }
103 }
104 
105 
107 {
109 
110  REPORTER& reporter = m_messagePanel->Reporter();
111 
112  m_runDragCommand = false;
113 
116 
118  updater.SetReporter ( &reporter );
119  updater.SetIsDryRun( aDryRun );
120  updater.SetLookupByTimestamp( !m_cbRelinkFootprints->GetValue() );
121  updater.SetDeleteUnusedComponents ( m_cbDeleteExtraFootprints->GetValue() );
122  updater.SetReplaceFootprints( m_cbUpdateFootprints->GetValue() );
123  updater.SetDeleteSinglePadNets( m_cbDeleteSinglePadNets->GetValue() );
124  updater.SetWarnPadNoNetInNetlist( m_warnForNoNetPads );
125  updater.UpdateNetlist( *m_netlist );
126 
127  m_messagePanel->Flush( true );
128 
129  if( aDryRun )
130  return;
131 
133 }
134 
135 
136 void DIALOG_UPDATE_PCB::OnOptionChanged( wxCommandEvent& event )
137 {
138  if( m_initialized )
139  PerformUpdate( true );
140 }
141 
142 
143 void DIALOG_UPDATE_PCB::OnUpdateClick( wxCommandEvent& event )
144 {
145  m_messagePanel->SetLabel( _( "Changes Applied To PCB" ) );
146  PerformUpdate( false );
147  m_sdbSizer1Cancel->SetDefault();
148 }
void SetVisibleSeverities(int aSeverities)
Set the visible severity filter.
void SetLazyUpdate(bool aLazyUpdate)
Sets the lasy update.
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:95
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
void OnOptionChanged(wxCommandEvent &event) override
BOARD_NETLIST_UPDATER updates 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)
Forces updating the HTML page, after the report is built in lazy mode If aSort = true,...
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
BOARD_NETLIST_UPDATER class definition.
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Moves cursor to the requested position expressed in world coordinates.
void SetFindByTimeStamp(bool aFindByTimeStamp)
Definition: pcb_netlist.h:267
void SetReporter(REPORTER *aReporter)
Sets the reporter object
PCBNEW_SETTINGS * GetPcbNewSettings()
REPORTER is 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.
PCB_EDIT_FRAME * m_frame
void SortByReference()
void OnUpdateClick(wxCommandEvent &event) override
void SetReplaceFootprints(bool aReplace)
Definition: pcb_netlist.h:270
NETLIST stores all of information read from a netlist along with the flags used to update the NETLIST...
Definition: pcb_netlist.h:194
DIALOG_NETLIST m_NetlistDialog
REPORTER & Reporter()
returns the reporter object that reports to this panel
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
WX_HTML_REPORT_PANEL * m_messagePanel
void Clear()
clears the report panel
#define _(s)
Definition: 3d_actions.cpp:33
PCB_EDIT_FRAME is the main frame for Pcbnew.
static bool m_warnForNoNetPads
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:78
BOARD * GetBoard() const
DIALOG_UPDATE_PCB(PCB_EDIT_FRAME *aParent, NETLIST *aNetlist)
void SetLabel(const wxString &aLabel) override
sets the frame label
wxStdDialogButtonSizer * m_sdbSizer1
void PerformUpdate(bool aDryRun)