Commit 8a5ea7ec authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Pcbnew BOARD object encapsulation improvements.

parent 8b6d5cb4
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -365,7 +365,7 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int aLayersCount )
        AppendMsgPanel( wxT( "Ok" ), msg, GREEN );
        AppendMsgPanel( wxT( "Ok" ), msg, GREEN );
        msg.Printf( wxT( "%d" ), nbunsucces );
        msg.Printf( wxT( "%d" ), nbunsucces );
        AppendMsgPanel( wxT( "Fail" ), msg, RED );
        AppendMsgPanel( wxT( "Fail" ), msg, RED );
        msg.Printf( wxT( "  %d" ), GetBoard()->m_NbNoconnect );
        msg.Printf( wxT( "  %d" ), GetBoard()->GetUnconnectedNetCount() );
        AppendMsgPanel( wxT( "Not Connected" ), msg, CYAN );
        AppendMsgPanel( wxT( "Not Connected" ), msg, CYAN );


        /* Delete routing from display. */
        /* Delete routing from display. */
+32 −20
Original line number Original line Diff line number Diff line
@@ -66,8 +66,8 @@ BOARD::BOARD() :


    m_Status_Pcb    = 0;                    // Status word: bit 1 = calculate.
    m_Status_Pcb    = 0;                    // Status word: bit 1 = calculate.
    SetColorsSettings( &g_ColorsSettings );
    SetColorsSettings( &g_ColorsSettings );
    m_NbNodes     = 0;                      // Number of connected pads.
    m_nodeCount     = 0;                    // Number of connected pads.
    m_NbNoconnect = 0;                      // Number of unconnected nets.
    m_unconnectedNetCount   = 0;            // Number of unconnected nets.


    m_CurrentZoneContour = NULL;            // This ZONE_CONTAINER handle the
    m_CurrentZoneContour = NULL;            // This ZONE_CONTAINER handle the
                                            // zone contour currently in progress
                                            // zone contour currently in progress
@@ -86,8 +86,8 @@ BOARD::BOARD() :


    m_NetClasses.GetDefault()->SetDescription( _( "This is the default net class." ) );
    m_NetClasses.GetDefault()->SetDescription( _( "This is the default net class." ) );


    m_ViaSizeSelector    = 0;
    m_viaSizeIndex    = 0;
    m_TrackWidthSelector = 0;
    m_trackWidthIndex = 0;


    /*  Dick 5-Feb-2012: this seems unnecessary.  I don't believe the comment
    /*  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.
        near line 70 of class_netclass.cpp.  I stepped through with debugger.
@@ -258,7 +258,7 @@ bool BOARD::SetCurrentNetClass( const wxString& aNetClassName )
    if( netClass == NULL )
    if( netClass == NULL )
        netClass = m_NetClasses.GetDefault();
        netClass = m_NetClasses.GetDefault();


    m_CurrentNetClassName = netClass->GetName();
    m_currentNetClassName = netClass->GetName();


    // Initialize others values:
    // Initialize others values:
    if( m_ViasDimensionsList.size() == 0 )
    if( m_ViasDimensionsList.size() == 0 )
@@ -287,11 +287,11 @@ bool BOARD::SetCurrentNetClass( const wxString& aNetClassName )


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


    if( m_ViaSizeSelector >= m_ViasDimensionsList.size() )
    if( m_viaSizeIndex >= m_ViasDimensionsList.size() )
        m_ViaSizeSelector = m_ViasDimensionsList.size();
        m_viaSizeIndex = m_ViasDimensionsList.size();


    if( m_TrackWidthSelector >= m_TrackWidthList.size() )
    if( m_trackWidthIndex >= m_TrackWidthList.size() )
        m_TrackWidthSelector = m_TrackWidthList.size();
        m_trackWidthIndex = m_TrackWidthList.size();


    return lists_sizes_modified;
    return lists_sizes_modified;
}
}
@@ -329,7 +329,7 @@ int BOARD::GetSmallestClearanceValue()


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


    return netclass->GetuViaDiameter();
    return netclass->GetuViaDiameter();
}
}
@@ -337,7 +337,7 @@ int BOARD::GetCurrentMicroViaSize()


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


    return netclass->GetuViaDrill();
    return netclass->GetuViaDrill();
}
}
@@ -925,15 +925,9 @@ int BOARD::GetNumSegmZone() const
}
}




unsigned BOARD::GetNoconnectCount() const
{
    return m_NbNoconnect;
}


unsigned BOARD::GetNodesCount() const
unsigned BOARD::GetNodesCount() const
{
{
    return m_NbNodes;
    return m_nodeCount;
}
}




@@ -1053,10 +1047,10 @@ void BOARD::DisplayInfo( EDA_DRAW_FRAME* frame )
        txt.Printf( wxT( "%d" ), GetRatsnestsCount() );
        txt.Printf( wxT( "%d" ), GetRatsnestsCount() );
        frame->AppendMsgPanel( _( "Links" ), txt, DARKGREEN );
        frame->AppendMsgPanel( _( "Links" ), txt, DARKGREEN );


        txt.Printf( wxT( "%d" ), GetRatsnestsCount() - GetNoconnectCount() );
        txt.Printf( wxT( "%d" ), GetRatsnestsCount() - GetUnconnectedNetCount() );
        frame->AppendMsgPanel( _( "Connect" ), txt, DARKGREEN );
        frame->AppendMsgPanel( _( "Connect" ), txt, DARKGREEN );


        txt.Printf( wxT( "%d" ), GetNoconnectCount() );
        txt.Printf( wxT( "%d" ), GetUnconnectedNetCount() );
        frame->AppendMsgPanel( _( "Unconnected" ), txt, BLUE );
        frame->AppendMsgPanel( _( "Unconnected" ), txt, BLUE );
    }
    }
}
}
@@ -2238,6 +2232,24 @@ TRACK* BOARD::CreateLockPoint( wxPoint& aPosition, TRACK* aSegment, PICKED_ITEMS
}
}




void BOARD::SetViaSizeIndex( unsigned aIndex )
{
    if( aIndex >= m_ViasDimensionsList.size() )
        m_viaSizeIndex = m_ViasDimensionsList.size();
    else
        m_viaSizeIndex = aIndex;
}


void BOARD::SetTrackWidthIndex( unsigned aIndex )
{
    if( m_trackWidthIndex >= m_TrackWidthList.size() )
        m_trackWidthIndex = m_TrackWidthList.size();
    else
        m_trackWidthIndex = aIndex;
}


#if defined(DEBUG)
#if defined(DEBUG)


void BOARD::Show( int nestLevel, std::ostream& os ) const
void BOARD::Show( int nestLevel, std::ostream& os ) const
+95 −34
Original line number Original line Diff line number Diff line
@@ -192,10 +192,9 @@ private:
    HIGH_LIGHT_INFO         m_highLight;                // current high light data
    HIGH_LIGHT_INFO         m_highLight;                // current high light data
    HIGH_LIGHT_INFO         m_highLightPrevious;        // a previously stored high light data
    HIGH_LIGHT_INFO         m_highLightPrevious;        // a previously stored high light data


    int                 m_fileFormatVersionAtLoad;  ///< the version in the *.brd header on first line
    int                     m_fileFormatVersionAtLoad;  ///< the version loaded from the file


    EDA_RECT                m_BoundingBox;
    EDA_RECT                m_BoundingBox;

    NETINFO_LIST            m_NetInfo;              ///< net info list (name, design constraints ..
    NETINFO_LIST            m_NetInfo;              ///< net info list (name, design constraints ..


    BOARD_DESIGN_SETTINGS   m_designSettings;
    BOARD_DESIGN_SETTINGS   m_designSettings;
@@ -208,6 +207,23 @@ private:
    /// Position of the origin axis, which is used in exports mostly
    /// Position of the origin axis, which is used in exports mostly
    wxPoint                 m_originAxisPosition;
    wxPoint                 m_originAxisPosition;


    /// Number of pads connected to the current net.
    int                     m_nodeCount;

    /// 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;

    /// Index for #m_ViaSizeList to select the current via size.
    /// 0 is the index selection of the default value Netclass
    unsigned                m_viaSizeIndex;

    // Index for m_TrackWidthList to select the value.
    unsigned                m_trackWidthIndex;

    /**
    /**
     * Function chainMarkedSegments
     * Function chainMarkedSegments
     * is used by MarkTrace() to set the BUSY flag of connected segments of the trace
     * is used by MarkTrace() to set the BUSY flag of connected segments of the trace
@@ -232,12 +248,6 @@ public:
    /// Flags used in ratsnest calculation and update.
    /// Flags used in ratsnest calculation and update.
    int m_Status_Pcb;
    int m_Status_Pcb;


    /// Active pads (pads attached to a net ) count.
    int m_NbNodes;

    /// Active ratsnest count (ratsnests not already connected by tracks)
    int m_NbNoconnect;

    DLIST<BOARD_ITEM>           m_Drawings;              // linked list of lines & texts
    DLIST<BOARD_ITEM>           m_Drawings;              // linked list of lines & texts
    DLIST<MODULE>               m_Modules;               // linked list of MODULEs
    DLIST<MODULE>               m_Modules;               // linked list of MODULEs
    DLIST<TRACK>                m_Track;                 // linked list of TRACKs and SEGVIAs
    DLIST<TRACK>                m_Track;                 // linked list of TRACKs and SEGVIAs
@@ -255,10 +265,6 @@ public:
    /// List of current netclasses. There is always the default netclass.
    /// List of current netclasses. There is always the default netclass.
    NETCLASSES                  m_NetClasses;
    NETCLASSES                  m_NetClasses;


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

    // handling of vias and tracks size:
    // handling of vias and tracks size:
    // the first value is always the value of the current NetClass
    // the first value is always the value of the current NetClass
    // The others values are extra values
    // The others values are extra values
@@ -271,13 +277,6 @@ public:
    // The first value is the current netclass track width
    // The first value is the current netclass track width
    std::vector <int>           m_TrackWidthList;
    std::vector <int>           m_TrackWidthList;


    /// Index for m_ViaSizeList to select the value.
    /// 0 is the index selection of the default value Netclass
    unsigned m_ViaSizeSelector;

    // Index for m_TrackWidthList to select the value.
    unsigned m_TrackWidthSelector;



    BOARD();
    BOARD();
    ~BOARD();
    ~BOARD();
@@ -672,8 +671,6 @@ public:
    /** Calculate the zone segment count */
    /** Calculate the zone segment count */
    int GetNumSegmZone() const;
    int GetNumSegmZone() const;


    unsigned GetNoconnectCount() const;    // Return the number of missing links.

    /**
    /**
     * Function GetNumRatsnests
     * Function GetNumRatsnests
     * @return int - The number of rats
     * @return int - The number of rats
@@ -690,6 +687,42 @@ public:
     */
     */
    unsigned GetNodesCount() const;
    unsigned GetNodesCount() const;


    /**
     * Function SetNodeCount
     * set the number of nodes of the current net to \a aCount.
     *
     * @param aCount is the number of nodes attached to the current net.
     */
    void SetNodeCount( unsigned aCount )   { m_nodeCount = aCount; }

    /**
     * Function GetUnconnectedNetCount
     * @return the number of unconnected nets in the current rats nest.
     */
    unsigned GetUnconnectedNetCount() const { return m_unconnectedNetCount; }

    /**
     * Function SetUnconnectedNetCount
     * sets the number of unconnected nets in the current rats nest to \a aCount.
     *
     * @param aCount is the number of unconneceted nets in the current rats nest.
     */
    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
     * Function GetPadCount
     * @return the number of pads in board
     * @return the number of pads in board
@@ -877,6 +910,20 @@ public:
     */
     */
    int GetSmallestClearanceValue();
    int GetSmallestClearanceValue();


    /**
     * Function GetTrackWidthIndex
     * @return the current track width list index.
     */
    unsigned GetTrackWidthIndex() const { return m_trackWidthIndex; }

    /**
     * Function SetTrackWidthIndex
     * sets the current track width list index to \a aIndex.
     *
     * @param aIndex is the track width list index.
     */
    void SetTrackWidthIndex( unsigned aIndex );

    /**
    /**
     * Function GetCurrentTrackWidth
     * Function GetCurrentTrackWidth
     * @return the current track width, according to the selected options
     * @return the current track width, according to the selected options
@@ -885,9 +932,23 @@ public:
     */
     */
    int GetCurrentTrackWidth() const
    int GetCurrentTrackWidth() const
    {
    {
        return m_TrackWidthList[m_TrackWidthSelector];
        return m_TrackWidthList[m_trackWidthIndex];
    }
    }


    /**
     * Function GetViaSizeIndex
     * @return the current via size list index.
     */
    unsigned GetViaSizeIndex() const { return m_viaSizeIndex; }

    /**
     * Function SetViaSizeIndex
     * sets the current via size list index to \a aIndex.
     *
     * @param aIndex is the via size list index.
     */
    void SetViaSizeIndex( unsigned aIndex );

    /**
    /**
     * Function GetCurrentViaSize
     * Function GetCurrentViaSize
     * @return the current via size, according to the selected options
     * @return the current via size, according to the selected options
@@ -896,7 +957,7 @@ public:
     */
     */
    int GetCurrentViaSize()
    int GetCurrentViaSize()
    {
    {
        return m_ViasDimensionsList[m_ViaSizeSelector].m_Diameter;
        return m_ViasDimensionsList[m_viaSizeIndex].m_Diameter;
    }
    }


    /**
    /**
@@ -907,8 +968,8 @@ public:
     */
     */
    int GetCurrentViaDrill()
    int GetCurrentViaDrill()
    {
    {
        return m_ViasDimensionsList[m_ViaSizeSelector].m_Drill > 0 ?
        return m_ViasDimensionsList[m_viaSizeIndex].m_Drill > 0 ?
               m_ViasDimensionsList[m_ViaSizeSelector].m_Drill : -1;
               m_ViasDimensionsList[m_viaSizeIndex].m_Drill : -1;
    }
    }


    /**
    /**
+1 −1
Original line number Original line Diff line number Diff line
@@ -120,7 +120,7 @@ void NETINFO_LIST::buildListOfNets()
        last_pad = pad;
        last_pad = pad;
    }
    }


    m_Parent->m_NbNodes = nodes_count;
    m_Parent->SetNodeCount( nodes_count );


    m_Parent->SynchronizeNetsAndNetClasses( );
    m_Parent->SynchronizeNetsAndNetClasses( );


+3 −1
Original line number Original line Diff line number Diff line
@@ -791,6 +791,7 @@ void PCB_BASE_FRAME::TestNetConnection( wxDC* aDC, int aNetCode )
    // Display results
    // Display results
    int net_notconnected_count = 0;
    int net_notconnected_count = 0;
    NETINFO_ITEM* net = m_Pcb->FindNet( aNetCode );
    NETINFO_ITEM* net = m_Pcb->FindNet( aNetCode );

    if( net )       // Should not occur, but ...
    if( net )       // Should not occur, but ...
    {
    {
        for( unsigned ii = net->m_RatsnestStartIdx; ii < net->m_RatsnestEndIdx; ii++ )
        for( unsigned ii = net->m_RatsnestStartIdx; ii < net->m_RatsnestEndIdx; ii++ )
@@ -798,8 +799,9 @@ void PCB_BASE_FRAME::TestNetConnection( wxDC* aDC, int aNetCode )
            if( m_Pcb->m_FullRatsnest[ii].IsActive() )
            if( m_Pcb->m_FullRatsnest[ii].IsActive() )
                net_notconnected_count++;
                net_notconnected_count++;
        }
        }

        msg.Printf( wxT( "links %d nc %d  net:nc %d" ),
        msg.Printf( wxT( "links %d nc %d  net:nc %d" ),
                    m_Pcb->GetRatsnestsCount(), m_Pcb->GetNoconnectCount(),
                    m_Pcb->GetRatsnestsCount(), m_Pcb->GetUnconnectedNetCount(),
                    net_notconnected_count );
                    net_notconnected_count );
    }
    }
    else
    else
Loading