fixed bug 585140 and minor cleaning

This commit is contained in:
jp 2010-05-27 12:23:29 +02:00
parent b0a7cfc8b7
commit 4574d4369e
6 changed files with 69 additions and 60 deletions

View File

@ -1,4 +1,4 @@
update=20/05/2010 10:19:24 update=27/05/2010 12:18:31
version=1 version=1
last_client=pcbnew last_client=pcbnew
[cvpcb] [cvpcb]

View File

@ -904,10 +904,12 @@ void WinEDA_PcbFrame::Process_Special_Functions( wxCommandEvent& event )
wxPoint pos = GetScreen()->m_Curseur; wxPoint pos = GetScreen()->m_Curseur;
track->Draw( DrawPanel, &dc, GR_XOR ); track->Draw( DrawPanel, &dc, GR_XOR );
PICKED_ITEMS_LIST itemsListPicker; PICKED_ITEMS_LIST itemsListPicker;
TRACK* newtrack = CreateLockPoint( pos, track, NULL, &itemsListPicker); TRACK* newtrack = CreateLockPoint( GetBoard(), pos, track, &itemsListPicker);
SaveCopyInUndoList(itemsListPicker,UR_UNSPECIFIED); SaveCopyInUndoList(itemsListPicker,UR_UNSPECIFIED);
track->Draw( DrawPanel, &dc, GR_XOR ); track->Draw( DrawPanel, &dc, GR_XOR );
newtrack->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; break;

View File

@ -127,9 +127,8 @@ TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
{ {
TrackOnStartPoint = (TRACK*) LockPoint; TrackOnStartPoint = (TRACK*) LockPoint;
g_HighLight_NetCode = TrackOnStartPoint->GetNet(); g_HighLight_NetCode = TrackOnStartPoint->GetNet();
CreateLockPoint( pos, CreateLockPoint( GetBoard(), pos,
TrackOnStartPoint, TrackOnStartPoint,
NULL,
&s_ItemsListPicker ); &s_ItemsListPicker );
} }
} }
@ -478,9 +477,9 @@ void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
g_HighLight_NetCode = adr_buf->GetNet(); g_HighLight_NetCode = adr_buf->GetNet();
/* Possible establishment of a hanging point. */ /* Possible establishment of a hanging point. */
LockPoint = CreateLockPoint( g_CurrentTrackSegment->m_End, LockPoint = CreateLockPoint( GetBoard(),
g_CurrentTrackSegment->m_End,
adr_buf, adr_buf,
g_CurrentTrackSegment,
&s_ItemsListPicker ); &s_ItemsListPicker );
} }
} }

View File

@ -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 * input: ptr_piste: pointer to the segment of track
* Extr = flag = START -> beginning of the test segment * Extr = flag = START -> beginning of the test segment
* END -> end of the segment to be tested * END -> end of the segment to be tested

View File

@ -1056,26 +1056,24 @@ BOARD_ITEM* LocateLockPoint( BOARD* Pcb, wxPoint pos, int LayerMask )
/* Create an intermediate point on a segment /* 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: * Returns:
* NULL if no new point (ie if aRefPoint already corresponded * NULL if no new point (ie if aRefPoint already corresponded at one end of aSegm
* At one end where: * or
* Pointer to the segment created * Pointer to the segment created
* Created and the point is the intersection of 2 lines segments aSegm and * Returns the exact value of aRefPoint
* refsegm
* Returns the exact value of aRefPoint
* If aSegm points to a via: * If aSegm points to a via:
* Returns the exact value of aRefPoint and ptsegm, * Returns the exact value of aRefPoint and a pointer to the via,
* But does not create extra point * But does not create extra point
*/ */
TRACK* CreateLockPoint( wxPoint& aRefPoint, TRACK* CreateLockPoint( BOARD* aPcb,
wxPoint& aRefPoint,
TRACK* aSegm, TRACK* aSegm,
TRACK* aRefSegm,
PICKED_ITEMS_LIST* aItemsListPicker ) PICKED_ITEMS_LIST* aItemsListPicker )
{ {
int cX, cY;
int dx, dy;
if( aSegm->m_Start == aRefPoint || aSegm->m_End == aRefPoint ) if( aSegm->m_Start == aRefPoint || aSegm->m_End == aRefPoint )
return NULL; return NULL;
@ -1086,15 +1084,12 @@ TRACK* CreateLockPoint( wxPoint& aRefPoint,
return aSegm; return aSegm;
} }
/* Calculation coordinate of intermediate point in the coordinate origin /* Calculation coordinate of intermediate point relative to
* = Original ptsegm * the start point of aSegm
*/ */
cX = aRefPoint.x - aSegm->m_Start.x; wxPoint delta = aSegm->m_End - aSegm->m_Start;
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;
// Not yet used: // Not yet in use:
#if 0 #if 0
int ox, oy, fx, fy; int ox, oy, fx, fy;
@ -1107,17 +1102,20 @@ TRACK* CreateLockPoint( wxPoint& aRefPoint,
} }
#endif #endif
/* that the item be on the segment ptsegm: cY/cX = dy/dx */ // calculate coordinates of aRefPoint relative to aSegm->m_Start
if( dx == 0 ) wxPoint newPoint = aRefPoint - aSegm->m_Start;
cX = 0; /* segm horizontal */ // newPoint must be on aSegm:
// Ensure newPoint.y/newPoint.y = delta.y/delta.x
if( delta.x == 0 )
newPoint.x = 0; /* horizontal segment*/
else 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 /* Create the intermediate point (that is to say creation of a new
* segment, beginning at the intermediate point. * segment, beginning at the intermediate point.
*/ */
cX += aSegm->m_Start.x; newPoint.x += aSegm->m_Start.x;
cY += aSegm->m_Start.y; newPoint.y += aSegm->m_Start.y;
TRACK* newTrack = aSegm->Copy(); TRACK* newTrack = aSegm->Copy();
if( aItemsListPicker ) if( aItemsListPicker )
@ -1131,29 +1129,39 @@ TRACK* CreateLockPoint( wxPoint& aRefPoint,
wxASSERT( list ); wxASSERT( list );
list->Insert( newTrack, aSegm->Next() ); 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 ) if( aItemsListPicker )
{ {
ITEM_PICKER picker( aSegm, UR_CHANGED ); ITEM_PICKER picker( aSegm, UR_CHANGED );
picker.m_Link = aSegm->Copy(); picker.m_Link = aSegm->Copy();
aItemsListPicker->PushItem( picker ); 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 ); aSegm->SetState( END_ONPAD, OFF );
/* The next segment begins at the new point. */ /* The new segment begins at the new point. */
aSegm = newTrack;; newTrack->m_Start = newPoint;
aSegm->m_Start.x = cX; newTrack->start = aSegm;
aSegm->m_Start.y = cY; newTrack->SetState( BEGIN_ONPAD, OFF );
aSegm->SetState( BEGIN_ONPAD, OFF );
aRefPoint.x = cX; D_PAD * pad = Locate_Pad_Connecte( aPcb, newTrack, START );
aRefPoint.y = cY; if ( pad )
{
newTrack->start = pad;
newTrack->SetState( BEGIN_ONPAD, ON );
aSegm->end = pad;
aSegm->SetState( END_ONPAD, ON );
}
return aSegm; aRefPoint = newPoint;
return newTrack;
} }

View File

@ -331,22 +331,22 @@ void MasqueAttributs( int* masque_set, int* masque_clr );
BOARD_ITEM* LocateLockPoint( BOARD* aPcb, wxPoint aPos, int aLayerMask ); BOARD_ITEM* LocateLockPoint( BOARD* aPcb, wxPoint aPos, int aLayerMask );
/* Create an intermediate point on a segment /* 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: * Returns:
* NULL if no new point (ie if aRefPoint already corresponded * NULL if no new point (ie if aRefPoint already corresponded at one end of aSegm
* At one end where: * or
* Pointer to the segment created * Pointer to the segment created
* If aRefSegm! Refsegm = NULL pointer is on the segment * Returns the exact value of aRefPoint
* Created and the point is the intersection of 2 lines segments ptsegm
* and aRefSegm
* Returns the exact value of aRefPoint
* If aSegm points to a via: * If aSegm points to a via:
* Returns the exact value of aRefPoint and aSegm, but does not create * Returns the exact value of aRefPoint and a pointer to the via,
* extra point * But does not create extra point
*/ */
TRACK* CreateLockPoint( wxPoint& aRefPoint, TRACK* CreateLockPoint( BOARD* aPcb,
wxPoint& aRefPoint,
TRACK* aSegm, TRACK* aSegm,
TRACK* aRefSegm,
PICKED_ITEMS_LIST* aItemsListPicker ); PICKED_ITEMS_LIST* aItemsListPicker );