KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pads_sch_symbol_builder.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) 2025 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef PADS_SCH_SYMBOL_BUILDER_H_
21#define PADS_SCH_SYMBOL_BUILDER_H_
22
24#include <lib_id.h>
25#include <map>
26#include <memory>
27#include <optional>
28#include <string>
29
30class LIB_SYMBOL;
31class SCH_SHAPE;
32class SCH_PIN;
33class SCHEMATIC;
34
35namespace PADS_SCH
36{
37
45{
46public:
47 PADS_SCH_SYMBOL_BUILDER( const PARAMETERS& aParams );
49
56 LIB_SYMBOL* BuildSymbol( const SYMBOL_DEF& aSymbolDef );
57
67 LIB_SYMBOL* GetOrCreateSymbol( const SYMBOL_DEF& aSymbolDef );
68
72 bool HasSymbol( const std::string& aName ) const;
73
80 LIB_SYMBOL* GetSymbol( const std::string& aName ) const;
81
88 static bool IsPowerSymbol( const std::string& aName );
89
96 static std::optional<LIB_ID> GetKiCadPowerSymbolId( const std::string& aPadsName );
97
105 LIB_SYMBOL* BuildKiCadPowerSymbol( const std::string& aKiCadName );
106
117 static std::string GetPowerStyleFromVariant( const std::string& aDecalName,
118 const std::string& aPinType );
119
132 const std::vector<SYMBOL_DEF>& aSymbolDefs );
133
141 const std::vector<SYMBOL_DEF>& aSymbolDefs );
142
152 const SYMBOL_DEF& aSymbolDef );
153
167 const SYMBOL_DEF& aSymbolDef,
168 const std::string& aPinNumber );
169
184 const SYMBOL_DEF& aSymbolDef,
185 const std::vector<std::string>& aPinNumbers );
186
197 const PARTTYPE_DEF& aPartType,
198 const SYMBOL_DEF& aSymbolDef,
199 const std::vector<std::string>& aPinNumbers,
200 const std::string& aCacheKey );
201
208 void AddHiddenPowerPins( LIB_SYMBOL* aSymbol,
209 const std::vector<PARTTYPE_DEF::SIGPIN>& aSigpins );
210
211private:
215 int toKiCadUnits( double aPadsValue ) const;
216
221 SCH_SHAPE* createShape( const SYMBOL_GRAPHIC& aGraphic );
222
227 std::vector<SCH_SHAPE*> createShapes( const SYMBOL_GRAPHIC& aGraphic );
228
232 SCH_PIN* createPin( const SYMBOL_PIN& aPin, LIB_SYMBOL* aParent );
233
237 int mapPinType( PIN_TYPE aPadsType );
238
240 std::map<std::string, std::unique_ptr<LIB_SYMBOL>> m_symbolCache;
241};
242
243} // namespace PADS_SCH
244
245#endif // PADS_SCH_SYMBOL_BUILDER_H_
Define a library symbol object.
Definition lib_symbol.h:83
int mapPinType(PIN_TYPE aPadsType)
Map PADS pin type to KiCad electrical type.
LIB_SYMBOL * BuildMultiUnitSymbol(const PARTTYPE_DEF &aPartType, const std::vector< SYMBOL_DEF > &aSymbolDefs)
Build a composite multi-unit LIB_SYMBOL from a multi-gate PARTTYPE.
bool HasSymbol(const std::string &aName) const
Check if a symbol with the given name already exists.
void AddHiddenPowerPins(LIB_SYMBOL *aSymbol, const std::vector< PARTTYPE_DEF::SIGPIN > &aSigpins)
Add hidden power pins from PARTTYPE SIGPIN entries to an existing symbol.
SCH_PIN * createPin(const SYMBOL_PIN &aPin, LIB_SYMBOL *aParent)
Create a SCH_PIN from a PADS pin definition.
LIB_SYMBOL * GetSymbol(const std::string &aName) const
Get a cached symbol by name.
int toKiCadUnits(double aPadsValue) const
Convert PADS coordinate to KiCad internal units.
LIB_SYMBOL * GetOrCreateMultiUnitSymbol(const PARTTYPE_DEF &aPartType, const std::vector< SYMBOL_DEF > &aSymbolDefs)
Get or create a multi-unit symbol for the given PARTTYPE.
static std::optional< LIB_ID > GetKiCadPowerSymbolId(const std::string &aPadsName)
Get KiCad power library symbol ID for a PADS power symbol.
std::vector< SCH_SHAPE * > createShapes(const SYMBOL_GRAPHIC &aGraphic)
Create one or more SCH_SHAPEs from a PADS graphic element.
LIB_SYMBOL * BuildKiCadPowerSymbol(const std::string &aKiCadName)
Build a power symbol using hard-coded KiCad-standard graphics.
PADS_SCH_SYMBOL_BUILDER(const PARAMETERS &aParams)
static bool IsPowerSymbol(const std::string &aName)
Check if a symbol name indicates a power symbol.
static std::string GetPowerStyleFromVariant(const std::string &aDecalName, const std::string &aPinType)
Map a PADS special_variant to a power symbol style name.
SCH_SHAPE * createShape(const SYMBOL_GRAPHIC &aGraphic)
Create a SCH_SHAPE from a PADS graphic element.
LIB_SYMBOL * GetOrCreateSymbol(const SYMBOL_DEF &aSymbolDef)
Get or create a symbol for the given definition.
LIB_SYMBOL * GetOrCreateConnectorPinSymbol(const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef, const std::string &aPinNumber)
Get or create a single-pin connector symbol with a specific pin number.
LIB_SYMBOL * GetOrCreateMultiUnitConnectorSymbol(const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef, const std::vector< std::string > &aPinNumbers, const std::string &aCacheKey)
Get or create a multi-unit connector symbol, cached by base reference.
LIB_SYMBOL * BuildMultiUnitConnectorSymbol(const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef, const std::vector< std::string > &aPinNumbers)
Build a multi-unit connector symbol where each unit represents one pin.
std::map< std::string, std::unique_ptr< LIB_SYMBOL > > m_symbolCache
LIB_SYMBOL * BuildSymbol(const SYMBOL_DEF &aSymbolDef)
Build a KiCad LIB_SYMBOL from a PADS symbol definition.
LIB_SYMBOL * GetOrCreatePartTypeSymbol(const PARTTYPE_DEF &aPartType, const SYMBOL_DEF &aSymbolDef)
Get or create a single-gate symbol with PARTTYPE-specific pin remapping.
Holds all the data relating to one schematic.
Definition schematic.h:88
General schematic parameters from SCH and FIELDS sections.
Part type definition from PARTTYPE section.
Symbol definition from CAEDECAL section.
Graphic primitive from CAEDECAL or LINES sections (OPEN, CLOSED, CIRCLE, COPCLS).
Pin T/P line pair from CAEDECAL.