Commit 6691eca2 authored by charras's avatar charras
Browse files

taking in account filled zones areas in pcb cleanup and tracks creation

parent 4f1c1469
Loading
Loading
Loading
Loading
+34 −5
Original line number Diff line number Diff line
@@ -216,17 +216,13 @@ wxPoint& BOARD::GetPosition()

void BOARD::UnLink()
{
    /* Modification du chainage arriere */
    /* Update back link */
    if( Back() )
    {
        if( Back()->Type() == TYPEPCB )
        {
            Back()->SetNext( Next() );
        }
        else /* Le chainage arriere pointe sur la structure "Pere" */
        {
//			Pback-> = Pnext;
        }
    }

    /* Modification du chainage avant */
@@ -1082,6 +1078,39 @@ void BOARD::RedrawFilledAreas(WinEDA_DrawPanel* panel, wxDC * aDC, int aDrawMode
}


/**
 * Function HitTestForAnyFilledArea
 * tests if the given wxPoint is within the bounds of a filled area of this zone.
 * the test is made on zones on layer from aStartLayer to aEndLayer
 * Note: if a zone has its flag BUSY (in .m_State) is set, it is ignored.
 * @param refPos A wxPoint to test
 * @param aStartLayer the first layer to test
 * @param aEndLayer the last layer (-1 to ignore it) to test
 * @return ZONE_CONTAINER* return a pointer to the ZONE_CONTAINER found, else NULL
 */
ZONE_CONTAINER*  BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos, int aStartLayer, int aEndLayer )
{
    if( aEndLayer < 0 )
        aEndLayer = aStartLayer;
    if( aEndLayer <  aStartLayer)
        EXCHG (aEndLayer, aStartLayer);

    for( unsigned ia = 0; ia < m_ZoneDescriptorList.size(); ia++ )
    {
        ZONE_CONTAINER* area = m_ZoneDescriptorList[ia];
        int layer = area->GetLayer();
        if ( (layer < aStartLayer) || (layer > aEndLayer) )
                continue;
        if ( area->GetState( BUSY ) )     // In locate functions we must skip tagged items with BUSY flag set.
            continue;
        if( area->HitTestFilledArea( aRefPos ) )
            return area;
    }

    return NULL;
}



#if defined(DEBUG)

+11 −0
Original line number Diff line number Diff line
@@ -355,6 +355,17 @@ public:
    /*************************/
    /* Copper Areas handling */
    /*************************/
    /**
     * Function HitTestForAnyFilledArea
     * tests if the given wxPoint is within the bounds of a filled area of this zone.
     * the test is made on zones on layer from aStartLayer to aEndLayer
     * Note: if a zone has its flag BUSY (in .m_State) is set, it is ignored.
     * @param refPos A wxPoint to test
     * @param aStartLayer the first layer to test
     * @param aEndLayer the last layer (-1 to ignore it) to test
     * @return ZONE_CONTAINER* return a pointer to the ZONE_CONTAINER found, else NULL
     */
    ZONE_CONTAINER*  HitTestForAnyFilledArea( const wxPoint& aRefPos, int aStartLayer, int aEndLayer = -1 );

    /**
     * Function RedrawAreasOutlines
+25 −0
Original line number Diff line number Diff line
@@ -797,6 +797,31 @@ bool ZONE_CONTAINER::HitTest( EDA_Rect& refArea )
    return is_out_of_box ? false : true;
}

/**
 * Function HitTestFilledArea
 * tests if the given wxPoint is within the bounds of a filled area of this zone.
 * @param aRefPos A wxPoint to test
 * @return bool - true if a hit, else false
 */
bool ZONE_CONTAINER::HitTestFilledArea( const wxPoint& aRefPos )
{
    unsigned indexstart = 0, indexend;
    bool     inside  = false;
    for( indexend = 0; indexend < m_FilledPolysList.size(); indexend++ )
    {
        if( m_FilledPolysList[indexend].end_contour )       // end of a filled sub-area found
        {
            if( TestPointInsidePolygon( m_FilledPolysList, indexstart, indexend, aRefPos.x, aRefPos.y ) )
            {
                inside = true;
                break;
            }
        }
    }
    return inside;
}



/************************************************************/
void ZONE_CONTAINER::Display_Infos( WinEDA_DrawFrame* frame )
+9 −0
Original line number Diff line number Diff line
@@ -166,11 +166,20 @@ public:
    /**
     * Function HitTest
     * tests if the given wxPoint is within the bounds of this object.
     * For zones, this means near an ouline segment
     * @param refPos A wxPoint to test
     * @return bool - true if a hit, else false
     */
    bool HitTest( const wxPoint& refPos );

    /**
     * Function HitTestFilledArea
     * tests if the given wxPoint is within the bounds of a filled area of this zone.
     * @param aRefPos A wxPoint to test
     * @return bool - true if a hit, else false
     */
    bool    HitTestFilledArea( const wxPoint& aRefPos );

    /** function BuildFilledPolysListData
     * Build m_FilledPolysList data from real outlines (m_Poly)
     * in order to have drawable (and plottable) filled polygons
+57 −12
Original line number Diff line number Diff line
@@ -169,6 +169,7 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC )
    TRACK*          other;
    TRACK*          startNetcode;
    TRACK*          next;
    ZONE_CONTAINER* zone;

    int             nbpoints_supprimes = 0;
    int             masklayer, oldnetcode;
@@ -234,7 +235,7 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC )
            oldnetcode = segment->GetNet();
        }

        flag_erase = 0;
        flag_erase = 0; //Not connected indicator
        type_end = 0;

        /* Is a pad found on a track end ? */
@@ -258,27 +259,51 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC )
        }

        // if not connected to a pad, test if segment's START is connected to another track
        // For via tests, an enhancement could to test if connected to 2 items on different layers.
        // Currently a via must be connected to 2 items, taht can be on the same layer
        int top_layer, bottom_layer;
        if( (type_end & START_ON_PAD ) == 0 )
        {
            other = Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track,
                                               NULL, START );
            if( other == NULL )
            other = Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track, NULL, START );

            if( other == NULL )     // Test a connection to zones
            {
                if( segment->Type() != TYPEVIA )
                {
                    zone = frame->m_Pcb->HitTestForAnyFilledArea(segment->m_Start, segment->GetLayer() );
                }

                else
                {
                    ((SEGVIA*)segment)->ReturnLayerPair( &top_layer, &bottom_layer );
                    zone = frame->m_Pcb->HitTestForAnyFilledArea(segment->m_Start, top_layer, bottom_layer );
                }
            }

            if( (other == NULL) && (zone == NULL) )
                flag_erase |= 1;

            else    // segment or via connected to this end
            else    // segment, via or zone connected to this end
            {
                segment->start = other;

                if( other->Type() == TYPEVIA )
                // If a via is connected to this end, test if this via has a second item connected
                // if no, remove it with the current segment
                if( other && other->Type() == TYPEVIA )
                {
                    // search for another segment following the via

                    segment->SetState( BUSY, ON );

                    TRACK* via = other;
                    SEGVIA* via = (SEGVIA*) other;
                    other = Locate_Piste_Connectee( via, frame->m_Pcb->m_Track,
                                                       NULL, START );
                    if( other == NULL )
                    {
                        via->ReturnLayerPair( &top_layer, &bottom_layer );
                        zone = frame->m_Pcb->HitTestForAnyFilledArea(via->m_Start, bottom_layer, top_layer );
                    }

                    if( (other == NULL) && (zone == NULL) )
                        flag_erase |= 2;

                    segment->SetState( BUSY, OFF );
@@ -291,22 +316,42 @@ static void DeleteUnconnectedTracks( WinEDA_PcbFrame* frame, wxDC* DC )
        {
            other = Locate_Piste_Connectee( segment, frame->m_Pcb->m_Track,
                                               NULL, END );
            if( other == NULL )
            if( other == NULL )     // Test a connection to zones
            {
                if( segment->Type() != TYPEVIA )
                    zone = frame->m_Pcb->HitTestForAnyFilledArea(segment->m_End, segment->GetLayer() );

                else
                {
                    ((SEGVIA*)segment)->ReturnLayerPair( &top_layer, &bottom_layer );
                    zone = frame->m_Pcb->HitTestForAnyFilledArea(segment->m_End,top_layer, bottom_layer  );
                }
            }

            if ( (other == NULL) && (zone == NULL) )
                flag_erase |= 0x10;

            else     // segment or via connected to this end
            else     // segment, via or zone connected to this end
            {
                segment->end = other;
                if( other->Type() == TYPEVIA )
                // If a via is connected to this end, test if this via has a second item connected
                // if no, remove it with the current segment
                if( other && other->Type() == TYPEVIA )
                {
                    // search for another segment following the via

                    segment->SetState( BUSY, ON );

                    TRACK* via = other;
                    SEGVIA* via = (SEGVIA*) other;
                    other = Locate_Piste_Connectee( via, frame->m_Pcb->m_Track,
                                                       NULL, END );
                    if( other == NULL )
                    {
                        via->ReturnLayerPair( &top_layer, &bottom_layer );
                        zone = frame->m_Pcb->HitTestForAnyFilledArea(via->m_End, bottom_layer, top_layer );
                    }

                    if( (other == NULL) && (zone == NULL) )
                        flag_erase |= 0x20;

                    segment->SetState( BUSY, OFF );
Loading