KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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>
31#include <tool/tool_manager.h>
32#include <tools/pcb_actions.h>
33#include <view/view_controls.h>
34#include <kiface_base.h>
35#include <kiplatform/ui.h>
36
37
39 DIALOG_UPDATE_PCB_BASE( aParent ),
40 m_frame( aParent ),
41 m_netlist( aNetlist ),
42 m_initialized( false )
43{
44 auto cfg = m_frame->GetPcbNewSettings();
45
46 m_cbRelinkFootprints->SetValue( cfg->m_NetlistDialog.associate_by_ref_sch );
47 m_cbUpdateFootprints->SetValue( cfg->m_NetlistDialog.update_footprints );
48 m_cbDeleteExtraFootprints->SetValue( cfg->m_NetlistDialog.delete_extra_footprints );
49
50 m_messagePanel->SetLabel( _("Changes to Be Applied") );
51 m_messagePanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
54
55 m_messagePanel->SetVisibleSeverities( cfg->m_NetlistDialog.report_filter );
56
57 m_messagePanel->GetSizer()->SetSizeHints( this );
58 m_messagePanel->Layout();
59
60 SetupStandardButtons( { { wxID_OK, _( "Update PCB" ) },
61 { wxID_CANCEL, _( "Close" ) } } );
62
64
65 m_initialized = true;
66 PerformUpdate( true );
67}
68
69
71{
72 PCBNEW_SETTINGS* cfg = nullptr;
73
74 try
75 {
77 }
78 catch( const std::runtime_error& e )
79 {
80 wxFAIL_MSG( e.what() );
81 }
82
83 if( cfg )
84 {
89 }
90
92 {
94 controls->SetCursorPosition( controls->GetMousePosition() );
96 }
97}
98
99
101{
103
104 REPORTER& reporter = m_messagePanel->Reporter();
105
106 m_runDragCommand = false;
107
110
111 if( !aDryRun )
112 {
115 }
116
118 updater.SetReporter ( &reporter );
119 updater.SetIsDryRun( aDryRun );
120 updater.SetLookupByTimestamp( !m_cbRelinkFootprints->GetValue() );
122 updater.SetReplaceFootprints( m_cbUpdateFootprints->GetValue() );
123 updater.SetOverrideLocks( m_cbOverrideLocks->GetValue() );
124 updater.UpdateNetlist( *m_netlist );
125
126 m_messagePanel->Flush( true );
127
128 if( aDryRun )
129 return;
130
132}
133
134
135void DIALOG_UPDATE_PCB::OnOptionChanged( wxCommandEvent& event )
136{
137 if( m_initialized )
138 {
139 PerformUpdate( true );
140 m_sdbSizer1OK->Enable( true );
141 m_sdbSizer1OK->SetDefault();
142 }
143}
144
145
146void DIALOG_UPDATE_PCB::OnUpdateClick( wxCommandEvent& event )
147{
148 m_messagePanel->SetLabel( _( "Changes Applied to PCB" ) );
149 PerformUpdate( false );
150
151 m_sdbSizer1Cancel->SetDefault();
152 // wxWidgets has a tendency to keep both buttons highlighted without the following:
153 m_sdbSizer1OK->Enable( false );
154}
Update the BOARD with a new netlist.
void SetReporter(REPORTER *aReporter)
Enable dry run mode (just report, no changes to PCB).
bool UpdateNetlist(NETLIST &aNetlist)
Update the board's components according to the new netlist.
void SetIsDryRun(bool aEnabled)
void SetDeleteUnusedFootprints(bool aEnabled)
void SetOverrideLocks(bool aOverride)
void SetReplaceFootprints(bool aEnabled)
void SetLookupByTimestamp(bool aEnabled)
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_UPDATE_PCB_BASE.
WX_HTML_REPORT_PANEL * m_messagePanel
void PerformUpdate(bool aDryRun)
void OnOptionChanged(wxCommandEvent &event) override
void OnUpdateClick(wxCommandEvent &event) override
DIALOG_UPDATE_PCB(PCB_EDIT_FRAME *aParent, NETLIST *aNetlist)
PCB_EDIT_FRAME * m_frame
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
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.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Definition: pcb_netlist.h:241
void SetReplaceFootprints(bool aReplace)
Definition: pcb_netlist.h:304
void SetFindByTimeStamp(bool aFindByTimeStamp)
Definition: pcb_netlist.h:301
void SortByReference()
DIALOG_NETLIST m_NetlistDialog
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:68
static TOOL_ACTION move
move or drag an item
Definition: pcb_actions.h:120
PCBNEW_SETTINGS * GetPcbNewSettings() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
BOARD * GetBoard() const
The main frame for Pcbnew.
void OnNetlistChanged(BOARD_NETLIST_UPDATER &aUpdater, bool *aRunDragCommand)
Called after netlist is updated.
Definition: netlist.cpp:87
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:72
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
void DeactivateTool()
Deactivate the currently active tool.
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
void Clear()
Clears the report panel.
void SetLazyUpdate(bool aLazyUpdate)
Set the lazy update.
void SetLabel(const wxString &aLabel) override
Set the frame label.
void SetFileName(const wxString &aReportFileName)
Set the report full file name to the string.
void SetVisibleSeverities(int aSeverities)
Set the visible severity filter.
void Flush(bool aSort=false)
Force updating the HTML page, after the report is built in lazy mode If aSort = true,...
REPORTER & Reporter()
Return the reporter object that reports to this panel.
#define _(s)
Class that computes missing connections on a PCB.