SwitchLayer() fix

This commit is contained in:
dickelbeck 2007-12-14 22:31:45 +00:00
parent 806f9aa1ca
commit 4a32a601e2
6 changed files with 54 additions and 24 deletions

View File

@ -5,6 +5,15 @@ Please add newer entries at the top, list the date and your name with
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>
================================================================================
+pcbnew

View File

@ -709,7 +709,20 @@ public:
// Track and via edition:
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_Status_Net( wxDC* DC );
TRACK* Delete_Segment( wxDC* DC, TRACK* Track );

View File

@ -241,7 +241,6 @@ void EraseDragListe()
for( ; pt_drag != NULL; pt_drag = NextStruct )
{
NextStruct = pt_drag->Pnext;
pt_drag->m_Segm->m_Flags = 0;
pt_drag->m_Segm->m_Flags = 0;
delete pt_drag;
}

View File

@ -1051,7 +1051,17 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer )
GetScreen()->m_Route_Layer_TOP = preslayer;
GetScreen()->m_Route_Layer_BOTTOM = layer;
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;
}
}
}

View File

@ -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 )
/****************************************************************/
/*
* 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
*/
/****************************************************************/
bool WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
/****************************************************************/
{
TRACK* pt_segm;
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;
Affiche_Status_Box();
SetToolbars();
return;
return true;
}
/* Avoid more than one via on the current location: */
if( Locate_Via( m_Pcb, g_CurrentTrackSegment->m_End, g_CurrentTrackSegment->GetLayer() ) )
return;
return false;
pt_segm = g_FirstTrackSegment;
for( ii = 0; ii < g_TrackSegmentCount - 1; ii++, pt_segm = (TRACK*) pt_segm->Pnext )
{
if( (pt_segm->Type() == TYPEVIA)
&& (g_CurrentTrackSegment->m_End == pt_segm->m_Start) )
return;
return false;
}
/* 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 ) )
/* DRC error, the change layer is not made */
return;
return false;
if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->Back() ) // We must handle 2 segments
{
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;
GetScreen()->m_Active_Layer = old_layer;
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
return;
return false;
}
/* 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();
SetToolbars();
return true;
}

View File

@ -234,7 +234,9 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel,
if( TrackSegWrapper == NULL )
return;
Track = TrackSegWrapper->m_Segm; if( Track == NULL )
Track = TrackSegWrapper->m_Segm;
if( Track == NULL )
return;
TrackSegWrapper = TrackSegWrapper->Pnext;
@ -260,6 +262,7 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel,
Track->Draw( panel, DC, draw_mode );
if( tSegmentToStart )
tSegmentToStart->Draw( panel, DC, draw_mode );
if( tSegmentToEnd )
tSegmentToEnd->Draw( panel, DC, draw_mode );
}
@ -386,11 +389,13 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel,
// update the segment coordinates (if possible)
if( tSegmentToStart == NULL )
{
xi1 = tx1; yi1 = ty1;
xi1 = tx1;
yi1 = ty1;
}
if( tSegmentToEnd == NULL )
{
xi2 = tx2; yi2 = ty2;
xi2 = tx2;
yi2 = ty2;
}
@ -736,6 +741,7 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
AddSegmentToDragList( DrawPanel, DC, flag, TrackToStartPoint );
track->m_Flags |= STARTPOINT;
}
if( TrackToEndPoint )
{
int flag = STARTPOINT;