2009-11-14 22:15:22 +00:00
|
|
|
/****************/
|
|
|
|
/* Edit traces. */
|
|
|
|
/****************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbnew.h"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2010-01-29 20:36:12 +00:00
|
|
|
#include "colors_selection.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
#include "drc_stuff.h"
|
2008-02-27 15:26:16 +00:00
|
|
|
#include "trigo.h"
|
|
|
|
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "protos.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2009-06-18 20:51:01 +00:00
|
|
|
static void Exit_Editrack( WinEDA_DrawPanel* panel, wxDC* DC );
|
|
|
|
void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC, bool erase );
|
|
|
|
static void ComputeBreakPoint( TRACK* track, int n, wxPoint end );
|
|
|
|
static void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-06-18 20:51:01 +00:00
|
|
|
static void EnsureEndTrackOnPad( D_PAD* Pad );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
static int OldNetCodeSurbrillance;
|
|
|
|
static int OldEtatSurbrillance;
|
2009-08-08 06:07:08 +00:00
|
|
|
static PICKED_ITEMS_LIST s_ItemsListPicker;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Routine to cancel the route if a track is being drawn, or exit the
|
|
|
|
* application EDITRACK.
|
2007-06-05 12:10:51 +00:00
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
static void Exit_Editrack( WinEDA_DrawPanel* Panel, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-12-21 12:05:36 +00:00
|
|
|
WinEDA_PcbFrame* frame = (WinEDA_PcbFrame*) Panel->GetParent();
|
2007-10-10 12:43:30 +00:00
|
|
|
TRACK* track = (TRACK*) frame->GetCurItem();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( track && ( track->Type()==TYPE_VIA || track->Type()==TYPE_TRACK ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
/* Erase the current drawing */
|
2009-10-01 16:46:13 +00:00
|
|
|
ShowNewTrackWhenMovingCursor( Panel, DC, false );
|
2010-01-24 13:46:01 +00:00
|
|
|
if( g_HighLight_Status )
|
|
|
|
frame->High_Light( DC );
|
2008-01-28 18:44:14 +00:00
|
|
|
|
2010-01-24 13:46:01 +00:00
|
|
|
g_HighLight_NetCode = OldNetCodeSurbrillance;
|
2007-08-20 01:20:48 +00:00
|
|
|
if( OldEtatSurbrillance )
|
2010-01-24 13:46:01 +00:00
|
|
|
frame->High_Light( DC );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
frame->MsgPanel->EraseMsgBox();
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Undo pending changes (mainly a lock point cretion) and clear the
|
|
|
|
// undo picker list:
|
2009-10-14 18:14:58 +00:00
|
|
|
frame->PutDataInPreviousState( &s_ItemsListPicker, false, false );
|
2009-08-08 06:07:08 +00:00
|
|
|
s_ItemsListPicker.ClearListAndDeleteItems();
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
// Delete current (new) track
|
2008-12-04 04:28:11 +00:00
|
|
|
g_CurrentTrackList.DeleteAll();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2008-01-28 18:44:14 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
Panel->ManageCurseur = NULL;
|
|
|
|
Panel->ForceCloseManageCurseur = NULL;
|
2007-09-12 02:14:07 +00:00
|
|
|
frame->SetCurItem( NULL );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-11-14 22:15:22 +00:00
|
|
|
* Begin drawing a new track and/or establish of a new track point.
|
2008-01-28 18:44:14 +00:00
|
|
|
*
|
2009-11-14 22:15:22 +00:00
|
|
|
* If no current track record of:
|
|
|
|
* - Search netname of the new track (pad out departure netname
|
|
|
|
* if the departure runway on an old track
|
|
|
|
* - Highlight all the net
|
|
|
|
* - Initialize the various trace pointers.
|
|
|
|
* If current track:
|
|
|
|
* - Control DRC
|
|
|
|
* - OK if DRC: adding a new track.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
TRACK* WinEDA_PcbFrame::Begin_Route( TRACK* aTrack, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-06-18 20:51:01 +00:00
|
|
|
D_PAD* pt_pad = NULL;
|
|
|
|
TRACK* TrackOnStartPoint = NULL;
|
2009-11-14 22:15:22 +00:00
|
|
|
int masquelayer =
|
|
|
|
g_TabOneLayerMask[( (PCB_SCREEN*) GetScreen() )->m_Active_Layer];
|
2009-06-18 20:51:01 +00:00
|
|
|
BOARD_ITEM* LockPoint;
|
|
|
|
wxPoint pos = GetScreen()->m_Curseur;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
DrawPanel->ManageCurseur = ShowNewTrackWhenMovingCursor;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = Exit_Editrack;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( aTrack == NULL ) /* Starting a new track */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-08-08 06:07:08 +00:00
|
|
|
// Prepare the undo command info
|
2009-11-14 22:15:22 +00:00
|
|
|
s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be
|
|
|
|
// necessary,
|
|
|
|
// but...
|
2009-08-08 06:07:08 +00:00
|
|
|
|
2008-11-27 10:12:46 +00:00
|
|
|
/* erase old highlight */
|
2010-01-24 13:46:01 +00:00
|
|
|
OldNetCodeSurbrillance = g_HighLight_NetCode;
|
|
|
|
OldEtatSurbrillance = g_HighLight_Status;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-01-24 13:46:01 +00:00
|
|
|
if( g_HighLight_Status )
|
|
|
|
High_Light( DC );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
g_CurrentTrackList.PushBack( new TRACK( GetBoard() ) );
|
2007-08-20 01:20:48 +00:00
|
|
|
g_CurrentTrackSegment->m_Flags = IS_NEW;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2010-01-24 13:46:01 +00:00
|
|
|
g_HighLight_NetCode = 0;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
// Search for a starting point of the new track, a track or pad
|
2009-01-05 05:21:35 +00:00
|
|
|
LockPoint = LocateLockPoint( GetBoard(), pos, masquelayer );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-01-28 18:44:14 +00:00
|
|
|
if( LockPoint ) // An item (pad or track) is found
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( LockPoint->Type() == TYPE_PAD )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
pt_pad = (D_PAD*) LockPoint;
|
2008-01-28 18:44:14 +00:00
|
|
|
|
|
|
|
/* A pad is found: put the starting point on pad centre */
|
2007-08-20 01:20:48 +00:00
|
|
|
pos = pt_pad->m_Pos;
|
2010-01-24 13:46:01 +00:00
|
|
|
g_HighLight_NetCode = pt_pad->GetNet();
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2008-01-28 18:44:14 +00:00
|
|
|
else /* A track segment is found */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-01-28 18:44:14 +00:00
|
|
|
TrackOnStartPoint = (TRACK*) LockPoint;
|
2010-01-24 13:46:01 +00:00
|
|
|
g_HighLight_NetCode = TrackOnStartPoint->GetNet();
|
2009-11-14 22:15:22 +00:00
|
|
|
CreateLockPoint( pos,
|
|
|
|
TrackOnStartPoint,
|
|
|
|
NULL,
|
|
|
|
&s_ItemsListPicker );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-14 22:15:22 +00:00
|
|
|
else // no starting point, but a filled zone area can exist. This is
|
|
|
|
// also a good starting point.
|
2008-11-27 10:12:46 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
ZONE_CONTAINER* zone =
|
|
|
|
GetBoard()->HitTestForAnyFilledArea( pos,
|
|
|
|
GetScreen()->
|
|
|
|
m_Active_Layer );
|
2008-12-04 04:28:11 +00:00
|
|
|
if( zone )
|
2010-01-24 13:46:01 +00:00
|
|
|
g_HighLight_NetCode = zone->GetNet();
|
2008-11-27 10:12:46 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
D( g_CurrentTrackList.VerifyListIntegrity(); );
|
|
|
|
|
2009-10-01 16:46:13 +00:00
|
|
|
build_ratsnest_pad( LockPoint, wxPoint( 0, 0 ), true );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
D( g_CurrentTrackList.VerifyListIntegrity(); );
|
|
|
|
|
2010-01-24 13:46:01 +00:00
|
|
|
High_Light( DC );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-10-03 17:18:08 +00:00
|
|
|
// Display info about track Net class, and init track and vias sizes:
|
2010-01-24 13:46:01 +00:00
|
|
|
g_CurrentTrackSegment->SetNet( g_HighLight_NetCode );
|
2009-10-03 17:18:08 +00:00
|
|
|
GetBoard()->SetCurrentNetClass( g_CurrentTrackSegment->GetNetClassName() );
|
|
|
|
m_TrackAndViasSizesList_Changed = true;
|
|
|
|
AuxiliaryToolBar_Update_UI();
|
|
|
|
|
2009-09-27 11:00:21 +00:00
|
|
|
g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer );
|
2009-10-30 17:58:15 +00:00
|
|
|
g_CurrentTrackSegment->m_Width = GetBoard()->GetCurrentTrackWidth();
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
if( GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth )
|
2008-01-28 18:44:14 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( TrackOnStartPoint && TrackOnStartPoint->Type() == TYPE_TRACK )
|
2009-10-03 17:18:08 +00:00
|
|
|
g_CurrentTrackSegment->m_Width = TrackOnStartPoint->m_Width;
|
2008-01-28 18:44:14 +00:00
|
|
|
}
|
|
|
|
g_CurrentTrackSegment->m_Start = pos;
|
2008-12-04 04:28:11 +00:00
|
|
|
g_CurrentTrackSegment->m_End = pos;
|
2009-09-27 11:00:21 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( pt_pad )
|
|
|
|
{
|
|
|
|
g_CurrentTrackSegment->start = pt_pad;
|
|
|
|
g_CurrentTrackSegment->SetState( BEGIN_ONPAD, ON );
|
|
|
|
}
|
|
|
|
else
|
2008-01-28 18:44:14 +00:00
|
|
|
g_CurrentTrackSegment->start = TrackOnStartPoint;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( g_TwoSegmentTrackBuild )
|
2008-01-28 18:44:14 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
// Create 2nd segment
|
|
|
|
g_CurrentTrackList.PushBack( g_CurrentTrackSegment->Copy() );
|
|
|
|
|
|
|
|
D( g_CurrentTrackList.VerifyListIntegrity(); );
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
g_CurrentTrackSegment->start = g_FirstTrackSegment;
|
2008-12-04 04:28:11 +00:00
|
|
|
g_FirstTrackSegment->end = g_CurrentTrackSegment;
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
g_FirstTrackSegment->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
|
|
|
|
}
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
D( g_CurrentTrackList.VerifyListIntegrity(); );
|
|
|
|
|
2009-10-14 18:14:58 +00:00
|
|
|
g_CurrentTrackSegment->DisplayInfoBase( this );
|
|
|
|
SetCurItem( g_CurrentTrackSegment, false );
|
2009-10-01 16:46:13 +00:00
|
|
|
DrawPanel->ManageCurseur( DrawPanel, DC, false );
|
2008-01-28 18:44:14 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
if( Drc_On )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
if( BAD_DRC ==
|
|
|
|
m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
|
|
|
return g_CurrentTrackSegment;
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
2009-11-14 22:15:22 +00:00
|
|
|
else /* Track in progress : segment coordinates are updated by
|
|
|
|
* ShowNewTrackWhenMovingCursor*/
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
/* Tst for a D.R.C. error: */
|
|
|
|
if( Drc_On )
|
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
if( BAD_DRC ==
|
|
|
|
m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
2008-01-28 18:44:14 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
// We must handle 2 segments
|
|
|
|
if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->Back() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
if( BAD_DRC ==
|
|
|
|
m_drc->Drc( g_CurrentTrackSegment->Back(),
|
|
|
|
GetBoard()->m_Track ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Current track is Ok: current segment is kept, and a new one is
|
|
|
|
* created unless the current segment is null, or 2 last are null
|
|
|
|
* if a 2 segments track build.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-10-01 16:46:13 +00:00
|
|
|
bool CanCreateNewSegment = true;
|
2007-08-20 01:20:48 +00:00
|
|
|
if( !g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull() )
|
2009-10-01 16:46:13 +00:00
|
|
|
CanCreateNewSegment = false;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( g_TwoSegmentTrackBuild && g_CurrentTrackSegment->IsNull()
|
2009-11-14 22:15:22 +00:00
|
|
|
&& g_CurrentTrackSegment->Back()
|
|
|
|
&& g_CurrentTrackSegment->Back()->IsNull() )
|
2009-10-01 16:46:13 +00:00
|
|
|
CanCreateNewSegment = false;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( CanCreateNewSegment )
|
|
|
|
{
|
|
|
|
/* Erase old track on screen */
|
2008-12-04 04:28:11 +00:00
|
|
|
D( g_CurrentTrackList.VerifyListIntegrity(); );
|
|
|
|
|
2009-10-01 16:46:13 +00:00
|
|
|
ShowNewTrackWhenMovingCursor( DrawPanel, DC, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
D( g_CurrentTrackList.VerifyListIntegrity(); );
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( g_Raccord_45_Auto )
|
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
Add_45_degrees_Segment( DC );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
TRACK* oneBeforeLatest = g_CurrentTrackSegment;
|
|
|
|
|
|
|
|
TRACK* newTrack = g_CurrentTrackSegment->Copy();
|
|
|
|
g_CurrentTrackList.PushBack( newTrack );
|
|
|
|
newTrack->m_Flags = IS_NEW;
|
|
|
|
|
|
|
|
newTrack->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
oneBeforeLatest->end = Locate_Pad_Connecte(
|
|
|
|
GetBoard(), oneBeforeLatest, END );
|
2008-12-04 04:28:11 +00:00
|
|
|
if( oneBeforeLatest->end )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
oneBeforeLatest->SetState( END_ONPAD, ON );
|
|
|
|
newTrack->SetState( BEGIN_ONPAD, ON );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->start = oneBeforeLatest->end;
|
|
|
|
|
|
|
|
D( g_CurrentTrackList.VerifyListIntegrity(); );
|
|
|
|
|
|
|
|
newTrack->m_Start = newTrack->m_End;
|
|
|
|
|
2009-06-18 20:51:01 +00:00
|
|
|
newTrack->SetLayer( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer );
|
2010-01-31 20:01:46 +00:00
|
|
|
if( !GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth )
|
2008-01-28 18:44:14 +00:00
|
|
|
{
|
2009-10-30 17:58:15 +00:00
|
|
|
newTrack->m_Width = GetBoard()->GetCurrentTrackWidth();
|
2008-01-28 18:44:14 +00:00
|
|
|
}
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-10-14 18:14:58 +00:00
|
|
|
D( g_CurrentTrackList.VerifyListIntegrity(); );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
/* Show the new position */
|
2009-10-01 16:46:13 +00:00
|
|
|
ShowNewTrackWhenMovingCursor( DrawPanel, DC, false );
|
2009-10-14 18:14:58 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-10-14 18:14:58 +00:00
|
|
|
SetCurItem( g_CurrentTrackSegment, false );
|
2007-08-20 01:20:48 +00:00
|
|
|
return g_CurrentTrackSegment;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Correct a bend is 90 and changes by 2 elbows at 45
|
|
|
|
* This only works on horizontal or vertical segments.
|
2008-01-28 18:44:14 +00:00
|
|
|
*
|
2009-11-14 22:15:22 +00:00
|
|
|
* Input: pointer to the segment that we have drawn
|
|
|
|
* Assume that the preceding segment is one that has been
|
|
|
|
* previously drawn
|
|
|
|
* Returns:
|
|
|
|
* 1 if ok
|
|
|
|
* 0 if not
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
bool WinEDA_PcbFrame::Add_45_degrees_Segment( wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-06-18 20:51:01 +00:00
|
|
|
int pas_45;
|
|
|
|
int dx0, dy0, dx1, dy1;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( g_CurrentTrackList.GetCount() < 2 )
|
2009-11-14 22:15:22 +00:00
|
|
|
return false; /* There must be 2 segments. */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
TRACK* curTrack = g_CurrentTrackSegment;
|
|
|
|
TRACK* prevTrack = curTrack->Back();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Test whether there has 2 consecutive segments to be connected.
|
2008-12-04 04:28:11 +00:00
|
|
|
if( curTrack->Type() != TYPE_TRACK || prevTrack->Type() != TYPE_TRACK )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
return false;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-10-14 19:43:31 +00:00
|
|
|
pas_45 = (int) GetScreen()->GetGridSize().x / 2;
|
2008-12-04 04:28:11 +00:00
|
|
|
if( pas_45 < curTrack->m_Width )
|
2009-10-14 19:43:31 +00:00
|
|
|
pas_45 = (int) GetScreen()->GetGridSize().x;
|
2008-02-27 15:26:16 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
while( pas_45 < curTrack->m_Width )
|
2007-08-20 01:20:48 +00:00
|
|
|
pas_45 *= 2;
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Test if the segments are horizontal or vertical.
|
2008-12-04 04:28:11 +00:00
|
|
|
dx0 = prevTrack->m_End.x - prevTrack->m_Start.x;
|
|
|
|
dy0 = prevTrack->m_End.y - prevTrack->m_Start.y;
|
|
|
|
|
|
|
|
dx1 = curTrack->m_End.x - curTrack->m_Start.x;
|
|
|
|
dy1 = curTrack->m_End.y - curTrack->m_Start.y;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Segments must be of sufficient length.
|
|
|
|
if( MAX( abs( dx0 ), abs( dy0 ) ) < ( pas_45 * 2 ) )
|
2008-12-04 04:28:11 +00:00
|
|
|
return false;
|
2008-01-28 18:44:14 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
if( MAX( abs( dx1 ), abs( dy1 ) ) < ( pas_45 * 2 ) )
|
2008-12-04 04:28:11 +00:00
|
|
|
return false;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Create a new segment and connect it with the previous 2 segments. */
|
2008-12-04 04:28:11 +00:00
|
|
|
TRACK* newTrack = curTrack->Copy();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->m_Start = prevTrack->m_End;
|
|
|
|
newTrack->m_End = curTrack->m_Start;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( dx0 == 0 ) // Segment precedent Vertical
|
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
if( dy1 != 0 ) // 2 segments are not 90 degrees.
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
delete newTrack;
|
|
|
|
return false;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Calculate coordinates the connection point.
|
|
|
|
* The new segment connects the 1st segment Vertical and the 2nd
|
|
|
|
* horizontal segment.
|
|
|
|
*/
|
2007-08-20 01:20:48 +00:00
|
|
|
if( dy0 > 0 )
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->m_Start.y -= pas_45;
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->m_Start.y += pas_45;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( dx1 > 0 )
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->m_End.x += pas_45;
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->m_End.x -= pas_45;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
if( Drc_On && BAD_DRC == m_drc->Drc( curTrack, GetBoard()->m_Track ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
delete newTrack;
|
|
|
|
return false;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
prevTrack->m_End = newTrack->m_Start;
|
|
|
|
curTrack->m_Start = newTrack->m_End;
|
|
|
|
|
|
|
|
g_CurrentTrackList.Insert( newTrack, curTrack );
|
|
|
|
return true;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
if( dy0 == 0 ) // Segment precedent horizontal
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
if( dx1 != 0 ) // 2 segments are not 90 degrees
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
delete newTrack;
|
|
|
|
return false;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Calculate the coordinates of the point of connection:
|
|
|
|
* A new segment has been established, connecting segment 1
|
|
|
|
* (horizontal) and segment 2 (vertical)
|
|
|
|
*/
|
2007-08-20 01:20:48 +00:00
|
|
|
if( dx0 > 0 )
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->m_Start.x -= pas_45;
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->m_Start.x += pas_45;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
if( dy1 > 0 )
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->m_End.y += pas_45;
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->m_End.y -= pas_45;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-01-05 05:21:35 +00:00
|
|
|
if( Drc_On && BAD_DRC==m_drc->Drc( newTrack, GetBoard()->m_Track ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
delete newTrack;
|
|
|
|
return false;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
prevTrack->m_End = newTrack->m_Start;
|
|
|
|
curTrack->m_Start = newTrack->m_End;
|
|
|
|
|
|
|
|
g_CurrentTrackList.Insert( newTrack, curTrack );
|
|
|
|
return true;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-11-14 22:15:22 +00:00
|
|
|
* End trace route in progress.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
void WinEDA_PcbFrame::End_Route( TRACK* aTrack, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
int masquelayer =
|
|
|
|
g_TabOneLayerMask[( (PCB_SCREEN*) GetScreen() )->m_Active_Layer];
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( aTrack == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
if( Drc_On && BAD_DRC==
|
|
|
|
m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Sauvegarde des coord du point terminal de la piste */
|
2008-12-04 04:28:11 +00:00
|
|
|
wxPoint pos = g_CurrentTrackSegment->m_End;
|
|
|
|
|
|
|
|
D( g_CurrentTrackList.VerifyListIntegrity(); );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( Begin_Route( aTrack, DC ) == NULL )
|
2007-08-20 01:20:48 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
ShowNewTrackWhenMovingCursor( DrawPanel, DC, true );
|
|
|
|
ShowNewTrackWhenMovingCursor( DrawPanel, DC, false );
|
|
|
|
trace_ratsnest_pad( DC );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
/* cleanup
|
2009-06-18 20:51:01 +00:00
|
|
|
* if( g_CurrentTrackSegment->Next() != NULL )
|
|
|
|
* {
|
|
|
|
* delete g_CurrentTrackSegment->Next();
|
|
|
|
* g_CurrentTrackSegment->SetNext( NULL );
|
|
|
|
* }
|
|
|
|
*/
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
D( g_CurrentTrackList.VerifyListIntegrity(); );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* The track here is non chained to the list of track segments.
|
|
|
|
* It must be seen in the area of net
|
|
|
|
* As close as possible to the segment base (or end), because
|
|
|
|
* This helps to reduce the computing time */
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Attaching the end of the track. */
|
2009-05-25 11:53:55 +00:00
|
|
|
BOARD_ITEM* LockPoint = LocateLockPoint( GetBoard(), pos, masquelayer );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
if( LockPoint ) /* End of trace is on a pad. */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( LockPoint->Type() == TYPE_PAD )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
EnsureEndTrackOnPad( (D_PAD*) LockPoint );
|
|
|
|
}
|
2009-11-14 22:15:22 +00:00
|
|
|
else /* End of is on a different track, it will
|
|
|
|
* possibly create an anchor. */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
TRACK* adr_buf = (TRACK*) LockPoint;
|
2010-01-24 13:46:01 +00:00
|
|
|
g_HighLight_NetCode = adr_buf->GetNet();
|
2008-02-27 15:26:16 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Possible establishment of a hanging point. */
|
2009-08-08 06:07:08 +00:00
|
|
|
LockPoint = CreateLockPoint( g_CurrentTrackSegment->m_End,
|
2007-08-20 01:20:48 +00:00
|
|
|
adr_buf,
|
2009-08-08 06:07:08 +00:00
|
|
|
g_CurrentTrackSegment,
|
2009-10-14 18:14:58 +00:00
|
|
|
&s_ItemsListPicker );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete Null segments:
|
2009-01-05 05:21:35 +00:00
|
|
|
DeleteNullTrackSegments( GetBoard(), g_CurrentTrackList );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
// Insert new segments if they exist. This can be NULL on a double click
|
|
|
|
// on the start point
|
2007-08-20 01:20:48 +00:00
|
|
|
if( g_FirstTrackSegment != NULL )
|
|
|
|
{
|
2009-06-18 20:51:01 +00:00
|
|
|
int netcode = g_FirstTrackSegment->GetNet();
|
|
|
|
TRACK* firstTrack = g_FirstTrackSegment;
|
|
|
|
int newCount = g_CurrentTrackList.GetCount();
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2010-01-21 20:36:48 +00:00
|
|
|
// Put entire new current segment list in BOARD, and prepare undo
|
2009-11-14 22:15:22 +00:00
|
|
|
// command
|
2008-12-04 04:28:11 +00:00
|
|
|
TRACK* track;
|
2009-11-14 22:15:22 +00:00
|
|
|
TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint(
|
|
|
|
GetBoard() );
|
2009-06-18 20:51:01 +00:00
|
|
|
while( ( track = g_CurrentTrackList.PopFront() ) != NULL )
|
2008-12-04 04:28:11 +00:00
|
|
|
{
|
2009-08-08 06:07:08 +00:00
|
|
|
ITEM_PICKER picker( track, UR_NEW );
|
|
|
|
s_ItemsListPicker.PushItem( picker );
|
2009-01-05 05:21:35 +00:00
|
|
|
GetBoard()->m_Track.Insert( track, insertBeforeMe );
|
2008-12-04 04:28:11 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
trace_ratsnest_pad( DC );
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
Trace_Une_Piste( DrawPanel, DC, firstTrack, newCount, GR_OR );
|
|
|
|
|
|
|
|
int i = 0;
|
2009-11-14 22:15:22 +00:00
|
|
|
for( track = firstTrack; track && i<newCount; ++i, track = track->Next() )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
track->m_Flags = 0;
|
2009-03-05 15:58:06 +00:00
|
|
|
track->SetState( BUSY, OFF );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
// erase the old track, if exists
|
2007-08-20 01:20:48 +00:00
|
|
|
if( g_AutoDeleteOldTrack )
|
|
|
|
{
|
2009-10-14 18:14:58 +00:00
|
|
|
EraseRedundantTrack( DC, firstTrack, newCount, &s_ItemsListPicker );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2009-10-14 18:14:58 +00:00
|
|
|
SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED );
|
2009-11-14 22:15:22 +00:00
|
|
|
s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more
|
|
|
|
// owner of picked items
|
|
|
|
/* compute the new rastnest */
|
2008-12-04 04:28:11 +00:00
|
|
|
test_1_net_connexion( DC, netcode );
|
2007-08-20 01:20:48 +00:00
|
|
|
GetScreen()->SetModify();
|
2009-04-17 08:51:02 +00:00
|
|
|
GetBoard()->DisplayInfo( this );
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
wxASSERT( g_FirstTrackSegment==NULL );
|
|
|
|
wxASSERT( g_CurrentTrackSegment==NULL );
|
|
|
|
wxASSERT( g_CurrentTrackList.GetCount()==0 );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-01-24 13:46:01 +00:00
|
|
|
if( g_HighLight_Status )
|
|
|
|
High_Light( DC );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2010-01-24 13:46:01 +00:00
|
|
|
g_HighLight_NetCode = OldNetCodeSurbrillance;
|
2007-08-20 01:20:48 +00:00
|
|
|
if( OldEtatSurbrillance )
|
2010-01-24 13:46:01 +00:00
|
|
|
High_Light( DC );
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
DrawPanel->ManageCurseur = NULL;
|
|
|
|
DrawPanel->ForceCloseManageCurseur = NULL;
|
2007-09-12 02:14:07 +00:00
|
|
|
SetCurItem( NULL );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-27 15:26:16 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack )
|
2008-02-27 15:26:16 +00:00
|
|
|
{
|
2009-09-10 15:22:26 +00:00
|
|
|
int net = aTrack->GetNet();
|
|
|
|
int width = aTrack->m_Width;
|
2008-02-29 20:35:11 +00:00
|
|
|
int layer = ( (PCB_SCREEN*) ActiveScreen )->m_Active_Layer;
|
2008-02-27 15:26:16 +00:00
|
|
|
|
2008-02-29 20:35:11 +00:00
|
|
|
wxPoint ref = ActiveScreen->RefPos( true );
|
2008-02-27 15:26:16 +00:00
|
|
|
|
2008-02-29 20:35:11 +00:00
|
|
|
TRACK* found = NULL;
|
2008-02-27 15:26:16 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
for( TRACK* track = listStart; track; track = track->Next() )
|
2008-02-29 20:35:11 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( track->Type() == TYPE_TRACK ) // skip vias
|
2008-02-29 20:35:11 +00:00
|
|
|
{
|
|
|
|
if( track->GetState( BUSY | DELETED ) )
|
|
|
|
continue;
|
2008-02-27 15:26:16 +00:00
|
|
|
|
2008-02-29 20:35:11 +00:00
|
|
|
if( layer != track->GetLayer() )
|
|
|
|
continue;
|
2008-02-27 15:26:16 +00:00
|
|
|
|
2008-02-29 20:35:11 +00:00
|
|
|
if( track->GetNet() == net )
|
|
|
|
continue;
|
2008-02-27 15:26:16 +00:00
|
|
|
|
2008-02-29 20:35:11 +00:00
|
|
|
/* TRACK::HitTest */
|
2009-11-14 22:15:22 +00:00
|
|
|
int dist = (width + track->m_Width) / 2 + aTrack->GetClearance(
|
|
|
|
track );
|
2008-02-27 15:26:16 +00:00
|
|
|
|
2009-06-18 20:51:01 +00:00
|
|
|
wxPoint pos = ref - track->m_Start;
|
|
|
|
wxPoint vec = track->m_End - track->m_Start;
|
2008-02-27 15:26:16 +00:00
|
|
|
|
2008-02-29 20:35:11 +00:00
|
|
|
if( !DistanceTest( dist, vec.x, vec.y, pos.x, pos.y ) )
|
|
|
|
continue;
|
2008-02-27 15:26:16 +00:00
|
|
|
|
2008-02-29 20:35:11 +00:00
|
|
|
found = track;
|
|
|
|
|
|
|
|
/* prefer intrusions from the side, not the end */
|
2008-02-29 23:01:30 +00:00
|
|
|
double tmp = (double) pos.x * vec.x + (double) pos.y * vec.y;
|
2009-11-14 22:15:22 +00:00
|
|
|
if( tmp >= 0 && tmp <= (double) vec.x * vec.x + (double) vec.y *
|
|
|
|
vec.y )
|
2008-02-29 20:35:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-02-27 15:26:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function PushTrack
|
|
|
|
* detects if the mouse is pointing into a conflicting track.
|
2008-02-26 21:12:08 +00:00
|
|
|
* In this case, it tries to push the new track out of the conflicting track's
|
|
|
|
* clearance zone. This gives us a cheap mechanism for drawing tracks that
|
|
|
|
* tightly follow others, independent of grid settings.
|
|
|
|
*
|
|
|
|
* KNOWN BUGS:
|
|
|
|
* - we do the same sort of search and calculation up to three times:
|
|
|
|
* 1) we search for magnetic hits (in controle.cpp)
|
|
|
|
* 2) we check if there's a DRC violation in the making (also controle.cpp)
|
|
|
|
* 3) we try to fix the DRC violation (here)
|
|
|
|
* - if we have a magnetic hit and a DRC violation at the same time, we choose
|
|
|
|
* the magnetic hit instead of solving the violation
|
|
|
|
* - should locate conflicting tracks also when we're crossing over them
|
|
|
|
*/
|
2008-02-27 15:26:16 +00:00
|
|
|
static void PushTrack( WinEDA_DrawPanel* panel )
|
2008-02-26 21:12:08 +00:00
|
|
|
{
|
2009-12-21 12:05:36 +00:00
|
|
|
BOARD* pcb = ( (WinEDA_BasePcbFrame*) (panel->GetParent()) )->GetBoard();
|
2008-02-26 21:12:08 +00:00
|
|
|
wxPoint cursor = ActiveScreen->m_Curseur;
|
|
|
|
wxPoint cv, vec, n;
|
2008-02-27 15:26:16 +00:00
|
|
|
TRACK* track = g_CurrentTrackSegment;
|
|
|
|
TRACK* other;
|
2008-02-29 23:01:30 +00:00
|
|
|
double det;
|
2008-02-27 15:26:16 +00:00
|
|
|
int dist;
|
|
|
|
double f;
|
2008-02-26 21:12:08 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
other = LocateIntrusion( pcb->m_Track, track );
|
2008-02-26 21:12:08 +00:00
|
|
|
|
|
|
|
/* are we currently pointing into a conflicting trace ? */
|
2008-02-27 15:26:16 +00:00
|
|
|
if( !other )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( other->GetNet() == track->GetNet() )
|
|
|
|
return;
|
2008-02-26 21:12:08 +00:00
|
|
|
|
2008-02-27 15:26:16 +00:00
|
|
|
cv = cursor - other->m_Start;
|
|
|
|
vec = other->m_End - other->m_Start;
|
2008-02-26 21:12:08 +00:00
|
|
|
|
2008-02-29 23:01:30 +00:00
|
|
|
det = (double) cv.x * vec.y - (double) cv.y * vec.x;
|
2008-02-26 21:12:08 +00:00
|
|
|
|
|
|
|
/* cursor is right at the center of the old track */
|
2008-02-27 15:26:16 +00:00
|
|
|
if( !det )
|
|
|
|
return;
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
dist =
|
|
|
|
(track->m_Width +
|
|
|
|
1) / 2 + (other->m_Width + 1) / 2 + track->GetClearance(
|
|
|
|
other ) + 2;
|
2008-02-27 15:26:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* DRC wants >, so +1.
|
|
|
|
* We may have a quantization error of 1/sqrt(2), so +1 again.
|
|
|
|
*/
|
2008-02-26 21:12:08 +00:00
|
|
|
|
|
|
|
/* Vector "n" is perpendicular to "other", pointing towards the cursor. */
|
2008-02-27 15:26:16 +00:00
|
|
|
if( det > 0 )
|
|
|
|
{
|
|
|
|
n.x = vec.y;
|
|
|
|
n.y = -vec.x;
|
2008-02-26 21:12:08 +00:00
|
|
|
}
|
2008-02-27 15:26:16 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
n.x = -vec.y;
|
|
|
|
n.y = vec.x;
|
2008-02-26 21:12:08 +00:00
|
|
|
}
|
2008-02-29 23:01:30 +00:00
|
|
|
f = dist / hypot( double(n.x), double(n.y) );
|
2009-04-05 20:49:15 +00:00
|
|
|
n.x = wxRound( f * n.x );
|
|
|
|
n.y = wxRound( f * n.y );
|
2008-02-26 21:12:08 +00:00
|
|
|
|
2008-02-29 20:35:11 +00:00
|
|
|
Project( &track->m_End, cursor, other );
|
2008-02-26 21:12:08 +00:00
|
|
|
track->m_End += n;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-27 15:26:16 +00:00
|
|
|
|
2009-10-03 17:18:08 +00:00
|
|
|
/* Redraw the current track beiing created when the mouse cursor is moved
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
void ShowNewTrackWhenMovingCursor( WinEDA_DrawPanel* panel,
|
|
|
|
wxDC* DC,
|
|
|
|
bool erase )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
D( g_CurrentTrackList.VerifyListIntegrity(); );
|
|
|
|
|
2009-10-14 18:14:58 +00:00
|
|
|
PCB_SCREEN* screen = (PCB_SCREEN*) panel->GetScreen();
|
2009-12-21 12:05:36 +00:00
|
|
|
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->GetParent();
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-10-14 18:14:58 +00:00
|
|
|
bool Track_fill_copy = DisplayOpt.DisplayPcbTrackFill;
|
2009-05-21 17:42:42 +00:00
|
|
|
DisplayOpt.DisplayPcbTrackFill = true;
|
2009-10-14 18:14:58 +00:00
|
|
|
int showTrackClearanceMode = DisplayOpt.ShowTrackClearanceMode;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
NETCLASS* netclass = g_FirstTrackSegment->GetNetClass();
|
|
|
|
|
2009-06-18 20:51:01 +00:00
|
|
|
if( showTrackClearanceMode != DO_NOT_SHOW_CLEARANCE )
|
|
|
|
DisplayOpt.ShowTrackClearanceMode = SHOW_CLEARANCE_ALWAYS;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-10-03 17:18:08 +00:00
|
|
|
/* Erase old track */
|
2007-08-20 01:20:48 +00:00
|
|
|
if( erase )
|
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
Trace_Une_Piste( panel,
|
|
|
|
DC,
|
|
|
|
g_FirstTrackSegment,
|
|
|
|
g_CurrentTrackList.GetCount(),
|
|
|
|
GR_XOR );
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2009-10-14 18:14:58 +00:00
|
|
|
frame->trace_ratsnest_pad( DC );
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS )
|
2009-06-18 17:32:27 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
int color =
|
2010-01-29 20:36:12 +00:00
|
|
|
g_ColorsSettings.GetLayerColor(g_CurrentTrackSegment->GetLayer());
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2009-06-18 17:32:27 +00:00
|
|
|
GRCircle( &panel->m_ClipBox, DC, g_CurrentTrackSegment->m_End.x,
|
2009-06-18 20:51:01 +00:00
|
|
|
g_CurrentTrackSegment->m_End.y,
|
2009-11-14 22:15:22 +00:00
|
|
|
( netclass->GetViaDiameter() / 2 ) + netclass->GetClearance(),
|
2009-06-18 20:51:01 +00:00
|
|
|
color );
|
2009-06-18 17:32:27 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
2009-03-30 19:28:54 +00:00
|
|
|
// MacOSX seems to need this.
|
|
|
|
if( g_CurrentTrackList.GetCount() == 0 )
|
|
|
|
return;
|
|
|
|
|
2009-10-03 17:18:08 +00:00
|
|
|
// Set track parameters, that can be modified while creating the track
|
2007-08-23 04:28:46 +00:00
|
|
|
g_CurrentTrackSegment->SetLayer( screen->m_Active_Layer );
|
2009-10-30 17:58:15 +00:00
|
|
|
g_CurrentTrackSegment->m_Width = frame->GetBoard()->GetCurrentTrackWidth();
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( g_TwoSegmentTrackBuild )
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
TRACK* previous_track = g_CurrentTrackSegment->Back();
|
2008-12-04 04:28:11 +00:00
|
|
|
if( previous_track && previous_track->Type()==TYPE_TRACK )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
previous_track->SetLayer( screen->m_Active_Layer );
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
if( !frame->GetBoard()->GetBoardDesignSettings()->m_UseConnectedTrackWidth )
|
2009-11-14 22:15:22 +00:00
|
|
|
previous_track->m_Width =
|
|
|
|
frame->GetBoard()->GetCurrentTrackWidth();
|
2008-02-12 01:02:53 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( Track_45_Only )
|
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( g_TwoSegmentTrackBuild )
|
|
|
|
{
|
|
|
|
g_CurrentTrackSegment->m_End = ActiveScreen->m_Curseur;
|
|
|
|
|
|
|
|
if( Drc_On )
|
2009-06-18 20:51:01 +00:00
|
|
|
PushTrack( panel );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
ComputeBreakPoint( g_CurrentTrackSegment,
|
|
|
|
g_CurrentTrackList.GetCount(),
|
2009-06-18 20:51:01 +00:00
|
|
|
g_CurrentTrackSegment->m_End );
|
2008-12-04 04:28:11 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Calculate of the end of the path for the permitted directions:
|
|
|
|
* horizontal, vertical or 45 degrees.
|
2008-12-04 04:28:11 +00:00
|
|
|
*/
|
2007-08-20 01:20:48 +00:00
|
|
|
Calcule_Coord_Extremite_45( g_CurrentTrackSegment->m_Start.x,
|
|
|
|
g_CurrentTrackSegment->m_Start.y,
|
|
|
|
&g_CurrentTrackSegment->m_End.x,
|
|
|
|
&g_CurrentTrackSegment->m_End.y );
|
|
|
|
}
|
|
|
|
}
|
2009-11-14 22:15:22 +00:00
|
|
|
else /* Here the angle is arbitrary */
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
g_CurrentTrackSegment->m_End = screen->m_Curseur;
|
|
|
|
}
|
|
|
|
|
2009-10-03 17:18:08 +00:00
|
|
|
/* Redraw the new track */
|
2008-12-04 04:28:11 +00:00
|
|
|
D( g_CurrentTrackList.VerifyListIntegrity(); );
|
2009-11-14 22:15:22 +00:00
|
|
|
Trace_Une_Piste( panel,
|
|
|
|
DC,
|
|
|
|
g_FirstTrackSegment,
|
|
|
|
g_CurrentTrackList.GetCount(),
|
|
|
|
GR_XOR );
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS )
|
2009-06-18 17:32:27 +00:00
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
int color =
|
2010-01-29 20:36:12 +00:00
|
|
|
g_ColorsSettings.GetLayerColor(g_CurrentTrackSegment->GetLayer());
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2009-06-18 17:32:27 +00:00
|
|
|
GRCircle( &panel->m_ClipBox, DC, g_CurrentTrackSegment->m_End.x,
|
2009-06-18 20:51:01 +00:00
|
|
|
g_CurrentTrackSegment->m_End.y,
|
2009-11-14 22:15:22 +00:00
|
|
|
( netclass->GetViaDiameter() / 2 ) + netclass->GetClearance(),
|
2009-06-18 20:51:01 +00:00
|
|
|
color );
|
2009-06-18 17:32:27 +00:00
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-10-14 18:14:58 +00:00
|
|
|
/* Display info about currrent segment and the full new track:
|
|
|
|
* Choose the interesting segment: because we are using a 2 segments step,
|
2009-11-14 22:15:22 +00:00
|
|
|
* the last segment can be null, and the previous segment can be the
|
|
|
|
* interesting segment.
|
2009-10-14 18:14:58 +00:00
|
|
|
*/
|
|
|
|
TRACK* isegm = g_CurrentTrackSegment;
|
|
|
|
if( isegm->GetLength() == 0 && g_CurrentTrackSegment->Back() )
|
|
|
|
isegm = g_CurrentTrackSegment->Back();
|
|
|
|
|
|
|
|
// display interesting segment info only:
|
|
|
|
isegm->DisplayInfoBase( frame );
|
|
|
|
|
|
|
|
// Add current track length
|
2010-01-13 21:15:54 +00:00
|
|
|
double trackLen = 0.0;
|
2009-10-14 18:14:58 +00:00
|
|
|
wxString msg;
|
|
|
|
for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() )
|
|
|
|
trackLen += track->GetLength();
|
|
|
|
|
2010-01-13 21:15:54 +00:00
|
|
|
valeur_param( wxRound( trackLen ), msg );
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Track Len" ), msg, DARKCYAN );
|
2009-10-14 18:14:58 +00:00
|
|
|
|
|
|
|
// Add current segments count (number of segments in this new track):
|
|
|
|
msg.Printf( wxT( "%d" ), g_CurrentTrackList.GetCount() );
|
2009-10-16 17:18:23 +00:00
|
|
|
frame->AppendMsgPanel( _( "Segs Count" ), msg, DARKCYAN );
|
2009-10-14 18:14:58 +00:00
|
|
|
|
2009-06-18 20:51:01 +00:00
|
|
|
DisplayOpt.ShowTrackClearanceMode = showTrackClearanceMode;
|
|
|
|
DisplayOpt.DisplayPcbTrackFill = Track_fill_copy;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2009-10-14 18:14:58 +00:00
|
|
|
frame->build_ratsnest_pad( NULL, g_CurrentTrackSegment->m_End, false );
|
|
|
|
frame->trace_ratsnest_pad( DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Determine the coordinate to advanced the the current segment
|
|
|
|
* in 0, 90, or 45 degrees, depending on position of origin and
|
|
|
|
* cursor position.
|
2007-08-20 01:20:48 +00:00
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
void Calcule_Coord_Extremite_45( int ox, int oy, int* fx, int* fy )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int deltax, deltay, angle;
|
|
|
|
|
|
|
|
deltax = ActiveScreen->m_Curseur.x - ox;
|
|
|
|
deltay = ActiveScreen->m_Curseur.y - oy;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
deltax = abs( deltax );
|
|
|
|
deltay = abs( deltay );
|
2009-06-18 20:51:01 +00:00
|
|
|
angle = 45;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( deltax >= deltay )
|
|
|
|
{
|
|
|
|
if( deltax == 0 )
|
|
|
|
angle = 0;
|
|
|
|
else if( ( (deltay << 6 ) / deltax ) < 26 )
|
|
|
|
angle = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
angle = 45;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( deltay == 0 )
|
|
|
|
angle = 90;
|
|
|
|
else if( ( (deltax << 6 ) / deltay ) < 26 )
|
|
|
|
angle = 90;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch( angle )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
*fx = ActiveScreen->m_Curseur.x;
|
|
|
|
*fy = oy;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 45:
|
2008-12-04 04:28:11 +00:00
|
|
|
deltax = MIN( deltax, deltay );
|
|
|
|
deltay = deltax;
|
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Recalculate the signs fo deltax and deltaY. */
|
|
|
|
if( ( ActiveScreen->m_Curseur.x - ox ) < 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
deltax = -deltax;
|
2009-11-14 22:15:22 +00:00
|
|
|
if( ( ActiveScreen->m_Curseur.y - oy ) < 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
deltay = -deltay;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
*fx = ox + deltax;
|
|
|
|
*fy = oy + deltay;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 90:
|
|
|
|
*fx = ox;
|
|
|
|
*fy = ActiveScreen->m_Curseur.y;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compute new track angle based on previous track.
|
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
int iDx = 0;
|
|
|
|
int iDy = 0;
|
|
|
|
int iAngle = 0;
|
|
|
|
|
|
|
|
if( SegmentCount <= 0 )
|
|
|
|
return;
|
|
|
|
if( track == NULL )
|
|
|
|
return;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
TRACK* newTrack = track;
|
2008-11-24 06:53:43 +00:00
|
|
|
track = track->Back();
|
2007-08-20 01:20:48 +00:00
|
|
|
SegmentCount--;
|
|
|
|
if( track )
|
|
|
|
{
|
2008-02-26 21:12:08 +00:00
|
|
|
iDx = end.x - track->m_Start.x;
|
|
|
|
iDy = end.y - track->m_Start.y;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
iDx = abs( iDx );
|
|
|
|
iDy = abs( iDy );
|
|
|
|
}
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
TRACK* lastTrack = track ? track->Back() : NULL;
|
|
|
|
if( lastTrack )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( (lastTrack->m_End.x == lastTrack->m_Start.x)
|
2009-06-18 20:51:01 +00:00
|
|
|
|| (lastTrack->m_End.y == lastTrack->m_Start.y) )
|
2007-08-20 01:20:48 +00:00
|
|
|
{
|
|
|
|
iAngle = 45;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( iAngle == 0 )
|
|
|
|
{
|
|
|
|
if( iDx >= iDy )
|
|
|
|
iAngle = 0;
|
|
|
|
else
|
|
|
|
iAngle = 90;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( track == NULL )
|
|
|
|
iAngle = -1;
|
|
|
|
|
|
|
|
switch( iAngle )
|
|
|
|
{
|
2009-11-14 22:15:22 +00:00
|
|
|
case -1:
|
2007-08-20 01:20:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
2009-11-14 22:15:22 +00:00
|
|
|
if( ( end.x - track->m_Start.x ) < 0 )
|
2008-02-26 21:12:08 +00:00
|
|
|
track->m_End.x = end.x + iDy;
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2008-02-26 21:12:08 +00:00
|
|
|
track->m_End.x = end.x - iDy;
|
2007-08-20 01:20:48 +00:00
|
|
|
track->m_End.y = track->m_Start.y;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 45:
|
2007-08-23 04:28:46 +00:00
|
|
|
iDx = MIN( iDx, iDy );
|
2007-08-20 01:20:48 +00:00
|
|
|
iDy = iDx;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-11-14 22:15:22 +00:00
|
|
|
/* Recalculate the signs fo deltax and deltaY. */
|
|
|
|
if( ( end.x - track->m_Start.x ) < 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
iDx = -iDx;
|
2009-11-14 22:15:22 +00:00
|
|
|
if( ( end.y - track->m_Start.y ) < 0 )
|
2007-08-20 01:20:48 +00:00
|
|
|
iDy = -iDy;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
track->m_End.x = track->m_Start.x + iDx;
|
|
|
|
track->m_End.y = track->m_Start.y + iDy;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 90:
|
2009-11-14 22:15:22 +00:00
|
|
|
if( ( end.y - track->m_Start.y ) < 0 )
|
2008-02-26 21:12:08 +00:00
|
|
|
track->m_End.y = end.y + iDx;
|
2007-08-20 01:20:48 +00:00
|
|
|
else
|
2008-02-26 21:12:08 +00:00
|
|
|
track->m_End.y = end.y - iDx;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
track->m_End.x = track->m_Start.x;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( track )
|
|
|
|
{
|
|
|
|
if( track->IsNull() )
|
2008-02-26 21:12:08 +00:00
|
|
|
track->m_End = end;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
newTrack->m_Start = track->m_End;
|
2007-08-20 01:20:48 +00:00
|
|
|
}
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->m_End = end;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Delete track segments which have len = 0; after creating a new track
|
2007-08-20 01:20:48 +00:00
|
|
|
* return a pointer on the first segment (start of track list)
|
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
if( aTrackList.GetCount() == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
TRACK* track = aTrackList.GetFirst();
|
2008-01-28 18:44:14 +00:00
|
|
|
TRACK* firsttrack = track;
|
|
|
|
TRACK* oldtrack;
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
BOARD_ITEM* LockPoint = track->start;
|
2007-08-20 01:20:48 +00:00
|
|
|
while( track != NULL )
|
|
|
|
{
|
|
|
|
oldtrack = track;
|
|
|
|
track = track->Next();
|
|
|
|
if( !oldtrack->IsNull() )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NULL segment, delete it
|
|
|
|
if( firsttrack == oldtrack )
|
|
|
|
firsttrack = track;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
delete aTrackList.Remove( oldtrack );
|
|
|
|
}
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( aTrackList.GetCount() == 0 )
|
|
|
|
return; // all the new track segments have been deleted
|
2007-08-20 01:20:48 +00:00
|
|
|
|
|
|
|
// we must set the pointers on connected items and the connection status
|
|
|
|
oldtrack = track = firsttrack;
|
|
|
|
firsttrack->start = NULL;
|
|
|
|
while( track != NULL )
|
|
|
|
{
|
2009-06-18 20:51:01 +00:00
|
|
|
oldtrack = track;
|
|
|
|
track = track->Next();
|
2007-08-20 01:20:48 +00:00
|
|
|
oldtrack->end = track;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
if( track )
|
|
|
|
track->start = oldtrack;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
oldtrack->SetStatus( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
firsttrack->start = LockPoint;
|
2008-12-04 04:28:11 +00:00
|
|
|
if( LockPoint && LockPoint->Type()==TYPE_PAD )
|
2007-08-20 01:20:48 +00:00
|
|
|
firsttrack->SetState( BEGIN_ONPAD, ON );
|
|
|
|
|
|
|
|
track = firsttrack;
|
|
|
|
while( track != NULL )
|
|
|
|
{
|
|
|
|
TRACK* next_track = track->Next();
|
|
|
|
LockPoint = Locate_Pad_Connecte( pcb, track, END );
|
|
|
|
if( LockPoint )
|
|
|
|
{
|
|
|
|
track->end = LockPoint;
|
|
|
|
track->SetState( END_ONPAD, ON );
|
|
|
|
if( next_track )
|
|
|
|
{
|
|
|
|
next_track->start = LockPoint;
|
|
|
|
next_track->SetState( BEGIN_ONPAD, ON );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
track = next_track;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Ensure the end point of g_CurrentTrackSegment is on the pas "Pad"
|
2007-08-20 01:20:48 +00:00
|
|
|
* if no, create a new track segment if necessary
|
|
|
|
* and move current (or new) end segment on pad
|
|
|
|
*/
|
2009-11-14 22:15:22 +00:00
|
|
|
void EnsureEndTrackOnPad( D_PAD* Pad )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-20 01:20:48 +00:00
|
|
|
if( g_CurrentTrackSegment->m_End == Pad->m_Pos ) // Ok !
|
|
|
|
{
|
|
|
|
g_CurrentTrackSegment->end = Pad;
|
|
|
|
g_CurrentTrackSegment->SetState( END_ONPAD, ON );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACK* lasttrack = g_CurrentTrackSegment;
|
|
|
|
if( !g_CurrentTrackSegment->IsNull() )
|
2008-01-28 18:44:14 +00:00
|
|
|
{
|
2007-08-30 22:20:52 +00:00
|
|
|
/* Must create a new segment, from track end to pad center */
|
2008-12-04 04:28:11 +00:00
|
|
|
g_CurrentTrackList.PushBack( lasttrack->Copy() );
|
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
lasttrack->end = g_CurrentTrackSegment;
|
|
|
|
}
|
2008-01-28 18:44:14 +00:00
|
|
|
|
2007-08-20 01:20:48 +00:00
|
|
|
g_CurrentTrackSegment->m_End = Pad->m_Pos;
|
|
|
|
g_CurrentTrackSegment->SetState( END_ONPAD, OFF );
|
|
|
|
|
|
|
|
g_CurrentTrackSegment->end = Pad;
|
|
|
|
g_CurrentTrackSegment->SetState( END_ONPAD, ON );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|