|
|
@ -13,38 +13,25 @@ |
|
|
|
#include <class_track.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <autorout.h>
|
|
|
|
#include <cell.h>
|
|
|
|
#include <ar_protos.h>
|
|
|
|
|
|
|
|
|
|
|
|
int ToMatrixCoordinate( int aPhysicalCoordinate ); |
|
|
|
|
|
|
|
void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color ); |
|
|
|
|
|
|
|
void TraceArc( int ux0, |
|
|
|
int uy0, |
|
|
|
int ux1, |
|
|
|
int uy1, |
|
|
|
void TraceArc( int ux0, int uy0, |
|
|
|
int ux1, int uy1, |
|
|
|
int ArcAngle, |
|
|
|
int lg, |
|
|
|
int layer, |
|
|
|
int color, |
|
|
|
int lg, int layer, int color, |
|
|
|
int op_logic ); |
|
|
|
|
|
|
|
|
|
|
|
static void DrawSegmentQcq( int ux0, |
|
|
|
int uy0, |
|
|
|
int ux1, |
|
|
|
int uy1, |
|
|
|
int lg, |
|
|
|
int layer, |
|
|
|
int color, |
|
|
|
static void DrawSegmentQcq( int ux0, int uy0, |
|
|
|
int ux1, int uy1, |
|
|
|
int lg, int layer, int color, |
|
|
|
int op_logic ); |
|
|
|
|
|
|
|
static void TraceFilledCircle( BOARD* aPcb, |
|
|
|
int cx, |
|
|
|
int cy, |
|
|
|
int radius, |
|
|
|
int cx, int cy, int radius, |
|
|
|
int aLayerMask, |
|
|
|
int color, |
|
|
|
int op_logic ); |
|
|
@ -71,19 +58,6 @@ static void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer, |
|
|
|
} \ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function ToMatrixCoordinate |
|
|
|
* compute the coordinate in the routing matrix from the real (board) value |
|
|
|
* @param aPhysicalCoordinate = value to convert |
|
|
|
* @return the coordinate relative to the matrix |
|
|
|
*/ |
|
|
|
int ToMatrixCoordinate( int aPhysicalCoordinate ) |
|
|
|
{ |
|
|
|
return aPhysicalCoordinate / Board.m_GridRouting; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PlacePad( BOARD* aPcb, D_PAD* aPad, int color, int marge, int op_logic ) |
|
|
|
{ |
|
|
|
int dx, dy; |
|
|
@ -108,7 +82,7 @@ void PlacePad( BOARD* aPcb, D_PAD* aPad, int color, int marge, int op_logic ) |
|
|
|
dy += abs( aPad->GetDelta().x ) / 2; |
|
|
|
} |
|
|
|
|
|
|
|
// The pad is a rectangle horizontally or vertically.
|
|
|
|
// The pad is a rectangle ( horizontal or vertical )
|
|
|
|
if( int( aPad->GetOrientation() ) % 900 == 0 ) |
|
|
|
{ |
|
|
|
// Orientation turned 90 deg.
|
|
|
@ -131,18 +105,16 @@ void PlacePad( BOARD* aPcb, D_PAD* aPad, int color, int marge, int op_logic ) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Initialize a color value, the cells included in the board area of the
|
|
|
|
* circle center cx, cy. |
|
|
|
/* Set to color the cells included in the circle
|
|
|
|
* Parameters: |
|
|
|
* center: cx, cy. |
|
|
|
* radius: a value add to the radius or half the score pad |
|
|
|
* aLayerMask: layer occupied |
|
|
|
* color: mask write in cells |
|
|
|
* op_logic: type of writing in the cell (WRITE, OR) |
|
|
|
*/ |
|
|
|
void TraceFilledCircle( BOARD* aPcb, |
|
|
|
int cx, |
|
|
|
int cy, |
|
|
|
int radius, |
|
|
|
int cx, int cy, int radius, |
|
|
|
int aLayerMask, |
|
|
|
int color, |
|
|
|
int op_logic ) |
|
|
@ -151,17 +123,12 @@ void TraceFilledCircle( BOARD* aPcb, |
|
|
|
int ux0, uy0, ux1, uy1; |
|
|
|
int row_max, col_max, row_min, col_min; |
|
|
|
int trace = 0; |
|
|
|
float fdistmin, fdistx, fdisty; |
|
|
|
double fdistmin, fdistx, fdisty; |
|
|
|
|
|
|
|
void (* WriteCell)( int, int, int, MATRIX_CELL ); |
|
|
|
int tstwrite = 0; |
|
|
|
int distmin; |
|
|
|
|
|
|
|
// Determine occupied layer.
|
|
|
|
|
|
|
|
/* Single routing layer on bitmap and BOTTOM
|
|
|
|
* Route_Layer_B = Route_Layer_A */ |
|
|
|
|
|
|
|
if( aLayerMask & GetLayerMask( Route_Layer_BOTTOM ) ) |
|
|
|
trace = 1; // Trace on BOTTOM
|
|
|
|
|
|
|
@ -208,10 +175,10 @@ void TraceFilledCircle( BOARD* aPcb, |
|
|
|
uy1 = cy + radius; |
|
|
|
|
|
|
|
// Calculate limit coordinates of cells belonging to the rectangle.
|
|
|
|
row_max = uy1 / Board.m_GridRouting; |
|
|
|
col_max = ux1 / Board.m_GridRouting; |
|
|
|
row_min = uy0 / Board.m_GridRouting; // if (uy0 > row_min*Board.m_GridRouting) row_min++;
|
|
|
|
col_min = ux0 / Board.m_GridRouting; // if (ux0 > col_min*Board.m_GridRouting) col_min++;
|
|
|
|
row_max = uy1 / RoutingMatrix.m_GridRouting; |
|
|
|
col_max = ux1 / RoutingMatrix.m_GridRouting; |
|
|
|
row_min = uy0 / RoutingMatrix.m_GridRouting; // if (uy0 > row_min*Board.m_GridRouting) row_min++;
|
|
|
|
col_min = ux0 / RoutingMatrix.m_GridRouting; // if (ux0 > col_min*Board.m_GridRouting) col_min++;
|
|
|
|
|
|
|
|
if( row_min < 0 ) |
|
|
|
row_min = 0; |
|
|
@ -232,16 +199,16 @@ void TraceFilledCircle( BOARD* aPcb, |
|
|
|
if( col_min > col_max ) |
|
|
|
col_max = col_min; |
|
|
|
|
|
|
|
fdistmin = (float) distmin * distmin; |
|
|
|
fdistmin = (double) distmin * distmin; |
|
|
|
|
|
|
|
for( row = row_min; row <= row_max; row++ ) |
|
|
|
{ |
|
|
|
fdisty = (float) ( cy - ( row * Board.m_GridRouting ) ); |
|
|
|
fdisty = (double) ( cy - ( row * RoutingMatrix.m_GridRouting ) ); |
|
|
|
fdisty *= fdisty; |
|
|
|
|
|
|
|
for( col = col_min; col <= col_max; col++ ) |
|
|
|
{ |
|
|
|
fdistx = (float) ( cx - ( col * Board.m_GridRouting ) ); |
|
|
|
fdistx = (double) ( cx - ( col * RoutingMatrix.m_GridRouting ) ); |
|
|
|
fdistx *= fdistx; |
|
|
|
|
|
|
|
if( fdistmin <= ( fdistx + fdisty ) ) |
|
|
@ -263,17 +230,17 @@ void TraceFilledCircle( BOARD* aPcb, |
|
|
|
/* If no cell has been written, it affects the 4 neighboring diagonal
|
|
|
|
* (Adverse event: pad off grid in the center of the 4 neighboring |
|
|
|
* diagonal) */ |
|
|
|
distmin = Board.m_GridRouting / 2 + 1; |
|
|
|
fdistmin = ( (float) distmin * distmin ) * 2; // Distance to center point diagonally
|
|
|
|
distmin = RoutingMatrix.m_GridRouting / 2 + 1; |
|
|
|
fdistmin = ( (double) distmin * distmin ) * 2; // Distance to center point diagonally
|
|
|
|
|
|
|
|
for( row = row_min; row <= row_max; row++ ) |
|
|
|
{ |
|
|
|
fdisty = (float) ( cy - ( row * Board.m_GridRouting ) ); |
|
|
|
fdisty = (double) ( cy - ( row * RoutingMatrix.m_GridRouting ) ); |
|
|
|
fdisty *= fdisty; |
|
|
|
|
|
|
|
for( col = col_min; col <= col_max; col++ ) |
|
|
|
{ |
|
|
|
fdistx = (float) ( cx - ( col * Board.m_GridRouting ) ); |
|
|
|
fdistx = (double) ( cx - ( col * RoutingMatrix.m_GridRouting ) ); |
|
|
|
fdistx *= fdistx; |
|
|
|
|
|
|
|
if( fdistmin <= ( fdistx + fdisty ) ) |
|
|
@ -391,9 +358,9 @@ void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_ |
|
|
|
if( y1 < y0 ) |
|
|
|
EXCHG( y0, y1 ); |
|
|
|
|
|
|
|
dy = y0 / Board.m_GridRouting; |
|
|
|
lim = y1 / Board.m_GridRouting; |
|
|
|
dx = x0 / Board.m_GridRouting; |
|
|
|
dy = y0 / RoutingMatrix.m_GridRouting; |
|
|
|
lim = y1 / RoutingMatrix.m_GridRouting; |
|
|
|
dx = x0 / RoutingMatrix.m_GridRouting; |
|
|
|
|
|
|
|
// Clipping limits of board.
|
|
|
|
if( ( dx < 0 ) || ( dx >= Ncols ) ) |
|
|
@ -418,9 +385,9 @@ void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_ |
|
|
|
if( x1 < x0 ) |
|
|
|
EXCHG( x0, x1 ); |
|
|
|
|
|
|
|
dx = x0 / Board.m_GridRouting; |
|
|
|
lim = x1 / Board.m_GridRouting; |
|
|
|
dy = y0 / Board.m_GridRouting; |
|
|
|
dx = x0 / RoutingMatrix.m_GridRouting; |
|
|
|
lim = x1 / RoutingMatrix.m_GridRouting; |
|
|
|
dy = y0 / RoutingMatrix.m_GridRouting; |
|
|
|
|
|
|
|
// Clipping limits of board.
|
|
|
|
if( ( dy < 0 ) || ( dy >= Nrows ) ) |
|
|
@ -448,16 +415,16 @@ void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_ |
|
|
|
EXCHG( x1, x0 ); EXCHG( y1, y0 ); |
|
|
|
} |
|
|
|
|
|
|
|
dx = x0 / Board.m_GridRouting; |
|
|
|
lim = x1 / Board.m_GridRouting; |
|
|
|
dy = y0 / Board.m_GridRouting; |
|
|
|
dx = x0 / RoutingMatrix.m_GridRouting; |
|
|
|
lim = x1 / RoutingMatrix.m_GridRouting; |
|
|
|
dy = y0 / RoutingMatrix.m_GridRouting; |
|
|
|
inc = 1; |
|
|
|
|
|
|
|
if( y1 < y0 ) |
|
|
|
inc = -1; |
|
|
|
|
|
|
|
il = lim - dx; cumul = il / 2; |
|
|
|
delta = abs( y1 - y0 ) / Board.m_GridRouting; |
|
|
|
delta = abs( y1 - y0 ) / RoutingMatrix.m_GridRouting; |
|
|
|
|
|
|
|
for( ; dx <= lim; ) |
|
|
|
{ |
|
|
@ -484,16 +451,17 @@ void TracePcbLine( int x0, int y0, int x1, int y1, int layer, int color, int op_ |
|
|
|
EXCHG( y1, y0 ); |
|
|
|
} |
|
|
|
|
|
|
|
dy = y0 / Board.m_GridRouting; |
|
|
|
lim = y1 / Board.m_GridRouting; |
|
|
|
dx = x0 / Board.m_GridRouting; |
|
|
|
dy = y0 / RoutingMatrix.m_GridRouting; |
|
|
|
lim = y1 / RoutingMatrix.m_GridRouting; |
|
|
|
dx = x0 / RoutingMatrix.m_GridRouting; |
|
|
|
inc = 1; |
|
|
|
|
|
|
|
if( x1 < x0 ) |
|
|
|
inc = -1; |
|
|
|
|
|
|
|
il = lim - dy; cumul = il / 2; |
|
|
|
delta = abs( x1 - x0 ) / Board.m_GridRouting; |
|
|
|
il = lim - dy; |
|
|
|
cumul = il / 2; |
|
|
|
delta = abs( x1 - x0 ) / RoutingMatrix.m_GridRouting; |
|
|
|
|
|
|
|
for( ; dy <= lim; ) |
|
|
|
{ |
|
|
@ -563,16 +531,16 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1, |
|
|
|
uy1 -= aPcb->GetBoundingBox().GetY(); |
|
|
|
|
|
|
|
// Calculating limits coord cells belonging to the rectangle.
|
|
|
|
row_max = uy1 / Board.m_GridRouting; |
|
|
|
col_max = ux1 / Board.m_GridRouting; |
|
|
|
row_min = uy0 / Board.m_GridRouting; |
|
|
|
row_max = uy1 / RoutingMatrix.m_GridRouting; |
|
|
|
col_max = ux1 / RoutingMatrix.m_GridRouting; |
|
|
|
row_min = uy0 / RoutingMatrix.m_GridRouting; |
|
|
|
|
|
|
|
if( uy0 > row_min * Board.m_GridRouting ) |
|
|
|
if( uy0 > row_min * RoutingMatrix.m_GridRouting ) |
|
|
|
row_min++; |
|
|
|
|
|
|
|
col_min = ux0 / Board.m_GridRouting; |
|
|
|
col_min = ux0 / RoutingMatrix.m_GridRouting; |
|
|
|
|
|
|
|
if( ux0 > col_min * Board.m_GridRouting ) |
|
|
|
if( ux0 > col_min * RoutingMatrix.m_GridRouting ) |
|
|
|
col_min++; |
|
|
|
|
|
|
|
if( row_min < 0 ) |
|
|
@ -660,16 +628,16 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1, |
|
|
|
+ (double) ( cy - uy0 ) * ( cy - uy0 ) ); |
|
|
|
|
|
|
|
// Calculating coordinate limits belonging to the rectangle.
|
|
|
|
row_max = ( cy + radius ) / Board.m_GridRouting; |
|
|
|
col_max = ( cx + radius ) / Board.m_GridRouting; |
|
|
|
row_min = ( cy - radius ) / Board.m_GridRouting; |
|
|
|
row_max = ( cy + radius ) / RoutingMatrix.m_GridRouting; |
|
|
|
col_max = ( cx + radius ) / RoutingMatrix.m_GridRouting; |
|
|
|
row_min = ( cy - radius ) / RoutingMatrix.m_GridRouting; |
|
|
|
|
|
|
|
if( uy0 > row_min * Board.m_GridRouting ) |
|
|
|
if( uy0 > row_min * RoutingMatrix.m_GridRouting ) |
|
|
|
row_min++; |
|
|
|
|
|
|
|
col_min = ( cx - radius ) / Board.m_GridRouting; |
|
|
|
col_min = ( cx - radius ) / RoutingMatrix.m_GridRouting; |
|
|
|
|
|
|
|
if( ux0 > col_min * Board.m_GridRouting ) |
|
|
|
if( ux0 > col_min * RoutingMatrix.m_GridRouting ) |
|
|
|
col_min++; |
|
|
|
|
|
|
|
if( row_min < 0 ) |
|
|
@ -688,8 +656,8 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1, |
|
|
|
{ |
|
|
|
for( col = col_min; col <= col_max; col++ ) |
|
|
|
{ |
|
|
|
rotrow = row * Board.m_GridRouting; |
|
|
|
rotcol = col * Board.m_GridRouting; |
|
|
|
rotrow = row * RoutingMatrix.m_GridRouting; |
|
|
|
rotcol = col * RoutingMatrix.m_GridRouting; |
|
|
|
RotatePoint( &rotcol, &rotrow, cx, cy, -angle ); |
|
|
|
|
|
|
|
if( rotrow <= uy0 ) |
|
|
@ -715,9 +683,8 @@ void TraceFilledRectangle( BOARD* aPcb, int ux0, int uy0, int ux1, int uy1, |
|
|
|
|
|
|
|
|
|
|
|
/* Fills all cells inside a segment
|
|
|
|
* half-width lg, org ux, ux end y0, y1 |
|
|
|
* is set to color. |
|
|
|
* coordinates are in PCB units (0.1 mil) are relative to the Board |
|
|
|
* half-width = lg, org = ux0,uy0 end = ux1,uy1 |
|
|
|
* coordinates are in PCB units |
|
|
|
*/ |
|
|
|
void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer, |
|
|
|
int color, int op_logic ) |
|
|
@ -768,27 +735,27 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer, |
|
|
|
if( uy1 < uy0 ) |
|
|
|
inc = -1; |
|
|
|
|
|
|
|
demi_pas = Board.m_GridRouting / 2; |
|
|
|
demi_pas = RoutingMatrix.m_GridRouting / 2; |
|
|
|
|
|
|
|
col_min = ( ux0 - lg ) / Board.m_GridRouting; |
|
|
|
col_min = ( ux0 - lg ) / RoutingMatrix.m_GridRouting; |
|
|
|
|
|
|
|
if( col_min < 0 ) |
|
|
|
col_min = 0; |
|
|
|
|
|
|
|
col_max = ( ux1 + lg + demi_pas ) / Board.m_GridRouting; |
|
|
|
col_max = ( ux1 + lg + demi_pas ) / RoutingMatrix.m_GridRouting; |
|
|
|
|
|
|
|
if( col_max > ( Ncols - 1 ) ) |
|
|
|
col_max = Ncols - 1; |
|
|
|
|
|
|
|
if( inc > 0 ) |
|
|
|
{ |
|
|
|
row_min = ( uy0 - lg ) / Board.m_GridRouting; |
|
|
|
row_max = ( uy1 + lg + demi_pas ) / Board.m_GridRouting; |
|
|
|
row_min = ( uy0 - lg ) / RoutingMatrix.m_GridRouting; |
|
|
|
row_max = ( uy1 + lg + demi_pas ) / RoutingMatrix.m_GridRouting; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
row_min = ( uy1 - lg ) / Board.m_GridRouting; |
|
|
|
row_max = ( uy0 + lg + demi_pas ) / Board.m_GridRouting; |
|
|
|
row_min = ( uy1 - lg ) / RoutingMatrix.m_GridRouting; |
|
|
|
row_max = ( uy0 + lg + demi_pas ) / RoutingMatrix.m_GridRouting; |
|
|
|
} |
|
|
|
|
|
|
|
if( row_min < 0 ) |
|
|
@ -823,11 +790,11 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer, |
|
|
|
for( col = col_min; col <= col_max; col++ ) |
|
|
|
{ |
|
|
|
int cxr; |
|
|
|
cxr = ( col * Board.m_GridRouting ) - ux0; |
|
|
|
cxr = ( col * RoutingMatrix.m_GridRouting ) - ux0; |
|
|
|
|
|
|
|
for( row = row_min; row <= row_max; row++ ) |
|
|
|
{ |
|
|
|
cy = (row * Board.m_GridRouting) - uy0; |
|
|
|
cy = (row * RoutingMatrix.m_GridRouting) - uy0; |
|
|
|
cx = cxr; |
|
|
|
RotatePoint( &cx, &cy, angle ); |
|
|
|
|
|
|
@ -864,10 +831,9 @@ void DrawSegmentQcq( int ux0, int uy0, int ux1, int uy1, int lg, int layer, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Fills all cells BOARD contained in the circle
|
|
|
|
* half-width lg center ux, ux through y0, y1 is set to color. |
|
|
|
* coord in PCB units (0.1 million) relating to the origin |
|
|
|
* pt_pcb-> m_PcbBox.m_Xmin, Y's board. |
|
|
|
/* Fills all cells of the routing matrix contained in the circle
|
|
|
|
* half-width = lg, center = ux0, uy0, ux1,uy1 is a point on the circle. |
|
|
|
* coord are in PCB units. |
|
|
|
*/ |
|
|
|
void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer, |
|
|
|
int color, int op_logic ) |
|
|
@ -908,9 +874,10 @@ void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Fills all BOARD cells contained in the arc of "L" angle half-width lg
|
|
|
|
* ux center, starting in ux y0, y1 is set to color. Coordinates are in |
|
|
|
* PCB units (0.1 mil) relating to the origin pt_pcb-> Pcb_oX, Y's board. |
|
|
|
/* Fills all routing matrix cells contained in the arc
|
|
|
|
* angle = ArcAngle, half-width lg |
|
|
|
* center = ux0,uy0, starting at ux1, uy1. Coordinates are in |
|
|
|
* PCB units. |
|
|
|
*/ |
|
|
|
void TraceArc( int ux0, int uy0, int ux1, int uy1, int ArcAngle, int lg, |
|
|
|
int layer, int color, int op_logic ) |