KiCad PCB EDA Suite
Loading...
Searching...
No Matches
altium_project_variants.cpp File Reference
#include <io/altium/altium_project_variants.h>
#include <boost/uuid/name_generator_sha1.hpp>
#include <boost/uuid/string_generator.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <project.h>
#include <set>
#include <wx/fileconf.h>
#include <wx/filename.h>
#include <wx/log.h>

Go to the source code of this file.

Functions

static wxString absoluteProjectPath (const wxString &aPrjPcbPath)
 wxFileConfig resolves a relative local filename against the user's home directory rather than the working directory, and reports nothing when the result does not exist, so a .PrjPcb named relatively on a command line would parse as an empty file.
 
KIID AltiumUniqueIdToKiid (const wxString &aUniqueId)
 Derive a stable KIID from an Altium component unique id.
 
ALTIUM_VARIANT_ENTRY ParseVariationString (const wxString &aValue)
 Parse a single pipe-delimited Altium "Variation" string into its component entry.
 
std::map< wxString, wxString > ParseAltiumProjectParameters (const wxString &aPrjPcbPath)
 Parse all [ParameterN] sections from an Altium .PrjPcb project file.
 
bool AltiumPowerPortNamesTakePriority (const wxString &aPrjPcbPath)
 Read the project's Power Port Names Take Priority netlist option.
 
void ApplyAltiumProjectParametersToProject (PROJECT *aProject, const std::map< wxString, wxString > &aParameters)
 Register Altium project parameters as KiCad project text variables so that imported board text referencing special strings (e.g.
 
std::vector< ALTIUM_PROJECT_VARIANT > ParseAltiumProjectVariants (const wxString &aPrjPcbPath)
 Parse all [ProjectVariantN] sections from an Altium .PrjPcb project file.
 

Function Documentation

◆ absoluteProjectPath()

static wxString absoluteProjectPath ( const wxString & aPrjPcbPath)
static

wxFileConfig resolves a relative local filename against the user's home directory rather than the working directory, and reports nothing when the result does not exist, so a .PrjPcb named relatively on a command line would parse as an empty file.

Definition at line 38 of file altium_project_variants.cpp.

Referenced by AltiumPowerPortNamesTakePriority(), ParseAltiumProjectParameters(), and ParseAltiumProjectVariants().

◆ AltiumPowerPortNamesTakePriority()

bool AltiumPowerPortNamesTakePriority ( const wxString & aPrjPcbPath)

Read the project's Power Port Names Take Priority netlist option.

Off, Altium's default, a net label names a net ahead of a power port on it.

Parameters
aPrjPcbPathFull path to the .PrjPcb file.

Definition at line 164 of file altium_project_variants.cpp.

References absoluteProjectPath(), and config.

Referenced by SCH_IO_ALTIUM::LoadSchematicFile().

◆ AltiumUniqueIdToKiid()

KIID AltiumUniqueIdToKiid ( const wxString & aUniqueId)

Derive a stable KIID from an Altium component unique id.

Altium unique ids are not hexadecimal, so KIID's string constructor cannot parse them and returns a fresh random uuid each call. This maps equal id strings to equal KIIDs.

Parameters
aUniqueIdAltium component unique id.
Returns
A KIID that is identical for identical input strings.

Definition at line 47 of file altium_project_variants.cpp.

Referenced by ApplyAltiumProjectVariantsToBoard(), and ALTIUM_PCB::ParseComponents6Data().

◆ ApplyAltiumProjectParametersToProject()

void ApplyAltiumProjectParametersToProject ( PROJECT * aProject,
const std::map< wxString, wxString > & aParameters )

Register Altium project parameters as KiCad project text variables so that imported board text referencing special strings (e.g.

".PCB_Revision") resolves to its value.

Existing project variables are not overwritten, and names that collide with KiCad's reserved or contextually resolved variables are skipped to preserve native resolution.

Definition at line 173 of file altium_project_variants.cpp.

References PROJECT::GetTextVars(), PROJECT::IncrementTextVarsTicker(), and name.

Referenced by LoadAltiumBoard(), and SCH_IO_ALTIUM::LoadSchematicFile().

◆ ParseAltiumProjectParameters()

std::map< wxString, wxString > ParseAltiumProjectParameters ( const wxString & aPrjPcbPath)

Parse all [ParameterN] sections from an Altium .PrjPcb project file.

Altium stores project-wide special strings (PCB_Revision, Company_Name, ...) here as Name/Value pairs. They are what board text such as ".PCB_Revision" resolves against, so they map to KiCad project text variables.

Parameters
aPrjPcbPathFull path to the .PrjPcb file.
Returns
Map of upper-cased parameter name to value, matching the case-insensitive variable references emitted by AltiumPcbSpecialStringsToKiCadStrings.

Definition at line 121 of file altium_project_variants.cpp.

References absoluteProjectPath(), config, and name.

Referenced by BOOST_AUTO_TEST_CASE(), LoadAltiumBoard(), and SCH_IO_ALTIUM::LoadSchematicFile().

◆ ParseAltiumProjectVariants()

std::vector< ALTIUM_PROJECT_VARIANT > ParseAltiumProjectVariants ( const wxString & aPrjPcbPath)

Parse all [ProjectVariantN] sections from an Altium .PrjPcb project file.

Parameters
aPrjPcbPathFull path to the .PrjPcb file.
Returns
Vector of project variants with their per-component entries.

Definition at line 217 of file altium_project_variants.cpp.

References absoluteProjectPath(), config, ALTIUM_PROJECT_VARIANT::description, ALTIUM_VARIANT_ENTRY::designator, ALTIUM_PROJECT_VARIANT::name, ParseVariationString(), and ALTIUM_PROJECT_VARIANT::variations.

Referenced by LoadAltiumBoard(), and SCH_IO_ALTIUM::LoadSchematicFile().

◆ ParseVariationString()

ALTIUM_VARIANT_ENTRY ParseVariationString ( const wxString & aValue)

Parse a single pipe-delimited Altium "Variation" string into its component entry.

Exposed for unit testing; consumers normally obtain entries via ParseAltiumProjectVariants().

Definition at line 61 of file altium_project_variants.cpp.

References ALTIUM_VARIANT_ENTRY::alternateFields, ALTIUM_VARIANT_ENTRY::designator, ALTIUM_VARIANT_ENTRY::kind, and ALTIUM_VARIANT_ENTRY::uniqueId.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and ParseAltiumProjectVariants().