LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent, bool aEndPointOnly ) const { SCH_ITEM* item; SCH_COMPONENT* component = NULL; LIB_PIN* pin = NULL; for( item = m_drawList.begin(); item; item = item->Next() ) { if( item->Type() != SCH_COMPONENT_T ) continue; component = (SCH_COMPONENT*) item; if( aEndPointOnly ) { pin = NULL; LIB_PART* part = Prj().SchLibs()->FindLibPart( component->GetPartName() ); if( !part ) continue; for( pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) ) { // Skip items not used for this part. if( component->GetUnit() && pin->GetUnit() && ( pin->GetUnit() != component->GetUnit() ) ) continue; if( component->GetConvert() && pin->GetConvert() && ( pin->GetConvert() != component->GetConvert() ) ) continue; if(component->GetPinPhysicalPosition( pin ) == aPosition ) break; } if( pin ) break; } else { pin = (LIB_PIN*) component->GetDrawItem( aPosition, LIB_PIN_T ); if( pin ) break; } } if( pin && aComponent ) *aComponent = component; return pin; }
LIB_PIN* SCH_SCREEN::GetPin( const wxPoint& aPosition, SCH_COMPONENT** aComponent, bool aEndPointOnly ) const { SCH_ITEM* item; SCH_COMPONENT* component = NULL; LIB_PIN* pin = NULL; for( item = m_drawList.begin(); item != NULL; item = item->Next() ) { if( item->Type() != SCH_COMPONENT_T ) continue; component = (SCH_COMPONENT*) item; if( aEndPointOnly ) { pin = NULL; LIB_COMPONENT* entry = CMP_LIBRARY::FindLibraryComponent( component->GetLibName() ); if( entry == NULL ) continue; for( pin = entry->GetNextPin(); pin != NULL; pin = entry->GetNextPin( pin ) ) { // Skip items not used for this part. if( component->GetUnit() && pin->GetUnit() && ( pin->GetUnit() != component->GetUnit() ) ) continue; if( component->GetConvert() && pin->GetConvert() && ( pin->GetConvert() != component->GetConvert() ) ) continue; if(component->GetPinPhysicalPosition( pin ) == aPosition ) break; } if( pin ) break; } else { pin = (LIB_PIN*) component->GetDrawItem( aPosition, LIB_PIN_T ); if( pin ) break; } } if( pin && aComponent ) *aComponent = component; return pin; }
SCH_COMPONENT* NETLIST_EXPORTER::findNextComponentAndCreatePinList( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheetPath ) { wxString ref; m_SortedComponentPinList.clear(); // continue searching from the middle of a linked list (the draw list) for( ; aItem; aItem = aItem->Next() ) { if( aItem->Type() != SCH_COMPONENT_T ) continue; // found next component SCH_COMPONENT* comp = (SCH_COMPONENT*) aItem; // Power symbols and other components which have the reference starting // with "#" are not included in netlist (pseudo or virtual components) ref = comp->GetRef( aSheetPath ); if( ref[0] == wxChar( '#' ) ) continue; // if( Component->m_FlagControlMulti == 1 ) // continue; /* yes */ // removed because with multiple instances of one schematic // (several sheets pointing to 1 screen), this will be erroneously be // toggled. LIB_PART* part = m_libs->FindLibPart( comp->GetPartName() ); if( !part ) continue; // If component is a "multi parts per package" type if( part->GetUnitCount() > 1 ) { // test if this reference has already been processed, and if so skip if( m_ReferencesAlreadyFound.Lookup( ref ) ) continue; // Collect all pins for this reference designator by searching // the entire design for other parts with the same reference designator. // This is only done once, it would be too expensive otherwise. findAllInstancesOfComponent( comp, part, aSheetPath ); } else // entry->GetUnitCount() <= 1 means one part per package { LIB_PINS pins; // constructed once here part->GetPins( pins, comp->GetUnitSelection( aSheetPath ), comp->GetConvert() ); for( size_t i = 0; i < pins.size(); i++ ) { LIB_PIN* pin = pins[i]; wxASSERT( pin->Type() == LIB_PIN_T ); addPinToComponentPinList( comp, aSheetPath, pin ); } } // Sort pins in m_SortedComponentPinList by pin number sort( m_SortedComponentPinList.begin(), m_SortedComponentPinList.end(), sortPinsByNum ); // Remove duplicate Pins in m_SortedComponentPinList eraseDuplicatePins( ); // record the usage of this library component entry. m_LibParts.insert( part ); // rejects non-unique pointers return comp; } return NULL; }