Commit 654e7e55 authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Removed D_PAD::SetNetname() function and D_PAD::m_Netname, D_PAD::m_ShortNetname fields.

D_PAD::GetNetname() and D_PAD::GetShortNetname() were moved to BOARD_CONNECTED_ITEM. Now they use the net name stored in NETINFO_ITEM.
Moved some one-line functions from class_board_connected_item.cpp to class_board_connected_item.h.
Added a copyright notice, moved Doxygen comments from class_board_connected_item.cpp to class_board_connected_item.h.

I have some doubts if changes introduced pcbnew/dialogs/dialog_pad_properties.cpp do not break anything, but I could not find a test case that breaks the pcbnew.

Performed tests:
- changed pad's net name from empty to existent - ok, name was changed
- changed pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty
- changed pad's net name from existent to empty - ok, net name became empty
- changed pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed
- (re)reading netlists, including net changes - fine, changes are applied, but empty nets are still kept
- loaded pcbnew/pcad2kicadpcb_plugin/examples/CK1202_V1.pcb to test P-CAD import plugin - ok, net names are correct
- imported an Eagle 6.0 board (Arduino Uno; http://arduino.cc/en/uploads/Main/arduino_Uno_Rev3-02-TH.zip) then saved in .kicad_pcb format and reloaded - ok, net names are correct
- saved demos/video/video.kicad_pcb in legacy format and then loaded it again - ok, net names are correct
parent bf80cc77
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -2546,12 +2546,9 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
                    }

                    if( !aNetlist.IsDryRun() )
                    {
                        pad->SetNetname( wxEmptyString );
                        pad->SetNet( 0 );
                }
            }
            }
            else                                 // Footprint pad has a net.
            {
                if( net.GetNetName() != pad->GetNetname() )
@@ -2570,8 +2567,6 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,

                    if( !aNetlist.IsDryRun() )
                    {
                        pad->SetNetname( net.GetNetName() );

                        NETINFO_ITEM* netinfo = FindNet( net.GetNetName() );
                        if( netinfo == NULL )
                        {
@@ -2653,7 +2648,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
                                    GetChars( previouspad->GetPadName() ) );
                        aReporter->Report( msg );
                    }
                    previouspad->SetNetname( wxEmptyString );

                    previouspad->SetNet( 0 );
                }
                netname = pad->GetNetname();
@@ -2667,11 +2662,8 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,

        // Examine last pad
        if( pad && count == 1 )
        {
            pad->SetNetname( wxEmptyString );
            pad->SetNet( 0 );
    }
    }

    // Last step: Some tests:
    // verify all pads found in netlist:
+16 −60
Original line number Diff line number Diff line
/**
 * @file class_board_connected_item.cpp
 * @brief BOARD_CONNECTED_ITEM class functions.
 */

/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
@@ -28,6 +23,11 @@
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */

/**
 * @file class_board_connected_item.cpp
 * @brief BOARD_CONNECTED_ITEM class functions.
 */

#include <fctsys.h>
#include <pcbnew.h>

@@ -36,68 +36,32 @@


BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) :
    BOARD_ITEM( aParent, idtype )
    BOARD_ITEM( aParent, idtype ), m_NetCode( 0 ), m_Subnet( 0 ), m_ZoneSubnet( 0 )
{
    m_NetCode    = 0;
    m_Subnet     = 0;
    m_ZoneSubnet = 0;
}


BOARD_CONNECTED_ITEM::BOARD_CONNECTED_ITEM( const BOARD_CONNECTED_ITEM& aItem ) :
    BOARD_ITEM( aItem )
    BOARD_ITEM( aItem ), m_NetCode( aItem.m_NetCode ), m_Subnet( aItem.m_Subnet ),
    m_ZoneSubnet( aItem.m_ZoneSubnet )
{
    m_NetCode = aItem.m_NetCode;
    m_Subnet = aItem.m_Subnet;
    m_ZoneSubnet = aItem.m_ZoneSubnet;
}


/**
 * Function GetNet
 * @return int - the net code.
 */
int BOARD_CONNECTED_ITEM::GetNet() const
const wxString& BOARD_CONNECTED_ITEM::GetNetname() const
{
    return m_NetCode;
}


void BOARD_CONNECTED_ITEM::SetNet( int aNetCode )
{
    m_NetCode = aNetCode;
}

    BOARD* board = GetBoard();
    NETINFO_ITEM* netinfo = board->FindNet( m_NetCode );

/**
 * Function GetSubNet
 * @return int - the sub net code.
 */
int BOARD_CONNECTED_ITEM::GetSubNet() const
{
    return m_Subnet;
    return netinfo->GetNetname();
}


void BOARD_CONNECTED_ITEM::SetSubNet( int aSubNetCode )
const wxString& BOARD_CONNECTED_ITEM::GetShortNetname() const
{
    m_Subnet = aSubNetCode;
}
    NETINFO_ITEM* netinfo = GetBoard()->FindNet( m_NetCode );


/**
 * Function GetZoneSubNet
 * @return int - the sub net code in zone connections.
 */
int BOARD_CONNECTED_ITEM::GetZoneSubNet() const
{
    return m_ZoneSubnet;
}


void BOARD_CONNECTED_ITEM::SetZoneSubNet( int aSubNetCode )
{
    m_ZoneSubnet = aSubNetCode;
    return netinfo->GetShortNetname();
}


@@ -132,11 +96,6 @@ int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
}


/** return a pointer to the netclass of the zone
 * if the net is not found (can happen when a netlist is reread,
 * and the net name is not existant, return the default net class
 * So should not return a null pointer
 */
NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
{
    // It is important that this be implemented without any sequential searching.
@@ -176,10 +135,7 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
        return board->m_NetClasses.GetDefault();
}

/**
 * Function GetNetClassName
 * @return the Net Class name of this item
 */

wxString BOARD_CONNECTED_ITEM::GetNetClassName() const
{
    wxString    name;
+68 −7
Original line number Diff line number Diff line
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
 * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you may find one here:
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * or you may search the http://www.gnu.org website for the version 2 license,
 * or you may write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */

/**
 * @file  class_board_connected_item.h
 * @brief Class BOARD_CONNECTED_ITEM.
@@ -6,7 +31,6 @@
#ifndef BOARD_CONNECTED_ITEM_H
#define BOARD_CONNECTED_ITEM_H


#include <class_board_item.h>

class NETCLASS;
@@ -48,22 +72,55 @@ public:
     * Function GetNet
     * @return int - the net code.
     */
    int GetNet() const;
    virtual void SetNet( int aNetCode );
    int GetNet() const
    {
        return m_NetCode;
    }

    virtual void SetNet( int aNetCode )
    {
        m_NetCode = aNetCode;
    }

    /**
     * Function GetSubNet
     * @return int - the sub net code.
     */
    int GetSubNet() const;
    void SetSubNet( int aSubNetCode );
    int GetSubNet() const
    {
        return m_Subnet;
    }

    void SetSubNet( int aSubNetCode )
    {
        m_Subnet = aSubNetCode;
    }

    /**
     * Function GetZoneSubNet
     * @return int - the sub net code in zone connections.
     */
    int GetZoneSubNet() const;
    void SetZoneSubNet( int aSubNetCode );
    int GetZoneSubNet() const
    {
        return m_ZoneSubnet;
    }

    void SetZoneSubNet( int aSubNetCode )
    {
        m_ZoneSubnet = aSubNetCode;
    }

    /**
     * Function GetNetname
     * @return const wxString& - the full netname
     */
    const wxString& GetNetname() const;

    /**
     * Function GetShortNetname
     * @return const wxString& - the short netname
     */
    const wxString& GetShortNetname() const;

    /**
     * Function GetClearance
@@ -84,6 +141,10 @@ public:

    /**
     * Function GetNetClassName
     * returns a pointer to the netclass of the zone.
     * If the net is not found (can happen when a netlist is reread,
     * and the net name does not exist, return the default net class
     * (should not return a null pointer).
     * @return the Net Class name of this item
     */
    wxString GetNetClassName() const;
+1 −11
Original line number Diff line number Diff line
@@ -364,13 +364,6 @@ void D_PAD::SetPadName( const wxString& name )
}


void D_PAD::SetNetname( const wxString& aNetname )
{
    m_Netname = aNetname;
    m_ShortNetname = m_Netname.AfterLast( '/' );
}


void D_PAD::Copy( D_PAD* source )
{
    if( source == NULL )
@@ -402,8 +395,6 @@ void D_PAD::Copy( D_PAD* source )

    SetSubRatsnest( 0 );
    SetSubNet( 0 );
    m_Netname = source->m_Netname;
    m_ShortNetname = source->m_ShortNetname;
}


@@ -412,7 +403,6 @@ void D_PAD::CopyNetlistSettings( D_PAD* aPad )
    // Don't do anything foolish like trying to copy to yourself.
    wxCHECK_RET( aPad != NULL && aPad != this, wxT( "Cannot copy to NULL or yourself." ) );

    aPad->SetNetname( GetNetname() );
    aPad->SetNet( GetNet() );

    aPad->SetLocalClearance( m_LocalClearance );
@@ -578,7 +568,7 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList )
        aList.push_back( MSG_PANEL_ITEM( _( "Pad" ), Line, BROWN ) );
    }

    aList.push_back( MSG_PANEL_ITEM( _( "Net" ), m_Netname, DARKCYAN ) );
    aList.push_back( MSG_PANEL_ITEM( _( "Net" ), GetNetname(), DARKCYAN ) );

    /* For test and debug only: display m_physical_connexion and
     * m_logical_connexion */
+0 −28
Original line number Diff line number Diff line
@@ -118,30 +118,6 @@ public:
        return m_NumPadName == other->m_NumPadName; // hide tricks behind sensible API
    }

    /**
     * Function SetNetname
     * @param aNetname: the new netname
     */
    void SetNetname( const wxString& aNetname );

    /**
     * Function GetNetname
     * @return const wxString& - the full netname
     */
    const wxString& GetNetname() const
    {
        assert( ( GetNet() == 0 ) == m_Netname.IsEmpty() );
        // assert( GetBoard()->FindNet( GetNet() ) == GetBoard()->FindNet( m_Netname ) );

        return m_Netname;
    }

    /**
     * Function GetShortNetname
     * @return const wxString& - the short netname
     */
    const wxString& GetShortNetname() const { return m_ShortNetname; }

    /**
     * Function GetShape
     * @return the shape of this pad.
@@ -475,10 +451,6 @@ private:

    int         m_boundingRadius;  ///< radius of the circle containing the pad shape


    wxString    m_Netname;         ///< Full net name like /mysheet/mysubsheet/vout used by Eeschema
    wxString    m_ShortNetname;    ///< short net name, like vout from /mysheet/mysubsheet/vout

    /// Pad name (4 char) or a long identifier (used in pad name
    /// comparisons because this is faster than string comparison)
    union
Loading