KiCad PCB EDA Suite
Loading...
Searching...
No Matches
headless_sch_context.h
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#ifndef KICAD_HEADLESS_SCH_CONTEXT_H
22#define KICAD_HEADLESS_SCH_CONTEXT_H
23
24#include <functional>
25#include <memory>
26
27#include <wx/string.h>
28
29#include <api/sch_context.h>
30
31class KIWAY;
32class PROJECT;
33class SCHEMATIC;
34class TOOL_MANAGER;
35
36
38{
39public:
40 HEADLESS_SCH_CONTEXT( SCHEMATIC** aSchematicSlot, PROJECT* aProject, KIWAY* aKiway = nullptr );
41
43
44 SCHEMATIC* GetSchematic() const override;
45
46 PROJECT& Prj() const override;
47
48 TOOL_MANAGER* GetToolManager() const override;
49
50 KIWAY* GetKiway() const override { return m_kiway; }
51
52 wxString GetCurrentFileName() const override;
53
54 bool CanAcceptApiCommands() const override { return true; }
55
56 std::optional<SCH_SHEET_PATH> GetCurrentSheet() const override { return std::nullopt; }
57
58 bool SaveSchematic() override;
59
60 bool SaveSchematicCopy( const wxString& aFileName, bool aCreateProject ) override;
61
62 bool RevertToSaved() override;
63
64private:
65 // Pointer-to-pointer because we don't own the schematic and the underlying pointer gets
66 // replaced if the client calls RevertToSaved. This will always point to the IFACE's pointer.
70 std::unique_ptr<TOOL_MANAGER> m_toolManager;
71};
72
73#endif
std::optional< SCH_SHEET_PATH > GetCurrentSheet() const override
SCHEMATIC * GetSchematic() const override
~HEADLESS_SCH_CONTEXT() override
PROJECT & Prj() const override
TOOL_MANAGER * GetToolManager() const override
KIWAY * GetKiway() const override
bool CanAcceptApiCommands() const override
wxString GetCurrentFileName() const override
bool SaveSchematicCopy(const wxString &aFileName, bool aCreateProject) override
HEADLESS_SCH_CONTEXT(SCHEMATIC **aSchematicSlot, PROJECT *aProject, KIWAY *aKiway=nullptr)
std::unique_ptr< TOOL_MANAGER > m_toolManager
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition kiway.h:340
Container for project specific data.
Definition project.h:63
Holds all the data relating to one schematic.
Definition schematic.h:148
An interface for the frame surface that the SCH API handlers need; to enable headless mode.
Definition sch_context.h:39
Master controller class: