Commit 3fed7b9d authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Component library object encapsulation work.

parent a6a34f35
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -4,6 +4,16 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
Please add newer entries at the top, list the date and your name with
email address.
email address.


2010-dec-07 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
++EESchema
  * Finish encapsulating LIB_FIELD object.
  * Encapsulated all members currently in use in LIB_PIN object.
++Common
  * Add SetModified() helper to EDA_BaseStruct object that checks for a parent
    object and sets it's modified status as well.


2010-dec-02 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
2010-dec-02 UPDATE Wayne Stambaugh <stambaughw@verizon.net>
================================================================================
================================================================================
++EESchema
++EESchema
+10 −6
Original line number Original line Diff line number Diff line
@@ -20,9 +20,7 @@ enum textbox {
};
};




/******************************************************************************/
EDA_BaseStruct::EDA_BaseStruct( EDA_BaseStruct* parent, KICAD_T idType )
EDA_BaseStruct::EDA_BaseStruct( EDA_BaseStruct* parent, KICAD_T idType )
/******************************************************************************/
{
{
    InitVars();
    InitVars();
    m_StructType = idType;
    m_StructType = idType;
@@ -30,9 +28,7 @@ EDA_BaseStruct::EDA_BaseStruct( EDA_BaseStruct* parent, KICAD_T idType )
}
}




/********************************************/
EDA_BaseStruct::EDA_BaseStruct( KICAD_T idType )
EDA_BaseStruct::EDA_BaseStruct( KICAD_T idType )
/********************************************/
{
{
    InitVars();
    InitVars();
    m_StructType = idType;
    m_StructType = idType;
@@ -51,9 +47,7 @@ EDA_BaseStruct::EDA_BaseStruct( const EDA_BaseStruct& base )
}
}




/********************************************/
void EDA_BaseStruct::InitVars()
void EDA_BaseStruct::InitVars()
/********************************************/
{
{
    m_StructType = TYPE_NOT_INIT;
    m_StructType = TYPE_NOT_INIT;
    Pnext       = NULL;     // Linked list: Link (next struct)
    Pnext       = NULL;     // Linked list: Link (next struct)
@@ -69,6 +63,16 @@ void EDA_BaseStruct::InitVars()
}
}




void EDA_BaseStruct::SetModified()
{
    m_Flags |= IS_CHANGED;

    // If this a child object, then the parent modification state also needs to be set.
    if( m_Parent )
        m_Parent->SetModified();
}


// see base_struct.h
// see base_struct.h
SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart,
SEARCH_RESULT EDA_BaseStruct::IterateForward( EDA_BaseStruct* listStart,
                                              INSPECTOR*      inspector,
                                              INSPECTOR*      inspector,
+1 −1
Original line number Original line Diff line number Diff line
@@ -898,7 +898,7 @@ static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,


        /* Calculate the pin position (according to the component orientation)
        /* Calculate the pin position (according to the component orientation)
         */
         */
        aPosition = DefaultTransform.TransformCoordinate( Pin->m_Pos ) + CmpPosition;
        aPosition = DefaultTransform.TransformCoordinate( Pin->GetPosition() ) + CmpPosition;
        return Pin;
        return Pin;
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -756,7 +756,7 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
        {
        {
            // Calculate the exact position of the connection point of the pin,
            // Calculate the exact position of the connection point of the pin,
            // depending on orientation of the component.
            // depending on orientation of the component.
            itempos    = LibItem->GetScreenCoord( pin->m_Pos );
            itempos    = LibItem->GetScreenCoord( pin->GetPosition() );
            itempos.x += LibItem->m_Pos.x;
            itempos.x += LibItem->m_Pos.x;
            itempos.y += LibItem->m_Pos.y;
            itempos.y += LibItem->m_Pos.y;
            if( ( itempos.x == pos.x ) && ( itempos.y == pos.y ) )
            if( ( itempos.x == pos.x ) && ( itempos.y == pos.y ) )
+10 −10
Original line number Original line Diff line number Diff line
@@ -417,11 +417,11 @@ void LIB_COMPONENT::RemoveDrawItem( LIB_DRAW_ITEM* aItem, WinEDA_DrawPanel* aPan
    {
    {
        LIB_FIELD* field = (LIB_FIELD*) aItem;
        LIB_FIELD* field = (LIB_FIELD*) aItem;


        if( field->m_FieldId < MANDATORY_FIELDS )
        if( field->GetId() < MANDATORY_FIELDS )
        {
        {
            wxLogWarning( _( "An attempt was made to remove the %s field \
            wxLogWarning( _( "An attempt was made to remove the %s field \
from component %s in library %s." ),
from component %s in library %s." ),
                          GetChars( field->m_Name ), GetChars( GetName() ),
                          GetChars( field->GetName() ), GetChars( GetName() ),
                          GetChars( GetLibraryName() ) );
                          GetChars( GetLibraryName() ) );
            return;
            return;
        }
        }
@@ -609,7 +609,7 @@ bool LIB_COMPONENT::Save( FILE* aFile )
        // fieldnames.
        // fieldnames.
        if( !fields[i].m_Text.IsEmpty() )
        if( !fields[i].m_Text.IsEmpty() )
        {
        {
            fields[i].m_FieldId = fieldId++;
            fields[i].SetId( fieldId++ );
            if( !fields[i].Save( aFile ) )
            if( !fields[i].Save( aFile ) )
                return false;
                return false;
        }
        }
@@ -916,9 +916,9 @@ bool LIB_COMPONENT::LoadField( char* aLine, wxString& aErrorMsg )
        return false;
        return false;
    }
    }


    if( field->m_FieldId < MANDATORY_FIELDS )
    if( field->GetId() < MANDATORY_FIELDS )
    {
    {
        LIB_FIELD* fixedField = GetField( field->m_FieldId );
        LIB_FIELD* fixedField = GetField( field->GetId() );


        // this will fire only if somebody broke a constructor or editor.
        // this will fire only if somebody broke a constructor or editor.
        // MANDATORY_FIELDS are always present in ram resident components, no
        // MANDATORY_FIELDS are always present in ram resident components, no
@@ -927,7 +927,7 @@ bool LIB_COMPONENT::LoadField( char* aLine, wxString& aErrorMsg )


        *fixedField = *field;
        *fixedField = *field;


        if( field->m_FieldId == VALUE )
        if( field->GetId() == VALUE )
            m_name = field->m_Text;
            m_name = field->m_Text;


        SAFE_DELETE( field );
        SAFE_DELETE( field );
@@ -1055,7 +1055,7 @@ void LIB_COMPONENT::GetFields( LIB_FIELD_LIST& aList )
            continue;
            continue;


        field = ( LIB_FIELD* ) &item;
        field = ( LIB_FIELD* ) &item;
        if( (unsigned) field->m_FieldId < MANDATORY_FIELDS )
        if( (unsigned) field->GetId() < MANDATORY_FIELDS )
            continue;  // was added above
            continue;  // was added above


        aList.push_back( *field );
        aList.push_back( *field );
@@ -1072,7 +1072,7 @@ LIB_FIELD* LIB_COMPONENT::GetField( int aId )


        LIB_FIELD* field = ( LIB_FIELD* ) &item;
        LIB_FIELD* field = ( LIB_FIELD* ) &item;


        if( field->m_FieldId == aId )
        if( field->GetId() == aId )
            return field;
            return field;
    }
    }


@@ -1089,7 +1089,7 @@ LIB_FIELD* LIB_COMPONENT::FindField( const wxString& aFieldName )


        LIB_FIELD* field = ( LIB_FIELD* ) &item;
        LIB_FIELD* field = ( LIB_FIELD* ) &item;


        if( field->m_Name == aFieldName )
        if( field->GetName() == aFieldName )
            return field;
            return field;
    }
    }


@@ -1262,7 +1262,7 @@ void LIB_COMPONENT::DeleteSelectedItems()
        {
        {
#if 0   // Set to 1 to allows fields deletion on block delete or other global command
#if 0   // Set to 1 to allows fields deletion on block delete or other global command
            LIB_FIELD& field = ( LIB_FIELD& ) *item;
            LIB_FIELD& field = ( LIB_FIELD& ) *item;
            if( (field.m_FieldId == REFERENCE) || (field.m_FieldId == VALUE) ||
            if( (field.GetId() == REFERENCE) || (field.m_FieldId == VALUE) ||
                (field.m_Attributs & TEXT_NO_VISIBLE) )
                (field.m_Attributs & TEXT_NO_VISIBLE) )
#endif
#endif
                item->m_Selected = 0;
                item->m_Selected = 0;
Loading