Add support for LIB_ALIAS objects.

This commit is contained in:
Jeff Young 2018-08-28 14:27:56 +01:00
parent 8b4f01b6b7
commit 8e915ae8d8
4 changed files with 35 additions and 13 deletions

View File

@ -813,9 +813,6 @@ void LIB_PART::GetFields( LIB_FIELDS& aList )
{ {
LIB_FIELD* field; LIB_FIELD* field;
// The only caller of this function is the library field editor, so it
// establishes policy here.
// Grab the MANDATORY_FIELDS first, in expected order given by // Grab the MANDATORY_FIELDS first, in expected order given by
// enum NumFieldType // enum NumFieldType
for( int id=0; id<MANDATORY_FIELDS; ++id ) for( int id=0; id<MANDATORY_FIELDS; ++id )

View File

@ -399,9 +399,7 @@ public:
void SetFields( const std::vector <LIB_FIELD>& aFieldsList ); void SetFields( const std::vector <LIB_FIELD>& aFieldsList );
/** /**
* Return a list of fields withing this part. The only known caller of * Return a list of fields within this part.
* this function is the library part field editor, and it establishes
* needed behavior.
* *
* @param aList - List to add fields to * @param aList - List to add fields to
*/ */

View File

@ -141,6 +141,7 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer )
*/ */
switch(item->Type()) switch(item->Type())
{ {
HANDLE_ITEM(LIB_ALIAS_T, LIB_ALIAS);
HANDLE_ITEM(LIB_PART_T, LIB_PART); HANDLE_ITEM(LIB_PART_T, LIB_PART);
HANDLE_ITEM(LIB_RECTANGLE_T, LIB_RECTANGLE); HANDLE_ITEM(LIB_RECTANGLE_T, LIB_RECTANGLE);
HANDLE_ITEM(LIB_POLYLINE_T, LIB_POLYLINE); HANDLE_ITEM(LIB_POLYLINE_T, LIB_POLYLINE);
@ -170,10 +171,10 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer )
return false; return false;
} }
void SCH_PAINTER::draw( LIB_PART *aComp, int aLayer, bool aDrawFields, int aUnit, int aConvert ) void SCH_PAINTER::draw( LIB_PART *aComp, int aLayer, bool aDrawFields, int aUnit, int aConvert )
{ {
auto comp = const_cast<LIB_PART*>(aComp); for( auto& item : aComp->GetDrawItems() )
for ( auto& item : comp->GetDrawItems() )
{ {
if( !aDrawFields && item.Type() == LIB_FIELD_T ) if( !aDrawFields && item.Type() == LIB_FIELD_T )
continue; continue;
@ -188,6 +189,30 @@ void SCH_PAINTER::draw ( LIB_PART *aComp, int aLayer, bool aDrawFields, int aUni
} }
} }
void SCH_PAINTER::draw( LIB_ALIAS *aAlias, int aLayer )
{
LIB_PART* comp = aAlias->GetPart();
int unit = 0;
int convert = 0;
draw( comp, aLayer, false, unit, convert );
LIB_FIELDS fields;
comp->GetFields( fields );
if( !aAlias->IsRoot() )
{
fields[ VALUE ].SetText( aAlias->GetName() );
fields[ DATASHEET ].SetText( aAlias->GetDocFileName() );
}
for( LIB_FIELD& field : fields )
draw( &field, aLayer );
}
static VECTOR2D mapCoords( const wxPoint& aCoord ) static VECTOR2D mapCoords( const wxPoint& aCoord )
{ {
return VECTOR2D( aCoord.x, -aCoord.y ); return VECTOR2D( aCoord.x, -aCoord.y );

View File

@ -32,6 +32,7 @@ class LIB_PIN;
class LIB_CIRCLE; class LIB_CIRCLE;
class LIB_ITEM; class LIB_ITEM;
class LIB_PART; class LIB_PART;
class LIB_ALIAS;
class LIB_POLYLINE; class LIB_POLYLINE;
class LIB_ARC; class LIB_ARC;
class LIB_FIELD; class LIB_FIELD;
@ -120,6 +121,7 @@ private:
void draw( LIB_CIRCLE *, int ); void draw( LIB_CIRCLE *, int );
void draw( LIB_ITEM *, int ); void draw( LIB_ITEM *, int );
void draw( LIB_PART *, int, bool aDrawFields = true, int aUnit = 0, int aConvert = 0 ); void draw( LIB_PART *, int, bool aDrawFields = true, int aUnit = 0, int aConvert = 0 );
void draw( LIB_ALIAS *, int );
void draw( LIB_ARC *, int ); void draw( LIB_ARC *, int );
void draw( LIB_POLYLINE *, int ); void draw( LIB_POLYLINE *, int );
void draw( LIB_FIELD *, int ); void draw( LIB_FIELD *, int );