2009-11-20 14:55:20 +00:00
|
|
|
/*************/
|
|
|
|
/* solve.cpp */
|
|
|
|
/*************/
|
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"
|
|
|
|
#include "confirm.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"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "autorout.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
#include "cell.h"
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
|
|
|
|
wxDC* DC,
|
|
|
|
int two_sides,
|
|
|
|
int row_source,
|
|
|
|
int col_source,
|
|
|
|
int row_target,
|
|
|
|
int col_target,
|
|
|
|
RATSNEST_ITEM* pt_chevelu );
|
|
|
|
static int Retrace( PCB_EDIT_FRAME* pcbframe,
|
|
|
|
wxDC* DC,
|
2009-11-20 14:55:20 +00:00
|
|
|
int,
|
|
|
|
int,
|
|
|
|
int,
|
|
|
|
int,
|
|
|
|
int,
|
|
|
|
int net_code );
|
|
|
|
static void OrCell_Trace( BOARD* pcb,
|
|
|
|
int col,
|
|
|
|
int row,
|
|
|
|
int side,
|
|
|
|
int orient,
|
|
|
|
int current_net_code );
|
2011-03-01 19:26:17 +00:00
|
|
|
static void Place_Piste_en_Buffer( PCB_EDIT_FRAME* pcbframe, wxDC* DC );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
|
|
|
|
static int segm_oX, segm_oY;
|
|
|
|
static int segm_fX, segm_fY; /* Origin and position of the current
|
|
|
|
* trace segment. */
|
2009-05-24 18:28:36 +00:00
|
|
|
static RATSNEST_ITEM* pt_cur_ch;
|
2009-11-20 14:55:20 +00:00
|
|
|
static int Ncurrent; /* measures of progress */
|
|
|
|
static int s_Clearance; // Clearance value used in autorouter
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
#define NOSUCCESS 0
|
|
|
|
#define STOP_FROM_ESC -1
|
|
|
|
#define ERR_MEMORY -2
|
|
|
|
#define SUCCESS 1
|
2007-06-05 12:10:51 +00:00
|
|
|
#define TRIVIAL_SUCCESS 2
|
|
|
|
|
|
|
|
/*
|
|
|
|
** visit neighboring cells like this (where [9] is on the other side):
|
|
|
|
**
|
|
|
|
** +---+---+---+
|
|
|
|
** | 1 | 2 | 3 |
|
|
|
|
** +---+---+---+
|
|
|
|
** | 4 |[9]| 5 |
|
|
|
|
** +---+---+---+
|
|
|
|
** | 6 | 7 | 8 |
|
|
|
|
** +---+---+---+
|
|
|
|
*/
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* for visiting neighbors on the same side: increments/decrements coord of
|
|
|
|
* [] [0] = row [] (1] = col was added to the coord of the midpoint for
|
|
|
|
* Get the coord of the 8 neighboring points.
|
|
|
|
*/
|
|
|
|
static int delta[8][2] =
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
{ 1, -1 }, /* northwest */
|
|
|
|
{ 1, 0 }, /* north */
|
|
|
|
{ 1, 1 }, /* northeast */
|
|
|
|
{ 0, -1 }, /* west */
|
|
|
|
{ 0, 1 }, /* east */
|
|
|
|
{ -1, -1 }, /* southwest */
|
|
|
|
{ -1, 0 }, /* south */
|
|
|
|
{ -1, 1 } /* southeast */
|
|
|
|
};
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
static int ndir[8] =
|
|
|
|
{
|
|
|
|
/* for building paths back to source */
|
2009-01-25 17:38:30 +00:00
|
|
|
FROM_SOUTHEAST, FROM_SOUTH, FROM_SOUTHWEST,
|
2007-08-23 04:28:46 +00:00
|
|
|
FROM_EAST, FROM_WEST,
|
2009-01-25 17:38:30 +00:00
|
|
|
FROM_NORTHEAST, FROM_NORTH, FROM_NORTHWEST
|
2007-08-23 04:28:46 +00:00
|
|
|
};
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* blocking masks for neighboring cells */
|
2008-04-30 11:52:34 +00:00
|
|
|
#define BLOCK_NORTHEAST ( DIAG_NEtoSW | BENT_StoNE | BENT_WtoNE \
|
2009-11-20 14:55:20 +00:00
|
|
|
| ANGLE_NEtoSE | ANGLE_NWtoNE \
|
2008-04-30 11:52:34 +00:00
|
|
|
| SHARP_NtoNE | SHARP_EtoNE | HOLE )
|
|
|
|
#define BLOCK_SOUTHEAST ( DIAG_SEtoNW | BENT_NtoSE | BENT_WtoSE \
|
2009-11-20 14:55:20 +00:00
|
|
|
| ANGLE_NEtoSE | ANGLE_SEtoSW \
|
2008-04-30 11:52:34 +00:00
|
|
|
| SHARP_EtoSE | SHARP_StoSE | HOLE )
|
|
|
|
#define BLOCK_SOUTHWEST ( DIAG_NEtoSW | BENT_NtoSW | BENT_EtoSW \
|
2009-11-20 14:55:20 +00:00
|
|
|
| ANGLE_SEtoSW | ANGLE_SWtoNW \
|
2008-04-30 11:52:34 +00:00
|
|
|
| SHARP_StoSW | SHARP_WtoSW | HOLE )
|
|
|
|
#define BLOCK_NORTHWEST ( DIAG_SEtoNW | BENT_EtoNW | BENT_StoNW \
|
2009-11-20 14:55:20 +00:00
|
|
|
| ANGLE_SWtoNW | ANGLE_NWtoNE \
|
2008-04-30 11:52:34 +00:00
|
|
|
| SHARP_WtoNW | SHARP_NtoNW | HOLE )
|
2009-11-20 14:55:20 +00:00
|
|
|
#define BLOCK_NORTH ( LINE_VERTICAL | BENT_NtoSE | BENT_NtoSW \
|
|
|
|
| BENT_EtoNW | BENT_WtoNE \
|
|
|
|
| BENT_StoNE | BENT_StoNW \
|
|
|
|
| CORNER_NORTHEAST | CORNER_NORTHWEST \
|
2008-04-30 11:52:34 +00:00
|
|
|
| ANGLE_NEtoSE | ANGLE_SWtoNW | ANGLE_NWtoNE \
|
2009-11-20 14:55:20 +00:00
|
|
|
| DIAG_NEtoSW | DIAG_SEtoNW \
|
|
|
|
| SHARP_NtoNE | SHARP_NtoNW \
|
2008-04-30 11:52:34 +00:00
|
|
|
| SHARP_EtoNE | SHARP_WtoNW | HOLE )
|
2009-11-20 14:55:20 +00:00
|
|
|
#define BLOCK_EAST ( LINE_HORIZONTAL | BENT_EtoSW | BENT_EtoNW \
|
|
|
|
| BENT_NtoSE | BENT_StoNE \
|
|
|
|
| BENT_WtoNE | BENT_WtoSE \
|
|
|
|
| CORNER_NORTHEAST | CORNER_SOUTHEAST \
|
2008-04-30 11:52:34 +00:00
|
|
|
| ANGLE_NEtoSE | ANGLE_SEtoSW | ANGLE_NWtoNE \
|
2009-11-20 14:55:20 +00:00
|
|
|
| DIAG_NEtoSW | DIAG_SEtoNW \
|
|
|
|
| SHARP_EtoNE | SHARP_EtoSE \
|
2008-04-30 11:52:34 +00:00
|
|
|
| SHARP_NtoNE | SHARP_StoSE | HOLE )
|
2009-11-20 14:55:20 +00:00
|
|
|
#define BLOCK_SOUTH ( LINE_VERTICAL | BENT_StoNE | BENT_StoNW \
|
|
|
|
| BENT_EtoSW | BENT_WtoSE \
|
|
|
|
| BENT_NtoSE | BENT_NtoSW \
|
|
|
|
| CORNER_SOUTHEAST | CORNER_SOUTHWEST \
|
2008-04-30 11:52:34 +00:00
|
|
|
| ANGLE_NEtoSE | ANGLE_SWtoNW | ANGLE_SEtoSW \
|
2009-11-20 14:55:20 +00:00
|
|
|
| DIAG_NEtoSW | DIAG_SEtoNW \
|
|
|
|
| SHARP_StoSE | SHARP_StoSW \
|
2008-04-30 11:52:34 +00:00
|
|
|
| SHARP_EtoSE | SHARP_WtoSW | HOLE )
|
2009-11-20 14:55:20 +00:00
|
|
|
#define BLOCK_WEST ( LINE_HORIZONTAL | BENT_WtoNE | BENT_WtoSE \
|
|
|
|
| BENT_NtoSW | BENT_StoNW \
|
|
|
|
| BENT_EtoSW | BENT_EtoNW \
|
|
|
|
| CORNER_SOUTHWEST | CORNER_NORTHWEST \
|
2008-04-30 11:52:34 +00:00
|
|
|
| ANGLE_SWtoNW | ANGLE_SEtoSW | ANGLE_NWtoNE \
|
2009-11-20 14:55:20 +00:00
|
|
|
| DIAG_NEtoSW | DIAG_SEtoNW \
|
|
|
|
| SHARP_WtoSW | SHARP_WtoNW \
|
2008-04-30 11:52:34 +00:00
|
|
|
| SHARP_NtoNW | SHARP_StoSW | HOLE )
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
struct block
|
|
|
|
{
|
|
|
|
int r1, c1;
|
|
|
|
long b1;
|
|
|
|
int r2, c2;
|
|
|
|
long b2;
|
|
|
|
};
|
|
|
|
|
2008-04-30 11:52:34 +00:00
|
|
|
/* blocking masks for diagonal traces */
|
|
|
|
static struct block blocking[8] =
|
|
|
|
{ {
|
|
|
|
0, -1,
|
|
|
|
BLOCK_NORTHEAST,
|
|
|
|
1, 0,
|
|
|
|
BLOCK_SOUTHWEST
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0, 0, 0,
|
|
|
|
0, 0, 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
1, 0,
|
|
|
|
BLOCK_SOUTHEAST,
|
|
|
|
0, 1,
|
|
|
|
BLOCK_NORTHWEST
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0, 0, 0,
|
|
|
|
0, 0, 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0, 0, 0,
|
|
|
|
0, 0, 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0, -1,
|
|
|
|
BLOCK_SOUTHEAST,
|
|
|
|
-1, 0,
|
|
|
|
BLOCK_NORTHWEST
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0, 0, 0,
|
|
|
|
0, 0, 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
-1, 0,
|
|
|
|
BLOCK_NORTHEAST,
|
|
|
|
0, 1,
|
|
|
|
BLOCK_SOUTHWEST
|
|
|
|
} };
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* mask for hole-related blocking effects */
|
2007-08-23 04:28:46 +00:00
|
|
|
static struct
|
|
|
|
{
|
|
|
|
long trace;
|
|
|
|
int present;
|
2009-11-20 14:55:20 +00:00
|
|
|
} selfok2[8] =
|
|
|
|
{
|
|
|
|
{ HOLE_NORTHWEST, 0 },
|
|
|
|
{ HOLE_NORTH, 0 },
|
|
|
|
{ HOLE_NORTHEAST, 0 },
|
|
|
|
{ HOLE_WEST, 0 },
|
|
|
|
{ HOLE_EAST, 0 },
|
|
|
|
{ HOLE_SOUTHWEST, 0 },
|
|
|
|
{ HOLE_SOUTH, 0 },
|
|
|
|
{ HOLE_SOUTHEAST, 0 }
|
2007-08-23 04:28:46 +00:00
|
|
|
};
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
static long newmask[8] =
|
|
|
|
{
|
|
|
|
/* patterns to mask out in neighbor cells */
|
|
|
|
0,
|
|
|
|
CORNER_NORTHWEST | CORNER_NORTHEAST,
|
2009-01-25 17:38:30 +00:00
|
|
|
0,
|
2009-11-20 14:55:20 +00:00
|
|
|
CORNER_NORTHWEST | CORNER_SOUTHWEST,
|
|
|
|
CORNER_NORTHEAST | CORNER_SOUTHEAST,
|
|
|
|
0,
|
|
|
|
CORNER_SOUTHWEST | CORNER_SOUTHEAST,
|
2009-01-25 17:38:30 +00:00
|
|
|
0
|
2007-08-23 04:28:46 +00:00
|
|
|
};
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Route all traces
|
|
|
|
* Return:
|
|
|
|
* 1 if OK
|
|
|
|
* -1 if escape (stop being routed) request
|
|
|
|
* -2 if default memory allocation
|
2007-08-23 04:28:46 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-20 14:55:20 +00:00
|
|
|
int current_net_code;
|
|
|
|
int row_source, col_source, row_target, col_target;
|
|
|
|
int success, nbsucces = 0, nbunsucces = 0;
|
2009-05-24 18:28:36 +00:00
|
|
|
NETINFO_ITEM* net;
|
2011-04-12 14:19:59 +00:00
|
|
|
bool stop = false;
|
2009-11-20 14:55:20 +00:00
|
|
|
wxString msg;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2011-04-12 14:19:59 +00:00
|
|
|
DrawPanel->m_AbortRequest = false;
|
2011-03-09 14:30:39 +00:00
|
|
|
DrawPanel->m_AbortEnable = true;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
s_Clearance = GetBoard()->m_NetClasses.GetDefault()->GetClearance();
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
Ncurrent = 0;
|
|
|
|
/* go until no more work to do */
|
|
|
|
GetWork( &row_source, &col_source, ¤t_net_code,
|
2009-11-20 14:55:20 +00:00
|
|
|
&row_target, &col_target, &pt_cur_ch ); // First net to route.
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
for( ; row_source != ILLEGAL; GetWork( &row_source, &col_source,
|
2009-11-20 14:55:20 +00:00
|
|
|
¤t_net_code, &row_target,
|
|
|
|
&col_target,
|
2009-01-25 17:38:30 +00:00
|
|
|
&pt_cur_ch ) )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Test to stop routing ( escape key pressed ) */
|
2007-08-23 04:28:46 +00:00
|
|
|
wxYield();
|
2011-04-12 14:19:59 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
if( DrawPanel->m_AbortRequest )
|
|
|
|
{
|
|
|
|
if( IsOK( this, _( "Abort routing?" ) ) )
|
|
|
|
{
|
|
|
|
success = STOP_FROM_ESC;
|
2011-03-09 14:30:39 +00:00
|
|
|
stop = true;
|
2007-08-23 04:28:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DrawPanel->m_AbortRequest = 0;
|
|
|
|
}
|
|
|
|
|
2011-04-12 14:19:59 +00:00
|
|
|
EraseMsgBox();
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
Ncurrent++;
|
2009-05-24 18:28:36 +00:00
|
|
|
net = GetBoard()->FindNet( current_net_code );
|
2011-04-12 14:19:59 +00:00
|
|
|
|
2009-05-24 18:28:36 +00:00
|
|
|
if( net )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-10-14 18:14:58 +00:00
|
|
|
msg.Printf( wxT( "[%8.8s]" ), GetChars( net->GetNetname() ) );
|
2011-04-12 14:19:59 +00:00
|
|
|
AppendMsgPanel( wxT( "Net route" ), msg, BROWN );
|
2007-08-23 04:28:46 +00:00
|
|
|
msg.Printf( wxT( "%d / %d" ), Ncurrent, Ntotal );
|
2011-04-12 14:19:59 +00:00
|
|
|
AppendMsgPanel( wxT( "Activity" ), msg, BROWN );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pt_cur_ch = pt_cur_ch;
|
2011-04-12 14:19:59 +00:00
|
|
|
segm_oX = GetBoard()->m_BoundaryBox.m_Pos.x + (Board.m_GridRouting * col_source);
|
|
|
|
segm_oY = GetBoard()->m_BoundaryBox.m_Pos.y + (Board.m_GridRouting * row_source);
|
|
|
|
segm_fX = GetBoard()->m_BoundaryBox.m_Pos.x + (Board.m_GridRouting * col_target);
|
|
|
|
segm_fY = GetBoard()->m_BoundaryBox.m_Pos.y + (Board.m_GridRouting * row_target);
|
2009-11-20 14:55:20 +00:00
|
|
|
|
|
|
|
/* Draw segment. */
|
|
|
|
GRLine( &DrawPanel->m_ClipBox,
|
|
|
|
DC,
|
|
|
|
segm_oX,
|
|
|
|
segm_oY,
|
|
|
|
segm_fX,
|
|
|
|
segm_fY,
|
|
|
|
0,
|
|
|
|
WHITE | GR_XOR );
|
2009-05-24 18:28:36 +00:00
|
|
|
pt_cur_ch->m_PadStart->Draw( DrawPanel, DC, GR_OR | GR_SURBRILL );
|
|
|
|
pt_cur_ch->m_PadEnd->Draw( DrawPanel, DC, GR_OR | GR_SURBRILL );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
success = Autoroute_One_Track( this,
|
|
|
|
DC,
|
|
|
|
two_sides,
|
|
|
|
row_source,
|
|
|
|
col_source,
|
|
|
|
row_target,
|
|
|
|
col_target,
|
|
|
|
pt_cur_ch );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
switch( success )
|
|
|
|
{
|
|
|
|
case NOSUCCESS:
|
2009-05-24 18:28:36 +00:00
|
|
|
pt_cur_ch->m_Status |= CH_UNROUTABLE;
|
2007-08-23 04:28:46 +00:00
|
|
|
nbunsucces++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STOP_FROM_ESC:
|
2011-03-09 14:30:39 +00:00
|
|
|
stop = true;
|
2007-08-23 04:28:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ERR_MEMORY:
|
2011-03-09 14:30:39 +00:00
|
|
|
stop = true;
|
2007-08-23 04:28:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
nbsucces++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-04-12 14:19:59 +00:00
|
|
|
msg.Printf( wxT( "%d" ), nbsucces );
|
|
|
|
AppendMsgPanel( wxT( "Ok" ), msg, GREEN );
|
|
|
|
msg.Printf( wxT( "%d" ), nbunsucces );
|
|
|
|
AppendMsgPanel( wxT( "Fail" ), msg, RED );
|
|
|
|
msg.Printf( wxT( " %d" ), GetBoard()->m_NbNoconnect );
|
|
|
|
AppendMsgPanel( wxT( "Not Connectd" ), msg, CYAN );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Delete routing from display. */
|
2009-05-24 18:28:36 +00:00
|
|
|
pt_cur_ch->m_PadStart->Draw( DrawPanel, DC, GR_AND );
|
|
|
|
pt_cur_ch->m_PadEnd->Draw( DrawPanel, DC, GR_AND );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
if( stop )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-04-12 14:19:59 +00:00
|
|
|
DrawPanel->m_AbortEnable = false;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
return SUCCESS;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Route a trace on the BOARD.
|
|
|
|
* Parameters:
|
|
|
|
* 1 side / 2 sides (0 / 1)
|
|
|
|
* Coord source (row, col)
|
|
|
|
* Coord destination (row, col)
|
|
|
|
* Net_code
|
|
|
|
* Pointer to the ratsnest reference
|
2008-02-12 01:02:53 +00:00
|
|
|
*
|
2009-11-20 14:55:20 +00:00
|
|
|
* Returns:
|
|
|
|
* SUCCESS if routed
|
2011-03-09 14:30:39 +00:00
|
|
|
* TRIVIAL_SUCCESS if pads are connected by overlay (no track needed)
|
2009-11-20 14:55:20 +00:00
|
|
|
* If failure NOSUCCESS
|
|
|
|
* Escape STOP_FROM_ESC if demand
|
|
|
|
* ERR_MEMORY if memory allocation failed.
|
2007-08-23 04:28:46 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
|
|
|
|
wxDC* DC,
|
|
|
|
int two_sides,
|
|
|
|
int row_source,
|
|
|
|
int col_source,
|
|
|
|
int row_target,
|
|
|
|
int col_target,
|
|
|
|
RATSNEST_ITEM* pt_chevelu )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-20 14:55:20 +00:00
|
|
|
int r, c, side, d, apx_dist, nr, nc;
|
|
|
|
int result, skip;
|
|
|
|
int i;
|
|
|
|
long curcell, newcell, buddy, lastopen, lastclos, lastmove;
|
|
|
|
int newdist, olddir, _self;
|
|
|
|
int current_net_code;
|
2011-05-13 13:15:28 +00:00
|
|
|
int marge;
|
2009-11-20 14:55:20 +00:00
|
|
|
int pad_masque_layer_s; /* Mask layers belonging to the
|
|
|
|
*starting pad. */
|
|
|
|
int pad_masque_layer_e; /* Mask layers belonging to the ending
|
|
|
|
*pad. */
|
|
|
|
int masque_layer_TOP = g_TabOneLayerMask[Route_Layer_TOP];
|
|
|
|
int masque_layer_BOTTOM = g_TabOneLayerMask[Route_Layer_BOTTOM];
|
|
|
|
int masque_layers; /* Mask two layers for routing. */
|
|
|
|
int tab_mask[2]; /* Enables the calculation of the mask
|
|
|
|
* layer being
|
|
|
|
* tested. (side = TOP or BOTTOM) */
|
|
|
|
int start_mask_layer = 0;
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
wxBusyCursor dummy_cursor; // Set an hourglass cursor while routing a
|
|
|
|
// track
|
2009-01-25 17:48:59 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
result = NOSUCCESS;
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
marge = s_Clearance +
|
|
|
|
( pcbframe->GetBoard()->GetCurrentTrackWidth() / 2 );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
/* clear direction flags */
|
2011-03-09 14:30:39 +00:00
|
|
|
i = Nrows * Ncols * sizeof(DIR_CELL);
|
2007-08-23 04:28:46 +00:00
|
|
|
memset( Board.m_DirSide[TOP], FROM_NOWHERE, i );
|
|
|
|
memset( Board.m_DirSide[BOTTOM], FROM_NOWHERE, i );
|
|
|
|
|
|
|
|
lastopen = lastclos = lastmove = 0;
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Set tab_masque[side] for final test of routing. */
|
2007-08-23 04:28:46 +00:00
|
|
|
tab_mask[TOP] = masque_layer_TOP;
|
|
|
|
tab_mask[BOTTOM] = masque_layer_BOTTOM;
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Set active layers mask. */
|
2007-08-23 04:28:46 +00:00
|
|
|
masque_layers = masque_layer_TOP | masque_layer_BOTTOM;
|
|
|
|
|
|
|
|
pt_cur_ch = pt_chevelu;
|
2007-10-13 06:18:44 +00:00
|
|
|
current_net_code = pt_chevelu->GetNet();
|
2009-05-24 18:28:36 +00:00
|
|
|
pad_masque_layer_s = pt_cur_ch->m_PadStart->m_Masque_Layer;
|
|
|
|
pad_masque_layer_e = pt_cur_ch->m_PadEnd->m_Masque_Layer;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* First Test if routing possible ie if the pads are accessible
|
|
|
|
* on the routing layers.
|
|
|
|
*/
|
|
|
|
if( ( masque_layers & pad_masque_layer_s ) == 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
goto end_of_route;
|
2009-11-20 14:55:20 +00:00
|
|
|
if( ( masque_layers & pad_masque_layer_e ) == 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
goto end_of_route;
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Then test if routing possible ie if the pads are accessible
|
|
|
|
* On the routing grid (1 grid point must be in the pad)
|
|
|
|
*/
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2011-03-09 20:09:11 +00:00
|
|
|
int cX = ( Board.m_GridRouting * col_source )
|
2009-11-20 14:55:20 +00:00
|
|
|
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x;
|
2011-03-09 20:09:11 +00:00
|
|
|
int cY = ( Board.m_GridRouting * row_source )
|
2009-11-20 14:55:20 +00:00
|
|
|
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y;
|
2009-05-24 18:28:36 +00:00
|
|
|
int dx = pt_cur_ch->m_PadStart->m_Size.x / 2;
|
|
|
|
int dy = pt_cur_ch->m_PadStart->m_Size.y / 2;
|
|
|
|
int px = pt_cur_ch->m_PadStart->GetPosition().x;
|
|
|
|
int py = pt_cur_ch->m_PadStart->GetPosition().y;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
if( ( ( pt_cur_ch->m_PadStart->m_Orient / 900 ) & 1 ) != 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
EXCHG( dx, dy );
|
2009-11-20 14:55:20 +00:00
|
|
|
if( ( abs( cX - px ) > dx ) || ( abs( cY - py ) > dy ) )
|
2007-08-23 04:28:46 +00:00
|
|
|
goto end_of_route;
|
|
|
|
|
2011-03-09 20:09:11 +00:00
|
|
|
cX = ( Board.m_GridRouting * col_target )
|
2009-11-20 14:55:20 +00:00
|
|
|
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x;
|
2011-03-09 20:09:11 +00:00
|
|
|
cY = ( Board.m_GridRouting * row_target )
|
2009-11-20 14:55:20 +00:00
|
|
|
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y;
|
2009-05-24 18:28:36 +00:00
|
|
|
dx = pt_cur_ch->m_PadEnd->m_Size.x / 2;
|
|
|
|
dy = pt_cur_ch->m_PadEnd->m_Size.y / 2;
|
|
|
|
px = pt_cur_ch->m_PadEnd->GetPosition().x;
|
|
|
|
py = pt_cur_ch->m_PadEnd->GetPosition().y;
|
|
|
|
if( ( (pt_cur_ch->m_PadEnd->m_Orient / 900) & 1 ) != 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
EXCHG( dx, dy );
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
if( ( abs( cX - px ) > dx ) || ( abs( cY - py ) > dy ) )
|
2007-08-23 04:28:46 +00:00
|
|
|
goto end_of_route;
|
|
|
|
}
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Test the trivial case: direct connection overlay pads. */
|
|
|
|
if( ( row_source == row_target ) && ( col_source == col_target )
|
2007-08-23 04:28:46 +00:00
|
|
|
&& ( pad_masque_layer_e & pad_masque_layer_s &
|
2010-01-31 20:01:46 +00:00
|
|
|
g_TabAllCopperLayerMask[pcbframe->GetBoard()->GetCopperLayerCount() - 1] ) )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
result = TRIVIAL_SUCCESS;
|
|
|
|
goto end_of_route;
|
|
|
|
}
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Placing the bit to remove obstacles on 2 pads to a link. */
|
2011-02-11 20:48:13 +00:00
|
|
|
pcbframe->SetStatusText( wxT( "Gen Cells" ) );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadStart,
|
|
|
|
CURRENT_PAD, marge, WRITE_OR_CELL );
|
|
|
|
Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadEnd,
|
|
|
|
CURRENT_PAD, marge, WRITE_OR_CELL );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Regenerates the remaining barriers (which may encroach on the placement
|
|
|
|
* bits precedent)
|
|
|
|
*/
|
|
|
|
i = pcbframe->GetBoard()->GetPadsCount();
|
2009-06-11 14:26:17 +00:00
|
|
|
for( unsigned ii = 0; ii < pcbframe->GetBoard()->GetPadsCount(); ii++ )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-11-20 14:55:20 +00:00
|
|
|
D_PAD* ptr = pcbframe->GetBoard()->m_NetInfo->GetPad( ii );
|
|
|
|
if( ( pt_cur_ch->m_PadStart != ptr ) && ( pt_cur_ch->m_PadEnd != ptr ) )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-11-20 14:55:20 +00:00
|
|
|
Place_1_Pad_Board( pcbframe->GetBoard(), ptr, ~CURRENT_PAD,
|
|
|
|
marge, WRITE_AND_CELL );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
InitQueue(); /* initialize the search queue */
|
|
|
|
apx_dist = GetApxDist( row_source, col_source, row_target, col_target );
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Initialize first search. */
|
|
|
|
if( two_sides ) /* Preferred orientation. */
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
if( abs( row_target - row_source ) > abs( col_target - col_source ) )
|
|
|
|
{
|
|
|
|
if( pad_masque_layer_s & masque_layer_TOP )
|
|
|
|
{
|
|
|
|
start_mask_layer = 2;
|
|
|
|
if( SetQueue( row_source, col_source, TOP, 0, apx_dist,
|
2009-01-25 17:38:30 +00:00
|
|
|
row_target, col_target ) == 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
return ERR_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( pad_masque_layer_s & masque_layer_BOTTOM )
|
|
|
|
{
|
|
|
|
start_mask_layer |= 1;
|
|
|
|
|
|
|
|
if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist,
|
2009-01-25 17:38:30 +00:00
|
|
|
row_target, col_target ) == 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
return ERR_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( pad_masque_layer_s & masque_layer_BOTTOM )
|
|
|
|
{
|
|
|
|
start_mask_layer = 1;
|
|
|
|
if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist,
|
2009-01-25 17:38:30 +00:00
|
|
|
row_target, col_target ) == 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
return ERR_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( pad_masque_layer_s & masque_layer_TOP )
|
|
|
|
{
|
|
|
|
start_mask_layer |= 2;
|
|
|
|
|
|
|
|
if( SetQueue( row_source, col_source, TOP, 0, apx_dist,
|
2009-01-25 17:38:30 +00:00
|
|
|
row_target, col_target ) == 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
return ERR_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( pad_masque_layer_s & masque_layer_BOTTOM )
|
|
|
|
{
|
|
|
|
start_mask_layer = 1;
|
|
|
|
|
|
|
|
if( SetQueue( row_source, col_source, BOTTOM, 0, apx_dist,
|
2009-01-25 17:38:30 +00:00
|
|
|
row_target, col_target ) == 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
return ERR_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* search until success or we exhaust all possibilities */
|
|
|
|
GetQueue( &r, &c, &side, &d, &apx_dist );
|
|
|
|
for( ; r != ILLEGAL; GetQueue( &r, &c, &side, &d, &apx_dist ) )
|
|
|
|
{
|
|
|
|
curcell = GetCell( r, c, side );
|
|
|
|
if( curcell & CURRENT_PAD )
|
|
|
|
curcell &= ~HOLE;
|
2009-11-20 14:55:20 +00:00
|
|
|
if( (r == row_target) && (c == col_target) /* success if layer OK */
|
2007-08-23 04:28:46 +00:00
|
|
|
&& ( tab_mask[side] & pad_masque_layer_e) )
|
|
|
|
{
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Remove link. */
|
2007-08-23 04:28:46 +00:00
|
|
|
GRSetDrawMode( DC, GR_XOR );
|
|
|
|
GRLine( &pcbframe->DrawPanel->m_ClipBox,
|
2009-01-25 17:38:30 +00:00
|
|
|
DC,
|
|
|
|
segm_oX,
|
|
|
|
segm_oY,
|
|
|
|
segm_fX,
|
|
|
|
segm_fY,
|
|
|
|
0,
|
|
|
|
WHITE );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Generate trace. */
|
2007-08-23 04:28:46 +00:00
|
|
|
if( Retrace( pcbframe, DC, row_source, col_source,
|
2009-01-25 17:38:30 +00:00
|
|
|
row_target, col_target, side, current_net_code ) )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
result = SUCCESS; /* Success : Route OK */
|
|
|
|
}
|
2009-11-20 14:55:20 +00:00
|
|
|
break; /* Routing complete. */
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:52:34 +00:00
|
|
|
if( pcbframe->DrawPanel->m_AbortRequest )
|
|
|
|
{
|
2009-11-20 14:55:20 +00:00
|
|
|
result = STOP_FROM_ESC;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
/* report every COUNT new nodes or so */
|
2009-01-28 17:08:35 +00:00
|
|
|
#define COUNT 20000
|
2009-11-20 14:55:20 +00:00
|
|
|
if( ( OpenNodes - lastopen > COUNT )
|
|
|
|
|| ( ClosNodes - lastclos > COUNT )
|
|
|
|
|| ( MoveNodes - lastmove > COUNT ) )
|
2009-09-10 15:22:26 +00:00
|
|
|
{
|
|
|
|
lastopen = OpenNodes;
|
2009-01-28 17:08:35 +00:00
|
|
|
lastclos = ClosNodes;
|
2009-09-10 15:22:26 +00:00
|
|
|
lastmove = MoveNodes;
|
2009-11-20 14:55:20 +00:00
|
|
|
msg.Printf( wxT( "Activity: Open %d Closed %d Moved %d" ),
|
|
|
|
OpenNodes, ClosNodes, MoveNodes );
|
2011-02-11 20:48:13 +00:00
|
|
|
pcbframe->SetStatusText( msg );
|
2009-09-10 15:22:26 +00:00
|
|
|
}
|
2009-01-28 17:08:35 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
_self = 0;
|
|
|
|
if( curcell & HOLE )
|
|
|
|
{
|
|
|
|
_self = 5;
|
|
|
|
/* set 'present' bits */
|
|
|
|
for( i = 0; i < 8; i++ )
|
|
|
|
{
|
|
|
|
selfok2[i].present = 0;
|
2009-11-20 14:55:20 +00:00
|
|
|
if( curcell & selfok2[i].trace )
|
2007-08-23 04:28:46 +00:00
|
|
|
selfok2[i].present = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( i = 0; i < 8; i++ ) /* consider neighbors */
|
|
|
|
{
|
|
|
|
nr = r + delta[i][0]; nc = c + delta[i][1];
|
|
|
|
|
|
|
|
/* off the edge? */
|
|
|
|
if( nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols )
|
2009-11-20 14:55:20 +00:00
|
|
|
continue; /* off the edge */
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
if( _self == 5 && selfok2[i].present )
|
|
|
|
continue;
|
|
|
|
newcell = GetCell( nr, nc, side );
|
|
|
|
if( newcell & CURRENT_PAD )
|
|
|
|
newcell &= ~HOLE;
|
|
|
|
|
|
|
|
/* check for non-target hole */
|
|
|
|
if( newcell & HOLE )
|
|
|
|
{
|
|
|
|
if( nr != row_target || nc != col_target )
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* check for traces */
|
|
|
|
else if( newcell & HOLE & ~(newmask[i]) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* check blocking on corner neighbors */
|
|
|
|
if( delta[i][0] && delta[i][1] )
|
|
|
|
{
|
|
|
|
/* check first buddy */
|
|
|
|
buddy = GetCell( r + blocking[i].r1, c + blocking[i].c1, side );
|
|
|
|
if( buddy & CURRENT_PAD )
|
|
|
|
buddy &= ~HOLE;
|
|
|
|
if( buddy & HOLE )
|
|
|
|
continue;
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// if (buddy & (blocking[i].b1)) continue;
|
2007-08-23 04:28:46 +00:00
|
|
|
/* check second buddy */
|
|
|
|
buddy = GetCell( r + blocking[i].r2, c + blocking[i].c2, side );
|
|
|
|
if( buddy & CURRENT_PAD )
|
|
|
|
buddy &= ~HOLE;
|
|
|
|
if( buddy & HOLE )
|
|
|
|
continue;
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// if (buddy & (blocking[i].b2)) continue;
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
olddir = GetDir( r, c, side );
|
|
|
|
newdist = d + CalcDist( ndir[i], olddir,
|
2009-11-20 14:55:20 +00:00
|
|
|
( olddir == FROM_OTHERSIDE ) ?
|
|
|
|
GetDir( r, c, 1 - side ) : 0, side );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
/* if (a) not visited yet, or (b) we have */
|
|
|
|
/* found a better path, add it to queue */
|
|
|
|
if( !GetDir( nr, nc, side ) )
|
|
|
|
{
|
|
|
|
SetDir( nr, nc, side, ndir[i] );
|
|
|
|
SetDist( nr, nc, side, newdist );
|
|
|
|
if( SetQueue( nr, nc, side, newdist,
|
2009-01-25 17:38:30 +00:00
|
|
|
GetApxDist( nr, nc, row_target, col_target ),
|
|
|
|
row_target, col_target ) == 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
return ERR_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( newdist < GetDist( nr, nc, side ) )
|
|
|
|
{
|
|
|
|
SetDir( nr, nc, side, ndir[i] );
|
|
|
|
SetDist( nr, nc, side, newdist );
|
|
|
|
ReSetQueue( nr, nc, side, newdist,
|
2009-01-25 17:38:30 +00:00
|
|
|
GetApxDist( nr, nc, row_target, col_target ),
|
|
|
|
row_target, col_target );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/** Test the other layer. **/
|
2010-02-24 15:33:03 +00:00
|
|
|
if( two_sides )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
olddir = GetDir( r, c, side );
|
|
|
|
if( olddir == FROM_OTHERSIDE )
|
|
|
|
continue; /* useless move, so don't bother */
|
|
|
|
if( curcell ) /* can't drill via if anything here */
|
|
|
|
continue;
|
|
|
|
/* check for holes or traces on other side */
|
|
|
|
if( ( newcell = GetCell( r, c, 1 - side ) ) != 0 )
|
|
|
|
continue;
|
|
|
|
/* check for nearby holes or traces on both sides */
|
|
|
|
for( skip = 0, i = 0; i < 8; i++ )
|
|
|
|
{
|
|
|
|
nr = r + delta[i][0]; nc = c + delta[i][1];
|
|
|
|
|
|
|
|
if( nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols )
|
2009-11-20 14:55:20 +00:00
|
|
|
continue; /* off the edge !! */
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
if( GetCell( nr, nc, side ) /* & blocking2[i]*/ )
|
|
|
|
{
|
|
|
|
skip = 1; /* can't drill via here */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( GetCell( nr, nc, 1 - side ) /* & blocking2[i]*/ )
|
|
|
|
{
|
|
|
|
skip = 1; /* can't drill via here */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( skip ) /* neighboring hole or trace? */
|
|
|
|
continue; /* yes, can't drill via here */
|
|
|
|
|
|
|
|
newdist = d + CalcDist( FROM_OTHERSIDE, olddir, 0, side );
|
|
|
|
|
|
|
|
/* if (a) not visited yet,
|
|
|
|
* or (b) we have found a better path,
|
|
|
|
* add it to queue */
|
|
|
|
if( !GetDir( r, c, 1 - side ) )
|
|
|
|
{
|
|
|
|
SetDir( r, c, 1 - side, FROM_OTHERSIDE );
|
|
|
|
SetDist( r, c, 1 - side, newdist );
|
|
|
|
if( SetQueue( r, c, 1 - side, newdist, apx_dist, row_target,
|
2009-01-25 17:38:30 +00:00
|
|
|
col_target ) == 0 )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
return ERR_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( newdist < GetDist( r, c, 1 - side ) )
|
|
|
|
{
|
|
|
|
SetDir( r, c, 1 - side, FROM_OTHERSIDE );
|
|
|
|
SetDist( r, c, 1 - side, newdist );
|
2009-11-20 14:55:20 +00:00
|
|
|
ReSetQueue( r,
|
|
|
|
c,
|
|
|
|
1 - side,
|
|
|
|
newdist,
|
|
|
|
apx_dist,
|
|
|
|
row_target,
|
|
|
|
col_target );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2009-11-20 14:55:20 +00:00
|
|
|
} /* Finished attempt to route on other layer. */
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
end_of_route:
|
2009-11-20 14:55:20 +00:00
|
|
|
Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadStart,
|
|
|
|
~CURRENT_PAD, marge, WRITE_AND_CELL );
|
|
|
|
Place_1_Pad_Board( pcbframe->GetBoard(), pt_cur_ch->m_PadEnd,
|
|
|
|
~CURRENT_PAD, marge, WRITE_AND_CELL );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
msg.Printf( wxT( "Activity: Open %d Closed %d Moved %d"),
|
|
|
|
OpenNodes, ClosNodes, MoveNodes );
|
2011-02-11 20:48:13 +00:00
|
|
|
pcbframe->SetStatusText( msg );
|
2009-01-28 17:08:35 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
return result;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
static long bit[8][9] =
|
|
|
|
{
|
|
|
|
/* OT=Otherside */
|
2007-08-23 04:28:46 +00:00
|
|
|
/* N, NE, E, SE, S, SW, W, NW, OT */
|
2008-04-30 11:52:34 +00:00
|
|
|
/* N */
|
2009-11-20 14:55:20 +00:00
|
|
|
{ LINE_VERTICAL,
|
|
|
|
BENT_StoNE,
|
|
|
|
CORNER_SOUTHEAST,
|
|
|
|
SHARP_StoSE,
|
|
|
|
0,
|
|
|
|
SHARP_StoSW,
|
|
|
|
CORNER_SOUTHWEST,
|
|
|
|
BENT_StoNW,
|
|
|
|
( HOLE | HOLE_SOUTH )
|
|
|
|
},
|
|
|
|
/* NE */
|
|
|
|
{
|
|
|
|
BENT_NtoSW,
|
|
|
|
DIAG_NEtoSW,
|
|
|
|
BENT_EtoSW,
|
|
|
|
ANGLE_SEtoSW,
|
|
|
|
SHARP_StoSW,
|
|
|
|
0,
|
|
|
|
SHARP_WtoSW,
|
|
|
|
ANGLE_SWtoNW,
|
|
|
|
( HOLE | HOLE_SOUTHWEST )
|
|
|
|
},
|
|
|
|
/* E */
|
|
|
|
{
|
|
|
|
CORNER_NORTHWEST,
|
|
|
|
BENT_WtoNE,
|
|
|
|
LINE_HORIZONTAL,
|
|
|
|
BENT_WtoSE,
|
|
|
|
CORNER_SOUTHWEST,
|
|
|
|
SHARP_WtoSW,
|
|
|
|
0,
|
|
|
|
SHARP_WtoNW,
|
|
|
|
( HOLE | HOLE_WEST )
|
|
|
|
},
|
|
|
|
/* SE */
|
|
|
|
{
|
|
|
|
SHARP_NtoNW,
|
|
|
|
ANGLE_NWtoNE,
|
|
|
|
BENT_EtoNW,
|
|
|
|
DIAG_SEtoNW,
|
|
|
|
BENT_StoNW,
|
|
|
|
ANGLE_SWtoNW,
|
|
|
|
SHARP_WtoNW,
|
|
|
|
0,
|
|
|
|
( HOLE | HOLE_NORTHWEST )
|
|
|
|
},
|
|
|
|
/* S */
|
|
|
|
{
|
|
|
|
0,
|
|
|
|
SHARP_NtoNE,
|
|
|
|
CORNER_NORTHEAST,
|
|
|
|
BENT_NtoSE,
|
|
|
|
LINE_VERTICAL,
|
|
|
|
BENT_NtoSW,
|
|
|
|
CORNER_NORTHWEST,
|
|
|
|
SHARP_NtoNW,
|
|
|
|
( HOLE | HOLE_NORTH )
|
|
|
|
},
|
|
|
|
/* SW */
|
|
|
|
{
|
|
|
|
SHARP_NtoNE,
|
|
|
|
0,
|
|
|
|
SHARP_EtoNE,
|
|
|
|
ANGLE_NEtoSE,
|
|
|
|
BENT_StoNE,
|
|
|
|
DIAG_NEtoSW,
|
|
|
|
BENT_WtoNE,
|
|
|
|
ANGLE_NWtoNE,
|
|
|
|
( HOLE | HOLE_NORTHEAST )
|
|
|
|
},
|
|
|
|
/* W */
|
|
|
|
{
|
|
|
|
CORNER_NORTHEAST,
|
|
|
|
SHARP_EtoNE,
|
|
|
|
0,
|
|
|
|
SHARP_EtoSE,
|
|
|
|
CORNER_SOUTHEAST,
|
|
|
|
BENT_EtoSW,
|
|
|
|
LINE_HORIZONTAL,
|
|
|
|
BENT_EtoNW,
|
|
|
|
( HOLE | HOLE_EAST )
|
|
|
|
},
|
|
|
|
/* NW */
|
|
|
|
{
|
|
|
|
BENT_NtoSE,
|
|
|
|
ANGLE_NEtoSE,
|
|
|
|
SHARP_EtoSE,
|
|
|
|
0,
|
|
|
|
SHARP_StoSE,
|
|
|
|
ANGLE_SEtoSW,
|
|
|
|
BENT_WtoSE,
|
|
|
|
DIAG_SEtoNW,
|
|
|
|
( HOLE | HOLE_SOUTHEAST )
|
|
|
|
}
|
2007-08-23 04:28:46 +00:00
|
|
|
};
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-01-25 17:38:30 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* work from target back to source, actually laying the traces
|
2009-11-20 14:55:20 +00:00
|
|
|
* Parameters:
|
|
|
|
* start on side target_side, of coordinates row_target, col_target.
|
|
|
|
* arrive on side masque_layer_start, coordinate row_source, col_source
|
|
|
|
* The search is done in reverse routing, the point of arrival (target) to
|
|
|
|
* the starting point (source)
|
|
|
|
* The router.
|
2008-02-12 01:02:53 +00:00
|
|
|
*
|
2009-11-20 14:55:20 +00:00
|
|
|
* Target_side = symbol (TOP / BOTTOM) of departure
|
|
|
|
* = Mask_layer_source mask layers Arrival
|
2008-02-12 01:02:53 +00:00
|
|
|
*
|
2009-11-20 14:55:20 +00:00
|
|
|
* Returns:
|
|
|
|
* 0 if error
|
|
|
|
* > 0 if Ok
|
2007-08-23 04:28:46 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC,
|
2009-11-20 14:55:20 +00:00
|
|
|
int row_source, int col_source,
|
|
|
|
int row_target, int col_target, int target_side,
|
|
|
|
int current_net_code )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
int r0, c0, s0;
|
2009-11-20 14:55:20 +00:00
|
|
|
int r1, c1, s1; /* row, col, starting side. */
|
|
|
|
int r2, c2, s2; /* row, col, ending side. */
|
2007-08-23 04:28:46 +00:00
|
|
|
int x, y = -1;
|
|
|
|
long b;
|
|
|
|
|
|
|
|
r1 = row_target;
|
|
|
|
c1 = col_target; /* start point is target ( end point is source )*/
|
|
|
|
s1 = target_side;
|
|
|
|
r0 = c0 = s0 = ILLEGAL;
|
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
wxASSERT( g_CurrentTrackList.GetCount() == 0 );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
/* find where we came from to get here */
|
|
|
|
r2 = r1; c2 = c1; s2 = s1;
|
|
|
|
x = GetDir( r1, c1, s1 );
|
|
|
|
|
|
|
|
switch( x )
|
|
|
|
{
|
|
|
|
case FROM_NORTH:
|
2009-11-20 14:55:20 +00:00
|
|
|
r2++;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_EAST:
|
2009-11-20 14:55:20 +00:00
|
|
|
c2++;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_SOUTH:
|
2009-11-20 14:55:20 +00:00
|
|
|
r2--;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_WEST:
|
2009-11-20 14:55:20 +00:00
|
|
|
c2--;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_NORTHEAST:
|
2009-11-20 14:55:20 +00:00
|
|
|
r2++;
|
|
|
|
c2++;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_SOUTHEAST:
|
2009-11-20 14:55:20 +00:00
|
|
|
r2--;
|
|
|
|
c2++;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_SOUTHWEST:
|
2009-11-20 14:55:20 +00:00
|
|
|
r2--;
|
|
|
|
c2--;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_NORTHWEST:
|
2009-11-20 14:55:20 +00:00
|
|
|
r2++;
|
|
|
|
c2--;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_OTHERSIDE:
|
2009-11-20 14:55:20 +00:00
|
|
|
s2 = 1 - s2;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
default:
|
2009-11-20 14:55:20 +00:00
|
|
|
DisplayError( pcbframe,
|
|
|
|
wxT( "Retrace: internal error: no way back" ) );
|
2007-08-23 04:28:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( r0 != ILLEGAL )
|
|
|
|
y = GetDir( r0, c0, s0 );
|
|
|
|
|
|
|
|
/* see if target or hole */
|
2009-11-20 14:55:20 +00:00
|
|
|
if( ( ( r1 == row_target ) && ( c1 == col_target ) )
|
|
|
|
|| ( s1 != s0 ) )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
int p_dir;
|
|
|
|
|
|
|
|
switch( x )
|
|
|
|
{
|
|
|
|
case FROM_NORTH:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_NORTH;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_EAST:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_EAST;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_SOUTH:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_SOUTH;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_WEST:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_WEST;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_NORTHEAST:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_NORTHEAST;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_SOUTHEAST:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_SOUTHEAST;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_SOUTHWEST:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_SOUTHWEST;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_NORTHWEST:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_NORTHWEST;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_OTHERSIDE:
|
|
|
|
default:
|
|
|
|
DisplayError( pcbframe, wxT( "Retrace: error 1" ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
OrCell_Trace(
|
|
|
|
pcbframe->GetBoard(), r1, c1, s1, p_dir, current_net_code );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-20 14:55:20 +00:00
|
|
|
if( ( y == FROM_NORTH || y == FROM_NORTHEAST
|
|
|
|
|| y == FROM_EAST || y == FROM_SOUTHEAST
|
|
|
|
|| y == FROM_SOUTH || y == FROM_SOUTHWEST
|
|
|
|
|| y == FROM_WEST || y == FROM_NORTHWEST )
|
|
|
|
&& ( x == FROM_NORTH || x == FROM_NORTHEAST
|
|
|
|
|| x == FROM_EAST || x == FROM_SOUTHEAST
|
|
|
|
|| x == FROM_SOUTH || x == FROM_SOUTHWEST
|
|
|
|
|| x == FROM_WEST || x == FROM_NORTHWEST
|
|
|
|
|| x == FROM_OTHERSIDE )
|
|
|
|
&& ( ( b = bit[y - 1][x - 1] ) != 0 ) )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-11-20 14:55:20 +00:00
|
|
|
OrCell_Trace( pcbframe->GetBoard(), r1, c1, s1, b,
|
|
|
|
current_net_code );
|
2007-08-23 04:28:46 +00:00
|
|
|
if( b & HOLE )
|
2009-11-20 14:55:20 +00:00
|
|
|
OrCell_Trace( pcbframe->GetBoard(), r2, c2, s2, HOLE,
|
|
|
|
current_net_code );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DisplayError( pcbframe, wxT( "Retrace: error 2" ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
if( ( r2 == row_source ) && ( c2 == col_source ) ) /* see if source */
|
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
int p_dir;
|
|
|
|
|
|
|
|
switch( x )
|
|
|
|
{
|
|
|
|
case FROM_NORTH:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_SOUTH;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_EAST:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_WEST;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_SOUTH:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_NORTH;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_WEST:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_EAST;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_NORTHEAST:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_SOUTHWEST;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_SOUTHEAST:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_NORTHWEST;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_SOUTHWEST:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_NORTHEAST;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_NORTHWEST:
|
2009-11-20 14:55:20 +00:00
|
|
|
p_dir = HOLE_SOUTHEAST;
|
|
|
|
break;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
case FROM_OTHERSIDE:
|
|
|
|
default:
|
|
|
|
DisplayError( pcbframe, wxT( "Retrace: error 3" ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
OrCell_Trace( pcbframe->GetBoard(), r2, c2, s2, p_dir,
|
|
|
|
current_net_code );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
/* move to next cell */
|
2009-11-20 14:55:20 +00:00
|
|
|
r0 = r1;
|
|
|
|
c0 = c1;
|
|
|
|
s0 = s1;
|
|
|
|
r1 = r2;
|
|
|
|
c1 = c2;
|
|
|
|
s1 = s2;
|
|
|
|
} while( !( ( r2 == row_source ) && ( c2 == col_source ) ) );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
Place_Piste_en_Buffer( pcbframe, DC );
|
|
|
|
return 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-23 21:03:26 +00:00
|
|
|
/* This function is used by Retrace and read the autorouting matrix data cells to create
|
|
|
|
* the real track on the physical board
|
|
|
|
*/
|
2007-08-23 04:28:46 +00:00
|
|
|
static void OrCell_Trace( BOARD* pcb, int col, int row,
|
|
|
|
int side, int orient, int current_net_code )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-23 04:28:46 +00:00
|
|
|
int dx0, dy0, dx1, dy1;
|
2008-12-04 04:28:11 +00:00
|
|
|
TRACK* newTrack;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( orient == HOLE ) // placement of a via
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack = new SEGVIA( pcb );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
g_CurrentTrackList.PushBack( newTrack );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
g_CurrentTrackSegment->SetState( TRACK_AR, ON );
|
2007-08-23 04:28:46 +00:00
|
|
|
g_CurrentTrackSegment->SetLayer( 0x0F );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-01-25 17:38:30 +00:00
|
|
|
g_CurrentTrackSegment->m_Start.x =
|
2009-11-20 14:55:20 +00:00
|
|
|
g_CurrentTrackSegment->m_End.x = pcb->m_BoundaryBox.m_Pos.x +
|
2011-03-09 20:09:11 +00:00
|
|
|
( Board.m_GridRouting * row );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-01-25 17:38:30 +00:00
|
|
|
g_CurrentTrackSegment->m_Start.y =
|
2009-11-20 14:55:20 +00:00
|
|
|
g_CurrentTrackSegment->m_End.y = pcb->m_BoundaryBox.m_Pos.y +
|
2011-03-09 20:09:11 +00:00
|
|
|
( Board.m_GridRouting * col );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
g_CurrentTrackSegment->m_Width = pcb->GetCurrentViaSize();
|
2010-01-31 20:01:46 +00:00
|
|
|
g_CurrentTrackSegment->m_Shape = pcb->GetBoardDesignSettings()->m_CurrentViaType;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2007-10-13 06:18:44 +00:00
|
|
|
g_CurrentTrackSegment->SetNet( current_net_code );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2008-12-04 04:28:11 +00:00
|
|
|
else // placement of a standard segment
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack = new TRACK( pcb );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
g_CurrentTrackList.PushBack( newTrack );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
|
|
|
g_CurrentTrackSegment->SetLayer( Route_Layer_BOTTOM );
|
|
|
|
if( side == TOP )
|
|
|
|
g_CurrentTrackSegment->SetLayer( Route_Layer_TOP );
|
|
|
|
|
2011-02-13 17:53:48 +00:00
|
|
|
g_CurrentTrackSegment->SetState( TRACK_AR, ON );
|
2009-11-20 14:55:20 +00:00
|
|
|
g_CurrentTrackSegment->m_End.x = pcb->m_BoundaryBox.m_Pos.x +
|
2011-03-09 20:09:11 +00:00
|
|
|
( Board.m_GridRouting * row );
|
2009-11-20 14:55:20 +00:00
|
|
|
g_CurrentTrackSegment->m_End.y = pcb->m_BoundaryBox.m_Pos.y +
|
2011-03-09 20:09:11 +00:00
|
|
|
( Board.m_GridRouting * col );
|
2007-10-13 06:18:44 +00:00
|
|
|
g_CurrentTrackSegment->SetNet( current_net_code );
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
if( g_CurrentTrackSegment->Back() == NULL ) /* Start trace. */
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
|
|
|
g_CurrentTrackSegment->m_Start.x = segm_fX;
|
|
|
|
g_CurrentTrackSegment->m_Start.y = segm_fY;
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Placement on the center of the pad if outside grid. */
|
|
|
|
dx1 = g_CurrentTrackSegment->m_End.x -
|
|
|
|
g_CurrentTrackSegment->m_Start.x;
|
|
|
|
dy1 = g_CurrentTrackSegment->m_End.y -
|
|
|
|
g_CurrentTrackSegment->m_Start.y;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
dx0 = pt_cur_ch->m_PadEnd->GetPosition().x -
|
|
|
|
g_CurrentTrackSegment->m_Start.x;
|
|
|
|
dy0 = pt_cur_ch->m_PadEnd->GetPosition().y -
|
|
|
|
g_CurrentTrackSegment->m_Start.y;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* If aligned, change the origin point. */
|
|
|
|
if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-11-20 14:55:20 +00:00
|
|
|
g_CurrentTrackSegment->m_Start =
|
|
|
|
pt_cur_ch->m_PadEnd->GetPosition();
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2008-12-04 04:28:11 +00:00
|
|
|
else // Creation of a supplemental segment
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-11-20 14:55:20 +00:00
|
|
|
g_CurrentTrackSegment->m_Start =
|
|
|
|
pt_cur_ch->m_PadEnd->GetPosition();
|
2008-02-12 01:02:53 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack = g_CurrentTrackSegment->Copy();
|
|
|
|
newTrack->m_Start = g_CurrentTrackSegment->m_End;
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
g_CurrentTrackList.PushBack( newTrack );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-11-24 06:53:43 +00:00
|
|
|
if( g_CurrentTrackSegment->Back() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-11-20 14:55:20 +00:00
|
|
|
g_CurrentTrackSegment->m_Start =
|
|
|
|
g_CurrentTrackSegment->Back()->m_End;
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
2009-10-30 17:58:15 +00:00
|
|
|
g_CurrentTrackSegment->m_Width = pcb->GetCurrentTrackWidth();
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
if( g_CurrentTrackSegment->m_Start != g_CurrentTrackSegment->m_End )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Reduce aligned segments by one. */
|
2008-12-04 04:28:11 +00:00
|
|
|
TRACK* oldTrack = g_CurrentTrackSegment->Back();
|
|
|
|
if( oldTrack && oldTrack->Type() != TYPE_VIA )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-11-20 14:55:20 +00:00
|
|
|
dx1 = g_CurrentTrackSegment->m_End.x -
|
|
|
|
g_CurrentTrackSegment->m_Start.x;
|
|
|
|
dy1 = g_CurrentTrackSegment->m_End.y -
|
|
|
|
g_CurrentTrackSegment->m_Start.y;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
dx0 = oldTrack->m_End.x - oldTrack->m_Start.x;
|
|
|
|
dy0 = oldTrack->m_End.y - oldTrack->m_Start.y;
|
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-01-25 17:38:30 +00:00
|
|
|
oldTrack->m_End = g_CurrentTrackSegment->m_End;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
delete g_CurrentTrackList.PopBack();
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Insert the new track created in the list of tracks.
|
|
|
|
* amend the points of beginning and end of the track so that they are
|
|
|
|
* connected
|
|
|
|
* Center on pads even if they are off grid.
|
2007-08-23 04:28:46 +00:00
|
|
|
*/
|
2011-03-01 19:26:17 +00:00
|
|
|
static void Place_Piste_en_Buffer( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-01-25 17:38:30 +00:00
|
|
|
if( g_FirstTrackSegment == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int dx0, dy0, dx1, dy1;
|
|
|
|
int marge, via_marge;
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_PANEL* panel = pcbframe->DrawPanel;
|
2011-02-01 15:46:25 +00:00
|
|
|
PCB_SCREEN* screen = pcbframe->GetScreen();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-02-01 15:46:25 +00:00
|
|
|
marge = s_Clearance + ( pcbframe->GetBoard()->GetCurrentTrackWidth() / 2 );
|
2009-11-20 14:55:20 +00:00
|
|
|
via_marge = s_Clearance + ( pcbframe->GetBoard()->GetCurrentViaSize() / 2 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
dx1 = g_CurrentTrackSegment->m_End.x - g_CurrentTrackSegment->m_Start.x;
|
|
|
|
dy1 = g_CurrentTrackSegment->m_End.y - g_CurrentTrackSegment->m_Start.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* Place on center of pad if off grid. */
|
2011-02-01 15:46:25 +00:00
|
|
|
dx0 = pt_cur_ch->m_PadStart->GetPosition().x - g_CurrentTrackSegment->m_Start.x;
|
|
|
|
dy0 = pt_cur_ch->m_PadStart->GetPosition().y - g_CurrentTrackSegment->m_Start.y;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-20 14:55:20 +00:00
|
|
|
/* If aligned, change the origin point. */
|
|
|
|
if( abs( dx0 * dy1 ) == abs( dx1 * dy0 ) )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-05-24 18:28:36 +00:00
|
|
|
g_CurrentTrackSegment->m_End = pt_cur_ch->m_PadStart->GetPosition();
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2009-11-20 14:55:20 +00:00
|
|
|
else
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
TRACK* newTrack = g_CurrentTrackSegment->Copy();
|
2008-02-12 01:02:53 +00:00
|
|
|
|
2009-05-24 18:28:36 +00:00
|
|
|
newTrack->m_End = pt_cur_ch->m_PadStart->GetPosition();
|
2008-12-04 04:28:11 +00:00
|
|
|
newTrack->m_Start = g_CurrentTrackSegment->m_End;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-04 04:28:11 +00:00
|
|
|
g_CurrentTrackList.PushBack( newTrack );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-02-01 15:46:25 +00:00
|
|
|
g_FirstTrackSegment->start = Locate_Pad_Connecte( pcbframe->GetBoard(),
|
|
|
|
g_FirstTrackSegment, START );
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
if( g_FirstTrackSegment->start )
|
|
|
|
g_FirstTrackSegment->SetState( BEGIN_ONPAD, ON );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-02-01 15:46:25 +00:00
|
|
|
g_CurrentTrackSegment->end = Locate_Pad_Connecte( pcbframe->GetBoard(),
|
|
|
|
g_CurrentTrackSegment, END );
|
|
|
|
|
2007-08-23 04:28:46 +00:00
|
|
|
if( g_CurrentTrackSegment->end )
|
|
|
|
g_CurrentTrackSegment->SetState( END_ONPAD, ON );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-01-25 17:38:30 +00:00
|
|
|
/* Out the new track on the matrix board */
|
2009-11-20 14:55:20 +00:00
|
|
|
for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() )
|
2007-08-23 04:28:46 +00:00
|
|
|
{
|
2009-01-05 05:21:35 +00:00
|
|
|
TraceSegmentPcb( pcbframe->GetBoard(), track, HOLE, marge, WRITE_CELL );
|
2009-11-20 14:55:20 +00:00
|
|
|
TraceSegmentPcb( pcbframe->GetBoard(), track, VIA_IMPOSSIBLE,
|
|
|
|
via_marge, WRITE_OR_CELL );
|
2007-08-23 04:28:46 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-01-25 17:38:30 +00:00
|
|
|
// Insert new segments in real board
|
|
|
|
int netcode = g_FirstTrackSegment->GetNet();
|
|
|
|
TRACK* firstTrack = g_FirstTrackSegment;
|
|
|
|
int newCount = g_CurrentTrackList.GetCount();
|
|
|
|
|
|
|
|
// Put entire new current segment list in BOARD
|
|
|
|
TRACK* track;
|
2011-02-01 15:46:25 +00:00
|
|
|
TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( pcbframe->GetBoard() );
|
2009-11-20 14:55:20 +00:00
|
|
|
|
2009-01-25 17:38:30 +00:00
|
|
|
while( ( track = g_CurrentTrackList.PopFront() ) != NULL )
|
|
|
|
{
|
|
|
|
pcbframe->GetBoard()->m_Track.Insert( track, insertBeforeMe );
|
|
|
|
}
|
|
|
|
|
|
|
|
Trace_Une_Piste( panel, DC, firstTrack, newCount, GR_OR );
|
|
|
|
|
|
|
|
pcbframe->test_1_net_connexion( DC, netcode );
|
|
|
|
|
2011-02-01 15:46:25 +00:00
|
|
|
screen->SetModify();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|