|
|
|
@ -63,7 +63,40 @@ std::string toUTFTildaText( const wxString& txt ) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SCH_SYMBOL::SCH_SYMBOL() : SCH_SYMBOL( *LIB_SYMBOL::Dummy(), LIB_ID(), nullptr, 0 ) { } |
|
|
|
/**
|
|
|
|
* Used to draw a dummy shape when a LIB_SYMBOL is not found in library |
|
|
|
* |
|
|
|
* This symbol is a 400 mils square with the text "??" |
|
|
|
*/ |
|
|
|
static LIB_SYMBOL* dummy() |
|
|
|
{ |
|
|
|
static LIB_SYMBOL* symbol; |
|
|
|
|
|
|
|
if( !symbol ) |
|
|
|
{ |
|
|
|
symbol = new LIB_SYMBOL( wxEmptyString ); |
|
|
|
|
|
|
|
SCH_SHAPE* square = new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE ); |
|
|
|
|
|
|
|
square->SetPosition( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) ); |
|
|
|
square->SetEnd( VECTOR2I( schIUScale.MilsToIU( 200 ), schIUScale.MilsToIU( -200 ) ) ); |
|
|
|
symbol->AddDrawItem( square ); |
|
|
|
|
|
|
|
SCH_TEXT* text = new SCH_TEXT( { 0, 0 }, wxT( "??"), LAYER_DEVICE ); |
|
|
|
|
|
|
|
text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) ); |
|
|
|
symbol->AddDrawItem( text ); |
|
|
|
} |
|
|
|
|
|
|
|
return symbol; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SCH_SYMBOL::SCH_SYMBOL() : |
|
|
|
SYMBOL( nullptr, SCH_SYMBOL_T ) |
|
|
|
{ |
|
|
|
Init( VECTOR2I( 0, 0 ) ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SCH_SYMBOL::SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId, |
|
|
|
@ -71,13 +104,17 @@ SCH_SYMBOL::SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId, |
|
|
|
const VECTOR2I& aPosition, EDA_ITEM* aParent ) : |
|
|
|
SYMBOL( aParent, SCH_SYMBOL_T ) |
|
|
|
{ |
|
|
|
SetLibSymbol( &aSymbol ); |
|
|
|
Init( aPosition ); |
|
|
|
|
|
|
|
m_unit = aUnit; |
|
|
|
m_bodyStyle = aBodyStyle; |
|
|
|
m_lib_id = aLibId; |
|
|
|
|
|
|
|
std::unique_ptr< LIB_SYMBOL > part; |
|
|
|
|
|
|
|
part = aSymbol.Flatten(); |
|
|
|
part->SetParent(); |
|
|
|
SetLibSymbol( part.release() ); |
|
|
|
|
|
|
|
// Copy fields from the library symbol
|
|
|
|
UpdateFields( aSheet, |
|
|
|
@ -118,8 +155,6 @@ SCH_SYMBOL::SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const SCH_SHEET_PATH* aSheet, |
|
|
|
SCH_SYMBOL::SCH_SYMBOL( const SCH_SYMBOL& aSymbol ) : |
|
|
|
SYMBOL( aSymbol ) |
|
|
|
{ |
|
|
|
SetLibSymbol( &aSymbol.GetLibSymbolRef() ); |
|
|
|
|
|
|
|
m_parent = aSymbol.m_parent; |
|
|
|
m_pos = aSymbol.m_pos; |
|
|
|
m_unit = aSymbol.m_unit; |
|
|
|
@ -148,6 +183,9 @@ SCH_SYMBOL::SCH_SYMBOL( const SCH_SYMBOL& aSymbol ) : |
|
|
|
m_pins.back()->SetParent( this ); |
|
|
|
} |
|
|
|
|
|
|
|
if( aSymbol.m_part ) |
|
|
|
SetLibSymbol( new LIB_SYMBOL( *aSymbol.m_part ) ); |
|
|
|
|
|
|
|
m_fieldsAutoplaced = aSymbol.m_fieldsAutoplaced; |
|
|
|
m_schLibSymbolName = aSymbol.m_schLibSymbolName; |
|
|
|
} |
|
|
|
@ -192,6 +230,12 @@ EDA_ITEM* SCH_SYMBOL::Clone() const |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool SCH_SYMBOL::IsMissingLibSymbol() const |
|
|
|
{ |
|
|
|
return m_part == nullptr; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool SCH_SYMBOL::IsMovableFromAnchorPoint() const |
|
|
|
{ |
|
|
|
// If a symbol's anchor is not grid-aligned to its pins then moving from the anchor is
|
|
|
|
@ -228,31 +272,39 @@ wxString SCH_SYMBOL::GetSchSymbolLibraryName() const |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SCH_SYMBOL::SetLibSymbol( const LIB_SYMBOL* aLibSymbol ) |
|
|
|
void SCH_SYMBOL::SetLibSymbol( LIB_SYMBOL* aLibSymbol ) |
|
|
|
{ |
|
|
|
wxASSERT_MSG( aLibSymbol, wxT( "SCH_SYMBOL::SetLibSymbol() called with NULL pointer" ) ); |
|
|
|
wxCHECK2( !aLibSymbol || aLibSymbol->IsRoot(), aLibSymbol = nullptr ); |
|
|
|
|
|
|
|
m_part.reset( aLibSymbol->Flatten().release() ); |
|
|
|
m_part->SetParent(); |
|
|
|
m_part.reset( aLibSymbol ); |
|
|
|
UpdatePins(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
wxString SCH_SYMBOL::GetDescription() const |
|
|
|
{ |
|
|
|
return m_part->GetDescription(); |
|
|
|
if( m_part ) |
|
|
|
return m_part->GetDescription(); |
|
|
|
|
|
|
|
return wxEmptyString; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
wxString SCH_SYMBOL::GetKeyWords() const |
|
|
|
{ |
|
|
|
return m_part->GetKeyWords(); |
|
|
|
if( m_part ) |
|
|
|
return m_part->GetKeyWords(); |
|
|
|
|
|
|
|
return wxEmptyString; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
wxString SCH_SYMBOL::GetDatasheet() const |
|
|
|
{ |
|
|
|
return m_part->GetDatasheetField().GetText(); |
|
|
|
if( m_part ) |
|
|
|
return m_part->GetDatasheetField().GetText(); |
|
|
|
|
|
|
|
return wxEmptyString; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -277,6 +329,9 @@ void SCH_SYMBOL::UpdatePins() |
|
|
|
|
|
|
|
m_pinMap.clear(); |
|
|
|
|
|
|
|
if( !m_part ) |
|
|
|
return; |
|
|
|
|
|
|
|
for( SCH_PIN* libPin : m_part->GetAllLibPins() ) |
|
|
|
{ |
|
|
|
// NW: Don't filter by unit: this data-structure is used for all instances,
|
|
|
|
@ -380,7 +435,10 @@ void SCH_SYMBOL::SetBodyStyle( int aBodyStyle ) |
|
|
|
|
|
|
|
bool SCH_SYMBOL::HasAlternateBodyStyle() const |
|
|
|
{ |
|
|
|
return m_part->HasAlternateBodyStyle(); |
|
|
|
if( m_part ) |
|
|
|
return m_part->HasAlternateBodyStyle(); |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -392,18 +450,25 @@ void SCH_SYMBOL::SetTransform( const TRANSFORM& aTransform ) |
|
|
|
|
|
|
|
int SCH_SYMBOL::GetUnitCount() const |
|
|
|
{ |
|
|
|
return m_part->GetUnitCount(); |
|
|
|
if( m_part ) |
|
|
|
return m_part->GetUnitCount(); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
wxString SCH_SYMBOL::GetUnitDisplayName( int aUnit ) const |
|
|
|
{ |
|
|
|
wxCHECK( m_part, ( wxString::Format( _( "Unit %s" ), SubReference( aUnit ) ) ) ); |
|
|
|
|
|
|
|
return m_part->GetUnitDisplayName( aUnit ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool SCH_SYMBOL::HasUnitDisplayName( int aUnit ) const |
|
|
|
{ |
|
|
|
wxCHECK( m_part, false ); |
|
|
|
|
|
|
|
return m_part->HasUnitDisplayName( aUnit ); |
|
|
|
} |
|
|
|
|
|
|
|
@ -411,6 +476,8 @@ bool SCH_SYMBOL::HasUnitDisplayName( int aUnit ) const |
|
|
|
void SCH_SYMBOL::PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle, |
|
|
|
const VECTOR2I& aOffset, bool aDimmed ) |
|
|
|
{ |
|
|
|
wxCHECK( m_part, /* void */ ); |
|
|
|
|
|
|
|
SCH_RENDER_SETTINGS localRenderSettings( *aSettings ); |
|
|
|
localRenderSettings.m_Transform = m_transform; |
|
|
|
localRenderSettings.m_ShowVisibleFields = false; |
|
|
|
@ -434,34 +501,41 @@ void SCH_SYMBOL::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBo |
|
|
|
if( m_DNP ) |
|
|
|
aDimmed = true; |
|
|
|
|
|
|
|
std::vector<SCH_PIN*> libPins = m_part->GetPins( m_unit, m_bodyStyle ); |
|
|
|
LIB_SYMBOL tempSymbol( *m_part ); |
|
|
|
std::vector<SCH_PIN*> tempPins = tempSymbol.GetPins( m_unit, m_bodyStyle ); |
|
|
|
|
|
|
|
// Copy the pin info from the symbol to the temp pins
|
|
|
|
for( unsigned i = 0; i < tempPins.size(); ++ i ) |
|
|
|
if( m_part ) |
|
|
|
{ |
|
|
|
SCH_PIN* symbolPin = GetPin( libPins[ i ] ); |
|
|
|
SCH_PIN* tempPin = tempPins[ i ]; |
|
|
|
std::vector<SCH_PIN*> libPins = m_part->GetPins( m_unit, m_bodyStyle ); |
|
|
|
LIB_SYMBOL tempSymbol( *m_part ); |
|
|
|
std::vector<SCH_PIN*> tempPins = tempSymbol.GetPins( m_unit, m_bodyStyle ); |
|
|
|
|
|
|
|
tempPin->SetName( symbolPin->GetShownName() ); |
|
|
|
tempPin->SetType( symbolPin->GetType() ); |
|
|
|
tempPin->SetShape( symbolPin->GetShape() ); |
|
|
|
} |
|
|
|
// Copy the pin info from the symbol to the temp pins
|
|
|
|
for( unsigned i = 0; i < tempPins.size(); ++ i ) |
|
|
|
{ |
|
|
|
SCH_PIN* symbolPin = GetPin( libPins[ i ] ); |
|
|
|
SCH_PIN* tempPin = tempPins[ i ]; |
|
|
|
|
|
|
|
for( SCH_ITEM& item : tempSymbol.GetDrawItems() ) |
|
|
|
{ |
|
|
|
if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( &item ) ) |
|
|
|
tempPin->SetName( symbolPin->GetShownName() ); |
|
|
|
tempPin->SetType( symbolPin->GetType() ); |
|
|
|
tempPin->SetShape( symbolPin->GetShape() ); |
|
|
|
} |
|
|
|
|
|
|
|
for( SCH_ITEM& item : tempSymbol.GetDrawItems() ) |
|
|
|
{ |
|
|
|
// Use SCH_FIELD's text resolver
|
|
|
|
SCH_FIELD dummy( this, -1 ); |
|
|
|
dummy.SetText( text->GetText() ); |
|
|
|
text->SetText( dummy.GetShownText( false ) ); |
|
|
|
if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( &item ) ) |
|
|
|
{ |
|
|
|
// Use SCH_FIELD's text resolver
|
|
|
|
SCH_FIELD dummy( this, -1 ); |
|
|
|
dummy.SetText( text->GetText() ); |
|
|
|
text->SetText( dummy.GetShownText( false ) ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
tempSymbol.Print( &localRenderSettings, m_unit, m_bodyStyle, m_pos + aOffset, false, |
|
|
|
aDimmed ); |
|
|
|
tempSymbol.Print( &localRenderSettings, m_unit, m_bodyStyle, m_pos + aOffset, false, |
|
|
|
aDimmed ); |
|
|
|
} |
|
|
|
else // Use dummy() part if the actual cannot be found.
|
|
|
|
{ |
|
|
|
dummy()->Print( &localRenderSettings, 0, 0, m_pos + aOffset, aForceNoFill, aDimmed ); |
|
|
|
} |
|
|
|
|
|
|
|
for( SCH_FIELD& field : m_fields ) |
|
|
|
field.Print( &localRenderSettings, m_unit, m_bodyStyle, aOffset, aForceNoFill, aDimmed ); |
|
|
|
@ -951,63 +1025,66 @@ SCH_FIELD* SCH_SYMBOL::FindField( const wxString& aFieldName, bool aIncludeDefau |
|
|
|
void SCH_SYMBOL::UpdateFields( const SCH_SHEET_PATH* aPath, bool aUpdateStyle, bool aUpdateRef, |
|
|
|
bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields ) |
|
|
|
{ |
|
|
|
std::vector<SCH_FIELD*> fields; |
|
|
|
m_part->GetFields( fields ); |
|
|
|
|
|
|
|
for( const SCH_FIELD* libField : fields ) |
|
|
|
if( m_part ) |
|
|
|
{ |
|
|
|
int id = libField->GetId(); |
|
|
|
SCH_FIELD* schField; |
|
|
|
std::vector<SCH_FIELD*> fields; |
|
|
|
m_part->GetFields( fields ); |
|
|
|
|
|
|
|
if( libField->IsMandatory() ) |
|
|
|
for( const SCH_FIELD* libField : fields ) |
|
|
|
{ |
|
|
|
schField = GetFieldById( id ); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
schField = FindField( libField->GetCanonicalName() ); |
|
|
|
int id = libField->GetId(); |
|
|
|
SCH_FIELD* schField; |
|
|
|
|
|
|
|
if( !schField ) |
|
|
|
if( libField->IsMandatory() ) |
|
|
|
{ |
|
|
|
wxString fieldName = libField->GetCanonicalName(); |
|
|
|
SCH_FIELD newField( VECTOR2I( 0, 0 ), GetFieldCount(), this, fieldName ); |
|
|
|
schField = AddField( newField ); |
|
|
|
schField = GetFieldById( id ); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
schField = FindField( libField->GetCanonicalName() ); |
|
|
|
|
|
|
|
if( aUpdateStyle ) |
|
|
|
{ |
|
|
|
schField->ImportValues( *libField ); |
|
|
|
schField->SetTextPos( m_pos + libField->GetTextPos() ); |
|
|
|
} |
|
|
|
if( !schField ) |
|
|
|
{ |
|
|
|
wxString fieldName = libField->GetCanonicalName(); |
|
|
|
SCH_FIELD newField( VECTOR2I( 0, 0 ), GetFieldCount(), this, fieldName ); |
|
|
|
schField = AddField( newField ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if( id == REFERENCE_FIELD && aPath ) |
|
|
|
{ |
|
|
|
if( aResetRef ) |
|
|
|
SetRef( aPath, m_part->GetReferenceField().GetText() ); |
|
|
|
else if( aUpdateRef ) |
|
|
|
SetRef( aPath, libField->GetText() ); |
|
|
|
} |
|
|
|
else if( id == VALUE_FIELD ) |
|
|
|
{ |
|
|
|
SetValueFieldText( UnescapeString( libField->GetText() ) ); |
|
|
|
} |
|
|
|
else if( id == FOOTPRINT_FIELD ) |
|
|
|
{ |
|
|
|
if( aResetOtherFields || aUpdateOtherFields ) |
|
|
|
SetFootprintFieldText( libField->GetText() ); |
|
|
|
} |
|
|
|
else if( id == DATASHEET_FIELD ) |
|
|
|
{ |
|
|
|
if( aResetOtherFields ) |
|
|
|
schField->SetText( GetDatasheet() ); // alias-specific value
|
|
|
|
else if( aUpdateOtherFields ) |
|
|
|
schField->SetText( libField->GetText() ); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if( aResetOtherFields || aUpdateOtherFields ) |
|
|
|
schField->SetText( libField->GetText() ); |
|
|
|
if( aUpdateStyle ) |
|
|
|
{ |
|
|
|
schField->ImportValues( *libField ); |
|
|
|
schField->SetTextPos( m_pos + libField->GetTextPos() ); |
|
|
|
} |
|
|
|
|
|
|
|
if( id == REFERENCE_FIELD && aPath ) |
|
|
|
{ |
|
|
|
if( aResetRef ) |
|
|
|
SetRef( aPath, m_part->GetReferenceField().GetText() ); |
|
|
|
else if( aUpdateRef ) |
|
|
|
SetRef( aPath, libField->GetText() ); |
|
|
|
} |
|
|
|
else if( id == VALUE_FIELD ) |
|
|
|
{ |
|
|
|
SetValueFieldText( UnescapeString( libField->GetText() ) ); |
|
|
|
} |
|
|
|
else if( id == FOOTPRINT_FIELD ) |
|
|
|
{ |
|
|
|
if( aResetOtherFields || aUpdateOtherFields ) |
|
|
|
SetFootprintFieldText( libField->GetText() ); |
|
|
|
} |
|
|
|
else if( id == DATASHEET_FIELD ) |
|
|
|
{ |
|
|
|
if( aResetOtherFields ) |
|
|
|
schField->SetText( GetDatasheet() ); // alias-specific value
|
|
|
|
else if( aUpdateOtherFields ) |
|
|
|
schField->SetText( libField->GetText() ); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if( aResetOtherFields || aUpdateOtherFields ) |
|
|
|
schField->SetText( libField->GetText() ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1060,13 +1137,19 @@ const SCH_PIN* SCH_SYMBOL::GetPin( const VECTOR2I& aPos ) const |
|
|
|
|
|
|
|
std::vector<SCH_PIN*> SCH_SYMBOL::GetLibPins() const |
|
|
|
{ |
|
|
|
return m_part->GetPins( m_unit, m_bodyStyle ); |
|
|
|
if( m_part ) |
|
|
|
return m_part->GetPins( m_unit, m_bodyStyle ); |
|
|
|
|
|
|
|
return std::vector<SCH_PIN*>(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::vector<SCH_PIN*> SCH_SYMBOL::GetAllLibPins() const |
|
|
|
{ |
|
|
|
return m_part->GetAllLibPins(); |
|
|
|
if( m_part ) |
|
|
|
return m_part->GetAllLibPins(); |
|
|
|
|
|
|
|
return std::vector<SCH_PIN*>(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1756,7 +1839,11 @@ BOX2I SCH_SYMBOL::doGetBoundingBox( bool aIncludePins, bool aIncludeFields ) con |
|
|
|
{ |
|
|
|
BOX2I bBox; |
|
|
|
|
|
|
|
bBox = m_part->GetBodyBoundingBox( m_unit, m_bodyStyle, aIncludePins, false ); |
|
|
|
if( m_part ) |
|
|
|
bBox = m_part->GetBodyBoundingBox( m_unit, m_bodyStyle, aIncludePins, false ); |
|
|
|
else |
|
|
|
bBox = dummy()->GetBodyBoundingBox( m_unit, m_bodyStyle, aIncludePins, false ); |
|
|
|
|
|
|
|
bBox = m_transform.TransformCoordinate( bBox ); |
|
|
|
bBox.Normalize(); |
|
|
|
|
|
|
|
@ -1834,64 +1921,87 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ |
|
|
|
aList.emplace_back( _( "Exclude from" ), msg ); |
|
|
|
}; |
|
|
|
|
|
|
|
if( !m_part->IsDummy() ) |
|
|
|
// part and alias can differ if alias is not the root
|
|
|
|
if( m_part ) |
|
|
|
{ |
|
|
|
if( m_part->IsPower() ) |
|
|
|
{ |
|
|
|
// Don't use GetShownText(); we want to see the variable references here
|
|
|
|
aList.emplace_back( _( "Power symbol" ), |
|
|
|
KIUI::EllipsizeStatusText( aFrame, GetField( VALUE_FIELD )->GetText() ) ); |
|
|
|
} |
|
|
|
else |
|
|
|
if( m_part.get() != dummy() ) |
|
|
|
{ |
|
|
|
aList.emplace_back( _( "Reference" ), |
|
|
|
UnescapeString( GetRef( currentSheet ) ) ); |
|
|
|
|
|
|
|
// Don't use GetShownText(); we want to see the variable references here
|
|
|
|
aList.emplace_back( _( "Value" ), |
|
|
|
KIUI::EllipsizeStatusText( aFrame, GetField( VALUE_FIELD )->GetText() ) ); |
|
|
|
addExcludes(); |
|
|
|
aList.emplace_back( _( "Name" ), |
|
|
|
KIUI::EllipsizeStatusText( aFrame, GetLibId().GetLibItemName() ) ); |
|
|
|
} |
|
|
|
if( m_part->IsPower() ) |
|
|
|
{ |
|
|
|
// Don't use GetShownText(); we want to see the variable references here
|
|
|
|
aList.emplace_back( _( "Power symbol" ), |
|
|
|
KIUI::EllipsizeStatusText( aFrame, GetField( VALUE_FIELD )->GetText() ) ); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
aList.emplace_back( _( "Reference" ), |
|
|
|
UnescapeString( GetRef( currentSheet ) ) ); |
|
|
|
|
|
|
|
// Don't use GetShownText(); we want to see the variable references here
|
|
|
|
aList.emplace_back( _( "Value" ), |
|
|
|
KIUI::EllipsizeStatusText( aFrame, GetField( VALUE_FIELD )->GetText() ) ); |
|
|
|
addExcludes(); |
|
|
|
aList.emplace_back( _( "Name" ), |
|
|
|
KIUI::EllipsizeStatusText( aFrame, GetLibId().GetLibItemName() ) ); |
|
|
|
} |
|
|
|
|
|
|
|
#if 0 // Display symbol flags, for debug only
|
|
|
|
aList.emplace_back( _( "flags" ), wxString::Format( "%X", GetEditFlags() ) ); |
|
|
|
aList.emplace_back( _( "flags" ), wxString::Format( "%X", GetEditFlags() ) ); |
|
|
|
#endif
|
|
|
|
|
|
|
|
if( !m_part->IsRoot() ) |
|
|
|
{ |
|
|
|
msg = _( "Missing parent" ); |
|
|
|
if( !m_part->IsRoot() ) |
|
|
|
{ |
|
|
|
msg = _( "Missing parent" ); |
|
|
|
|
|
|
|
std::shared_ptr< LIB_SYMBOL > parent = m_part->GetParent().lock(); |
|
|
|
std::shared_ptr< LIB_SYMBOL > parent = m_part->GetParent().lock(); |
|
|
|
|
|
|
|
if( parent ) |
|
|
|
msg = parent->GetName(); |
|
|
|
if( parent ) |
|
|
|
msg = parent->GetName(); |
|
|
|
|
|
|
|
aList.emplace_back( _( "Derived from" ), UnescapeString( msg ) ); |
|
|
|
} |
|
|
|
else if( !m_lib_id.GetLibNickname().empty() ) |
|
|
|
{ |
|
|
|
aList.emplace_back( _( "Library" ), m_lib_id.GetLibNickname() ); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
aList.emplace_back( _( "Library" ), _( "Undefined!!!" ) ); |
|
|
|
} |
|
|
|
aList.emplace_back( _( "Derived from" ), UnescapeString( msg ) ); |
|
|
|
} |
|
|
|
else if( !m_lib_id.GetLibNickname().empty() ) |
|
|
|
{ |
|
|
|
aList.emplace_back( _( "Library" ), m_lib_id.GetLibNickname() ); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
aList.emplace_back( _( "Library" ), _( "Undefined!!!" ) ); |
|
|
|
} |
|
|
|
|
|
|
|
// Display the current associated footprint, if exists.
|
|
|
|
// Display the current associated footprint, if exists.
|
|
|
|
// Don't use GetShownText(); we want to see the variable references here
|
|
|
|
msg = KIUI::EllipsizeStatusText( aFrame, GetField( FOOTPRINT_FIELD )->GetText() ); |
|
|
|
|
|
|
|
if( msg.IsEmpty() ) |
|
|
|
msg = _( "<Unknown>" ); |
|
|
|
|
|
|
|
aList.emplace_back( _( "Footprint" ), msg ); |
|
|
|
|
|
|
|
// Display description of the symbol, and keywords found in lib
|
|
|
|
aList.emplace_back( _( "Description" ) + wxT( ": " ) |
|
|
|
+ GetField( DESCRIPTION_FIELD )->GetText(), |
|
|
|
_( "Keywords" ) + wxT( ": " ) + m_part->GetKeyWords() ); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) ); |
|
|
|
// Don't use GetShownText(); we want to see the variable references here
|
|
|
|
msg = KIUI::EllipsizeStatusText( aFrame, GetField( FOOTPRINT_FIELD )->GetText() ); |
|
|
|
aList.emplace_back( _( "Value" ), |
|
|
|
KIUI::EllipsizeStatusText( aFrame, GetField( VALUE_FIELD )->GetText() ) ); |
|
|
|
addExcludes(); |
|
|
|
aList.emplace_back( _( "Name" ), |
|
|
|
KIUI::EllipsizeStatusText( aFrame, GetLibId().GetLibItemName() ) ); |
|
|
|
|
|
|
|
if( msg.IsEmpty() ) |
|
|
|
msg = _( "<Unknown>" ); |
|
|
|
wxString libNickname = GetLibId().GetLibNickname(); |
|
|
|
|
|
|
|
aList.emplace_back( _( "Footprint" ), msg ); |
|
|
|
if( libNickname.empty() ) |
|
|
|
msg = _( "No library defined!" ); |
|
|
|
else |
|
|
|
msg.Printf( _( "Symbol not found in %s!" ), libNickname ); |
|
|
|
|
|
|
|
// Display description of the symbol, and keywords found in lib
|
|
|
|
aList.emplace_back( _( "Description" ) + wxT( ": " ) |
|
|
|
+ GetField( DESCRIPTION_FIELD )->GetText(), |
|
|
|
_( "Keywords" ) + wxT( ": " ) + m_part->GetKeyWords() ); |
|
|
|
aList.emplace_back( _( "Library" ), msg ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -2111,10 +2221,15 @@ std::vector<VECTOR2I> SCH_SYMBOL::GetConnectionPoints() const |
|
|
|
|
|
|
|
SCH_ITEM* SCH_SYMBOL::GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType ) |
|
|
|
{ |
|
|
|
// Calculate the position relative to the symbol.
|
|
|
|
VECTOR2I libPosition = aPosition - m_pos; |
|
|
|
if( m_part ) |
|
|
|
{ |
|
|
|
// Calculate the position relative to the symbol.
|
|
|
|
VECTOR2I libPosition = aPosition - m_pos; |
|
|
|
|
|
|
|
return m_part->LocateDrawItem( m_unit, m_bodyStyle, aType, libPosition, m_transform ); |
|
|
|
} |
|
|
|
|
|
|
|
return m_part->LocateDrawItem( m_unit, m_bodyStyle, aType, libPosition, m_transform ); |
|
|
|
return nullptr; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -2345,91 +2460,94 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& |
|
|
|
if( aBackground ) |
|
|
|
return; |
|
|
|
|
|
|
|
std::vector<SCH_PIN*> libPins = m_part->GetPins( GetUnit(), GetBodyStyle() ); |
|
|
|
if( m_part ) |
|
|
|
{ |
|
|
|
std::vector<SCH_PIN*> libPins = m_part->GetPins( GetUnit(), GetBodyStyle() ); |
|
|
|
|
|
|
|
// Copy the source so we can re-orient and translate it.
|
|
|
|
LIB_SYMBOL tempSymbol( *m_part ); |
|
|
|
std::vector<SCH_PIN*> tempPins = tempSymbol.GetPins( GetUnit(), GetBodyStyle() ); |
|
|
|
// Copy the source so we can re-orient and translate it.
|
|
|
|
LIB_SYMBOL tempSymbol( *m_part ); |
|
|
|
std::vector<SCH_PIN*> tempPins = tempSymbol.GetPins( GetUnit(), GetBodyStyle() ); |
|
|
|
|
|
|
|
// Copy the pin info from the symbol to the temp pins
|
|
|
|
for( unsigned i = 0; i < tempPins.size(); ++ i ) |
|
|
|
{ |
|
|
|
SCH_PIN* symbolPin = GetPin( libPins[ i ] ); |
|
|
|
SCH_PIN* tempPin = tempPins[ i ]; |
|
|
|
// Copy the pin info from the symbol to the temp pins
|
|
|
|
for( unsigned i = 0; i < tempPins.size(); ++ i ) |
|
|
|
{ |
|
|
|
SCH_PIN* symbolPin = GetPin( libPins[ i ] ); |
|
|
|
SCH_PIN* tempPin = tempPins[ i ]; |
|
|
|
|
|
|
|
tempPin->SetName( symbolPin->GetShownName() ); |
|
|
|
tempPin->SetType( symbolPin->GetType() ); |
|
|
|
tempPin->SetShape( symbolPin->GetShape() ); |
|
|
|
tempPin->SetName( symbolPin->GetShownName() ); |
|
|
|
tempPin->SetType( symbolPin->GetType() ); |
|
|
|
tempPin->SetShape( symbolPin->GetShape() ); |
|
|
|
|
|
|
|
if( symbolPin->IsDangling() ) |
|
|
|
tempPin->SetFlags( IS_DANGLING ); |
|
|
|
} |
|
|
|
if( symbolPin->IsDangling() ) |
|
|
|
tempPin->SetFlags( IS_DANGLING ); |
|
|
|
} |
|
|
|
|
|
|
|
for( SCH_ITEM& item : tempSymbol.GetDrawItems() ) |
|
|
|
{ |
|
|
|
if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( &item ) ) |
|
|
|
for( SCH_ITEM& item : tempSymbol.GetDrawItems() ) |
|
|
|
{ |
|
|
|
// Use SCH_FIELD's text resolver
|
|
|
|
SCH_FIELD dummy( this, -1 ); |
|
|
|
dummy.SetText( text->GetText() ); |
|
|
|
text->SetText( dummy.GetShownText( false ) ); |
|
|
|
if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( &item ) ) |
|
|
|
{ |
|
|
|
// Use SCH_FIELD's text resolver
|
|
|
|
SCH_FIELD dummy( this, -1 ); |
|
|
|
dummy.SetText( text->GetText() ); |
|
|
|
text->SetText( dummy.GetShownText( false ) ); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter ); |
|
|
|
TRANSFORM savedTransform = renderSettings->m_Transform; |
|
|
|
renderSettings->m_Transform = GetTransform(); |
|
|
|
aPlotter->StartBlock( nullptr ); |
|
|
|
SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter ); |
|
|
|
TRANSFORM savedTransform = renderSettings->m_Transform; |
|
|
|
renderSettings->m_Transform = GetTransform(); |
|
|
|
aPlotter->StartBlock( nullptr ); |
|
|
|
|
|
|
|
for( bool local_background : { true, false } ) |
|
|
|
{ |
|
|
|
tempSymbol.Plot( aPlotter, local_background, aPlotOpts, GetUnit(), GetBodyStyle(), |
|
|
|
m_pos, GetDNP() ); |
|
|
|
|
|
|
|
for( SCH_FIELD field : m_fields ) |
|
|
|
for( bool local_background : { true, false } ) |
|
|
|
{ |
|
|
|
field.ClearRenderCache(); |
|
|
|
field.Plot( aPlotter, local_background, aPlotOpts, GetUnit(), GetBodyStyle(), |
|
|
|
m_pos, GetDNP() ); |
|
|
|
} |
|
|
|
} |
|
|
|
tempSymbol.Plot( aPlotter, local_background, aPlotOpts, GetUnit(), GetBodyStyle(), |
|
|
|
m_pos, GetDNP() ); |
|
|
|
|
|
|
|
if( m_DNP ) |
|
|
|
PlotDNP( aPlotter ); |
|
|
|
for( SCH_FIELD field : m_fields ) |
|
|
|
{ |
|
|
|
field.ClearRenderCache(); |
|
|
|
field.Plot( aPlotter, local_background, aPlotOpts, GetUnit(), GetBodyStyle(), |
|
|
|
m_pos, GetDNP() ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
SCH_SHEET_PATH* sheet = &Schematic()->CurrentSheet(); |
|
|
|
if( m_DNP ) |
|
|
|
PlotDNP( aPlotter ); |
|
|
|
|
|
|
|
// Plot attributes to a hypertext menu
|
|
|
|
if( aPlotOpts.m_PDFPropertyPopups ) |
|
|
|
{ |
|
|
|
std::vector<wxString> properties; |
|
|
|
SCH_SHEET_PATH* sheet = &Schematic()->CurrentSheet(); |
|
|
|
|
|
|
|
for( const SCH_FIELD& field : GetFields() ) |
|
|
|
// Plot attributes to a hypertext menu
|
|
|
|
if( aPlotOpts.m_PDFPropertyPopups ) |
|
|
|
{ |
|
|
|
wxString text_field = field.GetShownText( sheet, false); |
|
|
|
std::vector<wxString> properties; |
|
|
|
|
|
|
|
if( text_field.IsEmpty() ) |
|
|
|
continue; |
|
|
|
for( const SCH_FIELD& field : GetFields() ) |
|
|
|
{ |
|
|
|
wxString text_field = field.GetShownText( sheet, false); |
|
|
|
|
|
|
|
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), |
|
|
|
field.GetName(), text_field ) ); |
|
|
|
} |
|
|
|
if( text_field.IsEmpty() ) |
|
|
|
continue; |
|
|
|
|
|
|
|
if( !m_part->GetKeyWords().IsEmpty() ) |
|
|
|
{ |
|
|
|
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), |
|
|
|
_( "Keywords" ), |
|
|
|
m_part->GetKeyWords() ) ); |
|
|
|
} |
|
|
|
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), |
|
|
|
field.GetName(), text_field ) ); |
|
|
|
} |
|
|
|
|
|
|
|
aPlotter->HyperlinkMenu( GetBoundingBox(), properties ); |
|
|
|
} |
|
|
|
if( !m_part->GetKeyWords().IsEmpty() ) |
|
|
|
{ |
|
|
|
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), |
|
|
|
_( "Keywords" ), |
|
|
|
m_part->GetKeyWords() ) ); |
|
|
|
} |
|
|
|
|
|
|
|
aPlotter->HyperlinkMenu( GetBoundingBox(), properties ); |
|
|
|
} |
|
|
|
|
|
|
|
aPlotter->EndBlock( nullptr ); |
|
|
|
renderSettings->m_Transform = savedTransform; |
|
|
|
aPlotter->EndBlock( nullptr ); |
|
|
|
renderSettings->m_Transform = savedTransform; |
|
|
|
|
|
|
|
if( !m_part->IsPower() ) |
|
|
|
aPlotter->Bookmark( GetBoundingBox(), GetRef( sheet ), _( "Symbols" ) ); |
|
|
|
if( !m_part->IsPower() ) |
|
|
|
aPlotter->Bookmark( GetBoundingBox(), GetRef( sheet ), _( "Symbols" ) ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -2460,30 +2578,33 @@ void SCH_SYMBOL::PlotDNP( PLOTTER* aPlotter ) const |
|
|
|
|
|
|
|
void SCH_SYMBOL::PlotPins( PLOTTER* aPlotter ) const |
|
|
|
{ |
|
|
|
SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter ); |
|
|
|
TRANSFORM savedTransform = renderSettings->m_Transform; |
|
|
|
renderSettings->m_Transform = GetTransform(); |
|
|
|
if( m_part ) |
|
|
|
{ |
|
|
|
SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter ); |
|
|
|
TRANSFORM savedTransform = renderSettings->m_Transform; |
|
|
|
renderSettings->m_Transform = GetTransform(); |
|
|
|
|
|
|
|
std::vector<SCH_PIN*> libPins = m_part->GetPins( GetUnit(), GetBodyStyle() ); |
|
|
|
std::vector<SCH_PIN*> libPins = m_part->GetPins( GetUnit(), GetBodyStyle() ); |
|
|
|
|
|
|
|
// Copy the source to stay const
|
|
|
|
LIB_SYMBOL tempSymbol( *m_part ); |
|
|
|
std::vector<SCH_PIN*> tempPins = tempSymbol.GetPins( GetUnit(), GetBodyStyle() ); |
|
|
|
SCH_PLOT_OPTS plotOpts; |
|
|
|
// Copy the source to stay const
|
|
|
|
LIB_SYMBOL tempSymbol( *m_part ); |
|
|
|
std::vector<SCH_PIN*> tempPins = tempSymbol.GetPins( GetUnit(), GetBodyStyle() ); |
|
|
|
SCH_PLOT_OPTS plotOpts; |
|
|
|
|
|
|
|
// Copy the pin info from the symbol to the temp pins
|
|
|
|
for( unsigned i = 0; i < tempPins.size(); ++ i ) |
|
|
|
{ |
|
|
|
SCH_PIN* symbolPin = GetPin( libPins[ i ] ); |
|
|
|
SCH_PIN* tempPin = tempPins[ i ]; |
|
|
|
// Copy the pin info from the symbol to the temp pins
|
|
|
|
for( unsigned i = 0; i < tempPins.size(); ++ i ) |
|
|
|
{ |
|
|
|
SCH_PIN* symbolPin = GetPin( libPins[ i ] ); |
|
|
|
SCH_PIN* tempPin = tempPins[ i ]; |
|
|
|
|
|
|
|
tempPin->SetName( symbolPin->GetShownName() ); |
|
|
|
tempPin->SetType( symbolPin->GetType() ); |
|
|
|
tempPin->SetShape( symbolPin->GetShape() ); |
|
|
|
tempPin->Plot( aPlotter, false, plotOpts, GetUnit(), GetBodyStyle(), m_pos, GetDNP() ); |
|
|
|
} |
|
|
|
tempPin->SetName( symbolPin->GetShownName() ); |
|
|
|
tempPin->SetType( symbolPin->GetType() ); |
|
|
|
tempPin->SetShape( symbolPin->GetShape() ); |
|
|
|
tempPin->Plot( aPlotter, false, plotOpts, GetUnit(), GetBodyStyle(), m_pos, GetDNP() ); |
|
|
|
} |
|
|
|
|
|
|
|
renderSettings->m_Transform = savedTransform; |
|
|
|
renderSettings->m_Transform = savedTransform; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -2565,7 +2686,7 @@ bool SCH_SYMBOL::IsSymbolLikePowerGlobalLabel() const |
|
|
|
// It is a Power symbol
|
|
|
|
// It has only one pin type Power input
|
|
|
|
|
|
|
|
if( !GetLibSymbolRef().IsPower() ) |
|
|
|
if( !GetLibSymbolRef() || !GetLibSymbolRef()->IsPower() ) |
|
|
|
return false; |
|
|
|
|
|
|
|
std::vector<SCH_PIN*> pin_list = GetAllLibPins(); |
|
|
|
@ -2579,12 +2700,16 @@ bool SCH_SYMBOL::IsSymbolLikePowerGlobalLabel() const |
|
|
|
|
|
|
|
bool SCH_SYMBOL::IsPower() const |
|
|
|
{ |
|
|
|
wxCHECK( m_part, false ); |
|
|
|
|
|
|
|
return m_part->IsPower(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool SCH_SYMBOL::IsNormal() const |
|
|
|
{ |
|
|
|
wxCHECK( m_part, false ); |
|
|
|
|
|
|
|
return m_part->IsNormal(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -2673,11 +2798,22 @@ static struct SCH_SYMBOL_DESC |
|
|
|
propMgr.AddProperty( new PROPERTY<SCH_SYMBOL, bool>( _HKI( "Mirror Y" ), |
|
|
|
&SCH_SYMBOL::SetMirrorY, &SCH_SYMBOL::GetMirrorY ) ); |
|
|
|
|
|
|
|
auto hasLibPart = |
|
|
|
[]( INSPECTABLE* aItem ) -> bool |
|
|
|
{ |
|
|
|
if( SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( aItem ) ) |
|
|
|
return symbol->GetLibSymbolRef() != nullptr; |
|
|
|
|
|
|
|
return false; |
|
|
|
}; |
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<SYMBOL, bool>( _HKI( "Pin numbers" ), |
|
|
|
&SYMBOL::SetShowPinNumbers, &SYMBOL::GetShowPinNumbers ) ); |
|
|
|
&SYMBOL::SetShowPinNumbers, &SYMBOL::GetShowPinNumbers ) ) |
|
|
|
.SetAvailableFunc( hasLibPart ); |
|
|
|
|
|
|
|
propMgr.AddProperty( new PROPERTY<SYMBOL, bool>( _HKI( "Pin names" ), |
|
|
|
&SYMBOL::SetShowPinNames, &SYMBOL::GetShowPinNames ) ); |
|
|
|
&SYMBOL::SetShowPinNames, &SYMBOL::GetShowPinNames ) ) |
|
|
|
.SetAvailableFunc( hasLibPart ); |
|
|
|
|
|
|
|
const wxString groupFields = _HKI( "Fields" ); |
|
|
|
|
|
|
|
|