Commit 97003fef authored by Marco Mattila's avatar Marco Mattila
Browse files

Change board bounding box calculation to include all board items by default in...

Change board bounding box calculation to include all board items by default in pcbnew. Add a parameter to look for board edges only.
parent e07643f0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List()

    m_gllist = glGenLists( 1 );

    pcb->ComputeBoundaryBox();
    pcb->ComputeBoundingBox();
    g_Parm_3D_Visu.m_BoardSettings = pcb->GetBoardDesignSettings();
    g_Parm_3D_Visu.m_BoardSize     = pcb->m_BoundaryBox.GetSize();
    g_Parm_3D_Visu.m_BoardPos   = pcb->m_BoundaryBox.Centre();
+1 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ static bool WriteGeneralDescrPcb( BOARD* Pcb, FILE* File )
    fprintf( File, "LayerCount %d\n", NbLayers );

    /* Compute and print the board bounding box */
    Pcb->ComputeBoundaryBox();
    Pcb->ComputeBoundingBox();
    fprintf( File, "Di %d %d %d %d\n",
            Pcb->m_BoundaryBox.GetX(), Pcb->m_BoundaryBox.GetY(),
            Pcb->m_BoundaryBox.GetRight(),
+0 −1
Original line number Diff line number Diff line
@@ -1108,7 +1108,6 @@ public:
                                  bool include_fixe );
    void         FixeModule( MODULE* Module, bool Fixe );
    void         AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb );
    bool         SetBoardBoundaryBoxFromEdgesOnly();
    void         AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC );
    int          RecherchePlacementModule( MODULE* Module, wxDC* DC );
    void         GenModuleOnBoard( MODULE* Module );
+1 −1
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
    if( !IsOK( this, _( "Move modules?" ) ) )
        return;

    edgesExists = SetBoardBoundaryBoxFromEdgesOnly();
    edgesExists = GetBoard()->ComputeBoundingBox( true );

    if( PlaceModulesHorsPcb && !edgesExists )
    {
+1 −68
Original line number Diff line number Diff line
@@ -382,7 +382,7 @@ int WinEDA_PcbFrame::GenPlaceBoard()

    Board.UnInitBoard();

    if( !SetBoardBoundaryBoxFromEdgesOnly() )
    if( !GetBoard()->ComputeBoundingBox( true ) )
    {
        DisplayError( this, _( "No PCB edge found, unknown board size!" ) );
        return 0;
@@ -1086,73 +1086,6 @@ static MODULE* PickModule( WinEDA_PcbFrame* pcbframe, wxDC* DC )
}


/*
 * Determine the rectangle of the pcb, according to the contours
 * layer (EDGE) only
 * Output:
 *   GetBoard()->m_BoundaryBox updated
 * Returns FALSE if no contour
 */
bool WinEDA_PcbFrame::SetBoardBoundaryBoxFromEdgesOnly()
{
    int          rayon, cx, cy, d;
    int          xmax, ymax;
    BOARD_ITEM*  PtStruct;
    DRAWSEGMENT* ptr;
    bool         succes = FALSE;

    if( GetBoard() == NULL )
        return FALSE;

    GetBoard()->m_BoundaryBox.m_Pos.x = GetBoard()->m_BoundaryBox.m_Pos.y =
        0x7FFFFFFFl;
    xmax = ymax = -0x7FFFFFFFl;

    PtStruct = GetBoard()->m_Drawings;
    for( ; PtStruct != NULL; PtStruct = PtStruct->Next() )
    {
        if( PtStruct->Type() != TYPE_DRAWSEGMENT )
            continue;
        succes = TRUE;
        ptr    = (DRAWSEGMENT*) PtStruct;
        d = (ptr->m_Width / 2) + 1;
        if( ptr->m_Shape == S_CIRCLE )
        {
            cx    = ptr->m_Start.x; cy = ptr->m_Start.y;
            rayon =
                (int) hypot( (double) ( ptr->m_End.x - cx ),
                            (double) ( ptr->m_End.y - cy ) );
            rayon += d;
            GetBoard()->m_BoundaryBox.m_Pos.x = MIN(
                GetBoard()->m_BoundaryBox.m_Pos.x, cx - rayon );
            GetBoard()->m_BoundaryBox.m_Pos.y = MIN(
                GetBoard()->m_BoundaryBox.m_Pos.y, cy - rayon );
            xmax = MAX( xmax, cx + rayon );
            ymax = MAX( ymax, cy + rayon );
        }
        else
        {
            cx = MIN( ptr->m_Start.x, ptr->m_End.x );
            cy = MIN( ptr->m_Start.y, ptr->m_End.y );
            GetBoard()->m_BoundaryBox.m_Pos.x = MIN(
                GetBoard()->m_BoundaryBox.m_Pos.x, cx - d );
            GetBoard()->m_BoundaryBox.m_Pos.y = MIN(
                GetBoard()->m_BoundaryBox.m_Pos.y, cy - d );
            cx   = MAX( ptr->m_Start.x, ptr->m_End.x );
            cy   = MAX( ptr->m_Start.y, ptr->m_End.y );
            xmax = MAX( xmax, cx + d );
            ymax = MAX( ymax, cy + d );
        }
    }

    GetBoard()->m_BoundaryBox.SetWidth(
        xmax - GetBoard()->m_BoundaryBox.m_Pos.x );
    GetBoard()->m_BoundaryBox.SetHeight(
        ymax - GetBoard()->m_BoundaryBox.m_Pos.y );
    return succes;
}


/********************************************/
int Propagation( WinEDA_PcbFrame* frame )
/********************************************/
Loading