CADSTAR PCB Archive Importer: Correctly load the pad numbers as per the original design
To load the pad numbers correctly we need to also check the PART DEFINITION for each component
This commit is contained in:
parent
5db78a3d53
commit
f2ba9f7ac3
|
@ -884,9 +884,17 @@ public:
|
|||
};
|
||||
|
||||
PART_DEFINITION_PIN_ID ID;
|
||||
|
||||
wxString Identifier = wxEmptyString; ///< This should match a pad identifier
|
||||
///< in the component footprint
|
||||
///< subnode="PINIDENTIFIER". It is assumed
|
||||
///< that this could be empty in earlier
|
||||
///< versions of CADSTAR
|
||||
wxString Name = wxEmptyString; ///< Can be empty. If empty the pin name
|
||||
///< displayed wil be Identifier
|
||||
///< (subnode="PINNAME")
|
||||
///< This seems to be equivalent to "Pin
|
||||
///< Number" in KiCad.
|
||||
wxString Label = wxEmptyString; ///< This Can be empty (subnode=
|
||||
///< "PINLABEL")
|
||||
///< From CADSTAR Help: "Pin
|
||||
|
@ -900,6 +908,8 @@ public:
|
|||
///< correctly placed after any Gate and
|
||||
///< Pin Swaps are Back Annotated to the
|
||||
///< Schematic design."
|
||||
///< This seems to be equivalent to "Pin
|
||||
///< Name" in KiCad.
|
||||
wxString Signal = wxEmptyString; ///< Usually for Power/Ground pins,
|
||||
///< (subnode="PINSIGNAL")
|
||||
GATE_ID TerminalGate; ///< (subnode="PINTERM", param0)
|
||||
|
@ -914,11 +924,6 @@ public:
|
|||
///< the symbol is added to a schematic design
|
||||
///< subnode="PINPOSITION"
|
||||
|
||||
wxString Identifier =
|
||||
wxEmptyString; ///< This should match a pad identifier in the component
|
||||
///< footprint subnode="PINIDENTIFIER". It is assumed that
|
||||
///< this could be empty in earlier versions of CADSTAR
|
||||
|
||||
void Parse( XNODE* aNode );
|
||||
};
|
||||
|
||||
|
|
|
@ -774,13 +774,15 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef
|
|||
{
|
||||
PART::DEFINITION::PIN csPin = getPartDefinitionPin( *aCadstarPart, aGateID, term.ID );
|
||||
|
||||
pinName = csPin.Name;
|
||||
pinNum = wxString::Format( "%ld", csPin.ID );
|
||||
pinName = csPin.Label;
|
||||
pinNum = csPin.Name;
|
||||
|
||||
if( pinName.IsEmpty() )
|
||||
if( pinNum.IsEmpty() )
|
||||
{
|
||||
if( !csPin.Identifier.IsEmpty() )
|
||||
pinName = csPin.Identifier;
|
||||
pinNum = csPin.Identifier;
|
||||
else
|
||||
pinNum = wxString::Format( "%ld", csPin.ID );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -279,9 +279,12 @@ public:
|
|||
VARIANT_ID VariantID = wxEmptyString;
|
||||
|
||||
std::map<TERMINAL_ID, TERMATTR> TerminalAttributes;
|
||||
std::map<TERMINAL_ID, SYMPINNAME_LABEL> PinLabels;
|
||||
std::map<TERMINAL_ID, SYMPINNAME_LABEL> PinNames;
|
||||
std::map<TERMINAL_ID, PIN_NUM> PinNumbers;
|
||||
std::map<TERMINAL_ID, SYMPINNAME_LABEL> PinLabels; ///< Equivalent to KiCad's Pin Name
|
||||
std::map<TERMINAL_ID, SYMPINNAME_LABEL> PinNames; ///< Identifier of the pin in the PCB
|
||||
///< Equivalent to KiCad's Pin Number
|
||||
std::map<TERMINAL_ID, PIN_NUM> PinNumbers; ///< This seems to only appear in older
|
||||
///< designs and is similar to PinNames
|
||||
///< but only allowing numerical values
|
||||
std::map<ATTRIBUTE_ID, ATTRIBUTE_VALUE> AttributeValues;
|
||||
|
||||
void Parse( XNODE* aNode );
|
||||
|
|
|
@ -1192,7 +1192,7 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponents()
|
|||
{
|
||||
for( std::pair<COMPONENT_ID, COMPONENT> compPair : Layout.Components )
|
||||
{
|
||||
COMPONENT& comp = compPair.second;
|
||||
COMPONENT& comp = compPair.second;
|
||||
|
||||
auto fpIter = mLibraryMap.find( comp.SymdefID );
|
||||
|
||||
|
@ -1203,12 +1203,43 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponents()
|
|||
comp.Name, comp.SymdefID ) );
|
||||
}
|
||||
|
||||
FOOTPRINT* libFootprint = fpIter->second;
|
||||
|
||||
// copy constructor to clone the footprint from the library
|
||||
FOOTPRINT* footprint = new FOOTPRINT( *fpIter->second );
|
||||
FOOTPRINT* footprint = new FOOTPRINT( *libFootprint );
|
||||
const_cast<KIID&>( footprint->m_Uuid ) = KIID();
|
||||
|
||||
mBoard->Add( footprint, ADD_MODE::APPEND );
|
||||
|
||||
// First lets fix the pad names on the footprint.
|
||||
// CADSTAR defines the pad name in the PART definition and the SYMDEF (i.e. the PCB
|
||||
// footprint definition) uses a numerical sequence. COMP is the only object that has
|
||||
// visibility of both the SYMDEF and PART.
|
||||
if( Parts.PartDefinitions.find( comp.PartID ) != Parts.PartDefinitions.end() )
|
||||
{
|
||||
PART part = Parts.PartDefinitions.at( comp.PartID );
|
||||
|
||||
// Only do this when the number of pins in the part definition equals the number of
|
||||
// pads in the footprint.
|
||||
if( part.Definition.Pins.size() == footprint->Pads().size() )
|
||||
{
|
||||
for( std::pair<PART_DEFINITION_PIN_ID, PART::DEFINITION::PIN> pinPair :
|
||||
part.Definition.Pins )
|
||||
{
|
||||
PART::DEFINITION::PIN pin = pinPair.second;
|
||||
wxString pinName = pin.Name;
|
||||
|
||||
if( pinName.empty() )
|
||||
pinName = pin.Identifier;
|
||||
|
||||
if( pinName.empty() )
|
||||
pinName = wxString::Format( wxT( "%ld" ), pin.ID );
|
||||
|
||||
footprint->Pads().at( pin.ID - (long long) 1 )->SetName( pinName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Override pads with pad exceptions
|
||||
if( comp.PadExceptions.size() > 0 )
|
||||
{
|
||||
|
@ -1232,12 +1263,15 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponents()
|
|||
csPad.Side = padEx.Side;
|
||||
|
||||
// Find the pad in the footprint definition
|
||||
PAD* kiPad = footprint->Pads().at( padEx.ID - (long) 1 );
|
||||
PAD* kiPad = footprint->Pads().at( padEx.ID - (long long) 1 );
|
||||
wxString padName = kiPad->GetName();
|
||||
|
||||
if( kiPad )
|
||||
delete kiPad;
|
||||
|
||||
footprint->Pads().at( padEx.ID - (long) 1 ) = getKiCadPad( csPad, footprint );
|
||||
kiPad = getKiCadPad( csPad, footprint );
|
||||
kiPad->SetName( padName );
|
||||
footprint->Pads().at( padEx.ID - (long long) 1 ) = kiPad;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue