Commit d9eb15c9 authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Moved NETCLASSES to BOARD_DESIGN_SETTINGS.

Most of the changes are just adding GetDesignSettings() before every occurence of m_NetClasses.
More complex changes:
class_netclass.cpp - NETCLASS does not store the pointer to the parent BOARD anymore. Added function SetParams( BOARD_DESIGN_SETTINGS& ).
class_netclass.h - Removed GetTrackMinWidth(), GetViaMinDiameter(), GetViaMinDrill(), GetuViaMinDiameter(), GetuViaMinDrill() as they were refering to BOARD_DESIGN_SETTINGS anyway (they are not net class specific).
kicad_plugin.cpp - filters out empty nets (that are anyway not saved) when storing net class information. Previously it was done in NETCLASS::Format() function.
parent 5af454c2
Loading
Loading
Loading
Loading
+61 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include <pcbstruct.h>      // NB_COLORS
#include <class_pad.h>
#include <class_track.h>
#include <class_netclass.h>
#include <config_params.h>

/**
@@ -61,6 +62,9 @@ public:
    /// Track width list
    std::vector<int> m_TrackWidthList;

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

    bool    m_MicroViasAllowed;             ///< true to allow micro vias
    bool    m_BlindBuriedViaAllowed;        ///< true to allow blind/buried vias
    VIATYPE_T m_CurrentViaType;             ///< via type (VIA_BLIND_BURIED, VIA_THROUGH VIA_MICROVIA)
@@ -97,6 +101,56 @@ public:

    BOARD_DESIGN_SETTINGS();

    /**
     * Function SetCurrentNetClassName
     * sets the current net class name to \a aName.
     *
     * @param aName is a reference to a wxString object containing the current net class name.
     */
    void SetCurrentNetClassName( const wxString& aName ) { m_currentNetClassName = aName; }

    /**
     * Function GetCurrentNetClassName
     * @return the current net class name.
     */
    const wxString& GetCurrentNetClassName() const { return m_currentNetClassName; }

    /**
     * Function SetCurrentNetClass
     * Must be called after a netclass selection (or after a netclass parameter change
     * Initialize vias and tracks values displayed in comb boxes of the auxiliary toolbar
     * and some others parameters (netclass name ....)
     * @param aNetClassName = the new netclass name
     * @return true if lists of tracks and vias sizes are modified
     */
    bool SetCurrentNetClass( const wxString& aNetClassName );

    /**
     * Function GetBiggestClearanceValue
     * @return the biggest clearance value found in NetClasses list
     */
    int GetBiggestClearanceValue();

    /**
     * Function GetSmallestClearanceValue
     * @return the smallest clearance value found in NetClasses list
     */
    int GetSmallestClearanceValue();

    /**
     * Function GetCurrentMicroViaSize
     * @return the current micro via size,
     * that is the current netclass value
     */
    int GetCurrentMicroViaSize();

    /**
     * Function GetCurrentMicroViaDrill
     * @return the current micro via drill,
     * that is the current netclass value
     */
    int GetCurrentMicroViaDrill();

    /**
     * Function GetTrackWidthIndex
     * @return the current track width list index.
@@ -413,6 +467,13 @@ private:
    LAYER_MSK m_visibleLayers;      ///< Bit-mask for layer visibility
    int       m_visibleElements;    ///< Bit-mask for element category visibility
    int       m_boardThickness;     ///< Board thickness for 3D viewer

    /// Current net class name used to display netclass info.
    /// This is also the last used netclass after starting a track.
    wxString  m_currentNetClassName;

    void formatNetClass( NETCLASS* aNetClass, OUTPUTFORMATTER* aFormatter, int aNestLevel,
                         int aControlBits ) const throw( IO_ERROR );
};

#endif  // BOARD_DESIGN_SETTINGS_H_
+1 −1
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ void PlaceCells( BOARD* aPcb, int net_code, int flag )
    LAYER_MSK layerMask;

    // use the default NETCLASS?
    NETCLASS* nc = aPcb->m_NetClasses.GetDefault();
    NETCLASS* nc = aPcb->GetDesignSettings().m_NetClasses.GetDefault();

    int       trackWidth = nc->GetTrackWidth();
    int       clearance  = nc->GetClearance();
+1 −1
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int aLayersCount )

    m_canvas->SetAbortRequest( false );

    s_Clearance = GetBoard()->m_NetClasses.GetDefault()->GetClearance();
    s_Clearance = GetBoard()->GetDesignSettings().m_NetClasses.GetDefault()->GetClearance();

    // Prepare the undo command info
    s_ItemsListPicker.ClearListAndDeleteItems();  // Should not be necessary, but...
+5 −107
Original line number Diff line number Diff line
@@ -66,8 +66,7 @@ wxPoint BOARD_ITEM::ZeroOffset( 0, 0 );
BOARD::BOARD() :
    BOARD_ITEM( (BOARD_ITEM*) NULL, PCB_T ),
    m_NetInfo( this ),
    m_paper( PAGE_INFO::A4 ),
    m_NetClasses( this )
    m_paper( PAGE_INFO::A4 )
{
    // we have not loaded a board yet, assume latest until then.
    m_fileFormatVersionAtLoad = LEGACY_BOARD_FILE_VERSION;
@@ -92,19 +91,12 @@ BOARD::BOARD() :
            m_Layer[layer].m_Type = LT_UNDEFINED;
    }

    m_NetClasses.GetDefault()->SetDescription( _( "This is the default net class." ) );
    NETCLASS* defaultClass = m_designSettings.m_NetClasses.GetDefault();
    defaultClass->SetDescription( _( "This is the default net class." ) );

    m_designSettings.SetViaSizeIndex( 0 );
    m_designSettings.SetTrackWidthIndex( 0 );

    /*  Dick 5-Feb-2012: this seems unnecessary.  I don't believe the comment
        near line 70 of class_netclass.cpp.  I stepped through with debugger.
        Perhaps something else is at work, it is not a constructor race.
    // Initialize default values in default netclass.
    */
    m_NetClasses.GetDefault()->SetParams();

    SetCurrentNetClass( m_NetClasses.GetDefault()->GetName() );
    defaultClass->SetParams( m_designSettings );
    m_designSettings.SetCurrentNetClass( defaultClass->GetName() );

    // Set sensible initial values for custom track width & via size
    m_designSettings.UseCustomTrackViaSize( false );
@@ -319,100 +311,6 @@ void BOARD::PopHighLight()
}


bool BOARD::SetCurrentNetClass( const wxString& aNetClassName )
{
    NETCLASS* netClass = m_NetClasses.Find( aNetClassName );
    bool      lists_sizes_modified = false;

    // if not found (should not happen) use the default
    if( netClass == NULL )
        netClass = m_NetClasses.GetDefault();

    m_currentNetClassName = netClass->GetName();

    // Initialize others values:
    if( m_designSettings.m_ViasDimensionsList.size() == 0 )
    {
        VIA_DIMENSION viadim;
        lists_sizes_modified = true;
        m_designSettings.m_ViasDimensionsList.push_back( viadim );
    }

    if( m_designSettings.m_TrackWidthList.size() == 0 )
    {
        lists_sizes_modified = true;
        m_designSettings.m_TrackWidthList.push_back( 0 );
    }

    /* note the m_ViasDimensionsList[0] and m_TrackWidthList[0] values
     * are always the Netclass values
     */
    if( m_designSettings.m_ViasDimensionsList[0].m_Diameter != netClass->GetViaDiameter() )
        lists_sizes_modified = true;

    m_designSettings.m_ViasDimensionsList[0].m_Diameter = netClass->GetViaDiameter();

    if( m_designSettings.m_TrackWidthList[0] != netClass->GetTrackWidth() )
        lists_sizes_modified = true;

    m_designSettings.m_TrackWidthList[0] = netClass->GetTrackWidth();

    if( m_designSettings.GetViaSizeIndex() >= m_designSettings.m_ViasDimensionsList.size() )
        m_designSettings.SetViaSizeIndex( m_designSettings.m_ViasDimensionsList.size() );

    if( m_designSettings.GetTrackWidthIndex() >= m_designSettings.m_TrackWidthList.size() )
        m_designSettings.SetTrackWidthIndex( m_designSettings.m_TrackWidthList.size() );

    return lists_sizes_modified;
}


int BOARD::GetBiggestClearanceValue()
{
    int clearance = m_NetClasses.GetDefault()->GetClearance();

    //Read list of Net Classes
    for( NETCLASSES::const_iterator nc = m_NetClasses.begin(); nc != m_NetClasses.end(); nc++ )
    {
        NETCLASS* netclass = nc->second;
        clearance = std::max( clearance, netclass->GetClearance() );
    }

    return clearance;
}


int BOARD::GetSmallestClearanceValue()
{
    int clearance = m_NetClasses.GetDefault()->GetClearance();

    //Read list of Net Classes
    for( NETCLASSES::const_iterator nc = m_NetClasses.begin(); nc != m_NetClasses.end(); nc++ )
    {
        NETCLASS* netclass = nc->second;
        clearance = std::min( clearance, netclass->GetClearance() );
    }

    return clearance;
}


int BOARD::GetCurrentMicroViaSize()
{
    NETCLASS* netclass = m_NetClasses.Find( m_currentNetClassName );

    return netclass->GetuViaDiameter();
}


int BOARD::GetCurrentMicroViaDrill()
{
    NETCLASS* netclass = m_NetClasses.Find( m_currentNetClassName );

    return netclass->GetuViaDrill();
}


bool BOARD::SetLayer( LAYER_NUM aIndex, const LAYER& aLayer )
{
    if( aIndex < NB_COPPER_LAYERS )
+0 −65
Original line number Diff line number Diff line
@@ -208,10 +208,6 @@ private:
    /// Number of unconnected nets in the current rats nest.
    int                     m_unconnectedNetCount;

    /// Current net class name used to display netclass info.
    /// This is also the last used netclass after starting a track.
    wxString                m_currentNetClassName;

    /**
     * Function chainMarkedSegments
     * is used by MarkTrace() to set the BUSY flag of connected segments of the trace
@@ -223,10 +219,6 @@ private:
     */
    void chainMarkedSegments( wxPoint aPosition, LAYER_MSK aLayerMask, TRACK_PTRS* aList );

    void formatNetClass( NETCLASS* aNetClass, OUTPUTFORMATTER* aFormatter, int aNestLevel,
                         int aControlBits ) const
        throw( IO_ERROR );

public:

    void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
@@ -250,9 +242,6 @@ public:
    /// zone contour currently in progress
    ZONE_CONTAINER*             m_CurrentZoneContour;

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

    BOARD();
    ~BOARD();

@@ -742,20 +731,6 @@ public:
     */
    void SetUnconnectedNetCount( unsigned aCount ) { m_unconnectedNetCount = aCount; }

    /**
     * Function SetCurrentNetClassName
     * sets the current net class name to \a aName.
     *
     * @param aName is a reference to a wxString object containing the current net class name.
     */
    void SetCurrentNetClassName( const wxString& aName ) { m_currentNetClassName = aName; }

    /**
     * Function GetCurrentNetClassName
     * @return the current net class name.
     */
    const wxString& GetCurrentNetClassName() const { return m_currentNetClassName; }

    /**
     * Function GetPadCount
     * @return the number of pads in board
@@ -964,10 +939,6 @@ public:
     */
    int SortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount );

    /**************************************
     * Functions related to NetClasses:
     **************************************/

    /**
     * Function SynchronizeNetsAndNetClasses
     * copies NETCLASS info to each NET, based on NET membership in a NETCLASS.
@@ -977,42 +948,6 @@ public:
     */
    void SynchronizeNetsAndNetClasses();

    /**
     * Function SetCurrentNetClass
     * Must be called after a netclass selection (or after a netclass parameter change
     * Initialize vias and tracks values displayed in comb boxes of the auxiliary toolbar
     * and some others parameters (netclass name ....)
     * @param aNetClassName = the new netclass name
     * @return true if lists of tracks and vias sizes are modified
     */
    bool SetCurrentNetClass( const wxString& aNetClassName );

    /**
     * Function GetBiggestClearanceValue
     * @return the biggest clearance value found in NetClasses list
     */
    int GetBiggestClearanceValue();

    /**
     * Function GetSmallestClearanceValue
     * @return the smallest clearance value found in NetClasses list
     */
    int GetSmallestClearanceValue();

    /**
     * Function GetCurrentMicroViaSize
     * @return the current micro via size,
     * that is the current netclass value
     */
    int  GetCurrentMicroViaSize();

    /**
     * Function GetCurrentMicroViaDrill
     * @return the current micro via drill,
     * that is the current netclass value
     */
    int  GetCurrentMicroViaDrill();

    /***************************************************************************/

    wxString GetClass() const
Loading