diff --git a/change_log.txt b/change_log.txt index 1e529a8d1e..b18af92104 100644 --- a/change_log.txt +++ b/change_log.txt @@ -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 +================================================================================ ++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 ================================================================================ +pcbnew diff --git a/include/wxstruct.h b/include/wxstruct.h index 6bd5d55f7e..69d78a1a2b 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -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 ); diff --git a/pcbnew/dragsegm.cpp b/pcbnew/dragsegm.cpp index ec86ccd602..dc0e317fb6 100644 --- a/pcbnew/dragsegm.cpp +++ b/pcbnew/dragsegm.cpp @@ -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; } diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 7a6b0e7088..af99f6cc31 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -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; } } } diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index ad051a0a97..ffe9f2f3f2 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -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; } diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 80629b205f..457d37ffe6 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -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;