mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 19:43:44 +00:00
Correct ODB++ attribute output
System attributes should be prefixed by the . while user-defined attributes can be freeform ASCII Adds DNP & Component Type for footprints to ODB++ export
This commit is contained in:
parent
b933d3228f
commit
1259e6057a
pcbnew/pcb_io/odbpp
@ -58,7 +58,7 @@ void ATTR_RECORD_WRITER::WriteAttributes( std::ostream& ost ) const
|
||||
{
|
||||
ODB::CHECK_ONCE once;
|
||||
|
||||
for( const auto& attr : attributes )
|
||||
for( const auto& attr : m_ODBattributes )
|
||||
{
|
||||
if( once() )
|
||||
ost << ";";
|
||||
|
@ -197,6 +197,12 @@ struct IsSymbol : std::false_type
|
||||
{ \
|
||||
};
|
||||
|
||||
#define USED_BY_CMP_ENTITY( NAME ) \
|
||||
template <> \
|
||||
struct IsComp<NAME> : std::true_type \
|
||||
{ \
|
||||
};
|
||||
|
||||
// Attribute definitions
|
||||
// BOOLEAN ATTRIBUTES
|
||||
DEFINE_BOOLEAN_ATTR( SMD )
|
||||
@ -276,6 +282,18 @@ enum class VIA_TYPE
|
||||
DEFINE_OPTION_ATTR( VIA_TYPE )
|
||||
USED_BY_FEATURE_ENTITY( VIA_TYPE )
|
||||
|
||||
enum class COMP_MOUNT_TYPE
|
||||
{
|
||||
OTHER,
|
||||
SMD,
|
||||
THT,
|
||||
PRESSFIT
|
||||
};
|
||||
DEFINE_OPTION_ATTR( COMP_MOUNT_TYPE )
|
||||
USED_BY_CMP_ENTITY( COMP_MOUNT_TYPE )
|
||||
|
||||
DEFINE_BOOLEAN_ATTR( NO_POP )
|
||||
USED_BY_CMP_ENTITY( NO_POP )
|
||||
} // namespace ODB_ATTR
|
||||
|
||||
|
||||
@ -286,14 +304,26 @@ public:
|
||||
virtual ~ATTR_MANAGER() = default;
|
||||
|
||||
template <typename Tr, typename Ta>
|
||||
void AddFeatureAttribute( Tr& r, Ta v )
|
||||
void AddSystemAttribute( Tr& r, Ta v )
|
||||
{
|
||||
std::string name = std::string( "." ) + std::string( ODB_ATTR::AttributeName<Ta>::name );
|
||||
const auto id = GetAttrNameNumber( name );
|
||||
|
||||
if constexpr( std::is_enum_v<Ta> )
|
||||
r.m_ODBattributes.emplace( id, std::to_string( static_cast<int>( v ) ) );
|
||||
else
|
||||
r.m_ODBattributes.emplace( id, AttrValue2String( v ) );
|
||||
}
|
||||
|
||||
template <typename Tr, typename Ta>
|
||||
void AddUserDefAttribute( Tr& r, Ta v )
|
||||
{
|
||||
const auto id = GetAttrNameNumber( ODB_ATTR::AttributeName<Ta>::name );
|
||||
|
||||
if constexpr( std::is_enum_v<Ta> )
|
||||
r.attributes.emplace( id, std::to_string( static_cast<int>( v ) ) );
|
||||
r.m_ODBattributes.emplace( id, std::to_string( static_cast<int>( v ) ) );
|
||||
else
|
||||
r.attributes.emplace( id, AttrValue2String( v ) );
|
||||
r.m_ODBattributes.emplace( id, AttrValue2String( v ) );
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -345,7 +375,7 @@ public:
|
||||
void WriteAttributes( std::ostream& ost ) const;
|
||||
|
||||
public:
|
||||
std::map<unsigned int, std::string> attributes;
|
||||
std::map<unsigned int, std::string> m_ODBattributes;
|
||||
};
|
||||
|
||||
|
||||
|
@ -71,6 +71,24 @@ ODB_COMPONENT& COMPONENTS_MANAGER::AddComponent( const FOOTPRINT* aFp,
|
||||
comp.m_prp[key] = wxString::Format( "'%s'", field->GetText() );
|
||||
}
|
||||
|
||||
if( aFp->IsDNP() )
|
||||
{
|
||||
AddSystemAttribute( comp, ODB_ATTR::NO_POP{ true } );
|
||||
}
|
||||
|
||||
if( aFp->GetAttributes() & FP_SMD )
|
||||
{
|
||||
AddSystemAttribute( comp, ODB_ATTR::COMP_MOUNT_TYPE::SMD );
|
||||
}
|
||||
else if( aFp->GetAttributes() & FP_THROUGH_HOLE )
|
||||
{
|
||||
AddSystemAttribute( comp, ODB_ATTR::COMP_MOUNT_TYPE::THT );
|
||||
}
|
||||
else
|
||||
{
|
||||
AddSystemAttribute( comp, ODB_ATTR::COMP_MOUNT_TYPE::OTHER );
|
||||
}
|
||||
|
||||
return comp;
|
||||
}
|
||||
|
||||
|
@ -424,8 +424,8 @@ void FEATURES_MANAGER::InitFeatureList( PCB_LAYER_ID aLayer, std::vector<BOARD_I
|
||||
|
||||
if( !m_featuresList.empty() )
|
||||
{
|
||||
AddFeatureAttribute( *m_featuresList.back(), ODB_ATTR::PAD_USAGE::VIA );
|
||||
AddFeatureAttribute(
|
||||
AddSystemAttribute( *m_featuresList.back(), ODB_ATTR::PAD_USAGE::VIA );
|
||||
AddSystemAttribute(
|
||||
*m_featuresList.back(),
|
||||
ODB_ATTR::GEOMETRY{ "VIA_RoundD"
|
||||
+ std::to_string( via->GetWidth( aLayer ) ) } );
|
||||
@ -442,12 +442,12 @@ void FEATURES_MANAGER::InitFeatureList( PCB_LAYER_ID aLayer, std::vector<BOARD_I
|
||||
m_featuresList.size() - 1 );
|
||||
|
||||
// TODO: confirm TOOLING_HOLE
|
||||
// AddFeatureAttribute( *m_featuresList.back(), ODB_ATTR::PAD_USAGE::TOOLING_HOLE );
|
||||
// AddSystemAttribute( *m_featuresList.back(), ODB_ATTR::PAD_USAGE::TOOLING_HOLE );
|
||||
|
||||
if( !m_featuresList.empty() )
|
||||
{
|
||||
AddFeatureAttribute( *m_featuresList.back(), ODB_ATTR::DRILL::VIA );
|
||||
AddFeatureAttribute(
|
||||
AddSystemAttribute( *m_featuresList.back(), ODB_ATTR::DRILL::VIA );
|
||||
AddSystemAttribute(
|
||||
*m_featuresList.back(),
|
||||
ODB_ATTR::GEOMETRY{ "VIA_RoundD"
|
||||
+ std::to_string( via->GetWidth( aLayer ) ) } );
|
||||
@ -477,7 +477,7 @@ void FEATURES_MANAGER::InitFeatureList( PCB_LAYER_ID aLayer, std::vector<BOARD_I
|
||||
m_featuresList.size() - 1 );
|
||||
|
||||
if( zone->IsTeardropArea() && !m_featuresList.empty() )
|
||||
AddFeatureAttribute( *m_featuresList.back(), ODB_ATTR::TEAR_DROP{ true } );
|
||||
AddSystemAttribute( *m_featuresList.back(), ODB_ATTR::TEAR_DROP{ true } );
|
||||
}
|
||||
};
|
||||
|
||||
@ -529,7 +529,7 @@ void FEATURES_MANAGER::InitFeatureList( PCB_LAYER_ID aLayer, std::vector<BOARD_I
|
||||
shape.SetWidth( attributes.m_StrokeWidth );
|
||||
|
||||
AddShape( shape );
|
||||
AddFeatureAttribute( *m_featuresList.back(),
|
||||
AddSystemAttribute( *m_featuresList.back(),
|
||||
ODB_ATTR::STRING{ aTextString.ToStdString() } );
|
||||
}
|
||||
else
|
||||
@ -543,7 +543,7 @@ void FEATURES_MANAGER::InitFeatureList( PCB_LAYER_ID aLayer, std::vector<BOARD_I
|
||||
shape.SetWidth( attributes.m_StrokeWidth );
|
||||
AddShape( shape );
|
||||
if( !m_featuresList.empty() )
|
||||
AddFeatureAttribute( *m_featuresList.back(),
|
||||
AddSystemAttribute( *m_featuresList.back(),
|
||||
ODB_ATTR::STRING{ aTextString.ToStdString() } );
|
||||
}
|
||||
}
|
||||
@ -593,7 +593,7 @@ void FEATURES_MANAGER::InitFeatureList( PCB_LAYER_ID aLayer, std::vector<BOARD_I
|
||||
AddContour( poly_set, ii, FILL_T::FILLED_SHAPE );
|
||||
|
||||
if( !m_featuresList.empty() )
|
||||
AddFeatureAttribute(
|
||||
AddSystemAttribute(
|
||||
*m_featuresList.back(),
|
||||
ODB_ATTR::STRING{ aTextString.ToStdString() } );
|
||||
}
|
||||
@ -650,7 +650,7 @@ void FEATURES_MANAGER::InitFeatureList( PCB_LAYER_ID aLayer, std::vector<BOARD_I
|
||||
AddContour( finalpolyset, ii, FILL_T::FILLED_SHAPE );
|
||||
|
||||
if( !m_featuresList.empty() )
|
||||
AddFeatureAttribute( *m_featuresList.back(),
|
||||
AddSystemAttribute( *m_featuresList.back(),
|
||||
ODB_ATTR::STRING{ shownText.ToStdString() } );
|
||||
}
|
||||
}
|
||||
@ -701,10 +701,10 @@ void FEATURES_MANAGER::InitFeatureList( PCB_LAYER_ID aLayer, std::vector<BOARD_I
|
||||
iter->second->AddFeatureID( EDA_DATA::FEATURE_ID::TYPE::COPPER, m_layerName,
|
||||
m_featuresList.size() - 1 );
|
||||
if( !m_featuresList.empty() )
|
||||
AddFeatureAttribute( *m_featuresList.back(), ODB_ATTR::PAD_USAGE::TOEPRINT );
|
||||
AddSystemAttribute( *m_featuresList.back(), ODB_ATTR::PAD_USAGE::TOEPRINT );
|
||||
|
||||
if( !pad->HasHole() && !m_featuresList.empty() )
|
||||
AddFeatureAttribute( *m_featuresList.back(), ODB_ATTR::SMD{ true } );
|
||||
AddSystemAttribute( *m_featuresList.back(), ODB_ATTR::SMD{ true } );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -733,16 +733,16 @@ void FEATURES_MANAGER::InitFeatureList( PCB_LAYER_ID aLayer, std::vector<BOARD_I
|
||||
m_featuresList.size() - 1 );
|
||||
|
||||
if( !m_featuresList.empty() )
|
||||
AddFeatureAttribute( *m_featuresList.back(), ODB_ATTR::DRILL::PLATED );
|
||||
AddSystemAttribute( *m_featuresList.back(), ODB_ATTR::DRILL::PLATED );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !m_featuresList.empty() )
|
||||
AddFeatureAttribute( *m_featuresList.back(), ODB_ATTR::DRILL::NON_PLATED );
|
||||
AddSystemAttribute( *m_featuresList.back(), ODB_ATTR::DRILL::NON_PLATED );
|
||||
}
|
||||
}
|
||||
}
|
||||
// AddFeatureAttribute( *m_featuresList.back(),
|
||||
// AddSystemAttribute( *m_featuresList.back(),
|
||||
// ODB_ATTR::GEOMETRY{ "PAD_xxxx" } );
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user