KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_context.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 * @author Jon Evans <[email protected]>
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <api/pcb_context.h>
22
25#include <pcb_edit_frame.h>
26#include <reporter.h>
27
28
30{
31public:
33 m_frame( aFrame )
34 {
35 }
36
37 BOARD* GetBoard() const override
38 {
39 return m_frame->GetBoard();
40 }
41
42 PROJECT& Prj() const override
43 {
44 return m_frame->Prj();
45 }
46
47 TOOL_MANAGER* GetToolManager() const override
48 {
49 return m_frame->GetToolManager();
50 }
51
52 KIWAY* GetKiway() const override
53 {
54 return &m_frame->Kiway();
55 }
56
57 wxString GetCurrentFileName() const override
58 {
59 return m_frame->GetCurrentFileName();
60 }
61
62 bool CanAcceptApiCommands() const override
63 {
64 return m_frame->CanAcceptApiCommands();
65 }
66
67 bool SaveBoard() override
68 {
69 return m_frame->SaveBoard();
70 }
71
72 bool SavePcbCopy( const wxString& aFileName, bool aCreateProject, bool aHeadless ) override
73 {
74 return m_frame->SavePcbCopy( aFileName, aCreateProject, aHeadless );
75 }
76
77 bool ReadNetlistFromFile( const wxString& aFilename, NETLIST& aNetlist, REPORTER& aReporter ) override
78 {
79 return m_frame->ReadNetlistFromFile( aFilename, aNetlist, aReporter );
80 }
81
82 std::unique_ptr<BOARD_NETLIST_UPDATER> MakeNetlistUpdater() override
83 {
84 return std::make_unique<BOARD_NETLIST_UPDATER>( m_frame, GetBoard() );
85 }
86
87 void OnNetlistChanged( BOARD_NETLIST_UPDATER& aUpdater ) override
88 {
89 bool runDragCommand = false;
90 m_frame->OnNetlistChanged( aUpdater, &runDragCommand );
91 }
92
93private:
95};
96
97
98std::shared_ptr<PCB_CONTEXT> CreatePcbFrameContext( PCB_EDIT_FRAME* aFrame )
99{
100 return std::make_shared<PCB_EDIT_FRAME_CONTEXT>( aFrame );
101}
Update the BOARD with a new netlist.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:311
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
PCB-editor-specific context; extends BOARD_CONTEXT with save/filename operations.
Definition pcb_context.h:38
TOOL_MANAGER * GetToolManager() const override
bool SavePcbCopy(const wxString &aFileName, bool aCreateProject, bool aHeadless) override
std::unique_ptr< BOARD_NETLIST_UPDATER > MakeNetlistUpdater() override
Create a netlist updater bound to this context's board.
wxString GetCurrentFileName() const override
bool SaveBoard() override
PROJECT & Prj() const override
bool CanAcceptApiCommands() const override
bool ReadNetlistFromFile(const wxString &aFilename, NETLIST &aNetlist, REPORTER &aReporter) override
Read a netlist file and preload component footprints.
PCB_EDIT_FRAME_CONTEXT(PCB_EDIT_FRAME *aFrame)
void OnNetlistChanged(BOARD_NETLIST_UPDATER &aUpdater) override
Post-import board sync (nets, classes, DRC, ratsnest, new footprint placement).
KIWAY * GetKiway() const override
BOARD * GetBoard() const override
PCB_EDIT_FRAME * m_frame
The main frame for Pcbnew.
Container for project specific data.
Definition project.h:62
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:71
Master controller class:
std::shared_ptr< PCB_CONTEXT > CreatePcbFrameContext(PCB_EDIT_FRAME *aFrame)