Commit 9fea98dd authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: Fix compil issues with wxWidgets 2.8.12

Some code cleaning in autoroute functions.
parent d3f95548
......@@ -59,7 +59,7 @@
* graduated from 0 (rotation allowed) to 10 (rotation count null)
* the count is increased.
*/
static const float OrientPenality[11] =
static const double OrientPenality[11] =
{
2.0f, /* CntRot = 0 rotation prohibited */
1.9f, /* CntRot = 1 */
......@@ -82,7 +82,7 @@ static const float OrientPenality[11] =
static wxPoint CurrPosition; // Current position of the current module placement
static bool AutoPlaceShowAll = true;
float MinCout;
double MinCout;
static int TstModuleOnBoard( BOARD* Pcb, MODULE* Module, bool TstOtherSide );
......@@ -251,7 +251,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
DrawInfoPlace( DC );
error = GetOptimalModulePlacement( Module, DC );
float BestScore = MinCout;
double BestScore = MinCout;
PosOK = CurrPosition;
if( error == ESC )
......@@ -388,8 +388,8 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC )
ox = RoutingMatrix.m_BrdBox.GetX() + (jj * RoutingMatrix.m_GridRouting);
color = BLACK;
top_state = GetCell( ii, jj, TOP );
bottom_state = GetCell( ii, jj, BOTTOM );
top_state = RoutingMatrix.GetCell( ii, jj, TOP );
bottom_state = RoutingMatrix.GetCell( ii, jj, BOTTOM );
if( top_state & CELL_is_ZONE )
color = BLUE;
......@@ -403,7 +403,8 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC )
color = LIGHTGREEN;
else /* Display the filling and keep out regions. */
{
if( GetDist( ii, jj, TOP ) || GetDist( ii, jj, BOTTOM ) )
if( RoutingMatrix.GetDist( ii, jj, TOP ) ||
RoutingMatrix.GetDist( ii, jj, BOTTOM ) )
color = DARKGRAY;
}
......@@ -415,7 +416,6 @@ void PCB_EDIT_FRAME::DrawInfoPlace( wxDC* DC )
int PCB_EDIT_FRAME::GenPlaceBoard()
{
int NbCells;
wxString msg;
RoutingMatrix.UnInitRoutingMatrix();
......@@ -429,14 +429,14 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
}
RoutingMatrix.ComputeMatrixSize( GetBoard(), true );
NbCells = Ncols * Nrows;
int nbCells = RoutingMatrix.m_Ncols * RoutingMatrix.m_Nrows;
m_messagePanel->EraseMsgBox();
msg.Printf( wxT( "%d" ), Ncols );
msg.Printf( wxT( "%d" ), RoutingMatrix.m_Ncols );
m_messagePanel->SetMessage( 1, _( "Cols" ), msg, GREEN );
msg.Printf( wxT( "%d" ), Nrows );
msg.Printf( wxT( "%d" ), RoutingMatrix.m_Nrows );
m_messagePanel->SetMessage( 7, _( "Lines" ), msg, GREEN );
msg.Printf( wxT( "%d" ), NbCells );
msg.Printf( wxT( "%d" ), nbCells );
m_messagePanel->SetMessage( 14, _( "Cells." ), msg, YELLOW );
/* Choose the number of board sides. */
......@@ -494,7 +494,8 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
// Mark cells of the routing matrix to CELL_is_ZONE
// (i.e. availlable cell to place a module )
// Init a starting point of attachment to the area.
OrCell( Nrows / 2, Ncols / 2, BOTTOM, CELL_is_ZONE );
RoutingMatrix.OrCell( RoutingMatrix.m_Nrows / 2, RoutingMatrix.m_Ncols / 2,
BOTTOM, CELL_is_ZONE );
// find and mark all other availlable cells:
for( int ii = 1; ii != 0; )
......@@ -503,7 +504,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
// Initialize top layer. to the same value as the bottom layer
if( RoutingMatrix.m_BoardSide[TOP] )
memcpy( RoutingMatrix.m_BoardSide[TOP], RoutingMatrix.m_BoardSide[BOTTOM],
NbCells * sizeof(MATRIX_CELL) );
nbCells * sizeof(MATRIX_CELL) );
return 1;
}
......@@ -697,10 +698,10 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
LastPosOK = CurrPosition;
mincout = Score;
wxString msg;
msg.Printf( wxT( "Score %g, pos %3.4f, %3.4f" ),
msg.Printf( wxT( "Score %g, pos %3.4g, %3.4g" ),
mincout,
(float) LastPosOK.x / 10000,
(float) LastPosOK.y / 10000 );
(double) LastPosOK.x / 10000,
(double) LastPosOK.y / 10000 );
SetStatusText( msg );
}
}
......@@ -763,20 +764,20 @@ int TstRectangle( BOARD* Pcb, int ux0, int uy0, int ux1, int uy1, int side )
if( row_min < 0 )
row_min = 0;
if( row_max >= ( Nrows - 1 ) )
row_max = Nrows - 1;
if( row_max >= ( RoutingMatrix.m_Nrows - 1 ) )
row_max = RoutingMatrix.m_Nrows - 1;
if( col_min < 0 )
col_min = 0;
if( col_max >= ( Ncols - 1 ) )
col_max = Ncols - 1;
if( col_max >= ( RoutingMatrix.m_Ncols - 1 ) )
col_max = RoutingMatrix.m_Ncols - 1;
for( row = row_min; row <= row_max; row++ )
{
for( col = col_min; col <= col_max; col++ )
{
data = GetCell( row, col, side );
data = RoutingMatrix.GetCell( row, col, side );
if( ( data & CELL_is_ZONE ) == 0 )
return OUT_OF_BOARD;
......@@ -820,14 +821,14 @@ unsigned int CalculateKeepOutArea( int ux0, int uy0, int ux1, int uy1, int side
if( row_min < 0 )
row_min = 0;
if( row_max >= ( Nrows - 1 ) )
row_max = Nrows - 1;
if( row_max >= ( RoutingMatrix.m_Nrows - 1 ) )
row_max = RoutingMatrix.m_Nrows - 1;
if( col_min < 0 )
col_min = 0;
if( col_max >= ( Ncols - 1 ) )
col_max = Ncols - 1;
if( col_max >= ( RoutingMatrix.m_Ncols - 1 ) )
col_max = RoutingMatrix.m_Ncols - 1;
keepOut = 0;
......@@ -835,7 +836,7 @@ unsigned int CalculateKeepOutArea( int ux0, int uy0, int ux1, int uy1, int side
{
for( col = col_min; col <= col_max; col++ )
{
keepOut += (int) GetDist( row, col, side );
keepOut += RoutingMatrix.GetDist( row, col, side );
}
}
......@@ -1001,14 +1002,14 @@ void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1,
if( row_min < 0 )
row_min = 0;
if( row_max >= (Nrows - 1) )
row_max = Nrows - 1;
if( row_max >= (RoutingMatrix.m_Nrows - 1) )
row_max = RoutingMatrix.m_Nrows - 1;
if( col_min < 0 )
col_min = 0;
if( col_max >= (Ncols - 1) )
col_max = Ncols - 1;
if( col_max >= (RoutingMatrix.m_Ncols - 1) )
col_max = RoutingMatrix.m_Ncols - 1;
for( row = row_min; row <= row_max; row++ )
{
......@@ -1036,15 +1037,15 @@ void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1,
if( trace & 1 )
{
data = GetDist( row, col, BOTTOM ) + LocalKeepOut;
SetDist( row, col, BOTTOM, data );
data = RoutingMatrix.GetDist( row, col, BOTTOM ) + LocalKeepOut;
RoutingMatrix.SetDist( row, col, BOTTOM, data );
}
if( trace & 2 )
{
data = GetDist( row, col, TOP );
data = RoutingMatrix.GetDist( row, col, TOP );
data = MAX( data, LocalKeepOut );
SetDist( row, col, TOP, data );
RoutingMatrix.SetDist( row, col, TOP, data );
}
}
}
......@@ -1180,23 +1181,23 @@ int propagate()
#define NO_CELL_ZONE (HOLE | CELL_is_EDGE | CELL_is_ZONE)
pt_cell_V.reserve( MAX( Nrows, Ncols ) );
pt_cell_V.reserve( MAX( RoutingMatrix.m_Nrows, RoutingMatrix.m_Ncols ) );
fill( pt_cell_V.begin(), pt_cell_V.end(), 0 );
// Search from left to right and top to bottom.
for( row = 0; row < Nrows; row++ )
for( row = 0; row < RoutingMatrix.m_Nrows; row++ )
{
old_cell_H = 0;
for( col = 0; col < Ncols; col++ )
for( col = 0; col < RoutingMatrix.m_Ncols; col++ )
{
current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
current_cell = RoutingMatrix.GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
if( current_cell == 0 ) /* a free cell is found */
{
if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[col] & CELL_is_ZONE) )
{
OrCell( row, col, BOTTOM, CELL_is_ZONE );
RoutingMatrix.OrCell( row, col, BOTTOM, CELL_is_ZONE );
current_cell = CELL_is_ZONE;
nbpoints++;
}
......@@ -1209,19 +1210,19 @@ int propagate()
// Search from right to left and top to bottom/
fill( pt_cell_V.begin(), pt_cell_V.end(), 0 );
for( row = 0; row < Nrows; row++ )
for( row = 0; row < RoutingMatrix.m_Nrows; row++ )
{
old_cell_H = 0;
for( col = Ncols - 1; col >= 0; col-- )
for( col = RoutingMatrix.m_Ncols - 1; col >= 0; col-- )
{
current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
current_cell = RoutingMatrix.GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
if( current_cell == 0 ) /* a free cell is found */
{
if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[col] & CELL_is_ZONE) )
{
OrCell( row, col, BOTTOM, CELL_is_ZONE );
RoutingMatrix.OrCell( row, col, BOTTOM, CELL_is_ZONE );
current_cell = CELL_is_ZONE;
nbpoints++;
}
......@@ -1234,19 +1235,19 @@ int propagate()
// Search from bottom to top and right to left.
fill( pt_cell_V.begin(), pt_cell_V.end(), 0 );
for( col = Ncols - 1; col >= 0; col-- )
for( col = RoutingMatrix.m_Ncols - 1; col >= 0; col-- )
{
old_cell_H = 0;
for( row = Nrows - 1; row >= 0; row-- )
for( row = RoutingMatrix.m_Nrows - 1; row >= 0; row-- )
{
current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
current_cell = RoutingMatrix.GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
if( current_cell == 0 ) /* a free cell is found */
{
if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[row] & CELL_is_ZONE) )
{
OrCell( row, col, BOTTOM, CELL_is_ZONE );
RoutingMatrix.OrCell( row, col, BOTTOM, CELL_is_ZONE );
current_cell = CELL_is_ZONE;
nbpoints++;
}
......@@ -1259,19 +1260,19 @@ int propagate()
// Search from bottom to top and left to right.
fill( pt_cell_V.begin(), pt_cell_V.end(), 0 );
for( col = 0; col < Ncols; col++ )
for( col = 0; col < RoutingMatrix.m_Ncols; col++ )
{
old_cell_H = 0;
for( row = Nrows - 1; row >= 0; row-- )
for( row = RoutingMatrix.m_Nrows - 1; row >= 0; row-- )
{
current_cell = GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
current_cell = RoutingMatrix.GetCell( row, col, BOTTOM ) & NO_CELL_ZONE;
if( current_cell == 0 ) /* a free cell is found */
{
if( (old_cell_H & CELL_is_ZONE) || (pt_cell_V[row] & CELL_is_ZONE) )
{
OrCell( row, col, BOTTOM, CELL_is_ZONE );
RoutingMatrix.OrCell( row, col, BOTTOM, CELL_is_ZONE );
current_cell = CELL_is_ZONE;
nbpoints++;
}
......
......@@ -48,9 +48,6 @@
int Nb_Sides; /* Number of layer for autorouting (0 or 1) */
int Nrows = ILLEGAL;
int Ncols = ILLEGAL;
int Ntotal;
int OpenNodes; /* total number of nodes opened */
int ClosNodes; /* total number of nodes closed */
int MoveNodes; /* total number of nodes moved */
......@@ -194,7 +191,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
PlaceCells( GetBoard(), -1, FORCE_PADS );
/* Construction of the track list for router. */
Build_Work( GetBoard() );
RoutingMatrix.m_RouteCount = Build_Work( GetBoard() );
// DisplayRoutingMatrix( m_canvas, DC );
......@@ -234,7 +231,7 @@ void DisplayRoutingMatrix( EDA_DRAW_PANEL* panel, wxDC* DC )
{
int dcell0, dcell1 = 0, color;
int maxi = 600 / Ncols;
int maxi = 600 / RoutingMatrix.m_Ncols;
maxi = ( maxi * 3 ) / 4;
if( !maxi )
......@@ -242,12 +239,12 @@ void DisplayRoutingMatrix( EDA_DRAW_PANEL* panel, wxDC* DC )
GRSetDrawMode( DC, GR_COPY );
for( int col = 0; col < Ncols; col++ )
for( int col = 0; col < RoutingMatrix.m_Ncols; col++ )
{
for( int row = 0; row < Nrows; row++ )
for( int row = 0; row < RoutingMatrix.m_Nrows; row++ )
{
color = 0;
dcell0 = GetCell( row, col, BOTTOM );
dcell0 = RoutingMatrix.GetCell( row, col, BOTTOM );
if( dcell0 & HOLE )
color = GREEN;
......
......@@ -68,11 +68,6 @@ extern int Nb_Sides; /* Number of layers for autorouting (0 or 1) */
#define FORCE_PADS 1 /* Force placement of pads for any Netcode */
/* board dimensions */
extern int Nrows;
extern int Ncols;
extern int Ntotal;
/* search statistics */
extern int OpenNodes; /* total number of nodes opened */
extern int ClosNodes; /* total number of nodes closed */
......@@ -88,26 +83,35 @@ typedef char DIR_CELL;
/**
* class MATRIX_ROUTING_HEAD
* handle the matrix routing that describes the actual board
*/
class MATRIX_ROUTING_HEAD /* header of blocks of MATRIX_CELL */
class MATRIX_ROUTING_HEAD
{
public:
MATRIX_CELL* m_BoardSide[MAX_SIDES_COUNT]; /* ptr to block of memory: 2-sided board */
DIST_CELL* m_DistSide[MAX_SIDES_COUNT]; /* ptr to block of memory: path distance to
* cells */
DIR_CELL* m_DirSide[MAX_SIDES_COUNT]; /* header of blocks of chars:pointers back to
* source */
MATRIX_CELL* m_BoardSide[MAX_SIDES_COUNT]; // the image map of 2 board sides
DIST_CELL* m_DistSide[MAX_SIDES_COUNT]; // the image map of 2 board sides: distance to
// cells
DIR_CELL* m_DirSide[MAX_SIDES_COUNT]; // the image map of 2 board sides: pointers back to
// source
bool m_InitMatrixDone;
int m_Layers;
int m_Layers; // Layer count (1 2 )
int m_GridRouting; // Size of grid for autoplace/autoroute
EDA_RECT m_BrdBox; // Actual board bounding box
int m_Nrows, m_Ncols;
int m_MemSize;
int m_Nrows, m_Ncols; // Matrix size
int m_MemSize; // Memory requirement, just for statistics
int m_RouteCount; // Number of routes
private:
void (MATRIX_ROUTING_HEAD::* m_opWriteCell)( int aRow, int aCol, int aSide, MATRIX_CELL aCell); // a pointeur to the current selected cell op
public:
MATRIX_ROUTING_HEAD();
~MATRIX_ROUTING_HEAD();
void WriteCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell)
{
(*this.*m_opWriteCell)( aRow, aCol, aSide, aCell );
}
/**
* Function ComputeMatrixSize
* calculates the number of rows and columns of dimensions of \a aPcb for routing and
......@@ -127,6 +131,21 @@ public:
int InitRoutingMatrix();
void UnInitRoutingMatrix();
// Initialize WriteCell to make the aLogicOp
void SetCellOperation( int aLogicOp );
// functions to read/write one cell ( point on grid routing matrix:
MATRIX_CELL GetCell( int aRow, int aCol, int aSide);
void SetCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void OrCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void XorCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void AndCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void AddCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
DIST_CELL GetDist( int aRow, int aCol, int aSide );
void SetDist( int aRow, int aCol, int aSide, DIST_CELL );
int GetDir( int aRow, int aCol, int aSide );
void SetDir( int aRow, int aCol, int aSide, int aDir);
};
extern MATRIX_ROUTING_HEAD RoutingMatrix; /* 2-sided board */
......@@ -195,20 +214,9 @@ void SortWork(); /* order the work items; shortest first */
int GetApxDist( int r1, int c1, int r2, int c2 );
int CalcDist(int x,int y,int z ,int side );
/* BOARD.CPP */
/* routing_matrix.cpp */
int Build_Work( BOARD * Pcb );
void PlaceCells( BOARD * Pcb, int net_code, int flag = 0 );
MATRIX_CELL GetCell( int aRow, int aCol, int aSide);
void SetCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void OrCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void XorCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void AndCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
void AddCell( int aRow, int aCol, int aSide, MATRIX_CELL aCell);
DIST_CELL GetDist( int aRow, int aCol, int aSide );
void SetDist( int aRow, int aCol, int aSide, DIST_CELL );
int GetDir( int aRow, int aCol, int aSide );
void SetDir( int aRow, int aCol, int aSide, int aDir);
#endif // AUTOROUT_H
......@@ -71,17 +71,17 @@ static void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
{ \
if( layer < 0 ) \
{ \
WriteCell( dy, dx, BOTTOM, color ); \
RoutingMatrix.WriteCell( dy, dx, BOTTOM, color ); \
if( Nb_Sides ) \
WriteCell( dy, dx, TOP, color ); \
RoutingMatrix.WriteCell( dy, dx, TOP, color ); \
} \
else \
{ \
if( layer == Route_Layer_BOTTOM ) \
WriteCell( dy, dx, BOTTOM, color ); \
RoutingMatrix.WriteCell( dy, dx, BOTTOM, color ); \
if( Nb_Sides ) \
if( layer == Route_Layer_TOP ) \
WriteCell( dy, dx, TOP, color ); \
RoutingMatrix.WriteCell( dy, dx, TOP, color ); \
} \
}
......@@ -151,8 +151,6 @@ void TraceFilledCircle( BOARD* aPcb,
int row_max, col_max, row_min, col_min;
int trace = 0;
double fdistmin, fdistx, fdisty;
void (* WriteCell)( int, int, int, MATRIX_CELL );
int tstwrite = 0;
int distmin;
......@@ -166,29 +164,7 @@ void TraceFilledCircle( BOARD* aPcb,
if( trace == 0 )
return;
switch( op_logic )
{
default:
case WRITE_CELL:
WriteCell = SetCell;
break;
case WRITE_OR_CELL:
WriteCell = OrCell;
break;
case WRITE_XOR_CELL:
WriteCell = XorCell;
break;
case WRITE_AND_CELL:
WriteCell = AndCell;
break;
case WRITE_ADD_CELL:
WriteCell = AddCell;
break;
}
RoutingMatrix.SetCellOperation( op_logic );
cx -= aPcb->GetBoundingBox().GetX();
cy -= aPcb->GetBoundingBox().GetY();
......@@ -210,14 +186,14 @@ void TraceFilledCircle( BOARD* aPcb,
if( row_min < 0 )
row_min = 0;
if( row_max >= (Nrows - 1) )
row_max = Nrows - 1;
if( row_max >= (RoutingMatrix.m_Nrows - 1) )
row_max = RoutingMatrix.m_Nrows - 1;
if( col_min < 0 )
col_min = 0;
if( col_max >= (Ncols - 1) )
col_max = Ncols - 1;
if( col_max >= (RoutingMatrix.m_Ncols - 1) )
col_max = RoutingMatrix.m_Ncols - 1;
// Calculate coordinate limits of cell belonging to the rectangle.
if( row_min > row_max )
......@@ -242,10 +218,10 @@ void TraceFilledCircle( BOARD* aPcb,
continue;
if( trace & 1 )
WriteCell( row, col, BOTTOM, color );
RoutingMatrix.WriteCell( row, col, BOTTOM, color );
if( trace & 2 )
WriteCell( row, col, TOP, color );
RoutingMatrix.WriteCell( row, col, TOP, color );
tstwrite = 1;
}
......@@ -274,10 +250,10 @@ void TraceFilledCircle( BOARD* aPcb,
continue;
if( trace & 1 )
WriteCell( row, col, BOTTOM, color );
RoutingMatrix.WriteCell( row, col, BOTTOM, color );
if( trace & 2 )
WriteCell( row, col, TOP, color );
RoutingMatrix.WriteCell( row, col, TOP, color );
}
}
}
......@@ -359,26 +335,7 @@ void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_
int dx, dy, lim;
int cumul, inc, il, delta;
void (* WriteCell)( int, int, int, MATRIX_CELL );
switch( op_logic )
{
default:
case WRITE_CELL:
WriteCell = SetCell; break;
case WRITE_OR_CELL:
WriteCell = OrCell; break;
case WRITE_XOR_CELL:
WriteCell = XorCell; break;
case WRITE_AND_CELL:
WriteCell = AndCell; break;
case WRITE_ADD_CELL:
WriteCell = AddCell; break;
}
RoutingMatrix.SetCellOperation( op_logic );
if( x0 == x1 ) // Vertical.
{
......@@ -390,14 +347,14 @@ void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_
dx = x0 / RoutingMatrix.m_GridRouting;
// Clipping limits of board.
if( ( dx < 0 ) || ( dx >= Ncols ) )
if( ( dx < 0 ) || ( dx >= RoutingMatrix.m_Ncols ) )
return;
if( dy < 0 )
dy = 0;
if( lim >= Nrows )
lim = Nrows - 1;
if( lim >= RoutingMatrix.m_Nrows )
lim = RoutingMatrix.m_Nrows - 1;
for( ; dy <= lim; dy++ )
{
......@@ -417,14 +374,14 @@ void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_
dy = y0 / RoutingMatrix.m_GridRouting;
// Clipping limits of board.
if( ( dy < 0 ) || ( dy >= Nrows ) )
if( ( dy < 0 ) || ( dy >= RoutingMatrix.m_Nrows ) )
return;
if( dx < 0 )
dx = 0;
if( lim >= Ncols )
lim = Ncols - 1;
if( lim >= RoutingMatrix.m_Ncols )
lim = RoutingMatrix.m_Ncols - 1;
for( ; dx <= lim; dx++ )
{
......@@ -455,7 +412,7 @@ void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_
for( ; dx <= lim; )
{
if( ( dx >= 0 ) && ( dy >= 0 ) && ( dx < Ncols ) && ( dy < Nrows ) )
if( ( dx >= 0 ) && ( dy >= 0 ) && ( dx < RoutingMatrix.m_Ncols ) && ( dy < RoutingMatrix.m_Nrows ) )
{
OP_CELL( layer, dy, dx );
}
......@@ -492,7 +449,7 @@ void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_
for( ; dy <= lim; )
{
if( ( dx >= 0 ) && ( dy >= 0 ) && ( dx < Ncols ) && ( dy < Nrows ) )
if( ( dx >= 0 ) && ( dy >= 0 ) && ( dx < RoutingMatrix.m_Ncols ) && ( dy < RoutingMatrix.m_Nrows ) )
{
OP_CELL( layer, dy, dx );
}
......@@ -517,8 +474,6 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1,
int row_min, row_max, col_min, col_max;
int trace = 0;
void (* WriteCell)( int, int, int, MATRIX_CELL );
if( ( aLayerMask & GetLayerMask( Route_Layer_BOTTOM ) ) )
trace = 1; // Trace on BOTTOM
......@@ -528,29 +483,7 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1,
if( trace == 0 )
return;
switch( op_logic )
{
default:
case WRITE_CELL:
WriteCell = SetCell;
break;
case WRITE_OR_CELL:
WriteCell = OrCell;
break;
case WRITE_XOR_CELL:
WriteCell = XorCell;
break;
case WRITE_AND_CELL:
WriteCell = AndCell;
break;
case WRITE_ADD_CELL:
WriteCell = AddCell;
break;
}
RoutingMatrix.SetCellOperation( op_logic );
ux0 -= aPcb->GetBoundingBox().GetX();
uy0 -= aPcb->GetBoundingBox().GetY();
......@@ -573,24 +506,24 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1,
if( row_min < 0 )
row_min = 0;
if( row_max >= ( Nrows - 1 ) )
row_max = Nrows - 1;
if( row_max >= ( RoutingMatrix.m_Nrows - 1 ) )
row_max = RoutingMatrix.m_Nrows - 1;
if( col_min < 0 )
col_min = 0;
if( col_max >= ( Ncols - 1 ) )
col_max = Ncols - 1;
if( col_max >= ( RoutingMatrix.m_Ncols - 1 ) )
col_max = RoutingMatrix.m_Ncols - 1;
for( row = row_min; row <= row_max; row++ )
{
for( col = col_min; col <= col_max; col++ )
{
if( trace & 1 )
WriteCell( row, col, BOTTOM, color );
RoutingMatrix.WriteCell( row, col, BOTTOM, color );
if( trace & 2 )
WriteCell( row, col, TOP, color );
RoutingMatrix.WriteCell( row, col, TOP, color );
}
}
}
......@@ -606,8 +539,6 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1,
int rotrow, rotcol;
int trace = 0;
void (* WriteCell)( int, int, int, MATRIX_CELL );
if( aLayerMask & GetLayerMask( Route_Layer_BOTTOM ) )
trace = 1; // Trace on BOTTOM
......@@ -620,29 +551,7 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1,
if( trace == 0 )
return;
switch( op_logic )
{
default:
case WRITE_CELL:
WriteCell = SetCell;
break;
case WRITE_OR_CELL:
WriteCell = OrCell;
break;
case WRITE_XOR_CELL:
WriteCell = XorCell;
break;
case WRITE_AND_CELL:
WriteCell = AndCell;
break;
case WRITE_ADD_CELL:
WriteCell = AddCell;
break;
}
RoutingMatrix.SetCellOperation( op_logic );
ux0 -= aPcb->GetBoundingBox().GetX();
uy0 -= aPcb->GetBoundingBox().GetY();
......@@ -670,14 +579,14 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1,
if( row_min < 0 )
row_min = 0;
if( row_max >= ( Nrows - 1 ) )
row_max = Nrows - 1;
if( row_max >= ( RoutingMatrix.m_Nrows - 1 ) )
row_max = RoutingMatrix.m_Nrows - 1;
if( col_min < 0 )
col_min = 0;
if( col_max >= ( Ncols - 1 ) )
col_max = Ncols - 1;
if( col_max >= ( RoutingMatrix.m_Ncols - 1 ) )
col_max = RoutingMatrix.m_Ncols - 1;
for( row = row_min; row <= row_max; row++ )
{
......@@ -700,10 +609,10 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1,
continue;
if( trace & 1 )
WriteCell( row, col, BOTTOM, color );
RoutingMatrix.WriteCell( row, col, BOTTOM, color );
if( trace & 2 )
WriteCell( row, col, TOP, color );
RoutingMatrix.WriteCell( row, col, TOP, color );
}
}
}
......@@ -721,33 +630,10 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
int row_max, col_max, row_min, col_min;
int demi_pas;
void (* WriteCell)( int, int, int, MATRIX_CELL );
int angle;
int cx, cy, dx, dy;
switch( op_logic )
{
default:
case WRITE_CELL:
WriteCell = SetCell;
break;
case WRITE_OR_CELL:
WriteCell = OrCell;
break;
case WRITE_XOR_CELL:
WriteCell = XorCell;
break;
case WRITE_AND_CELL:
WriteCell = AndCell;
break;
case WRITE_ADD_CELL:
WriteCell = AddCell;
break;
}
RoutingMatrix.SetCellOperation( op_logic );
// Make coordinate ux1 tj > ux0 to simplify calculations
if( ux1 < ux0 )
......@@ -771,8 +657,8 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
col_max = ( ux1 + lg + demi_pas ) / RoutingMatrix.m_GridRouting;
if( col_max > ( Ncols - 1 ) )
col_max = Ncols - 1;
if( col_max > ( RoutingMatrix.m_Ncols - 1 ) )
col_max = RoutingMatrix.m_Ncols - 1;
if( inc > 0 )
{
......@@ -788,14 +674,14 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
if( row_min < 0 )
row_min = 0;
if( row_min > ( Nrows - 1 ) )
row_min = Nrows - 1;
if( row_min > ( RoutingMatrix.m_Nrows - 1 ) )
row_min = RoutingMatrix.m_Nrows - 1;
if( row_max < 0 )
row_max = 0;
if( row_max > ( Nrows - 1 ) )
row_max = Nrows - 1;
if( row_max > ( RoutingMatrix.m_Nrows - 1 ) )
row_max = RoutingMatrix.m_Nrows - 1;
dx = ux1 - ux0;
dy = uy1 - uy0;
......
......@@ -69,14 +69,12 @@ bool MATRIX_ROUTING_HEAD::ComputeMatrixSize( BOARD* aPcb, bool aUseBoardEdgesOnl
aPcb->SetBoundingBox( m_BrdBox );
m_Nrows = Nrows = m_BrdBox.GetHeight() / m_GridRouting;
m_Ncols = Ncols = m_BrdBox.GetWidth() / m_GridRouting;
m_Nrows = m_BrdBox.GetHeight() / m_GridRouting;
m_Ncols = m_BrdBox.GetWidth() / m_GridRouting;
/* get a small margin for memory allocation: */
Ncols += 1;
m_Nrows = Nrows;
Nrows += 1;
m_Ncols = Ncols;
// gives a small margin
m_Ncols += 1;
m_Nrows += 1;
return true;
}
......@@ -103,15 +101,13 @@ int MATRIX_ROUTING_HEAD::InitRoutingMatrix()
{
int ii, kk;
if( Nrows <= 0 || Ncols <= 0 )
if( m_Nrows <= 0 || m_Ncols <= 0 )
return 0;
m_Nrows = Nrows;
m_Ncols = Ncols;
m_InitMatrixDone = true; // we have been called
// give a small margin for memory allocation:
ii = (Nrows + 1) * (Ncols + 1);
ii = (RoutingMatrix.m_Nrows + 1) * (RoutingMatrix.m_Ncols + 1);
for( kk = 0; kk < m_Layers; kk++ )
{
......@@ -354,7 +350,7 @@ int Build_Work( BOARD* Pcb )
EDA_RECT bbbox = Pcb->GetBoundingBox();
InitWork(); /* clear work list */
Ntotal = 0;
int cellCount = 0;
for( unsigned ii = 0; ii < Pcb->GetRatsnestsCount(); ii++ )
{
......@@ -379,7 +375,7 @@ int Build_Work( BOARD* Pcb )
r1 = ( pt_pad->GetPosition().y - bbbox.GetY() + demi_pas ) / RoutingMatrix.m_GridRouting;
if( r1 < 0 || r1 >= Nrows )
if( r1 < 0 || r1 >= RoutingMatrix.m_Nrows )
{
msg.Printf( wxT( "error : row = %d ( padY %d pcbY %d) " ), r1,
pt_pad->GetPosition().y, bbbox.GetY() );
......@@ -389,7 +385,7 @@ int Build_Work( BOARD* Pcb )
c1 = ( pt_pad->GetPosition().x - bbbox.GetX() + demi_pas ) / RoutingMatrix.m_GridRouting;
if( c1 < 0 || c1 >= Ncols )
if( c1 < 0 || c1 >= RoutingMatrix.m_Ncols )
{
msg.Printf( wxT( "error : col = %d ( padX %d pcbX %d) " ), c1,
pt_pad->GetPosition().x, bbbox.GetX() );
......@@ -402,7 +398,7 @@ int Build_Work( BOARD* Pcb )
r2 = ( pt_pad->GetPosition().y - bbbox.GetY()
+ demi_pas ) / RoutingMatrix.m_GridRouting;
if( r2 < 0 || r2 >= Nrows )
if( r2 < 0 || r2 >= RoutingMatrix.m_Nrows )
{
msg.Printf( wxT( "error : row = %d ( padY %d pcbY %d) " ), r2,
pt_pad->GetPosition().y, bbbox.GetY() );
......@@ -412,7 +408,7 @@ int Build_Work( BOARD* Pcb )
c2 = ( pt_pad->GetPosition().x - bbbox.GetX() + demi_pas ) / RoutingMatrix.m_GridRouting;
if( c2 < 0 || c2 >= Ncols )
if( c2 < 0 || c2 >= RoutingMatrix.m_Ncols )
{
msg.Printf( wxT( "error : col = %d ( padX %d pcbX %d) " ), c2,
pt_pad->GetPosition().x, bbbox.GetX() );
......@@ -421,115 +417,143 @@ int Build_Work( BOARD* Pcb )
}
SetWork( r1, c1, current_net_code, r2, c2, pt_ch, 0 );
Ntotal++;
cellCount++;
}
SortWork();
return Ntotal;
return cellCount;
}
// Initialize WriteCell to make the aLogicOp
void MATRIX_ROUTING_HEAD::SetCellOperation( int aLogicOp )
{
switch( aLogicOp )
{
default:
case WRITE_CELL:
m_opWriteCell = &MATRIX_ROUTING_HEAD::SetCell;
break;
case WRITE_OR_CELL:
m_opWriteCell = &MATRIX_ROUTING_HEAD::OrCell;
break;
case WRITE_XOR_CELL:
m_opWriteCell = &MATRIX_ROUTING_HEAD::XorCell;
break;
case WRITE_AND_CELL:
m_opWriteCell = &MATRIX_ROUTING_HEAD::AndCell;
break;
case WRITE_ADD_CELL:
m_opWriteCell = &MATRIX_ROUTING_HEAD::AddCell;
break;
}
}
/* return the value stored in a cell
*/
MATRIX_CELL GetCell( int aRow, int aCol, int aSide )
MATRIX_CELL MATRIX_ROUTING_HEAD::GetCell( int aRow, int aCol, int aSide )
{
MATRIX_CELL* p;
p = RoutingMatrix.m_BoardSide[aSide];
return p[aRow * Ncols + aCol];
return p[aRow * m_Ncols + aCol];
}
/* basic cell operation : WRITE operation
*/
void SetCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
void MATRIX_ROUTING_HEAD::SetCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
MATRIX_CELL* p;
p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] = x;
p[aRow * m_Ncols + aCol] = x;
}
/* basic cell operation : OR operation
*/
void OrCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
void MATRIX_ROUTING_HEAD::OrCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
MATRIX_CELL* p;
p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] |= x;
p[aRow * m_Ncols + aCol] |= x;
}
/* basic cell operation : XOR operation
*/
void XorCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
void MATRIX_ROUTING_HEAD::XorCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
MATRIX_CELL* p;
p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] ^= x;
p[aRow * m_Ncols + aCol] ^= x;
}
/* basic cell operation : AND operation
*/
void AndCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
void MATRIX_ROUTING_HEAD::AndCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
MATRIX_CELL* p;
p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] &= x;
p[aRow * m_Ncols + aCol] &= x;
}
/* basic cell operation : ADD operation
*/
void AddCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
void MATRIX_ROUTING_HEAD::AddCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
{
MATRIX_CELL* p;
p = RoutingMatrix.m_BoardSide[aSide];
p[aRow * Ncols + aCol] += x;
p[aRow * m_Ncols + aCol] += x;
}
/* fetch distance cell */
DIST_CELL GetDist( int aRow, int aCol, int aSide ) /* fetch distance cell */
DIST_CELL MATRIX_ROUTING_HEAD::GetDist( int aRow, int aCol, int aSide ) /* fetch distance cell */
{
DIST_CELL* p;
p = RoutingMatrix.m_DistSide[aSide];
return p[aRow * Ncols + aCol];
return p[aRow * m_Ncols + aCol];
}
/* store distance cell */
void SetDist( int aRow, int aCol, int aSide, DIST_CELL x )
void MATRIX_ROUTING_HEAD::SetDist( int aRow, int aCol, int aSide, DIST_CELL x )
{
DIST_CELL* p;
p = RoutingMatrix.m_DistSide[aSide];
p[aRow * Ncols + aCol] = x;
p[aRow * m_Ncols + aCol] = x;
}
/* fetch direction cell */
int GetDir( int aRow, int aCol, int aSide )
int MATRIX_ROUTING_HEAD::GetDir( int aRow, int aCol, int aSide )
{
DIR_CELL* p;
p = RoutingMatrix.m_DirSide[aSide];
return (int) (p[aRow * Ncols + aCol]);
return (int) (p[aRow * m_Ncols + aCol]);
}
/* store direction cell */
void SetDir( int aRow, int aCol, int aSide, int x )
void MATRIX_ROUTING_HEAD::SetDir( int aRow, int aCol, int aSide, int x )
{
DIR_CELL* p;
p = RoutingMatrix.m_DirSide[aSide];
p[aRow * Ncols + aCol] = (char) x;
p[aRow * m_Ncols + aCol] = (char) x;
}
......@@ -82,7 +82,6 @@ static int segm_oX, segm_oY;
static int segm_fX, segm_fY; /* Origin and position of the current
* trace segment. */
static RATSNEST_ITEM* pt_cur_ch;
static int Ncurrent; /* measures of progress */
static int s_Clearance; // Clearance value used in autorouter
static PICKED_ITEMS_LIST s_ItemsListPicker;
......@@ -272,13 +271,12 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides )
NETINFO_ITEM* net;
bool stop = false;
wxString msg;
int routedCount = 0; // routed ratsnest count
m_canvas->SetAbortRequest( false );
s_Clearance = GetBoard()->m_NetClasses.GetDefault()->GetClearance();
Ncurrent = 0;
// Prepare the undo command info
s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be necessary, but...
......@@ -310,14 +308,14 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides )
EraseMsgBox();
Ncurrent++;
routedCount++;
net = GetBoard()->FindNet( current_net_code );
if( net )
{
msg.Printf( wxT( "[%8.8s]" ), GetChars( net->GetNetname() ) );
AppendMsgPanel( wxT( "Net route" ), msg, BROWN );
msg.Printf( wxT( "%d / %d" ), Ncurrent, Ntotal );
msg.Printf( wxT( "%d / %d" ), routedCount, RoutingMatrix.m_RouteCount );
AppendMsgPanel( wxT( "Activity" ), msg, BROWN );
}
......@@ -328,25 +326,15 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides )
segm_fY = GetBoard()->GetBoundingBox().GetY() + (RoutingMatrix.m_GridRouting * row_target);
/* Draw segment. */
GRLine( m_canvas->GetClipBox(),
DC,
segm_oX,
segm_oY,
segm_fX,
segm_fY,
0,
WHITE | GR_XOR );
GRLine( m_canvas->GetClipBox(), DC,
segm_oX, segm_oY, segm_fX, segm_fY,
0, WHITE | GR_XOR );
pt_cur_ch->m_PadStart->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT );
pt_cur_ch->m_PadEnd->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT );
success = Autoroute_One_Track( this,
DC,
two_sides,
row_source,
col_source,
row_target,
col_target,
pt_cur_ch );
success = Autoroute_One_Track( this, DC,
two_sides, row_source, col_source,
row_target, col_target, pt_cur_ch );
switch( success )
{
......@@ -439,7 +427,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
marge = s_Clearance + ( pcbframe->GetBoard()->GetCurrentTrackWidth() / 2 );
/* clear direction flags */
i = Nrows * Ncols * sizeof(DIR_CELL);
i = RoutingMatrix.m_Nrows * RoutingMatrix.m_Ncols * sizeof(DIR_CELL);
memset( RoutingMatrix.m_DirSide[TOP], FROM_NOWHERE, i );
memset( RoutingMatrix.m_DirSide[BOTTOM], FROM_NOWHERE, i );
......@@ -603,7 +591,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
for( ; r != ILLEGAL; GetQueue( &r, &c, &side, &d, &apx_dist ) )
{
curcell = GetCell( r, c, side );
curcell = RoutingMatrix.GetCell( r, c, side );
if( curcell & CURRENT_PAD )
curcell &= ~HOLE;
......@@ -675,13 +663,14 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
nc = c + delta[i][1];
/* off the edge? */
if( nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols )
if( nr < 0 || nr >= RoutingMatrix.m_Nrows ||
nc < 0 || nc >= RoutingMatrix.m_Ncols )
continue; /* off the edge */
if( _self == 5 && selfok2[i].present )
continue;
newcell = GetCell( nr, nc, side );
newcell = RoutingMatrix.GetCell( nr, nc, side );
if( newcell & CURRENT_PAD )
newcell &= ~HOLE;
......@@ -702,7 +691,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
if( delta[i][0] && delta[i][1] )
{
/* check first buddy */
buddy = GetCell( r + blocking[i].r1, c + blocking[i].c1, side );
buddy = RoutingMatrix.GetCell( r + blocking[i].r1, c + blocking[i].c1, side );
if( buddy & CURRENT_PAD )
buddy &= ~HOLE;
......@@ -712,7 +701,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
// if (buddy & (blocking[i].b1)) continue;
/* check second buddy */
buddy = GetCell( r + blocking[i].r2, c + blocking[i].c2, side );
buddy = RoutingMatrix.GetCell( r + blocking[i].r2, c + blocking[i].c2, side );
if( buddy & CURRENT_PAD )
buddy &= ~HOLE;
......@@ -723,17 +712,17 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
// if (buddy & (blocking[i].b2)) continue;
}
olddir = GetDir( r, c, side );
olddir = RoutingMatrix.GetDir( r, c, side );
newdist = d + CalcDist( ndir[i], olddir,
( olddir == FROM_OTHERSIDE ) ?
GetDir( r, c, 1 - side ) : 0, side );
RoutingMatrix.GetDir( r, c, 1 - side ) : 0, side );
/* if (a) not visited yet, or (b) we have */
/* found a better path, add it to queue */
if( !GetDir( nr, nc, side ) )
if( !RoutingMatrix.GetDir( nr, nc, side ) )
{
SetDir( nr, nc, side, ndir[i] );
SetDist( nr, nc, side, newdist );
RoutingMatrix.SetDir( nr, nc, side, ndir[i] );
RoutingMatrix.SetDist( nr, nc, side, newdist );
if( SetQueue( nr, nc, side, newdist,
GetApxDist( nr, nc, row_target, col_target ),
......@@ -742,10 +731,10 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
return ERR_MEMORY;
}
}
else if( newdist < GetDist( nr, nc, side ) )
else if( newdist < RoutingMatrix.GetDist( nr, nc, side ) )
{
SetDir( nr, nc, side, ndir[i] );
SetDist( nr, nc, side, newdist );
RoutingMatrix.SetDir( nr, nc, side, ndir[i] );
RoutingMatrix.SetDist( nr, nc, side, newdist );
ReSetQueue( nr, nc, side, newdist,
GetApxDist( nr, nc, row_target, col_target ),
row_target, col_target );
......@@ -755,7 +744,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
/** Test the other layer. **/
if( two_sides )
{
olddir = GetDir( r, c, side );
olddir = RoutingMatrix.GetDir( r, c, side );
if( olddir == FROM_OTHERSIDE )
continue; /* useless move, so don't bother */
......@@ -764,7 +753,7 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
continue;
/* check for holes or traces on other side */
if( ( newcell = GetCell( r, c, 1 - side ) ) != 0 )
if( ( newcell = RoutingMatrix.GetCell( r, c, 1 - side ) ) != 0 )
continue;
/* check for nearby holes or traces on both sides */
......@@ -772,16 +761,17 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
{
nr = r + delta[i][0]; nc = c + delta[i][1];
if( nr < 0 || nr >= Nrows || nc < 0 || nc >= Ncols )
if( nr < 0 || nr >= RoutingMatrix.m_Nrows ||
nc < 0 || nc >= RoutingMatrix.m_Ncols )
continue; /* off the edge !! */
if( GetCell( nr, nc, side ) /* & blocking2[i]*/ )
if( RoutingMatrix.GetCell( nr, nc, side ) /* & blocking2[i]*/ )
{
skip = 1; /* can't drill via here */
break;
}
if( GetCell( nr, nc, 1 - side ) /* & blocking2[i]*/ )
if( RoutingMatrix.GetCell( nr, nc, 1 - side ) /* & blocking2[i]*/ )
{
skip = 1; /* can't drill via here */
break;
......@@ -796,22 +786,21 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
/* if (a) not visited yet,
* or (b) we have found a better path,
* add it to queue */
if( !GetDir( r, c, 1 - side ) )
if( !RoutingMatrix.GetDir( r, c, 1 - side ) )
{
SetDir( r, c, 1 - side, FROM_OTHERSIDE );
SetDist( r, c, 1 - side, newdist );
RoutingMatrix.SetDir( r, c, 1 - side, FROM_OTHERSIDE );
RoutingMatrix.SetDist( r, c, 1 - side, newdist );
if( SetQueue( r, c, 1 - side, newdist, apx_dist, row_target, col_target ) == 0 )
{
return ERR_MEMORY;
}
}
else if( newdist < GetDist( r, c, 1 - side ) )
else if( newdist < RoutingMatrix.GetDist( r, c, 1 - side ) )
{
SetDir( r, c, 1 - side, FROM_OTHERSIDE );
SetDist( r, c, 1 - side, newdist );
ReSetQueue( r,
c,
RoutingMatrix.SetDir( r, c, 1 - side, FROM_OTHERSIDE );
RoutingMatrix.SetDist( r, c, 1 - side, newdist );
ReSetQueue( r, c,
1 - side,
newdist,
apx_dist,
......@@ -972,7 +961,7 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC,
{
/* find where we came from to get here */
r2 = r1; c2 = c1; s2 = s1;
x = GetDir( r1, c1, s1 );
x = RoutingMatrix.GetDir( r1, c1, s1 );
switch( x )
{
......@@ -1017,12 +1006,12 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC,
break;
default:
DisplayError( pcbframe, wxT( "Retrace: internal error: no way back" ) );
wxMessageBox( wxT( "Retrace: internal error: no way back" ) );
return 0;
}
if( r0 != ILLEGAL )
y = GetDir( r0, c0, s0 );
y = RoutingMatrix.GetDir( r0, c0, s0 );
/* see if target or hole */
if( ( ( r1 == row_target ) && ( c1 == col_target ) ) || ( s1 != s0 ) )
......@@ -1091,7 +1080,7 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC,
}
else
{
DisplayError( pcbframe, wxT( "Retrace: error 2" ) );
wxMessageBox( wxT( "Retrace: error 2" ) );
return 0;
}
}
......@@ -1136,7 +1125,7 @@ static int Retrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC,
case FROM_OTHERSIDE:
default:
DisplayError( pcbframe, wxT( "Retrace: error 3" ) );
wxMessageBox( wxT( "Retrace: error 3" ) );
return 0;
}
......
......@@ -92,13 +92,10 @@ void ReInitWork()
*/
static int GetCost( int r1, int c1, int r2, int c2 );
int SetWork( int r1,
int c1,
int SetWork( int r1, int c1,
int n_c,
int r2,
int c2,
RATSNEST_ITEM* pt_ch,
int pri )
int r2, int c2,
RATSNEST_ITEM* pt_ch, int pri )
{
CWORK* p;
......@@ -226,11 +223,10 @@ void SortWork()
static int GetCost( int r1, int c1, int r2, int c2 )
{
int dx, dy, mx, my;
double incl;
double incl = 1.0;
dx = abs( c2 - c1 );
dy = abs( r2 - r1 );
incl = 1.0;
mx = dx;
my = dy;
......
......@@ -1093,11 +1093,11 @@ PCB_IO::PCB_IO()
BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties )
{
wxFFile file( aFileName, "r" );
wxFFile file( aFileName, wxT("r") );
if( !file.IsOpened() )
{
THROW_IO_ERROR( _( "Unable to read file \"" ) + GetChars( aFileName ) + wxT( "\"" ) );
THROW_IO_ERROR( _( "Unable to read file \"" ) + aFileName + wxT( "\"" ) );
}
PCB_PARSER parser( new FILE_LINE_READER( file.fp(), aFileName ), aAppendToMe );
......
......@@ -29,6 +29,7 @@
#include <common.h>
#include <macros.h>
#include <convert_from_iu.h>
#include <errno.h>
#include <trigo.h>
#include <3d_struct.h>
#include <class_title_block.h>
......@@ -610,7 +611,7 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
T token;
wxString name;
wxString type;
bool isVisible;
bool isVisible = true;
int visibleLayers = 0;
int enabledLayers = 0;
std::vector< LAYER > layers;
......@@ -645,7 +646,7 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
Expecting( "hide or )" );
}
layers.push_back( LAYER( name, LAYER::ParseType( type.c_str() ), isVisible ) );
layers.push_back( LAYER( name, LAYER::ParseType( TO_UTF8( type ) ), isVisible ) );
}
int copperLayerCount = 0;
......@@ -691,7 +692,7 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR )
{
wxString error;
error.Printf( _( "Cannot determine fixed layer list index of layer name \"%s\"" ),
layers[i].m_Name );
layers[i].m_Name.GetData() );
THROW_IO_ERROR( error );
}
}
......@@ -1055,7 +1056,7 @@ void PCB_PARSER::parseNETCLASS() throw( IO_ERROR, PARSE_ERROR )
wxString error;
error.Printf( _( "duplicate NETCLASS name '%s' in file %s at line %d, offset %d" ),
nc->GetName().GetData(), CurSource(), CurLineNumber(), CurOffset() );
nc->GetName().GetData(), CurSource().GetData(), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment