KiCad PCB EDA Suite
Loading...
Searching...
No Matches
api_sch_utils.h File Reference
#include <memory>
#include <optional>
#include <vector>
#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>
#include <kiid.h>
#include <math/box2.h>
#include <sch_sheet_path.h>

Go to the source code of this file.

Classes

struct  SCH_FOCUS_TARGET
 

Functions

std::unique_ptr< EDA_ITEM > CreateItemForType (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.
 
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 box.
 
std::optional< wxString > FindVariantNoCase (const SCHEMATIC *aSchematic, const wxString &aName)
 Variant names are stored and compared exactly, but SCHEMATIC::HasVariant matches case-insensitively.
 

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 547 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 401 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()

◆ FindVariantNoCase()

std::optional< wxString > FindVariantNoCase ( const SCHEMATIC * aSchematic,
const wxString & aName )

◆ 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 114 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()

◆ ResolveFocusItems()

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

Every item must be on one sheet: aSheetPath when given, otherwise the first sheet the items resolve to. Unknown or off-sheet items and an empty list are bad requests.

Definition at line 590 of file api_sch_utils.cpp.

References EDA_ITEM::GetBoundingBox(), SCH_SHEET_LIST::GetSheetPathByKIIDPath(), SCHEMATIC::HasHierarchy(), SCHEMATIC::Hierarchy(), kiapi::common::MakeResponseStatus(), SCHEMATIC::RefreshHierarchy(), and SCHEMATIC::ResolveItem().

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

◆ UnpackPinMapOverride()

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

Definition at line 131 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 565 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 264 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().