Commit 047bb44e authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Pcbnew: minor changes in pcb-parser.cpp and kicad_plugin.cpp to make translations easier.

Code cleaning in autoroute functions.
parent 1b08d187
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -440,7 +440,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()
    m_messagePanel->SetMessage( 14, _( "Cells." ), msg, YELLOW );

    /* Choose the number of board sides. */
    Nb_Sides = TWO_SIDES;
    RoutingMatrix.m_RoutingLayersCount = 2;

    RoutingMatrix.InitRoutingMatrix();

@@ -450,7 +450,7 @@ int PCB_EDIT_FRAME::GenPlaceBoard()

    Route_Layer_BOTTOM = LAYER_N_FRONT;

    if( Nb_Sides == TWO_SIDES )
    if( RoutingMatrix.m_RoutingLayersCount > 1 )
        Route_Layer_BOTTOM = LAYER_N_BACK;

    Route_Layer_TOP = LAYER_N_FRONT;
@@ -618,7 +618,7 @@ int PCB_EDIT_FRAME::GetOptimalModulePlacement( MODULE* aModule, wxDC* aDC )
     */
    TstOtherSide = false;

    if( Nb_Sides == TWO_SIDES )
    if( RoutingMatrix.m_RoutingLayersCount > 1 )
    {
        D_PAD* Pad;
        int otherLayerMask = LAYER_BACK;
@@ -967,7 +967,7 @@ void CreateKeepOutRectangle( int ux0, int uy0, int ux1, int uy1,
    if( aLayerMask & GetLayerMask( Route_Layer_BOTTOM ) )
        trace = 1;     /* Trace on bottom layer. */

    if( ( aLayerMask & GetLayerMask( Route_Layer_TOP ) ) && Nb_Sides )
    if( ( aLayerMask & GetLayerMask( Route_Layer_TOP ) ) && RoutingMatrix.m_RoutingLayersCount )
        trace |= 2;    /* Trace on top layer. */

    if( trace == 0 )
+4 −13
Original line number Diff line number Diff line
@@ -47,12 +47,6 @@
#include <autorout.h>


int Nb_Sides;        /* Number of layer for autorouting (0 or 1) */
int OpenNodes;       /* total number of nodes opened */
int ClosNodes;       /* total number of nodes closed */
int MoveNodes;       /* total number of nodes moved */
int MaxNodes;        /* maximum number of nodes opened at one time */

MATRIX_ROUTING_HEAD RoutingMatrix;     // routing matrix (grid) to route 2-sided boards

/* init board, route traces*/
@@ -175,10 +169,10 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )
    m_messagePanel->EraseMsgBox();

    /* Map the board */
    Nb_Sides = ONE_SIDE;
    RoutingMatrix.m_RoutingLayersCount = 1;

    if( Route_Layer_TOP != Route_Layer_BOTTOM )
        Nb_Sides = TWO_SIDES;
        RoutingMatrix.m_RoutingLayersCount = 2;

    if( RoutingMatrix.InitRoutingMatrix() < 0 )
    {
@@ -195,10 +189,7 @@ void PCB_EDIT_FRAME::Autoroute( wxDC* DC, int mode )

    // DisplayRoutingMatrix( m_canvas, DC );

    if( Nb_Sides == TWO_SIDES )
        Solve( DC, TWO_SIDES ); /* double face */
    else
        Solve( DC, ONE_SIDE );  /* simple face */
    Solve( DC, RoutingMatrix.m_RoutingLayersCount );

    /* Free memory. */
    FreeQueue();
@@ -249,7 +240,7 @@ void DisplayRoutingMatrix( EDA_DRAW_PANEL* panel, wxDC* DC )
            if( dcell0 & HOLE )
                color = GREEN;

//            if( Nb_Sides )
//            if( RoutingMatrix.m_RoutingLayersCount )
//                dcell1 = GetCell( row, col, TOP );

            if( dcell1 & HOLE )
+20 −20
Original line number Diff line number Diff line
@@ -46,7 +46,8 @@ class BOARD;


/* Autorouter commands. */
enum CommandOpt {
enum AUTOPLACEROUTE_OPTIONS
{
    PLACE_ALL,
    PLACE_OUT_OF_BOARD,
    PLACE_INCREMENTAL,
@@ -58,13 +59,7 @@ enum CommandOpt {
    ROUTE_PAD
};


#define ONE_SIDE  0
#define TWO_SIDES 1

#define MAX_SIDES_COUNT 2

extern int Nb_Sides;    /* Number of layers for autorouting (0 or 1) */
#define MAX_ROUTING_LAYERS_COUNT 2

#define FORCE_PADS 1  /* Force placement of pads for any Netcode */

@@ -88,20 +83,23 @@ typedef char DIR_CELL;
class MATRIX_ROUTING_HEAD
{
public:
    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
    MATRIX_CELL* m_BoardSide[MAX_ROUTING_LAYERS_COUNT]; // the image map of 2 board sides
    DIST_CELL*   m_DistSide[MAX_ROUTING_LAYERS_COUNT];  // the image map of 2 board sides:
                                                        // distance to cells
    DIR_CELL*    m_DirSide[MAX_ROUTING_LAYERS_COUNT];   // the image map of 2 board sides:
                                                        // pointers back to source
    bool         m_InitMatrixDone;
    int          m_Layers;                      // Layer count (1 2 )
    int          m_RoutingLayersCount;          // Number of layers for autorouting (0 or 1)
    int          m_GridRouting;                 // Size of grid for autoplace/autoroute
    EDA_RECT     m_BrdBox;                      // Actual board bounding box
    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
    // a pointer to the current selected cell operation
    void        (MATRIX_ROUTING_HEAD::* m_opWriteCell)( int aRow, int aCol,
                                                        int aSide, MATRIX_CELL aCell);

public:
    MATRIX_ROUTING_HEAD();
@@ -114,7 +112,7 @@ public:

    /**
     * function GetBrdCoordOrigin
     * @returns the board coordinate corresponding to the
     * @return the board coordinate corresponding to the
     * routing matrix origin ( board coordinate offset )
     */
    wxPoint GetBrdCoordOrigin()
@@ -156,6 +154,12 @@ public:
    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);

    // calculate distance (with penalty) of a trace through a cell
    int CalcDist(int x,int y,int z ,int side );

    // calculate approximate distance (manhattan distance)
    int GetApxDist( int r1, int c1, int r2, int c2 );
};

extern MATRIX_ROUTING_HEAD RoutingMatrix;        /* 2-sided board */
@@ -220,10 +224,6 @@ int SetWork( int, int, int , int, int, RATSNEST_ITEM *, int );
void GetWork( int *, int *, int *, int *, int *, RATSNEST_ITEM ** );
void SortWork(); /* order the work items; shortest first */

/* DIST.CPP */
int GetApxDist( int r1, int c1, int r2, int c2 );
int CalcDist(int x,int y,int z ,int side );

/* routing_matrix.cpp */
int Build_Work( BOARD * Pcb );
void PlaceCells( BOARD * Pcb, int net_code, int flag = 0 );
+3 −3
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@

 /* calculate approximate distance (manhattan distance)
 */
int GetApxDist( int r1, int c1, int r2, int c2 )
int MATRIX_ROUTING_HEAD::GetApxDist( int r1, int c1, int r2, int c2 )
{
    int d1, d2; /* row and column deltas */

@@ -135,7 +135,7 @@ static int dir_penalty_BOTTOM[10][10] =

/* calculate distance (with penalty) of a trace through a cell
*/
int CalcDist(int x,int y,int z ,int side )
int MATRIX_ROUTING_HEAD::CalcDist(int x,int y,int z ,int side  )
{
    int adjust, ldist;

@@ -158,7 +158,7 @@ int CalcDist(int x,int y,int z ,int side )

    ldist = dist[x-1][y-1] + penalty[x-1][y-1] + adjust;

    if( Nb_Sides )
    if( m_RouteCount > 1 )
    {
        if( side == BOTTOM )
            ldist += dir_penalty_TOP[x-1][y-1];
+5 −5
Original line number Diff line number Diff line
@@ -71,14 +71,14 @@ static void TraceCircle( int ux0, int uy0, int ux1, int uy1, int lg, int layer,
        if( layer < 0 )                                                 \
        {                                                               \
            RoutingMatrix.WriteCell( dy, dx, BOTTOM, color );           \
            if( Nb_Sides )                                              \
            if( RoutingMatrix.m_RoutingLayersCount > 1 )                                              \
                RoutingMatrix.WriteCell( dy, dx, TOP, color );                        \
        }                                                               \
        else                                                            \
        {                                                               \
            if( layer == Route_Layer_BOTTOM )                           \
                RoutingMatrix.WriteCell( dy, dx, BOTTOM, color );       \
            if( Nb_Sides )                                              \
            if( RoutingMatrix.m_RoutingLayersCount > 1 )                                              \
                if( layer == Route_Layer_TOP )                          \
                    RoutingMatrix.WriteCell( dy, dx, TOP, color );      \
        }                                                               \
@@ -156,7 +156,7 @@ void TraceFilledCircle( int cx, int cy, int radius,
        trace = 1;       // Trace on BOTTOM

    if( aLayerMask & GetLayerMask( Route_Layer_TOP ) )
        if( Nb_Sides )
        if( RoutingMatrix.m_RoutingLayersCount > 1 )
            trace |= 2;  // Trace on TOP

    if( trace == 0 )
@@ -475,7 +475,7 @@ void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1,
    if( ( aLayerMask & GetLayerMask( Route_Layer_BOTTOM ) ) )
        trace = 1;     // Trace on BOTTOM

    if( ( aLayerMask & GetLayerMask( Route_Layer_TOP ) ) && Nb_Sides )
    if( ( aLayerMask & GetLayerMask( Route_Layer_TOP ) ) && RoutingMatrix.m_RoutingLayersCount > 1 )
        trace |= 2;    // Trace on TOP

    if( trace == 0 )
@@ -542,7 +542,7 @@ void TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1,

    if( aLayerMask & GetLayerMask( Route_Layer_TOP ) )
    {
        if( Nb_Sides )
        if( RoutingMatrix.m_RoutingLayersCount > 1 )
            trace |= 2;  // Trace on TOP
    }

Loading