KiCad PCB EDA Suite
Loading...
Searching...
No Matches
api_sch_utils.h File Reference
#include <memory>
#include <tl/expected.hpp>
#include <core/typeinfo.h>
#include <api/common/envelope.pb.h>
#include <api/schematic/schematic_types.pb.h>
#include <pin_map.h>

Go to the source code of this file.

Functions

std::unique_ptr< EDA_ITEMCreateItemForType (KICAD_T aType, EDA_ITEM *aContainer)
 
bool PackSymbol (kiapi::schematic::types::SchematicSymbolInstance *aOutput, const SCH_SYMBOL *aInput, const SCH_SHEET_PATH &aPath)
 
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 shared between every placement.
 
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 attribute and field differentials.
 
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).
 
PIN_MAP_INSTANCE_OVERRIDE UnpackPinMapOverride (const kiapi::schematic::types::PinMapInstanceOverride &aInput)
 
bool PackSheet (kiapi::schematic::types::SheetSymbol *aOutput, const SCH_SHEET *aInput, const SCH_SHEET_PATH &aPath)
 
tl::expected< bool, kiapi::common::ApiResponseStatus > UnpackSheet (SCH_SHEET *aOutput, const kiapi::schematic::types::SheetSymbol &aInput)
 Unpack the every placement data from the input.
 
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 carries.
 
void PackSheetPath (kiapi::common::types::SheetPath &aOutput, const SCH_SHEET_PATH &aInput)
 Specialization of PackSheetPath that includes the human-readable path.
 

Function Documentation

◆ ApplySheetInstance()

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 carries.

aParentPath is the path of the sheet that contains aSheet, which is how a sheet's placement records are keyed.

Definition at line 525 of file api_sch_utils.cpp.

References applySheetVariants(), and path.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and API_HANDLER_SCH::handleCreateUpdateItemsInternal().

◆ ApplySymbolInstance()

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 attribute and field differentials.

Variant names are registered with aSchematic so that the UI offers them for selection. aSymbol must already be in the schematic; the other placements of the symbol are untouched.

Definition at line 379 of file api_sch_utils.cpp.

References SCH_SYMBOL::AddHierarchicalReference(), applySymbolVariants(), SCH_SYMBOL::GetInstance(), SCH_SYMBOL_INSTANCE::m_Path, SCH_SYMBOL_INSTANCE::m_Reference, SCH_SYMBOL_INSTANCE::m_Unit, SCH_SHEET_PATH::Path(), SCH_SYMBOL::SetRef(), SCH_ITEM::SetUnit(), and SCH_SYMBOL::SetUnitSelection().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and API_HANDLER_SCH::handleCreateUpdateItemsInternal().

◆ CreateItemForType()

◆ PackPinMapOverride()

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).

Definition at line 110 of file api_sch_utils.cpp.

References edit, PIN_MAP_INSTANCE_OVERRIDE::m_ActiveMapName, PIN_MAP_INSTANCE_OVERRIDE::m_Edits, PIN_MAP_INSTANCE_OVERRIDE::m_Mode, and ToProtoEnum().

Referenced by PackSymbol().

◆ PackSheet()

◆ PackSheetPath()

void PackSheetPath ( kiapi::common::types::SheetPath & aOutput,
const SCH_SHEET_PATH & aInput )

Specialization of PackSheetPath that includes the human-readable path.

◆ PackSymbol()

◆ UnpackPinMapOverride()

PIN_MAP_INSTANCE_OVERRIDE UnpackPinMapOverride ( const kiapi::schematic::types::PinMapInstanceOverride & aInput)

Definition at line 127 of file api_sch_utils.cpp.

References FromProtoEnum(), and PIN_MAP_INSTANCE_OVERRIDE::m_Mode.

Referenced by applySymbolVariants(), and UnpackSymbol().

◆ UnpackSheet()

tl::expected< bool, kiapi::common::ApiResponseStatus > UnpackSheet ( SCH_SHEET * aOutput,
const kiapi::schematic::types::SheetSymbol & aInput )

Unpack the every placement data from the input.

Placement data is applied separately by ApplySheetInstance.

Definition at line 543 of file api_sch_utils.cpp.

References SCH_SHEET::Deserialize().

Referenced by BOOST_AUTO_TEST_CASE(), and API_HANDLER_SCH::handleCreateUpdateItemsInternal().

◆ UnpackSymbol()

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 shared between every placement.

Single-placement data is handled by ApplySymbolInstance.

Definition at line 259 of file api_sch_utils.cpp.

References SCH_SYMBOL::Deserialize(), SCH_SYMBOL::SetDNP(), SCH_SYMBOL::SetExcludedFromBoard(), SCH_SYMBOL::SetExcludedFromBOM(), SCH_SYMBOL::SetExcludedFromPosFiles(), SCH_SYMBOL::SetExcludedFromSim(), SCH_SYMBOL::SetPinMapOverride(), and UnpackPinMapOverride().

Referenced by BOOST_AUTO_TEST_CASE(), and API_HANDLER_SCH::handleCreateUpdateItemsInternal().