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#pragma once
22
23#include <memory>
24#include <optional>
25#include <vector>
26#include <tl/expected.hpp>
27#include <core/typeinfo.h>
28#include <api/common/envelope.pb.h>
29#include <api/schematic/schematic_types.pb.h>
30#include <pin_map.h>
31#include <kiid.h>
32#include <math/box2.h>
33#include <sch_sheet_path.h>
34
35class EDA_ITEM;
36class SCH_SYMBOL;
37class SCH_SHEET;
38class SCHEMATIC;
39
40std::unique_ptr<EDA_ITEM> CreateItemForType( KICAD_T aType, EDA_ITEM* aContainer );
41
42bool PackSymbol( kiapi::schematic::types::SchematicSymbolInstance* aOutput, const SCH_SYMBOL* aInput,
43 const SCH_SHEET_PATH& aPath );
44
49bool UnpackSymbol( SCH_SYMBOL* aOutput, const kiapi::schematic::types::SchematicSymbolInstance& aInput );
50
58void ApplySymbolInstance( SCH_SYMBOL* aSymbol,
59 const kiapi::schematic::types::SchematicSymbolInstance& aInput,
60 const SCH_SHEET_PATH& aPath, SCHEMATIC* aSchematic );
61
63void PackPinMapOverride( kiapi::schematic::types::PinMapInstanceOverride* aOutput,
64 const PIN_MAP_INSTANCE_OVERRIDE& aOverride );
65
66PIN_MAP_INSTANCE_OVERRIDE UnpackPinMapOverride( const kiapi::schematic::types::PinMapInstanceOverride& aInput );
67
68bool PackSheet( kiapi::schematic::types::SheetSymbol* aOutput, const SCH_SHEET* aInput,
69 const SCH_SHEET_PATH& aPath );
70
74tl::expected<bool, kiapi::common::ApiResponseStatus> UnpackSheet( SCH_SHEET* aOutput,
75 const kiapi::schematic::types::SheetSymbol& aInput );
76
84void ApplySheetInstance( SCH_SHEET* aSheet, const kiapi::schematic::types::SheetSymbol& aInput,
85 const SCH_SHEET_PATH& aParentPath, SCHEMATIC* aSchematic );
86
88void PackSheetPath( kiapi::common::types::SheetPath& aOutput, const SCH_SHEET_PATH& aInput );
89
95
101tl::expected<SCH_FOCUS_TARGET, kiapi::common::ApiResponseStatus>
102ResolveFocusItems( SCHEMATIC& aSchematic, const std::vector<KIID>& aIds, const std::optional<KIID_PATH>& aSheetPath );
103
107std::optional<wxString> FindVariantNoCase( const SCHEMATIC* aSchematic, const wxString& aName );
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.
tl::expected< SCH_FOCUS_TARGET, kiapi::common::ApiResponseStatus > ResolveFocusItems(SCHEMATIC &aSchematic, const std::vector< KIID > &aIds, const std::optional< KIID_PATH > &aSheetPath)
Resolve the items of a FocusOnItems request to the sheet that shows them and their combined bounding ...
std::optional< wxString > FindVariantNoCase(const SCHEMATIC *aSchematic, const wxString &aName)
Variant names are stored and compared exactly, but SCHEMATIC::HasVariant matches case-insensitively.
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...
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
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:149
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:73
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
Per-instance override of the active pin map and a sparse delta on top.
Definition pin_map.h:200
SCH_SHEET_PATH Sheet
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70