"comp" -> "symbol".

This commit is contained in:
Jeff Young 2021-01-19 23:50:18 +00:00
parent 0ded846130
commit 360953ba98
12 changed files with 119 additions and 119 deletions

View File

@ -41,17 +41,18 @@ void SCH_EDIT_FRAME::mapExistingAnnotation( std::map<wxString, wxString>& aMap )
for( size_t i = 0; i < references.GetCount(); i++ )
{
SCH_COMPONENT* comp = references[ i ].GetSymbol();
SCH_COMPONENT* symbol = references[ i ].GetSymbol();
SCH_SHEET_PATH* curr_sheetpath = &references[ i ].GetSheetPath();
KIID_PATH curr_full_uuid = curr_sheetpath->Path();
curr_full_uuid.push_back( comp->m_Uuid );
KIID_PATH curr_full_uuid = curr_sheetpath->Path();
wxString ref = comp->GetRef( curr_sheetpath );
curr_full_uuid.push_back( symbol->m_Uuid );
if( comp->GetUnitCount() > 1 )
ref << LIB_PART::SubReference( comp->GetUnitSelection( curr_sheetpath ) );
wxString ref = symbol->GetRef( curr_sheetpath );
if( comp->IsAnnotated( curr_sheetpath ) )
if( symbol->GetUnitCount() > 1 )
ref << LIB_PART::SubReference( symbol->GetUnitSelection( curr_sheetpath ) );
if( symbol->IsAnnotated( curr_sheetpath ) )
aMap[ curr_full_uuid.AsString() ] = ref;
}
}

View File

@ -261,13 +261,13 @@ protected:
for( SCH_ITEM* item : m_screen->Items().Overlapping( m_symbol->GetBoundingBox() ) )
{
if( SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( item ) )
if( SCH_COMPONENT* candidate = dynamic_cast<SCH_COMPONENT*>( item ) )
{
if( comp == m_symbol )
if( candidate == m_symbol )
continue;
std::vector<SCH_FIELD*> fields;
comp->GetFields( fields, /* aVisibleOnly */ true );
candidate->GetFields( fields, /* aVisibleOnly */ true );
for( SCH_FIELD* field : fields )
aItems.push_back( field );

View File

@ -372,14 +372,14 @@ void DIALOG_SCH_EDIT_ONE_FIELD::onScintillaCharAdded( wxStyledTextEvent &aEvent
{
partial = m_StyledTextCtrl->GetTextRange( start, pos );
SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( m_field->GetParent() );
SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( m_field->GetParent() );
SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( m_field->GetParent() );
if( comp )
if( symbol )
{
comp->GetContextualTextVars( &autocompleteTokens );
symbol->GetContextualTextVars( &autocompleteTokens );
SCHEMATIC* schematic = comp->Schematic();
SCHEMATIC* schematic = symbol->Schematic();
if( schematic && schematic->CurrentSheet().Last() )
schematic->CurrentSheet().Last()->GetContextualTextVars( &autocompleteTokens );
@ -405,14 +405,14 @@ void DIALOG_SCH_EDIT_ONE_FIELD::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH*
if( parent && parent->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( parent );
SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( parent );
if( fieldType == REFERENCE_FIELD )
comp->SetRef( aSheetPath, m_text );
symbol->SetRef( aSheetPath, m_text );
else if( fieldType == VALUE_FIELD )
comp->SetValue( m_text );
symbol->SetValue( m_text );
else if( fieldType == FOOTPRINT_FIELD )
comp->SetFootprint( m_text );
symbol->SetFootprint( m_text );
}
bool positioningModified = false;

View File

@ -403,9 +403,9 @@ int ERC_TESTER::TestNoConnectPins()
for( SCH_ITEM* item : sheet.LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
{
SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( item );
for( SCH_PIN* pin : comp->GetPins( &sheet ) )
for( SCH_PIN* pin : symbol->GetPins( &sheet ) )
{
if( pin->GetLibPin()->GetType() == ELECTRICAL_PINTYPE::PT_NC )
pinMap[pin->GetPosition()].emplace_back( pin );

View File

@ -72,31 +72,31 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName,
// Process component attributes
for( auto item : sheet.LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
{
SCH_COMPONENT* comp = findNextSymbol( item, &sheet );
SCH_COMPONENT* symbol = findNextSymbol( item, &sheet );
if( !comp )
if( !symbol )
continue;
CreatePinList( comp, &sheet );
CreatePinList( symbol, &sheet );
if( comp->GetPartRef() && comp->GetPartRef()->GetFPFilters().GetCount() != 0 )
cmpList.push_back( SCH_REFERENCE( comp, comp->GetPartRef().get(), sheet ) );
if( symbol->GetPartRef() && symbol->GetPartRef()->GetFPFilters().GetCount() != 0 )
cmpList.push_back( SCH_REFERENCE( symbol, symbol->GetPartRef().get(), sheet ) );
footprint = comp->GetFootprint( &sheet, true );
footprint = symbol->GetFootprint( &sheet, true );
footprint.Replace( wxT( " " ), wxT( "_" ) );
if( footprint.IsEmpty() )
footprint = wxT( "$noname" );
ret |= fprintf( f, " ( %s %s",
TO_UTF8( sheet.PathAsString() + comp->m_Uuid.AsString() ),
TO_UTF8( sheet.PathAsString() + symbol->m_Uuid.AsString() ),
TO_UTF8( footprint ) );
field = comp->GetRef( &sheet );
field = symbol->GetRef( &sheet );
ret |= fprintf( f, " %s", TO_UTF8( field ) );
field = comp->GetValue( &sheet, true );
field = symbol->GetValue( &sheet, true );
field.Replace( wxT( " " ), wxT( "_" ) );
ret |= fprintf( f, " %s", TO_UTF8( field ) );

View File

@ -286,22 +286,22 @@ bool NETLIST_EXPORTER_PSPICE::ProcessNetlist( unsigned aCtl )
// Process component attributes to find Spice directives
for( auto item : sheet.LastScreen()->Items().OfType( SCH_COMPONENT_T ) )
{
SCH_COMPONENT* comp = findNextSymbol( item, &sheet );
SCH_COMPONENT* symbol = findNextSymbol( item, &sheet );
if( !comp )
if( !symbol )
continue;
CreatePinList( comp, &sheet );
CreatePinList( symbol, &sheet );
SPICE_ITEM spiceItem;
spiceItem.m_parent = comp;
spiceItem.m_parent = symbol;
// Obtain Spice fields
SCH_FIELD* fieldLibFile = comp->FindField( GetSpiceFieldName( SF_LIB_FILE ) );
SCH_FIELD* fieldSeq = comp->FindField( GetSpiceFieldName( SF_NODE_SEQUENCE ) );
SCH_FIELD* fieldLibFile = symbol->FindField( GetSpiceFieldName( SF_LIB_FILE ) );
SCH_FIELD* fieldSeq = symbol->FindField( GetSpiceFieldName( SF_NODE_SEQUENCE ) );
spiceItem.m_primitive = GetSpiceField( SF_PRIMITIVE, comp, aCtl )[0];
spiceItem.m_model = GetSpiceField( SF_MODEL, comp, aCtl );
spiceItem.m_refName = comp->GetRef( &sheet );
spiceItem.m_primitive = GetSpiceField( SF_PRIMITIVE, symbol, aCtl )[0];
spiceItem.m_model = GetSpiceField( SF_MODEL, symbol, aCtl );
spiceItem.m_refName = symbol->GetRef( &sheet );
// Duplicate references will result in simulation errors
if( refNames.count( spiceItem.m_refName ) )
@ -314,7 +314,7 @@ bool NETLIST_EXPORTER_PSPICE::ProcessNetlist( unsigned aCtl )
refNames.insert( spiceItem.m_refName );
// Check to see if component should be removed from Spice netlist
spiceItem.m_enabled = StringToBool( GetSpiceField( SF_ENABLED, comp, aCtl ) );
spiceItem.m_enabled = StringToBool( GetSpiceField( SF_ENABLED, symbol, aCtl ) );
if( fieldLibFile && !fieldLibFile->GetShownText().IsEmpty() )
m_libraries.insert( fieldLibFile->GetShownText() );

View File

@ -56,10 +56,10 @@ SELECTION_CONDITION EE_CONDITIONS::SingleSymbol = [] (const SELECTION& aSel )
{
if( aSel.GetSize() == 1 )
{
SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( aSel.Front() );
SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( aSel.Front() );
if( comp )
return !comp->GetPartRef() || !comp->GetPartRef()->IsPower();
if( symbol )
return !symbol->GetPartRef() || !symbol->GetPartRef()->IsPower();
}
return false;
@ -70,10 +70,10 @@ SELECTION_CONDITION EE_CONDITIONS::SingleDeMorganSymbol = [] ( const SELECTION&
{
if( aSel.GetSize() == 1 )
{
SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( aSel.Front() );
SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( aSel.Front() );
if( comp )
return comp->GetPartRef() && comp->GetPartRef()->HasConversion();
if( symbol )
return symbol->GetPartRef() && symbol->GetPartRef()->HasConversion();
}
return false;
@ -84,10 +84,10 @@ SELECTION_CONDITION EE_CONDITIONS::SingleMultiUnitSymbol = [] ( const SELECTION&
{
if( aSel.GetSize() == 1 )
{
SCH_COMPONENT* comp = dynamic_cast<SCH_COMPONENT*>( aSel.Front() );
SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( aSel.Front() );
if( comp )
return comp->GetPartRef() && comp->GetPartRef()->GetUnitCount() >= 2;
if( symbol )
return symbol->GetPartRef() && symbol->GetPartRef()->GetUnitCount() >= 2;
}
return false;

View File

@ -636,11 +636,11 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
else if( item->Type() == SCH_PIN_T )
{
SCH_PIN* pin = (SCH_PIN*) item;
SCH_COMPONENT* comp = (SCH_COMPONENT*) item->GetParent();
SCH_COMPONENT* symbol = (SCH_COMPONENT*) item->GetParent();
wxString param;
wxString primitive;
primitive = NETLIST_EXPORTER_PSPICE::GetSpiceField( SF_PRIMITIVE, comp, 0 );
primitive = NETLIST_EXPORTER_PSPICE::GetSpiceField( SF_PRIMITIVE, symbol, 0 );
primitive.LowerCase();
if( primitive == "c" || primitive == "l" || primitive == "r" )
@ -650,7 +650,8 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
else
param = wxString::Format( wxT( "I%s" ), pin->GetName().Lower() );
simFrame->AddCurrentPlot( comp->GetRef( &m_frame->GetCurrentSheet() ), param );
simFrame->AddCurrentPlot( symbol->GetRef( &m_frame->GetCurrentSheet() ),
param );
}
return true;
@ -830,16 +831,16 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
else
{
SCH_ITEM* item = static_cast<SCH_ITEM*>( selTool->GetNode( aPosition ) );
SCH_COMPONENT* comp = nullptr;
SCH_COMPONENT* symbol = nullptr;
if( item )
{
if( item->Type() == SCH_FIELD_T )
comp = dynamic_cast<SCH_COMPONENT*>( item->GetParent() );
symbol = dynamic_cast<SCH_COMPONENT*>( item->GetParent() );
if( comp && comp->GetPartRef() && comp->GetPartRef()->IsPower() )
if( symbol && symbol->GetPartRef() && symbol->GetPartRef()->IsPower() )
{
std::vector<SCH_PIN*> pins = comp->GetPins();
std::vector<SCH_PIN*> pins = symbol->GetPins();
if( pins.size() == 1 )
conn = pins[0]->Connection();
@ -996,15 +997,15 @@ int SCH_EDITOR_CONTROL::UpdateNetHighlighting( const TOOL_EVENT& aEvent )
for( SCH_ITEM* item : screen->Items() )
{
SCH_CONNECTION* itemConn = nullptr;
SCH_COMPONENT* comp = nullptr;
SCH_COMPONENT* symbol = nullptr;
bool redraw = item->IsBrightened();
bool highlight = false;
if( item->Type() == SCH_COMPONENT_T )
comp = static_cast<SCH_COMPONENT*>( item );
symbol = static_cast<SCH_COMPONENT*>( item );
if( comp && comp->GetPartRef() && comp->GetPartRef()->IsPower() )
itemConn = comp->Connection();
if( symbol && symbol->GetPartRef() && symbol->GetPartRef()->IsPower() )
itemConn = symbol->Connection();
else
itemConn = item->Connection();
@ -1053,14 +1054,14 @@ int SCH_EDITOR_CONTROL::UpdateNetHighlighting( const TOOL_EVENT& aEvent )
redraw |= item->IsBrightened();
// comp is only non-null if the item is a SCH_COMPONENT_T
if( comp )
// symbol is only non-null if the item is a SCH_COMPONENT_T
if( symbol )
{
redraw |= comp->HasBrightenedPins();
redraw |= symbol->HasBrightenedPins();
comp->ClearBrightenedPins();
symbol->ClearBrightenedPins();
for( SCH_PIN* pin : comp->GetPins() )
for( SCH_PIN* pin : symbol->GetPins() )
{
SCH_CONNECTION* pin_conn = pin->Connection();
@ -1071,9 +1072,9 @@ int SCH_EDITOR_CONTROL::UpdateNetHighlighting( const TOOL_EVENT& aEvent )
}
}
if( comp->GetPartRef() && comp->GetPartRef()->IsPower() )
if( symbol->GetPartRef() && symbol->GetPartRef()->IsPower() )
{
std::vector<SCH_FIELD>& fields = comp->GetFields();
std::vector<SCH_FIELD>& fields = symbol->GetFields();
for( int id : { REFERENCE_FIELD, VALUE_FIELD } )
{
@ -1297,12 +1298,12 @@ void SCH_EDITOR_CONTROL::updatePastedInstances( const SCH_SHEET_PATH& aPastePath
{
if( item->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( item );
if( aForceKeepAnnotations )
{
KIID_PATH clipItemPath = aClipPath;
clipItemPath.push_back( comp->m_Uuid );
clipItemPath.push_back( symbol->m_Uuid );
// SCH_REFERENCE_LIST doesn't include the root sheet in the path
clipItemPath.erase( clipItemPath.begin() );
@ -1313,19 +1314,19 @@ void SCH_EDITOR_CONTROL::updatePastedInstances( const SCH_SHEET_PATH& aPastePath
{
SCH_REFERENCE instance = m_supplementaryClipboardInstances[ ii ];
comp->SetUnit( instance.GetUnit() );
comp->SetRef( &aPastePath, instance.GetRef() );
comp->SetValue( &aPastePath, instance.GetValue() );
comp->SetFootprint( &aPastePath, instance.GetFootprint() );
symbol->SetUnit( instance.GetUnit() );
symbol->SetRef( &aPastePath, instance.GetRef() );
symbol->SetValue( &aPastePath, instance.GetValue() );
symbol->SetFootprint( &aPastePath, instance.GetFootprint() );
}
else
{
comp->ClearAnnotation( &aPastePath );
symbol->ClearAnnotation( &aPastePath );
}
}
else
{
comp->ClearAnnotation( &aPastePath );
symbol->ClearAnnotation( &aPastePath );
}
}
else if( item->Type() == SCH_SHEET_T )

View File

@ -450,16 +450,16 @@ int SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic( const TOOL_EVENT& aEvent )
wxCHECK( part->GetLibId().IsValid(), 0 );
SCH_COMPONENT* comp = new SCH_COMPONENT( *part, libId, &schframe->GetCurrentSheet(), unit,
convert );
SCH_COMPONENT* symbol = new SCH_COMPONENT( *part, libId, &schframe->GetCurrentSheet(),
unit, convert );
comp->SetParent( schframe->GetCurrentSheet().LastScreen() );
symbol->SetParent( schframe->GetCurrentSheet().LastScreen() );
if( schframe->eeconfig()->m_AutoplaceFields.enable )
comp->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
symbol->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
schframe->Raise();
schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, true, comp );
schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, true, symbol );
}
return 0;

View File

@ -1618,11 +1618,12 @@ PAD* BOARD::GetPad( std::vector<PAD*>& aPadList, const wxPoint& aPosition, LSET
*
* This function is used to build ordered pads lists
*/
bool sortPadsByXthenYCoord( PAD* const & ref, PAD* const & comp )
bool sortPadsByXthenYCoord( PAD* const & aLH, PAD* const & aRH )
{
if( ref->GetPosition().x == comp->GetPosition().x )
return ref->GetPosition().y < comp->GetPosition().y;
return ref->GetPosition().x < comp->GetPosition().x;
if( aLH->GetPosition().x == aRH->GetPosition().x )
return aLH->GetPosition().y < aRH->GetPosition().y;
return aLH->GetPosition().x < aRH->GetPosition().x;
}

View File

@ -30,11 +30,10 @@
#include <pcb_edit_frame.h>
#include <project.h>
#include <wildcards_and_files_ext.h>
#include <board.h>
#include <footprint.h>
#include <wx/listimpl.cpp>
/* creates a BOM list rom board
/* creates a BOM list from board
* The format is:
* "Id";"Designator";"Package";"Number";"Designation";"Supplier and ref";
* 1;"P1";"DB25FC";1;"DB25FEMELLE";;;
@ -53,19 +52,18 @@
const wxString CsvFileExtension( wxT( "csv" ) ); // BOM file extension
class cmp
class BOM_ENTRY
{
public:
wxString m_Ref;
wxString m_Val;
LIB_ID m_fpid;
LIB_ID m_FPID;
int m_Id;
int m_CmpCount;
int m_Count;
};
WX_DECLARE_LIST( cmp, CmpList );
WX_DECLARE_LIST( BOM_ENTRY, BOM_ENTRY_LIST );
WX_DEFINE_LIST( CmpList )
WX_DEFINE_LIST( BOM_ENTRY_LIST )
void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
@ -114,25 +112,24 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
fprintf( fp_bom, "%s", TO_UTF8( msg ) );
// Build list
CmpList list;
cmp* comp = NULL;
CmpList::iterator iter;
int i = 1;
BOM_ENTRY_LIST list;
int i = 1;
for( FOOTPRINT* fp : GetBoard()->Footprints() )
for( FOOTPRINT* footprint : GetBoard()->Footprints() )
{
bool valExist = false;
// try to find component in existing list
for( iter = list.begin(); iter != list.end(); ++iter )
for( auto iter = list.begin(); iter != list.end(); ++iter )
{
cmp* current = *iter;
BOM_ENTRY* curEntry = *iter;
if( current->m_Val == fp->GetValue() && current->m_fpid == fp->GetFPID() )
if( curEntry->m_Val == footprint->GetValue()
&& curEntry->m_FPID == footprint->GetFPID() )
{
current->m_Ref.Append( wxT( ", " ), 1 );
current->m_Ref.Append( fp->Reference().GetShownText() );
current->m_CmpCount++;
curEntry->m_Ref.Append( wxT( ", " ), 1 );
curEntry->m_Ref.Append( footprint->Reference().GetShownText() );
curEntry->m_Count++;
valExist = true;
break;
@ -142,34 +139,34 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
// If component does not exist yet, create new one and append it to the list.
if( valExist == false )
{
comp = new cmp();
comp->m_Id = i++;
comp->m_Val = fp->Value().GetShownText();
comp->m_Ref = fp->Reference().GetShownText();
comp->m_fpid = fp->GetFPID();
comp->m_CmpCount = 1;
list.Append( comp );
BOM_ENTRY* newEntry = new BOM_ENTRY();
newEntry->m_Id = i++;
newEntry->m_Val = footprint->Value().GetShownText();
newEntry->m_Ref = footprint->Reference().GetShownText();
newEntry->m_FPID = footprint->GetFPID();
newEntry->m_Count = 1;
list.Append( newEntry );
}
}
// Print list. Also delete temporary created objects.
for( size_t ii = list.GetCount(); ii > 0; ii-- )
{
cmp* current = *list.begin(); // Because the first object will be removed
// from list, all objects will be get here
BOM_ENTRY* curEntry = *list.begin(); // Because the first object will be removed
// from list, all objects will be get here
msg.Empty();
msg << current->m_Id << wxT( ";\"" );
msg << current->m_Ref << wxT( "\";\"" );
msg << FROM_UTF8( current->m_fpid.GetLibItemName().c_str() ) << wxT( "\";" );
msg << current->m_CmpCount << wxT( ";\"" );
msg << current->m_Val << wxT( "\";;;\n" );
msg << curEntry->m_Id << wxT( ";\"" );
msg << curEntry->m_Ref << wxT( "\";\"" );
msg << FROM_UTF8( curEntry->m_FPID.GetLibItemName().c_str() ) << wxT( "\";" );
msg << curEntry->m_Count << wxT( ";\"" );
msg << curEntry->m_Val << wxT( "\";;;\n" );
fprintf( fp_bom, "%s", TO_UTF8( msg ) );
// We do not need this object, now: remove it from list and delete it
list.DeleteObject( current );
delete (current);
list.DeleteObject( curEntry );
delete (curEntry);
}
fclose( fp_bom );

View File

@ -102,7 +102,7 @@ class COMPONENT
/// this one is a copy of the netlist footprint assignment
LIB_ID m_altFpid;
/// The #FOOTPRINT loaded for #m_fpid.
/// The #FOOTPRINT loaded for #m_FPID.
std::unique_ptr< FOOTPRINT > m_footprint;
/// Component-specific properties found in the netlist.