Commit b88505dd authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Pcbnew: code cleaning in ratsnest.cpp. Add comments.

parent 619a82a6
Loading
Loading
Loading
Loading
+30 −8
Original line number Diff line number Diff line
@@ -397,17 +397,39 @@ public:
     */
    void DrawGeneralRatsnest( wxDC* aDC, int aNetcode = 0 );

    void trace_ratsnest_pad( wxDC* DC );
    void build_ratsnest_pad( BOARD_ITEM* ref, const wxPoint& refpos, bool init );
    /**
     * Function TraceAirWiresToTargets
     * This functions shows airwires to nearest connecting points (pads)
     * from the current new track end during track creation
     * Uses data prepared by BuildAirWiresTargetsList()
     * @param aDC = the current device context
     */
    void TraceAirWiresToTargets( wxDC* DC );

    /**
     * Function BuildAirWiresTargetsList
     * Build a list of candidates that can be a coonection point
     * when a track is started.
     * This functions prepares data to show airwires to nearest connecting points (pads)
     * from the current new track to candidates during track creation
     * @param aItemRef = the item connected to the starting point of the new track (track or pad)
     * @param aPosition = the position of the new track end (usually the mouse cursor on grid)
     * @param aInit = true to build full candidate list or false to update data
     * When aInit = false, aItemRef is not used (can be NULL)
     */
    void BuildAirWiresTargetsList( BOARD_CONNECTED_ITEM* aItemRef,
                                   const wxPoint& aPosition, bool aInit );

    /**
     * Fucntion TestRatsNest
     * computes the active rats nest
     * The general rats nest list must exist.
     * Compute the ACTIVE rats nest in the general rats nest list
     * if aNetCode == 0, test all nets, else test only aNetCode
     * Function TestForActiveLinksInRatsnest
     * Explores the full rats nest list (which must exist) to determine
     * the ACTIVE links in the full rats nest list
     * When tracks exist between pads, a link can connect 2 pads already connected by a track
     * and the link is said inactive.
     * When a link connects 2 pads not already connected by a track, the link is said active.
     * @param aNetCode = net code to test. If 0, test all nets
     */
    void TestRatsNest( wxDC* aDC, int aNetCode );
    void TestForActiveLinksInRatsnest( int aNetCode );

    /**
     * Function TestConnections
+1 −1
Original line number Diff line number Diff line
@@ -2133,7 +2133,7 @@ MODULE* BOARD::GetFootprint( const wxPoint& aPosition, int aActiveLayer,
}


BOARD_ITEM* BOARD::GetLockPoint( const wxPoint& aPosition, int aLayerMask )
BOARD_CONNECTED_ITEM* BOARD::GetLockPoint( const wxPoint& aPosition, int aLayerMask )
{
    for( MODULE* module = m_Modules; module; module = module->Next() )
    {
+1 −1
Original line number Diff line number Diff line
@@ -1251,7 +1251,7 @@ public:
     *                   layer mask.
     * @return A pointer to a BOARD_ITEM object if found otherwise NULL.
     */
    BOARD_ITEM* GetLockPoint( const wxPoint& aPosition, int aLayerMask );
    BOARD_CONNECTED_ITEM* GetLockPoint( const wxPoint& aPosition, int aLayerMask );

    /**
     * Function CreateLockPoint
+1 −1
Original line number Diff line number Diff line
@@ -558,7 +558,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )

        SetCurItem( NULL );        // CurItem might be deleted by this command, clear the pointer
        TestConnections( NULL );
        TestRatsNest( NULL, 0 );   // Recalculate the active ratsnest, i.e. the unconnected links
        TestForActiveLinksInRatsnest( 0 );   // Recalculate the active ratsnest, i.e. the unconnected links
        OnModify();
        GetBoard()->DisplayInfo( this );
        DrawPanel->Refresh();
+8 −8
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
    D_PAD*      pt_pad = NULL;
    TRACK*      TrackOnStartPoint = NULL;
    int         layerMask = g_TabOneLayerMask[( (PCB_SCREEN*) GetScreen() )->m_Active_Layer];
    BOARD_ITEM* LockPoint;
    BOARD_CONNECTED_ITEM* LockPoint;
    wxPoint     pos = GetScreen()->GetCrossHairPosition();

    if( aTrack == NULL )  /* Starting a new track  */
@@ -148,7 +148,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )

        D( g_CurrentTrackList.VerifyListIntegrity(); );

        build_ratsnest_pad( LockPoint, wxPoint( 0, 0 ), true );
        BuildAirWiresTargetsList( LockPoint, wxPoint( 0, 0 ), true );

        D( g_CurrentTrackList.VerifyListIntegrity(); );

@@ -428,7 +428,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC )

    ShowNewTrackWhenMovingCursor( DrawPanel, aDC, wxDefaultPosition, true );
    ShowNewTrackWhenMovingCursor( DrawPanel, aDC, wxDefaultPosition, false );
    trace_ratsnest_pad( aDC );
    TraceAirWiresToTargets( aDC );

    /* cleanup
     *  if( g_CurrentTrackSegment->Next() != NULL )
@@ -447,7 +447,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC )
     * This helps to reduce the computing time */

    /* Attaching the end of the track. */
    BOARD_ITEM* LockPoint = GetBoard()->GetLockPoint( pos, layerMask );
    BOARD_CONNECTED_ITEM* LockPoint = GetBoard()->GetLockPoint( pos, layerMask );

    if( LockPoint ) /* End of trace is on a pad. */
    {
@@ -489,7 +489,7 @@ bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC )
            GetBoard()->m_Track.Insert( track, insertBeforeMe );
        }

        trace_ratsnest_pad( aDC );
        TraceAirWiresToTargets( aDC );

        DrawTraces( DrawPanel, aDC, firstTrack, newCount, GR_OR );

@@ -680,7 +680,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
    {
        DrawTraces( aPanel, aDC, g_FirstTrackSegment, g_CurrentTrackList.GetCount(), GR_XOR );

        frame->trace_ratsnest_pad( aDC );
        frame->TraceAirWiresToTargets( aDC );

        if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS )
        {
@@ -807,8 +807,8 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
    DisplayOpt.ShowTrackClearanceMode = showTrackClearanceMode;
    DisplayOpt.DisplayPcbTrackFill    = Track_fill_copy;

    frame->build_ratsnest_pad( NULL, g_CurrentTrackSegment->m_End, false );
    frame->trace_ratsnest_pad( aDC );
    frame->BuildAirWiresTargetsList( NULL, g_CurrentTrackSegment->m_End, false );
    frame->TraceAirWiresToTargets( aDC );
}


Loading