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 #include <wx_html_report_panel.h>
34 #include <tool/tool_manager.h>
35 #include <tools/pcb_actions.h>
36 #include <tools/selection_tool.h>
37 #include <class_board.h>
38 #include <ratsnest_data.h>
39 #include <kiface_i.h>
40 
41 using namespace std::placeholders;
42 
43 
45 
46 
48  DIALOG_UPDATE_PCB_BASE( aParent ),
49  m_frame( aParent ),
50  m_netlist( aNetlist ),
51  m_initialized( false )
52 {
53  auto cfg = m_frame->GetSettings();
54 
55  m_cbUpdateFootprints->SetValue( cfg->m_NetlistDialog.update_footprints );
56  m_cbDeleteExtraFootprints->SetValue( cfg->m_NetlistDialog.delete_extra_footprints );
57  m_cbDeleteSinglePadNets->SetValue( cfg->m_NetlistDialog.delete_single_pad_nets );
59 
60  m_messagePanel->SetLabel( _("Changes To Be Applied") );
63 
64  m_messagePanel->SetVisibleSeverities( cfg->m_NetlistDialog.report_filter );
65 
66  m_messagePanel->GetSizer()->SetSizeHints( this );
67  m_messagePanel->Layout();
68 
69  // We use a sdbSizer to get platform-dependent ordering of the action buttons, but
70  // that requires us to correct the button labels here.
71  m_sdbSizer1OK->SetLabel( _( "Update PCB" ) );
72  m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
73  m_sdbSizer1->Layout();
74 
75  m_sdbSizer1OK->SetDefault();
77 
78  m_initialized = true;
79  PerformUpdate( true );
80 }
81 
82 
84 {
86 
87  auto cfg = m_frame->GetSettings();
88 
90  cfg->m_NetlistDialog.delete_extra_footprints = m_cbDeleteExtraFootprints->GetValue();
91  cfg->m_NetlistDialog.delete_single_pad_nets = m_cbDeleteSinglePadNets->GetValue();
92  cfg->m_NetlistDialog.report_filter = m_messagePanel->GetVisibleSeverities();
93 
94  if( m_runDragCommand )
95  {
97  controls->SetCursorPosition( controls->GetMousePosition() );
99  }
100 }
101 
102 
104 {
106 
107  REPORTER& reporter = m_messagePanel->Reporter();
108 
109  m_runDragCommand = false;
110 
114 
116  updater.SetReporter ( &reporter );
117  updater.SetIsDryRun( aDryRun );
118  updater.SetLookupByTimestamp( !m_cbRelinkFootprints->GetValue() );
119  updater.SetDeleteUnusedComponents ( m_cbDeleteExtraFootprints->GetValue() );
120  updater.SetReplaceFootprints( m_cbUpdateFootprints->GetValue() );
121  updater.SetDeleteSinglePadNets( m_cbDeleteSinglePadNets->GetValue() );
122  updater.SetWarnPadNoNetInNetlist( m_warnForNoNetPads );
123  updater.UpdateNetlist( *m_netlist );
124 
125  m_messagePanel->Flush( true );
126 
127  if( aDryRun )
128  return;
129 
131 }
132 
133 
134 void DIALOG_UPDATE_PCB::OnOptionChanged( wxCommandEvent& event )
135 {
136  if( m_initialized )
137  PerformUpdate( true );
138 }
139 
140 
141 void DIALOG_UPDATE_PCB::OnUpdateClick( wxCommandEvent& event )
142 {
143  m_messagePanel->SetLabel( _( "Changes Applied To PCB" ) );
144  PerformUpdate( false );
145  m_sdbSizer1Cancel->SetDefault();
146 }
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:103
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
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:139
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:309
void SetReporter(REPORTER *aReporter)
Sets the reporter object
REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:62
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 aReplaceFootprints)
Definition: pcb_netlist.h:313
NETLIST stores all of information read from a netlist along with the flags used to update the NETLIST...
Definition: pcb_netlist.h:212
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
void SetDeleteExtraFootprints(bool aDeleteExtraFootprints)
Definition: pcb_netlist.h:298
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)
PCBNEW_SETTINGS * GetSettings()