Commit 85dc98a5 authored by dickelbeck's avatar dickelbeck
Browse files

more netclass work

parent f9f671d1
Loading
Loading
Loading
Loading
+18 −0
Original line number Original line Diff line number Diff line
@@ -4,6 +4,24 @@ KiCad ChangeLog 2009
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.


2009-Aug-16 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++pcbnew
  * first of my work on NETCLASSes, more to come.
    wrote: BOARD* BOARD_ITEM::GetBoard(), int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* ),
    rewrote: classes NETCLASS, NETCLASSES, BOARD::SynchronizeNetsAndNetClasses(),
    added: NETCLASS::m_ViaDrillSize, NETCLASS::m_Description.  Removed netname from
    EQUIPOTs in *.brd file (were redundant with NETCLASSes in *.brd file).  NETCLASSes
    now follow EQUIPOTs in *.brd file.
    NETs and NETCLASSes are linked by pointer from class NET.
    BOARD::SynchronizeNetsAndNetClasses() will validate pointers, NETs and NETCLASSes.
  * Pay particular attention to the new:
    int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
    which considers two netclasses and finds the largest distance from the two
    involved.
  * I would love to see class NETINFO_ITEM renamed to NET.


2009-Aug-6 UPDATE Dick Hollenbeck <dick@softplc.com>
2009-Aug-6 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
================================================================================
++pcbnew
++pcbnew
+23 −0
Original line number Original line Diff line number Diff line
@@ -189,6 +189,7 @@ public:
    {
    {
        wxMessageBox(wxT("virtual BOARD_ITEM::Move used, should not occur"), GetClass());
        wxMessageBox(wxT("virtual BOARD_ITEM::Move used, should not occur"), GetClass());
    }
    }

    /**
    /**
     * Function Rotate
     * Function Rotate
     * Rotate this object.
     * Rotate this object.
@@ -199,6 +200,7 @@ public:
    {
    {
        wxMessageBox(wxT("virtual BOARD_ITEM::Rotate used, should not occur"), GetClass());
        wxMessageBox(wxT("virtual BOARD_ITEM::Rotate used, should not occur"), GetClass());
    }
    }

    /**
    /**
     * Function Flip
     * Function Flip
     * Flip this object, i.e. change the board side for this object
     * Flip this object, i.e. change the board side for this object
@@ -208,8 +210,16 @@ public:
    {
    {
        wxMessageBox(wxT("virtual BOARD_ITEM::Flip used, should not occur"), GetClass());
        wxMessageBox(wxT("virtual BOARD_ITEM::Flip used, should not occur"), GetClass());
    }
    }


    /**
     * Function GetBoard
     * returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
     */
    virtual BOARD* GetBoard() const;
};
};


class NETCLASS;


/**
/**
 * Class BOARD_CONNECTED_ITEM
 * Class BOARD_CONNECTED_ITEM
@@ -253,6 +263,19 @@ public:
     */
     */
    int GetZoneSubNet() const;
    int GetZoneSubNet() const;
    void SetZoneSubNet( int aSubNetCode );
    void SetZoneSubNet( int aSubNetCode );


    /**
     * Function GetClearance
     * returns the clearance in 1/10000 inches to aItem from this BOARD_CONNECTED_ITEM.
     */
     virtual int GetClearance( BOARD_CONNECTED_ITEM* aItem ) const;

     /**
      * Function GetNetClass
      * returns the NETCLASS for this item.
      */
     virtual NETCLASS* GetNetClass() const;
};
};




+11 −15
Original line number Original line Diff line number Diff line
@@ -20,7 +20,7 @@ wxPoint BOARD_ITEM::ZeroOffset( 0, 0 );
/* Constructor */
/* Constructor */
BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) :
BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) :
    BOARD_ITEM( (BOARD_ITEM*)parent, TYPE_PCB ),
    BOARD_ITEM( (BOARD_ITEM*)parent, TYPE_PCB ),
    m_NetClassesList(this)
    m_NetClasses(this)
{
{
    m_PcbFrame = frame;
    m_PcbFrame = frame;
    m_Status_Pcb    = 0;                        // Mot d'etat: Bit 1 = Chevelu calcule
    m_Status_Pcb    = 0;                        // Mot d'etat: Bit 1 = Chevelu calcule
@@ -37,10 +37,6 @@ BOARD::BOARD( EDA_BaseStruct* parent, WinEDA_BasePcbFrame* frame ) :
        m_Layer[layer].m_Name = ReturnPcbLayerName( layer, true );
        m_Layer[layer].m_Name = ReturnPcbLayerName( layer, true );
        m_Layer[layer].m_Type = LT_SIGNAL;
        m_Layer[layer].m_Type = LT_SIGNAL;
    }
    }

    // Add the default Netclass to list
    NETCLASS * default_netclass = new NETCLASS(this);
    m_NetClassesList.AddNetclass( default_netclass );
}
}




@@ -538,7 +534,7 @@ void BOARD::DisplayInfo( WinEDA_DrawFrame* frame )
    txt.Printf( wxT( "%d" ), GetNodesCount() );
    txt.Printf( wxT( "%d" ), GetNodesCount() );
    Affiche_1_Parametre( frame, POS_AFF_NBNODES, _( "Nodes" ), txt, DARKCYAN );
    Affiche_1_Parametre( frame, POS_AFF_NBNODES, _( "Nodes" ), txt, DARKCYAN );


    txt.Printf( wxT( "%d" ), m_NetInfo->GetNetsCount() );
    txt.Printf( wxT( "%d" ), m_NetInfo->GetCount() );
    Affiche_1_Parametre( frame, POS_AFF_NBNETS, _( "Nets" ), txt, RED );
    Affiche_1_Parametre( frame, POS_AFF_NBNETS, _( "Nets" ), txt, RED );


    /* These parameters are known only if the full ratsnest is available,
    /* These parameters are known only if the full ratsnest is available,
@@ -822,7 +818,7 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
 */
 */
NETINFO_ITEM* BOARD::FindNet( int anetcode ) const
NETINFO_ITEM* BOARD::FindNet( int anetcode ) const
{
{
    // the first valid netcode is 1 and the last is m_NetInfo->GetNetsCount()-1.
    // the first valid netcode is 1 and the last is m_NetInfo->GetCount()-1.
    // zero is reserved for "no connection" and is not used.
    // zero is reserved for "no connection" and is not used.
    // NULL is returned for non valid netcodes
    // NULL is returned for non valid netcodes
    NETINFO_ITEM* item = m_NetInfo->GetNetItem( anetcode );
    NETINFO_ITEM* item = m_NetInfo->GetNetItem( anetcode );
@@ -850,7 +846,7 @@ NETINFO_ITEM* BOARD::FindNet( const wxString& aNetname ) const
    // zero is reserved for "no connection" and is not used.
    // zero is reserved for "no connection" and is not used.
    if( !aNetname.IsEmpty() )
    if( !aNetname.IsEmpty() )
    {
    {
        for( unsigned ii = 1;  ii <  m_NetInfo->GetNetsCount();  ii++ )
        for( unsigned ii = 1;  ii <  m_NetInfo->GetCount();  ii++ )
        {
        {
            NETINFO_ITEM* item = m_NetInfo->GetNetItem( ii );
            NETINFO_ITEM* item = m_NetInfo->GetNetItem( ii );
            if( item && item->GetNetname() == aNetname )
            if( item && item->GetNetname() == aNetname )
@@ -909,15 +905,15 @@ static bool s_SortByNodes( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
 */
 */
int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount )
int BOARD::ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount )
{
{
    if( m_NetInfo->GetNetsCount() == 0 )
    if( m_NetInfo->GetCount() == 0 )
        return 0;
        return 0;


    // Build the list
    // Build the list
    std::vector <NETINFO_ITEM*> netBuffer;
    std::vector <NETINFO_ITEM*> netBuffer;


    netBuffer.reserve( m_NetInfo->GetNetsCount() );
    netBuffer.reserve( m_NetInfo->GetCount() );


    for( unsigned ii = 1; ii < m_NetInfo->GetNetsCount(); ii++ )
    for( unsigned ii = 1; ii < m_NetInfo->GetCount(); ii++ )
    {
    {
        if( m_NetInfo->GetNetItem( ii )->GetNet() > 0 )
        if( m_NetInfo->GetNetItem( ii )->GetNet() > 0 )
            netBuffer.push_back( m_NetInfo->GetNetItem( ii ) );
            netBuffer.push_back( m_NetInfo->GetNetItem( ii ) );
@@ -941,14 +937,14 @@ bool BOARD::Save( FILE* aFile ) const
    bool        rc = false;
    bool        rc = false;
    BOARD_ITEM* item;
    BOARD_ITEM* item;


    // save the netclasses
    m_NetClassesList.Save( aFile );

    // save the nets
    // save the nets
    for( unsigned ii = 0; ii < m_NetInfo->GetNetsCount(); ii++ )
    for( unsigned ii = 0; ii < m_NetInfo->GetCount(); ii++ )
        if( !m_NetInfo->GetNetItem( ii )->Save( aFile ) )
        if( !m_NetInfo->GetNetItem( ii )->Save( aFile ) )
            goto out;
            goto out;


    // Saved nets do not include netclass names, so save netclasses after nets.
    m_NetClasses.Save( aFile );

    // save the modules
    // save the modules
    for( item = m_Modules;  item;  item = item->Next() )
    for( item = m_Modules;  item;  item = item->Next() )
        if( !item->Save( aFile ) )
        if( !item->Save( aFile ) )
+4 −4
Original line number Original line Diff line number Diff line
@@ -97,7 +97,7 @@ public:
    std::vector<RATSNEST_ITEM> m_LocalRatsnest;             /* Rastnest list relative to a given footprint
    std::vector<RATSNEST_ITEM> m_LocalRatsnest;             /* Rastnest list relative to a given footprint
                                                             *  (used while moving a footprint) */
                                                             *  (used while moving a footprint) */


    NETCLASS_LIST               m_NetClassesList;           // List of current netclasses. There is always the default netclass
    NETCLASSES                 m_NetClasses;                ///< List of current netclasses. There is always the default netclass


    ZONE_CONTAINER*             m_CurrentZoneContour;       // zone contour currently in progress
    ZONE_CONTAINER*             m_CurrentZoneContour;       // zone contour currently in progress


@@ -338,15 +338,15 @@ public:
    int           ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount );
    int           ReturnSortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount );


    /**
    /**
     * Function TransfertDesignRulesToNets
     * Function SynchronizeNetsAndNetClasses
     * copies Netclass parameters to each net, corresponding to its net class.
     * copies NETCLASS info to each NET, based on NET membership in a NETCLASS.
     * Must be called after a Design Rules edition, or after reading a netlist (or editing the list of nets)
     * Must be called after a Design Rules edition, or after reading a netlist (or editing the list of nets)
     * Also this function removes the non existing nets in netclasses and add net nets in default netclass
     * Also this function removes the non existing nets in netclasses and add net nets in default netclass
     * (this happens after reading a netlist)
     * (this happens after reading a netlist)
     * @param none
     * @param none
     * @return none
     * @return none
     */
     */
    void           TransfertDesignRulesToNets();
    void            SynchronizeNetsAndNetClasses();


    /**
    /**
     * Function Save
     * Function Save
+47 −0
Original line number Original line Diff line number Diff line
@@ -68,3 +68,50 @@ void BOARD_CONNECTED_ITEM::SetZoneSubNet( int aSubNetCode )
{
{
    m_ZoneSubnet = aSubNetCode;
    m_ZoneSubnet = aSubNetCode;
}
}


int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
{
    NETCLASS*   hisclass = aItem->GetNetClass();
    NETCLASS*   myclass  = GetNetClass();

    wxASSERT( hisclass );
    wxASSERT( myclass );

    if( myclass )
    {
        if( hisclass )
            return MAX( hisclass->GetClearance(), myclass->GetClearance() );
        else
            return myclass->GetClearance();
    }
    else if( hisclass )
    {
        return hisclass->GetClearance();
    }

    return 0;
}


NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
{
    // It is important that this be implemented without any sequential searching.
    // Simple array lookups should be fine, performance-wise.

    BOARD*  board = GetBoard();
    wxASSERT( board );
    if( board )
    {
        NETINFO_ITEM* net = board->FindNet( GetNet() );
        wxASSERT( net );
        if( net )
        {
            NETCLASS* netclass = net->GetNetClass();
            wxASSERT( netclass );
            return netclass;
        }
    }

    return NULL;
}
Loading