Commit 4a32a601 authored by dickelbeck's avatar dickelbeck

SwitchLayer() fix

parent 806f9aa1
...@@ -5,6 +5,15 @@ Please add newer entries at the top, list the date and your name with ...@@ -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
......
...@@ -709,7 +709,20 @@ public: ...@@ -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 );
......
...@@ -242,7 +242,6 @@ void EraseDragListe() ...@@ -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;
} }
......
...@@ -1051,7 +1051,17 @@ void WinEDA_PcbFrame::SwitchLayer( wxDC* DC, int layer ) ...@@ -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;
} }
} }
} }
......
...@@ -153,19 +153,10 @@ void WinEDA_PcbFrame::ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC ) ...@@ -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 ) ...@@ -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 ) ...@@ -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 ) ...@@ -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 ) ...@@ -303,6 +294,8 @@ void WinEDA_PcbFrame::Other_Layer_Route( TRACK* track, wxDC* DC )
Affiche_Status_Box(); Affiche_Status_Box();
SetToolbars(); SetToolbars();
return true;
} }
......
...@@ -234,7 +234,9 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel, ...@@ -234,7 +234,9 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel,
if( TrackSegWrapper == NULL ) if( TrackSegWrapper == NULL )
return; return;
Track = TrackSegWrapper->m_Segm; if( Track == NULL )
Track = TrackSegWrapper->m_Segm;
if( Track == NULL )
return; return;
TrackSegWrapper = TrackSegWrapper->Pnext; TrackSegWrapper = TrackSegWrapper->Pnext;
...@@ -260,6 +262,7 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel, ...@@ -260,6 +262,7 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel,
Track->Draw( panel, DC, draw_mode ); Track->Draw( panel, DC, draw_mode );
if( tSegmentToStart ) if( tSegmentToStart )
tSegmentToStart->Draw( panel, DC, draw_mode ); tSegmentToStart->Draw( panel, DC, draw_mode );
if( tSegmentToEnd ) if( tSegmentToEnd )
tSegmentToEnd->Draw( panel, DC, draw_mode ); tSegmentToEnd->Draw( panel, DC, draw_mode );
} }
...@@ -386,11 +389,13 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel, ...@@ -386,11 +389,13 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel,
// update the segment coordinates (if possible) // update the segment coordinates (if possible)
if( tSegmentToStart == NULL ) if( tSegmentToStart == NULL )
{ {
xi1 = tx1; yi1 = ty1; xi1 = tx1;
yi1 = ty1;
} }
if( tSegmentToEnd == NULL ) if( tSegmentToEnd == NULL )
{ {
xi2 = tx2; yi2 = ty2; xi2 = tx2;
yi2 = ty2;
} }
...@@ -736,6 +741,7 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC ...@@ -736,6 +741,7 @@ void WinEDA_PcbFrame::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
AddSegmentToDragList( DrawPanel, DC, flag, TrackToStartPoint ); AddSegmentToDragList( DrawPanel, DC, flag, TrackToStartPoint );
track->m_Flags |= STARTPOINT; track->m_Flags |= STARTPOINT;
} }
if( TrackToEndPoint ) if( TrackToEndPoint )
{ {
int flag = STARTPOINT; int flag = STARTPOINT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment