53 static const wxString discount( wxT(
" " ) );
58 if( !footprint.IsEmpty() )
60 text += discount + footprint;
85 m_includeInBom( true ),
86 m_includeOnBoard( true )
151 wxFAIL_MSG(
"Failed to clone LIB_ITEM." );
248 const LIB_ITEM* lhsItem = static_cast<const LIB_ITEM*>( &(*lhsItemIt) );
249 const LIB_ITEM* rhsItem = static_cast<const LIB_ITEM*>( &(*rhsItemIt) );
251 wxCHECK( lhsItem && rhsItem, lhsItem - rhsItem );
253 if( lhsItem->
Type() != rhsItem->
Type() )
254 return lhsItem->
Type() - rhsItem->
Type();
256 retv = lhsItem->
compare( *rhsItem );
268 for(
size_t i = 0; i <
m_fpFilters.GetCount(); i++ )
336 std::unique_ptr< LIB_PART > retv;
342 wxCHECK_MSG( parent, retv,
346 retv.reset(
new LIB_PART( *parent.get() ) );
357 retv->GetFieldById( i )->SetText( parent->GetFieldById( i )->GetText() );
365 const LIB_FIELD* aliasField = dynamic_cast<const LIB_FIELD*>( &item );
367 wxCHECK2( aliasField,
continue );
380 retv->AddDrawItem( newField );
384 retv->RemoveDrawItem( parentField );
385 retv->AddDrawItem( newField );
395 retv.reset(
new LIB_PART( *
this ) );
472 subRef << wxChar( u );
494 if( aMulti && drawItem.m_unit && ( drawItem.m_unit != aMulti ) )
497 if( aConvert && drawItem.m_convert && ( drawItem.m_convert != aConvert ) )
505 drawItem.Print( aSettings, aOffset, (
void*)
false, aOpts.
transform );
512 if( aMulti && drawItem.m_unit && ( drawItem.m_unit != aMulti ) )
515 if( aConvert && drawItem.m_convert && ( drawItem.m_convert != aConvert ) )
520 LIB_FIELD& field = static_cast<LIB_FIELD&>( drawItem );
531 drawItem.Print( aSettings, aOffset, (
void*) &aOpts, aOpts.
transform );
535 drawItem.Print( aSettings, aOffset, (
void*)
NULL, aOpts.
transform );
540 drawItem.Print( aSettings, aOffset, (
void*) forceNoFill, aOpts.
transform );
549 wxASSERT( aPlotter !=
NULL );
563 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
566 if( aConvert && item.m_convert && ( item.m_convert != aConvert ) )
570 item.Plot( aPlotter, aOffset, fill, aTransform );
580 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
583 if( aConvert && item.m_convert && ( item.m_convert != aConvert ) )
586 item.Plot( aPlotter, aOffset,
593 const wxPoint& aOffset,
const TRANSFORM& aTransform )
595 wxASSERT( aPlotter !=
NULL );
605 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
608 if( aConvert && item.m_convert && ( item.m_convert != aConvert ) )
623 item.Plot( aPlotter, aOffset, fill, aTransform );
631 wxASSERT( aItem !=
NULL );
637 if( static_cast<LIB_FIELD*>( aItem )->IsMandatory() )
643 for( LIB_ITEMS::iterator i = items.begin(); i != items.end(); i++ )
679 while( ( it !=
m_drawings.
end( aType ) ) && ( aItem != &( *it ) ) )
706 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
710 if( aConvert && item.m_convert && ( item.m_convert != aConvert ) )
713 aList.push_back( (
LIB_PIN*) &item );
722 GetPins( pinList, aUnit, aConvert );
724 for(
size_t i = 0; i < pinList.size(); i++ )
728 if( aNumber == pinList[i]->GetNumber() )
737 bool aTestType,
bool aTestOrientation,
bool aTestLength )
const 742 for(
const LIB_PIN* eachThisPin : thisPinList )
744 wxASSERT( eachThisPin );
746 aOtherPart.
GetPins( otherPinList, 0, 0 );
747 bool foundMatch =
false;
749 for(
const LIB_PIN* eachOtherPin : otherPinList )
751 wxASSERT( eachOtherPin );
754 if( eachThisPin->GetUnit() != eachOtherPin->GetUnit() )
758 if( eachThisPin->GetConvert() != eachOtherPin->GetConvert() )
762 if( eachThisPin->GetPosition() != eachOtherPin->GetPosition() )
766 if( aTestNums && ( eachThisPin->GetNumber() != eachOtherPin->GetNumber() ) )
770 if( aTestNames && ( eachThisPin->GetName() != eachOtherPin->GetName() ) )
774 if( aTestType && ( eachThisPin->GetType() != eachOtherPin->GetType() ) )
779 && ( eachThisPin->GetOrientation() != eachOtherPin->GetOrientation() ) )
783 if( aTestLength && ( eachThisPin->GetLength() != eachOtherPin->GetLength() ) )
806 bool initialized =
false;
813 && aUnit != item.m_unit )
818 if( item.m_convert > 0 && aConvert > 0 && aConvert != item.m_convert )
825 bBox.
Merge( item.GetBoundingBox() );
828 bBox = item.GetBoundingBox();
855 if( item.m_unit > 0 && aUnit > 0 && aUnit != item.m_unit )
858 if( item.m_convert > 0 && aConvert > 0 && aConvert != item.m_convert )
865 bbox.
Merge( static_cast<const LIB_PIN&>( item ).GetBoundingBox(
false,
true ) );
867 bbox.
Merge( item.GetBoundingBox() );
890 for(
unsigned i=0; i<aFields.size(); ++i )
912 LIB_FIELD* field = static_cast<LIB_FIELD*>( &item );
915 aList.push_back( field );
929 LIB_FIELD* field = static_cast<LIB_FIELD*>( &item );
932 aList.push_back( *field );
943 if( field->
GetId() == aId )
955 if( static_cast<LIB_FIELD*>( &item )->GetCanonicalName() == aFieldName )
956 return static_cast<LIB_FIELD*>( &item );
967 if( static_cast<const LIB_FIELD*>( &item )->GetCanonicalName() == aFieldName )
968 return static_cast<const LIB_FIELD*>( &item );
978 wxASSERT( field !=
NULL );
986 wxASSERT( field !=
NULL );
994 wxASSERT( field !=
NULL );
1002 wxASSERT( field !=
NULL );
1010 item.Offset( aOffset );
1024 if( item.m_convert > LIB_ITEM::LIB_CONVERT::BASE )
1030 for(
const LIB_ITEM& item : parent->GetDrawItems() )
1032 if( item.m_convert > LIB_ITEM::LIB_CONVERT::BASE )
1044 item.ClearTempFlags();
1051 item.ClearEditFlags();
1056 KICAD_T aType,
const wxPoint& aPoint )
1060 if( ( aUnit && item.m_unit && aUnit != item.m_unit )
1061 || ( aConvert && item.m_convert && aConvert != item.m_convert )
1067 if( item.HitTest( aPoint ) )
1076 const wxPoint& aPoint,
const TRANSFORM& aTransform )
1101 if( item.IsType( aFilterTypes ) )
1123 if( i->m_unit > aCount )
1129 else if( aDuplicateDrawItems )
1136 std::vector< LIB_ITEM* > tmp;
1140 if( item.m_unit != 1 )
1143 for(
int j = prevCount + 1; j <= aCount; j++ )
1147 tmp.push_back( newItem );
1151 for(
auto item : tmp )
1163 return parent->GetUnitCount();
1177 if( aDuplicatePins )
1179 std::vector< LIB_ITEM* > tmp;
1187 if( item.m_convert == 1 )
1191 tmp.push_back( newItem );
1196 for(
unsigned i = 0; i < tmp.size(); i++ )
1208 if( i->m_convert > 1 )
1224 if( aSep ==
'.' || aSep ==
'-' || aSep ==
'_' )
1227 if( aFirstId ==
'1' && aSep != 0 )
1234 std::vector<LIB_ITEM*> unitItems;
1241 if( ( aConvert == -1 && item.GetUnit() == aUnit )
1242 || ( aUnit == -1 && item.GetConvert() == aConvert )
1243 || ( aUnit == item.GetUnit() && aConvert == item.GetConvert() ) )
1244 unitItems.push_back( &item );
1253 std::vector<struct PART_UNITS> units;
1260 int unit = item.GetUnit();
1261 int convert = item.GetConvert();
1263 auto it = std::find_if( units.begin(), units.end(),
1264 [unit,
convert] (
const auto& a ) {
1265 return a.m_unit == unit && a.m_convert ==
convert;
1268 if( it == units.end() )
1271 newUnit.
m_unit = item.GetUnit();
1273 newUnit.
m_items.push_back( &item );
1274 units.emplace_back( newUnit );
1278 it->m_items.push_back( &item );
1291 std::vector<LIB_ITEM*> compareDrawItems;
1292 std::vector<LIB_ITEM*> currentDrawItems;
1293 std::vector<struct PART_UNITS> uniqueUnits;
1301 if( unit.
m_items.size() == 0 )
1304 uniqueUnits.emplace_back( unit );
1309 currentDrawItems = unit.
m_items;
1311 for( unitNum = 2; unitNum <=
GetUnitCount(); unitNum++ )
1315 wxCHECK2_MSG( compareDrawItems.size() != 0,
continue,
1316 "Multiple unit symbol defined with empty units." );
1318 if( currentDrawItems.size() != compareDrawItems.size() )
1322 unit.
m_items = compareDrawItems;
1323 uniqueUnits.emplace_back( unit );
1327 for( i = 0; i < currentDrawItems.size(); i++ )
1329 if( currentDrawItems[i]->compare( *compareDrawItems[i],
1330 LIB_ITEM::COMPARE_FLAGS::UNIT ) != 0 )
1334 unit.
m_items = compareDrawItems;
1335 uniqueUnits.emplace_back( unit );
1349 unit.
m_items = currentDrawItems;
1350 uniqueUnits.emplace_back( unit );
1355 for( unitNum = 2; unitNum <=
GetUnitCount(); unitNum++ )
1359 wxCHECK2_MSG( compareDrawItems.size() != 0,
continue,
1360 "Multiple unit symbol defined with empty units." );
1362 if( currentDrawItems.size() != compareDrawItems.size() )
1366 unit.
m_items = compareDrawItems;
1367 uniqueUnits.emplace_back( unit );
1371 for( i = 0; i < currentDrawItems.size(); i++ )
1373 if( currentDrawItems[i]->compare( *compareDrawItems[i],
1374 LIB_ITEM::COMPARE_FLAGS::UNIT ) != 0 )
1378 unit.
m_items = compareDrawItems;
1379 uniqueUnits.emplace_back( unit );
Field Reference of part, i.e. "IC21".
const wxString GetName() const
Return the file name without path or extension.
LIB_FIELD & GetFootprintField()
Return reference to the footprint field.
void SetLib(PART_LIB *aLibrary)
static int m_subpartIdSeparator
the separator char between the subpart id and the reference like U1A ( m_subpartIdSeparator = 0 ) or ...
ITERATOR begin(int aType=UNDEFINED_TYPE)
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib=false)
Replace illegal LIB_ID item name characters with underscores '_'.
virtual ~LIB_PART()
http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
LIB_FIELD & GetDatasheetField()
Return reference to the datasheet field.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
wxString GetName() const override
const wxString GetLibraryName() const
bool HasConversion() const
Test if part has more than one body conversion type (DeMorgan).
virtual void SetColor(COLOR4D color)=0
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
int m_unitCount
Number of units (parts) per package.
LIB_ITEM * GetNextDrawItem(const LIB_ITEM *aItem=NULL, KICAD_T aType=TYPE_NOT_INIT)
Return the next draw object pointer.
PART_SPTR SharedPtr() const
void clear(int aType=UNDEFINED_TYPE)
Field object used in symbol libraries.
void SetUnitCount(int aCount, bool aDuplicateDrawItems=true)
Set the units per part count.
static int m_subpartFirstId
the ASCII char value to calculate the subpart symbol id from the part number: only 'A',...
void unique()
Remove duplicate elements in list.
std::vector< struct PART_UNITS > GetUnitDrawItems()
Return a list of LIB_ITEM objects separated by unit and convert number.
LIB_ITEMS_CONTAINER m_drawings
LIB_PIN * GetPin(const wxString &aNumber, int aUnit=0, int aConvert=0) const
Return pin object with the requested pin aNumber.
std::vector< LIB_ITEM * > m_items
The items unique to this unit and alternate body style.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
LIB_FIELD & GetValueField()
Return reference to the value field.
int Compare(const LIB_PART &aRhs) const
Comparison test that can be used for operators.
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
wxString GetKeyWords() const
int m_unit
The unit number.
LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS
LIBRENTRYOPTIONS m_options
Special part features such as POWER or NORMAL.)
int compare(const LIB_ID &aLibId) const
Compare the contents of LIB_ID objects by performing a std::string comparison of the library nickname...
const INSPECTOR_FUNC & INSPECTOR
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
bool m_unitsLocked
True if part has multiple units and changing one unit does not automatically change another unit.
void ClearTempFlags()
Clears the status flag all draw objects in this part.
virtual void SetParent(EDA_ITEM *aParent)
bool operator<(const LIB_PART &aItem1, const LIB_PART &aItem2)
wxString GetName(bool aUseDefaultName=true) const
Returns the field name.
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
The base class for drawable items used by schematic library components.
std::vector< struct PART_UNITS > GetUniqueUnits()
Return a list of unit numbers that are unique to this symbol.
void PlotLibFields(PLOTTER *aPlotter, int aUnit, int aConvert, const wxPoint &aOffset, const TRANSFORM &aTransform)
Plot Lib Fields only of the part to plotter.
void SetOffset(const wxPoint &aOffset)
Move the part aOffset.
ITERATOR end(int aType=UNDEFINED_TYPE)
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
int m_pinNameOffset
The offset in mils to draw the pin name.
PART_REF m_parent
Use for inherited symbols.
int m_unit
Unit identification for multiple parts per package.
void operator()(void const *) const
std::vector< LIB_ITEM * > GetUnitItems(int aUnit, int aConvert)
Return a list of item pointers for aUnit and aConvert for this symbol.
void SetConversion(bool aSetConvert, bool aDuplicatePins=true)
Set or clear the alternate body style (DeMorgan) for the part.
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
LIB_FIELD * FindField(const wxString &aFieldName)
Find a field within this part matching aFieldName and returns it or NULL if not found.
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
int GetUnitCount() const override
For items with units, return the number of units.
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0) const
Return a list of pin object pointers from the draw item list.
int m_convert
Shape identification for alternate body styles.
void SetParent(LIB_PART *aParent=nullptr)
Define a library symbol object.
void GetFields(std::vector< LIB_FIELD * > &aList)
Return a list of fields within this part.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
wxString GetDescription() override
#define STRUCT_DELETED
flag indication structures to be erased
LIB_PART(const wxString &aName, LIB_PART *aParent=nullptr, PART_LIB *aLibrary=nullptr)
void RemoveDuplicateDrawItems()
Remove duplicate draw items from list.
wxArrayString m_fpFilters
List of suitable footprint names for the part (wild card names accepted).
#define DEFAULT_PIN_NAME_OFFSET
The intersheets references prefix string.
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
LIB_FIELD * GetFieldById(int aId) const
Return pointer to the requested field.
int SetLibItemName(const UTF8 &aLibItemName, bool aTestForRev=true)
Override the library item name portion of the LIB_ID to aLibItemName.
ITERATOR erase(const ITERATOR &aIterator)
http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
ITERATOR_BASE< LIB_ITEM, MULTIVECTOR< LIB_ITEM, FIRST_TYPE_VAL, LAST_TYPE_VAL >, typename ITEM_PTR_VECTOR::iterator > ITERATOR
The const iterator.
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
int m_convert
The alternate body style of the unit.
wxString GetUnitReference(int aUnit) override
Return an identifier for aUnit for symbols with units.
Base plotter engine class.
RENDER_SETTINGS * RenderSettings()
TRANSFORM DefaultTransform
static void SetSubpartIdNotation(int aSep, int aFirstId)
Set the separator char between the subpart id and the reference 0 (no separator) or '.
timestamp_t m_lastModDate
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, int aMulti, int aConvert, const PART_DRAW_OPTIONS &aOpts)
Print part.
const EDA_RECT GetUnitBoundingBox(int aUnit, int aConvert) const
Get the bounding box for the symbol.
Handle the component boundary box.
wxString GetFullText(int unit=1) const
Return the text of a field.
static wxString SubReference(int aUnit, bool aAddSeparator=true)
wxString GetSearchText() override
A base class for most all the KiCad significant classes used in schematics and boards.
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
ITERATOR_BASE< const LIB_ITEM, const MULTIVECTOR< LIB_ITEM, FIRST_TYPE_VAL, LAST_TYPE_VAL >, typename ITEM_PTR_VECTOR::const_iterator > CONST_ITERATOR
LIB_ITEM * LocateDrawItem(int aUnit, int aConvert, KICAD_T aType, const wxPoint &aPoint)
Locate a draw object.
const LIB_PART & operator=(const LIB_PART &aPart)
virtual void SetName(const wxString &aName)
wxString m_keyWords
Search keywords.
Definition for part library class.
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
STATUS_FLAGS GetFlags() const
const EDA_RECT GetBodyBoundingBox(int aUnit, int aConvert) const
Get the symbol bounding box excluding fields.
void SetFields(const std::vector< LIB_FIELD > &aFieldsList)
Overwrite all the existing fields in this symbol with fields supplied in aFieldsList.
virtual int compare(const LIB_ITEM &aOther, LIB_ITEM::COMPARE_FLAGS aCompareFlags=LIB_ITEM::COMPARE_FLAGS::NORMAL) const
Provide the draw object specific comparison called by the == and < operators.
void AddField(LIB_FIELD *aField)
Add a field.
Object used to load, save, search, and otherwise manipulate symbol library files.
#define IS_NEW
New item, just created.
virtual const wxString & GetText() const
Return the string associated with the text object.
size_t size(int aType=UNDEFINED_TYPE) const
bool PinsConflictWith(const LIB_PART &aOtherPart, bool aTestNums, bool aTestNames, bool aTestType, bool aTestOrientation, bool aTestLength) const
Return true if this part's pins do not match another part's pins.
void Plot(PLOTTER *aPlotter, int aUnit, int aConvert, const wxPoint &aOffset, const TRANSFORM &aTransform) const
Plot lib part to plotter.
virtual wxString GetShownText(int aDepth=0) const
Return the string actually shown after processing of the base text.
bool UnitsLocked() const
Check whether part units are interchangeable.
KICAD_T Type() const
Returns the type of object.
void RemoveDrawItem(LIB_ITEM *aItem)
Remove draw aItem from list.
Field Name Module PCB, i.e. "16DIP300".
bool GetColorMode() const