Commit 4a32a601 authored by dickelbeck's avatar dickelbeck
Browse files

SwitchLayer() fix

parent 806f9aa1
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -5,6 +5,15 @@ Please add newer entries at the top, list the date and your name with
email address.
email address.




2007-Dec-14 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew
    WinEDA_PcbFrame::Other_Layer_Route() now returns bool, so that if the DRC
    would not allow the new via placement, then it can be checked and the layer
    change can also then be aborted.  Previously the layer change would happen
    in mid track if the via could not be placed.


2007-Dec-13 UPDATE   Dick Hollenbeck <dick@softplc.com>
2007-Dec-13 UPDATE   Dick Hollenbeck <dick@softplc.com>
================================================================================
================================================================================
+pcbnew
+pcbnew
+14 −1
Original line number Original line Diff line number Diff line
@@ -709,7 +709,20 @@ public:


    // Track and via edition:
    // Track and via edition:
    void                DisplayTrackSettings();
    void                DisplayTrackSettings();
    void                Other_Layer_Route( TRACK* track, wxDC* DC );
    
    /**
     * Function Other_Layer_Route
     * operates in one of two ways.  If argument track is NULL, then swap the active
     * layer between m_Route_Layer_TOP and m_Route_Layer_BOTTOM.  If a track is
     * in progress (track is not NULL), and if DRC allows it, place a via on the end
     * of the current track, and then swap the current active layer and start a new
     * segment on the new layer.
     * @param track A TRACK* to append the via to or NULL.
     * @param DC A device context to draw on.
     * @return bool - true if the operation was successful, else false such as
     *   the case where DRC would not allow a via.
     */ 
    bool                Other_Layer_Route( TRACK* track, wxDC* DC );
    void                Affiche_PadsNoConnect( wxDC* DC );
    void                Affiche_PadsNoConnect( wxDC* DC );
    void                Affiche_Status_Net( wxDC* DC );
    void                Affiche_Status_Net( wxDC* DC );
    TRACK*              Delete_Segment( wxDC* DC, TRACK* Track );
    TRACK*              Delete_Segment( wxDC* DC, TRACK* Track );
+0 −1
Original line number Original line Diff line number Diff line
@@ -242,7 +242,6 @@ void EraseDragListe()
    {
    {
        NextStruct = pt_drag->Pnext;
        NextStruct = pt_drag->Pnext;
        pt_drag->m_Segm->m_Flags = 0;        
        pt_drag->m_Segm->m_Flags = 0;        
        pt_drag->m_Segm->m_Flags = 0;        
        delete pt_drag;
        delete pt_drag;
    }
    }


+11 −1
Original line number Original line Diff line number Diff line
@@ -1051,7 +1051,17 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
                GetScreen()->m_Route_Layer_TOP    = preslayer;
                GetScreen()->m_Route_Layer_TOP    = preslayer;
                GetScreen()->m_Route_Layer_BOTTOM = layer;
                GetScreen()->m_Route_Layer_BOTTOM = layer;
                GetScreen()->m_Active_Layer = preslayer;
                GetScreen()->m_Active_Layer = preslayer;
                Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC );
                
                if( Other_Layer_Route( (TRACK*) GetScreen()->GetCurItem(), DC ) )
                {
                    if( DisplayOpt.ContrastModeDisplay )
                        GetScreen()->SetRefreshReq();
                }
                
                // if the via was allowed by DRC, then the layer swap has already
                // been done by Other_Layer_Route(). if via not allowed, then 
                // return now so assignment to m_Active_Layer below doesn't happen.
                return;
            }
            }
        }
        }
    }
    }
+10 −17
Original line number Original line Diff line number Diff line
@@ -153,19 +153,10 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC )
}
}





/****************************************************************/
/****************************************************************/
void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
/****************************************************************/
/****************************************************************/

/*
 *  if no track in progress :
 *		swap the active layer between m_Route_Layer_TOP and m_Route_Layer_BOTTOM
 *  if a track is in progress :
 *		put (if possible, i.e. if no DRC problem) a Via on the end of the current
 *		track, swap the current active layer and start a new trac segment on the new layer
 * @param track = track in progress, or NULL
 * @param DC = current device context
 */
{
{
    TRACK*  pt_segm;
    TRACK*  pt_segm;
    SEGVIA* Via;
    SEGVIA* Via;
@@ -180,19 +171,19 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
            GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_BOTTOM;
            GetScreen()->m_Active_Layer = GetScreen()->m_Route_Layer_BOTTOM;
        Affiche_Status_Box();
        Affiche_Status_Box();
        SetToolbars();
        SetToolbars();
        return;
        return true;
    }
    }


    /* Avoid more than one via on the current location: */
    /* Avoid more than one via on the current location: */
    if( Locate_Via( m_Pcb, g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->GetLayer() ) )
    if( Locate_Via( m_Pcb, g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->GetLayer() ) )
        return;
        return false;
    
    
    pt_segm = g_FirstTrackSegment;
    pt_segm = g_FirstTrackSegment;
    for( ii = 0; ii < g_TrackSegmentCount - 1; ii++, pt_segm = (TRACK*) pt_segm->Pnext )
    for( ii = 0; ii < g_TrackSegmentCount - 1; ii++, pt_segm = (TRACK*) pt_segm->Pnext )
    {
    {
        if( (pt_segm->Type() == TYPEVIA)
        if( (pt_segm->Type() == TYPEVIA)
           && (g_CurrentTrackSegment->m_End == pt_segm->m_Start) )
           && (g_CurrentTrackSegment->m_End == pt_segm->m_Start) )
            return;
            return false;
    }
    }


    /* Is the current segment Ok (no DRC error) ? */
    /* Is the current segment Ok (no DRC error) ? */
@@ -200,12 +191,12 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
    {
    {
        if( BAD_DRC==m_drc->Drc( g_CurrentTrackSegment, m_Pcb->m_Track ) )
        if( BAD_DRC==m_drc->Drc( g_CurrentTrackSegment, m_Pcb->m_Track ) )
            /* DRC error, the change layer is not made */
            /* DRC error, the change layer is not made */
            return;
            return false;
            
            
        if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->Back() )    // We must handle 2 segments
        if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->Back() )    // We must handle 2 segments
        {
        {
            if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment->Back(), m_Pcb->m_Track ) )
            if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment->Back(), m_Pcb->m_Track ) )
                return;
                return false;
        }
        }
    }
    }


@@ -256,7 +247,7 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
        delete Via;
        delete Via;
        GetScreen()->m_Active_Layer = old_layer;
        GetScreen()->m_Active_Layer = old_layer;
        DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
        DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
        return;
        return false;
    }
    }


    /* A new via was created. It was Ok.
    /* A new via was created. It was Ok.
@@ -303,6 +294,8 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )


    Affiche_Status_Box();
    Affiche_Status_Box();
    SetToolbars();
    SetToolbars();
    
    return true;
}
}




Loading