KiCad PCB EDA Suite
Loading...
Searching...
No Matches
api_handler_sch.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 (C) 2024 Jon Evans <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
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 along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef KICAD_API_HANDLER_SCH_H
22#define KICAD_API_HANDLER_SCH_H
23
25#include <api/sch_context.h>
26#include <api/common/commands/editor_commands.pb.h>
27#include <api/schematic/schematic_commands.pb.h>
28#include <api/schematic/schematic_jobs.pb.h>
29#include <kiid.h>
30
31using namespace kiapi;
32using namespace kiapi::common;
33
34class SCH_EDIT_FRAME;
35class SCH_ITEM;
36class SCH_SHEET;
37
38
40{
41public:
43 API_HANDLER_SCH( std::shared_ptr<SCH_CONTEXT> aContext, SCH_EDIT_FRAME* aFrame = nullptr );
44
45protected:
46 std::unique_ptr<COMMIT> createCommit() override;
47
48 kiapi::common::types::DocumentType thisDocumentType() const override
49 {
50 return kiapi::common::types::DOCTYPE_SCHEMATIC;
51 }
52
53 const EDA_IU_SCALE& getIuScale() const override { return schIUScale; }
55 tl::expected<bool, ApiResponseStatus> validateDocumentInternal( const DocumentSpecifier& aDocument ) const override;
56
57 std::optional<SCH_ITEM*> getItemById( const KIID& aId, SCH_SHEET_PATH* aPathOut = nullptr ) const;
58
60 EDA_ITEM* aContainer );
61
63 const std::string& aClientName,
64 const types::ItemHeader &aHeader,
65 const google::protobuf::RepeatedPtrField<google::protobuf::Any>& aItems,
66 std::function<void(commands::ItemStatus, google::protobuf::Any)> aItemHandler )
67 override;
68
69 void deleteItemsInternal( std::map<KIID, ItemDeletionStatus>& aItemsToDelete,
70 const std::string& aClientName ) override;
71
72 std::optional<EDA_ITEM*> getItemFromDocument( const DocumentSpecifier& aDocument,
73 const KIID& aId ) override;
74
75 std::optional<TITLE_BLOCK*> getTitleBlock() override;
76
77 std::optional<PAGE_INFO> getPageSettings() override;
78
79 bool setPageSettings( const PAGE_INFO& aPageInfo ) override;
80
81 wxString getDrawingSheetFileName() override;
82
83 void setDrawingSheetFileName( const wxString& aFileName ) override;
84
85 void onModified() override;
86
87private:
90
92
95
98
101
104
107
110
113
116
117 void packSheetInstance( kiapi::schematic::types::SheetInstance* aInstance, SCH_SHEET_PATH& aPath,
118 SCH_SHEET* aSheet );
119
122
123 SCHEMATIC* schematic() const;
124
125 void filterValidSchTypes( std::set<KICAD_T>& aTypeList );
126
128 std::shared_ptr<SCH_CONTEXT> m_context;
129 static std::set<KICAD_T> s_allowedTypes;
130};
131
132
133#endif //KICAD_API_HANDLER_SCH_H
tl::expected< T, ApiResponseStatus > HANDLER_RESULT
Definition api_handler.h:45
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:127
API_HANDLER_EDITOR(EDA_BASE_FRAME *aFrame=nullptr)
HANDLER_RESULT< types::RunJobResponse > handleRunSchematicJobExportDxf(const HANDLER_CONTEXT< kiapi::schematic::jobs::RunSchematicJobExportDxf > &aCtx)
std::optional< TITLE_BLOCK * > getTitleBlock() override
wxString getDrawingSheetFileName() override
SCH_EDIT_FRAME * m_frame
HANDLER_RESULT< kiapi::schematic::types::SchematicHierarchyResponse > handleGetSchematicHierarchy(const HANDLER_CONTEXT< kiapi::schematic::types::GetSchematicHierarchy > &aCtx)
std::unique_ptr< COMMIT > createCommit() override
Override this to create an appropriate COMMIT subclass for the frame in question.
SCHEMATIC * schematic() const
HANDLER_RESULT< kiapi::schematic::types::SchematicNetlistResponse > handleGetSchematicNetlist(const HANDLER_CONTEXT< kiapi::schematic::types::GetSchematicNetlist > &aCtx)
HANDLER_RESULT< types::RunJobResponse > handleRunSchematicJobExportPdf(const HANDLER_CONTEXT< kiapi::schematic::jobs::RunSchematicJobExportPdf > &aCtx)
static std::set< KICAD_T > s_allowedTypes
HANDLER_RESULT< commands::GetItemsResponse > handleGetItemsById(const HANDLER_CONTEXT< commands::GetItemsById > &aCtx)
std::optional< SCH_ITEM * > getItemById(const KIID &aId, SCH_SHEET_PATH *aPathOut=nullptr) const
bool setPageSettings(const PAGE_INFO &aPageInfo) override
std::shared_ptr< SCH_CONTEXT > m_context
std::optional< EDA_ITEM * > getItemFromDocument(const DocumentSpecifier &aDocument, const KIID &aId) override
const EDA_IU_SCALE & getIuScale() const override
Returns the internal-unit scale that the concrete editor uses.
HANDLER_RESULT< types::RunJobResponse > handleRunSchematicJobExportSvg(const HANDLER_CONTEXT< kiapi::schematic::jobs::RunSchematicJobExportSvg > &aCtx)
HANDLER_RESULT< std::unique_ptr< EDA_ITEM > > createItemForType(KICAD_T aType, EDA_ITEM *aContainer)
void filterValidSchTypes(std::set< KICAD_T > &aTypeList)
HANDLER_RESULT< types::RunJobResponse > handleRunSchematicJobExportBOM(const HANDLER_CONTEXT< kiapi::schematic::jobs::RunSchematicJobExportBOM > &aCtx)
std::optional< PAGE_INFO > getPageSettings() override
HANDLER_RESULT< types::RunJobResponse > handleRunSchematicJobExportPs(const HANDLER_CONTEXT< kiapi::schematic::jobs::RunSchematicJobExportPs > &aCtx)
void onModified() override
API_HANDLER_SCH(SCH_EDIT_FRAME *aFrame)
kiapi::common::types::DocumentType thisDocumentType() const override
Override this to specify which document type this editor handles.
HANDLER_RESULT< types::ItemRequestStatus > handleCreateUpdateItemsInternal(bool aCreate, const std::string &aClientName, const types::ItemHeader &aHeader, const google::protobuf::RepeatedPtrField< google::protobuf::Any > &aItems, std::function< void(commands::ItemStatus, google::protobuf::Any)> aItemHandler) override
HANDLER_RESULT< commands::GetOpenDocumentsResponse > handleGetOpenDocuments(const HANDLER_CONTEXT< commands::GetOpenDocuments > &aCtx)
HANDLER_RESULT< types::RunJobResponse > handleRunSchematicJobExportNetlist(const HANDLER_CONTEXT< kiapi::schematic::jobs::RunSchematicJobExportNetlist > &aCtx)
void deleteItemsInternal(std::map< KIID, ItemDeletionStatus > &aItemsToDelete, const std::string &aClientName) override
void packSheetInstance(kiapi::schematic::types::SheetInstance *aInstance, SCH_SHEET_PATH &aPath, SCH_SHEET *aSheet)
tl::expected< bool, ApiResponseStatus > validateDocumentInternal(const DocumentSpecifier &aDocument) const override
void setDrawingSheetFileName(const wxString &aFileName) override
HANDLER_RESULT< commands::GetItemsResponse > handleGetItems(const HANDLER_CONTEXT< commands::GetItems > &aCtx)
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:100
Definition kiid.h:48
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:79
Holds all the data relating to one schematic.
Definition schematic.h:89
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:168
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:75