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 <common.h>
29 #include <pcb_edit_frame.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_draw_panel_gal.h>
38 #include <class_board.h>
39 #include <ratsnest_data.h>
40 #include <view/view.h>
41 #include <functional>
42 #include <kiface_i.h>
43 
44 using namespace std::placeholders;
45 
46 #define NETLIST_FILTER_MESSAGES_KEY wxT("NetlistReportFilterMsg")
47 #define NETLIST_UPDATEFOOTPRINTS_KEY wxT("NetlistUpdateFootprints")
48 #define NETLIST_DELETESHORTINGTRACKS_KEY wxT("NetlistDeleteShortingTracks")
49 #define NETLIST_DELETEEXTRAFOOTPRINTS_KEY wxT("NetlistDeleteExtraFootprints")
50 #define NETLIST_DELETESINGLEPADNETS_KEY wxT("NetlistDeleteSinglePadNets")
51 
53 
54 
56  DIALOG_UPDATE_PCB_BASE( aParent ),
57  m_frame( aParent ),
58  m_netlist( aNetlist ),
59  m_initialized( false )
60 {
62 
67 
68  m_messagePanel->SetLabel( _("Changes To Be Applied") );
71 
73 
74  m_messagePanel->GetSizer()->SetSizeHints( this );
75 
76  // We use a sdbSizer to get platform-dependent ordering of the action buttons, but
77  // that requires us to correct the button labels here.
78  m_sdbSizer1OK->SetLabel( _( "Update PCB" ) );
79  m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
80  m_sdbSizer1->Layout();
81 
82  m_sdbSizer1OK->SetDefault();
84 
85  m_initialized = true;
86  PerformUpdate( true );
87 }
88 
89 
91 {
93 
98 
99  if( m_runDragCommand )
100  {
102  controls->SetCursorPosition( controls->GetMousePosition() );
104  }
105 }
106 
107 
109 {
111 
112  REPORTER& reporter = m_messagePanel->Reporter();
113 
114  m_runDragCommand = false;
115 
117  m_netlist->SetFindByTimeStamp( m_matchByTimestamp->GetSelection() == 0 );
119 
121  updater.SetReporter ( &reporter );
122  updater.SetIsDryRun( aDryRun );
123  updater.SetLookupByTimestamp( m_matchByTimestamp->GetSelection() == 0 );
124  updater.SetDeleteUnusedComponents ( m_cbDeleteExtraFootprints->GetValue() );
125  updater.SetReplaceFootprints( m_cbUpdateFootprints->GetValue() );
126  updater.SetDeleteSinglePadNets( m_cbDeleteSinglePadNets->GetValue() );
127  m_warnForNoNetPads = m_cbWarnNoNetPad->GetValue();
128  updater.SetWarnPadNoNetInNetlist( m_warnForNoNetPads );
129  updater.UpdateNetlist( *m_netlist );
130 
131  m_messagePanel->Flush( true );
132 
133  if( aDryRun )
134  return;
135 
137 }
138 
139 
140 void DIALOG_UPDATE_PCB::OnMatchChanged( wxCommandEvent& event )
141 {
142  if( m_initialized )
143  PerformUpdate( true );
144 }
145 
146 
147 void DIALOG_UPDATE_PCB::OnOptionChanged( wxCommandEvent& event )
148 {
149  if( m_initialized )
150  PerformUpdate( true );
151 }
152 
153 
154 void DIALOG_UPDATE_PCB::OnUpdateClick( wxCommandEvent& event )
155 {
156  m_messagePanel->SetLabel( _( "Changes Applied To PCB" ) );
157  PerformUpdate( false );
158  m_sdbSizer1Cancel->SetDefault();
159 }
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
void OnMatchChanged(wxCommandEvent &event) override
Class 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.
#define NETLIST_FILTER_MESSAGES_KEY
void Flush(bool aSort=false)
Forces updating the HTML page, after the report is built in lazy mode If aSort = true,...
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
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:109
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:314
void SetReporter(REPORTER *aReporter)
Sets the reporter object
Class REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:61
void OnNetlistChanged(BOARD_NETLIST_UPDATER &aUpdater, bool *aRunDragCommand)
Called after netlist is updated.
Definition: netlist.cpp:95
PCB_EDIT_FRAME * m_frame
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
void SortByReference()
wxConfigBase * m_config
void OnUpdateClick(wxCommandEvent &event) override
void SetReplaceFootprints(bool aReplaceFootprints)
Definition: pcb_netlist.h:318
Class NETLIST stores all of information read from a netlist along with the flags used to update the N...
Definition: pcb_netlist.h:217
REPORTER & Reporter()
returns the reporter object that reports to this panel
#define NETLIST_DELETESINGLEPADNETS_KEY
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
#define _(s)
WX_HTML_REPORT_PANEL * m_messagePanel
void Clear()
clears the report panel
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
static bool m_warnForNoNetPads
The common library.
#define NETLIST_DELETEEXTRAFOOTPRINTS_KEY
#define NETLIST_UPDATEFOOTPRINTS_KEY
void SetDeleteExtraFootprints(bool aDeleteExtraFootprints)
Definition: pcb_netlist.h:303
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)