From 4574d4369e592d50512f5196b1e5b9ac66e7f74d Mon Sep 17 00:00:00 2001 From: jp Date: Thu, 27 May 2010 12:23:29 +0200 Subject: [PATCH] fixed bug 585140 and minor cleaning --- demos/sonde xilinx/sonde xilinx.pro | 2 +- pcbnew/edit.cpp | 4 +- pcbnew/editrack.cpp | 7 +-- pcbnew/locate.cpp | 2 +- pcbnew/move_or_drag_track.cpp | 90 ++++++++++++++++------------- pcbnew/protos.h | 24 ++++---- 6 files changed, 69 insertions(+), 60 deletions(-) diff --git a/demos/sonde xilinx/sonde xilinx.pro b/demos/sonde xilinx/sonde xilinx.pro index 4f748dfb0e..ba9b09fb46 100644 --- a/demos/sonde xilinx/sonde xilinx.pro +++ b/demos/sonde xilinx/sonde xilinx.pro @@ -1,4 +1,4 @@ -update=20/05/2010 10:19:24 +update=27/05/2010 12:18:31 version=1 last_client=pcbnew [cvpcb] diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 0d75b848f5..f2c6190cab 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -904,10 +904,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event ) wxPoint pos = GetScreen()->m_Curseur; track->Draw( DrawPanel, &dc, GR_XOR ); PICKED_ITEMS_LIST itemsListPicker; - TRACK* newtrack = CreateLockPoint( pos, track, NULL, &itemsListPicker); + TRACK* newtrack = CreateLockPoint( GetBoard(), pos, track, &itemsListPicker); SaveCopyInUndoList(itemsListPicker,UR_UNSPECIFIED); track->Draw( DrawPanel, &dc, GR_XOR ); newtrack->Draw( DrawPanel, &dc, GR_XOR ); + /* compute the new rastnest, because connectivity could change */ + test_1_net_connexion( &dc, track->GetNet() ); } break; diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 0edb5aed33..65a11cb09c 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -127,9 +127,8 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC ) { TrackOnStartPoint = (TRACK*) LockPoint; g_HighLight_NetCode = TrackOnStartPoint->GetNet(); - CreateLockPoint( pos, + CreateLockPoint( GetBoard(), pos, TrackOnStartPoint, - NULL, &s_ItemsListPicker ); } } @@ -478,9 +477,9 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC ) g_HighLight_NetCode = adr_buf->GetNet(); /* Possible establishment of a hanging point. */ - LockPoint = CreateLockPoint( g_CurrentTrackSegment->m_End, + LockPoint = CreateLockPoint( GetBoard(), + g_CurrentTrackSegment->m_End, adr_buf, - g_CurrentTrackSegment, &s_ItemsListPicker ); } } diff --git a/pcbnew/locate.cpp b/pcbnew/locate.cpp index a4769e3f9b..c9bfbcdc5d 100644 --- a/pcbnew/locate.cpp +++ b/pcbnew/locate.cpp @@ -82,7 +82,7 @@ TRACK* Locate_Via_Area( TRACK* aStart, const wxPoint& pos, int layer ) } -/* Location of the pellet CONNECTED developed a test track +/* Locate the pad CONNECTED to a track * input: ptr_piste: pointer to the segment of track * Extr = flag = START -> beginning of the test segment * END -> end of the segment to be tested diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 039bb4d127..5fd83a7c43 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -1056,26 +1056,24 @@ BOARD_ITEM* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask ) /* Create an intermediate point on a segment - * ASegm segment is broken into 2 segments connecting point pX, pY + * aSegm segment is broken into 2 segments connecting point pX, pY + * After insertion: + * The new segment starts from to new point, and ends to initial aSegm ending point + * the old segment aSegm ends to new point * Returns: - * NULL if no new point (ie if aRefPoint already corresponded - * At one end where: - * Pointer to the segment created - * Created and the point is the intersection of 2 lines segments aSegm and - * refsegm - * Returns the exact value of aRefPoint + * NULL if no new point (ie if aRefPoint already corresponded at one end of aSegm + * or + * Pointer to the segment created + * Returns the exact value of aRefPoint * If aSegm points to a via: - * Returns the exact value of aRefPoint and ptsegm, - * But does not create extra point + * Returns the exact value of aRefPoint and a pointer to the via, + * But does not create extra point */ -TRACK* CreateLockPoint( wxPoint& aRefPoint, +TRACK* CreateLockPoint( BOARD* aPcb, + wxPoint& aRefPoint, TRACK* aSegm, - TRACK* aRefSegm, PICKED_ITEMS_LIST* aItemsListPicker ) { - int cX, cY; - int dx, dy; - if( aSegm->m_Start == aRefPoint || aSegm->m_End == aRefPoint ) return NULL; @@ -1086,15 +1084,12 @@ TRACK* CreateLockPoint( wxPoint& aRefPoint, return aSegm; } - /* Calculation coordinate of intermediate point in the coordinate origin - * = Original ptsegm + /* Calculation coordinate of intermediate point relative to + * the start point of aSegm */ - cX = aRefPoint.x - aSegm->m_Start.x; - cY = aRefPoint.y - aSegm->m_Start.y; - dx = aSegm->m_End.x - aSegm->m_Start.x; - dy = aSegm->m_End.y - aSegm->m_Start.y; + wxPoint delta = aSegm->m_End - aSegm->m_Start; - // Not yet used: + // Not yet in use: #if 0 int ox, oy, fx, fy; @@ -1107,17 +1102,20 @@ TRACK* CreateLockPoint( wxPoint& aRefPoint, } #endif - /* that the item be on the segment ptsegm: cY/cX = dy/dx */ - if( dx == 0 ) - cX = 0; /* segm horizontal */ + // calculate coordinates of aRefPoint relative to aSegm->m_Start + wxPoint newPoint = aRefPoint - aSegm->m_Start; + // newPoint must be on aSegm: + // Ensure newPoint.y/newPoint.y = delta.y/delta.x + if( delta.x == 0 ) + newPoint.x = 0; /* horizontal segment*/ else - cY = ( cX * dy ) / dx; + newPoint.y = wxRound(( (double)newPoint.x * delta.y ) / delta.x); /* Create the intermediate point (that is to say creation of a new * segment, beginning at the intermediate point. */ - cX += aSegm->m_Start.x; - cY += aSegm->m_Start.y; + newPoint.x += aSegm->m_Start.x; + newPoint.y += aSegm->m_Start.y; TRACK* newTrack = aSegm->Copy(); if( aItemsListPicker ) @@ -1131,29 +1129,39 @@ TRACK* CreateLockPoint( wxPoint& aRefPoint, wxASSERT( list ); list->Insert( newTrack, aSegm->Next() ); - /* Correct pointer at the end of the new segment. */ - newTrack->end = aSegm->end; - - /* Segment ends at new point. */ if( aItemsListPicker ) { ITEM_PICKER picker( aSegm, UR_CHANGED ); picker.m_Link = aSegm->Copy(); aItemsListPicker->PushItem( picker ); } - aSegm->m_End.x = cX; - aSegm->m_End.y = cY; + /* Correct pointer at the end of the new segment. */ + newTrack->end = aSegm->end; + newTrack->SetState( END_ONPAD, aSegm->GetState( END_ONPAD ) ); + + /* Set connections info relative to the new point + */ + + /* Old segment now ends at new point. */ + aSegm->m_End = newPoint; + aSegm->end = newTrack; aSegm->SetState( END_ONPAD, OFF ); - /* The next segment begins at the new point. */ - aSegm = newTrack;; - aSegm->m_Start.x = cX; - aSegm->m_Start.y = cY; - aSegm->SetState( BEGIN_ONPAD, OFF ); + /* The new segment begins at the new point. */ + newTrack->m_Start = newPoint; + newTrack->start = aSegm; + newTrack->SetState( BEGIN_ONPAD, OFF ); - aRefPoint.x = cX; - aRefPoint.y = cY; + D_PAD * pad = Locate_Pad_Connecte( aPcb, newTrack, START ); + if ( pad ) + { + newTrack->start = pad; + newTrack->SetState( BEGIN_ONPAD, ON ); + aSegm->end = pad; + aSegm->SetState( END_ONPAD, ON ); + } - return aSegm; + aRefPoint = newPoint; + return newTrack; } diff --git a/pcbnew/protos.h b/pcbnew/protos.h index 8e64a3b8d1..ca5a97ffb6 100644 --- a/pcbnew/protos.h +++ b/pcbnew/protos.h @@ -331,22 +331,22 @@ void MasqueAttributs( int* masque_set, int* masque_clr ); BOARD_ITEM* LocateLockPoint( BOARD* aPcb, wxPoint aPos, int aLayerMask ); /* Create an intermediate point on a segment - * ASegm segment is broken into 2 segments connecting point pX, pY + * aSegm segment is broken into 2 segments connecting point pX, pY + * After insertion: + * The new segment starts from to new point, and ends to initial aSegm ending point + * the old segment aSegm ends to new point * Returns: - * NULL if no new point (ie if aRefPoint already corresponded - * At one end where: - * Pointer to the segment created - * If aRefSegm! Refsegm = NULL pointer is on the segment - * Created and the point is the intersection of 2 lines segments ptsegm - * and aRefSegm - * Returns the exact value of aRefPoint + * NULL if no new point (ie if aRefPoint already corresponded at one end of aSegm + * or + * Pointer to the segment created + * Returns the exact value of aRefPoint * If aSegm points to a via: - * Returns the exact value of aRefPoint and aSegm, but does not create - * extra point + * Returns the exact value of aRefPoint and a pointer to the via, + * But does not create extra point */ -TRACK* CreateLockPoint( wxPoint& aRefPoint, +TRACK* CreateLockPoint( BOARD* aPcb, + wxPoint& aRefPoint, TRACK* aSegm, - TRACK* aRefSegm, PICKED_ITEMS_LIST* aItemsListPicker );