KiCad PCB EDA Suite
Loading...
Searching...
No Matches
api_sch_utils.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
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef KICAD_API_SCH_UTILS_H
22#define KICAD_API_SCH_UTILS_H
23
24#include <memory>
25#include <tl/expected.hpp>
26#include <core/typeinfo.h>
27#include <api/common/envelope.pb.h>
28#include <api/schematic/schematic_types.pb.h>
29#include <pin_map.h>
30
31class EDA_ITEM;
32class SCH_SYMBOL;
33class SCH_SHEET;
34class SCH_SHEET_PATH;
35class SCHEMATIC;
36
37std::unique_ptr<EDA_ITEM> CreateItemForType( KICAD_T aType, EDA_ITEM* aContainer );
38
39bool PackSymbol( kiapi::schematic::types::SchematicSymbolInstance* aOutput, const SCH_SYMBOL* aInput,
40 const SCH_SHEET_PATH& aPath );
41
46bool UnpackSymbol( SCH_SYMBOL* aOutput, const kiapi::schematic::types::SchematicSymbolInstance& aInput );
47
55void ApplySymbolInstance( SCH_SYMBOL* aSymbol,
56 const kiapi::schematic::types::SchematicSymbolInstance& aInput,
57 const SCH_SHEET_PATH& aPath, SCHEMATIC* aSchematic );
58
60void PackPinMapOverride( kiapi::schematic::types::PinMapInstanceOverride* aOutput,
61 const PIN_MAP_INSTANCE_OVERRIDE& aOverride );
62
63PIN_MAP_INSTANCE_OVERRIDE UnpackPinMapOverride( const kiapi::schematic::types::PinMapInstanceOverride& aInput );
64
65bool PackSheet( kiapi::schematic::types::SheetSymbol* aOutput, const SCH_SHEET* aInput,
66 const SCH_SHEET_PATH& aPath );
67
71tl::expected<bool, kiapi::common::ApiResponseStatus> UnpackSheet( SCH_SHEET* aOutput, const kiapi::schematic::types::SheetSymbol& aInput );
72
80void ApplySheetInstance( SCH_SHEET* aSheet, const kiapi::schematic::types::SheetSymbol& aInput,
81 const SCH_SHEET_PATH& aParentPath, SCHEMATIC* aSchematic );
82
84void PackSheetPath( kiapi::common::types::SheetPath& aOutput, const SCH_SHEET_PATH& aInput );
85
86#endif //KICAD_API_SCH_UTILS_H
std::unique_ptr< EDA_ITEM > CreateItemForType(KICAD_T aType, EDA_ITEM *aContainer)
void ApplySymbolInstance(SCH_SYMBOL *aSymbol, const kiapi::schematic::types::SchematicSymbolInstance &aInput, const SCH_SHEET_PATH &aPath, SCHEMATIC *aSchematic)
Apply placement-specific data to an aSymbol at aPath: reference, unit, and the per-placement attribut...
void PackSheetPath(kiapi::common::types::SheetPath &aOutput, const SCH_SHEET_PATH &aInput)
Specialization of PackSheetPath that includes the human-readable path.
bool PackSheet(kiapi::schematic::types::SheetSymbol *aOutput, const SCH_SHEET *aInput, const SCH_SHEET_PATH &aPath)
bool PackSymbol(kiapi::schematic::types::SchematicSymbolInstance *aOutput, const SCH_SYMBOL *aInput, const SCH_SHEET_PATH &aPath)
void ApplySheetInstance(SCH_SHEET *aSheet, const kiapi::schematic::types::SheetSymbol &aInput, const SCH_SHEET_PATH &aParentPath, SCHEMATIC *aSchematic)
Apply the placement data in a sheet message to aSheet: page number and the variants the message carri...
PIN_MAP_INSTANCE_OVERRIDE UnpackPinMapOverride(const kiapi::schematic::types::PinMapInstanceOverride &aInput)
void PackPinMapOverride(kiapi::schematic::types::PinMapInstanceOverride *aOutput, const PIN_MAP_INSTANCE_OVERRIDE &aOverride)
Pack/unpack a pin-to-pad map instance override to/from its protobuf form (issue #2282).
tl::expected< bool, kiapi::common::ApiResponseStatus > UnpackSheet(SCH_SHEET *aOutput, const kiapi::schematic::types::SheetSymbol &aInput)
Unpack the every placement data from the input.
bool UnpackSymbol(SCH_SYMBOL *aOutput, const kiapi::schematic::types::SchematicSymbolInstance &aInput)
Unpack the geometry, the library definition, fields, and the default-variant attributes that are shar...
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
Holds all the data relating to one schematic.
Definition schematic.h:148
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
Schematic symbol object.
Definition sch_symbol.h:75
Per-instance override of the active pin map and a sparse delta on top.
Definition pin_map.h:200
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70