KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_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/sch_context.h>
22#include <api/sch_api_save.h>
23
24#include <sch_edit_frame.h>
25
26
28{
29public:
31 m_frame( aFrame )
32 {
33 }
34
35 SCHEMATIC* GetSchematic() const override
36 {
37 return &m_frame->Schematic();
38 }
39
40 PROJECT& Prj() const override
41 {
42 return m_frame->Prj();
43 }
44
45 TOOL_MANAGER* GetToolManager() const override
46 {
47 return m_frame->GetToolManager();
48 }
49
50 KIWAY* GetKiway() const override
51 {
52 return &m_frame->Kiway();
53 }
54
55 wxString GetCurrentFileName() const override
56 {
57 return m_frame->GetCurrentFileName();
58 }
59
60 bool CanAcceptApiCommands() const override
61 {
62 return m_frame->CanAcceptApiCommands();
63 }
64
65 std::optional<SCH_SHEET_PATH> GetCurrentSheet() const override
66 {
67 return m_frame->GetCurrentSheet();
68 }
69
70 bool SaveSchematic() override
71 {
72 return SCH_API_SAVE::SaveSchematic( m_frame->Schematic(), m_frame->Prj() );
73 }
74
75 bool SaveSchematicCopy( const wxString& aFileName, bool aCreateProject ) override
76 {
77 return SCH_API_SAVE::SaveSchematicCopy( m_frame->Schematic(), m_frame->Prj(), aFileName, aCreateProject );
78 }
79
80private:
82};
83
84
85std::shared_ptr<SCH_CONTEXT> CreateSchFrameContext( SCH_EDIT_FRAME* aFrame )
86{
87 return std::make_shared<SCH_EDIT_FRAME_CONTEXT>( aFrame );
88}
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:311
Container for project specific data.
Definition project.h:62
Holds all the data relating to one schematic.
Definition schematic.h:90
An interface for the frame surface that the SCH API handlers need; to enable headless mode.
Definition sch_context.h:39
std::optional< SCH_SHEET_PATH > GetCurrentSheet() const override
SCH_EDIT_FRAME * m_frame
SCHEMATIC * GetSchematic() const override
bool CanAcceptApiCommands() const override
PROJECT & Prj() const override
bool SaveSchematicCopy(const wxString &aFileName, bool aCreateProject) override
KIWAY * GetKiway() const override
bool SaveSchematic() override
wxString GetCurrentFileName() const override
SCH_EDIT_FRAME_CONTEXT(SCH_EDIT_FRAME *aFrame)
TOOL_MANAGER * GetToolManager() const override
Schematic editor (Eeschema) main window.
Master controller class:
bool SaveSchematic(SCHEMATIC &aSchematic, PROJECT &aProject)
Save every screen in the hierarchy to its current path, then update the project file.
bool SaveSchematicCopy(SCHEMATIC &aSchematic, PROJECT &aProject, const wxString &aFileName, bool aCreateProject)
Save the root schematic to aFileName without changing the open document.
std::shared_ptr< SCH_CONTEXT > CreateSchFrameContext(SCH_EDIT_FRAME *aFrame)