fixed bug 585140 and minor cleaning

This commit is contained in:
jp 2010-05-27 12:24:42 +02:00
commit 4a11fb3685
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
last_client=pcbnew
[cvpcb]

View File

@ -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;

View File

@ -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 );
}
}

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
* Extr = flag = START -> beginning of the test segment
* 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
* 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;
}

View File

@ -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 );